Advertisement
TheVideoVolcano

Disable CMD or Regedit or anything TUTORIAL

Dec 6th, 2013
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.64 KB | None | 0 0
  1. 'How disable CMD, Regedit or Task Manager dynamiclly with VB.NET (using policy reg keys)
  2. 'What you want to do is goto RUN > type gpedit.msc > Administrative Templates > System > Prevent Access to the command 'prompt (are choose which one you want to disable (eg. command prompt, registry tools)
  3.  
  4. 'You are probably thinking "this isn't dynamic". Hold up we aren't finished.
  5.  
  6. 'Now you want to edit your chosen one, eg command prompt and enable it.
  7.  
  8. 'Now goto Run > type regedit > CTRL + F (for find box) and type in "DisableCMD". This will take you to the subkey in 'which the value is stored for the policy.
  9.  
  10. 'Now you want right click the subkey folder which contains the value "DisableCMD" and click "Export". We aren't 'exporting anything, we are simply getting the path which is located at the bottom. copy that link and close out of 'regedit.
  11.  
  12. 'Go back to gpedit.msc and disable the setting you made before to command prompt and apply and exit out it.
  13.  
  14. 'Now you need to create a global variable, let's say...
  15.  
  16.   Private CMDblockKey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Policies\Microsoft\Windows", True)
  17. 'The link you would have pasted in the quotes would have excess "HKEY parents" you want to remove that up until the 'Software as we use ...currentuser.opensubkey("and the path") instead of ...HKEY_CURRENT_USER\Software....
  18.  
  19. 'Now I chose to create private sub for disabling and enable the key/value (create and delete).
  20.  
  21. I put...
  22.  
  23. Private Sub disableCMD()
  24.  
  25. End Sub
  26.  
  27. 'and...
  28.  
  29. private sub enableCMD()
  30.  
  31. End Sub
  32.  
  33. 'Before we add the code, let's create the boolean setting.
  34. 'Goto Project > %appname% Properties > Settings > Create a setting like "disableCMD" and choose boolean for the type 'and set the value to 'True'.
  35.  
  36. 'Create a 'Checkbox' to control our boolean.
  37. 'Double click to get checkchanged event for the checkbox and type..
  38.  
  39. If checkbox1.checked then
  40. disableCMD()
  41. Else
  42. enableCMD()
  43. End If
  44.  
  45. 'Now let's get back to them subs
  46.  
  47. 'So when checked we will... (write what I do)
  48.  
  49. Private Sub disableCMD()
  50.  
  51.  My.Settings.disableCMD = True 'When we check the box to disable, we set it to true
  52.  Dim Systemkey As RegistryKey = CMDblockKey.CreateSubKey("System", False) ' make a variable as registry key and make 'it equal to what CMDblockkey is plus a subkey which we create now. Make it "system" because that is what computer 'does when it makes it. and just set permission to false.
  53.  Systemkey.SetValue("DisableCMD", "2", Microsoft.Win32.RegistryValueKind.DWord)'now we can put a value in systemkey 'which is essentially (Software\Policies\Microsoft\Windows\System --> value).
  54. 'Make the value called "DisableCMD" and set the data to "2" or num "1" if you want to block scripts" and the type of 'value it is, and it must be that "Dword" or it won't work (I don't think)
  55. 'That is all for that sub now let's go to the 'enableCMD' sub.
  56. End Sub
  57.  
  58. Private Sub enable CMD
  59. My.Settings.disableCMD = False 'Now we make it false
  60.         Dim deletekey As RegistryKey = CMDblockKey 'Make a varible and set it to 'CMDblockKey (like before).
  61.         Try
  62.             deletekey.DeleteSubKey("System") 'We delete the subkey 'system' so it removes the policy. I have in Try Catch so incase it isn't to be found for some reason it won't crash, bit of a lazy way but it works.
  63.         Catch 'catch only because i dont want to display errors, so no need for "ex as exception".
  64.         End Try
  65. End Sub
  66.  
  67. 'Now we need to make it so when the 'form_loads' it will read whatever the setting was last set to. so it doesn't keep 'reverting, that would be frustrating.
  68.  
  69.  
  70. 'I will finish this soon and also supply the code without the all the text in between it.
  71.  
  72. 'Night.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement