1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
Option Explicit
Dim oIE
Dim Divisor
Dim TotalItters
Dim Itter
Dim oFSO
Dim oFldr
Dim oFile
Dim oCSVFile
Dim oShell
Dim sPath
Dim vSleep
Dim sLine
Dim x
Dim vWindow
Dim oApp
Dim sWidth
Dim SHeight
Dim SWidthW
Dim SHeightW
On Error Resume Next
sPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
set oShell = createobject("WScript.Shell")
Set oFSO = CreateObject("scripting.filesystemobject")
Set oFldr = oFSO.GetFolder(sPath)
Set oIE = CreateObject("InternetExplorer.Application")
TotalItters = 50
'sleep for dirs with few files
'so the user can see the progress
If TotalItters <= 60 then
vSleep = 10
End If
With oIE
.AddressBar = False
.ToolBar = False
.StatusBar = False
.Resizable = False
.Navigate("about:blank")
Do Until .readyState = 4: wscript.sleep 100: Loop
With .Document
With .ParentWindow
SWidth = .Screen.AvailWidth
SHeight = .Screen.AvailHeight
SWidthW = .Screen.AvailWidth * .4
SHeightW = .Screen.AvailHeight * .15
.resizeto SWidthW, SHeightW
.moveto (SWidth - SWidthW)/2, (SHeight - SHeightW)/2
'Get the divisor for processing the line width
Divisor = Round((SWidthW-30) / TotalItters, 4)
End With
.WriteLn ("<html>")
.WriteLn ("<head>")
.WriteLn ("<script language=""vbscript"">")
.WriteLn ("Sub NoRefreshKey ()")
.WriteLn ("Select Case window.event.keycode")
.WriteLn ("Case 82: SuppressKey= window.event.ctrlkey")
.WriteLn ("Case 116: SuppressKey= True")
.WriteLn ("End Select")
.WriteLn ("If SuppressKey Then")
.WriteLn ("window.event.keycode= 0")
.WriteLn ("window.event.cancelbubble= True")
.WriteLn ("window.event.returnvalue= False")
.WriteLn ("End If")
.WriteLn ("End Sub")
.WriteLn ("Sub NoContextMenu ()")
.WriteLn ("window.event.cancelbubble= True")
.WriteLn ("window.event.returnvalue= False")
.WriteLn ("End Sub")
.WriteLn ("Set document.onkeydown= GetRef(""NoRefreshKey"")")
.WriteLn ("Set document.oncontextmenu= GetRef(""NoContextMenu"")")
.WriteLn ("</script>")
.WriteLn ("</head>")
.WriteLn ("<body>")
.writeln ("<DIV id='d1'>" & " Reading Files" & "</DIV>")
.writeln ("<hr id='hr1'; size=20; width=0; align='left'; noshade>")
.WriteLn ("</body>")
.WriteLn ("</html>")
With .ParentWindow.document.body
.style.backgroundcolor = "White"
.scroll="no"
.style.Font = "10pt 'Arial'"
End With
.Title = "Progress Bar"
oIE.Visible = True
WScript.Sleep 100
End With ' document
End With ' oIE
oShell.AppActivate "Internet Explorer", True
Traitement
For Each oFile In oFldr.Files
'increase the itter
Itter = Itter + Divisor
'itter the line
oIE.document.getElementById("hr1").width = Itter
'show the text progress to
oIE.document.getElementById("d1").innerhtml = "Initializing .... "
For x = 0 To vSleep
WScript.Sleep 1
Next
Next
oIE.document.getElementById("d1").innerhtml = "FMT.exe will start"
while((GetProcessRunning("FMT.exe") = FALSE))
Wend
oIE.Quit
Sub Traitement
oShell.Run chr(34) & "./FMT.bat" & Chr(34), 0
Set oShell = Nothing
End Sub
Function GetProcessRunning(pStrProcessName)
Dim BoolStatus,Process,Objectservice
Set Objectservice = GetObject ("winmgmts:")
BoolStatus = False
for Each Process In Objectservice.InstancesOf ("Win32_Process")
If ucase(Process.Name) = ucase(pStrProcessName) Then
BoolStatus = True
End If
Next
GetProcessRunning = BoolStatus
End Function |
Partager