SV650.org - SV650 & Gladius 650 Forum



Idle Banter For non SV and non bike related chat (and the odd bit of humour - but if any post isn't suitable it'll get deleted real quick).
There's also a "U" rating so please respect this. Newbies can also say "hello" here too.

Reply
 
Thread Tools
Old 04-06-09, 03:09 PM   #1
slloyd
Guest
 
Posts: n/a
Default How to delay a batch file in MS Win XP?

I have a batch file that needs to run about 1 min after windows has booted up to the desktop?

Looking at the DELAY command but don't seem to work.

Any ideas?
  Reply With Quote
Old 04-06-09, 03:17 PM   #2
Baph
Guest
 
Posts: n/a
Default Re: How to delay a batch file in MS Win XP?

Sleep 60

http://www.microsoft.com/windowsserv...s/default.mspx
  Reply With Quote
Old 04-06-09, 03:18 PM   #3
RatchetJob
Guest
 
Posts: n/a
Default Re: How to delay a batch file in MS Win XP?

There is no simple way to make the process sleep for a set time without an external utility.

However as a workaround insert a line similar to this:

ping 1.1.1.1 -n 60 -w 1000 > null

This will ping a non existent address 60 times with a 1000ms timeout with the result of causing a 1 minute delay.

It will redirect the ping output to null so that the ping will not display any output on screen.

HTH
  Reply With Quote
Old 04-06-09, 04:09 PM   #4
MiniMatt
Guest
 
Posts: n/a
Default Re: How to delay a batch file in MS Win XP?

didn't there used to be a pause function - press any key to continue thingy?
  Reply With Quote
Old 04-06-09, 04:16 PM   #5
SoulKiss
Member
Mega Poster
 
SoulKiss's Avatar
 
Join Date: Jul 2006
Location: Sunny Croydonia
Posts: 6,124
Default Re: How to delay a batch file in MS Win XP?

Quote:
Originally Posted by slloyd View Post
I have a batch file that needs to run about 1 min after windows has booted up to the desktop?

Looking at the DELAY command but don't seem to work.

Any ideas?
On linux I would launch the batch file (script) at boot time, have it evaluate the results of the uptime command - if uptime > 60 secs then leave the loop, else sleep for 10 seconds, then execute the body of the code then exit.

in pseudocode

while (loop!=1)
{
get uptime
if uptime < 60
{
sleep 10
}
else
{
loop=1
}
do stuff
end
__________________
Sent from my PC NOT using any Tapatalk type rubbish!!

█╬╬╬╬()i¯i▀▀▀▀▀█Ξ███████████████████████████████)

Last edited by SoulKiss; 04-06-09 at 04:17 PM.
SoulKiss is offline   Reply With Quote
Old 04-06-09, 04:24 PM   #6
Baph
Guest
 
Posts: n/a
Default Re: How to delay a batch file in MS Win XP?

Quote:
Originally Posted by SoulKiss View Post
On linux I would launch the batch file (script) at boot time, have it evaluate the results of the uptime command - if uptime > 60 secs then leave the loop, else sleep for 10 seconds, then execute the body of the code then exit.

in pseudocode

while (loop!=1)
{
get uptime
if uptime < 60
{
sleep 10
}
else
{
loop=1
}
do stuff
end
Extremely helpful, for a Windows desktop.
  Reply With Quote
Old 04-06-09, 04:31 PM   #7
SoulKiss
Member
Mega Poster
 
SoulKiss's Avatar
 
Join Date: Jul 2006
Location: Sunny Croydonia
Posts: 6,124
Default Re: How to delay a batch file in MS Win XP?

Quote:
Originally Posted by Baph View Post
Extremely helpful, for a Windows desktop.
Well I have no idea what can cannot be done on a Windows platform - I dont code for that.

But if he can work out how to get a windows box to tell him how long its been up for, then can use that in a comparison, then what I have written WILL help - hence pseudocode and not Perl

You really should change your nick to [pedant]Baph[/pedant]

Oh wait, got to go throw some stones from my glass house
__________________
Sent from my PC NOT using any Tapatalk type rubbish!!

█╬╬╬╬()i¯i▀▀▀▀▀█Ξ███████████████████████████████)
SoulKiss is offline   Reply With Quote
Old 04-06-09, 04:33 PM   #8
ophic
Member
Mega Poster
 
ophic's Avatar
 
Join Date: Jan 2004
Location: Whyteleafe
Posts: 3,395
Default Re: How to delay a batch file in MS Win XP?

you can record and test the %TIME% variable for 1 minute elapsed.

The question i'd be asking is why do you want something to run 1 minute after login. If we know the nature of what you're trying to achieve, perhaps there's a more elegant way to achieve it?
__________________
Silver SV650SK3, Fuel exhaust
ophic is offline   Reply With Quote
Old 04-06-09, 04:37 PM   #9
Baph
Guest
 
Posts: n/a
Default Re: How to delay a batch file in MS Win XP?

Quote:
Originally Posted by ophic View Post
If we know the nature of what you're trying to achieve, perhaps there's a more elegant way to achieve it?
+1.

Quote:
Originally Posted by SoulKiss
Format and install Linux
Just don't ask him!
  Reply With Quote
Old 04-06-09, 05:23 PM   #10
slloyd
Guest
 
Posts: n/a
Default Re: How to delay a batch file in MS Win XP?

Quote:
Originally Posted by RatchetJob View Post
However as a workaround insert a line similar to this:

ping 1.1.1.1 -n 60 -w 1000 > null

This will ping a non existent address 60 times with a 1000ms timeout with the result of causing a 1 minute delay.

It will redirect the ping output to null so that the ping will not display any output on screen.

HTH
This seemed to work for me as an interim solution.

I needed this because I had the following situation:-

PC is on a WORKGROUP network, separate from the DOMAIN network. Needs to print to the DOMAIN printer, so connecting the Network Printer via IP address works, but once the PC was rebooted and you tried to access the printer, it came back with the error message Access Denied.

Even if I add the Group EVERYONE Full Control rights to the SHARED printer, it still doesn't connect.

The only way I found to be able to access the printer after the PC had rebooted was running the following unattended command:-

net use \\IP ADDRESS of Server\Printer Share Name /USER:Administrator@Domain Password /persistent:yes

So now, I have now added the ping 1000 command to the beginning of the script as supplied by RatchJob, and this delays enough time for all services to start and the command to complete successfully.
  Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New Test Delay 6 months Nostrils Bikes - Talk & Issues 1 11-09-08 08:00 PM
Brands Hatch - 24-4-08 First Batch Mr Toad Photos 22 25-04-08 11:06 PM
BBC Sport: Bad weather causes Manx GP delay NewsBot News 0 31-08-07 03:40 PM
BBC Sport: Mist causes further delay to TT NewsBot News 0 04-06-07 08:00 AM
Batch converting Adobe pdf tomjones2 Idle Banter 1 17-03-06 03:16 PM


All times are GMT. The time now is 04:25 PM.


Powered by vBulletin® - Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.