ranhalt Posted December 24, 2009 Posted December 24, 2009 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!
funkey Posted December 24, 2009 Posted December 24, 2009 (edited) Do it with DOS _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 ;==>_UnMapDirectoryEdit: 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)) EndFuncEdit2: This works too!_MapDirectory('L:', '.') ;workingdir _MapDirectory('M:', '..') ;parent directory from workingdir Edited December 24, 2009 by funkey Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning.
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