Connecting Tech Pros Worldwide Forums | Help | Site Map

Run a bat in the background

Member
 
Join Date: Mar 2008
Posts: 114
#1: Aug 7 '09
I have a .bat file that I currently click to run, I really would like this to constantly run in the background. Does anyone know how to do this?

System: Windows XP

Thanks in advance
Matt

harshadd's Avatar
Familiar Sight
 
Join Date: Dec 2007
Posts: 177
#2: Aug 13 '09

re: Run a bat in the background


I can suggest 2 ways to do the same
ONE:
download cmdow.exe (google 0n it & it will be in first few results)
then edit ur bat file as below:
first line of ur bat file should be
cmdow @ /HID
and last line or ur Bat file will be
%0

TWO: another way is very simple
Write a VB script as below:
and save it as runbat.vbs - or some thing similar

dim shell
set shell=createobject("wscript.shell")
shell.run "test.cmd" ,0
set shell=nothing
last line or ur Bat file will be obviously %0

as %0 is a system variable which represents the bathfile name itself.
But NOTE: you can not stop the batch file if u run it in invisible mode, you have to logout or use cmdow in any case to make it visible again and then stop.


Logic:
shell.run "test.cmd" ,0
in above line from ur Vb Script file "0" is for invisible mode.

Harshad D - Mumbai
Member
 
Join Date: May 2009
Posts: 81
#3: Aug 15 '09

re: Run a bat in the background


It depends on what you mean by "all the time". If you want to just suck up 100% of your CPU with it, then a batch file like this:
:A
rem do whatever you want to do
goto A
will do the trick.

The NT shell also comes with the "at" command which allows you to schedule tasks to be run in the future.

Last, and probably the most flexible method is to modify your script for PowerShell and make use of .NET's scheduling abilities.
Reply


Similar Microsoft Windows / Vista / XP / ME / 95 & 98 bytes