CODE:
'Resume Script if Error Occurs'Resume Script if Error Occurs
On Error Resume Next
' Create a WSH Shell object:
Set wshShell = CreateObject( "WScript.Shell" )
' Create a new key:
wshShell.RegWrite "HKCU\TestKey\", ""
' Read the values if already exists:
CurrentState = (wshShell.RegRead( "HKCU\TestKey\StringTestValue" ))
'Optional Error Handling
If Err.Number <> 0 Then
MsgBox("Error Occured - Variable did not exist")
End If
'Prompt for String - Use Previous Value if Available
MyString = Cint(InputBox("Please Serial Number", "Enter Value", CurrentState))
' Write string value:
wshShell.RegWrite "HKCU\TestKey\StringTestValue", MyString, "REG_SZ"
' Release the object
Set wshShell = Nothing
CODE:
' Create a WSH Shell object:
Set wshShell = CreateObject( "WScript.Shell" )
' Read the value from Registry:
MyString = (wshShell.RegRead( "HKCU\TestKey\StringTestValue" ))
'MsgBox(MyString)
MySerial = MyString
MyString = MyString + 1
'Write string value:
wshShell.RegWrite "HKCU\TestKey\StringTestValue", MyString, "REG_SZ"
' Release the object
Set wshShell = Nothing