How To Auto-launch VBscript with Elevated Privileges

For cases when you need to execute a VBS script (*.vbs file) as admin with elevated privileges you can try the following snippet. This can be done by running ShellExecute and setting the runas flag to run an executable or to run an entire script (batch file or VBScript) with elevated permissions. You can copy/embed the following snippet into your vbscript file or batch file. This should result in executing your script as admin just by double-clicking it.

Caution: Please use this carefully. Make sure your VBScript or batch file is correct and serves the intended purpose only because whatever your script contains will be executed as ‘Admin’

Tushar Sharma
Tushar Sharmahttps://www.automationdojos.com
Hi! This is Tushar, the author of 'Automation Dojos'. A passionate IT professional with a big appetite for learning, I enjoy technical content creation and curation. Hope you are having a good time! Don't forget to subscribe and stay in touch. Wishing you happy learning!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

RELATED POSTS

How To Write Windows Environment Variables With VBScript

This is in continuation to the last post where we saw how to read windows environment variables using VBScript. As mentioned in the last...

VBS Part 2 – Fundamentals and Concepts

Having gone through the Introductory part, it is time to look at some crucial fundamentals and concepts. This article is to refresh some of...

COM Components and Scripting Process

Although this article should not concern you at all as a 'script developer' as long as you are aware of creating a reference to...

Â

MORE IN THIS CATEGORY

Convert List to Array Using For-Loop

The simplest way to convert a List to an array is to use a for-loop. The following code snippet demonstrates this method. First, the code...

Concatenate Strings Using String Joiner

Java 8 has added a new class called StringJoiner. This concatenates Strings using a delimiter as well as adds a prefix and suffix to...

Format Decimal Numbers Using Locale

If you want to create a DecimalFormat instance for a specific Locale, create a NumberFormat and cast it to a DecimalFormat. The java.text.DecimalFormat class is...

RECENT 'HOW-TO'

How To Install Oh-My-Posh On Windows PowerShell

Oh-My-Posh is a powerful custom prompt engine for any shell that has the ability to adjust the prompt string with a function or variable. It does not...

SIMILAR ON CODEX

- Advertisement -spot_img