HowTo get ShellExecute to run a command file?
-
Visual Studio 6.0, C/C++ I would like to run a command (batch) file from within my app that, among other things, copies some files that are passed to it on startup. In the 4th parameter of ShellExecute() I have 2 parameters separated by a blank space. === the command file: copy.cmd @echo off REM the echo command is a dignostic. echo 1 >> log.txt copy %1 c:\dir1 copy %2 c:\dir2 === the Shell Execute() call ShellExecute(NULL, "open", "copy.cmd","C:\\file1.txt C:\\file2.txt", NULL, SW_SHOWNORMAL); When this runs I get a quick flash of the screen. I'm guessing that a command window is opening and immediately closing. The command file does not seem to run. I've tried various machinations like running cmd.exe in parameter 3, but still can't get my command file to execute. Any help would be very much appreciated :-) Robert
-
Visual Studio 6.0, C/C++ I would like to run a command (batch) file from within my app that, among other things, copies some files that are passed to it on startup. In the 4th parameter of ShellExecute() I have 2 parameters separated by a blank space. === the command file: copy.cmd @echo off REM the echo command is a dignostic. echo 1 >> log.txt copy %1 c:\dir1 copy %2 c:\dir2 === the Shell Execute() call ShellExecute(NULL, "open", "copy.cmd","C:\\file1.txt C:\\file2.txt", NULL, SW_SHOWNORMAL); When this runs I get a quick flash of the screen. I'm guessing that a command window is opening and immediately closing. The command file does not seem to run. I've tried various machinations like running cmd.exe in parameter 3, but still can't get my command file to execute. Any help would be very much appreciated :-) Robert
-
Visual Studio 6.0, C/C++ I would like to run a command (batch) file from within my app that, among other things, copies some files that are passed to it on startup. In the 4th parameter of ShellExecute() I have 2 parameters separated by a blank space. === the command file: copy.cmd @echo off REM the echo command is a dignostic. echo 1 >> log.txt copy %1 c:\dir1 copy %2 c:\dir2 === the Shell Execute() call ShellExecute(NULL, "open", "copy.cmd","C:\\file1.txt C:\\file2.txt", NULL, SW_SHOWNORMAL); When this runs I get a quick flash of the screen. I'm guessing that a command window is opening and immediately closing. The command file does not seem to run. I've tried various machinations like running cmd.exe in parameter 3, but still can't get my command file to execute. Any help would be very much appreciated :-) Robert
-
Visual Studio 6.0, C/C++ I would like to run a command (batch) file from within my app that, among other things, copies some files that are passed to it on startup. In the 4th parameter of ShellExecute() I have 2 parameters separated by a blank space. === the command file: copy.cmd @echo off REM the echo command is a dignostic. echo 1 >> log.txt copy %1 c:\dir1 copy %2 c:\dir2 === the Shell Execute() call ShellExecute(NULL, "open", "copy.cmd","C:\\file1.txt C:\\file2.txt", NULL, SW_SHOWNORMAL); When this runs I get a quick flash of the screen. I'm guessing that a command window is opening and immediately closing. The command file does not seem to run. I've tried various machinations like running cmd.exe in parameter 3, but still can't get my command file to execute. Any help would be very much appreciated :-) Robert
Hi Robert, You need not to specify fifth parameter. I have tested the following on my system: HINSTANCE hInst = ShellExecute(NULL,NULL,"c:\\test\\copy.cmd","c:\\aa.txt c:\\tt.log","",SW_HIDE); and this is working fine on my system. Hope it will help you :) Ritu Kwatra
-
Thank-you Kuphryn for your help! :-)
-
You should specify the fifth parameter. For example: I put copy.cmd, a.log, b.log all in my d:\\temp. ShellExecute(NULL, "open", "copy.cmd", "a.log b.log", "d:\\temp", SW_SHOWNORMAL); Ray
Thank-you for your help, Ray. Yup, I've been ignoring the 5th parameter! Got it working now. :-)
-
Hi Robert, You need not to specify fifth parameter. I have tested the following on my system: HINSTANCE hInst = ShellExecute(NULL,NULL,"c:\\test\\copy.cmd","c:\\aa.txt c:\\tt.log","",SW_HIDE); and this is working fine on my system. Hope it will help you :) Ritu Kwatra
Thank-you for your help, Ritu. I've been ignoring the 5th parameter. Got it working now. :-)
-
Hi Robert, You need not to specify fifth parameter. I have tested the following on my system: HINSTANCE hInst = ShellExecute(NULL,NULL,"c:\\test\\copy.cmd","c:\\aa.txt c:\\tt.log","",SW_HIDE); and this is working fine on my system. Hope it will help you :) Ritu Kwatra