Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 11, 2016, 02:01:50 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: Simple GUI to manage virtual drives  (Read 2717 times)

johnfdeluca

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 81
    • View Profile
    • Donate to Member
IDEA: Simple GUI to manage virtual drives
« on: December 19, 2006, 10:55:53 PM »
I have a simple batch file which is launched when my windows launches which creates "virtual" drives via two methods (1) net use dos command for network drive and (b) substr dos command for local folders.  Here's an example of a couple lines:

net use Z: \\diskstation\john password user:john
subst J: "C:\Documents and Settings\John\My Documents"

I really live to use these drive letters as fast access to common folders (be it local or network directory).  I think it would be cool to have a simple GUI that allows me to do this.  A bit of searching on the internet got me close as I found a GUI app http://www.autoitscript.com/forum/index.php?showtopic=28884&hl=subst (autoit script) to issue the subst command.  What's missing though are the following features:
  • ability to save it into a batch file in a startup directory so I dont need to keep issuing it every time I reboot.
  • ability to handle network shares

I'd like to have the app handle the network shares as well and write it all to a batch file in the startup directory.  I'd also like the ability to load the contents of an existing batch file (from a previous use of the app) to manage it (remove drives etc.).

Here's the autoit scipt which may serve as a starting point (though it doesnt need to be in auto it):
#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("SUBST Command Utility", 258, 282, 192, 125)
$Group1 = GUICtrlCreateGroup("Set a Drive", 8, 8, 241, 105)
$Input1 = GUICtrlCreateInput("", 72, 24, 25, 21, "M2", $WS_EX_CLIENTEDGE)
GUICtrlSetLimit(-1,1)
GUICtrlCreateLabel("Drive letter", 16, 27, 55, 17)
$Input2 = GUICtrlCreateInput("", 16, 56, 225, 21, -1, $WS_EX_CLIENTEDGE)
$Button1 = GUICtrlCreateButton("Browse", 184, 24, 57, 25)
GUICtrlCreateLabel("Set Drive to =>", 104, 27, 75, 17)
$Button2 = GUICtrlCreateButton("Set Now", 80, 80, 97, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Current Drives", 8, 128, 241, 145)
$List1 = GUICtrlCreateList("", 24, 144, 25, 123, -1, $WS_EX_CLIENTEDGE)
$Button3 = GUICtrlCreateButton("Delete Selected", 72, 152, 153, 33)
$Button4 = GUICtrlCreateButton("Delete All Subst Drives", 72, 192, 153, 33)
$Button5 = GUICtrlCreateButton("Refresh Drives", 72, 232, 153, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
getdrives()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button1
        $dir = FileSelectFolder ( "Select Folder to SUBST to.", "", 4 , "C:" )
        If $dir <> "" Then GUICtrlSetData( $Input2, $dir )
    Case $msg = $Button2
        If StringIsAlpha ( GUICtrlRead($Input1) ) And FileExists ( GUICtrlRead($Input2) ) Then
            $command = "subst /d " & GUICtrlRead($Input1) & ": "
            Run(@ComSpec & " /c " & $command, "", @SW_HIDE)
            $command = "subst " & GUICtrlRead($Input1) & ": " & '"' & GUICtrlRead($Input2) & '"'
            Run(@ComSpec & " /c " & $command, "", @SW_HIDE)
            Sleep(500)
            getdrives()
            EndIf
        Case $msg = $Button3
            $command = "subst /d " & GUICtrlRead($List1)
            Run(@ComSpec & " /c " & $command, "", @SW_HIDE)
            Sleep(500)
            getdrives()
        Case $msg = $Button4
            ProgressOn( "SUBST Delete", "Deleting drives" )
            For $i = 97 To 122
            ProgressSet( (100/26)*($i-97), "Drive " & Chr($i) & " deleted" )
            getdrives()
            Sleep(50)
            $command = "subst /d " & Chr($i) & ":"
            Run(@ComSpec & " /c " & $command, "", @SW_HIDE)
            Next
            Sleep(500)
            getdrives()
            ProgressOff()
        Case $msg = $Button5
            getdrives()
    Case Else
        ;
    EndSelect
WEnd
Exit
Func getdrives()
;GUICtrlSetData ( $List1, "" )
$drives = DriveGetDrive ( "ALL" )
$drivelist = ""
For $i = 1 to $drives[0]
    $drivelist = $drivelist & "|" & $drives[$i]
Next
GUICtrlSetData ( $List1, $drivelist )
GUISetState(@SW_SHOW)
EndFunc

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,258
    • View Profile
    • Coding Snacks by Lanux128
    • Read more about this member.
    • Donate to Member
Re: IDEA: Simple GUI to manage virtual drives
« Reply #1 on: December 20, 2006, 12:32:13 AM »
two programs come to my mind: VirDir Manager & Virtual Subst.. :)

johnfdeluca

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 81
    • View Profile
    • Donate to Member
Re: IDEA: Simple GUI to manage virtual drives
« Reply #2 on: December 20, 2006, 10:14:59 AM »
Collaboration is a great thing.  Thanks so much for pointing these out.  They both seem spot-on for what I need. 

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,258
    • View Profile
    • Coding Snacks by Lanux128
    • Read more about this member.
    • Donate to Member
Re: IDEA: Simple GUI to manage virtual drives
« Reply #3 on: December 20, 2006, 09:15:02 PM »
you're welcome.. as the cliché goes, why re-invent the wheel? :)