Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Service running a VBS file

Status
Not open for further replies.

johnpayback

IS-IT--Management
Oct 2, 2006
110
US
Does anyone know if it is possible on a Windows 2000 Server to create a Windows service so that it runs a VBS file instead of having to use an EXE? My problem is that I have a vbscript that runs continously but it cannot run unless an account is logged into the server. I need to make it run regardless of any account being logged into the server. Ideas? Examples? Any help would be great.

JP
 
Why not using cscript.exe ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The script actually restarts a process that has to run with a specific local admin account.

You mention CScript. Do you mean create a service with cscript.exe <scriptname>? I did not think of that. Do you think that would be the best way for restarting a process?

JP
 
I have one question. What is the difference in running wscript rather than cscript when doing this? Any problem with using wscript or does it need to be cscript?

JP
 
>I have one question. What is the difference in running wscript rather than cscript when doing this? Any problem with using wscript or does it need to be cscript?

The differences mainly manifest themselves in the interactive with user.

[1] For both hosts _without_ options //b in place.

[1.1] wscript.echo
[1.1.1] On cscript, it will just display the message on the console and the execute goes on without the need of user to acknowledge whereas
[1.1.2] On wscript, user acknowledement is required.

[1.2] msgbox and inputbox functions
On both hosts, user acknowledgement is required.

[2] For both hosts _with_ options //b in place, ie, cscript.exe //b or wscript.exe //b, all display and interactive aspects of the script will be suppressed. The will be no difference execution-wise.

For a scheduled job or job executed on the server, it is a design pre-requisit to not to script in any interactive lines. For a transplant of a script which are conceived to use non-interactive adverse to be executed on the server or as a scheduled job, it would be advisable to use //b switch. If not, the second best is just to use cscript and pray that there is no msgbox/inputbox type in there without physically revising the script.

Does this answer your concern?
 
You might try Create your own user-defined services Windows NT/2000/XP/2003. This gives a brief explanation of (and a download link for) srvany.exe, an old NT tool.

For Win9x the rules are different of course.

Note that this may not work well with CScript/WScript. I don't know how those script hosts handle the logoff signal when users log off. The download has a .WRI file explaining this.

The instructions at the link above are not complete enough for running a script as a service. Be sure to read the .WRI file!


This has always been a bit of a hack, but it might do the trick for you.
 
The svrany works great but what I am really needing is to always make sure the script is running and if it fails I need it to start back automatically. Has anyone seen this before? The script runs continously already with it's coding but if someone kills the wscript or cscript process because they think it is a security violation then how can I insure it starts back without having to manually start it. Or even if the server reboots itself how can I make sure it starts back up?

JP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top