Skip to content

Package fails running simple bat file

Featured Replies

Hi everyone,

I'm trying to push a simple batch file that will disable startup repair on windows 7. The batch file is only 2 lines but needs to run as an administrator:

bcdedit /set {default} recoveryenabled No 
bcdedit /set {default} bootstatuspolicy ignoreallfailures

I saved that as a .bat and created a package to deploy it to a collection. I set the command line option to be the name of the bat file, set it as a required package and set it to run as Administrator.

 

When it runs on the client machine, the execmgr log shows it running and exiting with error code 1. No changes are made in bcdedit. If I copy the script to the local machine, run a command prompt as admin, and run the script, it works fine. It seems like it's a permissions issue on the account that SCCM uses to run the script.

 

Are there certain SCCM accounts that should be local admins on the client computers? I have no issues when installing MSI's and EXE's using SCCM, but I can't figure this one out.

 

Any pointers anyone can offer?

 

Thanks

Did u test this Script Manually ( Without SCCM ) ?

  • Author

I did.

If I run it as a normal non-admin user it fails. If I run it from an elevated command prompt, it works fine and makes the changes to the BCD file.

While creating the program , specify to run it with admin access not in user context.

in CM 7, you have the option to chose where it say , whether or not used is logged in, which automatically takes it into admin context

  • Author

I think I figured the problem. All our clients are 64-bit Windows 7. Apparently when SCCM runs a script, it uses a 32-bit command line. From what I can tell, I was calling Bcdedit and the 32-bit command line was redirecting it to C:\Windows\Syswow64 where there is no BCDEdit.

 

I found this blog entry that talks about the issue

http://madluka.wordpress.com/2012/09/24/configmgr-2012-64bit-file-system-redirection-bites-again/

 

I tried using his suggested code at the top of my batch file and the BCD file actually gets changed now.

IF "%PROCESSOR_ARCHITEW6432%"=="" GOTO native
  %SystemRoot%\Sysnative\cmd.exe /c %0 %* Exit
:native
<your script starts here>

It's still returning an exit code of 1 saying there was an error, but that could be because of the new code I added.

  • 5 years later...

I encountered the same problem.

I think its solved like this in a single line TS. I will confirm this tomorrow after testing.

mklink cmdin64.exe "c:\Windows\System32\cmd.exe" & cmdin64.exe /c "command (in my case bcdedit /set testsigning on)"

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.