Error 193 “Not a valid Win32 application” can occur when starting a Windows service. What this error means and how you can fix it, I explain in this article.
Error 193 – In Short
If you get error 193 “Not a valid Win32 application” when starting a Windows service, it is often because the corresponding Windows service was not correctly registered with the Windows Service Manager. To better understand this, you need to know what sets a Windows service apart from a regular Windows program.
Windows Service – What Exactly Is It?
A Windows service is not just a normal Windows program that you start with a mouse click. A Windows service is a program that runs in the background and has no user interface. When such a Windows service is running, you won’t see anything of it on your monitor.
To be able to start and stop these so-called Windows services, there is the Windows Service Manager. You can reach it by typing “services.msc” in the search field of the taskbar. In German, this service manager program is simply called “Dienste.”
For a program to run as a Windows service, it must be registered with the “Services” program. This happens, for example, with the help of the command-line tool “sc.exe”.
Error 193 – The Cause
But how does error 193 “Not a valid Win32 application” occur? The Windows Service Manager has a “special” way of handling command-line arguments. Error 193 occurs, among other reasons, when a directory name contains a space (e.g., C:\Users\Fridolin Froehlich) and in the parent directory (C:\Users) there is a file whose file name consists of the first word of the directory (e.g., “C:\Users\Fridolin”). Sounds complicated, so let’s do an example:
“Not a valid Win32 application” – Example:
Suppose your Windows user is named “Fridolin Froehlich” and his home directory is C:\Users\Fridolin Froehlich
But in the directory C:\Users there is also a file named Fridolin
Suppose the Windows service you want to register is located in the directory C:\Users\Fridolin Froehlich\Repositories\Mein Windows-Service\bin
You register the Windows service in PowerShell with administrator rights using the command:sc.exe create "Mein Windows-Service" binpath="C:\Users\Fridolin Froehlich\Repositories\Mein Windows-Service\bin\Mein Windows-Service.exe"
After that, the creation of the Windows service is confirmed:
[SC] CreateService SUCCESS
That looks good at first. We enclosed the binpath in double quotes, since there are spaces, and sc.exe seemed to create the service successfully.
IMPORTANT: This confirmation message is not a guarantee that the service can actually be found and started by the Windows Service Manager.
If you now try to start the service, it fails:
sc.exe start "Mein Windows-Service"
[SC] StartService FAILED, error 193.
To understand this, you need to know how the Services Manager handles the binpath argument.
The Windows Services Manager and its Command-Line Arguments … 🤯😫
When creating the Windows service, you did enclose the binpath in quotes, but Windows only takes the text inside the quotes to determine the service’s binpath. You can see this if you open the Services Manager (search in the Taskbar, or type services.msc in the command line) and view the service’s details. Just look for the service “Mein Windows-Service” in the list and double-click it. In the small window, you see the entry “Path to executable.” There, the path looks like this:
C:\Users\Fridolin Froehlich\Repositories\Mein Windows-Service\bin\Mein Windows-Service.exe
The quotes are missing, even though we used quotes on the command line 🤦♂️. That’s what I mean by “the Windows Services Manager only uses the text within the quotes.”
So, now our binpath looks as above. Great. When the Windows Services Manager wants to start the service, it sends the command C:\Users\Fridolin Froehlich\Repositories\Mein Windows-Service\bin\Mein Windows-Service.exe to the command processor. The processor handles the command as if it had been entered directly at the command line. Spaces at the command line work as delimiters. Between the program you want to call and the command-line arguments there must be a space, and if you have multiple command-line arguments, they must also be separated by spaces.
So, how does the command processor interpret the call to the Windows service? The command processor “thinks” like this:
- Call the program
C:\Users\Fridolin.
- Call the program
- First argument:
Froehlich\Repositories\Mein
- First argument:
- Second argument:
Windows-Service\bin\Mein
- Second argument:
- Third argument:
Windows-Service.exe
- Third argument:
The command processor then tries to find and execute the file C:\Users\Fridolin. If this file exists but is not a Windows program, you get error 193 “Not a valid Win32 application.” Understandable …
How to Fix Error 193?
- Option A: Add quotes to the binpath
This is the cleanest solution. To avoid error 193 when starting a Windows service, you must use escaped quotes in the binpath:
sc.exe create "Mein Windows-Service" binpath="\"C:\Users\Fridolin Froehlich\Repositories\Mein Windows-Service\bin\Mein Windows-Service.exe\""Important here is the backslash (\) before the additional quotes.
- Option A: Add quotes to the binpath
- Option B: Find and rename the problematic file
In the example above, the file
C:\Users\Fridolinis the problem. If you still need the file, you should simply rename it. It’s enough to give the file a new extension (e.g.,.txt). You can do this with the commandren C:\Users\Fridolin C:\Users\Fridolin.txt.If you no longer need the file, you can simply delete it, for example with the command
del C:\Users\FridolinBut doesn’t the problem with the space as a separator remain? Interestingly, no. Since the file
C:\Users\Fridolin
no longer exists, the command processor no longer tries to call it. Instead, it then ignores the spaces and can start the Windows service 🤦♂️ 🤷♂️
- Option B: Find and rename the problematic file
- Option C: Choose a different directory to store the Windows service
Usually, the user directory (in our case
C:\Users\Fridolin Froehlich) is the problem, since it often consists of several words (first name, last name). So, we need to pick or create a directory that is not within the user directory. For example,C:\Projekte\Mein Windows-ServiceThis directory can be created with the commandmd "C:\Projekte\Mein Windows-Service"Next, copy your service exe to this directory:
copy "C:\Users\Fridolin Froehlich\Repositories\Mein Windows-Service\bin\Mein Windows-Service.exe" "C:\Projekte\Mein Windows-Service\"
- Option C: Choose a different directory to store the Windows service
Error: “Set-Content : A positional parameter cannot be found that accepts argument ‘binpath=”
This error occurs when you use only the command sc in PowerShell instead of sc.exe
The command sc in Windows PowerShell launches the cmdlet “Set-Content.” However, that’s not what we need. We need sc.exe – a command-line program for communicating with the Service Control Manager and with Windows services.
Sources
How to: register service with SC command without losing quotes in binpath value
When creating a service with sc.exe how to pass in context parameters?

