• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Help with c++ and cmd.exe

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am attempting to write a shell of sorts for cmd.exe. What I want to do is have the user type in a command and then it be passed into the command line. I know this is possible because freecommander has a way to do this but I need to know how. Any help will be appreciated.
 
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use the /C option, e.g.
cmd /c dir
executes the "dir" command. For more options type "help cmd" into your shell.
 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am still somewhat of a newb with c++ so how exactly would i do this? i tried this


and got this error
 
Joachim Rohde
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if we are talking about the same thing here. I understood that you want to pass a command to cmd.exe which gets executed.
Anyway, if you want to execute an external program from within your C code have a look at http://www.cplusplus.com/reference/clibrary/cstdlib/system/
 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you soooooo much! that helped out alot! now i just need to figure out how to pass a string to do the same thing.
i used this code:

and got this error:

can you please explain to me why this is happening? also whenever i use:

and put multiple words in the string it only prints out the first word.
any help on this issue?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic