Elevated App cannot access HKEY_LOCAL_MACHINE on Windows 8

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<p style="margin-bottom:0pt <span style="font-family:Verdana,sans-serif; font-size:9pt We have an app that has worked for years on WinXP, Vista and Win7 but suddenly does not work on Windows 8. When run it throws the following error: Requested Registry
access not allowed. Here is the code that fails:
<p style="margin-bottom:0pt
<p style="margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:8pt Dim<span style="background:white; color:black; font-family:Consolas; font-size:8pt sKey
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt As<span style="background:white; color:black; font-family:Consolas; font-size:8pt
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt String<span style="background:white; color:black; font-family:Consolas; font-size:8pt =
<span style="background:white; color:#a31515; font-family:Consolas; font-size:8pt "SoftwareMicrosoftNET Framework SetupNDPv4Full"
<p style="margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:8pt Dim<span style="background:white; color:black; font-family:Consolas; font-size:8pt bExists
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt As<span style="background:white; color:black; font-family:Consolas; font-size:8pt
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt Boolean<span style="background:white; color:black; font-family:Consolas; font-size:8pt = DoesKeyExist(<span style="background:white; color:#2b91af; font-family:Consolas; font-size:8pt RegType<span style="background:white; color:black; font-family:Consolas; font-size:8pt .LOCALMACHINE,
sKey)
<p style="margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:8pt Dim<span style="background:white; color:black; font-family:Consolas; font-size:8pt regKey
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt As<span style="background:white; color:black; font-family:Consolas; font-size:8pt
<span style="background:white; color:#2b91af; font-family:Consolas; font-size:8pt RegistryKey
<p style="margin-bottom:0pt
<p style="margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:8pt If<span style="background:white; color:black; font-family:Consolas; font-size:8pt bExists =
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt True<span style="background:white; color:black; font-family:Consolas; font-size:8pt
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt Then
<p style="text-indent:0.5in; margin-bottom:0pt <span style="background:white; color:black; font-family:Consolas; font-size:8pt regKey = Registry.LocalMachine.OpenSubKey(sKey,
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt True<span style="background:white; color:black; font-family:Consolas; font-size:8pt )
<p style="margin:0in 0in 0pt 0.5in <span style="background:white; color:blue; font-family:Consolas; font-size:8pt If<span style="background:white; color:black; font-family:Consolas; font-size:8pt
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt Not<span style="background:white; color:black; font-family:Consolas; font-size:8pt regKey
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt Is<span style="background:white; color:black; font-family:Consolas; font-size:8pt
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt Nothing<span style="background:white; color:black; font-family:Consolas; font-size:8pt
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt Then
<p style="margin:0in 0in 0pt 0.5in; text-indent:0.5in <span style="background:white; color:blue; font-family:Consolas; font-size:8pt Dim<span style="background:white; color:black; font-family:Consolas; font-size:8pt objReturn
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt As<span style="background:white; color:black; font-family:Consolas; font-size:8pt
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt String<span style="background:white; color:black; font-family:Consolas; font-size:8pt = regKey.GetValue(<span style="background:white; color:#a31515; font-family:Consolas; font-size:8pt "Install"<span style="background:white; color:black; font-family:Consolas; font-size:8pt )
<p style="margin:0in 0in 0pt 0.5in; text-indent:0.5in <span style="background:white; color:blue; font-family:Consolas; font-size:8pt If<span style="background:white; color:black; font-family:Consolas; font-size:8pt
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt Not<span style="background:white; color:black; font-family:Consolas; font-size:8pt objReturn =
<span style="background:white; color:#a31515; font-family:Consolas; font-size:8pt "1"<span style="background:white; color:black; font-family:Consolas; font-size:8pt
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt Then
<p style="margin:0in 0in 0pt 1in; text-indent:0.5in <span style="background:white; color:black; font-family:Consolas; font-size:8pt StartProcess(<span style="background:white; color:#a31515; font-family:Consolas; font-size:8pt "c:Router-CIMDotNetFrameworkdotNetFx40_Full_x86_x64.exe"<span style="background:white; color:black; font-family:Consolas; font-size:8pt ,
<span style="background:white; color:#a31515; font-family:Consolas; font-size:8pt ""<span style="background:white; color:black; font-family:Consolas; font-size:8pt )
<p style="margin:0in 0in 0pt 0.5in; text-indent:0.5in <span style="background:white; color:blue; font-family:Consolas; font-size:8pt End<span style="background:white; color:black; font-family:Consolas; font-size:8pt
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt If
<p style="margin:0in 0in 0pt 0.5in <span style="background:white; color:blue; font-family:Consolas; font-size:8pt Else
<p style="margin:0in 0in 0pt 0.5in; text-indent:0.5in <span style="background:white; color:black; font-family:Consolas; font-size:8pt StartProcess(<span style="background:white; color:#a31515; font-family:Consolas; font-size:8pt "c:Router-CIMDotNetFrameworkdotNetFx40_Full_x86_x64.exe"<span style="background:white; color:black; font-family:Consolas; font-size:8pt ,
<span style="background:white; color:#a31515; font-family:Consolas; font-size:8pt ""<span style="background:white; color:black; font-family:Consolas; font-size:8pt )
<p style="margin:0in 0in 0pt 0.5in <span style="background:white; color:blue; font-family:Consolas; font-size:8pt End<span style="background:white; color:black; font-family:Consolas; font-size:8pt
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt If
<p style="margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:8pt Else
<p style="text-indent:0.5in; margin-bottom:0pt <span style="background:white; color:black; font-family:Consolas; font-size:8pt StartProcess(<span style="background:white; color:#a31515; font-family:Consolas; font-size:8pt "c:Router-CIMDotNetFrameworkdotNetFx40_Full_x86_x64.exe"<span style="background:white; color:black; font-family:Consolas; font-size:8pt ,
<span style="background:white; color:#a31515; font-family:Consolas; font-size:8pt ""<span style="background:white; color:black; font-family:Consolas; font-size:8pt )
<p style="margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:8pt End<span style="background:white; color:black; font-family:Consolas; font-size:8pt
<span style="background:white; color:blue; font-family:Consolas; font-size:8pt If
<p style="margin-bottom:0pt
<p style="margin-bottom:0pt This VB project has a manifest that has worked for years:
<p style="margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <?<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt xml<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt version<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt 1.0<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt encoding<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt UTF-8<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt standalone<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt yes<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt ?>
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt assembly<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt xmlns<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt urn:schemas-microsoft-com:asm.v1<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt manifestVersion<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt 1.0<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt trustInfo<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt xmlns<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt urn:schemas-microsoft-com:asm.v3<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt security<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt requestedPrivileges<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
<<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt requestedExecutionLevel<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt level<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt requireAdministrator<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt
<span style="background:white; color:red; font-family:Consolas; font-size:9.5pt uiAccess<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt =<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt false<span style="background:white; color:black; font-family:Consolas; font-size:9.5pt "<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt />
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
</<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt requestedPrivileges<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
</<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt security<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt <span>
</<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt trustInfo<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="line-height:normal; margin-bottom:0pt <span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt </<span style="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt assembly<span style="background:white; color:blue; font-family:Consolas; font-size:9.5pt >
<p style="margin-bottom:0pt When this is installed on a WIN 8 client the error occurs on execution.
<p style="margin-bottom:0pt If I right click the executable, on the client, and select run as administrator, I still get the error
<p style="margin-bottom:0pt If I right click the executable, on the client, and change compatibility to Windows 7 then the app runs without error.
<p style="margin-bottom:0pt The section of code that I have included is where it fails. That section of code only reads the registry. We have other sections of code in this app that write to HKEY_LOCAL_MACHINE. Since execution never reached that code I can’t
say for certain that it would have worked or not but I can assume that it would not have.

<p style="margin-bottom:0pt As an AutoDESK developer we write apps that will load into AutoCAD and Inventor. The only way we can get our apps into those programs is to read and write to HKEY_LOCAL_MACHINE.

<p style="margin-bottom:0pt I am not sure what has changed in Windows 8, and searching the general web has found nothing.
<p style="margin-bottom:0pt Please advise.
<p style="margin-bottom:0pt Charley Cook
<span style="background:white; color:blue; line-height:115%; font-family:Consolas; font-size:8pt <hr class="sig CharleyCook

View the full article
 
Back
Top