找到正在运行的进程位置

时间:2014-10-24 12:41:31

标签: vbscript location file-copying

我有一个项目需要在某个进程运行时找到路径。我已经有一个脚本专门检查和定位特定的运行进程及其路径。

我需要做的是,例如,如果脚本返回a.exe在文件夹D:\ samplefolder \ a.exe中运行的值,脚本将只记录exe运行的位置,如果startpath未在C:\ samplefolder \ a.exe上运行,然后脚本将从" D:\ samplefolder \ a.exe"开始复制。到" C:\ samplefolder \ a.exe"

Function DetectExecPath

    Dim strRunningProcess, objService, strQuery, objProcess, strProcessRunning

    strProcessRunning = False

        strRunningProcess = "sample.exe"
        strQuery = "Select * FROM Win32_Process WHERE Name = '" & strRunningProcess & "' "

        Set strService = GetObject("winmgmts://./root/cimv2").ExecQuery( strQuery )              

        For each objProcess in strService

            If objProcess.name = strRunningProcess  Then

                msgbox "found running" & objProcess.CommandLine

            Else

                msgbox "not running"

            End If

        Next

End Function

0 个答案:

没有答案