mahmoud_2008
asked on
Run a script with admin rights
Dear All,
I already posted a question regarding a problem I face which is in the following:
https://www.experts-exchange.com/questions/24283794/Copy-files-through-group-policy.html
In summary users need to have admin rights to run such a script, how to accomplish this since the users doesn't have admin rights on their machines? and I don't know their computer names?
I already posted a question regarding a problem I face which is in the following:
https://www.experts-exchange.com/questions/24283794/Copy-files-through-group-policy.html
In summary users need to have admin rights to run such a script, how to accomplish this since the users doesn't have admin rights on their machines? and I don't know their computer names?
Use a GPO to apply a *computer* *startup* script to the machines in question. Unlike login scripts, startup scripts run in the system's security context, and the system has the necessary permissions to add files to the system32 folder.
ASKER
I did the following:
create a startup script at computers stratup with the following:
copy \\DC(IP)\netlogon\Filename 1 c:\windows\system32
copy \\DC(IP)\netlogon\Filename 2 c:\windows\system32
copy \\DC(IP)\netlogon\Filename 3 c:\windows\system32
apply this group policy for computers but still I couldn't see the files copied to the machines which I apply the froup policy into it, did I miss something?
create a startup script at computers stratup with the following:
copy \\DC(IP)\netlogon\Filename
copy \\DC(IP)\netlogon\Filename
copy \\DC(IP)\netlogon\Filename
apply this group policy for computers but still I couldn't see the files copied to the machines which I apply the froup policy into it, did I miss something?
The syntax looks okay. If the file names contain spaces, you need to enclose them in quotes, and you might want to take %Systemroot% instead of C:\Windows
Save the script as startup.cmd or whatever.cmd in the netlogon share, then set the policy to run (obviously replacing your.domain.local with your domain name)
\\your.domain.local\netlog on\startup .cmd
In addition, you might want to create a log file; if there is no file with the name of the script and the extension .log in %Systemroot%\Temp after a reboot of the machine, you need to check your event log and your group policies, because the script isn't running.
Save the script as startup.cmd or whatever.cmd in the netlogon share, then set the policy to run (obviously replacing your.domain.local with your domain name)
\\your.domain.local\netlog
In addition, you might want to create a log file; if there is no file with the name of the script and the extension .log in %Systemroot%\Temp after a reboot of the machine, you need to check your event log and your group policies, because the script isn't running.
set LogFile=%Systemroot%\Temp\%~n0.log
>>"%LogFile%" echo %Date% %Time%: Startup script started
copy "\\DC(IP)\netlogon\Filename1" "%Systemroot%\system32" >>"%LogFile%"
copy "\\DC(IP)\netlogon\Filename2" "%Systemroot%\system32" >>"%LogFile%"
copy "\\DC(IP)\netlogon\Filename3" "%Systemroot%\system32" >>"%LogFile%"
ASKER
oBdA it display the following error messages:
Wed 04/08/2009 7:29:22.72: Startup script started
Access is denied.
Access is denied.
Access is denied.
Access is denied.
Wed 04/08/2009 7:29:22.72: Startup script started
Access is denied.
Access is denied.
Access is denied.
Access is denied.
Try the following script, it will give you a detailed log about which permissions are missing.
Just adjust SourceFolder variable (no quotes around the path) and the source files (each file separated by a space from the next, quotes around each file name if it contains a space).
Just adjust SourceFolder variable (no quotes around the path) and the source files (each file separated by a space from the next, quotes around each file name if it contains a space).
set LogFile=%Systemroot%\Temp\%~n0.log
>>"%LogFile%" echo %Date% %Time%: Startup script started
set SourceFolder=\\DC(IP)\netlogon
set SourceFiles="Filename 1" "Filename 2" "Filename 3"
set TargetFolder=%Systemroot%\system32
>>"%LogFile%" echo Profile: %UserProfile%
>>"%LogFile%" echo Source folder directory listing:
dir "%SourceFolder%" >>"%LogFile%" 2>&1
if errorlevel 1 (
>>"%LogFile%" echo Unable to read from "%SourceFolder%"; exiting script.
goto :eof
)
>>"%LogFile%" echo Target folder directory listing:
dir "%SourceFolder%" >>"%LogFile%" 2>&1
if errorlevel 1 (
>>"%LogFile%" echo Unable to read from "%TargetFolder%"; exiting script.
goto :eof
)
>>"%LogFile%" echo Testing write access to target folder:
copy "%~f0" "%TargetFolder%" >>"%LogFile%"
if errorlevel 1 (
>>"%LogFile%" echo Unable to write to "%TargetFolder%"; current permissions:
cacls "%TargetFolder%" >>"%LogFile%" 2>&1
goto :eof
)
>>"%LogFile%" echo Permissions verified.
del "%TargetFolder%\%~nx0"
for %%a in (%SourceFiles%) do (
>>"%LogFile%" echo Copying %%~a ...
copy "%SourceFolder%\%%~a" "%TargetFolder%" >>"%LogFile%"
)
ASKER
Hi oBdA
I configure the script as below:
But it display the following error, even I I run login to the PC with a domain admin rights:
Thu 04/09/2009 8:32:45.53: Startup script started
Profile: C:\Documents and Settings\Default User
Source folder directory listing:
Access is denied.
Unable to read from "\\172.16.2.1\netlogon"; exiting script.
I configure the script as below:
But it display the following error, even I I run login to the PC with a domain admin rights:
Thu 04/09/2009 8:32:45.53: Startup script started
Profile: C:\Documents and Settings\Default User
Source folder directory listing:
Access is denied.
Unable to read from "\\172.16.2.1\netlogon"; exiting script.
set LogFile=%Systemroot%\Temp\%~n0.log
>>"%LogFile%" echo %Date% %Time%: Startup script started
set SourceFolder=\\172.16.2.1\netlogon
set SourceFiles="piot2.dll" "xeres-c1.dll" "locale-1-20.dll"
set TargetFolder=%Systemroot%\system32
>>"%LogFile%" echo Profile: %UserProfile%
>>"%LogFile%" echo Source folder directory listing:
dir "%SourceFolder%" >>"%LogFile%" 2>&1
if errorlevel 1 (
>>"%LogFile%" echo Unable to read from "%SourceFolder%"; exiting script.
goto :eof
)
>>"%LogFile%" echo Target folder directory listing:
dir "%SourceFolder%" >>"%LogFile%" 2>&1
if errorlevel 1 (
>>"%LogFile%" echo Unable to read from "%TargetFolder%"; exiting script.
goto :eof
)
>>"%LogFile%" echo Testing write access to target folder:
copy "%~f0" "%TargetFolder%" >>"%LogFile%"
if errorlevel 1 (
>>"%LogFile%" echo Unable to write to "%TargetFolder%"; current permissions:
cacls "%TargetFolder%" >>"%LogFile%" 2>&1
goto :eof
)
>>"%LogFile%" echo Permissions verified.
del "%TargetFolder%\%~nx0"
for %%a in (%SourceFiles%) do (
>>"%LogFile%" echo Copying %%~a ...
copy "%SourceFolder%\%%~a" "%TargetFolder%" >>"%LogFile%"
)
Then somebody changed the permissions of the netlogon folder. "Authenticated Users" have to have Read permissions (and this is configured by default), this is not the case with your netlogon share. You need to investigate what happened with these permissions, and change them back to their defaults.
This article might help, but make sure you have a working backup of your DC(s) should you decide to implement it:
Reapply Default SYSVOL Security Settings
http://technet.microsoft.com/en-us/library/cc816750.aspx
This article might help, but make sure you have a working backup of your DC(s) should you decide to implement it:
Reapply Default SYSVOL Security Settings
http://technet.microsoft.com/en-us/library/cc816750.aspx
ASKER
Hi oBdA, and thanks for your support
I checked the permissions, there is everyone with Read only access on the NETLOGON folder, also I login with a domain admin rights to the PC and when I execute \\IP\netlogon I was able to browse the folder and see the files.
I checked the permissions, there is everyone with Read only access on the NETLOGON folder, also I login with a domain admin rights to the PC and when I execute \\IP\netlogon I was able to browse the folder and see the files.
Create a share "Test" on your DC, share it as Test, and add "Authenticated Users" with Read permissions to this folder.
Put the files into this folder, and set SourceFolder to \\172.16.2.1\Test (see script below).
Try again.
Put the files into this folder, and set SourceFolder to \\172.16.2.1\Test (see script below).
Try again.
set LogFile=%Systemroot%\Temp\%~n0.log
>>"%LogFile%" echo %Date% %Time%: Startup script started
>>"%LogFile%" echo Script: %~dpnx0
set SourceFolder=\\172.16.2.1\Test
set SourceFiles="piot2.dll" "xeres-c1.dll" "locale-1-20.dll"
set TargetFolder=%Systemroot%\system32
>>"%LogFile%" echo Profile: %UserProfile%
>>"%LogFile%" echo Source folder directory listing "%SourceFolder%":
dir "%SourceFolder%" >>"%LogFile%" 2>&1
if errorlevel 1 (
>>"%LogFile%" echo Unable to read from "%SourceFolder%"; exiting script.
goto :eof
)
>>"%LogFile%" echo Target folder directory listing:
dir "%SourceFolder%" >>"%LogFile%" 2>&1
if errorlevel 1 (
>>"%LogFile%" echo Unable to read from "%TargetFolder%"; exiting script.
goto :eof
)
>>"%LogFile%" echo Testing write access to target folder:
copy "%~f0" "%TargetFolder%" >>"%LogFile%"
if errorlevel 1 (
>>"%LogFile%" echo Unable to write to "%TargetFolder%"; current permissions:
cacls "%TargetFolder%" >>"%LogFile%" 2>&1
goto :eof
)
>>"%LogFile%" echo Permissions verified.
del "%TargetFolder%\%~nx0"
for %%a in (%SourceFiles%) do (
>>"%LogFile%" echo Copying %%~a ...
copy "%SourceFolder%\%%~a" "%TargetFolder%" >>"%LogFile%"
)
ASKER
same error message, but now the folder change Unable to read from "\\172.16.2.1\test"; exiting script.
strange problem !!!
strange problem !!!
Please post the complete log file.
ASKER
oBdA,
Even if I change the directory from %Systemroot%\system32 to c:\dell I got the same error.
Even if I change the directory from %Systemroot%\system32 to c:\dell I got the same error.
Thu 04/09/2009 10:06:52.24: Startup script started
Profile: C:\Documents and Settings\Default User
Source folder directory listing:
Access is denied.
Unable to read from "\\172.16.2.1\netlogon"; exiting script.
Thu 04/09/2009 14:24:25.12: Startup script started
Profile: C:\Documents and Settings\Default User
Source folder directory listing:
Access is denied.
Unable to read from "\\172.16.2.1\test"; exiting script.
Thu 04/09/2009 14:32:10.36: Startup script started
Profile: C:\Documents and Settings\Default User
Source folder directory listing:
Access is denied.
Unable to read from "\\172.16.2.1\test"; exiting script.
Thu 04/09/2009 14:38:43.60: Startup script started
Profile: C:\Documents and Settings\Default User
Source folder directory listing:
Access is denied.
Unable to read from "\\172.16.2.1\test"; exiting script.
Did you add "Authenticated Users" (NOT "Users" or "Domain Users") with Read permissions to the test folder?
Are the Share permissions configured to allow at least Read permissions to Everyone?
The *computer* *account* needs acccess to the shared folder (domain computers are members of Authenticated Users as well).
Are the Share permissions configured to allow at least Read permissions to Everyone?
The *computer* *account* needs acccess to the shared folder (domain computers are members of Authenticated Users as well).
ASKER
Yes, I already checked it, but still I face the same issue.
oBdA,
if I collect the computer names, is it possible to install these files remotely on these computers using a domain admin privilages?
oBdA,
if I collect the computer names, is it possible to install these files remotely on these computers using a domain admin privilages?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks oBdA,
I will try it and inform.
I will try it and inform.
ASKER
Thanks for your support