Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
497 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...