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.

Recommended Answers

All 9 Replies

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.

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

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

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?

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

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

copy /b file1 + file2 file3

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

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")

<<snip>>

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.

>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.