Solved

Run only once for a batch file.

Posted on 2002-06-21
12
165 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

696 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