Link to home
Start Free TrialLog in
Avatar of rowfei
rowfei

asked on

Add & Edit registry key valume VBScript

Need create a vbScript to to the following steps:

1) To verify if the following key already exist. If it is, then a message pops up " The key already exist." Otherwires, go to step 2.
\\HKEY_LOCAL_MACHINE\Software\Microsoft\Office\11.0\Access\Security\Level
the key of type DWORD and set the value to 1

2) to create this new Registry key:

\\HKEY_LOCAL_MACHINE\Software\Microsoft\Office\11.0\Access\Security\Level

Create the key of type DWORD and set the value to 1

Thanks
Avatar of rodriguesp
rodriguesp
Flag of Portugal image

Hi follows a script that dows what we need

Regards
Paulo Rodrigues
Option Explicit
 
Dim oShell
 
Private Function KeyExists (keyName)
	Dim bKey
		
	On Error Resume Next
 
	bKey = oShell.RegRead(keyName)
 
	If TypeName (bKey) = "Empty" Then
		KeyExists = False
	Else
		KeyExists = True
	End If
End Function
 
 
 
Set oShell = CreateObject("Wscript.Shell")
 
If keyExists("HKEY_LOCAL_MACHINE\Software\Microsoft\Office\11.0\Access\Security\Level") Then
    wscript.echo "Key exists"
Else
    oshell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Office\11.0\Access\Security\Level", 1, "REG_DWORD"
End If
 
Set oShell = Nothing

Open in new window

Avatar of rowfei
rowfei

ASKER

Thanks, rodriguesp.

I would like to add some more to the script to step 1 & 2.

Addd to Step 1:

If the Level value is not 1, then change it to 1 with confirm message "The value have been changed."

Add to Step 2:
1) After creaate the new registry key and then a confirm message pops up.

Thanks a lot.
ASKER CERTIFIED SOLUTION
Avatar of rodriguesp
rodriguesp
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rowfei

ASKER

Thank you so much, Paulo. It works really well.
I think rowfei should had accepted my answer as a solution

Regards
Paulo Rodrigues
Avatar of rowfei

ASKER

Sorry, Paulo. I thought I have accepted already. Sorry about that. Many thanks to you for all of your help.