2

Is it possible to know if a PowerShell script is launched from GUI e.g. double-click in the explorer or manually in a powershell console?

I would like to use an interactive console mode if it's launched in GUI / explorer.

Paebbels
  • 15,573
  • 13
  • 70
  • 139

1 Answers1

3

Query $host automatic variable

$host.name

return the name of the actual host.

CB.
  • 58,865
  • 9
  • 159
  • 159
  • I think I made a mistake, because PowerShell Script can not be started by double click from explorer :( (for comparison: old *.bat and *.cmd files can be launched by double-click) – Paebbels Mar 18 '15 at 13:06