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.

  • reg ADD HKCU\Software\Sysinternals\PSexec /v EulaAccepted /t REG_DWORD /d 1 /f – STTR Jun 13 at 14:29
  • @STTR - You should submit an answer – Ramhound Jun 13 at 14:47
  • @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 Jun 13 at 15:10
  • Normally that registry value gets auto-added after you accept once. It's strange. – grawity Jun 13 at 15:36
  • 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 Jun 13 at 17:28
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

  • Thanks a lot! :) – Natiya Jun 14 at 7:41
2

Run psexec with the -accepteula parameter.

From the help when running psexec /? :

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.