@ac-essentials/misc-util
    Preparing search index...

    Function escapeWin32CmdCommandArg

    • Escape a string to be safely used as a shell argument in Windows cmd.exe

      It adds double quotes around a string and escapes any existing problematic characters (such as %, !, and ") by replacing them with spaces. Backslashes are escaped by doubling them.

      Example:

      const unsafe = 'A "complex" %string% with !special! chars \\';
      const safe = escapeShellArgWindows(unsafe);
      console.log(safe); // "A complex string with special chars \\"

      Parameters

      • expr: string

        The string to escape

      Returns string

      The escaped string