Saman Zia
Saman Zia

Reputation: 147

How i can use DOS Command in VB.NET?

I want to run this "rar a -rr10 -s c:\backup.rar c:\file.txt" DOS command in vb.net, my main problem is that i want to compress file in Winrar software using vb.net coding. a button is press in window form that compress the file.

This "rar a -rr10 -s c:\backup.rar c:\file.txt" DOS command compress the file.txt to backup.rar

Tell me multiple ways if anyone know to complete above task.

Upvotes: 0

Views: 1314

Answers (1)

1. Using Process.Start directly:

Imports System.Diagnostics
...

Process.Start("rar.exe", "a -rr10 -s c:\backup.rar c:\file.txt")

2. Using ProcessStartInfo:

Imports System.Diagnostics
...

Dim startInfo As New ProcessStartInfo("rar.exe")
startInfo.Arguments = "a -rr10 -s c:\backup.rar c:\file.txt"
' ... possibly set other parameters here... '

Process.Start(startInfo)

(Of course you might have to specify the path to rar.exe if it's not in the current directory.)

Upvotes: 4

Related Questions