none
Delete Usb key in Registry on Vista (manually or whit code)

    Question

  •  

    Hi, i wont remove on my pc list of drive usb connect.

    In the registry i have find in:

    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USB

    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR

    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Enum\USB

    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Enum\USBSTOR

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR

    trace of usb key connetted on my pc.

    I wont remove this trace(manually or whit program in c#), but when i can delete node : "error not permission", on Windows Vista (in Windows Xp function correctly)

    I have make a simple program in c# but in XP function, in windows Vista not function.

    this example of my code.

      public static string RegistryLocationUSB = "SYSTEM\\CurrentControlSet\\Enum\\USB";  
     
            private void Form1_Load(object sender, EventArgs e)  
            {  
                timer1.Enabled = true;  
                timer2.Enabled = false;  
             
              try  
                {  
                    RegistryKey sk1 = Registry.LocalMachine.OpenSubKey(RegistryLocationUSB, true);  
                  //Faccio il ciclo delle chiavi nella root UASB  
                    foreach (string valuename in sk1.GetSubKeyNames()) {  
                        //Memorizzo il nome  
                        string s = valuename;  
                        if(s.Contains("VID_")){  
                            sk1.DeleteSubKeyTree(s);  
     
                            }  
               
                    }  
     
                    sk1.Close(); 

     Can help me. thanks

    Friday, January 30, 2009 7:48 AM

Answers

  • Looks like Vista UAC security issue. There is a forum on this web site for security programming questions. Don't ask here. 
    You can also search "windows vista uac application guideline" and compare to your application design. 

    MSMVP VC++
    • Marked as answer by Harry Zhu Tuesday, February 03, 2009 9:13 AM
    Friday, January 30, 2009 7:54 PM