Re: If "HKEY_CURRENT_USER\Software\Microsoft\Communicator\Transpor by ozdorf
ozdorf
Wed May 07 10:18:01 CDT 2008
Thank you for the help, but I'm getting Error:
Unable to open registry key "HKCU\Software\Microsoft\Communicator\Transport"
for reading.
Code: 80070002
Source: WshShell.RegRead
"Pegasus (MVP)" wrote:
>
> "Hank" <Hank@discussions.microsoft.com> wrote in message
> news:A9B46365-6E1E-4FB5-B22B-C4EF18841376@microsoft.com...
> > I'm trying to create a script that checks if the following key exist on
> > users' pc:
> > HKEY_CURRENT_USER\Software\Microsoft\Communicator\Transport
> >
> > If exist, exit the script, if not exist create the key as following:
> > WSHShell.RegWrite
> > "HKEY_CURRENT_USER\Software\Microsoft\Communicator\Transport", 1,
> > "REG_DWORD"
> >
> > I cannot get this to work. Thank you for any help.
>
> Here is one way of doing it:
>
> Set WshShell = WScript.CreateObject("WScript.Shell")
> bKey = "HKCU\Software\Microsoft\Communicator\Transport"
> On Error Resume Next
> Err.clear
> sKey = WshShell.RegRead(bKey)
> If Err.number <> 0 Then
> Err.clear
> WshShell.RegWrite bKey, 1, "REG_DWORD"
> if err.number <> 0 then WScript.Echo "Cannot create key"
> End If
> On Error Goto 0
>
>
>