Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Run bat file as service

2 views
Skip to first unread message

Wayne Jones

unread,
Aug 23, 2002, 12:03:53 PM8/23/02
to
How would you run a bat file as a service? I have a bat
file that must be running for users to access an
application, but I cannot log off the server, only lock
it. The resource kit has a tool to run an exe as a
service, but I could not get it to run a bat.
Thanks - Wayne

Torgeir Bakken

unread,
Aug 23, 2002, 1:38:06 PM8/23/02
to
Wayne Jones wrote:

Hi

Did you use double backslashes in the paths when entering the path to the batch
file?

The example in MS KB article Q152460 uses this example:

c:\\winnt\\system32\\cmd.exe /k


Two things you can try as a workaround if it refuses to start files with
extension .bat:

1)
When configuring the startup, try this:

c:\\winnt\\system32\\cmd.exe /c c:\\batfiles\\test.bat

(modify to reflect your own Windows NT path and batch file path)

2)
or create a vbscript that starts the batch file.

In svrany, put in this command line:

cscript //B //Nologo <path to vbs file>

or maybe

c:\\winnt\\system32\\cscript //B //Nologo <path to vbs file>


Here is a script that can be used:

' *** Script Start ***

sBatchFile = "c:\bat files\test.bat"

Set oShell = CreateObject("WScript.Shell")

' Chr(34) is a quote, added to support spaces in the file path
' If input parameters are to be added to the batch file,
' they must be added behind the last Chr(34)
oShell.Run Chr(34) & sBatchFile & Chr(34), 0, True

' *** Script Stop ***


MS Knowledge Base articles

HOWTO: Create a User-Defined Service (Q137890)
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q137890


Troubleshooting SrvAny Using Cmd.exe (Q152460)
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q152460


Windows 2000 Magazine Articles

Feb 2000 / Srvany
http://www.win2000mag.com/Articles/Index.cfm?ArticleID=7959&Key=Tips

Mar 2000 / More About Srvany
http://www.win2000mag.com/Articles/Index.cfm?ArticleID=8148&Key=NT%20Services


This postings indicates that SrvAny can be used directly for batch files

From: Dave Pink (tron...@msn.com)
Subject: Re: Need notification when a batch file stops running
Newsgroups: alt.msdos.batch.nt, alt.msdos.batch
Date: 2001-11-27 08:30:03 PST
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=fa516b59.0111270830.31bc6c80%40posting.google.com

From: Dave Pink (tron...@msn.com)
Subject: How can I be notified when a batch file stops running?
Newsgroups: alt.msdos.batch.nt
Date: 2001-11-21 07:24:44 PST
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&th=f23e3d88d0487f74&rnum=6

The freeware FireDaemon (www.firedaemon.com) is also mentioned as a substitute
for SRVANY.EXE


--
torgeir


Wayne

unread,
Aug 26, 2002, 9:57:44 AM8/26/02
to
Yes, I tried entering the double backslashes, and I tried
running a regular exe file also, but had no luck.
Thanks - Wayne
>.
>
0 new messages