Friday, February 10, 2012

Using PSExec from LocalSystem

PSExec is an awesome tool to automate things.

For example, you can use it from an UPS monitoring service (e.g. What’s Up Gold) to start a command on your SAN appliance to stop caching if there is any problem with the UPS.

Exactly this setup caused some trouble because the script was working fine when I tested it, but when run by the monitoring service the script didn’t do anything. The script was just hanging.

After a little investigation it turned out that the problem was the EULA screen PSExec normally displays. Since the monitoring program uses LocalSystem, there was no entry inside the registry that the EULA was displayed and PSExec was waiting for an user to accept it.

The solution is simple:

  • Create the registry key HKEY_USERS\.DEFAULT\Software\Sysinternals\PsExec
  • Below this, create a REG_DWORD value named EulaAccepted and set it to 1

Now the script will run just fine.

2 comments:

  1. and the alternative: start psexec with the -accepteula parameter?

    ReplyDelete
  2. At least on this system psexec.exe didn't listed this parameter, that's why I used the outlined method.

    ReplyDelete