Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Run only once for a batch file.

Posted on 2002-06-21
12
Medium Priority
?
169 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 200 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

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…
Read on to get a few ideas on how to promote your next corporate event.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

718 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