Solved

Loop VBScript

Posted on 2006-11-14
4
540 Views
Last Modified: 2008-01-09
I Have this Script, Working fine.  In this script I Have 3 condicion, I need to begin one before to continue other one. But I need to run all condicion in one script.

Example. Condition one, whe this end, continue other, when end this continue other...etc.

Dim oWshShell, strProfile, fsow,objFileSys, objTextStream

Set oWshShell = CreateObject ("WScript.Shell")
Set fsow = CreateObject("Scripting.FileSystemObject")
Set objFileSys = CreateObject("Scripting.FileSystemObject")
strProfile = oWshShell.ExpandEnvironmentStrings("%WINDIR%")
strTemp    = oWshShell.ExpandEnvironmentStrings("%TEMP%")
NetFrame= "\Microsoft.NET\Framework\"

If fsow.FileExists(strTemp & "\NetFrameOk.txt") Then

self.close()

ElseIf  fsow.FileExists(strProfile & NetFrame & "v2.0.50727\ndpsetup.ico") Then
        RunPro = "MsiExec.exe /Q /X{CB2F7EDD-9D1F-43C1-90FC-4F52EAE172A1}"
        oWshshell.run RunPro
        objFileSys.DeleteFile strProfile & NetFrame & "v2.0.50727\ndpsetup.ico"
        MsgBox "Des-instalando FrameWork v2.0"

ElseIf Not fsow.FileExists(strProfile & NetFrame & "v1.1.4322\ndpsetup.ico") Then
         RunPro = ".\1033dotnetfx.exe" & " /q:a /c:" & chr(34) & "install /l /q" & chr(34)
         oWshshell.run RunPro
         MsgBox "Verificando FrameWork 1.1"

ElseIf Not fsow.FileExists(strProfile &  NetFrame &"v1.1.4322\Updates\hotfix.exe") Then
          RunPro = ".\NDP1.1sp1-KB867460-X86.exe  /q"
          oWshshell.run RunPro
          MsgBox "Verificando Update a FrameWork 1.1"

ElseIf fsow.FileExists(strProfile &  NetFrame &"v1.1.4322\CasPol.exe") Then
          RunPro =strProfile & NetFrame &_
          "v1.1.4322\Caspol -machine -q -addgroup 1 -url http://172.18.249.66/* FullTrust -n CMVT"
          oWshshell.run RunPro
          Set objTextStream = objFileSys.CreateTextFile(strTemp & "\NetFrameOk.txt",True)
End IF
0
Comment
Question by:HelpDeskCentennialrd
  • 2
4 Comments
 
LVL 4

Expert Comment

by:hclgroup
ID: 17939340
Then you shouldn't be using elseif, you should use nested if statements

if conidtion1 then
   do process1
   if condition2 then
      do process2
      if condition3 then
         do process3
      end if
   end if
end if
0
 

Author Comment

by:HelpDeskCentennialrd
ID: 17939657
My first script was like your recommendation but in this script  the firts condition it FALSE I supposed he going to other condition, but nothing happen and I don't know why.


Dim oWshShell, strProfile, fsow,objFileSys, objTextStream

Set oWshShell = CreateObject ("WScript.Shell")
Set fsow = CreateObject("Scripting.FileSystemObject")
Set objFileSys = CreateObject("Scripting.FileSystemObject")
strProfile = oWshShell.ExpandEnvironmentStrings("%WINDIR%")
strTemp    = oWshShell.ExpandEnvironmentStrings("%TEMP%")
NetFrame= "\Microsoft.NET\Framework\"

