11/05/22 12:52:45.51 fmtZs305P
>>471の言うようにプロセスidで辿ればいいんじゃね
function GetProcessInfo(pid) {
var wmi = GetObject("winmgmts:");
var qSet = wmi.ExecQuery("Select * From Win32_Process Where ProcessId=" + pid);
for (var q = new Enumerator(qSet); !q.atEnd(); q.moveNext()) {
return [ q.item().ParentProcessId, q.item().ExecutablePath];
}
}
function GetPID() {
var wShell = WScript.CreateObject("WScript.Shell");
var oExec = wShell.Exec("cmd.exe");
return GetProcessInfo(oExec.ProcessID)[0];
}
MyPID = GetPID();
ParentPID = GetProcessInfo(MyPID)[0];
ParentPath = GetProcessInfo(ParentPID)[1];
WScript.Echo(ParentPID + ":" + ParentPath);