2010-04-28 02:47:03 +0000 2010-04-28 02:47:03 +0000
← ソフトウェアユーザー

コマンドラインからテキストファイルへのプリンタの一覧表示

スコア 30
Advertisement

インストールされているプリンタとその場所のリストをテキストファイルに出力するために、コマンドラインから使用できるコマンドはありますか? あるいは、コマンドラインから実行できるプログラムはありますか?

Advertisement
Advertisement

回答 (7)

解決策が見つかりました

スコア 28
2010-04-28 03:18:35 +0000

Windows XPではprntmngrを使用:

PRNMNGR -l >> C:\printers.txt

Windows Vista以降ではPowerShellを使用:

get-WmiObject -class Win32_printer | ft name, systemName, shareName >> c:\printers.txt

注意: Vista+でファイルをC:に書き込もうとすると、あなたの権利やPowerShellがどのように生成されたかによってはエラーが発生します。

Windows 2000の場合:

XPからのPrnMngr.vbsファイル(/Windows/System32フォルダにあります)はWindows 2000で動作します。XPマシンから2000マシンにコピーして実行してください。

cscript prnmngr.vbs -l >> c:\printers.txt

0x1&

私のユーザーのデスクトップからはなぜか実行されないことがわかりましたが、.VBSをC:のルートにコピーしたところ、問題なく実行されました。

Advertisement
スコア 18
2017-05-11 18:44:28 +0000

私は以下を使用しています。

wmic printer list brief

OR

wmic printer get name

これは、コマンドを実行したシステムに接続されているプリンタの簡単なリストを表示するだけです。また、ネットワークプリンタがある場合は、プリンタが接続されているコンピュータも表示されます。

これを使って、システムにインストールされている各プリンタの設定の非常に詳細なリストを取得することもできます。

wmic printer list full

テキストファイルに出力するには、コマンドの最後にこれを追加します。

>>"[directory]\[filename].txt"

例:

wmic printer list brief >> c:\users\admin\documents\printerlist.txt
Advertisement
スコア 4
2014-04-16 14:09:17 +0000
Advertisement

win7でPSを使いたくない時があります(リモートPCでバックグラウンドで管理作業をさせてくれるアプリケーションがあるのですが、powershellは使いません)。XPのVisual BasicスクリプトはWin7用の以下のフォルダにあります:

C:\Windows\System32\Printing_Admin_Scripts\en-US
Advertisement
スコア 1
2013-03-08 17:19:12 +0000
Advertisement

注意: Windows XPの場合、デフォルトのスクリプトホストを必ずCScriptの最初の

C:\CScript //H:CScript

に変更してください。

スコア 0
2018-07-06 15:48:07 +0000

ということで、これが私の解決策です。

; ******************
;ALLOCATING CONSOLE
; ******************
; cmd calls hidden

global cPid
DetectHiddenWindows, on
Run, %comspec% /k ,,Hide UseErrorLevel,cPid
WinWait, ahk_pid %cPid%,, 1
DllCall("AttachConsole","uint",cPid)
hCon:=DllCall("CreateFile","str","CONOUT$","uint",0xC0000000,"uint",7,"uint",0,"uint",3,"uint",0,"uint",0)

; *******GET PRINTER NAMES**********

AllPrintersNameClearArray := strSplit(StrReplace(StrReplace(StrReplace(StrReplace("|" StrReplace(StrReplace(StrReplace(RunWaitOne("wmic printer get name")," ","")," `r",""),"`r",""),"|NAME`n",""),"`n","|"),"||","",All),"|","`n"),"`n")

RunWaitOne(command) {

    objShell := ComObjCreate("WScript.Shell")
    objExec := objShell.Exec(command)
    strStdOut := ""
    while, !objExec.StdOut.AtEndOfStream
    strStdOut := objExec.StdOut.ReadAll()
    return %strStdOut%
}

; ****Clean at the end*****

Finish:
DllCall("CloseHandle", "uint", hCon)
DllCall("FreeConsole")
Process, Close, %cPid%
ExitApp
return
Advertisement
スコア 0
2019-04-17 19:50:16 +0000
Advertisement

Powershellを使用します。

[System.Drawing.Printing.PrinterSettings]::InstalledPrinters