Archive: RunAs with Windows 7 does not work


RunAs with Windows 7 does not work
I am using the NSIS RunAs plugin in order to call another install program if the user has only user privileges. In XP the RunAs is working fine. Under Win7 the RunAs always exits with error.

I have tried both methods:

1.
StrCpy $1 $ADMIN_LOGON
StrCpy $2 $ADMIN_PASSWD
StrCpy $3 “$INST_TEMP\Update_Monitor\UpdateMon_Installer.exe "
StrCpy $4 0
System::Call 'RunAs::RunAsW(w r1,w r2,w r3,*w .r4) i .r0 ? u'

2.
RunAs::RunAs `"$INST_TEMP\Update_Monitor\UpdateMon_Installer.exe` `$ADMIN_LOGON` `$ADMIN_PASSWD`

Any ideas why this works does not work anymore on Win7?

Many thanks.


2 is never going to work, this thing is not a NSIS plugin...

As to why 1 does not work is hard to say when you don't post the error message. But I'd say this "plugin" code is horrible and buggy, it leaks handles and the error string buffer.

To get the error string, you would have to treat $4 as a WCHAR* and extract it with the system::call struct syntax, then you will get a error string that may give some hints as to why it is failing, alternatively, do something like

system::call'user32::MessageBoxW(i0,ir4,i0,i0)i'

After that you can pass $4 to LocalFree, but there is no way to close the two leaked handles, that needs to be fixed in the source

I have found the runas problem.

Method 1 is another runas plugin for NSIS and I have used this dll to run method 2.

The good thing with method 1 was that it does not require any dll file to be located with the installer. But as the method does not longer work with Windows 7 I have to switch to the other runas plugin.