Re: Command promt in VB 6
welcome to the forums... :wave:
may be creating a batch file(with the commands needed) and executing it using vb6 is a good idea.... (Shell "mybatchfile.bat" )
or, some thing like this:
Code:
Shell "cmd.exe /c ren abc.txt new.txt", vbHide
others may have better solutions... :wave:
1 Attachment(s)
Re: Command promt in VB 6
It depends on how much you can do "blind" and how much requires interaction.
Simply "typing" a series of fixed commands is pretty easy. You can create a .CMD or .BAT file and execute that.
However you might need to run a program, give it input, read and parse the output, then give it new input, etc. This requires another approach and a big part of the challenge can be in writing your program to interpret and act on those output responses.
If all you really want is to perform things like file and directory management though you'd probably be better off just using the related VB6 statements (Kill, FileCopy, MkDir, Name, etc.). I'm not sure what the benefit of spawning CMD.EXE really is unless you just want to use its command-line file redirection for blind operations.
The simple demo attached here contains ShellPipe and its helper class SmartBuffer. See the ShellPipe source for a description of the control and its use.
When I need a program to spawn console processes and interact with them I use my ShellPipe control. This lets you start such programs and retain control. You can receive the program's output, send the program input, abort the process as needed, etc. It operates asynchronously using an event model similar to that of the Winsock control.
Re: Command promt in VB 6
guys tanx for answers but it didn`t help much... as I said i am an bigginer in VB but I desperately need to make a program. i want to make it like this:
it would need just to type the names of the files I want to work with and the directory it needs to interact. the parameters between should be automatically typed and executed...
I know that this is a bit hard since I am just a bigginer but I am a fast learner... please help me... :(:( :wave: :check:
Re: Command promt in VB 6
@dilettante, very nice control!!! Is it ok to use this in my own projects?
Re: Command promt in VB 6
Quote:
Originally Posted by
pcuser
@dilettante, very nice control!!! Is it ok to use this in my own projects?
Sure thing. I don't provide support though, so I hope the logic is clear enough if you want to modify it for your own needs.
It is pretty stable now though and I use it "as is" in many projects. I'm at the point where I treat it as a black box just as if it were compiled into an OCX.
You might have another alternative to the SmartBuffer class. If you do use SmartBuffer you may want to look at the tuning constants CHUNK_SIZE and CHUNK_SOFT_LIMIT and adjust them to fit your application. For example if your interactions with the child process tend to be closer to 80-column lines of text you might make CHUNK_SIZE = 100 or so, and then maybe change CHUNK_SOFT_LIMIT = CHUNK_SIZE * 100 or something.
The defaults are working pretty well for me, and don't seem to cause any problems with excessive memory consumption.
Re: Command promt in VB 6
Quote:
Originally Posted by
Arxya
I know that this is a bit hard since I am just a bigginer but I am a fast learner... please help me...
You weren't really clear about the operations you want to perform on these files.
As I said earlier, VB has a number of file-related statements and functions for performing many common operations though. You should not need to spawn and interact with a command interpreter like CMD.EXE to do this.
Look in the documentation for the Kill, FileCopy, Name, MkDir, and similar statements.
If those don't do what you need we'll need more information.
Re: Command promt in VB 6
look... it`s not that simple... I need this so I can make a program to extract AUTOMATICALY the .sdc files. The only way to extrack these files is to use the command promt and type everything in... i know that way but it would be simpler to do it like this... thats why I need help... I hope you wont steal my idea :D:D:D
Re: Command promt in VB 6
Your attitude leaves a bit to be desired (look...). The folks here are not paid
to provide solutions, they volunteer. I have no idea what the extension .sdc
refers to nor what program does this extraction. If you can do it from the
command line, then you can easily write a batch file (.bat) to be called from
VB6. Note that if the process is time consuming you will need to call the
batch file asynchronously. Google for 'Shell And Wait'
Re: Command promt in VB 6
I am so sorry for my behavior and I very appreciate your work that you have done for me. Does any of you has a web page or something that could help me learn the basics of Visual Basic 6? I need this because I have a great desire to know how to make projects and programs... and who knows, maybe someday I will do what you are exactly doing... helping others :D :D :D :D :D :D
Re: Command promt in VB 6