An official Batch Programming blog! To Solve the daily problems with windows and fixing them with little notepad scripts. Unlock the Hidden Secrets of Windows, Learn to crack Software via CMD & Make your own Programming tools. Understand to Manipulate your PC via CMD.

TheBATeam Forum

Best method for UAC...
 
Notifications
Clear all

[Solved] Best method for UAC prompt without Vbs  


SheWolf99
Posts: 5
(@sheerowwanjiku)
Active Member
Joined: 2 months ago

Hello again, was wondering which is the very best method to prompt for admin. Is it also possible to get admin without having to integrate or embed a hybrid js or vbs script outside batch? 

4 Replies
sintrode
Posts: 13
(@sintrode)
Active Member
Joined: 3 months ago

"Very best" is subjective. What are your needs? What is your exact goal? Please describe your task in as much detail as possible, including why you can't (or won't) use VBS for this, even though it's widely considered to be best practice.

 

Preliminary help: https://stackoverflow.com/questions/7044985/how-can-i-auto-elevate-my-batch-file-so-that-it-requests-from-uac-administrator

Reply
anic17
Posts: 2
(@anic17)
New Member
Joined: 4 months ago

Well, I don't know why you want to not using VBScript nor JavaScript nor PowerShell.

Here I have a fast solution that is coded in JavaScript, within creating any files:

@echo off
net session 2> nul >nul
if %errorlevel% neq 0 goto elevate
goto adminTasks

:elevate
CD /d %~dp0
mshta "javascript: var shell = new ActiveXObject('shell.application'); shell.Shellexecute('%~nx0', '', '', 'runas', 1);close();"
exit

:adminTasks
echo Here put all the code to be runned as administrator

 

Found that on Stack Overflow: https://stackoverflow.com/a/37669661/12613647 .

Contact us in Discord: https://discord.gg/b9VFF47

 

 

Reply
anic17
Posts: 2
(@anic17)
New Member
Joined: 4 months ago

You can also use that file that plugin:

Reply
SheWolf99
Posts: 5
(@sheerowwanjiku)
Active Member
Joined: 2 months ago

omg thanks Guys!!

Reply
Share:

© 2020 TheBATeam

Our Core Values   /   Terms & Conditions   /   Privacy Policy   /   Why Register?

Theme by Anders Norén