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

Posted on 2011-05-05
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
    LVL 12

    Accepted Solution

    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

    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.
    LVL 4

    Author Comment

    @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.
    LVL 4

    Author Closing Comment

    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

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    How can you create a game plan that lets you focus on special projects instead of running from cubicle to cubicle every day and feeling like you’ve accomplished nothing? Try these strategies for prioritizing your tasks, offloading what you can, and …
    If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
    This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
    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.

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    27 Experts available now in Live!

    Get 1:1 Help Now