Wednesday, June 23, 2010

PSExec failing on Windows XP 64-bit

Symptoms

Recently, I used a batch script in combination with PSExec to try to install an MSI file on a remote computer with Windows XP 64-bit. The installation worked just fine on Windows XP and Windows 7 32-bit but failed on the 64-bit OS. I kept getting the cryptic return code 1 from the batch script and redirecting the output of the batch script yielded an empty log file.

I was pulling my hair out when I noticed I was using version 1.95 of PSExec. After upgrading my batch script magically worked! I'm not sure why I was using an old version but from here forward I'll make sure to have 1.98 installed.

Solution

Install PSExec 1.98 and magically PSExec now works just fine on Windows XP 64-bit machines.

2 comments:

  1. Great !!

    anyways, any sample code for install an MSI on a remote computer using psexec ? thanks.

    ReplyDelete
    Replies
    1. Good question.

      PSexec simply runs an application or msi. In most cases, the msi you want to run is not going to be located on the remote computer yet so you're going to run the msi from a network path or find a way to copy it to the remote computer from some other location. PSExec does not transfer files, it simply executes remote commands. So one of the big questions you have to answer is, how do I get my MSI or other files to the remote computer before running them?

      My personal preference is to use PSExec to copy a batch file to the remote computer. That batch file is written to pull all the needed files to the remote computer first (to a temp folder or otherwise) and then run the files it copies locally on the remote computer. It may seem like this isn't needed and overly complicated, but actually makes sense because lots of .net applications won't be able to run properly from network shares due to some security settings in .NET. You are generally much better off executing code locally on the remote computer and trying to make as few psexec calls as possible.

      In the past I would use psexec many times in one script. The problem is, my scripts would take forever to execute because although handy, psexec isn't very fast. It actually works by registering and starting a service that runs the commands you send to it. Each time you run psexec, it goes though that whole process of registering and starting a service.

      So for example code. I would put everything on the network somewhere (let's say \\server\apps\psexec.exe, \\server\apps\install.bat and \\server\apps\install.msi). I would then put the following code inside of install.bat:

      copy "\\server\apps\install.msi" "C:\temp\install.msi"
      msiexec /i "C:\temp\install.msi" /qb-

      Now, to actually execute the remote call, we just use the following:

      start /min \\server\apps\psexec.exe /accepteula \\REMOTECOMPUTER /u DOMAIN\USER /p PASSWORD \\server\apps\install.bat

      Make sure to replace REMOTECOMPUTER with the computer name or IP of the remote computer, replace DOMAIN\USER and PASSWORD with the credentials of a domain admin or a local admin on the remote computer.

      That should be it!

      Note: we use /accepteula in the command because otherwise psexec gets made that we didn't accept the end user license agreement. :[

      Delete