2
我試圖從批處理文件中指定PowerShell腳本中的參數。從批處理文件運行Powershell腳本中的參數
腳本本身看起來喜歡這樣的:
Param(
[Parameter(Mandatory=$true,HelpMessage="Application switch")]
[string[]]$Apps,
[ValidateRange(3,9999)]
[int]$SwitchDelay = 30
$AppPids = @()
$Windows = Get-Process | ? { $_.MainWindowTitle -ne "" }
$Wsh = New-Object -COM Wscript.Shell
foreach ($App in $Apps) {
foreach ($Window in $Windows) {
if ($Window.MainWindowTitle -like $App) {
Write-Verbose "Vindusfilter ""$App"" found hit on ""$($Window.MainWindowTitle)"" med PID ""$($Window.Id)"""
$AppPids += $Window.Id
}
}
}
do {
foreach ($ID in $AppPIDS) {
# Hides text...
$Wsh.AppActivate($ID) | Out-Null
Start-Sleep -Seconds $SwitchDelay
Write-Verbose "Changed window to PID ""$ID"""
}
} while ($true)
什麼,我試圖做的是在一個批處理文件來定義是這樣的:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "C:\AppRotate.ps1" -Apps "*Chrome*", "Spotify*" -Switchdelay 5
pause
(應該顯示錯誤信息在這裏,需要更多的信譽第一...) 錯誤:「... PositionalParameterNotFound.Approtate.ps1」
我基本上是新的腳本,所以任何想法?
帕拉姆你的右括號在哪裏( – gpullen 2014-11-06 14:42:54
它在複製/粘貼過程中丟失) – Zyph 2014-11-07 08:54:15