Support Forums
[C#] Check If Executed From USB Drive - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: [C#] Check If Executed From USB Drive (/showthread.php?tid=11241)



[C#] Check If Executed From USB Drive - wchar_t - 08-13-2010

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.


RE: [C#] Check If Executed From USB Drive - Fragma - 08-13-2010

Thanks. Another helpful bit of code.


RE: [C#] Check If Executed From USB Drive - Buzz Lightyear - 08-19-2010

Thanks for the snippet man!


RE: [C#] Check If Executed From USB Drive - Black Shadow - 08-21-2010

Thanks this will come in handy.


RE: [C#] Check If Executed From USB Drive - `P R O D I G Y™ - 08-25-2010

When a program is auto executed, is it the code itself or a file to manage it?


RE: [C#] Check If Executed From USB Drive - euverve - 05-15-2011

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



RE: [C#] Check If Executed From USB Drive - cfillion - 05-15-2011

Thank for shared that, it will be usefull. Smile

Use the code tag instead of quote.


RE: [C#] Check If Executed From USB Drive - stephen5565 - 05-20-2011

Another



RE: [C#] Check If Executed From USB Drive - The Holy Shit. - 05-30-2011

Your TBOT Source? Me and T3rror coded this, T3rror coded this specific function.


RE: [C#] Check If Executed From USB Drive - Filefinder - 05-31-2011

I may add this in my crypter as a little extra.