Jump to content
  • Advertisement
Sign in to follow this  
Iiimage

Sending info from c++ to .bat files?

This topic is 3005 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering if it was possible to send variables from my c++ program to a .bat file using Private Sub Command1_Click() char str1 = "Hello" Shell ".\rec.bat" & " " & str1", vbNormalFocus End Sub but i don't know what I would put in that batch file to get the varibles, and I don't even know if this is a way to go about doing that.

Share this post


Link to post
Share on other sites
Advertisement
Yeah, arguments to a batch file are accessible as %1, %2, etc. There are more advanced ways to use the arguments, but if all you want to do is give it a string, that's sufficient.

Share this post


Link to post
Share on other sites
Go read about pipes and redirection.

Observe this UNIX command:

cat file.stuff | strings > result.txt

Assuming that file.stuff contains both binary data with some text buried in it, this command sequence will extract the text into result.txt.

Here's how.

cat is a program that reads a file and dumps the output into standard output. The pipe symbol tells it to redirect that output into another program. strings can read that information through standard input, parse it to scrub any non-text data, and dump the result into standard output. The arrow redirects strings' output into a file.

In C++ you can access standard out, in and error with the cout, cin and cerr streams. You can do it with any other language too but the APIs will differ.

The syntax for using redirection in Windows is probably different but this post is just to let you know that these features exist. You'll need to look up how piping or redirection is done in the Windows command line (and thus bat files.)

EDIT: I just realized you said from C++ to .bat, not the other way around.

I'll leave this here though in case you think of something useful with it.

Also, that's not C++, that's Visual Basic.

Share this post


Link to post
Share on other sites
Quote:
Original post by Iiimage
can you explain a little bit, I've used batch files but I never have transfered data to them.


Quote:
Original post by Sneftel
Yeah, arguments to a batch file are accessible as %1, %2, etc. There are more advanced ways to use the arguments, but if all you want to do is give it a string, that's sufficient.


Share this post


Link to post
Share on other sites
haha okay, sense that is VB script... i should probably find a way to do it thru c++, thanks for the help tho

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!