Solved

Loop VBScript

Posted on 2006-11-14
4
529 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C Programming - If Statement 8 72
Image decoding from Camera 3 72
C# code editing and collaboration 3 98
ruby gem installation 2 36
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

943 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now