Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call different commands based on if/then

Status
Not open for further replies.

aquias

MIS
Jun 13, 2003
820
US
I'm writing a script that will accomplish a few things. First is to check for a specific registry key, if that exists then the script will exit. If the key doesn't exist the script will check for a folder, if that does not exist it will create it. Lastly the script will call an msi install package.

I've got all the pieces of the puzzle, I just don't know how to tackle getting these to work together.

Dim objFSO, WshShell, newfolder

strComputer = "."
Set wshShell = CreateObject("WScript.Shell")
Set objRegistry = GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")
Set objFSO = CreateObject("Scripting.FileSystemObject")

strKeyPath = "Software\Microsoft\Windows\Uninstall"
strValueName = "{3FE28AA5-8140-47E4-A0D3-974F24831556}"
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
If IsNull(strValue) Then
If Not objFSO.FolderExists("C:\Windows\Logs\") Then
newfolder = objFSO.CreateFolder("C:\Windows\Logs\")
Else
End If

That's the rough code. I left off the WshShell.Run variable only because that should be easy to plug in once I get these two playing nice.

Thank you.
 
Code:
...
If IsNull(strValue) Then 
  If Not objFSO.FolderExists("C:\Windows\Logs\") Then
    objFSO.CreateFolder "C:\Windows\Logs\"
  End If
  WshShell.Run ...
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top