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

Early Bound Vs Late Bound (Binding)

What is Binding Before we dive into 'Early' and 'Late' stuff, let us discover, what the 'Binding' itself means? In simple terms, the 'Binding' refers to...

VBS Part 1 – Introduction and Background

At the upfront, this theoretical article might look boring to most of us but still, it is advisable to know about our scripting friend...

How To Read Windows Environment Variables With VBScript

Reading an environment variable is simple. There are a couple of methods available to do this but the main preferred ones are the below...

Â

MORE IN THIS CATEGORY

Concatenate Strings Using String.join()

Java 8 has added a static join method to the String class. This concatenates Strings using a delimiter. Performance wise, it is similar to...

Remove Duplicates from List Using Stream

Java 8 has added the Stream API that helps to easily perform bulk operations on Collections. A new method called stream() method has been...

Convert String to Date Using SimpleDateFormat Class

Sometimes, you may need to convert a String to a java.util.Date object. For this, you need to use the SimpleDateFormat class. You need to...

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