Old 1st June 2012, 09:13   #1
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
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?
Yathosho is offline   Reply With Quote
Old 1st June 2012, 09:39   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 1st June 2012, 09:53   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,145
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...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 1st June 2012, 10:14   #4
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
Quote:
Originally Posted by Afrow UK View Post
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.
Yathosho is offline   Reply With Quote
Old 1st June 2012, 10:24   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,145
Quote:
Originally Posted by Yathosho View Post
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)

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 1st June 2012, 11:46   #6
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
thanks, will give it a try
Yathosho is offline   Reply With Quote
Old 1st March 2013, 09:52   #7
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
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?
Yathosho is offline   Reply With Quote
Old 1st March 2013, 13:39   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 14th March 2013, 16:17   #9
Marshallx7
Junior Member
 
Join Date: Oct 2012
Posts: 36
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.
Marshallx7 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump