System.IO.FileNotFoundException occurred while registering the window service: Failed to load file or assembly "Xxx.exe" file, or one of its dependencies could not be loaded, it is possible that your registration microsoft.net\ The framework version is different,
This exception is reported when your program compiles at 4.0 but uses 2.0 to register, solution: Change the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe version to Microsoft.net\framework\v4.0.30319\installutil.exe is OK.
Register the Bat command:
Echo Press any key to start installing Windows Information Auto-Push service ...
Echo.
Pause
Echo.
Echo Cleanup Original service items ...
%systemroot%\microsoft.net\framework\v4.0.30319\installutil/u D:\YouWinService.exe > InstallService.log
Echo
echo clean up, start install background service ...
Echo
%systemroot%\microsoft.net\framework\v4.0.30319\installutil D:\YouWinService.exe >> InstallService.log
Echo Service installation Complete, start service ...
Echo
When the echo operation is finished, see the specific operation results in InstallService.log.
Echo.
Pause
Uninstall Service
@echo Press any key to start uninstalling Windows Information Auto-Push service ...
@echo
@pause
@echo is cleaning up the original service program ...
%systemroot%\microsoft.net\framework\v4.0.30319\installutil/u D:\YouWinService.exe > InstallService.log
@echo
@echo clean up, see the results of the operation in InstallService.log.
@pause
Window Service Registration exception