Problem running a script on startup

  • Thread starter Thread starter Allan Cady
  • Start date Start date
A

Allan Cady

I have a script (vbs) that needs to run on system startup, regardless
of whether any user logs on. I thought I knew how to do this, but I'm
not seeing the result I expected.

I added a registry value in
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, with
the correct command to run the script. But when I restart the
machine, as far as I can tell, the script isn't getting run until I
log on as an interactive user. (I can tell whether it has run without
logging on.)

Does anyone have any idea why it's doing this, and more importantly,
what can I do that will make the script run without logging on?

I'm doing this on Windows 2000 Server.

Thanks,

Allan
 
Allan Cady said:
I have a script (vbs) that needs to run on system startup, regardless
of whether any user logs on. I thought I knew how to do this, but I'm
not seeing the result I expected.

I added a registry value in
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, with
the correct command to run the script. But when I restart the
machine, as far as I can tell, the script isn't getting run until I
log on as an interactive user. (I can tell whether it has run without
logging on.)

Does anyone have any idea why it's doing this, and more importantly,
what can I do that will make the script run without logging on?

I'm doing this on Windows 2000 Server.

Thanks,

Allan

Rather than playing with insufficiently known keys in the registry,
you should use the Task Scheduler to run your startup task. It
has a nice graphical user interface, it lets you specify the account
under which the task should run and it lets you select when
exactly and how often your task should run.
 
Allan Cady said:
I have a script (vbs) that needs to run on system startup, regardless
of whether any user logs on. I thought I knew how to do this, but I'm
not seeing the result I expected.

I added a registry value in
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, with
the correct command to run the script. But when I restart the
machine, as far as I can tell, the script isn't getting run until I
log on as an interactive user. (I can tell whether it has run without
logging on.)

Does anyone have any idea why it's doing this, and more importantly,
what can I do that will make the script run without logging on?

I'm doing this on Windows 2000 Server.

Thanks,

Allan

Rather than playing with insufficiently known keys in the registry,
you should use the Task Scheduler to run your startup task. It
has a nice graphical user interface, it lets you specify the account
under which the task should run and it lets you select when
exactly and how often your task should run.
 
Use the Group policy editor
%windir%\system32\gpedit.msc Computer Configuration\Windows
Settings\Scripts\Startup

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


:
|I have a script (vbs) that needs to run on system startup, regardless
| of whether any user logs on. I thought I knew how to do this, but I'm
| not seeing the result I expected.
|
| I added a registry value in
| HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, with
| the correct command to run the script. But when I restart the
| machine, as far as I can tell, the script isn't getting run until I
| log on as an interactive user. (I can tell whether it has run without
| logging on.)
|
| Does anyone have any idea why it's doing this, and more importantly,
| what can I do that will make the script run without logging on?
|
| I'm doing this on Windows 2000 Server.
|
| Thanks,
|
| Allan
 
Use the Group policy editor
%windir%\system32\gpedit.msc Computer Configuration\Windows
Settings\Scripts\Startup

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


:
|I have a script (vbs) that needs to run on system startup, regardless
| of whether any user logs on. I thought I knew how to do this, but I'm
| not seeing the result I expected.
|
| I added a registry value in
| HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, with
| the correct command to run the script. But when I restart the
| machine, as far as I can tell, the script isn't getting run until I
| log on as an interactive user. (I can tell whether it has run without
| logging on.)
|
| Does anyone have any idea why it's doing this, and more importantly,
| what can I do that will make the script run without logging on?
|
| I'm doing this on Windows 2000 Server.
|
| Thanks,
|
| Allan
 
That's one option... or the OP could use any other type of SERVICE
instead... either a natively done or use SrvAny. The Run key values
are used only when a user logs on and is an alternative to a shortcut
in Startup folder.

- Sten
 
That's one option... or the OP could use any other type of SERVICE
instead... either a natively done or use SrvAny. The Run key values
are used only when a user logs on and is an alternative to a shortcut
in Startup folder.

- Sten
 
Interesting suggestions all...

None of these suggestions work quite as I want, but I made a little
compromise and went with the Task Scheduler solution. I have it
working now.

In case anyone's interested, here's a little more detail on what I'm
up to, and the hurdles I had to cross to get there.

I'm administering a web server which is built with a stack of two
machines, serving different roles. There are services on machine 1
that need to wait to start until services on machine 2 are ready.
This is Windows 2000 Server, and we don't have a domain or any other
network infrastructure that would make cross-machine control easier...
just two independent machines talking over a LAN.

