1

local OS: Windows Server 2003 remote OS: Windows Server 2003 64-bit

I have a management server (32-bit) which has many scheduled batch scripts running on. One of the script is to use psexec to launch process on remote host(64-bit).

My script just simply does below. However it will return "The handle is invalid".

C:\psexec.exe \\%HOST% -i 1 -d -u %ADMINID% -p %ADMINPASSWORD% -w %PATH% MyApplication.exe

Look up online found that RDP to session 1 and psexec to session 1 may have different environment and different available system resources (handles). So that's probably why my psexec script doesn't work.

However, make psexec running under console session in the script does work.

C:\psexec.exe \\%HOST% -i 0 -d -u %ADMINID% -p %ADMINPASSWORD% -w %PATH% MyApplication.exe

There are some people say run psexec under WoW64 or let psexec launch the application under WoW64 can be a work-around on 64-bit machines. I am guessing psexec on console session does similar. Can anyone confirm?

My question: my application has GUI, so I still need it running in user session. Is there any way to do this? Please advise, thanks.

3

You can achieve running in interactive mode using below command:

C:\psexec.exe \\%HOST% -i 0 -d -u %ADMINID% -p %ADMINPASSWORD% -w %PATH% cmd /c MyApplication.exe 

Above works, if you don't want to capture exit code from the application launched.

1

Look up online found that RDP to session 1 and psexec to session 1 may have different environment and different available system resources (handles). So that's probably why my psexec script doesn't work.

No, that makes no sense. While it's true that some handles can be shared (inherited, actually) between processes, it doesn't make any sense outside the scope of programming.

There are some people say run psexec under WoW64 or let psexec launch the application under WoW64 can be a work-around on 64-bit machines. I am guessing psexec on console session does similar. Can anyone confirm?

WoW64 means "Windows on Windows 64". Basically, it's the 32-bits environment inside a windows 64 OS. Every win32 executable will be running "under" WoW64: there is no other way for the to run because they cannot use the 64bit version of the OS functions: they need to go through the translation layer provided by WoW64.

My question: my application has GUI, so I still need it running in user session. Is there any way to do this? Please advise, thanks.

That is probably the reason why your application is failing (not PSexec, but your app): it's trying to get a handle to a window and, since it's not running in an interactive environment, this call fails (I'm guessing it's trying to get a handle to explorer or something).

(beside that, try adding the -i switch as Rupasri Somavarapu suggested: it should work)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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