Avatar of jamorlando
jamorlandoFlag for United States of America

asked on 

Batch file that runs in the background

Hi,
Currently I have a batch file which is an infinite loop that runs in the background.  Task scheduler starts it, and it runs in the background without me needing to be logged in.

However, if kill the process, I can't figure out a way to start this back up in the background.

If I right click and run the task, it opens in a window.
I even found a simple VBScript to run a batch file using vbhide to hide the window.  However, using this, I'm unable to log out!

How can I emulate task scheduler behavior without explicitly using task scheduler?

Thanks,
Jamie
Microsoft DOSWindows XPVB Script

Avatar of undefined
Last Comment
jamorlando
Avatar of Krzysztof Pytko
Krzysztof Pytko
Flag of Poland image

You can try to download Windows 2003 Resource Kit and use InstSrv and SrvAny commands to set up your batch as service.

Try, maybe it would solve your problem.

Resource Kit you will find here
http://www.microsoft.com/downloads/en/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

and hot to set up batch as service, Microsoft's article explains it well
http://support.microsoft.com/kb/137890

Regards,
Krzysztof
ASKER CERTIFIED SOLUTION
Avatar of fhmc
fhmc

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Vishal Patel
Vishal Patel
Flag of India image

HI,
Try this out. Copy following four lines to any word editor and save this file as .vbs & run it. It will keep running without any visible output.

Dim oWsh, commands
Set oWsh = WScript.CreateObject ( "WScript.Shell")
command = "your command(with arguments) or batchfile(with fullpath) goes here"
oWsh.Run command, 0


Avatar of jamorlando
jamorlando
Flag of United States of America image

ASKER

@iSiek, thanks .. I've dabbled in creating services before but maybe I'll give it another shot

@fhmc, wouldn't that user have to be logged in at all times for the loop to continue to run?

@vjpatel, I'm not sure but I think:
oWsh.Run command, 0
is the same as
oWsh.Run command, vbhide
Which means that if the user logs out, the script stops running.
SOLUTION
Avatar of fhmc
fhmc

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of jamorlando
jamorlando
Flag of United States of America image

ASKER

@fhmc, this was the clever, simple solution I was looking for.
Tried it out and it works perfectly.

Now if the process stops, I can manually start it again without having to reboot the machine!
Windows XP
Windows XP

Microsoft Windows XP is the sixth release of the NT series of operating systems, and was the first to be marketed in a variety of editions: XP Home and XP Professional, designed for business and power users. The advanced features in XP Professional are generally disabled in Home Edition, but are there and can be activated. There were two 64-bit editions, an embedded edition and a tablet edition.

119K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo