|
|
|
|
#1 |
|
Junior Member
Join Date: Sep 2007
Posts: 13
|
Capturing Error returned from UAC::ExecCodeSegment
Hi,
I have the scneario that I need to check the state of a user registry key and if that key exists then do some work that is required to be ran as admin. I used the Code: Function un.CheckVSPluginInstall ReadRegStr $2 HKCU "SOFTWARE\Company\Product" "VSSupport" FunctionEnd ClearErrors GetFunctionAddress $0 un.CheckVSPluginInstall UAC::ExecCodeSegment $0 IfErrors noVSplugin 0 #DO the admin things novsplugin: This has always appeared to work but on Vista it seem that it doesn't as when the VSSupport key is not there no Error is flagged back from the un.CheckVSPluginInstall function. This works okay in XP but not in Vista when running as a non-admin user This seems like a common thing to do and I'm sure it used to work..I'm using v0.0.11d of UAC How do othe rpeople do this type of thing? |
|
|
|
|
|
#2 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
|
You need to switch to v0.2, it synchronizes the registers both ways (Not sure if it handles the error flag, if not, use a register)
IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Sep 2007
Posts: 13
|
I did just download V0.2.1, so If I use a register in the Function I can query it in the main admin code? If that is the new functionality in V0.2.1 this solves a lot of the workarounds I have in place and is the missing link for this plugin.
I'll give that a go Thanks Mark |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Sep 2007
Posts: 13
|
Hi Anders,
I'll admit I'm slightly confused. I have upgraded my AUC.sh and UAC.dll (ANSI version) but none of the UAC:: commands now work, I get: Invalid command: UAC::ExecCodeSegment lookig athe trace it only seems to load: - UAC::_ whereas in previous version it loads: - UAC::Exec - UAC::ExecCodeSegment - UAC::ExecWait - UAC::GetElevationType - UAC::GetOuterHwnd - UAC::GetShellFolderPath - UAC::IsAdmin - UAC::RunElevated - UAC::ShellExec - UAC::ShellExecWait - UAC::StackPush - UAC::SupportsUAC - UAC::Unload I may be missing something and it's obvious but the Main wiki plugin page still shows these commands as the ones to use |
|
|
|
|
|
#5 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
|
you need to use the uac.nsh header file
IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#6 | |
|
Junior Member
Join Date: Dec 2006
Posts: 9
|
Quote:
I tried: !include UAC.nsh but that made no difference. And in fact was there already anyway I was trying to upgrade to 0.2.1 so I could capture returns from ExecCodeSegments |
|
|
|
|
|
|
#7 |
|
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
Allow me to expand on Anders' statement:
You need to use the new macros in the uac.nsh header file. |
|
|
|
|
|
#8 | |
|
Junior Member
Join Date: Dec 2006
Posts: 9
|
Quote:
For anyone else, old code like: code: can be easily replaced with code: Without documentation, I am unsure what the .oninit code is supposed to be, the examples have a lot of stuff in them and not sure what is required. I'm currently using: code: I am unsure about the uninstaller (if it needs to be elevated?) and any UnLoad requirements. Still, it's a start, thanks! I'll fiddle around more to see whats needed |
|
|
|
|
|
|
#9 | |
|
Junior Member
Join Date: Sep 2007
Posts: 13
|
Quote:
I'll have a go at making all these changes and see what happens. |
|
|
|
|
|
|
#10 | |
|
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
Quote:
!insertmacro UAC_RunElevated ${If} $2 = 0x666666 ;our special return, the new process was not admin after all MessageBox mb_iconExclamation "You need to login with an account that is a member of the admin group to continue..." Abort ${EndIf} |
|
|
|
|
|
|
#11 | |
|
Junior Member
Join Date: Dec 2006
Posts: 9
|
Quote:
After reading what you had there and re-reading the example apps, I realize that the UAC_AdminOnly.nis has a good example of the onInit code too!
|
|
|
|
|
|
|
#12 |
|
Junior Member
Join Date: Dec 2006
Posts: 9
|
Hurm, it seems to work well now, a few issues with the Uninstaller (But I haven't yet looked at that, I have a feeling I am doing stuff to admin that should be done to user)
One issue is if you run the installer from (say) explorer, the Installer appears BEHIND any forms on the screen. I looked at: code: but wasn't too sure if this was the right direction. I also know BringToFront doesn't work on Vista/Win7 after MS changed it. Are there any recommendations? |
|
|
|
|
|
#13 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
|
The init stuff is for page jumping (Elevation on a installer page like UAC_DualMode)
@fashtas: Are you doing the elevation in .onInit? That can cause focus issues since at some point, there is no window IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#14 | |
|
Junior Member
Join Date: Dec 2006
Posts: 9
|
Quote:
I moved the elevation to a custom pre_ function of the first visible window and the forms now show up on top of everything. I have to run through some tests now (and uninstall the right stuff now), but otherwise it seems to be working nicely, thanks very much for the help everyone! |
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|