Jump to content

bcdedit /set TESTSIGNING ON command in Autoit?

Recommended Posts

Dear forum members;

I have been trying different ways to get bcdedit /set TESTSIGNING ON and OFF to work in Autoit. I have tried .bat file and .cmd files with admininstrator required acces in Autoit (#RequireAdmin).  I have tried following commands in autoit too:

Run("bcdedit /set TESTSIGNING ON", "C:\Windows\System32")

Run("bcdedit.exe -set TESTSIGNING", "C:\Windows\System32")


But after restart Testmode is not ON. 

I also tried to make a SFX of the .bat and .cmd files. But when I run the SFX.EXE file cmd screen goes in endless loops.

I found following topic, "How to enable test mode by "run" or "shellexecute"?", but without working advice. Can someone help me with a working command in Autoit? Or is this not possible in Autoit? 

I have a working cmd attached. When I doubleclick on the CMD, Testmode works after restart of Computer. But the cmd file is not working when I try to use it in Autoit. 

Thanks in advance. 



Link to post
Share on other sites

Hi Kajoe,

How did you run the script?

You should make sure you run the script with administrative privileges.  One of the ways is to compile your script, right click and "Run as administrator". Without administrative privileges you don't get access to bcdedit.exe utility.

Link to post
Share on other sites

There are a few ways that you can successfully run your bcedit command in AutoIt.

I can give you an explanation on why what you've tried so far hasn't worked, if needed.  Can you try the following command and see if it works for you?  Make sure that you keep the #RequireAdmin directive in the script.

ShellExecute("bcdedit.exe", "/set TESTSIGNING ON", "", "runas")


Edited by TheXman
Link to post
Share on other sites

I did. I have #RequireAdmin on top of my script


I see, you are right. The value is protected. This is the error:

An error has occurred setting the element data.
The value is protected by Secure Boot policy and cannot be modified or deleted.


Edited by Factfinder
Link to post
Share on other sites
1 minute ago, Kajoe said:

Can't find bcdedit.exe

You obviously understand what the error means.  Just supply the full path to the the bcdedit utility and rerun it.

ShellExecute("c:\windows\system32\bcdedit.exe", "/set TESTSIGNING ON", "", "runas")


Link to post
Share on other sites
7 minutes ago, Kajoe said:

HiI TheXman,

Thank you very much for helping. I tried your command and got following error message. Can't find bcdedit.exe


How do you compile your script? do you  compile to x64 version?

Apart from that:

Secure Boot is enabled for your computer's UEFI firmware. You need to disable Secure Boot first and then run the commands.

Edited by Factfinder
Link to post
Share on other sites

I find it very odd that you get an error message saying that it cannot find a system utility that is in the C:\Windows\System32 folder.  That folder is in the path by default.  How are you launching this script and in what type of environment (sccm, AD, psexec, etc)?

Since I cannot replicate the "not found" error, there's obviously something very different between your PC's environment and mine.

Link to post
Share on other sites

wauw Factfinder that did the trick. I had compiled as x86 instead of x64.

I have tried it again now. And now it is working perfectly. Thank you very much. I am going to try the other scriptlines above too and will let you know. All thank you very much for super support

Link to post
Share on other sites

All scriptlines above adviced to me, are working perfectly now with x64 compiling. 

Super. I was trying and searching for days. What a great forum. Thanks mates. You all are super.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...