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

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
LVL 1
YashyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
Just checking... Are you running your batch file using the same credentials as psexec?
oBdACommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
YashyAuthor Commented:
I used the script which you put the link in for here and I took out the 'ECHO'...worked a charm:))
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.