How to capture the PID of a process when launching it from command line?

前端 未结 8 1892
栀梦
栀梦 2020-11-30 13:48

Is there a way to do this purely in a .bat file?

The purpose is to launch iexplore.exe, then kill just that instance when it\'s finished.

相关标签:
8条回答
  • 2020-11-30 14:43

    PowerShell can be used for this:

    powershell -executionPolicy bypass -command "& {$process = start-process $args[0] -passthru -argumentlist $args[1..($args.length-1)]; exit $process.id}" notepad test.txt
    
    echo Process ID of new process: %errorlevel%
    
    0 讨论(0)
  • 2020-11-30 14:45

    Ummm, TaskList & TaskKill?!

    0 讨论(0)
提交回复
热议问题