mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

 Creating a service with a vbscript

Author Message
DennisT

  • Total Posts : 1
  • Scores: 3
  • Reward points : 0
  • Joined: 12/9/2008
  • Status: offline
Creating a service with a vbscript Tuesday, December 09, 2008 10:21 AM (permalink)
4.5
Hi,
I'm new to this forum.  Recently I was working on a script that needed to be always running.  The script monitors a shared folder and when a file is placed in that folder it processes it.
 
After writing my script I went to run it as a service and found that Windows requires a exe.  A review of vbs to exe tools wasn't successful.  Maybe it was my programming but every one I tried didn't create a fully functional exe.  After a little research and some testing I came up with a method to create a service that uses a vbs script.  The price is right [sm=thumbsup.gif]  Hopefully someone will find this useful:
 
Install the Resource Kit if you haven’t already or acquire the instsrv.exe and srvany.exe files.  Your vbscript file should be complete and debugged.  Warning – This procedure assumes you are competent as an administrator and know how to use regedit.
Note: in the example below we use vbsService.  Substitute a name that is appropriate.
 
At the command prompt type:
instsrv.exe vbsService \Program Files\Windows Resource Kits\Tools\srvany.exe

It will create  
a service named vbsService. You can see "The Service was successfully created" message.

Run REGEDIT and find the "vbsService”.

It will be under HKeyLocalMachine\SYSTEM\CurrentControlSet\Services\vbsService.

Create a "Parameters" key.
Open the "Parameters" key
Create an "Application" string value (REG_SZ) within the "Parameters" key
Edit "Application" and specify the full path of your application executable (including the extension) . Make sure that your path is correct.  (IE C:\WINDOWS\system32\wscript.exe)

 Note:  The application exe is wscript.exe.  This will appear as a process in task manager.  If you wish, you can make a copy of wscript.exe (ie. vbsService.exe) and then the process name in task manager is a little more informative.
 
Under the “Parameters" key add the following:
AppParameters (String) – enter a value of /B /nologo YourvbsScript.vbs
where YourvbsScript.vbs is the vbs script you’ve written.  The nologo is probably not needed.
AppDirectory (String) - Specify the current directory to use for your application.

 
You may also want to update/add the string Description (IE under vbsService) to describe the service.
 
The service will run with the default permissions (local system account).  If you need to change them you can do this in Control Panel -> Administrative Tools -> Services -> vbsService -> Log On.
 
Reboot (it is Windows).
 
If you want to remove a service use this syntax: instsrv.exe vbsService remove
 
#1
    imorris

    • Total Posts : 1
    • Scores: -2
    • Reward points : 0
    • Joined: 3/18/2011
    • Status: offline
    Re: Creating a service with a vbscript Friday, March 18, 2011 6:22 AM (permalink)
    1
    I registered just to extend my grattitude for your instructions.  They worked perfectly.  Thank you so much!
    #2
      everstrike

      • Total Posts : 12
      • Scores: 0
      • Reward points : 0
      • Joined: 4/12/2007
      • Status: offline
      Re: Creating a service with a vbscript Wednesday, November 30, 2011 8:24 PM (permalink)
      0
      You can do this conversion (VBS script to Windows Service) using ExeToService.
      #3
        ebgreen

        • Total Posts : 8081
        • Scores: 94
        • Reward points : 0
        • Joined: 7/12/2005
        • Status: offline
        Re: Creating a service with a vbscript Thursday, December 01, 2011 4:31 AM (permalink)
        0
        Or the solution that I prefer for this specific situation (monitoring a folder for file creation) would be to use what windows already supplies natively. The WMI service that is already running allows you to register event sinks through it to run code based on events such as file creation. There are examples of this here in the forum.
        "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
        Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
        http://www.visualbasicscript.com/m_47117/tm.htm
        #4

          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • New Messages
          • No New Messages
          • Hot Topic w/ New Messages
          • Hot Topic w/o New Messages
          • Locked w/ New Messages
          • Locked w/o New Messages
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2012 ASPPlayground.NET Forum Version 3.8
          mbt shoes www.wileywilson.com