Hello,
I am writing a script to check if an image name/date has been written into the registry. if not, I create the regirtry key and add a value for the Data. Everything is working fine with the exception that even though a key/the data exists, it will still write another key entry in the Image folder.
Here is small piece of the script...
ImageVer=objshell.RegRead ("HKEY_LOCAL_MACHINE\Software\Tools\Image")
If ImageVer = "" Then ' Checks to see if the key exists, if not it creates the key and value
ImageValueName = "Date&Time" & " " &MyDateTime & " " & SystemName
' WScript.Echo(ImageValueName)
Set ImageReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\root\default:StdRegProv")
ImageReg.CreateKey HKEY_LOCAL_MACHINE,Imageverpath
ImageReg.SetStringValue HKEY_LOCAL_MACHINE,Imageverpath,ImageValuename,MyDateTime
ImageVer=objshell.RegRead("HKEY_LOCAL_MACHINE\Software\Tools\Image")
F.WriteLine "Your Current Image Version is: " & ImageValuename
Else
F.WriteLine "Your Current Image Version is: " & ImageValuename
End If
My company wants to have the time/date and workstation number (IE: SystemName) as the key name and the time/date are the registry key data.
When I use the If Imagever = "" command, it thinks there is no key written and writes another key into the registry.
Is there another way to write the If command to check for part of the registry key, if it is found then to continue on to the else command ???
Here is an example of my key name and data for that key...
Registry Key Name:
Date&Time 12-10-08 11:14 WS8870
Registry Key Data:
12-10-08 11:14
I am writing a script to check if an image name/date has been written into the registry. if not, I create the regirtry key and add a value for the Data. Everything is working fine with the exception that even though a key/the data exists, it will still write another key entry in the Image folder.
Here is small piece of the script...
ImageVer=objshell.RegRead ("HKEY_LOCAL_MACHINE\Software\Tools\Image")
If ImageVer = "" Then ' Checks to see if the key exists, if not it creates the key and value
ImageValueName = "Date&Time" & " " &MyDateTime & " " & SystemName
' WScript.Echo(ImageValueName)
Set ImageReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\root\default:StdRegProv")
ImageReg.CreateKey HKEY_LOCAL_MACHINE,Imageverpath
ImageReg.SetStringValue HKEY_LOCAL_MACHINE,Imageverpath,ImageValuename,MyDateTime
ImageVer=objshell.RegRead("HKEY_LOCAL_MACHINE\Software\Tools\Image")
F.WriteLine "Your Current Image Version is: " & ImageValuename
Else
F.WriteLine "Your Current Image Version is: " & ImageValuename
End If
My company wants to have the time/date and workstation number (IE: SystemName) as the key name and the time/date are the registry key data.
When I use the If Imagever = "" command, it thinks there is no key written and writes another key into the registry.
Is there another way to write the If command to check for part of the registry key, if it is found then to continue on to the else command ???
Here is an example of my key name and data for that key...
Registry Key Name:
Date&Time 12-10-08 11:14 WS8870
Registry Key Data:
12-10-08 11:14