Jump to content

"Desk Drive" Clone


Recommended Posts

Desk Drive is freeware utility that checks the presence of drives, and if it finds them, creates a shortcut for them on the desktop. But I read that it takes up ~17 mb of ram so I decided to make my own. about 15 minutes later i have a decent script.. it does everything except remove the shortcut to a removable drive after it is disconnected. it works fine with the CD/DVD drives, but not with USB.

here's why...

check drives >> check drive space >> create shortcut to for drives with more than 0 mb >> delete "would be" shortcut for drives with 0 mb space >> rinse >> repeat.

when a shortcut is created for a usb device, and then the device is removed, the shortcut remains, because the drive letter is no longer there, and therefore cannot be checked for file size, so the "would be" shortcut cannot be deleted.

this is not the case for cd/dvd drives, because their letter is always available, even with no disk inserted.

plz help me!!!

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.11.12 (beta)
 Author:         BLuFeNiX (formerly known as HackerZer0)

 Script Function: 
    
    Add drive shortcuts to desktop
    
#ce ----------------------------------------------------------------------------

While 1
    Sleep(2000)
    $cdrom = DriveGetDrive( "CDROM" )
    If NOT @error Then
        For $i = 1 to $cdrom[0]
            $varcd = DriveSpaceTotal( $cdrom[$i] & "\" )
            $dirvar = StringTrimRight($cdrom[$i], 1)
            If $varcd > 0 Then
                If NOT FileExists(@DesktopDir & "\Drive (" & $dirvar & ").lnk") Then
                    FileCreateShortcut($cdrom[$i],@DesktopDir & "\Drive (" & $dirvar & ").lnk")
                EndIf
            EndIf
            If $varcd = 0 Then
                FileDelete(@DesktopDir & "\Drive (" & $dirvar & ").lnk")
            EndIf
        Next
    EndIf
    
    $removable = DriveGetDrive( "REMOVABLE" )
    If NOT @error Then
        For $i = 1 to $removable[0]
            $varremovable = DriveSpaceTotal( $removable[$i] & "\" )
            $dirvar = StringTrimRight($removable[$i], 1)
            If $varremovable > 0 Then
                If NOT FileExists(@DesktopDir & "\Drive (" & $dirvar & ").lnk") Then
                    FileCreateShortcut($removable[$i],@DesktopDir & "\Drive (" & $dirvar & ").lnk")
                EndIf
            EndIf
            If $varremovable = 0 Then
                FileDelete(@DesktopDir & "\Drive (" & $dirvar & ").lnk")
            EndIf
            
        Next
    EndIf
WEnd

THX!!!

Link to comment
Share on other sites

you can always check for drive existance by using FileExists("D:\") (1 if it exists, 0 if not)

for me, this works with removeable drives as FileExists returns 0 if the drive has been removed.

You just need to keep track of the drives you DID create shortcuts for.

(maybe an array?)

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

I am already using DriveGetDrive()

But surely if you rechecked it the drive letter that used to be ther for the USB drive isn't there anymore so you can delete the shortcut.

Everytime you create a shortcut to a drive record it in an array, then check the array of shortcuts and the array for DriveGetDrive() if there is a shortcut to a drive that no longer exists then delete the shortcut and remove it from your array.

Or am I missing the point?

Link to comment
Share on other sites

Giving this some thought I think that maybe you made it a bit more complicated than it needed to be.

While 1
    
For $i = 65 to 90
    If DriveStatus (Chr($i) & ":") = "READY" then 
        If NOT FileExists(@desktopDir & "\Drive" & Chr($i) & ".lnk") then FileCreateShortcut(Chr($i) & ":",@DesktopDir & "\Drive" & Chr($i) & ".lnk")
        
        Elseif FileExists(@desktopDir & "\Drive" & Chr($i) & ".lnk") then 
            FileDelete(@desktopDir & "\Drive" & Chr($i) & ".lnk")
    EndIf
Next
    Sleep(1000)
WEnd
Link to comment
Share on other sites

Or one that cleans up itself on exit

HotkeySet("+{Esc}","_Quit")

Local $Temp = StringSplit("ABCDEFGHIJKLMNOPQRSTUVWXYZ","")
Local $aDrives[27][2]
For $i = 0 to 26
    $aDrives[$i][0] = $Temp[$i]
Next

$Temp = 0
While 1

For $i = 1 to 26
    If DriveStatus ($aDrives[$i][0] & ":") = "READY" then 
        
        If NOT FileExists(@desktopDir & "\Drive" & $aDrives[$i][0] & ".lnk") then 
            FileCreateShortcut($aDrives[$i][0] & ":",@DesktopDir & "\Drive" & $aDrives[$i][0] & ".lnk")
            $aDrives[$i][1] = @DesktopDir & "\Drive" & $aDrives[$i][0] & ".lnk"
        EndIf
        
    Elseif FileExists(@desktopDir & "\Drive" & $aDrives[$i][0] & ".lnk") then 
            FileDelete(@desktopDir & "\Drive" & $aDrives[$i][0] & ".lnk")
            $aDrives[$i][1] = ""
    EndIf
Next
    Sleep(1000)
WEnd

Func OnAutoItExit()
    
    For $i = 1 to 26
        If $aDrives[$i][1] <> "" and FileExists($aDrives[$i][1]) then FileDelete($aDrives[$i][1])
    Next
    
EndFunc

Func _Quit()
    Exit
EndFunc
Link to comment
Share on other sites

Why do I get the feeling from the name "HackerZer0" asking for methods of scanning for removable devices that this is going to be used as malware for spreading a virus?

He's been around a while I don't think he is!

Link to comment
Share on other sites

He's been around a while I don't think he is!

Thank You :)

I may be a hacker, but just white hat... I help people track down hackers, I'm more of a security analyst.

anyway..

@ChrisL

That's a very nice script, it does everything I need, except, I don't want it to show system drives (C:, D:, etc)

only removable and cd drives (with media in them)

Link to comment
Share on other sites

Thank You :)

I may be a hacker, but just white hat... I help people track down hackers, I'm more of a security analyst.

anyway..

@ChrisL

That's a very nice script, it does everything I need, except, I don't want it to show system drives (C:, D:, etc)

only removable and cd drives (with media in them)

No problems, thats an easy mod for you though with

If DriveGetType($aDrives[$i][0] & ":") = "Fixed" then Continueloop
Edited by ChrisL
Link to comment
Share on other sites

aha! I knew there was an easier way.. I haven't used autoit in a while so i need to brush up on my commands. Thx! here's the final source code for anyone who wants it..

Free feel to clean up/modify...

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.11.12 (beta)
 Author:         BLuFeNiX (formerly known as HackerZer0)

 Script Function:
    Add shortcut to removable media to desktop.

#ce ----------------------------------------------------------------------------

Opt("OnExitFunc", "_CLEANUP")

While 1
    
    For $i = 65 to 90
        If DriveStatus (Chr($i) & ":") = "READY" then
        
            If DriveGetType(Chr($i) & ":") = "Fixed" then Continueloop
        
            If NOT FileExists(@desktopDir & "\Drive (" & Chr($i) & ").lnk") then FileCreateShortcut(Chr($i) & ":",@DesktopDir & "\Drive (" & Chr($i) & ").lnk")
        
            Else
                FileDelete(@desktopDir & "\Drive (" & Chr($i) & ").lnk")
        EndIf
    Next
    
    Sleep(1000)
WEnd

Func _CLEANUP()
    FileDelete(@desktopDir & "\Drive (*).lnk")
EndFunc
Link to comment
Share on other sites

  • 1 month later...

nice script but there are some problems

using a program such as filemon reveals significant repetitive file access attempts

as well, the first drive a:\ (65), if that is a floppy drive, makes physical drive noises repetitively

cleaning up the code should minimize these unnecessary file accesses

Link to comment
Share on other sites

nice script but there are some problems

using a program such as filemon reveals significant repetitive file access attempts

as well, the first drive a:\ (65), if that is a floppy drive, makes physical drive noises repetitively

cleaning up the code should minimize these unnecessary file accesses

Looking forward to seeing your code muttley

Link to comment
Share on other sites

  • 2 weeks later...

Looking forward to seeing your code muttley

Ian Perez updated Desktop Media and it works much better so I won't be working on the autoit code.

Desktop Media is a non-.net app that does the same function as Desk Drive (and much better I might add).

Link to comment
Share on other sites

Ian Perez updated Desktop Media and it works much better so I won't be working on the autoit code.

Desktop Media is a non-.net app that does the same function as Desk Drive (and much better I might add).

What an absolubte arse!

HackerZer0 decided to make a script because he wanted to, you come on here say it's crap and it could be made much better easily. All you have done is point to another application that you haven't written. You could pick loads off apps and say XYZ is better.

I would love to see how YOU would improve HackerZer0's code seeing as you say it is so easy.

Before slating other peoples efforts perhaps you could prove your worth first.

Just my humble opinion!

Link to comment
Share on other sites

What an absolubte arse!

HackerZer0 decided to make a script because he wanted to, you come on here say it's crap and it could be made much better easily. All you have done is point to another application that you haven't written. You could pick loads off apps and say XYZ is better.

I would love to see how YOU would improve HackerZer0's code seeing as you say it is so easy.

Before slating other peoples efforts perhaps you could prove your worth first.

Just my humble opinion!

ChrisL, couple things (these quotes are from my previous posts).

1)"nice script but there are some problems"

2)"cleaning up the code should minimize these unnecessary file accesses"

I was impressed by the script and stated as such, but also did point out how things could be improved. Isn't that the goal of the forums is to share and critique (gracefully?).

I was planning to undertake the code improvement when I noticed that Ian (after a delay) released a updated version of Desktop Media which fixed the problems with his program. I could still undertake the autoit code modification but there really is no point unless I wanted to do it for a challenge or fun (which ever came first).

Your comments are uncalled for and are quite inappropriate.

As for JFee's question - the program (Desktop Media) allocates 4,492K (currently on my system) and is very low on CPU utilization.

Link to comment
Share on other sites

One other thing ChrisL

I stated "Ian Perez updated Desktop Media and it works much better" which may of created all of your unnecessary comments.

Desktop Media (non-.net) is better than Desk Drive (.net)

In using a program of this type, I would have used (and modified) the autoit code other than to use the actual Desk Drive program.

The autoit code provided is excellent (I was not degrading the autoit code).

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...