|
-
February 4th, 2011, 12:16 AM
#1
[RESOLVED] Run Dos Command
Hi All
I try to run dos command through mfc vc++.I know run dos command through .bat file.But my question is
Can i run dos command directly from code?
Please help me
-
February 4th, 2011, 01:57 AM
#2
Re: Run Dos Command
Yes, you can. Just use CreateProcess.
Victor Nijegorodov
-
February 4th, 2011, 02:09 AM
#3
Re: Run Dos Command
Directly from code without the DOS black window ?
-
February 4th, 2011, 02:18 AM
#4
Re: Run Dos Command
 Originally Posted by hypheni
Directly from code without the DOS black window ?
With ot without the "the DOS black window" will depend on the parameters passed in the CreateProcess. See the documentation in MSDN.
Victor Nijegorodov
-
February 4th, 2011, 05:26 AM
#5
Re: Run Dos Command
CreateProcess is for executing a module, so for dos command run it must have the cmd.exe path as its argument.
Instead why dont use old system(). Its much more easier if one wants to execute dos command.
-
February 4th, 2011, 05:31 AM
#6
Re: Run Dos Command
 Originally Posted by hypheni
CreateProcess is for executing a module, so for dos command run it must have the cmd.exe path as its argument.
Instead why dont use old system(). Its much more easier if one wants to execute dos command.
A little terminology correction:
DOS was short for MS-DOS, a 16-bit operating system most popular in the 1980's and early 90's. You also had PC-DOS, DR-DOS, and other variants.
There is no DOS any more in modern 32/64 bit Windows OS. What you see there is a 32-bit console window.
Regards,
Paul McKenzie
-
February 4th, 2011, 05:56 AM
#7
-
February 4th, 2011, 06:05 AM
#8
Re: Run Dos Command
 Originally Posted by hypheni
CreateProcess is for executing a module, so for dos command run it must have the cmd.exe path as its argument.
Instead why dont use old system(). Its much more easier if one wants to execute dos command.
No, you don't need the cmd.exe path at all. The OS already know it.
Victor Nijegorodov
-
February 4th, 2011, 06:18 AM
#9
Re: Run Dos Command
So if I want to execute this DOS command what will be the CreateProcess params.
systeminfo > c:\check.txt
-
February 4th, 2011, 06:24 AM
#10
Re: Run Dos Command
Victor Nijegorodov
-
February 4th, 2011, 06:26 AM
#11
Re: Run Dos Command
Thanks for all of you.
Problem solved
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|