title: How to enabled Windows Script Host
body: <p>I need to execute some cmd command which will require Windows Script Host to be enabled. By default, Windows Script Host is enabled. But the problem is some of my clients, Windows Script Host is disabled. One of the reasons behind it is by using the software called <code>Smadav</code>. It altered the system configuration of the Operating system and somewhat disabling and preventing it from using the Windows Script Host. </p>
  
  <p>I tried to re-enabled Windows Script Host manually while Smadav is installed and running by re-configuring <code>Registry</code>, the location is in <code>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings</code> then I added an entry <code>Enabled</code> with a value of <code>1</code>, but still, Windows Script Host is prevented by Smadav and won't execute.</p>
  
  <p>The solution is to uninstall the Smadav, but I still need to re-enable the Windows Script Host. I want to do it programmatically, anybody can help me out? Below is my current code, but it doesn't work. Not changing the value of key nor creating the key if it doesn't exist.</p>
  
  <pre><code>            string location = @"SOFTWARE\Microsoft\Windows Script Host\Settings";
              RegistryKey enabled = Registry.LocalMachine.OpenSubKey(location, true);
              if (enabled != null) //key exist, just enable it by setting value to 1
              {
                  enabled.SetValue("Enabled", 1, RegistryValueKind.DWord);
                  enabled.Close();
              }
              else { //key doesn't exist, create a key and set the value to 1
                  enabled.CreateSubKey("Enabled");
                  enabled.SetValue("Enabled", 1, RegistryValueKind.DWord);
                  enabled.Close();
              }
  </code></pre>