Run parameters in a Powershell script from a batch file -
Run parameters in a Powershell script from a batch file -
i'm trying specify parameters in powershell script, batch file.
the script looks likes this:
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 nail on ""$($window.mainwindowtitle)"" med pid ""$($window.id)""" $apppids += $window.id } } } { foreach ($id in $apppids) { # hides text... $wsh.appactivate($id) | out-null start-sleep -seconds $switchdelay write-verbose "changed window pid ""$id""" } } while ($true)
and i'm trying define in batch file like:
%systemroot%\system32\windowspowershell\v1.0\powershell.exe -executionpolicy bypass -file "c:\approtate.ps1" -apps "*chrome*", "spotify*" -switchdelay 5 pause
(supposed show error message here, need more reputation first...) error: "... positionalparameternotfound.approtate.ps1"
i'm new scripting, ideas?
%systemroot%\system32\windowspowershell\v1.0\powershell.exe -executionpolicy bypass -file "c:\approtate.ps1" -apps "*chrome*","spotify*" -switchdelay 5
the problem space between first, , sec variable of parameter -apps.
should work now.
powershell batch-file command-line-arguments
Comments
Post a Comment