Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PSexec and windows 2008 server (access denied)

Tags:

psexec

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?

like image 358
user3032725 Avatar asked Dec 04 '13 11:12

user3032725


People also ask

How do I enable PsExec?

Open the windows command prompt and switch to the pstools directory, then type psexec and press enter. You should see PsExec return the version and command syntax.

What user does PsExec run as?

Normally PSExec will run with the credentials of the local user that has run the command.

Which directory will PsExec try to access?

All Computers in an Active Directory Domain PsExec will search your entire Active Directory domain and attempt to run a command on every computer.


1 Answers

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
like image 77
Paul Feld Avatar answered Sep 28 '22 02:09

Paul Feld