Enter network credentials as part of batch script
Posted
by Michael
on Super User
See other posts from Super User
or by Michael
Published on 2010-06-07T13:17:32Z
Indexed on
2010/06/07
13:23 UTC
Read the original article
Hit count: 245
WinXP: I have several system services that are needed to run some machinery in my lab. The machine these services are running uses a lab login that has administrator rights. Our IS department, unfortunately, has it set up where at some point during the night the login "loses" the privilege level to start/stop these services. The account stays logged in, but the software controlling my hardware becomes unresponsive.
In order to get things back up and running, I have to stop the system services and restart them. Because of the security settings, however, I have to re-enter the user password to start the service (even though the user was never logged out). That, I get the "This service cannot be started due to a logon failure" and I have to enter the password.
What would be ideal is to have a batch script run before anyone gets into work that stops all of the necessary services, enters the user credentials when prompted, and then restarts them so that everything is ready for first shift to run.
I assumed that using the Task Scheduler in Windows would work as it allows you to run batch files with a user's name and password, but this didn't seem to do the trick. With this setup I would arrive to find that all the services are stopped but not started again. (Presumably because the authentication failed.)
The batch file is about as simple as it gets, all I have is:
net stop "Service1"
net stop "Serivce2"
etc., then restart in reverse order based on dependency:
net start "Service2"
net start "Serivce1"
What would it take to accomplish what I'm trying to do and restart the services?
© Super User or respective owner