Archive: ShellEx macro


ShellEx macro
i don't know where this macro came from, i couldn't find it on the wiki or the forum. i'm pretty sure though i got it from someone here.

so, i've been using this for some years now and never ran into a problem. from what i remember, this allowed me building an installer with user rights and whenever it runs an executable, it will display an elevation dialog if required by the executable.

however, i've been told it won't work if the path or the executable contains a single quote. any ideas?


How is that macro different to ExecShell? And why would you want to put a quote in the file path? You have a separate parameter for command line arguments.

Stu


That macro uses the SEE_MASK_NOCLOSEPROCESS (0x00000040) flag meaning that your code is leaking process handles. Other than passing the working directory as a parameter without having to use SetOutPath, this macro has no advantage over ExecShell...

Edit: I'm guessing somebody that does not know what they are doing copied parts of this macro. That macro has the same single quote issue but at least it provides some actual value over ExecShell...


Originally posted by Afrow UK
How is that macro different to ExecShell? And why would you want to put a quote in the file path? You have a separate parameter for command line arguments.

Stu
i have no idea. as i said, this was recommended me to someone as i wanted to be able to execute a program with admin rights even if the installer runs with user rights only. from what i remember a simple exec didn't execute such a program, whereas this macro popped up an elevation dialog.

Originally posted by Yathosho
i have no idea. as i said, this was recommended me to someone as i wanted to be able to execute a program with admin rights even if the installer runs with user rights only. from what i remember a simple exec didn't execute such a program, whereas this macro popped up an elevation dialog.
A normal ExecShell will do that (ExecShell calls ShellExecute and Exec[Wait] calls CreateProcess)

thanks, will give it a try


hm, i noticed when using ExecShell runas it only works with .exe files but .msi files will not open at all. is this a limitation by windows?


An MSI file is not an executable. You must use msiexec.exe.

Edit: And why are you using runas exactly? You should just use RequestExecutionLevel (along with UserInfo) to ensure the installer is already elevated before any installation occurs.

Stu


Indeed, it always annoys me when installers install partly to all users/HKLM and partly to current user/HKCU. The rest of my family end up with partially installed/broken apps that they don't want.