What is the reason PSExec keeps asking to accept EULA?

1

I'm using PSExec in a script that I run in a Windows 10 to send some commands to a Windows 7. However, sometimes these commands don't work and I realized this happens because at random times, when I send the commands I get the message:

"This is the first run of this program. You must accept EULA to continue. Use -accepteula to accept EULA."

So the commands don't take any effect. Then, I manually send the commands and accept the EULA and everything works fine till the next random time when the previous message is shown again.

I'd like to know a way to stop this behaviour.

Natiya

Posted 2019-06-13T14:12:15.827

Reputation: 179

reg ADD HKCU\Software\Sysinternals\PSexec /v EulaAccepted /t REG_DWORD /d 1 /f – STTR – 2019-06-13T14:29:31.813

@STTR - You should submit an answer – Ramhound – 2019-06-13T14:47:20.043

@STTR you mean I need to add that registry key value? Is that what I should type in the command line? which PC: the Windows 10 or 7? thanks!! – Natiya – 2019-06-13T15:10:37.827

Normally that registry value gets auto-added after you accept once. It's strange. – user1686 – 2019-06-13T15:36:14.590

This command will work on almost the entire Windows family, where you can run psexec. You need administrative privileges, i.e. You must run the command prompt as an administrator. In fact, this is an alternative to the method of installing the key in the manual via regedit. – STTR – 2019-06-13T17:28:35.727

Answers

1

The problem is that your scripts can run in different contexts. For example, the user may be recognized as local and the script will begin to be executed on his behalf. Often, Group Policy scripts run on behalf of the system user, and so on. Among other things, you are running a script with a different system environment. Before starting the script, when you have already connected to the resource, it is worth checking the environment variables that are important for you to answer the question where and with what rights and in what environment your script is executed. For a number of systems, in particular, Windows 7 has temporary variables, "Volatile".

ReadEnv.vbs:

Set WshShell = CreateObject("WScript.Shell")
Set WshEnv = WshShell.Environment
WScript.Echo "WINDIR=" & WshEnv.Item("WINDIR")  & vbCrLf &_
                                                  vbCrLf

Set WshShell = CreateObject("WScript.Shell")
WScript.Echo "Environment System:"              & vbCrLf &_ 
"..............................................."
For Each IEnv In WshShell.Environment("System")
    WScript.Echo IEnv
Next

WScript.Echo vbCrLf & "Environment User:"       & vbCrLf &_ 
"..............................................."
For Each IEnv In WshShell.Environment("User")
    WScript.Echo IEnv
Next

WScript.Echo vbCrLf & "Environment Volatile:"   & vbCrLf &_ 
"..............................................."
For Each IEnv In WshShell.Environment("Volatile")
    WScript.Echo IEnv
Next
WScript.Echo vbCrLf & "Environment Process:"    & vbCrLf &_ 
"..............................................."
For Each IEnv In WshShell.Environment("Process")
    WScript.Echo IEnv
Next

view:

cscript ReadEnv.vbs | more

save to file:

cscript ReadEnv.vbs >> out.txt

If you do not care from which user your script is executed, you can add a line to it

psexec //YourRemoteStationName reg ADD HKCU\Software\Sysinternals\PSexec /v EulaAccepted /t REG_DWORD /d 1 /f

in this case, you will receive a key installation at the remote station and

to install the key if psexec runs local:

reg ADD HKCU\Software\Sysinternals\PSexec /v EulaAccepted /t REG_DWORD /d 1 /f

STTR

Posted 2019-06-13T14:12:15.827

Reputation: 6 180

Thanks a lot! :) – Natiya – 2019-06-14T07:41:57.910

2

Run psexec with the -accepteula parameter.

From the help when running psexec /? :

-accepteula This flag suppresses the display of the license dialog.

harrymc

Posted 2019-06-13T14:12:15.827

Reputation: 306 093