Click to See Complete Forum and Search --> : Registry VBScript If the Key is exsits


SungHyun Jin
October 8th, 2006, 04:43 PM
I want to write down a VBScript file that finds Keys on Visual Studio Deploy project.

And I write down this.
' VBScript source code
Set Shell = CreateObject( "WScript.Shell" )
Shell.RegWrite "HKLM\SOFTWARE\MyCompany\MyProgram\version", "1.0", "REG_SZ"
Shell.RegWrite "HKLM\SOFTWARE\MyCompany\MyProgram\Install_Dir",Shell.CurrentDirectory, "REG_EXPAND_SZ"

And the string Shell.CurrentDirectory means that I want to assign the key for the installed folder. is it a right method?

And I write down deleting code for uninstalling.
But this is more mass and dull.

' VBScript source code
Set Shell = CreateObject( "WScript.Shell" )
strRead= Shell.RegRead "HKLM\SOFTWARE\MyCompany\MyProgram\version"
if(strRead>0)
Shell.RegDelete "HKLM\SOFTWARE\MyCompany\MyProgram\version"
strRead= Shell.RegRead "HKLM\SOFTWARE\MyCompany\MyProgram\Install_Dir"
if(strRead>0)
Shell.RegDelete "HKLM\SOFTWARE\MyCompany\MyProgram\Install_Dir"
strRead= Shell.RegRead "HKLM\SOFTWARE\MyCompany\MyProram"
if(strRead>0)
Shell.RegDelete "HKLM\SOFTWARE\MyCompay\MyProgram"
strRead= Shell.RegRead "HKLM\SOFTWARE\MyCompany"
if(strRead>0)
Shell.RegDelete "HKLM\SOFTWARE\MyCompany"

I want to try to check the Key exist and when only the key exists, it will be deleted. but it has error when uninstalling this program.

It makes dull. The program can't delete in control panel add or delete program tool. So I recommend you must verify your script utterly strong before you try to install and test.

Maybe I am a fool. But I tried to see and bit it at the time and develop along.

Please give me some solutions.

PeejAvery
October 8th, 2006, 07:19 PM
I must admit it is hard to understand you at points. I assume that is because English is not your first language.

Don't forget that VBScript only works on Internet Explorer. You will not be able to use Firefox nor any other browser for this.

Your code looks pretty good to me, just repititious. This (http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/registry/) web page should be a great to help to you.