How to run multiple commands with psexec?
I don't think those parentheses are valid. I think the /s
switch in cmd.exe
should preserve everything between the first and last "
. Does this work?
psexec @ComputerList.txt -u domain\administrator cmd /s /c "xcopy "\\NetworkPath\Forefront Software\Install.exe" "C:\Windows" && Install.exe /u /s && del C:\Windows\Install.exe"
I tested with the following simplified command and it worked (modified to /k
so I could view output).
psexec \\remotemachine cmd /s /k "dir "c:\temp" && echo "hello""
Related videos on Youtube
Comments
-
seffland almost 2 years
I need to run a command to uninstall forefront on some of our workstations and am having a bit of trouble formatting the command.
Here's what needs to happen (in multiple commands)
xcopy \\serverpath\Installer.exe C:\Windows Install.exe /u /s Del C:\Windows\Install.exe
I'm using psexec with a computer list but keep running into errors. This is what my command looks like as of right now.
psexec @ComputerList.txt -u domain\administrator cmd /c (xcopy "\\NetworkPath\Forefront Software\Install.exe" "C:\Windows" && Install.exe /u /s && del C:\Windows\Install.exe)
I think the spaces in the path name and quotes are messing things up...
EDIT:
Tried running it with a script with no luck. It looks like scepinstall.exe just hangs on the remote machine. I also tried using the exe that can be found in
C:\Windows\ccmsetup\
Thanks for the help
-
seffland about 10 yearsThat would force us to run multiple commands, first copying the script to all the machines then running it. We are trying to do this in one seamless command since it will be deployed to 500+ machines. If that's the only way to do it I guess we have to then...
-
Zoredache about 10 yearsFalse, read the docs. Passing the
-c
option causes psexec to copy the script as part of the task. technet.microsoft.com/en-us/sysinternals/bb897553.aspx -
seffland about 10 yearsTried doing it as a script, but it's now hanging on the uninstall. I also tried a script that would CD into Windows\CCMSetup\ and run the exe there, but it returns
script.bat exited on testmachine with error code -2147156221
-