Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
473 views
in Technique[技术] by (71.8m points)

inno setup - How to open a web site after uninstallation in non-elevated mode?

Having used the code posted here to launch a web page after uninstall, I note that ShellExec starts the browser with the elevated credentials used by default by the Programs and Features control panel when starting the uninstaller.

Using ShellExecAsOriginalUser is documented as not possible during uninstall, and the suggestion made here does not seem to be applicable in the case of wanting to access a URL.

Any suggestions on how to handle this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Based on How to run exe with/without elevated privileges from PowerShell, this seem to do the trick:

Exec('explorer', 'https://www.example.com/', '', SW_SHOW, ewNoWait, ErrorCode);

I believe it works, because while the code obviously runs explorer process elevated, the Explorer does not allow multiple instances. So the new instance will just ask the existing instance of explorer (which is not elevated) to open the URL. The existing non-elevated instance of Explorer will run non-elevated instance of the web browser.

It's similar to how the web browsers themselves work. If you run chrome url (or any other browser) from an elevated process (like the un/installer), if no Chrome process is running yet, the URL opens in new elevated Chrome browser. But if some Chrome process is already running, the new elevated process will just ask the existing non-elevated process to open the URL.

The only difference is that while there is not always some web browser process running, there is always an (unelevated) Explorer process. And actually, even if there's not, Explorer de-elevates itself.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...