Hw to execute dos commands in C

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2007
Posts: 13
Reputation: abhi_marichi is an unknown quantity at this point 
Solved Threads: 0
abhi_marichi abhi_marichi is offline Offline
Newbie Poster

Hw to execute dos commands in C

 
0
  #1
Feb 25th, 2009
I need to execute some dos commands like executables(.exe)
PLEASE HELP ME OUT OF THIS
Last edited by abhi_marichi; Feb 25th, 2009 at 1:25 pm.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 476
Reputation: csurfer is just really nice csurfer is just really nice csurfer is just really nice csurfer is just really nice csurfer is just really nice 
Solved Threads: 76
csurfer's Avatar
csurfer csurfer is offline Offline
Posting Pro in Training

Re: Hw to execute dos commands in C

 
0
  #2
Feb 25th, 2009
Originally Posted by abhi_marichi View Post
I need to execute some dos commands like executables(.exe)
PLEASE HELP ME OUT OF THIS
Read more about the "system" command in C language.Your every requisite would get fulfilled.
Through system command you can call all commands you can call in a command prompt mode and also execute certain kinds of files too.
I Surf in "C"....
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Hw to execute dos commands in C

 
0
  #3
Feb 26th, 2009
Please, never use "system" command in C term in this context. No "commands" in C. The system is a library function in C...
Last edited by ArkM; Feb 26th, 2009 at 5:15 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 357
Reputation: death_oclock will become famous soon enough death_oclock will become famous soon enough 
Solved Threads: 37
death_oclock's Avatar
death_oclock death_oclock is offline Offline
Posting Whiz

Re: Hw to execute dos commands in C

 
0
  #4
Feb 26th, 2009
Take a look at ShellExecute

Edit: I misunderstood ArkM's post, I thought it was advising against the use of system() (as is usually the case). I suppose in this case, it would be okay?
Last edited by death_oclock; Feb 26th, 2009 at 5:53 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Hw to execute dos commands in C

 
0
  #5
Feb 27th, 2009
I have never came out against this part of the C language Standard
It's exactly the program case for the system standard library function (not command)...
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 357
Reputation: death_oclock will become famous soon enough death_oclock will become famous soon enough 
Solved Threads: 37
death_oclock's Avatar
death_oclock death_oclock is offline Offline
Posting Whiz

Re: Hw to execute dos commands in C

 
0
  #6
Feb 27th, 2009
Ah, I wasn't saying you always bash the system function, but whenever it appears in code just about everyone else goes crazy.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 476
Reputation: csurfer is just really nice csurfer is just really nice csurfer is just really nice csurfer is just really nice csurfer is just really nice 
Solved Threads: 76
csurfer's Avatar
csurfer csurfer is offline Offline
Posting Pro in Training

Re: Hw to execute dos commands in C

 
0
  #7
Mar 2nd, 2009
>Arkm
>death_oclock
Well I couldn't really make out if you people were against usage of system library function here in this context.If yes could you state the reason...?
I Surf in "C"....
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,783
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 745
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Hw to execute dos commands in C

 
1
  #8
Mar 2nd, 2009
>Well I couldn't really make out if you people were against
>usage of system library function here in this context.
By my reading, death_oclock isn't sure, and ArkM hasn't stated a preference.

>If yes could you state the reason...?
In this case, system is still risky, but no more risky than ShellExecute as they both have the same vulnerability: unless you're careful about the path you pass, a malicious program can be run in place of the one you expected.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 476
Reputation: csurfer is just really nice csurfer is just really nice csurfer is just really nice csurfer is just really nice csurfer is just really nice 
Solved Threads: 76
csurfer's Avatar
csurfer csurfer is offline Offline
Posting Pro in Training

Re: Hw to execute dos commands in C

 
0
  #9
Mar 2nd, 2009
Originally Posted by Narue View Post
>Well I couldn't really make out if you people were against
>usage of system library function here in this context.
By my reading, death_oclock isn't sure, and ArkM hasn't stated a preference.

>If yes could you state the reason...?
In this case, system is still risky, but no more risky than ShellExecute as they both have the same vulnerability: unless you're careful about the path you pass, a malicious program can be run in place of the one you expected.
Path is still a user input right ? As both system and ShellExecute have same problems on the system side execution,its just the path which determines whether it would suit this application or not.
So once we are sure that the path given by user is right the system(<path>) should not create any problem.Isn't it Naure?
I Surf in "C"....
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,783
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 745
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Hw to execute dos commands in C

 
1
  #10
Mar 2nd, 2009
>Path is still a user input right ?
I don't know, the OP changed his post so that it no longer specifies.

>So once we are sure that the path given by user is right
>the system(<path>) should not create any problem.
It can still create problems, but those problems aren't something you can easily control with code.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC