Script to Copy Directory to Program Files folder with Administrator rights

Asked

Viewed 455 times

1

Good afternoon, you guys, I would like to copy some files in *.vbs, to a folder in "Program Files(X86)" via logon Script. But the message that appears is that the user has no rights to make the copy.

psexec.exe -d -nobanner -u DOMÍNIO\administrator -p "SENHA" "copy \\meu servidor\pasta pública\arquivos  %PROGRAMFILES(X86)%\OCINV~1\Plugins%"

I appreciate any help!

  • psexec.exe will be barred by (all?) the Antivirus...

1 answer

0

Update: Based on the comment, disable UAC (User-Account-Control)...

On the station/server/pc to run psexec.exe:

Giving up a reg query in the key below return: EnableLUA REG_DWORD 0x1

reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" | findstr "EnableLUA"
Rem :: EnableLUA    REG_DWORD    0x1

rem ::  Então adicione a entrada/valor 0
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA /t REG_DWORD /d 0 /f

1) I suggest to check in the station of destination, if it exists this key and if it is enabled(0x1):

reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system" | find "LocalAccountTokenFilterPolicy" | find "0x1"

If it exists and is enabled, the command returns to you:

LocalAccountTokenFilterPolicy    REG_DWORD    0x1

2) If there is no or the value differs from 0x1, use this command to add/enable:

reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system" /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f

3) Remove the -d argument and add -i -h -s, use password without quotation marks and try with cmd /c copy:

psexec.exe -i -h -s -nobanner -u dominio\administrator -p SENHA "cmd /c copy "\\meu servidor\pasta publica\arquivos\*.vbs"  "%PROGRAMFILES(X86)%\OCINV~1\Plugins\""

4) See the documentation:

Note: 1) Option 1 and 2 are for remote access.

Note: 2) I searched online posts on the topic without finding anything that states that copying files via remote action, can operate in destination folders other than between shared folders, there are only a few that suggest creating a bat for this task.

Note: 3) Code has not been tested.


  • I tested your code @It Wasn’t Me, and the following message appeared: Couldn’t install PSEXESVC service:

  • Has the same message Couldn’t install PSEXESVC service:

  • It was edited a few hours ago...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.