LoginSignup
2
4

More than 5 years have passed since last update.

Powershell で firefox を起動してみる

Last updated at Posted at 2016-11-25

0.IEの起動方法


$ie = New-Object -ComObject InternetExplorer.Application  # IE起動
$ie.Navigate("hogehoge.ne.jp")                            # URL指定
$ie.Visible = $true                                       # 表示

で実現できる。
参考: PowerShellからIEを操作

では、firefoxの場合は?

1.スクリプトを記述する
firefoxを起動する.ps1


$url = "http://www.yahoo.co.jp"
& 'C:\Program Files (x86)\Mozilla Firefox\firefox.exe' $url

2.スクリプトを実行する
firefoxを起動する.ps1 を右クリックし、
「プログラムから開く」で
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
を指定する。

3.結果
firefox が起動し、Yahoo を表示する。

4.宿題


function is64bit() {
  return ([IntPtr]::Size -eq 8)
}

function get-programfilesdir() {
  if (is64bit -eq $true) {
    (Get-Item "Env:ProgramFiles(x86)").Value
  }
  else {
    (Get-Item "Env:ProgramFiles").Value
  }
}

これを混ぜて、OSが 32bit or 64bit を判別できるようにする。
2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4