Jump to content

Recommended Posts

Posted

I have a script in a folder, but need to make the parent folder a network drive. If the layout is Folder1\Folder2\script, Folder2 is @workingdir, but I want to map Folder1 as M:. Usually, the syntax for going up dirs is ..\, so I was thinking instead of

DriveMapAdd("M:", @workingdir, 8)

using

DriveMapAdd("M:", "..\" & @workingdir, 8)

but it doesn't like that. i have to use relative paths, not literal since things could change. any suggestions? merry christmas!

Posted (edited)

Do it with DOS Posted Image

_MapDirectory('M:', @WorkingDir)
Sleep(10000)
_UnMapDirectory('M:')

Func _MapDirectory($Drive, $Path)
;funkey Dec, 24, 2009
$cmd = 'subst ' & $Drive & ' "' & $Path & '"'
Run(@ComSpec & " /c " & $cmd, "", @SW_HIDE)
EndFunc   ;==>_MapDirectory

Func _UnMapDirectory($Drive)
;funkey Dec, 24, 2009
$cmd = 'subst ' & $Drive & ' /D'
Run(@ComSpec & " /c " & $cmd, "", @SW_HIDE)
EndFunc   ;==>_UnMapDirectory

Edit: Sorry, you want this.

MsgBox(0, @WorkingDir, _GetParentDirectory(@WorkingDir, 1))
MsgBox(0, @WorkingDir, _GetParentDirectory(@WorkingDir))

Func _GetParentDirectory($Path, $BackSlash = 0)
;funkey Dec, 24, 2009
Return StringLeft($Path, StringInStr($Path, "\", 0, -1) - Not($BackSlash))
EndFunc

Edit2: This works too!

_MapDirectory('L:', '.') ;workingdir
_MapDirectory('M:', '..') ;parent directory from workingdir
Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

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
  • Recently Browsing   0 members

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