PsExec: Win7-to-Win7 Access Denied (psexesvc remains)

大憨熊 提交于 2019-12-03 21:34:53

Bit late, I know, but I've just been trying to solve this too. Turns out it has to do with security levels / user access levels.

I was trying to run psexec from a command prompt on a local PC and had started the command prompt by right clicking and choosing "Run as administrator". Then I'd run the psexec command targetting a remote server and specify a domain admin account for the -u parameter.

However, my local account only had administrative privileges on the local machine, not the remote one and choosing "run as administrator" doesn't actually mean "run as domain administrator"! (Obviously, duh!).

So, in effect, what was happening was that it was trying to run my main command as a domain admin on the remote but the psexec part was being run as my (non-admin) domain user account - which didn't have the appropriate permissions on the server.

Solution: Instead of starting a command prompt as above use the runas command.

eg: Start -> Run -> runas /user:domain\administrator cmd
then run your psexec command and you won't need the -u flag

or, from inside a normal command prompt you could do this instead:

runas /user:domain\administrator "psexec \\remote cmd"

after trying everything and still not getting any good results I figured what was the issue at least in my case. I had a machine with logged in domain account(not domain admin but at least local to the machine admin) and few other machines that had local accounts with admin rights. Psexec worked on all of them but was not working on my machine using domain account with local admin rights. On the machine that psexec worked with the local admin account I logged in with my domain account with local admin rights - and to no surprise it did not work.

So bottom line is that you should start the psexec call to the remote server with admin account local to the machine that you are sending the call from.

Better yet just insert this before your psexec string which will go now in double quotes

runas /user: ""

this way psexec will run but using the local admin account and no need to actually log in with the local admin account

The only way which works for me was to set the network credentials:

cmdkey /list:%DOMAIN% | find "%DOMAIN_USER%" >NUL || cmdkey /add:%DOMAIN% /user:%DOMAIN%\%DOMAIN_USER% /pass:%DOMAIN_USER_PWD% >>%LOGFILE% 2>>&1

Runas was not possible with local shares and other permissions.

I know this is really late, however as it's the first search in Google I am going to reply.

Through much research I found that you need to have the username and password BEFORE the system name, so instead of:

psexec \\remote -u domain\user -p password -i -d cmd.exe

Do it this way:

psexec -u domain\user -p password -i -d \\remote cmd.exe

I wanted to install a program from a server share (the PC I'm working on, I was logged in as domain administrator) remotely on "RemotePC".

PsExec worked on RemotePC with "local" programs (local to "RemotePC") like cmd.exe:

PsExec.exe \\RemotePC cmd.exe

Initially, my full command looked like this:

PsExec.exe \\RemotePC "\\server\sharename\path to program\setup.exe" /s /v"/qn IP_SERVER=192.168.1.10 PORT=112 INSTALLDIR=\"%ProgramFiles(x86)%\path\ \" "

But the setup from the server share didn't start. Error message:

PsExec could not start \\server\sharename\path to program\setup.exe on RemotePC

Access is denied

I tried much of the solutions I found here and on other websites like adding PsExec -u administrator -p password and using cmd.exe /c, but it didn't work.

Finally I found a working command (the /s with extra quotes around the commandline did the trick):

PsExec.exe \\RemotePC -u administrator -p AdminPassword cmd.exe /s /c " commandline "

The full working command looks like this:

PsExec.exe \\RemotePC -u administrator -p AdminPassword cmd.exe /s /c " "\\server\sharename\path to program\setup.exe" /s /v"/qn IP_SERVER=192.168.1.10 PORT=112 INSTALLDIR=\"%ProgramFiles(x86)%\path\ \" " "

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!