Support Forums

Full Version: [C#] Check If Executed From USB Drive
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Quote:public static void usbcheck()
{
DriveInfo[] drives = DriveInfo.GetDrives();
{

foreach (DriveInfo drive in drives)
if (drive.DriveType == DriveType.Removable)
if (drive.RootDirectory.Root.ToString()[0] == Environment.CurrentDirectory[0])
// Is USB Drive
else
{
// Not USB Drive
}
}
}

Grabbed from my TBOT Source.

it doesnt have to have a malware application.

very usefull code.
Thanks. Another helpful bit of code.
Thanks for the snippet man!
Thanks this will come in handy.
When a program is auto executed, is it the code itself or a file to manage it?
Translated to VB.NET

Code:
Public Shared Sub usbcheck()
        Dim drives() As DriveInfo = DriveInfo.GetDrives
        For Each drive As DriveInfo In drives
            If (drive.DriveType = DriveType.Removable) Then
                If (drive.RootDirectory.Root.ToString(0) = Environment.CurrentDirectory(0)) Then
                Else
                    ' Not USB Drive
                End If
            End If
        Next
    End Sub
Thank for shared that, it will be usefull. Smile

Use the code tag instead of quote.
Another
Your TBOT Source? Me and T3rror coded this, T3rror coded this specific function.
I may add this in my crypter as a little extra.