Inserting a 'wait' command into a batch file

CaptainTrips

New Member
Simple question. I've created a batch file to do a number of things, but I need to insert a 'wait' time between some of the steps. I seem to remember being able to do this with a DLL in the past, but I could be wrong. I've found some ways to do it with additional programs, or creative ways (the method I am using now is to just ping the local host). is there a simple "wait 10000" or such?

Any ideas?

Just to clarify, this is not the "pause" command.

Thanks in advance!
 
Last edited:
why exactly do you need to insert the delay, if i may ask?

I've solved the problem, I'll explain below. What I had going was a batch file that put my monitor to sleep and locked my PC. I have roomates and wanted a step of protection. they're pretty green to computers, so a simple windows password would stop them if they came snooping.

So if I locked the PC, then put the monitor to sleep, the PC would lock, but the monitor wouldn't sleep. If I put the monitor to sleep, then locked the PC, the monitor would sleep, the PC would lock, waking up the monitor. I was hoping a delay might solve this.

But, I found a different neat utility that controls a lot of basic little functions of your PC, like putting your monitor to sleep (with an optional delay), open CD drives, volume changes, lots of window and icon manipulations etc. It's called nircmd.

So my batch file now reads:
rundll32.exe user32.dll, LockWorkStation
"C:\Nircmd\nircmd.exe" cmdwait 2000 monitor off

works like a charm.
 
Nice. Pretty decent stuff.
I don't use batch files that much. Though reading this I realise how capable they are of doing some quite cool stuff
 
But, I found a different neat utility that controls a lot of basic little functions of your PC, like putting your monitor to sleep (with an optional delay), open CD drives, volume changes, lots of window and icon manipulations etc
Is there a reason you want to script that kind of stuff? Because your OS can all that stuff as well.
 
If there is, I wasn't aware of it. How would I go about it in Win7 Pro?
This isn't the command I was thinking of but it should result in the monitor powering off after a minute of inactivity.

powercfg -change -monitor-timeout-ac 1

The command to set the system to hibernate/standby (depends on power config options) is rundll32 powrprof.dll, SetSuspendState

There is one for monitor too, but I can't seem to find it right now. Nircmd works, (as does some other 3rd party tools) but they do require you to install them on the machine you want to use your batch files on.
 
Last edited:
I knew a few of them could be done with system32 and such. I'm just not too savvy on what it can do, and how. Thanks.

Nircmd doesn't require an install. It's just a single exe, a command line tool with a lot of launch modifiers. Here's everything it can do. Some of them seem silly to me, like copying all your desktop shortcuts, but I suppose someone out there needs that feature.

... Nircmd works, (as does some other 3rd party tools) but they do require you to install them on the machine you want to use your batch files on.
 
Last edited:
Back
Top