I am using the schtask command with powershell. The emerging issue is that when it is C: \ Program Files \, it considers the path to be only C: \ Program, and the rest of the path is an argument. I tried to escape from it using "pre" and "post of the field", but made a difference. How can i do this? I cannot recode the path because it can be changed when the user installs it.
I created this on Windows 7 x64. It creates a task that the script returns. However, when I look at it in Task Schedular, the properties of the task, then the actions and delete the changes. It shows the program as C: \ Program, and then the rest as an argument.
Script:
$folder = Split-Path $MyInvocation.MyCommand.Path -Parent $app = "\Demon.DatabasePurge.exe" $exe = $app.Insert(0, $folder) schtasks /create /tn "Demon Purge Job" /sc daily /st 00:00:00 /tr $exe
Here is what I tried:
$folder = Split-Path $MyInvocation.MyCommand.Path -Parent $app = "\Demon.DatabasePurge.exe`"" $exe = $app.Insert(0, $folder) $exe2 = $exe.Insert(0, "`"") schtasks /create /tn "Demon Purge Job" /sc daily /st 00:00:00 /tr $exe2
source share