Windows/UAC - Launch another program not as administrator?

Just starting out? Need help? Post your questions and find answers here.
BarryG
Addict
Addict
Posts: 4178
Joined: Thu Apr 18, 2019 8:17 am

Re: Windows/UAC - Launch another program not as administrator?

Post by BarryG »

@JHPJHP: The code you sent works: I get 2 x CMD.exe windows opened, the first elevated and the second, not. Thanks! :)
fryquez
Enthusiast
Enthusiast
Posts: 391
Joined: Mon Dec 21, 2015 8:12 pm

Re: Windows/UAC - Launch another program not as administrator?

Post by fryquez »

There is also a way to call shellexecute from shell explorer.

viewtopic.php?p=563728#p563728
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Windows/UAC - Launch another program not as administrator?

Post by ChrisR »

Tested ShellExecInExplorerProcess with:

Code: Select all

ShellExecInExplorerProcess("cmd.exe", "/C Whoami & Net Session 1>NUL 2>NUL && (Echo Run with elevated rights) || (Echo Run without elevated rights) & Pause")
It does the job, great :)
User avatar
JHPJHP
Addict
Addict
Posts: 2258
Joined: Sat Oct 09, 2010 3:47 am

Re: Windows/UAC - Launch another program not as administrator?

Post by JHPJHP »

Hi BarryG,

Looks like you were already part of the thread back in 2020.

I not only agree with the previous posts, but tested it Six ways to Sunday and it seems to be a better solution for your requirements.

Definitely worth a second look :!: great job fryquez.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
BarryG
Addict
Addict
Posts: 4178
Joined: Thu Apr 18, 2019 8:17 am

Re: Windows/UAC - Launch another program not as administrator?

Post by BarryG »

JHPJHP wrote: Sun Oct 20, 2024 2:03 pmLooks like you were already part of the thread back in 2020
Yeah, I totally forgot about that. I think something must be up with it that I discovered since, which is why I got initially excited with it but then had to abort it and ask again the other day. I'll do some tests to see why I gave up on it.
Post Reply