We help IT Professionals succeed at work.

Psexec script opens runs, but opens up command prompt and hangs

Yashy
Yashy asked
on
heya,

I had the following script given to me by our awesome EE OdBA:

c:\psexec.exe @"C:\Temp\machines.txt" -u Domain\Username -p Password msiexec.exe /i "\\networkservername\sharename\my.msi" /quiet /norestart

In the 'machines.txt', there's an IP address in the format 192.168.55.20. When I run the batch file, the command prompt goes past the actual Systinternals message and then hangs on \\192.168.55.20.

However, if I open up the command prompt and put the IP address in manually and run 'psexec omain\Username -p Password msiexec.exe /i "\\192.168.55.20\sharename\my.msi" /quiet /norestart' then it works perfectly and exits successfully.

Any ideas? Am I doing something wrong? Perhaps I need to run the batch file on an elevated command or something?

thanks
Yashy
Comment
Watch Question

NVITEnd-user support

Commented:
Just checking... Are you running your batch file using the same credentials as psexec?
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
Interesting; that seems to be a bug in psexec's @file argument.
When @file is used instead of \\machinename, the arguments of the command to be executed seem to be swallowed.
I can confirm that for the current version v2.11 as well as v1.98 which I still had lying around.
The result of running it with "@file" is an unexplainable error for a simple command:
C:\Temp>psexec @"C:\Temp\test.txt" -u DOMAIN\Administrator -p Password net share c$

PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com

\\192.168.1.1:

The syntax of this command is:

NET
    [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |
      HELPMSG | LOCALGROUP | PAUSE | SESSION | SHARE | START |
      STATISTICS | STOP | TIME | USE | USER | VIEW ]
net exited on 192.168.1.1 with error code 1.

Open in new window

When the same file is used with a "for /f" loop and "\\machine" is used, it works as expected:
C:\Temp>for /f %a in (C:\Temp\test.txt) do @psexec \\%a -u DOMAIN\Administrator -p Password net share c$

PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com


Share name        C$
Path              C:\
Remark            Default share
Maximum users     No limit
Users
Caching           Manual caching of documents
Permission        Everyone, FULL

The command completed successfully.

net exited on 192.168.1.1 with error code 0.

Open in new window

So currently, your remote machine is "showing" the syntax box that appears when you just call msiexec without arguments, and waiting for someone to click the "OK" button.
You can run the following command (in another prompt) to release psexec:
taskkill /s 192.168.55.20 /im msiexec.exe

Open in new window

Workaround: either use the script in http:Q_28652193.html#a40712744, or the one-liner quick fix for the command prompt (make sure the input file is saved as ANSI, not Unicode):
for /f %a in (C:\Temp\machines.txt) do @psexec \\%a -u DOMAIN\Username -p Password msiexec.exe /i "\\networkservername\sharename\my.msi" /quiet /norestart

Open in new window

Author

Commented:
I used the script which you put the link in for here and I took out the 'ECHO'...worked a charm:))