A command job defined to run on a Windows agent has a command with an argument. The full command and argument string is surrounded by double quotes in the job definition. When the job is executed, it fails saying the command cannot be found. However, if the double quotes are removed from the command in the job definition, the job runs successfully.
When running the job from the command prompt on Windows, it runs successfully both ways. Why does including double quotes in the job's command cause it to fail when run by the agent?
Release : 12
Component : CA Workload Automation AE (AutoSys)
When the Windows agent is installed with AutoSys compatibility settings, it will automatically puts double quotes around the job command when it executes it through cmd.exe. There is no need to include them in the job definition. When you put double quotes around the command in the job definition, the agent adds another set and the command ends up surrounded by two sets of double quotes. The extra set of double quotes makes it fail.
For example, a Windows job contains the following command...
command: "C:\scripts\test_win.bat 45"
Here is what it looks like on the agent side when it executes the command...
05/27/2022 17:08:17.832-0400 CAWA_I_20013 Command to be executed: "C:\Windows\SYSTEM32\cmd.exe" /c ""C:\scripts\test_win.bat 45""
With the extra set of double quotes, cmd.exe sees the command and the argument (C:\scripts\test_win.bat 45) as one filename and tries to execute that. That is why it gets the error saying command doesn't exist.
However, when you remove the quotes from the job definition, it looks like this...
05/27/2022 17:03:30.113-0400 CAWA_I_20013 Command to be executed: "C:\Windows\SYSTEM32\cmd.exe" /c "C:\scripts\test_win.bat 45"
Without the extra set of double quotes, cmd.exe sees the command as just "C:\scripts\test_win.bat" with an argument of "45" and is able to execute it successfully.