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:
constunsafe = 'A "complex" %string% with !special! chars \\'; constsafe = escapeShellArgWindows(unsafe); console.log(safe); // "A complex string with special chars \\"
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: