bostonrake Posted January 26, 2016 Report post Posted January 26, 2016 Hey all, First, I posted this in a thread I started about a different batch file. I figure this one warrants its own thread. Hopefully that is ok! Anyway, I worked on this all day yesterday and I still can't get it to run. I have changed it to run locally instead of from the dp. I moved the batch file to the folder containing all the contents. Here is a look at the folder... You can ignore the "Batch for SCCM" folder as that was my testing folder for awhile. I'm now trying to run sccm_remove2010_install_2013.bat. The contents are... echo cd %~dp0 setlocal :DeployOffice call cscript OffScrub10.vbs ProPlus /bypass 1 /q /s /NoCancel start /wait setup.exe /configure proplus.xml :End Endlocal When I manually run this from c:\windows\syswow64\ccm\cached\packagefolder, it runs fine. However, I cannot get SCCM to run it. When I run it manually it changes the directory to the package folder located in c:\windows\syswow64\ccm\cached so it is able to run the files in the batch. I cannot figure out for the life of me why it doesn't run in SCCM... and I've looked at execmgr.log and it appears to call it fine, but nothing ever happens on the machine. Any ideas? Thanks, Doug Quote Share this post Link to post Share on other sites More sharing options...
bostonrake Posted February 12, 2016 Report post Posted February 12, 2016 I finally got this to work! Long story short, my batch file has a script at the beginning to get admin/elevation rights. It looks like this... @Echo Off Setlocal :: First check if we are running As Admin/Elevated FSUTIL dirty query >nul if %errorlevel% EQU 0 goto START ::Create and run a temporary VBScript to elevate this batch file Set _batchFile=%~f0 Set _Args=%* :: double up any quotes Set _batchFile=""%_batchFile:"=%"" Set _Args=%_Args:"=""% Echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\~ElevateMe.vbs" Echo UAC.ShellExecute "cmd", "/c ""%_batchFile% %_Args%""", "", "runas", 1 >> "%temp%\~ElevateMe.vbs" cscript "%temp%\~ElevateMe.vbs" Exit /B :START :: set the current directory to the batch file location cd /d %~dp0 :: Place the code which requires Admin/elevation below Echo We are now running as admin [%1] [%2] There is another one that works you can find here... http://www.techgainer.com/create-batch-file-automatically-run-administrator/ That site takes awhile to load... it has some stupid snow animation. Anyway, the above alone was not enough. I also had to edit the office scrub vbs file. I found the information on that here... http://www.windowsmanagementexperts.com/article-for-this-week/article-for-this-week.htm Hopefully this helps someone in the future! Thanks, Doug Quote Share this post Link to post Share on other sites More sharing options...