Solved

Loop VBScript

Posted on 2006-11-14
4
545 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This is about my first experience with programming Arduino.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

732 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