Jump to content

Recommended Posts

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
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

Signature - my forum contributions:

  Reveal hidden contents

 

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

Signature - my forum contributions:

  Reveal hidden contents

 

Posted

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")?

Signature - my forum contributions:

  Reveal hidden contents

 

Posted (edited)
  Quote

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

Expand  

Yes.

  Quote

 

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

 

Expand  

Yes.

I use Windows 10 x64.

Edited by behdadsoft
Posted

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.

 

Signature - my forum contributions:

  Reveal hidden contents

 

Posted
  Quote

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

Expand  

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.

Expand  

I do that, but nothing changed.

Posted

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.

Posted
  On 8/11/2018 at 10:49 AM, behdadsoft said:

made Different Map drives

Expand  

what does that mean?

Signature - my forum contributions:

  Reveal hidden contents

 

Posted

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

Signature - my forum contributions:

  Reveal hidden contents

 

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
Posted

@error 0 means OK, no error.

Signature - my forum contributions:

  Reveal hidden contents

 

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.

 

Expand  

According to Help:

002.png

 

thank you for your helps.

+1:)

Edited by behdadsoft
  • Developers
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 etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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
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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...