Solved

Run only once for a batch file.

Posted on 2002-06-21
12
162 Views
Last Modified: 2010-04-13
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 ?
0
Comment
Question by:j_script
  • 3
  • 3
  • 2
  • +4
12 Comments
 
LVL 17

Accepted Solution

by:
mikecr earned 50 total points
ID: 7099202
Put a line in the autoexec.bat file to run it during startup or you can edit the registry to run it during shutdown. This will all depend on what operating system that your running it on. If you let us know what the OS is, we can give you links to what you might need.
0
 

Author Comment

by:j_script
ID: 7099212
win2000 server
0
 
LVL 86

Expert Comment

by:jkr
ID: 7099235
Put an entry under

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce

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

This should work.
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:j_script
ID: 7099246
It works either I relogin as another user or rebooting
the box. What I want is only do it when the box is rebooting,
0
 
LVL 7

Expert Comment

by:jmiller47
ID: 7099259
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.
0
 

Author Comment

by:j_script
ID: 7099292
I cannot find autoexec,bat in my win2000 server.
Where should I put it and how do I tell win2000 server
to execute it ?
0
 
LVL 7

Expert Comment

by:jmiller47
ID: 7099358
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?
0
 
LVL 17

Expert Comment

by:mikecr
ID: 7099370
It's actually called autoexec.nt and it's located in the c:\winnt\system32 directory.
0
 
LVL 7

Expert Comment

by:jmiller47
ID: 7099384
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
0
 
LVL 12

Expert Comment

by:pjknibbs
ID: 7100014
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.
0
 
LVL 10

Expert Comment

by:Longbow
ID: 7103357
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
0
 
LVL 5

Expert Comment

by:Netminder
ID: 8581091
Force-accepted.

Netminder
EE Admin
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adprep 12 76
Print Server: Problem from NT to windows 2008 server environment 3 642
Recovering backup .Qic files on Windows 7 6 2,229
OLD CPUs 12 80
If you thought ransomware was bad, think again! Doxware has the potential to be even more damaging.
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question