' If running under wscript.exe, relaunch under cscript.exe in a hidden window... ' 如果当前进程为 wscript ,则替换为 隐藏的 cscript 运行 IfInStr(1, WScript.FullName, "wscript.exe", vbTextCompare) > 0Then WithCreateObject("WScript.Shell") WScript.Quit .Run("cscript.exe """ & WScript.ScriptFullName & """", 0, True) EndWith EndIf
' 定义 wscript 对象 dim objShell dim command dim last_pid set objShell=wscript.createObject("wscript.shell") 'vbs代码开始----------------------------------------------
function get_last_pid() Dim Fso ,tf,fileName,strLine strLine=Empty fileName=getfolder() & "\pid.txt" Set Fso = CreateObject("Scripting.FileSystemObject") If Fso.fileexists(fileName)Then 'read from file Set tf =Fso.opentextfile(fileName,1) DoWhile tf.atendofstream<>True strLine = tf.ReadLine Loop tf.close EndIf Set Fso = Nothing get_last_pid=strLine endfunction
function set_last_pid(pid) Dim fso ,fw,fileName fileName=getfolder() & "\pid.txt" set fso=CreateObject("scripting.filesystemobject") set fw=fso.opentextfile(fileName,2,true) fw.writeline pid fw.close Set fso = Nothing endfunction
' If running under wscript.exe, relaunch under cscript.exe in a hidden window... ' 如果当前进程为 wscript ,则替换为 隐藏的 cscript 运行 IfInStr(1, WScript.FullName, "wscript.exe", vbTextCompare) > 0Then WithCreateObject("WScript.Shell") WScript.Quit .Run("cscript.exe """ & WScript.ScriptFullName & """", 0, True) EndWith EndIf
' 定义 wscript 对象 dim objShell dim command dim last_pid set objShell=wscript.createObject("wscript.shell") 'vbs代码开始----------------------------------------------
function get_last_pid() Dim Fso ,tf,fileName,strLine strLine=Empty fileName=getfolder() & "\pid.txt" Set Fso = CreateObject("Scripting.FileSystemObject") If Fso.fileexists(fileName)Then 'read from file Set tf =Fso.opentextfile(fileName,1) DoWhile tf.atendofstream<>True strLine = tf.ReadLine Loop EndIf tf.close Set Fso = Nothing get_last_pid=strLine endfunction
function set_last_pid(pid) Dim fso ,fw,fileName fileName=getfolder() & "\pid.txt" set fso=CreateObject("scripting.filesystemobject") set fw=fso.opentextfile(fileName,2,true) fw.writeline pid fw.close Set fso = Nothing endfunction