Someone suggested I could use psexec
(http://www.sysinternals.com/ntw2k/freeware/psexec.shtml) for the
cross-machine communication. I built a vbscript that uses psexec to
ask machine 2 if it's ready, then once it is, the script runs a bunch
of NET START commands on machine 1. The script runs just fine from
the command line. So the next task was to get it to run on system
start. This was the most difficult challenge.

The Task Scheduler solution looked promising... I had forgotten that
it included an option to schedule something on computer startup. The
problem was, in my original scheme, the Task Scheduler service was one
of the services that I wanted to start from the script after machine 2
was ready. So a bit of a bootstrap problem there.

The startup script capability of the group policy at first looked like
the better way to go... easy to configure, and it didn't depend on
Task Scheduler. But when I tried it, I got an error from psexec... it
couldn't connect to machine 2. I get the following message from
psexec:

A specified logon session does not exist. It may already have been
terminated. Connecting to 192.168.0.145...
Couldn't access 192.168.0.145:

I suspect this is related to the fact that the script is running as
LocalSystem, instead of as an actual user. But I don't know.

I couldn't find my way around that, so I eventually decided that the
possible consequences of Task Scheduler starting early were minimal
enough to tolerate, so I scheduled the script in Task Scheduler. Now
the script runs fine on startup.

I haven't tried the service (srvany) option.

Thanks for the help,

Allan


Dave Patrick said:
Use the Group policy editor
%windir%\system32\gpedit.msc Computer Configuration\Windows
Settings\Scripts\Startup

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


:
|I have a script (vbs) that needs to run on system startup, regardless
| of whether any user logs on. I thought I knew how to do this, but I'm
| not seeing the result I expected.
|
| I added a registry value in
| HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, with
| the correct command to run the script. But when I restart the
| machine, as far as I can tell, the script isn't getting run until I
| log on as an interactive user. (I can tell whether it has run without
| logging on.)
|
| Does anyone have any idea why it's doing this, and more importantly,
| what can I do that will make the script run without logging on?
|
| I'm doing this on Windows 2000 Server.
|
| Thanks,
|
| Allan
 
Interesting suggestions all...

None of these suggestions work quite as I want, but I made a little
compromise and went with the Task Scheduler solution. I have it
working now.

In case anyone's interested, here's a little more detail on what I'm
up to, and the hurdles I had to cross to get there.

I'm administering a web server which is built with a stack of two
machines, serving different roles. There are services on machine 1
that need to wait to start until services on machine 2 are ready.
This is Windows 2000 Server, and we don't have a domain or any other
network infrastructure that would make cross-machine control easier...
just two independent machines talking over a LAN.

Someone suggested I could use psexec
(http://www.sysinternals.com/ntw2k/freeware/psexec.shtml) for the
cross-machine communication. I built a vbscript that uses psexec to
ask machine 2 if it's ready, then once it is, the script runs a bunch
of NET START commands on machine 1. The script runs just fine from
the command line. So the next task was to get it to run on system
start. This was the most difficult challenge.

The Task Scheduler solution looked promising... I had forgotten that
it included an option to schedule something on computer startup. The
problem was, in my original scheme, the Task Scheduler service was one
of the services that I wanted to start from the script after machine 2
was ready. So a bit of a bootstrap problem there.

The startup script capability of the group policy at first looked like
the better way to go... easy to configure, and it didn't depend on
Task Scheduler. But when I tried it, I got an error from psexec... it
couldn't connect to machine 2. I get the following message from
psexec:

A specified logon session does not exist. It may already have been
terminated. Connecting to 192.168.0.145...
Couldn't access 192.168.0.145:

I suspect this is related to the fact that the script is running as
LocalSystem, instead of as an actual user. But I don't know.

I couldn't find my way around that, so I eventually decided that the
possible consequences of Task Scheduler starting early were minimal
enough to tolerate, so I scheduled the script in Task Scheduler. Now
the script runs fine on startup.

I haven't tried the service (srvany) option.

Thanks for the help,

Allan


Dave Patrick said:
Use the Group policy editor
%windir%\system32\gpedit.msc Computer Configuration\Windows
Settings\Scripts\Startup

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


:
|I have a script (vbs) that needs to run on system startup, regardless
| of whether any user logs on. I thought I knew how to do this, but I'm
| not seeing the result I expected.
|
| I added a registry value in
| HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, with
| the correct command to run the script. But when I restart the
| machine, as far as I can tell, the script isn't getting run until I
| log on as an interactive user. (I can tell whether it has run without
| logging on.)
|
| Does anyone have any idea why it's doing this, and more importantly,
| what can I do that will make the script run without logging on?
|
| I'm doing this on Windows 2000 Server.
|
| Thanks,
|
| Allan
 
Back
Top