For the Run Shell Command actions, environment variables are supported but the environment variable must be encapsulated in double quotes if the value for the environment variable is a path that contains spaces.
There are many conditions where double quotes are required to be able to handle different spaces and parameter entries. Here are a number of examples:
Example 1: Using an environment variable where there are no spaces in the full path name
• the environment variable ‘Temp_Home’ = C:\Temp
• the folder “New” is located under the folder “Temp” (e.g. C:\Temp\New)
the command to be entered in Run Shell Command will be:
dir %Temp_Home%\New
Example 2: Using an environment variable where spaces exist in the full path name
• the environment variable ‘Catapult_Home’ = C:\Program Files\Esprida\Esprida LiveControl Agent
• the folder “test” is located under the folder “Esprida LiveControl Agent” (e.g. C:\Program Files\Esprida\Esprida LiveControl Agent\test)
the command to be entered in Run Shell Command will be:
dir “%Catapult_Home%”\test
The double quotes around the environment variable are required to properly parse the folder path with spaces.
Example 3: using an environment variable where spaces exist in the full path name and parameters are being passed for the command
• the environment variable ‘Catapult_Home’ = C:\Program Files\Esprida\Esprida LiveControl Agent
• the folder “test” is located under the folder “Esprida LiveControl Agent” (e.g. C:\Program Files\Esprida\Esprida LiveControl Agent\test)
the command to be entered in Run Shell Command will be:
dir “%Catapult_Home%”\test /O:S
The double quotes around the environment variable are required to properly parse the folder path with spaces. The /O:S parameter tells the DIR command to sort the output according to file size.
Example 4: executing a DIR on a folder and redirecting the output where both the paths have spaces
• the environment variable ‘Catapult_Home’ = C:\Program Files\Esprida\Esprida LiveControl Agent
• the folder “test” is located under the folder “Esprida LiveControl Agent” (e.g. C:\Program Files\Esprida\Esprida LiveControl Agent\test)
the command to be entered in Run Shell Command will be:
Dir “%catapult_home%”\test > “%catapult_home%\test\out.txt”
Example 5: executing a VBS file which requires a parameter
• the VBS file is ‘Test.vbs’
• the parameter is a path and file name for an output from the VBS file (e.g. C:\Temp\Test.log)
the command to be entered in Run Shell Command will be:
C:\Temp\Test.vbs C:\Temp\Test.log
or
cscript C:\Temp\Test.vbs C:\Temp\Test.log
No double quotes are required as there are no spaces in the folder or file names.
Example 6: executing a VBS file that requires a parameter where the folder path to the VBS file has a space
• the VBS file is ‘C:\Program Files\Esprida\Test.vbs’
• the parameter is a path and file name for an output from the VBS file (e.g. C:\Temp\Test.log)
the command to be entered in Run Shell Command will be:
C:\”Program Files”\Esprida\Test.vbs C:\Temp\Test.log
or
“cscript C:\”Program Files”\Esprida\Test.vbs C:\Temp\Test.log”
Example 7: executing a VBS file that requires a parameter where the parameter is a folder path with a space
• the VBS file is ‘C:\Program Files\Esprida\Test.vbs’
• the parameter is a path and file name for an output from the VBS file (e.g. C:\Temp\Test.log)
the command to be entered in Run Shell Command will be:
C:\Temp\Test.vbs C:\”Scott Folder”\Test.log
or
“cscript C:\Temp\Test.vbs C:\”Scott Folder”\Test.log”
Example 8: executing a VBS file that requires a parameter where both the VBS file and the parameter are on folder path with a space
• the VBS file is ‘C:\Program Files\Esprida\Test.vbs’
• the parameter is a path and file name for an output from the VBS file (e.g. C:\New Folder\Test.log)
the command to be entered in Run Shell Command will be:
C:\”Program Files”\Esprida\Test.vbs C:\”New Folder”\Test.log
or
“cscript C:\”Program Files”\Esprida\Test.vbs C:\”New Folder”\Test.log”
NOTES for all examples:
1. adding opening and closing quotes and the term script in front of your command guarantees that the command will be executed with using the correct program. For example, if the extension .VBS had been reconfigured to automatically open Notepad.exe, the output log file would not be created.
2. Do not copy command from Microsoft Word and paste them directly into the Run Shell Command command window. MS Word uses curly quotes by default which are not supported at the command line interface for Microsoft Windows. All quotes must be standard ‘straight quotes’. A command with incorrect quotes will result in an execution error with a message like:
‘C:\”Program’ is not recognized as an internal or external command,
operable program or batch file.
It is best to create or validate all command involving quotes in another editor.