Jump to content

Makecab Expand Tool


Recommended Posts

I have made this Vb.net app to run either Makecab or Expand, this app now displays the output of either function.

MakeCabExpandImg.png


Public Class Form1
Dim MeClose
Dim MeLabel = Chr(187) & " Drag And Drop Single File Or Multiple Files. Drag And Drop A Single Folder Or Multiple Folders. This will auto sort the files for either Makecab or Expand process."
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = MeLabel
Me.Text = "Gunsmokingman MakeCab And Expand Tool"
ShowInfo(False)
'-> To Accept Cmd Line Arguments EG
'-> Start /Wait PATH_TO\MakeCabAndExpand.exe "SomeFileToCabOrExpand.zzz"
'-> Run The App From Sendto Folder
For Each Args In My.Application.CommandLineArgs
If Args.Count >= 1 Then
MeClose = True
SortFileFolder(Args.ToString)
End If
Next
'-> Close The App After Files Or Folder Are Completed
If MeClose = True Then
Me.Close()
End If
End Sub
''' <summary>
''' Change Status Bar Background
''' </summary>
''' <param name="Show"></param>
''' <remarks></remarks>
Private Sub ShowInfo(ByVal Show As Boolean)
If Show Then
TxtInfo1.BackgroundImage = MakeCabAndExpand.My.Resources._125_LightLime
Else
TxtInfo1.BackgroundImage = MakeCabAndExpand.My.Resources._125_LightTan
TxtInfo1.Text = ""
End If
End Sub
''' <summary>
''' Drag And Drop Action
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub Form1_Drag(ByVal sender As Object, ByVal e As DragEventArgs) Handles MyBase.DragEnter, MyBase.DragDrop
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
Dim MyObject As String() = CType(e.Data.GetData(DataFormats.FileDrop), String())
Try
For Each I In MyObject
SortFileFolder(I.ToString)
Next
Catch ex As Exception
End Try
End If
Label1.TextAlign = ContentAlignment.TopLeft
Label1.Text = MeLabel
End Sub
''' <summary>
''' Check Either A File Or Folder
''' </summary>
''' <param name="Chk"></param>
''' <remarks></remarks>
Private Sub SortFileFolder(ByRef Chk)
If Microsoft.VisualBasic.Right(InStr(Chk, "."), 5) Then
Me.Focus()
Work(Chk)
Else
Me.Focus()
ListAll(My.Computer.FileSystem.GetFiles(Chk), My.Computer.FileSystem.GetDirectories(Chk))
End If
End Sub
''' <summary>
''' List All Files From Parent Folder Threw All Sub Folders
''' </summary>
''' <param name="Files"></param>
''' <param name="Folders"></param>
''' <remarks></remarks>
Private Sub ListAll(ByRef Files, ByRef Folders)
For Each File In Files
Work(File)
Next
For Each Folder In Folders
ListAll(My.Computer.FileSystem.GetFiles(Folder), My.Computer.FileSystem.GetDirectories(Folder))
Next
End Sub
''' <summary>
''' Makecab Or Expand Display Output To App
''' </summary>
''' <param name="File"></param>
''' <remarks></remarks>
Private Sub Work(ByRef File)
Environment.CurrentDirectory = My.Computer.FileSystem.GetParentPath(File)
Dim F = Chr(34) & File.ToString & Chr(34)
Dim Run As New Process()
ShowInfo(True)
If Not Microsoft.VisualBasic.Right(File, 1) = "_" Then
'-> MakeCab
Run.StartInfo.RedirectStandardOutput = True
Run.StartInfo.UseShellExecute = False
Run.StartInfo.CreateNoWindow = True
Run.StartInfo.FileName = Environment.SystemDirectory & "\makecab.exe "
Run.StartInfo.Arguments = " /D CompressionType=LZX /D CompressionMemory=21 " & F
Run.Start()
Label1.TextAlign = ContentAlignment.MiddleLeft
Label1.Text = "Path : " & My.Computer.FileSystem.GetParentPath(File) & vbCrLf & _
"Name : " & My.Computer.FileSystem.GetFileInfo(File).Name
Do
MyBase.Update()
TxtInfo1.Text = Run.StandardOutput.ReadLine.ToString()
Me.Activate()
Loop Until Run.HasExited
Else
'-> Expand
Run.StartInfo.RedirectStandardOutput = True
Run.StartInfo.UseShellExecute = False
Run.StartInfo.CreateNoWindow = True
Run.StartInfo.FileName = Environment.SystemDirectory & "\expand.exe "
Run.StartInfo.Arguments = F & " /R"
Run.Start()
Label1.TextAlign = ContentAlignment.MiddleLeft
Label1.Text = "Path : " & My.Computer.FileSystem.GetParentPath(File) & vbCrLf & _
"Name : " & My.Computer.FileSystem.GetFileInfo(File).Name
Do
MyBase.Update()
TxtInfo1.Text = Run.StandardOutput.ReadLine.ToString()
Me.Activate()
Loop Until Run.HasExited
End If
If My.Computer.FileSystem.FileExists(File) Then My.Computer.FileSystem.DeleteFile(File, 2, 2)
ShowInfo(False)
End Sub
'-> Close App
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
End Class

New Source Code

MakeCabAndExpand.exe

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...