![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Guest | Set empty default registry key value using regwrite ? Hello, RegWrite vbscript function is a bit tricky to me. For example I want to create registry key: dim obj1 set obj1 = CreateObject( "WScript.Shell" ) obj1.RegWrite( "HKCU\Software\somekey\", 1, "REG_SZ" ) So OK example above creates somekey key with default value 1, but my goal here is to set default value to empty value, not 1. (emty value is displayed like "(value not set)" in regedit). How do I set default key value to emty value using RegWrite ? thanks Vilius |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Set empty default registry key value using regwrite ? Hi, You could try setting a dummy value and then removing the dummy value leaving the key behind - this works... dim obj1 set obj1 = CreateObject( "WScript.Shell" ) obj1.RegWrite "HKCU\Software\somekey\dummyval", 1, "REG_SZ" obj1.RegDelete "HKCU\Software\somekey\dummyval" Thanks, Jon www.insidetheregistry.com --- "Vilius Mockûnas" <v_mockunas@xxxxxx> wrote in message news:e35YS6l6JHA.1372@xxxxxx Quote: > Hello, > > RegWrite vbscript function is a bit tricky to me. For example I want to > create registry key: > > dim obj1 > set obj1 = CreateObject( "WScript.Shell" ) > obj1.RegWrite( "HKCU\Software\somekey\", 1, "REG_SZ" ) > > So OK example above creates somekey key with default value 1, but my goal > here is to set default value to empty value, not 1. (emty value is > displayed like "(value not set)" in regedit). > > How do I set default key value to emty value using RegWrite ? > > thanks > Vilius > > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Set empty default registry key value using regwrite ? Thanks for workaround. This one also works as expected but I get TypeMismatch error: obj1.RegWrite "HKCU\Software\somekey\", null, "REG_SZ" Using with "on error resume next" it's OK. V "Jon Wallace" <info@xxxxxx> wrote in message news:e$WSyCp6JHA.1372@xxxxxx Quote: > Hi, > > You could try setting a dummy value and then removing the dummy value > leaving the key behind - this works... > > dim obj1 > set obj1 = CreateObject( "WScript.Shell" ) > obj1.RegWrite "HKCU\Software\somekey\dummyval", 1, "REG_SZ" > obj1.RegDelete "HKCU\Software\somekey\dummyval" > > Thanks, > Jon > > www.insidetheregistry.com > > --- > > "Vilius Mockûnas" <v_mockunas@xxxxxx> wrote in message > news:e35YS6l6JHA.1372@xxxxxx Quote: >> Hello, >> >> RegWrite vbscript function is a bit tricky to me. For example I want to >> create registry key: >> >> dim obj1 >> set obj1 = CreateObject( "WScript.Shell" ) >> obj1.RegWrite( "HKCU\Software\somekey\", 1, "REG_SZ" ) >> >> So OK example above creates somekey key with default value 1, but my goal >> here is to set default value to empty value, not 1. (emty value is >> displayed like "(value not set)" in regedit). >> >> How do I set default key value to emty value using RegWrite ? >> >> thanks >> Vilius >> >> |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Set empty default registry key value using regwrite ? There doesn't seem to be a way to just create a key. You can just use: obj1.RegWrite "HKCU\Software\somekey\", "" It sets "" instead of [value not set], but so what? That's the same thing in practice. If you even just click "modify" in the context menu for a new key, the default value will be set to "". Either way, RegRead will return "". It's just a quirk. (Also, the default value is string type by definition. You're treating it as DWORD even though you specified REG_SZ.) The help is kind of strange for RegWrite. It says the 2nd parameter is: "The name of the new key you want to create, the name of the value you want to add to an existing key, or the new value you want to assign to an existing value-name." I don't know of any way to name the new key with the 2nd parameter. I also don't know of any way to name the new value that way. The 2nd parameter is the value data. (To add to the confusion, the help even gets the terminology wrong. Generally it's known as key, value and data, whereas the scripting help refers to "value-name" for value and "value" for data.) Quote: > > RegWrite vbscript function is a bit tricky to me. For example I want to > create registry key: > > dim obj1 > set obj1 = CreateObject( "WScript.Shell" ) > obj1.RegWrite( "HKCU\Software\somekey\", 1, "REG_SZ" ) > > So OK example above creates somekey key with default value 1, but my goal > here is to set default value to empty value, not 1. (emty value is Quote: > like "(value not set)" in regedit). > > How do I set default key value to emty value using RegWrite ? > > thanks > Vilius > > |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Set empty default registry key value using regwrite ? "Vilius Mockûnas" <v_mockunas@xxxxxx> wrote in message news:e35YS6l6JHA.1372@xxxxxx Quote: > Hello, > > RegWrite vbscript function is a bit tricky to me. For example I want to > create registry key: > > dim obj1 > set obj1 = CreateObject( "WScript.Shell" ) > obj1.RegWrite( "HKCU\Software\somekey\", 1, "REG_SZ" ) > > So OK example above creates somekey key with default value 1, but my goal > here is to set default value to empty value, not 1. (emty value is > displayed like "(value not set)" in regedit). > > How do I set default key value to emty value using RegWrite ? Const HKCU = &H80000001 Set oReg = GetObject("WinMgmts:\root\default:StdRegProv") oReg.CreateKey HKCU, "Software\somekey" |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: Set empty default registry key value using regwrite ? On Jun 11, 1:33*am, "Vilius Mockûnas" <v_mocku...@xxxxxx> wrote: Quote: > Hello, > > RegWrite vbscript function is a bit tricky to me. For example I want to > create registry key: > > dim obj1 > set obj1 = CreateObject( "WScript.Shell" ) > obj1.RegWrite( "HKCU\Software\somekey\", 1, "REG_SZ" ) > > So OK example above creates somekey key with default value 1, but my goal > here is to set default value to empty value, not 1. (emty value is displayed > like "(value not set)" in regedit). > > How do I set default key value to emty value using RegWrite ? > > thanks > Vilius obj1.RegWrite( "HKCU\Software\somekey\", " ", "REG_SZ" ) Seems to work for me. OldDog |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: Set empty default registry key value using regwrite ? "James Whitlow" wrote: Quote: > "Vilius Mockûnas" <v_mockunas@xxxxxx> wrote in message > news:e35YS6l6JHA.1372@xxxxxx Quote: > > Hello, > > > > RegWrite vbscript function is a bit tricky to me. For example I want to > > create registry key: > > > > dim obj1 > > set obj1 = CreateObject( "WScript.Shell" ) > > obj1.RegWrite( "HKCU\Software\somekey\", 1, "REG_SZ" ) > > > > So OK example above creates somekey key with default value 1, but my goal > > here is to set default value to empty value, not 1. (emty value is > > displayed like "(value not set)" in regedit). > > > > How do I set default key value to emty value using RegWrite ? > As an alternative to 'RegWrite', you could use the WMI registry object. > > Const HKCU = &H80000001 > Set oReg = GetObject("WinMgmts:\root\default:StdRegProv") > oReg.CreateKey HKCU, "Software\somekey" > > obj1.run "reg add ""HKCU\Software\somekey""", 0,true |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| RegWrite Syntax | VB Script | |||
| Set Your Default Programs - Empty | Vista General | |||
| question about: vista default user profile & registry\shell issues | Vista installation & setup | |||
| How do I operate on (default) property of Registry provider? | PowerShell | |||
| How to see and change the value of (Default) in a registry key | PowerShell | |||