Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am actually not sure that this is possible. let's see:

I have a script that runs on a Build server. Let's name this server A.
It drops the bins to a shared folder on server B. And I want to run the program on server C.

So using caspol I can allow the executable to be ran remotely. that means from B I can run \C\shared\my.exe

What I want to do is from A run \C\shared\my.exe on B.

SysInternals\PsExec.exe -u username -p password -accepteula \\ServerC -i 0 -d -w \\ServerB\Nightly\Server \\ServerB\Nightly\Server\server.exe

The user has all the necessary rights.

But, the -w (working directory) options apparently wants a path relative to the server I point to. Any idea?

share|improve this question

3 Answers 3

Without knowing what your application does, do you need to define the working path? I may be wrong, but I don't believe UNC paths are supported? What about a little trickery, and doing a map of a network drive, and bundle it up in a script? Something like:

pushd \\ServerB\Nightly\Server
server.exe
popd

Put this in a script, then call it using psexec:

psexec -u username -p password \\machine -accepteula -i 0 -d \\serverb\nightly\server\myscript.bat

The pushd command maps the next available drive letter to the share, and then changes directory to that new map. popd returns back to the previous path, and unmounts the drive.

share|improve this answer
    
Ha, that is really cool commands that I didn't know about, I'll try that as soon as I have time for this again. I spent too much time on this and needed to postpone it. I'll get back to you as soon as I tried this :). At least if it doesn't solve it, I learnt smthg :) –  Stephane Jan 13 '11 at 10:23

try it with the -e switch as well (doesn't try to load the user's profile) not too sure about the "-accepteula" switch either since psexec doesn't prompt for one AFAIK and this doesn't appear to be a valid switch for psexec...

The 2 switches "-i" and "-d" contradict each other since -i makes it run interactively and -d says only to use it with non-interactive applications. I have never had a need to use either switch.

The best way to approach a troublesome operation involving remote systems that I have found is first try to run it locally, then slowly start moving different components to remote boxes and getting them to work from there. That way you figure out exactly where the problem lies in your syntax of your original attempt.

psexec usage

share|improve this answer
    
nope, -i is to interact with the desktop (like a console app), while -d will not wait to terminate (so that psexec doesn't keep running as long as the remote program runs). they don't contradict eachother. accepteula was necessary. I have tested it. And this was working perfectly as long as I didn't put the executable on a shared folder. But thanks –  Stephane Jan 11 '11 at 14:27
    
if you go to the "psexec usage" page i provided it specifically says for -d "Don't wait for application to terminate. Only use this option for non-interactive applications." You are forcing it to be interactive by using the -i switch. Try it is all I'm saying...if the main issue appears to be with the working directory, try putting this psexec command in a batch that maps the UNC path to a drive letter first and reference the drive letter in the psexec line. Maybe psexec has an issue with using a UNC path as a working directory. –  August Jan 11 '11 at 14:33

In your script you can copy the thing that you want to run to the local machine disk and after run it delete it. Use robocopy.exe \UNC-Path LocalDestionation to copy the file, run it and after that delete it. Remenber that you always have envitoment variables like %Temp% to use.

For your case running using Sysinternals PSExec you can try make a bat that runs every bat line started with PSExec. You can use enviroment variables in the bat using the SET command for things like the username.

Alternative I recommend you to test this free software that let you run remote commands very easy with a simple GUI: PQD Deploy.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.