Skip to content

Instantly share code, notes, and snippets.

Last active December 22, 2022 06:39
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
installing and removing a user-defined service.
@echo off
set ServicePath=HKLM\System\CurrentControlSet\Services
if "%1"=="-i" goto :create
if "%1"=="-d" goto :delete
goto :usage
md %windir%\system32\srvice\%2\ & copy /y srvany.exe %windir%\system32\srvice\%2\
sc query %2 || sc create %2 start= %3 binPath= %windir%\system32\srvice\%2\srvany.exe DisplayName= %2
reg add %ServicePath%\%2\Parameters /v Application /d %4 /f
reg add %ServicePath%\%2\Parameters /v AppDirectory /d %5 /f
if defined %6 reg add %ServicePath%\%2\Parameters /v AppParameters /d %6 /f
) 1>nul 2>nul
goto :done
sc query state= | find "%2" && sc stop %2
sc query %2 && sc delete %2
rd /q /s %windir%\system32\srvice\%2\
rd %windir%\system32\srvice\
) 1>nul 2>nul
goto :done
echo. Services Manager 0.1.0 - unmric
echo. Usage: srvmgr [-vadl?] [-i .. ] [-d ServiceName]
echo. Arguments:
echo. -i - Sends a Continue control request to a service.
echo. *ServiceName = (string)
echo. *StartType = (boot, system, auto, demand, disabled)
echo. *binPath = (string)
echo. *BinDirectory = (string)
echo. BinArguments = (string)
echo. -d - Deletes a service (from the registry).
echo. *ServiceName = (string)
echo. Examples:
echo. srvmgr -i test auto c:\test.exe c:\
echo. srvmgr -d test
goto Done
echo on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment