PSEXEC help

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
SMAndy
Posts: 8
Joined: 28 May 2012 03:23

PSEXEC help

#1 Post by SMAndy » 27 Jul 2012 02:43

Hi all,

I'm trying to write a script to remotely fix WMI issues on a target PC. Now, i'm pretty good at psexec, and have managed to get a remote PC to uninstall a program without prompts, from my pc using psexec and wmic.

Right now, i'm trying to fix WMI remotely using a similar method. The first command I need the target PC to run is net stop winmgmt. Unfortunately, there are dependent services... My command to stop winmgmt is this:

psexec \\%target% -s -i -u %userdomain%\%username% cmd /c net stop winmgmt

Ideally, this works... But because there are dependent services, when i run it, the remote PC gets a command prompt saying "these services are dependent, do you want to close these too y/n?"

If i just run this:

psexec \\%target% cmd /c net stop winmgmt

i get a -1 error on MY pc, but I see this:

C:\Users\%username%>psexec \\%target% cmd /c net stop winmgmt

PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - http://www.sysinternals.com


No valid response was provided.
The following services are dependent on the Windows Management Instrumentation service.
Stopping the Windows Management Instrumentation service will also stop these services.

Security Center
IP Helper
SMS Agent Host

Do you want to continue this operation? (Y/N) [N]:
cmd exited on uknml4953 with error code -1.


Any ideas how I can get this to work? Of course, in the above example, i've replaced the actual names with their variable ID's. I could stop the dependent services first using the same method, but that would involve starting them again afterwards, and I can't know how many services will be dependent on winmgmt if WMI is broken - I just want it to close down what it needs to close.

If i just run psexec \\%target% cmd, i can then use commands on the target PC, but I can't script that - it would have to be manually run, which means it can be done remotely, but it's not a great way around it, because I want to be able to script it for people that don't know psexec or much about the command prompt. (we have techies here that are very much of the "point and click" breed... believing that if you can't do it with a mouse, it can't be done)

Sorry for the long post, hope it makes sense!

<edited for typo>

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: PSEXEC help

#2 Post by foxidrive » 27 Jul 2012 05:45

SMAndy wrote: Security Center


Is that going to generate a UAC prompt?

SMAndy
Posts: 8
Joined: 28 May 2012 03:23

Re: PSEXEC help

#3 Post by SMAndy » 01 Aug 2012 08:49

Shouldn't do. The PC's in question have group policy to turn off the UAC prompts.

Post Reply