Jump to content

Install and start a service


creeping
 Share

Recommended Posts

Erm, pretty simple and straight forward. Creates and starts a service, probably not worth posting here but o well.

#include <Process.au3>

$instsrvExe  = "instsrv.exe"
$srvanyExe   = "srvany.exe"
$serviceExe  = "POSTMGR.EXE"
$exeDest     = @WindowsDir
$service     = "Jit_Postmgr"
$servicesKey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\"
$paramKey    = "Parameters"
$appKey      = "Application"

FileInstall("C:\Documents and Settings\J\Desktop\instsrv.exe", @SystemDir & "\", 1)
FileInstall("C:\Documents and Settings\J\Desktop\srvany.exe", @SystemDir & "\", 1)
FileInstall("C:\Documents and Settings\J\Desktop\POSTMGR.EXE", $exeDest & "\", 1)

_RunDOS(@SystemDir & "\" & $instsrvExe & " " & $service & " " & @SystemDir & "\" & $srvanyExe)

RegWrite($servicesKey & $service & "\" & $paramKey)
RegWrite($servicesKey & $service & "\" & $paramKey, $appKey, "REG_SZ", $exeDest & "\" & $serviceExe)

_RunDOS("NET START " & $service)
Link to comment
Share on other sites

Seems to be very usefull... but could you explain a little more what are you exactly doing?

If I create a program called MyService... How can I use your code?

Do I need something extra? :)

Where do I get "instsrv.exe" and "srvany.exe"?

Link to comment
Share on other sites

Link to comment
Share on other sites

Yea, Im sure there better ways to install and run a service, I simply took this from the microsoft website.

See here: http://support.microsoft.com/kb/q137890/

"instsrv.exe" and "srvany.exe" are found in Windows Server 2003 Resource Kit Tools

http://www.microsoft.com/downloads/details...;displaylang=en

Instrsrv.exe installs and removes system services from Windows NT and Srvany.exe allows any Windows NT application to run as a service.

#include <Process.au3>

$instsrvExe  = "instsrv.exe"
$srvanyExe   = "srvany.exe"
$serviceExe  = "POSTMGR.EXE"    <------- .exe file to create service from(in your case ....)
$exeDest     = @WindowsDir         <------- where to place this .exe
$service     = "Jit_Postmgr"           <------- service name (MyService in your case)
$servicesKey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\"
$paramKey    = "Parameters"
$appKey      = "Application"

FileInstall("C:\Documents and Settings\J\Desktop\instsrv.exe", @SystemDir & "\", 1)  <--- needs to change
FileInstall("C:\Documents and Settings\J\Desktop\srvany.exe", @SystemDir & "\", 1)  <--- needs to change
FileInstall("C:\Documents and Settings\J\Desktop\POSTMGR.EXE", $exeDest & "\", 1) <--- needs to change

_RunDOS(@SystemDir & "\" & $instsrvExe & " " & $service & " " & @SystemDir & "\" & $srvanyExe)

RegWrite($servicesKey & $service & "\" & $paramKey)
RegWrite($servicesKey & $service & "\" & $paramKey, $appKey, "REG_SZ", $exeDest & "\" & $serviceExe)

_RunDOS("NET START " & $service)
Edited by creeping
Link to comment
Share on other sites

@creeping: Since you have not been here long, I won't be too hard on you, but you need to take the time to learn about the search feature. If you use the search for these forums, you will see that there are many posts mentioning srvany and instsrv as a way to install a service, not to mention uses of sc.exe and others. There is even as much as a purely autoit service control functionality that allows you to create, delete and control services without any external programs. You can find out more about it here.

In the future, please search to see if there are any currently existing scripts that perform the functionality you would like to present before posting your version.

Who else would I be?
Link to comment
Share on other sites

I think sometimes using an external program is easier and cleaner for noob programers as creeping and me...

The other solution is more elegant!!! congrats to SumTingWong

But I keep creeping's solution by now because I'ts what I understand (by now)

Thanks this-is-me :lmao: for your valuable orientation...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...