Jump to content
Sign in to follow this  
saywell

Map local folder to drive

Recommended Posts

saywell

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
water

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

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
saywell

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
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
saywell

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  

×