Solved

Access denied

Posted on 2014-01-21
8
396 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…

732 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