| | | | | | | | | | | Dim wso, objWord | | Set wso = CreateObject("Wscript.Shell") | | Set objWord = CreateObject("word.Application") | | | | If AppPrevInstance() = True Then | | Call wso.Popup("该程序不允许重复运行!" & vbCrLf & String(75," ") & _ | | vbCrLf & "程序将在 3 秒后全部退出 ...", 3, WScript.ScriptName, vbOKOnly+vbCritical) | | | | objWord.Quit | | WScript.Quit(2) | | End If | | | | | | dim TmpDiskNum | | TmpDiskNum=0 | | Do | | Call ufind() | | WScript.Sleep 2000 | | | | Call CloseRepeatFolderWindow() | | Loop | | | | | | Sub ufind() | | On Error Resume Next | | dim a | | Set fso = CreateObject("scripting.filesystemobject") | | Set Disks = fso.Drives | | dim DiskNumber | | DiskNumber = 0 | | | | For Each Disk In Disks | | If Disk.IsReady And Disk.DriveType = 1 Then | | | | DiskNumber = DiskNumber + 1 | | | | | | | | D = Disk.DriveLetter | | | | if DiskNumber > TmpDiskNum then | | dim wso | | Set wso = CreateObject("WScript.Shell") | | wso.Run "Explorer.exe /n," | | end if | | | | | | Call CloseRepeatFolderWindow() | | WScript.Sleep 1000 | | Set wso = NoThing | | a = true | | End If | | Next | | | | TmpDiskNum = DiskNumber | | | | if a = false then | | | | | | End if | | | | End Sub | | | | | | | | Function AppPrevInstance() | | AppPrevInstance=False | | Dim objItem, i | | For Each objItem in GetObject("winmgmts:\\.\root\cimv2:win32_process").instances_ | | IF LCase(objItem.Name)=LCase(Right(WScript.FullName,11)) Then | | IF InStr(1,objItem.CommandLine,WScript.ScriptFullName,vbTextCompare) > 0 Then i=i+1 | | End IF | | Next | | If i>1 Then AppPrevInstance=True | | End Function | | | | | | | | | | Sub CloseRepeatFolderWindow() | | On Error Resume Next | | Dim Shell, Dict, Wins | | Set Shell = CreateObject("Shell.Application") | | Set Dict = CreateObject("Scripting.Dictionary") | | Set Wins = Shell.Windows | | For i=Wins.Count-1 To 0 step -1 | | If Instr(LCase(Wins(i).FullName),"\explorer.exe") Then | | If Dict.Exists(Wins(i).LocationURL) Then | | Wins(i).Quit | | Else | | Dict.Add Wins(i).LocationURL,True | | End If | | End If | | Next | | End SubCOPY |
|