If not fsow.FileExists(strTemp & "\NetFrameOk.txt") Then '<----It Good

        If fsow.FileExists(strProfile & NetFrame & "v2.0.50727\ndpsetup.ico") Then '<-False
                RunPro = "MsiExec.exe /Q /X{CB2F7EDD-9D1F-43C1-90FC-4F52EAE172A1}"
                oWshshell.run RunPro
                objFileSys.DeleteFile strProfile & NetFrame & "\v2.0.50727\ndpsetup.ico"
                MsgBox "Des-instalando FrameWork v2.0"

        If fsow.FileExists(strProfile & NetFrame & "v1.1.4322\ndpsetup.ico") Then '<-True

                RunPro = ".\1033dotnetfx.exe" & " /q:a /c:" & chr(34) & "install /l /q" & chr(34)
                oWshshell.run RunPro
                MsgBox "Verificando FrameWork 1.1"
                   ' self.close()

        If fsow.FileExists(strProfile &  NetFrame &"v1.1.4322\Updates\hotfix.exe") Then
                RunPro = ".\NDP1.1sp1-KB867460-X86.exe  /q"
                oWshshell.run RunPro
                MsgBox "Verificando Update a FrameWork 1.1"
                       
        If fsow.FileExists(strProfile &  NetFrame &"v1.1.4322\CasPol.exe") Then
             RunPro =strProfile & NetFrame &_
               "v1.1.4322\Caspol -machine -q -addgroup 1 -url http://172.18.249.66/* FullTrust -n CMVT"
                'oWshshell.run RunPro
                MsgBox       strTemp            
                Set objTextStream = objFileSys.CreateTextFile(strTemp & "\NetFrameOk.txt",True)

                End IF
            End IF
        End IF
  End IF
Else

MsgBox "Quit"

End IF
0
 

Author Comment

by:HelpDeskCentennialrd
ID: 17939836

Ok, this other version, working fine, but I need to wait the second option conclude to continue with other one. Can I use   "WScript.Sleep 2700" or What can you recommend to me

Dim oWshShell, strProfile, fsow,objFileSys, objTextStream

Set oWshShell = CreateObject ("WScript.Shell")
Set fsow = CreateObject("Scripting.FileSystemObject")
Set objFileSys = CreateObject("Scripting.FileSystemObject")
strProfile = oWshShell.ExpandEnvironmentStrings("%WINDIR%")
strTemp    = oWshShell.ExpandEnvironmentStrings("%TEMP%")
NetFrame= "\Microsoft.NET\Framework\"
ON ERROR RESUME NEXT

If Not fsow.FileExists(strTemp & "\NetFrameOk.txt") Then

        If fsow.FileExists(strProfile & NetFrame & "v2.0.50727\ndpsetup.ico") Then
                RunPro = "MsiExec.exe /Q /X{CB2F7EDD-9D1F-43C1-90FC-4F52EAE172A1}"
                oWshshell.run RunPro
                objFileSys.DeleteFile strProfile & NetFrame & "\v2.0.50727\ndpsetup.ico"
                MsgBox "Des-instalando FrameWork v2.0"
         End IF

        If Not fsow.FileExists(strProfile & NetFrame & "v1.1.4322\ndpsetup.ico") Then
                RunPro = ".\1033dotnetfx.exe" & " /q:a /c:" & chr(34) & "install /l /q" & chr(34)
                oWshshell.run RunPro
                MsgBox "Verificando FrameWork 1.1"
                     WScript.Sleep 2700

        If Not fsow.FileExists(strProfile &  NetFrame &"v1.1.4322\Updates\hotfix.exe") Then
                RunPro = ".\NDP1.1sp1-KB867460-X86.exe  /q"
                oWshshell.run RunPro
                MsgBox "Verificando Update a FrameWork 1.1"
                     WScript.Sleep 2700

        If fsow.FileExists(strProfile &  NetFrame &"v1.1.4322\CasPol.exe") Then
             RunPro =strProfile & NetFrame &_
               "v1.1.4322\Caspol -machine -q -addgroup 1 -url http://172.18.249.66/* FullTrust -n CMVT"
                'oWshshell.run RunPro
                MsgBox       strTemp            
                Set objTextStream = objFileSys.CreateTextFile(strTemp & "\NetFrameOk.txt",True)


            End IF
        End IF
  End IF
Else

MsgBox "Quit"

End IF
0
 
LVL 3

Accepted Solution

by:
JRockSolid earned 50 total points
ID: 17982775
Use the WMI Win32_Product class INSTALL method Explained here :
http://www.serverwatch.com/tutorials/article.php/1476661

That should not give a return from the MSIEXEC until the program is installed then you can verify the return code and move on to the next condition


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about a problem I had getting the GPS LocationListener working.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question