Jump to content


bostonrake

Another Batch File Problem

Recommended Posts

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...



post-29990-0-66440900-1453756823.jpg



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



Share this post


Link to post
Share on other sites

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...
Hopefully this helps someone in the future!
Thanks,
Doug

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.