我尝试使用WMI-Object更改powershell中的纸盘设置。但是我刚才知道我正在尝试改变的价值是只读的。有人可以通过PowerShell或VBScript帮助我完成任务吗?
sender.sendPulse('\x01') # using the hex escape code
sender.sendPulse(chr(1)) # the integer 1, so `1111 1111` would be 255
sender.sendPulse(chr(0x01)) # hex literal
sender.sendPulse(chr(0b01)) # Binary literal. Could also be 0b00000001. You could use `0b0000_0001` or `0b_0000_0001` in Python 3.6+
我尝试过这个并没有用。
请帮忙!
提前致谢!
答案 0 :(得分:1)
由于该值是只读的,因此您将无法使用WMI进行设置。 .Net有System.Printing
有一个输入框设置,这不完美但有效。我在我的PSPrintTools模块中创建了一个函数。我认为Tray1,Tray2也是值得的,但我不记得我的头脑。除此之外,您还可以编辑PrintTicket XML。以下是该功能的相关代码:
$Printer = "Example Printer Name"
$InputBin = "AutoSelect","AutoSheetFeeder","Cassette","Manual","Tractor" #choose one
Add-Type -AssemblyName System.Printing
$Permissions = [System.Printing.PrintSystemDesiredAccess]::AdministrateServer
$QueuePerms = [System.Printing.PrintSystemDesiredAccess]::AdministratePrinter
$PrintServer = new-object System.Printing.LocalPrintServer -ArgumentList $Permissions
$NewQueue = New-Object System.Printing.PrintQueue -ArgumentList $PrintServer,$Printer,1,$QueuePerms
$InputBinCaps = $NewQueue.GetPrintCapabilities().InputBinCapability
if ($null -ne $InputBinCaps) {
if ($InputBinCaps.Contains([System.Printing.InputBin]::$InputBin)) {
$NewQueue.DefaultPrintTicket.InputBin = [System.Printing.InputBin]::$InputBin
$NewQueue.UserPrintTicket.InputBin = [System.Printing.InputBin]::$InputBin
} else {
Write-Error "$InputBin unavailable on $Printer"
}
}
$NewQueue.commit()
$NewQueue.dispose()
$PrintServer.commit()
$PrintServer.dispose()