appname = "OE.exe" key = "HKCU\Software\MetaProducts\Offline Explorer MX\Parameters\CurrentDir" ProgramFilesPath = createobject("wscript.shell").expandenvironmentstrings("%ProgramFiles%") ' TerminateApp appname RunApp ProgramFilesPath & "\Offline Explorer Enterprise\OE.exe", "/exit" pathDir = ReadPath(key) fileWD = pathDir & "\WebDown.dat" DelObjects fileWD, pathDir RunApp ProgramFilesPath & "\Offline Explorer Enterprise\OE.exe" sub DelObjects(fname, path) set fso = createobject("scripting.filesystemobject") set txtfile = fso.opentextfile(fname) txt = txtfile.readall txtfile.close if not fso.folderexists(path & "\Temp") then fso.createfolder path & "\Temp" set shapp = createobject("shell.application") shapp.namespace(path & "\Temp").movehere fname, 16 arr = split(txt,"[Object]") arrdesc = filter(arr,"Descr=") str = left(arr(0),instr(arr(0),"ObjectsCount=")+12) & cstr(ubound(arrdesc)+1) & vbcrlf set txtfile = fso.opentextfile(fname, 2, true) txtfile.write str & "[Object]" & join(arrdesc,"[Object]") txtfile.close end sub sub TerminateApp(appname) set srv = getobject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") servname = "select * from win32_process where name = '" & appname & "'" set procs = srv.execquery(servname) for each proc in procs proc.terminate next end sub function ReadPath(key) set wshshell = createobject("wscript.shell") ReadPath = wshshell.regread(key) end function sub RunApp(app) set shapp = createobject("shell.application") shapp.shellexecute app end sub |