Sign in to follow this  
Followers 0
SinghIsKing

Removable or fixed?

14 posts in this topic

hi all, i would like to know how can i check about drive type?

i have a file in my usb flash drive and i don't want it to be run from Fixed and Cd, dvd drives. i only want it to be run from Removable devices.

who can help me about it?

Share this post


Link to post
Share on other sites



hi all, i would like to know how can i check about drive type?

i have a file in my usb flash drive and i don't want it to be run from Fixed and Cd, dvd drives. i only want it to be run from Removable devices.

who can help me about it?

Hello SinghIsKing

Welcome in Autoit forum.

you can get the type of any drive by

DriveGetType ( "path" )

Its good for you to read the AutoIt help Manual, you will find all the functions about drives and files.


73 108 111 118 101 65 117 116 111 105 116

Share this post


Link to post
Share on other sites

Hello SinghIsKing

Welcome in Autoit forum.

you can get the type of any drive by

DriveGetType ( "path" )

Its good for you to read the AutoIt help Manual, you will find all the functions about drives and files.

Thanks for the welcome,

i have read about it but how the script will check itself if it's running from a fixed or usb drive?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks for the help, sorry for one more question.

i have a file in

E:\Dongle\Start.exe

can i know if it is in fixed or usb drive using AutoIt Script?

i tried

$File = "E:\Dongle\Start.exe"

msgbox(0,"",DriveGetType($File))

but it gives nothing.

Edited by SinghIsKing

Share this post


Link to post
Share on other sites

Thanks for the help, sorry for one more question.

i have a file in

E:\Dongle\Start.exe

can i know if it is in fixed or usb drive using AutoIt Script?

i tried

$File = "E:\Dongle\Start.exe"

msgbox(0,"",DriveGetType($File))

but it gives nothing.

Hi there,

Here are two examples for you, but i deeply recomend some reading in the help file a.k.a. AutoIT Bible.

Feel free to try it and modify!

;Example 1

$file = FileOpenDialog("Choose file", @DesktopDir, "All (*.*)", 1)
$disk = StringMid($file, 1, 2)
$result = DriveGetType($disk)
MsgBox (64, "Result", "The selected file is in a " & $result & " Disk")

;Example2

$test = DriveGetDrive("REMOVABLE")
    for $x = 1 to $test[0]
        MsgBox(64, "test", "Drive " & $test[$x] & " Is a Removable disk")
    next

Cheers.


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

it gives nothing.

I can't imagine why that would be unless the E: drive isn't present or the path is incorrect. Try just E:

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I can't imagine why that would be unless the E: drive isn't present or the path is incorrect. Try just E:

Test it on your pc
msgbox(0,"",DriveGetType($CmdLineRaw))
it will give no result.

@ november

hi friend, Thanks for the examples.

Edited by SinghIsKing

Share this post


Link to post
Share on other sites

no, it's not working.

Share this post


Link to post
Share on other sites

no, it's not working.

Hi again,

Just explain to me... is the start.exe your script compiled or just 3rd party file?

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

Hi again,

Just explain to me... is the start.exe your script compiled or just 3rd party file?

Cheers

just 3rd party file

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

just 3rd party file

Hi again,

Try this...

HotKeySet("{ESC}", "over");Press ESC to exit monitoring file

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""

While 1
    
$process = ProcessList("Start.exe")

    IF $process [0][0] = 0 Then
        ConsoleWrite("Start.exe not running, sleeping for 10 secs" & @CRLF)
        sleep (10000); ten secs Sleep
    Else
        $ProID = $process[1][1]
        Search()
    EndIf
Sleep(50)

WEnd

Func Search()

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE ProcessID LIKE '" & $ProID & "'", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output &= $objItem.ExecutablePath
   Next
  ;ConsoleWrite($Output)
Else
   ConsoleWrite("No WMI Objects Found for class: " & "Win32_Process" )
Endif

$file = $Output
$disk = StringMid($file, 1, 2)
$result = DriveGetType($disk)
If $result <> "REMOVABLE" Then
    ConsoleWrite($Output & " Running from a non removable disk. PID : " & $ProID & " Killed" & @CRLF)
    ProcessClose($ProID)
    Return
Else
    ConsoleWrite($Output & " Running from a removable disk." & @CRLF)
    Sleep(5000);sleep 5 secs
Endif
$Output = ""

EndFunc

Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

Func over()
    Exit
EndFunc

Cheers

Edited by november

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

Test it on your pc

msgbox(0,"",DriveGetType($CmdLineRaw))
it will give no result.
you probably didnt define $CMDlineRaw

at the start of your script add this

$CmdLineRaw = 'E:/" ; set this to what you need to define it to


code

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

you probably didnt define $CMDlineRaw

at the start of your script add this

$CmdLineRaw = 'E:/" ; set this to what you need to define it to

Not to mention that throwing in command line params is gonna screw up the path. For example: running a script in SciTE uses the cmdline params '/errorstdout space "scriptfullpath"' which is not a valid "path" Edited by spudw2k

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0