Search code examples
cmdpsexecrunas

Can't force psexec to use the given user account


I used to use runas for running my app under another user account. Now I need to pass the password through as well. I found that psexec is an easy way to do it.

So the batch file contains:

@echo off
psexec my.exe -u hostname\user -p password

The problem is my.exe is still being initiated under the user I'm currently logged onto the system with and not under the one declared in the cmd above.


Solution

  • the program must be the last argument try this :

    psexec -u hostname\user -p password my.exe