第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 PHP powershell 腳本更改默認打印機紙張尺寸

使用 PHP powershell 腳本更改默認打印機紙張尺寸

PHP
皈依舞 2023-09-15 17:04:24
我正在嘗試從 PHP 更改默認打印機紙張尺寸索引.php<?php$printer = Shell_Exec ('powershell.exe -executionpolicy bypass -NoProfile -Command "(Get-WmiObject win32_printer | Where-Object Default -eq $True).Name"');$printer = substr($printer, 0, -1);$printer = '"' . $printer . '"';$cmd = ('powershell.exe -executionpolicy bypass -NoProfile -Command ../A5.ps1 ' .$printer);echo shell_exec($cmd);?>A5.ps1$printer=$args[0]Set-PrintConfiguration -PrinterName $printer -PaperSize A5錯誤Set-PrintConfiguration : The specified printer was not found. At C:\Users\t4taa\Desktop\phpdesktop\A5.ps1:2 char:1 + Set-PrintConfiguration -PrinterName $printer -PaperSize A5 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi...erConfiguration) [Set-PrintCo nfiguration], CimException + FullyQualifiedErrorId : HRESULT 0x80070709,Set-PrintConfiguration當我從 PowerShell 運行腳本文件時工作正常,但從 PHP 運行腳本文件時,它拒絕獲取打印機名稱或錯過雙引號,如何解決此問題。
查看完整描述

1 回答

?
繁星淼淼

TA貢獻1775條經(jīng)驗 獲得超11個贊

為什么不A5.ps1改成


$printer = (Get-WmiObject win32_Printer | Where-Object { $_.Default -eq $true }).Name

Set-PrintConfiguration -PrinterName $printer -PaperSize A5

讓 powershell 找出默認打印機名稱并設置紙張尺寸。


這樣你就可以在index.php:


<?php

$cmd = ('powershell.exe -ExecutionPolicy Bypass -NoProfile -File ../A5.ps1');

echo shell_exec($cmd);

?>

使用-File而不是-Command



查看完整回答
反對 回復 2023-09-15
  • 1 回答
  • 0 關注
  • 154 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號