I have a Server 2008 R2 Standard. I need to execute a batch-file using psexec from my PC Win7. The only time this worked is when i disabled the UAC on my server. Deactivating the UAC is out of the question, I'm looking for a solution with UAC enabled.
Error message:
Could not start PSEXESVC service on remotehost:
Access denied.
PS: In my command line of psexec I'm using the administrator user of my server to execute the batch-file. The UAC level is 3 on my server.
Best regards,
Tasso
It took me hours to find a working way to PsExec between two Windows 7 computers with a non-Admin user starting PsExec.
Disabling UAC...
EnableLUA=0
ConsentPromptBehaviorAdmin=0
LocalAccountTokenFilterPolicy=1
...did not work, turning off the firewall did not work.
Here I found the working way - thanks JelmerS (PSexec is not connecting to machine using supplied username and password).
*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*
Best regards, Peter
It seems that running PsExec from a Win7/Win2K8 machine against a Win7/Win2K8 target, regardless of the "-u" and "-p" params on the PsExec command-line,those params are ignored and PsExec is being executed remotely with whatever user credentials we happen to be logged in locally with.
Even though you stating which user account to execute the command on the remote system it executes the psexec command as the user that opened the command window.
When opening the Command Prompt, please right click it and select 'run as Administrator'. Meanwhile, make sure the user has administrator privileges on target PC.
The only solution i see to offer is to use the "Runas" (with the account you will need on the remote system) command to execute PsExec and forget the -u -p params.
In command prompt, you can try as,
echo "password" > pwd
runas /env /netonly /user:domain\Administrator "psexec.exe your_local_program.bat" < pwd
del pwd
Or just:
echo password | runas /env /netonly /user:domain\Administrator "psexec.exe your_local_program.bat"
Moreover....
Don't forget to check your Anti-virus which frequently blocks several of the PStools.
Related
I want to run a program from startup by a batch file in startup folder, the file says this:
runas.exe /savecred /"user:pedro burgos" "%cd%\test.bat"
But, the problem is that when I run this and enter my password, it says Error 5: Access denied
Can anyone help me pls?
Found this in another forum.
Feel like a dumbass now, but do use caution, and get more info.
The runas command depends on the Secondary Logon service.
On my system, it is by default set to manual, and it is not activated.
AFAIK, this is a legacy feature, so that is probably the reason why it is not running.
EDIT:
It's legacy, because this command predates UAC; MS would like you to use UAC instead of runas, which is safer; you can trigger a UAC prompt by calling scripts in PowerShell with -Verb RunAs argument
Had the same issue as you on Server 2019, secondary logon service on manual. Your initial answer seemed to be the solution but it wasn't. On server 2019 the secondary logon service is on manual by default and will start automatic if you are using a run as command.
The answer was as is upgraded the server 2019 edition that the local system account didn't have the correct rights to engage with the secondary logon service.
Resolved the issue with this MS article (article is for server 2012)
Start CMD as administrator;
sc sdset seclogon D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWRPDTLOCRRC;;;IU)(A;;CCLCSWDTLOCRRC;;;SU)(A;;CCLCSWRPDTLOCRRC;;;AU)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)
try this
runas.exe /savecred /user:"pedro burgos" "%cd%\test.bat"
Make sure user "pedro burgos" actually has access to that directory. For example, one user can't just access other user's directories. You can test this theory by moving the script to something like C:\temp
I have written a batch file which starts OpenVPN. If the client is found, I check the connectivity by running PING. If the server is not found, then this means that although OpenVPN is running, the connection has not been established. At this point I want to restart OpenVPN. Because I am not using the admin account for this script, I always get the error "permission denied" when using TASKKILL /F. Is there anyway around this?
There are two methods of running a command with administrator privileges.
Solution 1:
Right-Click the batch-file and click run as admin.
Solution 2:
Use the runas command to run a command or batch file with administrative permissions. This way the process is still automate but you will still need to type in the password for administrator.
Example:
C:\> runas /user:administrator "taskkill /f /im explorer.exe"
Enter the password for administrator:
Type runas /? for more info.
if you are already the administrator, you can create a shortcut to your batch file and when you right click the shortcut -> properties -> advanced -> check the checkbox "run as administrator"
and voila!
everytime you run the batch script via this shortcut file, it will run as administrator and will kill without any discrimination, happily ever after
I am trying to clear IE cache of a remote computer by using the following script in Powershell
$computer= read-host "computer name"
psexec \\$computer -i 0 cmd /c RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351
It runs on the remote computer (the user can see it running) but does not clear cache of the logged on user.
I've also tried to copy a batch file containing the command RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351 on to the logged on user's desktop and then running it
$computer= read-host "computer name"
$user = read-host "User ID"
copy C:\test.bat \\$computer'\C$\Documents and Settings\'$user'\Desktop'
PsExec \\$computer -i 0 cmd /c "C:\Documents and Settings\$user\Desktop\test.bat"
Still no joy
If the user runs the batch file himself it clears his cache.
I just basically want to clear the IE cache of the logged on user remotely.
Any help will be highly appreciated.
Cheers
Ronnie
It's incredibly difficult to impersonate a user without knowing their password (imagine the security implications!). In my experience it's easier to run it as either a logon or logoff script using group policy.
We have a file that we send to the bank and it worked via bat file when sending through FTPS.exe but not we must use PSFTP.exe which works for the desktop user but not the service account. We have tried logging in as the service account user and running the process which works when we are logged in as but not when scheduled through a Windows Server. Have also tried putting the Y in the bat file to answer the validate question whcih we have to answer only once when using desktop user without success.
I have read a lot of hits online pointing to authentication, using two files, etc... but not sure how to implement them. I would really appreciate assistance with this.
here is my bat file which is called by Gentran as an executeable, server is Windows 2008 R2, Service Pack1:
SET MOVEitIP=FTX-SERVSH.bnymellon.com
SET MOVEitUser=******
SET MOVEitPassword=******
echo cd /inbound/trp/ >> frommoveit.txt
echo mput D:\GENSRVNT\PositivePay\*.txt >> frommoveit.txt
echo quit >> frommoveit.txt
psftp -batch %MOVEitIP% -l %MOVEitUser% -pw %MOVEitPassword% -b frommoveit.txt
del frommoveit.txt
Basically took script from bat file for FTPS.exe and updated it for PSFTP.exe to use. Again, this works as desktop user and service account user (when signed into the server) but not when automated.
Thank you in advance for your assistance.
Krise
The service account must have the "Log On Locally" rights otherwise the account will not be able to logon to execute the sheduled task. I think you will see the logon error in the eventvwr at the time the task was run.
I am Help Desk for a company and we have some computers on our VPN. We sometimes have to use Windows Remote Desktop to login to these computers. (mostly Windows XP but some Windows 7)
When we remote into a Windows the computer/session is locked
I would like to be able to make a popup appear on their computer saying they can log back in.
I use 2 command-line tools in order to issue remote commands: psexec & nircmd.
nircmd is useful because it has command-line options to make a pop-up but it will pop-up inside the session not on the "computer locked screen".
I have played with Local Security Policy and it will you to display a message when they first login but not while the session is locked.
It does have an option to display username while session is locked so somehow it can display certain things during a locked session.
#npocmaka Thanks
I ended up using msg.exe but because of restrictions on our company's network I used a combination of psexec and msg
msg server:IPADDRESS /v "message"
didn't work so I used
psexec \IPADDRESS -u username -p password msg /server:IPADDRESS /v "message"
but in order for it to work I had to run
psexec \IPADDRESS -u username -p password reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v AllowRemoteRPC /t REG_DWORD /d 1 /f
on the remote computer. I got the reg command from another post in StackOverflow actually!