Solved

Loop VBScript

Posted on 2006-11-14
4
523 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
Comment Utility
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
Comment Utility
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
Comment Utility

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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 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 …

743 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

17 Experts available now in Live!

Get 1:1 Help Now