Run CMD on boot

Hello, my problem is as follows:

I want to run a CMD after computer's reboot, with no user logged on.
I can't use AT commands or install services.
Is there any Registry Entry that can run a command only when computer starts (and after disappear)?

Thank you,

P.D. I'm an administrator, and the machines are NT 4.0 SP5.
marcmcAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
There's no way to do this before a user logs on. However, ther'es a workaround

Placing an entry under

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce

Will cause the .cmd file to run when the first user logs on. This has to be sth. like

myentry = "cmd.exe /c c:\path\mycmd.cmd"

where 'myentry' is the value's name...
0
bchewCommented:
HKLM/Software/Microsoft/Windows/Current Version/RunOnce.
0
marcmcAuthor Commented:
That's the problem. Any user logs on when the computer reboot. I need another way.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Tim HolmanCommented:
What exactly do you need to do ?
What CMD do you need to run ?
SMS / WinInstall would do the trick.
You could use a login script to run at user logon and place a tag file on the system so that it wouldn't run again ?
0
jkrCommented:
>>That's the problem. Any user logs on when the computer
>>reboot

This is no problem - it doesn't matter which user logs on, the result will always be the execution of your command file (BTW: That's the way MS recommends to install service packs in unattended setups...)
0
marcmcAuthor Commented:
Sorry, my comment is incorrect. When the computer reboot, no user log into in a few hours, and I want to execute the CMD command immediately.
0
KimdaCommented:
why cant you run the cmd, as a service ?
0
Tim HolmanCommented:
You'll have to run the command as a service or use bchew's registry suggestion.
Nither way requires a user logon.
0
fciiiCommented:
Well, there is a way to do this, using autoexnt, which is part of the NT Resourse Kit package.  It requires that you put AUTOEXNT.EXE and SERVMESS.DLL in the &systemroot%/system32 directory.  Then create an AUTOEXNT.BAT file with the needed commands and copy this one also into the %systemroot%/system32 directory.  For example, if I wanted to copy the system file sam.log to another lacation for whatever purpose, I would open notepad and write the text;

"copy  <root drive>%systemroot%\system32\config\sam.log f:"

and close note pad.  When note pad asked me what to save the file as, I would name it AUTOEXNT.BAT and save it to the %systemroot%/system32 directory. At the next boot of the machine, the command, copy, would be carried out automatically, before and log in attempt.

At the command prompt type "INSTEXNT install", after the install process finishes, screen should read ">> CreateService AutoExNT SUCCESS with InterActive Flag turned OFF".

Included below is the instructions for the command which were included with NT Resourse Kit

-----------------------------------------

Notes for the AutoExNT Service, Version 1.2
=================================================

The AutoExNT service allows you to start a batch file, AUTOEXNT.BAT, at boot time without having to log on the computer on which it will run.

To use AutoExNT, you must be running Windows NT 3.5 or later. It includes a "/interactive" option, analogous to the /interactive option of the AT command, which allows you to see the processes started.


Files
========
The AutoExNT service requires the following files:
AUTOEXNT.EXE      The AutoExNT service routine. Copy this into your %systemroot%/system32 directory.
AUTOEXNT.TXT      This Readme
INSTEXNT.EXE      Use this to install the service.
SERVMESS.DLL      The AutoExNT message DLL. Copy this into your %systemroot%/system32 directory.


Usage
========
- First copy the AUTOEXNT.EXE and the SERVMESS.DLL into the %systemroot%/system32 directory.
- Now create an AUTOEXNT.BAT file with the needed commands and copy this one also into the %systemroot%/system32 directory.

NOTE:      Don't forget that there are no user-environment variables at boot time, so use full pathnames etc.  Also, if you are relying on a service (for example, server or schedule) you might want to add a NET START "service" in the beginning of your AUTOEXNT.BAT batch file to make sure that these services are running before you execute your dependent process. This is needed since at boot time, there is no guarantee that all processes will be up and running when AutoExNT is executed.

- At a command prompt, type:
      INSTEXNT install
When everything is fine, the application responses:
        >> CreateService AutoExNT SUCCESS
         with InterActive Flag turned OFF.

- You may also type at this prompt:
      INSTEXNT install /interactive.
In this case, you can see the processes running on the desktop. However, users (logged on locally) are able to stop them.

When everything is fine, the application responds:
        >> CreateService AutoExNT SUCCESS
         with InterActive Flag turned ON.


To test the service.
========================
Log in as an administrator and enter the following command:

      net start autoexnt

You will see a new Commandbox running the AUTOEXNT.BAT file.

To install for autostart at boottime:
======================================
-  Choose Control Panel | Services.
-  Select AutoExNT
-  Select Startup
-  Select Startup Type: Automatic
-  When you need rights outside your local system (for example to perform a NET USE command):
      Select "Logon As: This Account."
      Specify an account which has sufficient privileges on your domain/system, and give/confirm the password.
-  Choose OK.

Your AutoExNT service is now installed.


Comments/suggestions/critiques:
======================================
Please send e-mail to janve@microsoft.com.

Jan van Eekeren,
The Netherlands.
1 February 1995

Hope this helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.