I want to add a registry key (DWORD=1) in HKEY_LOCAL_MACHINE \SYSTEM\CurrentControlSet\Control\StorageDevicePolicies using VBScript. How can I do that?

2 Answers

An example of registry entry creation would be:

Const HKEY_CURRENT_USER = &H80000001 strComputer = "." Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\Script Center" strValueName = "My DWORD Value" dwValue = 13 objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue 

where the targets can be changed accordingly to your needs.

Source

3

Some examples:

Example 1: Set the registry flag to display Hidden and System files in Windows Explorer:

Set WshShell = CreateObject("WScript.Shell") myKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden" WshShell.RegWrite myKey,1,"REG_DWORD" Set WshShell = Nothing 

Example 2: Set the registry flag to hide Hidden and System files in Windows Explorer (the default):

Set WshShell = CreateObject("WScript.Shell") myKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden" WshShell.RegWrite myKey,0,"REG_DWORD" Set WshShell = Nothing 

Example 3: Create a "default value" at KCU\KeyName\
Note: The trailing backslash is required:

Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.RegWrite "HKCU\KeyName\","", "REG_SZ" Set WshShell = Nothing 

Credit to

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy