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
  • 14,791
  • 12
  • 61
  • 127

1 Answers1

3

Query $host automatic variable

$host.name

return the name of the actual host.

CB.
  • 56,179
  • 8
  • 151
  • 155
  • 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