Reputation: 6273
When I try to run following command
C:\Documents and Settings\BURE\My Documents\ibos\script>powershell.exe -NoProfile -WindowStyle Hidden & 'C:\Documents and Settings\BURE\My Documents\ibos\script\files_from_nomad.ps1' 1
I get following error
Missing expression after unary operator '-'.
At line:1 char:2
+ - <<<< WindowStyle Hidden
The filename, directory name, or volume label syntax is incorrect.
It works before, but not now? Why?
What I try to do is to schadular a script:
schtasks /CREATE /RU BURE /SC MINUTE /TN files_to_nomad /TR "powershell.exe -NoProfile -WindowStyle Hidden & 'C:\Documents and Settings\BURE\My Documents\ibos\script\files_to_nomad.ps1' 1"
I have exact the same schedular on another computer.
Upvotes: 2
Views: 18979
Reputation: 17964
arguments : -file "C:\Program Files\path\to\pcp\script.php"
Upvotes: 0
Reputation: 201822
I get the same error when I try to execute your command (but with double quotes around &
to 1
) on PowerShell 1.0. 1.0 doesn't support the WindowStyle parameter. Is it possible you are developing this on 2.0 but then testing it out on a PowerShell 1.0 system? Also, if you are running this from PowerShell 2.0 this will make the current window hidden. Is that your intent? You could fire the script off in another, hidden PowerShell window using Start-Process -WindowStyle Hidden.
Upvotes: 3
Reputation: 29469
Maybe the command should be quoted:
powershell.exe -NoProfile -WindowStyle Hidden "& 'C:\Docum...\script\files_from_nomad.ps1' 1"
Besides that - have you tried to remove -WindowStyle Hidden
? What does it do then?
Upvotes: 0