user3486019 user3486019 - 6 months ago 38
Bash Question

C++ ShellExecute special characters

How can I run this command from ShellExecute?

With windows cmd, I use this line and works perfect:

C:\backup.exe -daily %date%


that results:

C:\backup.exe -daily 05/19/2016


But in C ++ the interpreter does not work with %.
It results:

C:\backup.exe -daily %date%


How can I solve this problem?

ShellExecute(NULL, NULL,
"C:\\backup.exe",
"-daily %date%",
NULL,
SW_HIDE
);

Answer

Run cmd.exe /C backup.exe ... to let cmd take care of the variable substitution.

Comments