Start the bat File with:
ShellExecuteW(NULL,"open","c:\\users\\route206\\desktop\\test.bat",NULL,NULL,1);
That seemed to do the trick.
I was done fiddling around with task scheduler; this is much better!
#import "shell32.dll" int ShellExecuteW(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd); #import ShellExecuteW(NULL,"open","c:\\users\\route206\\desktop\\test.bat",NULL,NULL,1);
is it correct that the above only works on 64bit machines?
I'm now trying on a 32bit - no joy.. :-?
any suggestions?
is it correct that the above only works on 64bit machines?
No, it's not restricted to 64-bit machines. (The difference between Ansi A and Unicode W versions of Win32 functions has nothing to do with 32-bit vs 64-bit.)
Your example works for me (obviously changing the "route206" to my Windows username). But the location of the Windows desktop for the current user isn't necessarily C:\Users\whatever\Desktop. It varies quite widely depending on the version of Windows and various other factors. I suspect that you are now trying it on an old 32-bit computer running something like Windows XP. I think that the normal desktop location on XP is something like C:\Documents And Settings\whatever\Desktop.
I'll try it again, but i'm pretty sure the location is correct. It's a Win7 machine.. Will let you know and thanks: always good to know someone got it to work.. :-)
ShellExecuteW(NULL,"open","c:\\users\\route206\\desktop\\test.bat",NULL,NULL,1);
- The first argument is an int, use 0 not NULL.
- The last two are strings. Try passing empty strings ("") not NULLS.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello i'm looking to run a BAT file from a script (and upon successful testing ultimately from an EA).
I've looked at https://www.mql5.com/en/forum/139191 which i found very helpful but...
is not working.
I do allow for a DLL import when starting. First i get the 'unrecognized character escape sequence' upon compiling, upon which i added a slash, ie: c:\\users\\route206\\desktop\\test.bet. That DID compile, but not success upon running.
Later when i put the file on c:\ (so now not requiring any slashes) the script does again compile, but again no success.
In both cases i get the the 'this is a test' Alert, but the execution of the BAT file fails.
GetLastError() give me "0".
I noticed the post i'm using is an older post, so maybe things have changed since?
any help is appreciated, thanks in advance.
Hopefully Mr. Roeder is again seeing my mistake(s) quickly?