Sign in to follow this  
Followers 0
saywell

Map local folder to drive

5 posts in this topic

Hi guys. A quick question about DriveMapAdd.

Is it possible to map a local folder eg C:\folder to a drive letter using this function - as DOS would do Subst X: C:\folder ?

If so, what is the syntax for it?

Thanks,

William

Share this post


Link to post
Share on other sites



Create a share for the folder and then use DriveMapAdd like:

DrivemapAdd("*", "\\" & @ComputerName & "\folder")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Create a share for the folder and then use DriveMapAdd like:

DrivemapAdd("*", "\\" & @ComputerName & "\folder")

Thanks, Water.

That works fine:

#Include <NetShare.au3>

$netshare = _Net_Share_ShareAdd ("","test",$STYPE_TEMPORARY,"C:\test")
$sFreeDrive = DrivemapAdd("*", "\\" & @ComputerName & "\test")
MsgBox (0,"Free", $sFreeDrive)
DriveMapDel ($sFreeDrive)

It will also allow me to remove my code that seeks the next free drive letter.

My concern here is that this function may be blocked if the user doesn't have enough privileges - or would this work in any circumstances where the DOS subst command would work from a batch file?

William

Edited by saywell

Share this post


Link to post
Share on other sites

My concern here is that this function may be blocked if the user doesn't have enough privileges - or would this work in any circumstances where the DOS subst command would work from a batch file?

I really don't know. Best bet would be to test it on a "normal" user.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Water,

I shall indeed test it on various machines here at work, but the problem is that it will be running from a CD sent to other hospitals, each with their own security policies.

I guess if it works on all the ones I test here, I'll have to give it a go with the recipients and hope I don't get too many howls of anguish back! And if I do, add a test for success in setting up the share, with a fail running a different method eg writing, running and deleting a batch file!

Thanks for your help.

William

[edit] - UPDATE

The first PC I tried it on, other than my own, failed! It was OK with a DOS Subst from a batch file, though, so I think the security problem is real. Well worth a try, though!

W.

Edited by saywell

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