cmd command in ShellExecuteW
cmd command in ShellExecuteW
Loading saved threads...
Luandre Ezra · External communityPost link
External question — Stack Overflow Stack Exchange
Author: Luandre Ezra
Original post: https://stackoverflow.com/questions/77781500
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I want to delete a file using cmd comment. I run the code in MQL5 language from my EA. Here's the code that I used
string PathReportBacktest=sTerminalTesterDataPath+"\\MQL5\\Files\\Reports\\"+StrategyCategory+"\\"+StrategyName+"\\"+ FileName +" Report.xml";
ShellExecuteW(0, "open", "cmd", "/C del "+PathReportBacktest, "", 0)
I tried to use the show window option and I found that the cmd opens up and closed without doing anything.
Quote
Report
Luandre Ezra · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: Luandre Ezra
Original post: https://stackoverflow.com/a/77785318
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
2 things that I do to fix the problem,
I found the problem which is the space within the file, if the file name is text.txt (doesn't have space) it works with the above but if the file name is text 1.txt, it will fail to delete the file.
instead of using this code
ShellExecuteW(0, "open", "cmd", "/C del "+PathReportBacktest, "", 0)
I change it into
ShellExecuteW(0, "open", "cmd", "/C del [fileName]", "[file location]", 0)
e.g.
ShellExecuteW(0, "open", "cmd", "/C del text*1.txt", "D:\\folder1\\", 0)
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Luandre Ezra Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/77781500 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I want to delete a file using cmd comment. I run the code in MQL5 language from my EA. Here's the code that I used string PathReportBacktest=sTerminalTesterDataPath+"\\MQL5\\Files\\Reports\\"+StrategyCategory+"\\"+StrategyName+"\\"+ FileName +" Report.xml"; ShellExecuteW(0, "open", "cmd", "/C del "+PathReportBacktest, "", 0) I tried to use the show window option and I found that the cmd opens up and closed without doing anything.
Checking account access…