Why won't this script run on startup?

TheSmJ

2[H]4U
Joined
Dec 20, 2006
Messages
2,749
I have a computer GPO set to run the following script upon boot:

Code:
@echo Off
:Created: MArtin Mayr / 20130624
:purpose: Setup SAP GUI 7.30 and patches

if exist c:\SAPInstalled.txt goto end
echo SAP Install-started to %computername% on %date% %time% >> \\MI-NORFS01\temp$\SAPGUI\SAPInstalled.txt
: Install SAPGUI silent
\\MI-NORFS01\temp$\SAPGUI\11A00102\GUI\WINDOWS\WIN32\setup\NwSAPsetup.exe /package:"Gentherm Default Package" /silent
echo SAP Installed to %computername% on %date% %time% >> \\MI-NORFS01\temp$\SAPGUI\SAPInstalled.txt
 
: sapllogon.ini and saplogontree.xml must be in the program files folder to work properly
:set default SAP Location
set SAPGUI_folder="%ProgramFiles%\SAP\FrontEnd\SAPgui\"

:check for X64 machine destination folder
if exist "%ProgramFiles(x86)%\SAP\FrontEnd\SAPgui\" set SAPGUI_folder="%ProgramFiles(x86)%\SAP\FrontEnd\SAPgui\"

xcopy /y \\MI-NORFS01\temp$\SAPGUI\11A00102\_CONFIG\saplogon.ini %SAPGUI_folder%
rem xcopy /y \\MI-NORFS01\temp$\SAPGUI\11A00102\_CONFIG\saplogontree.xml %SAPGUI_folder%

rem delete saplogontree.xml because it causes issues
del %SAPGUI_folder%\saplogontree.xml

xcopy /y \\MI-NORFS01\temp$\SAPGUI\11A00102\_CONFIG\sapmsg.ini %SystemROOT%\

xcopy /y \\MI-NORFS01\temp$\SAPGUI\11A00102\_CONFIG\sapdoccd.ini %SystemROOT%\

:create links
xcopy /y "\\MI-NORFS01\temp$\SAPGUI\11A00102\_CONFIG\SAP Logon.lnk" "C:\Users\Public\Desktop\"
xcopy /y "\\MI-NORFS01\temp$\SAPGUI\11A00102\_CONFIG\SAP Logon.lnk" "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\SAP Front End\"
xcopy /y "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\SAP Front End\" "C:\Users\Public\Desktop\"

echo SAP Installed >> C:\SAPInstalled.txt

:end
If I run this script manually as an administrator, everything works as it should. If I run it manually as System via PSExec, it works. It doesn't run at all when I try to have it start at boot using a Computer GPO. GPresults show that the GPO was accepted, and there are no errors in the event logs, however the script is never actually run.

I'm all out of ideas here. Obviously the permissions in the shares are right or else I wouldn't have been able to run it manually as System. It's as though the computer looks at the script, goes "Meh..." and skips over it.
 
As a test turn off UAC on a machine and deploy your script to that machine.

What I bet is occuring is that your script is not running as invoker...aka "elevated admin"

My manually running it in a command prompt you automatically run it as envoker.


You can test to see if something like batchpatch can run it. Or you can use something like a batch file compressor to convert the script to an exe file and THEN convert it to an MSI and use ORCA to give it the correct installation rights.

Another option would be https://ninite.com/pro
 
The user "system" does not give the computer account access to the script. Either give the computer account access to the script directly or just use authenticated users or domain computers (which is not intuitive).

You don't get errors in the log because the GPO telling the client to run a script was applied successfully. If the script itself runs is another matter entirely and has nothing to do with the former :)
 
Last edited:
Sorry about the delay. I was on vacation and really needed to distance myself from this problem.

As much as I'd like to, I cannot use other software to fix this.

It's not just this batch file. It's any or all startup batch files (lucky we do not normally use them).

The share that the batch is pointing to has full rights for "Everyone", and the same exact GPO works for other computers under another OU. So, can't be permissions or a bad script/GPO.

I'm at wit's end here...
 
Back
Top