Paul
Mon Jun 30 19:09:35 CDT 2008
"Tom Lavedas" <tglbatch@cox.net> wrote in message
news:52629681-cbf3-4e0d-8b90-28cd3fcd6ad3@k37g2000hsf.googlegroups.com...
On Jun 26, 6:42 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> "Daz" <darren.black...@gmail.com> wrote in message
>
> news:c975b492-61a9-490b-a9ca-f5b4e4457abb@w8g2000prd.googlegroups.com...
>
>
>
> > Const ForReading = 1
> > strCount = 0
> > strComputer = "."
> > Set ObjWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.
> > \root\cimv2")
> > Set FSO = CreateObject("Scripting.FileSystemObject")
> > Set Act = CreateObject("Wscript.Shell")
> > Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
> > \cimv2")
>
> > Sub Main
> > If window.external.argv(1) = "" Then
> > help
> > ElseIf FSO.GetFile(cfgfile).Size > 0 Then
> > Call Update_Services
> > Else
> > InvalidFile
> > End If
> > CheckActiveX("ZProgBar.ocx")
> > iTimerID = window.setInterval("Display_Progress", strCount)
> > Call Display_Progress
> > End Sub
>
> > Sub Display_Progress
> > If ProgressBar1.Value = ProgressBar1.Max Then
> > window.clearInterval(iTimerID)
> > self.close
> > Else
> > ProgressBar1.Value = ProgressBar1.Value + 1
> > End If
> > End Sub
>
> > Sub Update_Services
> > Set objTextFile = FSO.OpenTextFile(cfgfile, ForReading)
> > Do Until objTextFile.AtEndOfStream
> > strNextLine = Trim(objTextFile.Readline)
> > If (strNextLine <> "") Then
> > arrServiceList = Split(strNextLine , ",")
> > Set colListOfServices = objWMI.ExecQuery("Select * from
> > Win32_Service Where Name ='" &_
> > Trim(LCase(arrServiceList(0))) & "'")
> > For Each objService In colListOfServices
> > objService.ChangeStartMode(Trim(LCase(arrServiceList(1))))
> > If Trim(LCase(arrServiceList(1))) <> "automatic" Then
> > objService.StopService()
> > If Trim(LCase(arrServiceList(1))) = "automatic" Then
> > objService.StartService()
> > Next
> > strCount = strCount + 1
> > End If
> > Loop
> > End Sub
>
> > Function CheckActiveX(objX)
> > sysDir = window.external.GetSystemDirectory()
> > oActive = window.external.FindResource(objX)
> > If Fso.FileExists(sysDir & objX) Then
> > ' Nothing to be done :D '
> > Else
> > window.external.CopyResourceToFile oActive, sysDir
> > 'Act.run "RegSvr32 /s " & sysDir & oActive, 0, True
> > window.external.DllRegisterServer sysDir & "\" & objX
> > End If
> > End Function
>
> > Sub Window_Onload
> > StyleIT
> > idTimer = window.setTimeout("Main", 200, "VBScript")
> > End Sub
>
> I'm probably a bit dense but I don't really understand your
> program. Here are some of the things that confuse me:
> - What is behind the reference to
> "window.external.CopyResourceToFile oActive, sysDir"?
> - If you want to copy a file, why not use the FS object?
> - You declare "sub main" but you never call it. How does
> your program start? What is the purpose of putting the
> main program into a subroutine?
> - You refer to "InvalidFile" but there is no function/subroutine
> of this name. How does it work?
> - Same for "StyleIt".
This doesn't appear to be VBS under WSH. Rather, the reference to
'window' suggest some form of an HTML-like host - or possibly .Net.
I'm thinking it is run under an IE host. One reference I found to
window.external was this:
http://support.microsoft.com/kb/q183339/. Maybe recent IE versions have
more methods available.
-Paul Randall