?
Solved

Access denied

Posted on 2014-01-21
8
Medium Priority
?
418 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
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 500 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

OfficeMate Freezes on login or does not load after login credentials are input.
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
Suggested Courses

770 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