Sign in to follow this  
Followers 0
saywell

Subst

3 posts in this topic

The DOS subst command lets you use a folder as a designated drive letter. Is this possible in AotoIT?

Also, can drive letters be changed.

I need to re-allocate a CD drive to another letter, then subst a folder so it appears to be the original CD cdive letter. This is to work around some software that can ONLY look at the CD drive for data input.

If anyone could point me in the right direction, I'd be grateful.

Thanks,

William

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This is an example to delete and recreate driveletters:

$KERNEL32 = DllOpen("Kernel32.dll")

$szVolumeMountPoint = "E:\" ; The Drive Letter with Backslash
$szVolumeName = _GetVolumeNameForVolumeMountPoint($szVolumeMountPoint) ; get the VolumeName, needed to recreate it afterwards
If Not @error Then
    MsgBox(0, 'VolumeName', "Dirveletter " & $szVolumeMountPoint & " is connected with volume:" & @CRLF & $szVolumeName)
    $success = _DeleteVolumeMountPoint($szVolumeMountPoint)
    If $success Then
        MsgBox(0, 'Delte Colume', "The driveletter is removed. It will be recreated when you click OK")
        $success = _SetVolumeMountPoint($szVolumeMountPoint, $szVolumeName)
        If $success Then 
            MsgBox(0, '', "The driveletter is recreated.")
        Else
            MsgBox(0, '', "Could not recreate the driveletter.")
        EndIf
    Else
        MsgBox(0, '', "Could not remove the driveletter " & $szVolumeMountPoint )
    EndIf
Else
    MsgBox(0, '', "Could not get the VolumeName for " & $szVolumeMountPoint)
EndIf

Func _GetVolumeNameForVolumeMountPoint($szVolumeMountPoint)
    ; Prog@ndy
    Local $pszVolumeName = DllStructCreate("wchar[51]")
    Local $success = DllCall($KERNEL32, "int", "GetVolumeNameForVolumeMountPointW", "wstr", $szVolumeMountPoint, "ptr", DllStructGetPtr($pszVolumeName), "dword", 51)
    If @error Then Return SetError(2,0,"")
    Return SetError($success[0]=0,0,String(DllStructGetData($pszVolumeName,1)))
EndFunc

Func _DeleteVolumeMountPoint($szVolumeMountPoint)
    ; Prog@ndy
    Local $success = DllCall($KERNEL32, "int", "DeleteVolumeMountPointW", "wstr", $szVolumeMountPoint)
    If @error Then Return SetError(2,0,0)
    Return SetError($success[0]=0,0,$success[0])
EndFunc

Func _SetVolumeMountPoint($szVolumeMountPoint, $szVolumeName)
    ; Prog@ndy
    Local $success = DllCall($KERNEL32, "int", "SetVolumeMountPointW", "wstr", $szVolumeMountPoint, "wstr", $szVolumeName)
    If @error Then Return SetError(2,0,0)
    Return SetError($success[0]=0,0,$success[0])
EndFunc

Those functions only work with real hardware. (so those are meant to remove and recreate your CD-Drive)

The SUBST-command can be simulated with these funcs: http://www.autoit.de/index.php?page=Thread...69362#post69362 This is the translated UDF-info:

;==================================================================================================
; Function Name:   _PartialDrive($sDeviceName=-1, $sTargetPath=-1, $iDelete=0)
; Description:: Creates or removes a Virtual Drive. The Drive will
;                 be romved automatically on shutdown.
; Parameter(s): $sDeviceName        Driveletter of the Drive to create / delete
;                                  -1   first free Driveletter (default)
;                 $sTargetPath      Path to link the driveletter to, 
                                                     -1= Create: link to @MyDocumentsDir (default)
;                                                       Delete: the path connected with the driveletter will be found automatically.
;    optional:  $iDelete            0=Creation (default); 1=Deletion of the Drive
; Return Value(s): Success          Driveletter of the created/deleted virtual Drive
;                  Fehler           0   @error=1 given driveletter already existing (only when creating)
;                                      @error=2 no free driveletter available (only when creating)
;                                      @error=3 no valid path to link to
;                                      @error=4 Action failed
;                                      @error=5 no valid drive to delete
; Author(s):       BugFix (bugfix@autoit.de)
; Modified:     Prog@ndy (translated info)
;==================================================================================================
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Many thanks (if belatedly)!

William

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