Jump to content
behdadsoft

DriveMapAdd don't work

Recommended Posts

behdadsoft
Posted (edited)

Hi.

I want create a Map drive by autoit, but it always return @error = 0 and can't create Map Drive. 

At the first, I shared my drive and then with below code i tried to Add Map Drive. but it can't create.

DriveMapAdd("*", "\\" & @ComputerName & "\shared")

NOTE: I used Windows 10.

Edited by behdadsoft

Share this post


Link to post
Share on other sites
orbs
Posted (edited)

that works for me.

i advise you to verify that Windows does accept the share name you designate to it (because by default, Windows would share your folder by the name of the folder). to verify that, open the "Computer Management" (compmgmt.msc) and navigate to the "Shares" list.

of course, permissions may also be an issue.

one more thing to check: if you do not specify a drive letter, Windows may assign you a drive letter already in use by a removable device (e.g. USB drive). try to specify a drive letter that you know for a fact that is available.

 

Edited by orbs

Share this post


Link to post
Share on other sites
behdadsoft

There is my shared folder in "Shares" list.

so for permissions, do you have any idea?

 

Share this post


Link to post
Share on other sites
orbs
Posted (edited)

first i advise you check the return value of your function, like this:

Global $xRet = DriveMapAdd("*", "\\" & @ComputerName & "\shared")
ConsoleWrite('return value = ' & $xRet & @CRLF & '@error value = ' & @error & @CRLF)

if you claim @error = 0, then i truly wonder what is the return value.

i will check on Windows 10 shortly (i'm on Windows 7).

 

Edited by orbs

Share this post


Link to post
Share on other sites
behdadsoft

It return Empty String.

Share this post


Link to post
Share on other sites
orbs

works as expected for me on Windows 10.

retro-check:

you get a return value of empty string and @error value of 0?

your share appears on the "Shares" list with its name set to the name you specified ("shared")?

Share this post


Link to post
Share on other sites
behdadsoft
Posted (edited)
Quote

you get a return value of empty string and @error value of 0?

Yes.

Quote

 

your share appears on the "Shares" list with its name set to the name you specified ("shared")?

 

Yes.

I use Windows 10 x64.

Edited by behdadsoft

Share this post


Link to post
Share on other sites
orbs

1) what if you set a specific available drive letter (e.g. "Z:" instead of "*")? same return and @error values?

2) shot in the dark: disable your anti-virus and recheck.

 

Share this post


Link to post
Share on other sites
behdadsoft
Quote

1) what if you set a specific available drive letter (e.g. "Z:" instead of "*")? same return and @error values?

Return 0 and 0. but when i run it again, error code is 3 and return 0. while there is no Map Drives.

Quote

2) shot in the dark: disable your anti-virus and recheck.

I do that, but nothing changed.

Share this post


Link to post
Share on other sites
behdadsoft

Now after changed "*" to "Z:", it give me an error 0 and made Different Map drives, but they don't show in My Computer.

I test this code on two PC with Windows 10 X64, but both have same result.

Share this post


Link to post
Share on other sites
orbs
1 minute ago, behdadsoft said:

made Different Map drives

what does that mean?

Share this post


Link to post
Share on other sites
behdadsoft
Posted (edited)

it make different drives.

first MsgBox give me @error, and second MsgBox give me return drive map.

$Map = DriveMapAdd("*", "\\" & @ComputerName & "\Shared")
MsgBox(0,"",@error)
MsgBox(0,"",$Map)

 

00.png

1.png

Edited by behdadsoft

Share this post


Link to post
Share on other sites
orbs

and P: does not appear in "My Computer"? what about cmd "dir P:"?

Share this post


Link to post
Share on other sites
behdadsoft

The system cannot find the path specified.

Share this post


Link to post
Share on other sites
behdadsoft
Posted (edited)

i don't know what happen. now it work fine and made a Map Drive. but i don't know why @error is 0.

this result is same on both PCs.

Edited by behdadsoft

Share this post


Link to post
Share on other sites
orbs

@error 0 means OK, no error.

  • Like 1

Share this post


Link to post
Share on other sites
behdadsoft
Posted (edited)

I found what is the problem.

problem is relate to this part of my code:

#RequireAdmin

when i removed it, my code work very well.

Quote

 

@error 0 means OK, no error.

 

According to Help:

002.png

 

thank you for your helps.

+1:)

Edited by behdadsoft

Share this post


Link to post
Share on other sites
Jos
Posted (edited)

Please do not report posts when you think there is a bug. 
So for starters: You never mentioned you where running this script in Admin mode, which is quite essential to mention when reporting issues.
Are you getting a UAC prompt and if so are you using the same account?
Please explain why you think there is a bug in AutoIt in stead of your script and exactly describe what you are doing!

Jos 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
jdelaney
Posted (edited)

Several reasons a drive won't get mapped.  If your current user is a local account, you'll need to pass in credentials to map to a remote computer.  If you are using a network account, but running elevated, you will also need to pass in credentials.  If you are using a network account, and not running elevated, windows automagically use your login credentials to map a drive.  So if you have the permissions on the server you are mapping you will automatically succeed in the mapping.

Other reasons a drive will failed to get mapped is if there is already another mapped drive to that server.  There are workarounds for this, you can instead map by the IP.

 

I'd suggest you attempt to pass in credentials to the function, with a user that has the rights on the target machine.

Edited by jdelaney
  • Like 1

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
behdadsoft

Thanks. :)

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

×