Link to home
Start Free TrialLog in
Avatar of iamsateesh
iamsateesh

asked on

Access denied

Support,

I want to stop/start the windows services using below command.

sc \\<serviceName> start <Service_Name>

But I'm getting access denied error. Is there anyway I can hardcode userid and password of the system before executing stop service command?
Avatar of tsaico
tsaico
Flag of Afghanistan image

Is this for a remote computer or the computer you are on?

You can use the net start and stop commands

net stop <servicename>

Oh, and I also think you need the command line to run in an admin window, be it a batch or manually run.
Avatar of Chris Millard
You could also use PsExec (part of PsTools - http://technet.microsoft.com/en-gb/sysinternals/bb896649.aspx) to run the command.

With PsExec you can run a command on a local or remote machine, and you can also specify a username and password to run the command as.

Example (to run on a local PC)

psexec -u <domain\username> -p <password> sc \\<serviceName> start <Service_Name>
Avatar of iamsateesh
iamsateesh

ASKER

I want to stop and start the services on remote computer from local laptop...
I want to stop and start the services on remote computer from local laptop...

The PsExec (mentioned above) would be the method of choice.

Maybe you need to run it within a command shell, with i.e.
psexec -u <domain\username> -p <password> cmd /c net start <serviceName>

Open in new window

Is there any batch script or vb script[script contains computer name, userid and password]
 I execute before stopping and starting the services?
None I know of.

the commands
net start <serviceName>
net stop <serviceName>

Open in new window

will do anything needed to start/stop the service. NET is a transient command (executable file bundled into Windows).

PsExec is a tool for executing commands on a remote machine and part of the "Sysinternals Suite", a free collection of tools that once was independent. The suite got too good to remain independent, so MS hired the programmer and now the Sysinternals suite is part of Microsoft's tools collection (TechNet). It's old web address http://www.sysinternals.com now redirects to a Microsoft Technet site, where the tools could easily be found. They're worth a look in any case, by the way, an they're actively maintained.
Oh, are you on a domain?  If so, then the admin shares should also be enabled.  Otherwise, you will need to make at least one valid connection before you will be allowed to connect to the remote computer

here is a post on what I am talking about, just check out the guy's command line example, where he logs in as a local user once just to authenticate. then from there his sc command works fine
http://www.neowin.net/forum/topic/954040-how-do-you-startstop-windows-7-service-remotely/
ASKER CERTIFIED SOLUTION
Avatar of Frank Helk
Frank Helk
Flag of Germany image

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