PSexec Not Connecting – Troubleshooting Username and Password Issues

pstools

I'm trying to connect from a Win 7 machine to a Win2k8R2 machine using the command:

psexec \MACHINE_NAME_HERE -u MACHINE_NAME_HERE\Administrator -p PASSWORD_HERE notepad

When I try this I get the error message:

Couldn't access MACHINE_NAME_HERE Access is denied.

I tried omitting the -p and manually putting in the password, but the same issue persists.

When I check the machine I'm trying to access I see that in the security event viewer that the Administrator login was successful, so I know the username password is correct, and the machine is accepting my login, but I also noticed that it tries to also log in with my domain account, which isn't in the admin list on the remote machine. If I add my domain account to the remote machine then everything works, but in this case it defeats the purpose, sometimes I need to be able to run commands on the machine when it's no on the domain.

The machine is set to use the simple model for Sharing and Security as well.

Best Answer

This is because psexec still tries to access the ADMIN$ share with your local credentials, before executing your command as another user. According to this thread, you can cache credentials before executing psexec:

cmdkey.exe /add:MACHINE_NAME_HERE /user:MACHINE_NAME_HERE\Administrator /pass:PASSWORD_HERE 
psexec.exe \\MACHINE_NAME_HERE -i notepad
cmdkey.exe /delete:MACHINE_NAME_HERE

I added -i, since you specified running notepad here. Without the -i, notepad will sit idle with no interacton. Also, please remembet that, when you use -u, psexec will send the password in plaintext.