todd1215
todd1215

Reputation: 413

VB2010 and accessing windows registry

I'm having some issue with a VB program I wrote and also a setup.exe that accesses the Windows registry in a 64bit OS such as Win2k8 or Win2k3.

First Part: Issue with setup.exe and the windows registry First I'll explain the issue with the setup.exe. During install I have a custom action that fires off during the install to make a registry change to:

HKLM/Software/Microsoft/Windows NT/CurrentVersion/WinLogin/Userinit.

On 32bit OSes it works fine but on 64bit OSes it writes to:

HKLM/Software/WOW6432Node/Microsoft/Windows NT/CurrentVersion/Winlogon/Userinit

My issue here is that the logon process doesn't read from this location when a user logs in. I understand why it's accessing the 32bit part of the 64bit registry. It's because the setup.exe is a 32bit process. I can't find anywhere how I can set it to 64bit instead. Maybe all setup.exe's are 32bit, I don't know as I'm new to creating a setup program. Any idea on how to get past this issue?

Second part: issue with 64bit process accessing windows registry The second issue is when my program runs right after the user logs in. it's suppose to set a registry value that prevents the user from running the 'Task Manager' and being able to kill the app. I know it's probably a bad coding practice to circumvent Windows security but this is an internal app that I'm writing for my Company.

The code below is the function that fires to do the locking and unlocking of the task manager. On a 32bit system it works just fine, it's the 64bit one that it doesn't work in. Also have some issue when UAC is enabled. I don't want the user to be prompted to run as an administrator and not sure how to do that either. Any ideas?

Private Sub taskMgrState(ByVal state As String)
    Dim hive As String = "HKEY_CURRENT_USER\"
    Dim systemSubKey As String = "Software\Microsoft\Windows\CurrentVersion\Policies\System"
    If state = "enabled" Then
        'enable task manager use
        'create the subkey for later use
        If My.Computer.Registry.GetValue(hive & systemSubKey, "DisableTaskMgr", Nothing) Is Nothing Then
            My.Computer.Registry.LocalMachine.CreateSubKey(systemSubKey)
        End If
        'set DisableTaskMgr valuename to 0 which disables blocking the running of task manager
        My.Computer.Registry.SetValue(hive & systemSubKey, "DisableTaskMgr", 0)
    ElseIf state = "disabled" Then
        'disable the use of the task manager while this app is running
        If My.Computer.Registry.GetValue(hive & systemSubKey, "DisableTaskMgr", Nothing) Is Nothing Then
            My.Computer.Registry.LocalMachine.CreateSubKey(systemSubKey)
        End If
        'set DisableTaskMgr valuename to 0 which disables blocking the running of task manager
        My.Computer.Registry.SetValue(hive & systemSubKey, "DisableTaskMgr", 1)
    End If
End Sub

Upvotes: 2

Views: 967

Answers (1)

David Kroukamp
David Kroukamp

Reputation: 36423

To change a Setup Projects Target Platform Click On your ProjectName Deployment Project Proeprties (usually the 2nd item from the top) in the Solution Explorer then navigate to its properties tab and find the Target Platform It is automatically x86 change this to x64 You would now have to release 2 versions though. :)

Upvotes: 1

Related Questions