Run BAT as Admin from User Button?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Skettalee
Posts: 136
Joined: 06 May 2019 20:27

Run BAT as Admin from User Button?

Post by Skettalee »

I have lots and lots of toolbars buttons along with graphics that I made and some of the buttons I have set to just bring up a list of Batch files to execute like one for running one of the various Ai Tools that I have install on my system with just
On Left Click:

Code: Select all

C:\!Sd\Comfy\ComfyUi.bat
C:\!Sd\FaceFusion\FaceFusion.bat
C:\!Sd\ForgeUi\ForgeUi.bat
C:\!Sd\roop-unleashed\Roop-Unleashed.bat
C:\!Sd\Rope-Next\Rope-Next.bat
C:\!Sd\Rvc\RVC.bat
Which brings up a list with those files listed like this:
Screenshot 2024-11-01 194953.png
Screenshot 2024-11-01 194953.png (75.29 KiB) Viewed 1520 times

Now i like being able to do this as I do so much and sometimes quickly want to access various things. But well besides the main question do people also know how to do that menu thing but be able to maybe change the list to have icons and possibly change the text you want to see for each item like possibly :

Code: Select all

"ComfyUi" C:\!Sd\Comfy\ComfyUi.bat Icon:comfyui.ico
"FaceFusion" C:\!Sd\FaceFusion\FaceFusion.bat Icon:C:\Users\damie\AppData\Roaming\XYplorer\Icons\facefusion.ico
"ForgeUi" C:\!Sd\ForgeUi\ForgeUi.bat icon: D:\_Damien\Icons\Custom\Labeled\Ai Artwork.ico
"Roop-Unleashed" C:\!Sd\roop-unleashed\Roop-Unleashed.bat Icon:roop-unleashed.ico
etc...


But my main question is there are times where I need to run any given BAT file as Administrator and through that menu method I dont know how to accomplish this, does anyone know how to make "FROM A BUTTON" it execute a file as administrator? :?:

eil
Posts: 1816
Joined: 13 Jan 2011 19:44

Re: Run BAT as Admin from User Button?

Post by eil »

Considering 1 question - check scripting command popupmenu() = it allows to create custom menus with custom_name,path,custom_icon format items.

Not sure about per-item "run as admin", my guess would be if XY is initially started "as admin" any file it runs will be run same, but not sure here, so maybe smbd will say more.
Win 7 SP1 x64 100% 1366x768|1900x1080

Skettalee
Posts: 136
Joined: 06 May 2019 20:27

Re: Run BAT as Admin from User Button?

Post by Skettalee »

eil wrote: 02 Nov 2024 10:32 maybe smbd will say more.
Server Message Block Daemon? Something Must Be Done? I dont understand smbd.

I will look into the popupmenu() command too, thanks!

eil
Posts: 1816
Joined: 13 Jan 2011 19:44

Re: Run BAT as Admin from User Button?

Post by eil »

smbd= somebody. :lol:
Win 7 SP1 x64 100% 1366x768|1900x1080

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Run BAT as Admin from User Button?

Post by highend »

Code: Select all

    $elevate = "path to nircmd\nircmd.exe";
    run lax("$elevate" elevatecmd exec runas "<curitem>");
https://www.nirsoft.net/utils/nircmd.html
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 64915
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Run BAT as Admin from User Button?

Post by admin »

In the next beta (v26.60.0101) this should run a BAT file in an elevated process (pops the UAC prompt) :

Code: Select all

open "E:\Test\BAT\test.bat", we;

Post Reply