What is the reason PSExec keeps asking to accept EULA?
Solution 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
Solution 2
Run psexec
with the -accepteula
parameter.
From the help when running psexec /?
:
-accepteula This flag suppresses the display of the license dialog.
Related videos on Youtube
Comments
-
Natiya over 1 year
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.
-
STTR almost 5 yearsreg ADD HKCU\Software\Sysinternals\PSexec /v EulaAccepted /t REG_DWORD /d 1 /f
-
Ramhound almost 5 years@STTR - You should submit an answer
-
Natiya almost 5 years@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!!
-
user1686 almost 5 yearsNormally that registry value gets auto-added after you accept once. It's strange.
-
STTR almost 5 yearsThis 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 viaregedit
.
-