LoginSignup
3
14

More than 3 years have passed since last update.

PowerShellで印刷など

Last updated at Posted at 2019-05-27

コマンドプロンプトから印刷だとlprサービスが必要だが、うまく出来なかったためPowerShellの方法を調べた。

参考

既定のプリンターで印刷

  • a.txtを印刷(アプリケーションは表示、終了を待たない)
Start-Process "c:\a.txt" -Verb Print
  • a.txtを印刷 (アプリケーションは非表示、終了を待たない)
非表示
Start-Process "c:\a.txt" -Verb Print -WindowStyle Hidden
  • a.txtを印刷 (アプリケーションは非表示、終了を待つ)
非表示
Start-Process "c:\a.txt" -Verb Print -WindowStyle Hidden -Wait
  • 管理者として実行 (hostsを編集)
Start-Process notepad.exe "c:\Windows\System32\drivers\etc\hosts" -Verb runAs

起動方法

  • Start-Process
  • saps

オプション

  • -WindowStyle
    • Hidden : 非表示で実行
    • Maximized : 最大化
  • -Verb
    • runAs : 管理者として実行
    • Print : 印刷
  • -Wait
    • プロセスの終了を待つ
  • -WorkingDirectory
    • 作業場所となるディレクトリを指定

その他PowerShellコマンド

  • Start-Sleep -s 3
    • 3秒待つ

特権になる


PowerShell Start-Process "cmd.exe" -ArgumentList '/k "cd %cd%"' -Verb runAs

他のコマンド

  • powershell_ise
    • 統合環境の起動
  • alias
    • コマンドalias一覧表示
    • alias | findstr "select"
  • dir | ogv
    • 結果をグリッド表示
  • ii
    • ファイルを関連付けられたプログラムで実行
    • ii .
    • ii Readme.txt
  • Get-ChildItem -Path Cert:\CurrentUser\Root
    • 証明書一覧(CA)を出力

フルパスで取得

3
14
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
3
14