Solved

Loop VBScript

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
OCT or Config.xml 2 53
deploy workstation 4 95
Sending email via PHP & Pear - Warning: include_once(Net/SMTP.php): failed to open stream 5 53
VB.NET 2008 Publish Error 2 25
This is an explanation of a simple data model to help parse a JSON feed
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

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