我正在嘗試通過設定SetCustomShell通過 PowerShell 來設定資訊亭。
通過以下方式獲取類實體
$ShellLauncherClass = [wmiclass]"\\$COMPUTER\${NAMESPACE}:WESL_UserSetting"
并設定自定義外殼
$ShellLauncherClass.SetCustomShell($Kiosk_SID, "C:\Path\To\Executable.exe", ($null), ($null), 0)
有沒有辦法在 SetCustomShell 函式中為可執行檔案設定作業目錄?是否有任何方法可以在可執行檔案的首選項上進行設定?還是將用戶的作業目錄設定為程式目錄?
如上所述配置后,程式將無法正常運行,但如果Start-Process -FilePath C:\Path\To\Executable.exe -WorkingDirectory C:\Path\To使用它,程式將按預期啟動。
有什么建議嗎?
uj5u.com熱心網友回復:
確實不是我想要的解決方案,但為了實作這一點,我設定了一個 PowerShell 腳本作為程式的包裝器。每 20 秒檢查一次,查看軟體是否已關閉并需要再次打開。
for(;;){
try{
if (!(Get-Process -Name Executable -ErrorAction SilentlyContinue)){
Start-Process -FilePath "C:\Path\To\Executable.exe" -WorkingDirectory "C:\Path\To"
}
$proc = Get-Process -Name Executable | Sort-Object -Property ProcessName -Unique -ErrorAction SilentlyContinue
if (!$proc -or ($proc.Responding -eq $false)) {
$proc.Kill()
Start-Sleep -s 10
Start-Process -FilePath "C:\Path\To\Executable.exe" -WorkingDirectory "C:\Path\To"
}
}
catch { }
Start-sleep -s 20
}
然后將此腳本設定$ShellLauncherClass.SetCustomShell($User_SID, "powershell.exe -WindowStyle hidden -file C:\Path\To\Script.ps1", ($null), ($null), 0)為替換該用戶的默認 shell。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/526136.html
標籤:视窗电源外壳企业
上一篇:如何將PowerShell命令列的輸出輸出到我的專案?
下一篇:避免最后一項溢位內容
