Running psexec with username / password switches + program parameters causes "The handle is invalid" error.

Posted on 2011-05-05
Medium Priority
Last Modified: 2012-05-11
Hi There,

I have an application that I am launching with psexec via an ssh session that I log into on the remote machine.  So, I am calling psexec on the remote machine itself.  The remote machine--a Windows 7 box--hosts MobaSSH which is a free SSH server for Windows.  The application I am launching has a GUI which must launch because I need to pass a script to the application.  The application must completely load before the script is processed.

Once logged in to the remote machine via SSH, I can launch the application, in interactive mode, with the following incantation:

psexec -d -i 2 -u myusername -p mypassword myapp -m

The application launches fine, and it is usable.  But I get the following error / output in my terminal window:

The handle is invalid.
Couldn't install PsExec service:
Starting myapp on mycomputer . . . on mycomputer. . .
myapp started on mycomputer with process ID 3900

So while I can launch the application fine, the problem is that I cannot pass the script to the application with its switch with this incantation

psexec -d -i 2 -u myusername -p mypasswrod myapp -m -r myscriptfile.jsx

I get the same error, and the script simply does not get read in by the application.  I have verified that if I am on the console session at the remote machine, and I simply type the following in a cmd shell, the script executes just fine:

myapp -m -r myscriptfile.jsx

Does anybody know what the "The handle is invalid.  Couldn't install PsExec service" error is?  Is that what is causing my script not to execute when myapp launches?

If you have any tips, suggestions, ideas as to how to solve this problem, I would be grateful.

Thank you for your time and help!
Question by:ariestav
  • 2
  • 2
LVL 12

Accepted Solution

serchlop earned 2000 total points
ID: 35699093
Have you tried to create a bat file with the line

myapp -m -r myscriptfile.jsx

and the call the bat in the psexec.
LVL 12

Expert Comment

ID: 35699135
Why do you uses -i 2, do you need to start the myapp in the second session?

psexec -d -i 2 -u myusername -p mypasswrod myapp -m -r myscriptfile.jsx

maybe you can try
psexec -d -i -u myusername -p mypasswrod myapp -m -r myscriptfile.jsx
to interact with desktop user.

Author Comment

ID: 35699276
@serchlop I'm verifying everything works via remote desktop which runs on a second session, that's why I use -i 2.  The batch file is a good idea, and I will try it, thank you.

Author Closing Comment

ID: 35699488
The batch file worked after I used a absolute path to the script file for my application.  Thank you for the suggestion to do so!

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
While Plesk offers many potential benefits to website administrators, including compatibility with Windows Server and other leading technologies, the company has also been working to differentiate it from other control panels for content management…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question