954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to use DOS command in vb.net

Hello Everybody,
I want to I want to perform dos command (copy) in vb.net.I want to do it on button click event.Invoking the command using .bat format is not suit for me, because the source and destination of copying depending upon the selection of source and destination(that's done by users of this application).Please help me.

krm08
Newbie Poster
11 posts since Dec 2008
Reputation Points: 10
Solved Threads: 0
 
Shell("cmd /c copy file1 file2", vbHide)


the cmd /c closes the command window as soon as the command is ran and vbhide hides the command window so its not seen.

Hope this helps.

bobbydiaz
Newbie Poster
1 post since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

Dunno why you don't just do the copy from within VB.NET (without a system call)

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

probably doing an assignment for school and is directed to do it this way. (maybe a vbscript batch file for system admin?)

rapture
Posting Whiz in Training
294 posts since Jul 2007
Reputation Points: 155
Solved Threads: 41
 

hello friends

Shell("cmd /c copy file1 file2", vbHide)

doesn't work.
I need to run the command

copy /b file1 + file2

how can I do this?

krm08
Newbie Poster
11 posts since Dec 2008
Reputation Points: 10
Solved Threads: 0
 

File.Copy("C:\directory\File1.txt", "C:\Directory\File2.txt")

rapture
Posting Whiz in Training
294 posts since Jul 2007
Reputation Points: 155
Solved Threads: 41
 

It doesn't works.Any way thanks for your reply.As I mentioned above I want to perform

copy /b file1 + file2 file3
krm08
Newbie Poster
11 posts since Dec 2008
Reputation Points: 10
Solved Threads: 0
 

Are File1 File2 and File3 supposed to be variables in your program, or are they hard-coded in names?

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

To run DOS command in VB.Net use following code. It might be useful for you.
Shell("cmd.exe /c c:\first.exe < in.txt > out.txt")

<>

GuggiTanvi
Newbie Poster
3 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
Infraction Points: 5
 

Dim tre = "copy /b """ & txtFile1.Text & """" & txtFile2.Text & """
Shell(tre, vbHide)

bt if you want two files to be copied into one ?? you shuld look for the particualr command to that bt the syntax to call it in the vb.net code will be the same.

>

mirza.imran
Newbie Poster
1 post since Apr 2012
Reputation Points: 0
Solved Threads: 0
 

Post: Markdown Syntax: Formatting Help
You