Answered by:
PSEXEC is Executing the target batch file in my session!

Question
-
Hi Scripting Guys,
Quick question. I'm running into an issue with psexec when attempting to copy over a batch file and run it as system on a remote computer. Instead of the batch file being executed on the target, it shows up in the next line on my cmd prompt and executes locally.
I'm using:
psexec \\targetmachine -s -c -f \\Share\remove.bat
I've tried hosting the file from my computer instead of a share as well but I got the same result.
The batch file contains this:
wmic product where "name like 'Java%%'" call uninstall
It copies the file onto the target and says it's running it, and then it shows up on my machine.
Any help would be welcomed! Thanks guys.
- Moved by Bill_Stewart Friday, November 28, 2014 5:16 PM This is not a third-party software support forum
Tuesday, October 28, 2014 10:09 AM
Answers
-
Your question is about a utility and not about scripting. There is a forum for that utility. You would do best by posting in that forum.
http://forum.sysinternals.com/pstools_forum8.html
Look at the questions and you will find many similar to yours.
This forum is for scripting questions. Your question is "why doesn't my utility program work as I expect it to work?". You are typing it at a prompt. It is a third party utility.
¯\_(ツ)_/¯
- Proposed as answer by Mike Laughlin Tuesday, October 28, 2014 1:00 PM
- Marked as answer by Just Karl Tuesday, December 23, 2014 10:17 PM
Tuesday, October 28, 2014 12:13 PM
All replies
-
It copies the file onto the target and says it's running it, and then it shows up on my machine.
When you say "it shows up on my machine" then I assume that you're trying to say "The screen output from wmic.exe shows up on my machine." This is by design so that you can see what is happening. Also - this is not a scripting question (scripting = programming scripts) but a question about a utility that would best be answered in a forum that deals with console commands.Tuesday, October 28, 2014 11:27 AM -
I feel like if it was for programming scripts it should be called programming scripts. That's an overly esoteric bit of info that just makes you come across as rude.
And no. It does not show output from WMIC. It actually executes on the next line of batch on my machine. My java was removed and the java on the target machine is still present.
Thanks for you help, however useful it is so far.
Tuesday, October 28, 2014 11:40 AM -
Your question is about a utility and not about scripting. There is a forum for that utility. You would do best by posting in that forum.
http://forum.sysinternals.com/pstools_forum8.html
Look at the questions and you will find many similar to yours.
This forum is for scripting questions. Your question is "why doesn't my utility program work as I expect it to work?". You are typing it at a prompt. It is a third party utility.
¯\_(ツ)_/¯
- Proposed as answer by Mike Laughlin Tuesday, October 28, 2014 1:00 PM
- Marked as answer by Just Karl Tuesday, December 23, 2014 10:17 PM
Tuesday, October 28, 2014 12:13 PM -
I will also note that you are not running the command correctly. Please read the documentation more carefully. You are not telling it what to copy.
¯\_(ツ)_/¯
Tuesday, October 28, 2014 12:18 PM -
Hi Owlxiozee,
Suggest you to Run the Psexec against a list of servers. Mention the name of the remote machine on the list and Run the Psexec.
Example: C:\Windows\system32\Psexec.exe @C:\Serverlist.txt cmd /c \\Share\remove.bat
Explanations:
@C:\Serverlist.txt - A list of server / servers located in C:\ with the name Serverlist.txt in the local machine from which you are executing.
So it opens the command prompt of the machine name in the list.
Let me know the result.
Gautam.75801
- Edited by Gautam RMicrosoft employee Tuesday, October 28, 2014 12:23 PM
- Proposed as answer by Gautam RMicrosoft employee Tuesday, October 28, 2014 1:50 PM
Tuesday, October 28, 2014 12:22 PM -
Warning - you are likely to get lots of wrong answers in this forum because it is not a scripting issue. You have the command wrong. Look at the examples in the documentation and fix it. Getting names from a file will not help.
¯\_(ツ)_/¯
Tuesday, October 28, 2014 12:31 PM -
I feel like if it was for programming scripts it should be called programming scripts. That's an overly esoteric bit of info that just makes you come across as rude.
This is an interesting point of view. Everyone's telling you that you're in the wrong place yet you perceive this advice as being "rude". I felt reminded of Hans Christian Andersen's fairy tale The Princess and the Pea. I would recommend a somewhat thicker skin and a bit of detachment. Nobody tried to attack you!Tuesday, October 28, 2014 1:10 PM