Solved

Access denied

Posted on 2014-01-21
8
376 Views
Last Modified: 2014-01-27
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?
0
Comment
Question by:iamsateesh
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 9

Expert Comment

by:tsaico
ID: 39797341
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.
0
 
LVL 17

Expert Comment

by:Chris Millard
ID: 39797361
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>
0
 

Author Comment

by:iamsateesh
ID: 39797753
I want to stop and start the services on remote computer from local laptop...
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 14

Expert Comment

by:frankhelk
ID: 39797985
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

0
 

Author Comment

by:iamsateesh
ID: 39798269
Is there any batch script or vb script[script contains computer name, userid and password]
 I execute before stopping and starting the services?
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 39799408
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.
0
 
LVL 9

Expert Comment

by:tsaico
ID: 39800147
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/
0
 
LVL 14

Accepted Solution

by:
frankhelk earned 250 total points
ID: 39800222
Hmmm ... looks like that's needed for sc.

Since PsExec accepts credentials by its own, I presume that the PsExec attempt works well w/o logging in first (but I admit that I havn't tested that - just try yourself).

In both cases I presume that is not a problem if the user of the local machine is known on the target machine with the same credentials ... regardless of workgroup, domain or AD (easier when both are in the same domain or AD ...).
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question