When a backslash is a part of the callout command line, Site Recovery Manager doubles all backslashes.

Problem

The command-line system interpreter treats double backslashes as a single backslash only in file paths. If the callout command requires a backslash in a parameter other than a file path and the command does not convert double backslashes to a single backslash, the callout command might fail with an error.

For example, you can add a callout step to the workflow and enter the following text as a command:
c:\Windows\system32\cmd.exe /C "C:\myscript.cmd" a/b/c \d\e\f \\g\\h c:\myscript.log
As result of the callout step, Site Recovery Manager runs the following command:
c:\\Windows\\system32\\cmd.exe /C "C:\\myscript.cmd" a/b/c \\d\\e\\f \\\\g\\\\h c:\\myscript.log

If myscript.cmd does not change the double backslash to a single backslash, and parameters \d\e\f and \\g\\h are sensitive to the number of back slashes, myscript.cmd can fail.

Solution

  1. Create an additional command-line batch file to contain commands and all required parameters. The callout step runs this additional batch file without any argument. For the example, the solution is as follows:
    1. In a text editor such as Notepad, create a file c:\SRM_callout.cmd with the following content: C:\myscript.cmd a/b/c \d\e\f \\g\\h c:\myscript.log
    2. In a recovery plan callout step, enter the command to run: c:\\Windows\\system32\\cmd.exe /C c:\SRM_callout.cmd
  2. Add a code to the original script file that replaces double back slashes with a single back slash.
    1. Add code similar to the following sample in the beginning of the script file c:\myscript.cmd.
      @echo off
      set arg2=%2
      set arg3=%3
      set fixed_arg2=%arg2:\\=\%
      set fixed_arg3=%arg3:\\=\%
      
      If you use the shift command in a script, all backslash-sensitive parameters are handled this way.
    2. If you do not use the shift command in a script, make the following changes:

      Replace %2 with %fixed_arg2%.

      Replace %3 with %fixed_arg3%.

    3. Do not change the callout step command.