starting as a windows service
#1
Scooby Regular
Thread Starter
Join Date: Jun 2002
Location: Berkshire
Posts: 1,280
Likes: 0
Received 0 Likes
on
0 Posts
I have a command line (its an ip-tunnel application) which i currently run on one of my machines at startup which is fine but its currently run from a batch file and sits on the task bar all the time which is a bit messy and vunerable to being shut down accidently. Is there any way to execute this command line on startup as a service or otherwise hidden?
#2
Scooby Regular
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
theres a utility in the resource kit.. bit.. apps shouldnt really be run as services.. mail me if you cant find it..
David
David
#3
Scooby Regular
You need the files instsrv.exe and srvany.exe to install and run the utility as a service. Copy both to your %systemroot%\System32\ folder i.e. c:\winnt\system32 OR c:\windows\system32 (if XP)
The install command from a batch file would be:-
%systemroot%\system32\instsrv servicename %systemroot%\system32\srvany.exe
This will create a servive entry under HKLM\system\currentcontrolset\services\
You'll need to create a Paramter key under the new service with the following string values:-
AppDirectory
Application
The value of AppDirectory would be the folder holding the application executable and the Application value would hold the name and full path to the .exe file.
e.g. AppDirectory = "C:\appfolder" & Application = "C:\appfolder\app.exe"
I use a batch file to install the seti client as a service, so I mail you my install script for an idea of how it's done.
Stefan
The install command from a batch file would be:-
%systemroot%\system32\instsrv servicename %systemroot%\system32\srvany.exe
This will create a servive entry under HKLM\system\currentcontrolset\services\
You'll need to create a Paramter key under the new service with the following string values:-
AppDirectory
Application
The value of AppDirectory would be the folder holding the application executable and the Application value would hold the name and full path to the .exe file.
e.g. AppDirectory = "C:\appfolder" & Application = "C:\appfolder\app.exe"
I use a batch file to install the seti client as a service, so I mail you my install script for an idea of how it's done.
Stefan
#4
Scooby Regular
OK, I would e-mail you if you had an e-mail address in your profile.
Here's the batch script:-
rem
rem create Seti directory
rem
mkdir %systemroot%\System32\SAH
%systemroot%\System32\Attrib +h %systemroot%\System32\SAH
rem
rem copy files
rem
copy instsrv.exe %systemroot%\System32\instsrv.exe
copy srvany.exe %systemroot%\System32\srvany.exe
copy SAH.exe %systemroot%\System32\SAH\SAH.exe
copy user_info.sah %systemroot%\System32\SAH\user_info.sah
copy setiwatch.exe %systemroot%\System32\SAH\setiwatch.exe
rem
rem Create new services
rem
%systemroot%\System32\instsrv SAH %systemroot%\System32\srvany.exe
And here's the registry (.reg) file needed for the new service:-
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\SAH]
"Type"=dword:00000010
"Start"=dword:00000002
"ErrorControl"=dword:00000001
"ImagePath"=hex(2):25,53,79,73,74,65,6d,52,6f,6f,7 4,25,5c,53,79,73,74,65,6d,33,\
32,5c,53,52,56,41,4e,59,2e,45,58,45,00
"DisplayName"="SAH"
"ObjectName"="LocalSystem"
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\SAH\Parameters]
"AppDirectory"="C:\\WINNT\\System32\\SAH\\"
"Application"="C:\\WINNT\\System32\\SAH\\sah.e xe"
"AppParameters"=""
If you need the two files, e-mail me and I'll send you them.
Stefan
Here's the batch script:-
rem
rem create Seti directory
rem
mkdir %systemroot%\System32\SAH
%systemroot%\System32\Attrib +h %systemroot%\System32\SAH
rem
rem copy files
rem
copy instsrv.exe %systemroot%\System32\instsrv.exe
copy srvany.exe %systemroot%\System32\srvany.exe
copy SAH.exe %systemroot%\System32\SAH\SAH.exe
copy user_info.sah %systemroot%\System32\SAH\user_info.sah
copy setiwatch.exe %systemroot%\System32\SAH\setiwatch.exe
rem
rem Create new services
rem
%systemroot%\System32\instsrv SAH %systemroot%\System32\srvany.exe
And here's the registry (.reg) file needed for the new service:-
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\SAH]
"Type"=dword:00000010
"Start"=dword:00000002
"ErrorControl"=dword:00000001
"ImagePath"=hex(2):25,53,79,73,74,65,6d,52,6f,6f,7 4,25,5c,53,79,73,74,65,6d,33,\
32,5c,53,52,56,41,4e,59,2e,45,58,45,00
"DisplayName"="SAH"
"ObjectName"="LocalSystem"
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\SAH\Parameters]
"AppDirectory"="C:\\WINNT\\System32\\SAH\\"
"Application"="C:\\WINNT\\System32\\SAH\\sah.e xe"
"AppParameters"=""
If you need the two files, e-mail me and I'll send you them.
Stefan
Thread
Thread Starter
Forum
Replies
Last Post
hardcoreimpreza
Computer & Technology Related
21
11 October 2015 03:40 PM