• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

How to stop service, copy file, and restart

BCinSC

Platinum Member
Oct 11, 1999
2,084
0
0
Need to copy a file, but first completely stop the service that writes to it, then restart that service when copy is complete. NT-based operating systems (NT, 2000, XP, 20003) all execute batch file commands without regard to prior command completion (ah, the down-side to multi-threaded OSes). I'm sure there are simply ways, beyond TPAUSE, to wait for each to complete before executing next. Help? Thanks.
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Put the delete command in a loop so it keeps trying to delete it till it no longer exists?

Do loop:

do{
delete(file)
}
while(exists(file))


While loop:

while(exists(file)){
delete(file)
}
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Originally posted by: BCinSC
Don't want to delete, just copy.

lol, sorry about that :eek:. I don't know the dos commands but maybe you could do it like this ? Make a call to stop the service and then wait a around in a while loop that checks if the service is stopped. If it is, it copys the file and sets the value of the var so that the loop will break.
 

SearchMaster

Diamond Member
Jun 6, 2002
7,791
114
106
Sorry if this is too obvious but couldn't you use "net stop service&copy file&net start service"? If you're not sure of the service name, try "net help services".