Link to home
Start Free TrialLog in
Avatar of j_script
j_script

asked on

Run only once for a batch file.

I have a file called test in c:\test.
I have a batch file called test.bat in c:\temp.
This batch file will delete test.

I want this batch to be called only when the system is
rebooting, not re-log in. How do I do that ?
ASKER CERTIFIED SOLUTION
Avatar of mikecr
mikecr
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of j_script
j_script

ASKER

win2000 server
Put an entry under

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce

"RunMyBatch"="c:\temp\test.bat"

This should work.
It works either I relogin as another user or rebooting
the box. What I want is only do it when the box is rebooting,
This is the Windows 2000 section so I assume this is Windows 2000.

Windows 2000 does have an autoexec.bat that you can use. This is not used very often, but it may do the job for you.
I cannot find autoexec,bat in my win2000 server.
Where should I put it and how do I tell win2000 server
to execute it ?
jkr,

I'm not sure, but your suggestion should only run once, then disappear forever correct? This is sually reserved for running a new setup program only once upon the net startup. Is that correct?
It's actually called autoexec.nt and it's located in the c:\winnt\system32 directory.
I thought that was it and then I found an autoexec.bat (with nothing in it) in my root directory.

That might have been there from a test in times past...

Thanks for the correction mikecr
Add it as a scheduled task to run on system startup. It will then run every time the system starts up, but not when you just log off and log back in again, which sounds like what you need.
Use autoexnt from the resource kit. (exists with NT4
 Resource Kit). Maybe you find it in the 2000 Resource Kit.
It work before any service.
It will not be reloaded at each logon
Force-accepted.

Netminder
EE Admin