Recently I was trying out a vbscript (.vbs) and it all worked perfectly on my laptop. However when I tried the same vbscript on my test system, things didn’t go as smoothly because for some weird reason it did not work. Then I found out it was due to User Account Control which is disabled on my laptop but enabled on the test system. The vbscript requires elevation to use Windows Management Instrumentation to enable and disable hardware on device manager. Right clicking on the vbs file and there is no Run as administrator option but this is still not a big problem because I can modify the registry to add the run as administration option for vbs file. The biggest problem is the vbscript requires to run together with arguments and it is best to automatically run it when Windows is booted up.
I can’t just create a batch file to run the vbscript with arguments and put it at Startup folder because UAC will automatically block that from working without informing you. Fortunately there is a trick to bypass the UAC prompt by using the Windows Task Scheduler.
Here are the steps on how to make a program run under Task Scheduler with the highest privileges to bypass the UAC prompt.
1. Click the Start button and type Task Scheduler on the search programs and files bar and hit enter.
2. Click Action from the menubar and select Create Tasks.
3. You will need to fill up the Name and Description box and check the Run with highest privileges checkbox.
4. Go to Actions tab and click the New button.
5. Make sure that “Start a program” option is selected and browse for the program that you want to run without UAC prompt and click OK. Optionally you can also specify the command line arguments if required.
6. Now go to Settings tab and make sure that “Allow task to be run on demand” is selected. Click the OK button to create the task and you should see the task being added to the Task Scheduler.
7. You can either manually run the program directly from Task Scheduler by right clicking on the task and select Run, or create a shortcut which is very useful when you want to put it on startup. To create a shortcut, right click on Desktop, select New > Shortcut. Type the following location at the box and click Next.
schtasks /run /TN "X-Ray"
You will need to change the X-Ray that is between the double quotes to the name of the task which you’ve used in step 3. You can set any name for the shortcut and click the Finish button. Whenever you need to run the program without the annoying UAC prompt, simply run the shortcut which you’ve created. You can even put the shortcut in Startup folder so that it runs in highest privileges without prompting you to allow the following program to make changes to this computer.
If you totally disable the UAC, you don’t need this but it is good to know that there is a way to bypass the UAC restriction using Task Scheduler. If you have UAC enabled and would like to keep it that way, then you may find this tip useful if you need to run certain programs that requires elevation on Windows startup.