6

I have a program which uses psExec for retrieving environment variables on a remote host. I get the error: Could not start PSEXESVC service on xxhost Access denied.

This command works for windows 2003 servers but not 2008 (it works on 2008 if I run CMD as another user): psexec \xxhost -u xxdomain\xxuser -p xxpasswrd-h cmd /c echo %%JAVA_HOME^%%

I also tried creating a connection before executing psexec (with NET USE)-as above, this works on 2003 but not 2008: NET USE \XXhost psexec \host cmd /c echo %%JAVA_HOME^%%

The problem is that I can't use RUNAS in batchfiles as it prompts for password. So, does anybody know how a workaround without having to make changes on the remote server?

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
user3032725
  • 71
  • 1
  • 1
  • 4
  • This answer for Windows 7 worked for me, and might help: http://stackoverflow.com/questions/18791468/psexec-win7-to-win7-access-denied-psexesvc-remains – FreeText Jan 29 '15 at 22:43

3 Answers3

19

It took me hours to find a working way to PsExec between 2 Windows 7 Computers with non-Admin user starting PsExec ... Disabling UAC (EnableLUA=0, ConsentPromptBehaviorAdmin=0, LocalAccountTokenFilterPolicy=1) did not work, turning off the Firewalls did not work...

Here i found the working way - thanks JelmerS: (Info from https://serverfault.com/questions/489822/psexec-is-not-connecting-to-machine-using-supplied-username-and-password/489845)

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
Community
  • 1
  • 1
Paul Feld
  • 271
  • 3
  • 4
  • Hi wow, had no idea I got a reply on this one. But thanks, looking forward to trying it out! – user3032725 Sep 02 '14 at 11:34
  • It work! Thank you, but I wonder why psexec.exe \\MACHINE_NAME_HERE -u xxdomain\xxuser -p xxpassword -i notepad doesn't work, is it a known bug? – carfield Aug 16 '16 at 14:59
0

I'm using PsExec v2.2 and the problem was solved when I used psexec64.

https://community.spiceworks.com/topic/1977162-psexec-32-bit-on-64-bit-host-no-longer-working

arkhos
  • 391
  • 3
  • 4
0

For me, even using PSEXEC64 didn't work. Still received the same error. Here's what did work - I had to add the user that was running the psexec command to the remote machine's administrators group and then sign out, then sign in as that user.

But then I was getting a new error: "Logon Failure: the user has not been granted the requested logon type at this computer"

The fix for this problem was to add the -i switch to the command line. This only applies to PSEXEC version 2.30 and higher. So my command prompt looked like this:

psexec64 -u domain\username -p password -i \\remotemachinename cmd
Will Buffington
  • 1,048
  • 11
  • 13