LeeSylvester Posted October 18, 2007 Share Posted October 18, 2007 Hey guys,I've just started with AutoIt, really, having discovered it a couple of weeks ago. Two days ago, I started a project whose source files needed to sit in a path that was located on a drive P: rather than where I normally keep my project files (nested deep in my "My Documents" directory). So, I went on a hunt to find a decent Virtual Drive application. I ended up finding two. Both were buggy and required fee's to make the drives remain following a reboot. Thus I decided to use AutoIt to write my own toolIt took just four hours to makeYou guys, being the users of such a cool product, can download this tool (no fees like those cheap @$?%) from here. It supports adding and removing virtual drives and persists after a reboot. Just as it should!!!Regards,Lee Link to comment Share on other sites More sharing options...
Fossil Rock Posted October 18, 2007 Share Posted October 18, 2007 I'm not going to run any app a n00bie posts unless the source is included. Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
LeeSylvester Posted October 18, 2007 Author Share Posted October 18, 2007 I'm not going to run any app a n00bie posts unless the source is included. lol... Yeah, I hadn't thought of that. Okay, I can't see why not. This will at least set me up for the bigger projects which I might not want to submit source for Lee expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> #Include <GuiListView.au3> #include <Array.au3> #Include <GuiCombo.au3> #include <File.au3> TraySetToolTip( "DesignRealm Virtual-Drive" ) Opt( "TrayIconHide", 1 ) Opt("OnExitFunc", "OnClose") Dim $win_width = 420 Dim $win_height = 250 Dim $btn_top_height = 30 Dim $btn_top_width = 100 Dim $btn_bottom_height = 30 Dim $btn_bottom_width = 100 Dim $btn_file_height = 20 Dim $btn_file_width = 20 Dim $txt_file_height = 20 Dim $txt_file_width = 220 Dim $cbs_drive_height = 20 Dim $cbs_drive_width = 50 Dim $spacer = 5 Dim $diag = GUICreate( "DesignRealm Virtual-Drive", $win_width, $win_height, -1, -1, BitOR( $WS_POPUPWINDOW, $WS_CAPTION ), BitOR( $WS_EX_ACCEPTFILES, $WS_EX_TOOLWINDOW ) ) Dim $listview = GUICtrlCreateListView ( "Select | Drive | Path", $spacer, ( $spacer*2 ) + $btn_top_height, $win_width - ( $spacer*2 ), $win_height - ( ( ( $spacer*2 ) + $btn_top_height ) + ( ( $spacer*2 ) + $btn_bottom_height ) ), BitOR( $LVS_SINGLESEL, $LVS_SORTDESCENDING ), BitOR( $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_FLATSB ) ) _GUICtrlListViewSetColumnWidth ( $listview, 0, 50 ) _GUICtrlListViewSetColumnWidth ( $listview, 1, 50 ) _GUICtrlListViewSetColumnWidth ( $listview, 2, ( $win_width - ( $spacer*2 ) ) - 105 ) Dim $refresh_btn = GUICtrlCreateButton ( "Refresh", $win_width - ( $btn_bottom_width + $spacer ), $win_height - ( $btn_bottom_height + $spacer ), $btn_bottom_width, $btn_bottom_height ) Dim $create_btn = GUICtrlCreateButton ( "Create New", $spacer, $win_height - ( $btn_bottom_height + $spacer ), $btn_bottom_width, $btn_bottom_height ) Dim $delete_btn = GUICtrlCreateButton ( "Delete Selected", $btn_bottom_width + ( $spacer*2 ), $win_height - ( $btn_bottom_height + $spacer ), $btn_bottom_width, $btn_bottom_height ) Dim $fileopen = GUICtrlCreateButton ( "...", $win_width - ( $btn_file_width + $spacer ), $spacer + ( $btn_top_height - $btn_file_height ), $btn_file_width, $btn_file_height ) Dim $filetxt = GUICtrlCreateInput( "", $win_width - ( $btn_file_width + ( $spacer*2 ) + $txt_file_width ), $spacer + ( $btn_top_height - $txt_file_height ), $txt_file_width, $txt_file_height, $ES_READONLY ) Dim $driveletters = GUICtrlCreateCombo ( "", $win_width - ( $btn_file_width + ( $spacer*3 ) + $txt_file_width + $cbs_drive_width ), $spacer + ( $btn_top_height - $cbs_drive_height ), $cbs_drive_width, $cbs_drive_height, $CBS_DROPDOWNLIST ) GUISetState ( @SW_SHOW ) Func AddDriveToList( $driveStr ) Dim $array = StringSplit( $driveStr, '\: => ', 1 ) If $array[0] > 1 Then $item = GUICtrlCreateListViewItem( "|" & $array[1] & "|" & $array[2], $listview ) EndFunc Func AddDrive() If GUICtrlRead( $filetxt ) <> "" Then RunWait( @ComSpec & " /c subst " & GUICtrlRead( $driveletters ) & ': "' & GUICtrlRead( $filetxt ) & '"', @SystemDir, @SW_HIDE ) EndIf GUICtrlSetData( $filetxt, "" ) GetDriveLetters() GetDrives() EndFunc Func GetIndices() Dim $array[1] Dim $n For $n = 0 to _GUICtrlListViewGetItemCount( $listview ) -1 If _GUICtrlListViewGetCheckedState( $listview, $n ) Then _ArrayAdd( $array, $n ) EndIf Next Return $array EndFunc Func GetDrives() ClearDrives() Dim $foo = Run( @ComSpec & " /c subst", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD ) Dim $drive = "" Dim $line = "" While 1 $line = $line & StdoutRead( $foo ) If @error Then ExitLoop Wend Dim $array = StringSplit( $line, Chr(10) & Chr(13) ) For $drive = 1 To $array[0] If StringInStr( $array[$drive], ':\:' ) Then AddDriveToList( $array[$drive] ) Next EndFunc Func ClearDrives() _GUICtrlListViewDeleteAllItems( $listview ) EndFunc Func GetDriveLetters() ClearDriveLetters() Dim $taken = DriveGetDrive( "ALL" ) Dim $all = StringSplit( "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "" ) Dim $top = "" Dim $i For $i = 1 To $all[0] If _ArraySearch( $taken, $all[$i] & ":" ) = -1 Then If $top = "" Then $top = $all[$i] GUICtrlSetData( $driveletters, $all[$i], $top ) EndIf Next EndFunc Func ClearDriveLetters() _GUICtrlComboResetContent ( $driveletters ) EndFunc Func RemoveDrives() Dim $col, $n For $n = 0 to _GUICtrlListViewGetItemCount( $listview ) -1 If _GUICtrlListViewGetCheckedState( $listview, $n ) Then $col = _GUICtrlListViewGetItemText ( $listview, $n, 1 ) RunWait( @ComSpec & " /c subst " & $col & " /d", @SystemDir, @SW_HIDE ) EndIf Next _GUICtrlListViewDeleteAllItems( $listview ) GetDrives() GetDriveLetters() EndFunc Func OnClose() Dim $path = @SystemDir & "\" & "vdstor.bat" If Not FileExists( $path ) Then If Not _FileCreate( $path ) Then MsgBox( 4096, "Error", "Error setting drives to permenant. You may need to reassign the drives when you next reboot." ) RegDelete( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "VDStor" ) Return -1 EndIf EndIf Dim $file = FileOpen( $path, 2 ) If $file = -1 Then MsgBox( 4096, "Error", "Error setting drives to permenant. You may need to reassign the drives when you next reboot." ) RegDelete( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "VDStor" ) Return -1 EndIf Dim $foo = Run( @ComSpec & " /c subst", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD ) Dim $drive = "" Dim $line = "" While 1 $line = $line & StdoutRead( $foo ) If @error Then ExitLoop Wend Dim $array = StringSplit( $line, @CRLF ) FileWriteLine( $file, "@ECHO OFF" ) For $drive = 1 To $array[0] If StringInStr( $array[$drive], ':\:' ) Then Dim $farray = StringSplit( $array[$drive], '\: => ', 1 ) If $farray[0] > 1 Then FileWriteLine( $file, "@subst " & $farray[1] & ' "' & $farray[2] & '"' ) EndIf Next RegWrite( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "VDStor", "REG_SZ", @SystemDir & "\" & "vdstor.bat" ) EndFunc GetDrives() GetDriveLetters() While 1 Dim $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $refresh_btn GetDrives() Case $delete_btn If MsgBox( 4, "Confirm...", "Are you sure you wish to delete the selected drives?" ) = 6 Then RemoveDrives() EndIf Case $fileopen GUICtrlSetData( $filetxt, StringStripCR( StringStripWS( FileSelectFolder( "Select a Path...", "" ), 3 ) ) ) Case $create_btn AddDrive() EndSwitch Wend Link to comment Share on other sites More sharing options...
Fossil Rock Posted October 18, 2007 Share Posted October 18, 2007 (edited) Okay, I can't see why not.Sorry if it sounded like I was doubting you intent, but script kiddies like to pack harmful stuff into exe's and post them.As for virtual drives, I've used Daemon Tools for many years without any problems and there is a free version. Edited October 18, 2007 by Fossil Rock Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
LeeSylvester Posted October 18, 2007 Author Share Posted October 18, 2007 Yes, but Daemon Tools is for Virtual CDROM drives. This tool creates virtual drives from directories on your hard drive. Therefore, instead of C:\Documents and Settings\My Ridiculously long name\My Documents\Development\Some Company\Project 5\Website\source media\ You can have W:\ That's quite a difference Lee Link to comment Share on other sites More sharing options...
JOHNe Posted October 18, 2007 Share Posted October 18, 2007 Nice one thanks .... "Our deepest fear is not that we are inadequate.Our deepest fear is that we are powerful beyond measure.It is our light, not our darkness that most frightens us." Link to comment Share on other sites More sharing options...
Fossil Rock Posted October 18, 2007 Share Posted October 18, 2007 Yes, but Daemon Tools is for Virtual CDROM drives. This tool creates virtual drives from directories on your hard drive. Therefore, instead ofC:\Documents and Settings\My Ridiculously long name\My Documents\Development\Some Company\Project 5\Website\source media\You can haveW:\That's quite a difference LeeAh, my bad ... Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
James Posted October 18, 2007 Share Posted October 18, 2007 I will try this when I get home. It looks really nice! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
gseller Posted October 18, 2007 Share Posted October 18, 2007 Ok, that is way cool! If this is from a noobie, can't wait to see what ya come up with in a couple more weeks.. LOL Link to comment Share on other sites More sharing options...
LeeSylvester Posted October 18, 2007 Author Share Posted October 18, 2007 Ok, that is way cool! If this is from a noobie, can't wait to see what ya come up with in a couple more weeks.. LOLThank you I've actually been playing with the idea of creating a PowerTools style app for XP users. Currently, I'm playing with a wizard idea for adding options to Windows Explorers context menus. I dunno. I guess I need to think hard about what Windows really needs.Lee Link to comment Share on other sites More sharing options...
gseller Posted October 18, 2007 Share Posted October 18, 2007 sounds great! Looking forward to seeing the results. Link to comment Share on other sites More sharing options...
James Posted October 18, 2007 Share Posted October 18, 2007 That's awesome! And you have just started AutoIt, fantastic! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
spudw2k Posted October 31, 2007 Share Posted October 31, 2007 Clever, a frontend to subst. Can't complain. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF  Link to comment Share on other sites More sharing options...
Nahuel Posted November 1, 2007 Share Posted November 1, 2007 (edited) Wow man! Great work! I'm so gonna use this! Just one thing... how do I make it so I can set a label to the new drive? :"> Edited November 1, 2007 by Nahuel Link to comment Share on other sites More sharing options...
NeoFoX Posted November 1, 2007 Share Posted November 1, 2007 It's a very nice program, which I'm using right now I made just a small change: - Program is always in Tray Icon accesable, so I can use the right-mouse button and the program starts again. And I noticed that the 'Virtual Drive' which is created is a Copy of your C: drive. When you change the name of your C: drive, the name of your virtual drive will change in that one to. I don't know if it is possible to assign it an own name, because it's not a fysical drive. But, keep up the good work. Neo [center][font="Arial"]--- The Neo and Only --- [/font][font="Arial"]--Projects---[/font]Image to Text converterText to ASCII converter[/center] Link to comment Share on other sites More sharing options...
sg1kritik Posted November 2, 2007 Share Posted November 2, 2007 very handy util, thx for the code - nice work Link to comment Share on other sites More sharing options...
BrettF Posted November 2, 2007 Share Posted November 2, 2007 Thank you. This is great! Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
MCP Posted November 3, 2007 Share Posted November 3, 2007 Clever, a frontend to subst. Can't complain. eh eh eh... old wolf... Link to comment Share on other sites More sharing options...
flyingboz Posted November 3, 2007 Share Posted November 3, 2007 lot of work for subst and subst /d..... Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
ako673de Posted November 23, 2007 Share Posted November 23, 2007 Hi, something off topic: subst soes not work quite ggod on NT based systems. Even ntsubst, which is reported to be a clone working better on NT systems, shows things like: - Network shares connected as drives overwrite drives created by xxsubst - removable media like memory card slots overwrite xxsubst drives Does anybody know a well supported way to create virtual drives on NT systems? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now