Hard DriveIn one of the comments on Providing User Feedback In AutoIt, Jim is wondering how you can map drives:

I was wondering though, can autoit make an executable that would setup a permanent drive map. Instead of a non-technical user mapping a drive, the executable file would setup a predefined mapped drive. That would be cool..
Thanks
Jim

Well, Jim, there are several different ways that you can map drives but two of the easiest are using a batch file or through AutoIt. Now I know that you can’t make a batch file into an executable but I thought that I would show you how todo this anyway.

Our Example

For this post, I want to use an example to help clarify these concepts. For our example, we would like to map drive letter T: to network share \\server\share.

Batch File

To map a drive in a batch file, simply use the net use command. So, for our example, we would use:

net use T: \\server\share

If you want the drive mapping to return each time you reboot, add the /persistent:yes option:

net use T: \\server\share /persistent:yes

AutoIt

In AutoIt, you use the DriveMapAdd command. Our example would look like this:

DriveMapAdd("T:","\\server\share")

To allow it to survive a reboot, add one more option:

DriveMapAdd("T:","\\server\share",8)

That’s all there is to it. You can then compile this into an executable and away you go!

Hope that answers your question, Jim

If you found this post useful, why don't you buy me a cup of coffee to show your gratitude?