net stop "My Service" %SystemRoot%\Microsoft.Net\Framework\v4.0.30319\installutil.exe /u MyService.exe %SystemRoot%\Microsoft.Net\Framework\v4.0.30319\installutil.exe MyService.exe net start "My Service"
The script worked fine but one day the batch was failed with the following error.
Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'file:///D:\Services\MyService.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format..As it turned out, the MyService.exe assembly happened to be 64bit binary and the installutil.exe was for 32 bit. So changing the installutil.exe path to 64 bit folder made it working.