Tuesday, May 25, 2010

A very quick and dirty way to create a service from a vbscript file

Creating service from VB Script

1. Execute the below Command:
instsrv.exe C:\windows\System32\srvany.exe

Note: 'Service Created' message indicates Service Created Successfully

2. Copy the srvany.exe file from C:\windows\System32 at the same path of your script

3. Open Registry Editor and create a Key "Parameters" under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\

4. under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\\Parameters, create the following values
AppDirectory REG_SZ "C:\Current Work\Service\" < Directory path of your VB Script
Application REG_SZ wscript.exe < u can change to Wscript or cscript>
AppParameters REG_SZ "C:\Current Work\Service\one.vbs" < your VB Script Name with path

5. Open Services under Control Panel and select the Service Name which create at Step 1

Click on properties, open Logon Tab and select the Check Box 'Allow Service to Interact with Desktop'
Click ok on Properties window
Now Start the service.

Note: Whenever you change anything in your script, restart the Service

1 comment:

  1. srvany.exe is part of resource kit. Those who want to read a bit more on how to create a custom service please head to :
    http://support.microsoft.com/kb/137890

    A big thanks to kiran for summarizing this for me :-)

    Cheers guys!
    Sree

    ReplyDelete