views:

1124

answers:

3

Hi there,

I've been trying to get psexec to run executables on remote machines from custom build tasks in visual studio. All of these commands work from the command line but running it from an application seems to be a problem. Some commands work, on other psexec hangs and consequently so do msbuild and visual studio 2005. I'm calling SharePoint's stsadm.exe in this case, but this problem occurs with a lot of programs, when running psexec from an application. There are lots of people having this problem, but there seems to be no solution, so my question is: Does anyone know a working alternative to psexec?

A: 

There's always RCE.

RemCom is a small (10KB upx packed) remoteshell / telnet replacement that lets you execute processes on remote windows systems, copy files on remote systems, process there output and stream it back. It allows execution of remote shell commands directly with full interactive console without having to install any client software. On local machines it is also able to impersonate so can be used as a silent replacement for Runas command.

bzlm
thanks for the answer. Right now i'm working with my own WMI client, but it fails every now and then
benzhi
We all fail now and then. Don't worry about it.
bzlm
A: 

You can try to have psexec call a bat program that executes what you need on the remote machine. I ran into this issue with installutil.exe. A simple bat file on the remote machine resolved it.

You should also share your experience on the sysinternals board. There may be something they can do in a future revision.

rifferte
thanks. This is how i first solved it, but the batch runs to fast and then exits, so i'm not able to read the info.
benzhi
Doesn't "pause" remedy that?
bzlm
well - you would have to pause within the bat file I suppose.
rifferte
+1  A: 

I've experienced 'hangs' when executing PSEXEC against a remote system, but I always attributed it to the security context in which the remote process was running under.

From PSEXEC help:

If you omit a username the remote process runs in the same account from which you execute PsExec, but because the remote process is impersonating it will not have access to network resources on the remote system. When you specify a username the remote process executes in the account specified, and will have access to any network resources the account has access to. Note that the password is transmitted in clear text to the remote system.

If your executing a process remotely, that then needs to access the database (stsadm.exe), then it could be failing trying to access the network resource, depending on how PSEXEC was executed. If thats the case, I'd imagine it would eventually time out and give some sort of resource unavailable message.

There are two things that generally done when executing deployment steps against a remote machine to prevent the behavior your describing:

  1. Like rifferte mentioned, make sure all assets needed to deploy are local to the remote machine (copy files, etc) before using PSEXEC to execute the script (*.bat, *.vbs, *.ps, etc) - so that everything runs 'local' to the remote machine.

  2. Run PSEXEC using a domain username/password when executing it - note that this information is passed in clear text to the remote server.

Zach Bonham