Solved

Run only once for a batch file.

Posted on 2002-06-21
12
159 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
 

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

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…
Hyena v12.2 is now available for downloading and is available in English, French, German and Spanish versions.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now