1.    02 Jan 2016 #1
    Join Date : Jan 2016
    Posts : 1
    Windows 10 Professional 64 bit

    Bypass UAC in Windows 10 to run a backup job using batch file.


    Hi Everyone,


    This is my first posting on this forum, so please bear with me if I may have inadvertently not followed all the rules although I did try.

    I have a need to run a backup job at logoff/shutdown using the Genie Backup Software. The code in the batch file to do so is shown here (Exactly as it appears in the batch file - the batch file is named "DeepakPC_Backup_GBM_Command.bat") :-

    The following command can only be run on my main PC that runs on Windows 10 Professional 64 bit O/S with the Genie Backup Software.

    Starts Here
    "D:\Program Files\Genie9\Genie Backup Manager\GBM.exe" -e -job "DeepakPCBackup"
    Ends Here

    As a FYI, this command runs fine once the UAC dialog box is provided with the appropriate response when run at Command Prompt or by double clicking on the batch file. I do not wish for this UAC dialog box to appear and would want to run the application by passing the UAC dialog box.

    The above batch file is not run directly but is called by a VB Script fie (a .vbs file named "DeepakPC_Backup_UserInteractionScript.vbs"), the contents of which are as follows :-

    Code:
    Dim objShell, strComputer, strInput
    Const wshYes = 6
    Const wshNo = 7
    Const wshYesNoDialog = 4
    Const wshQuestionMark = 32
    Set objShell = CreateObject("Wscript.Shell")
    intReturn = objShell.Popup("Do you want run the backup job now?", 0, "Backup Now?", wshYesNoDialog + wshQuestionMark)
    If intReturn = wshYes Then
            objShell.Run "%comspec% /c ""E:\DataFiles\Deepak\GBMBackupProcessFiles\DeepakPC_Backup_GBM_Command.bat""",1 , True
            set objShell = Nothing
    End If 
    Ordinarily, the above VB script is run as a 'Shutdown script' specified in the Group Policy Editor.

    With the above set up, the process still works but I do get the UAC dialog box - this is something that is not acceptable to me and I wanted to be able to run this process without the UAC dialog box showing up.

    I did a lot of googling and learned that this would require a registry change with when effected using a batch file would normally require a reboot - again something that is not acceptable in this current circumstances. I eventually came up with some code (with bits of code from other people on the internet with some part of it coming from Shawn Brink - the bit for creating 4 different .reg files for the different levels of UAC that were generally acceptable in one of his postings) to change the registry entries - which requires running the Command Prompt as an 'Administrator'.

    The following command can only be run on another PC that runs on Windows 7 Professional 64 bit O/S but doesn't have the Genie Backup Software, so I can only test for registry entries change on this PC.

    This code is shown below :-

    Code:
    Set oShell = CreateObject("Shell.Application")
    
    'This supposedly runs the Command Prompt as an Administrator
    oShell.ShellExecute "cmd.exe", "/k", , runas, 1
    
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run "%comspec% /c ""E:\DataFiles\GBMBackupProcessFiles\ChangeUAC_RegFiles_Modified.bat""", 1, True 


    This code in the ChangeUAC_RegFiles_Modified.bat is shown below :-

    Code:
    'This is where the registry files reside on my test PC
    cd /d e:\DataFiles\UACModifiedRegistryFiles\
    Start regedit.exe /S UAC_Level-4_Disable.reg 
    This code in the UAC_Level-4_Disable.reg is shown below :-
    Code:
    Windows Registry Editor Version 5.00
    ; Created by: Original script by Shawn Brink, modified by Deepak Agarwal on 26/12/2015
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
    "ConsentPromptBehaviorAdmin"=dword:00000000
    "EnableLUA"=dword:00000000
    "PromptOnSecureDesktop"=dword:00000000
    This seems to run OK on this PC. Assuming that this will work on my PC running Windows 10 Professional 64 bit O/S, the the full VB script shutdown script will look like this :-

    Code:
    Dim objShell, strComputer, strInput
    Const wshYes = 6
    Const wshNo = 7
    Const wshYesNoDialog = 4
    Const wshQuestionMark = 32
    Set objShell = CreateObject("Wscript.Shell")
    intReturn = objShell.Popup("Do you want run the backup job now?", 0, "Backup Now?", wshYesNoDialog + wshQuestionMark)
    If intReturn = wshYes Then
        Set oShell = CreateObject("Shell.Application")
    
        'Run the Command Prompt as an Administrator
        oShell.ShellExecute "cmd.exe", "/k", , runas, 1
        Set objShell = CreateObject("Wscript.Shell")
    
        'Run the batch file to make the necessary registry entry changes to avoid the UAC dialog box
        objShell.Run "%comspec% /c ""E:\DataFiles\GBMBackupProcessFiles\ChangeUAC_RegFiles_Modified.bat""", 1, True
    
        'Run the batch file to run the backup job
            objShell.Run "%comspec% /c ""E:\DataFiles\Deepak\GBMBackupProcessFiles\DeepakPC_Backup_GBM_Command.bat""",1 , True
    
        'May not be necessary
            set objShell = Nothing
    End If 

    I would be grateful if someone could please have a look at above piece of code and advise if this philosophy will on a PC running Windows 10 Professional 64 bit O/S as well as I did read somewhere though that this philosophy will work only with PC's running up to Windows 8 or 8.1.? I cannot test the whole thing on my test PC as only runs Windows 7 Professional 64 bit O/S and also doesn't have Genie Backup Software on it either. Also, that I am a trifle uncomfortalble running code that tampers with registry entries on my main PC with a lot to loose before someone of the likes of you all at least having a look at the test code provided above.


    Any assistance shall be highly values.


    Best regards


    Deepak
    Last edited by agarwaldvk; 02 Jan 2016 at 21:51. Reason: Duplicate Posting
      My ComputerSystem Spec

 


Similar Threads
Thread Forum
App doesnt open through a batch file
Chaps... I have a desktop running with a few apps 24/7 feeding to a network, on the rare occasion it drops or restarts due to some update or power outage I thought I could write a simple batchfile just to restart everything automatically. ...
Software and Apps
Customization Add Batch File to New Context Menu in Windows 10
A .bat file is a batch file that consists of a series of commands to be executed by the command line interpreter, stored in a plain text file. The New context menu allows users to quickly create new files, folders, and shortcuts. You can right...
Tutorials
Need Help Creating Batch file to speed up Windows 10
I've been working to get some speed back on my laptop but I haven't been able to understand where or how I can get the text that needs to be pasted in the .bat file. I've looked and looked and can't find a clear answer anywhere.
Performance & Maintenance
Size of backup file using Windows Backup
I have an HP a6547c desktop that has gone from Vista to Windows 8.1 and finally to Windows 10. Attached is a Western Digital 1TB external hard drive that was wiped clean. I started the Windows Backup program (worried at first when it said Backup...
Backup and Restore
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 14:26.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums