none
Is there a way I can edit this VBscript to run as admin every time?

    Question

  • I have this script that I edited to use at work for disabling startup repair. The problem is I need the script to always call command prompt as admin. I remote into at least 10 or more machines every day where having to disable startup repair it one of my tasks in order to start disk encryption and having a script available every time would really be convenient. I'm a complete noob when it comes to scripting/programming so forgive me if I look like an imbecile here. Below is the code I have thus far:

    Set objShell = WScript.CreateObject("WScript.Shell")
    objShell.Run("%comspec% /K bcdedit /set {default} recoveryenabled No"), 1, True

    I've underlined the command. Thanks for any assistance.

     
    • Changed type Bill_Stewart Wednesday, November 13, 2013 5:07 AM User asked a question
    • Moved by Bill_Stewart Thursday, January 02, 2014 8:34 PM Abandoned
    Wednesday, November 13, 2013 4:15 AM

All replies

  • Are you deploying this script using group policy???.


    Akshay Pate Server Administrator

    Wednesday, November 13, 2013 4:47 AM
  • I have this script that I edited to use at work for disabling startup repair. The problem is I need the script to always call command prompt as admin. I remote into at least 10 or more machines every day where having to disable startup repair it one of my tasks in order to start disk encryption and having a script available every time would really be convenient. I'm a complete noob when it comes to scripting/programming so forgive me if I look like an imbecile here. Below is the code I have thus far:

    Set objShell = WScript.CreateObject("WScript.Shell")
    objShell.Run("%comspec% /K bcdedit /set {default} recoveryenabled No"), 1, True

    I've underlined the command. Thanks for any assistance.

     

    No.

    You can use PowerShell remoting to set certain BCD values.  Some can also be set running as a startup script in Group Policy.

    THe script can be a simple one line batch file.

    I am pretty sure the command needs to be this:

    bcdedit /set {default} recoveryenabled=No


    ¯\_(ツ)_/¯



    • Edited by jrv Wednesday, November 13, 2013 4:55 AM
    Wednesday, November 13, 2013 4:51 AM
  • You can, but you'll need to use the ShellExecute function of the Shell.Application object instead of WshShell.Run.  See http://msdn.microsoft.com/en-us/library/windows/desktop/gg537745(v=vs.85).aspx for details on that function.  You'll need to pass "RunAs" as the 4th argument (vOperation).

    You'll still need to respond to the UAC prompt when running this script, though.

    Set objShell = CreateObject("WScript.Shell")
    strCommand = objShell.ExpandEnvironmentStrings("%comspec%")
    
    Set objShellApp = CreateObject("Shell.Application")
    objShellApp.ShellExecute strCommand, "/K bcdedit /set {default} recoveryenabled No", , "RunAs", 1
    

    Wednesday, November 13, 2013 4:58 AM
  • Are you deploying this script using group policy???.


    Akshay Pate Server Administrator

    no
    Wednesday, November 13, 2013 5:37 AM
  • thanks david
    Wednesday, November 13, 2013 5:37 AM
  • thanks david

    That will work if you are just looking to save right clicking the file to run it.  It will still as you for permission.

    Group Policy will do this remotely on all systems automatically.


    ¯\_(ツ)_/¯

    Wednesday, November 13, 2013 6:23 AM