Detecting how a batch file was executed

后端 未结 9 1819
伪装坚强ぢ
伪装坚强ぢ 2020-12-28 08:24

Assuming Windows, is there a way I can detect from within a batch file if it was launched from an open command prompt or by double-clicking? I\'d like to add a pause to the

9条回答
  •  一整个雨季
    2020-12-28 09:10

    crazy idea: use tasklist and parse it's results. I've wrote in a test batch file:

    tasklist > test.out

    and when I double-clicked it, there was an additional "cmd.exe" process just before the tasklist process, that wasn't there when the script was run from command line (but note that might not be enough if someone opens a command line shell and then double-click the batch file)

提交回复
热议问题