Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loops to start over?

Status
Not open for further replies.
May 11, 2004
37
US
Well, thaks to helpful direction, I am just about there. Any ideas on how to start this script from the begining after the user clicks OK on the popup box for Sub rich()?


strComputer = InputBox("Enter computer name and click ok. If you don't know the name of your computer, click cancel")

If strComputer = "" Then
call rich()
Else
call rich2()
End IF

Sub rich()
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" _
& strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery( _
"Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
Wscript.Echo "Name: " & objItem.Name
Next
End Sub

Sub rich2()
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "c:\Assettracker\clientcon.exe"
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "richard.rekos@questionmark.com"
objEmail.To = "richard.rekos@questionmark.com"
objEmail.Subject = "AT Output"
objEmail.Textbody = "AT Output"
objEmail.AddAttachment "C:\assettracker\data\" _
& strComputer & ".xml"
objEmail.Send
End Sub
 
Nope, I just want it to start over again from the beginning. Is that possible?
 
How about this:
Code:
Dim bContinue

bContinue = True
Do While bContinue
    strComputer = InputBox("Enter computer name and click ok.  If you don't know the name of your computer, click cancel")

    bContinue = False
    If strComputer = "" Then
        call rich()
    Else
        call rich2()
    End IF
Loop

Sub rich()
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" _
        & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery( _
        "Select * from Win32_ComputerSystem",,48)
    For Each objItem in colItems
        Wscript.Echo "Name: " & objItem.Name
    Next
    bContinue = True
End Sub

Sub rich2()
    Set objShell = WScript.CreateObject("WScript.Shell")
    objShell.Run "c:\Assettracker\clientcon.exe"
    Set objEmail = CreateObject("CDO.Message")
    objEmail.From = "richard.rekos@questionmark.com"
    objEmail.To = "richard.rekos@questionmark.com"
    objEmail.Subject = "AT Output"
    objEmail.Textbody = "AT Output"
    objEmail.AddAttachment "C:\assettracker\data\" _
        & strComputer & ".xml"
    objEmail.Send
End Sub

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top