Link to home
Start Free TrialLog in
Avatar of wilsontony
wilsontony

asked on

Running a process in Windows 2000 Before Logon

I would like to run a command in Windows 2000 to inform a console that the PC has rebooted. I only want to do this once.

I tried adding a key to the runonce key in the registry for "NET SEND CONSOLE Rebooted". This works but only when someone signs onto the PC. How can I do this at startup but before the user signs on.

Urgent response requested, hence the high points.
Avatar of Paul Maker
Paul Maker
Flag of United Kingdom of Great Britain and Northern Ireland image

the best way to do this is write a service; services get started when the machine boots up windows. they are executed before logon.

you will need to write one
regsiter it
set it to start automatically....

can you program....
Avatar of jhance
jhance

As already noted, the only things that run WITHOUT an interactive logon are SERVICES.  This is what they are for.

Let me suggest Kevin Miller's book on the subject, "Windows NT Services" published by WROX.
Avatar of wilsontony

ASKER

I only want to run this ONCE. If I create a service it will run it everytime. I do not want to make too drastic a change to the PCs.

Thanks for the comments.
just have your service use the system("NET SEND machine message") then exit. that way it will execute once when the system is started then it will die.

>>I do not want to make too drastic a change to the PCs.

then if you consider registering a service drastic then go tell your manager it is not possible to do what he/she wants.... then maybe collect your coat, ask for your p45 to be sent straight to you home address and go home
If I could make the service unregister itself as soon as it runs the first time then this may be acceptable.

I would be doing this remotely via WMI so ideally the solution would be as simple as possible. I thought someone may have some cute way of doing this and that is the reason I posted this question.

As an MCSE/2000 with over 10 years experience, please spare me the P45 quips!
I HARDLY consider a SERVICE to be "drastic".  Under Windows NT/2000/XP a service is simply an application that runs without an interactive user.

There is no requirement that a service continue running.  It can simply start, do its thing, and then terminate.

I'll just 2nd makerp's sentiment that if you consider this "drastic" that you are unqualified to do what you as being asked to do.

Once again, I refer you to Miller's book.  It will help you learn something new, help you solve this problem, and make you a better and potentially more valuable employee.
>>If I could make the service unregister itself as soon as it runs the first time then this may be acceptable.

why would you want to do that; then youll have to re-register it before each time you were going to re-boot. do you only want this to run ONLY ONCE or every time it re-boots. if ONLY ONCE then may i suggest that you phone call the effected people, this will probably be cheaper...... if you want it to run when ever the machine starts then you need to regsiter it ONCE on the PC and then forget about it.
Well you could use the task Scheduler and schedule it to run at system startup. Then put a batch file in the RunOnce key to delete the scheduled task

DEL C:\WINNT\Tasks\TheTask.job

Of couse I am sure you know you need to include a User and the Password for the user in the sheduled task. In this case one with admin privleges.


The Crazy One
As far as running it as a service you could let the service run and then in the RunOne put in a batch file to run this command

TheDrive\TheFolder\TheService /uninstall
i would do this via group policy Startup script

(mmc - add remove snap-in - group policy)

There, browse to "local Computer Policy - Windows sttings - Scripts(Startup/Shutdown)

add a batchfile with about the following content:

--------------
net send %console% Rebooted
del thisbatchfile.bat
--------------



ASKER CERTIFIED SOLUTION
Avatar of bonzai
bonzai

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Bonzai has exactly the right answer. Forget about that Service nonsense.
huh... thank you smadaras... feeling verry embarrassed :-)
The one thing I would add to bonzai's response is that I would use a vbscript, which sets and then checks a reg key, instead of deleting the batch file. With that scenario you can put the startup script in any GPO, site, domain or OU.
Thanks for all the comments guys. You were all really helpful