Solved

Run only once for a batch file.

Posted on 2002-06-21
12
166 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
How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Getting to know the threat landscape in which DDoS has evolved, and making the right choice to get ourselves geared up to defend against  DDoS attacks effectively. Get the necessary preparation works done and focus on Doing the First Things Right.
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

630 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