February 24, 201016 yr I have made this Vb.net app to run either Makecab or Expand, this app now displays the output of either function.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 SubEnd ClassNew Source CodeMakeCabAndExpand.exe
February 24, 201016 yr Uses .NET Framework 3.5?Edit: after the primary error (no .NET 3.5), if I click Continue, it still works.Thank you very much, saves a lot of lines pointing Command Prompt to folders. Edited February 24, 201016 yr by Sp0iLedBrAt
February 24, 201016 yr Author I made this on Windows 7 so i was not thinking about the framework version.
Create an account or sign in to comment