Jump to content

Recommended Posts

Posted

I have a script that will have to temporarily map a network drive to share, copy a file and then disconnect. Since this could be run on any number of users I have to guess at their mappings. DriveMapAdd will let me use the '*' for the next available drive, but then I need to know what that drive is. After a successful mapping, both @error and @extended return '0' as values.

CODE
DriveMapAdd("X:", "\\myserver\stuff")

$MAPDRV=@extended

MsgBox(4096,@error, "Drive mapped as: "&$MAPDRV)

I'm running version 3.2.12.0. Anyone have any ideas why this is giving me empty values?

Peace

--Darktan

Posted

I have a script that will have to temporarily map a network drive to share, copy a file and then disconnect. Since this could be run on any number of users I have to guess at their mappings. DriveMapAdd will let me use the '*' for the next available drive, but then I need to know what that drive is. After a successful mapping, both @error and @extended return '0' as values.

DriveMapAdd("X:", "\\myserver\stuff")
$MAPDRV=@extended
MsgBox(4096,@error, "Drive mapped as: "&$MAPDRV)

I'm running version 3.2.12.0. Anyone have any ideas why this is giving me empty values?

Peace

--Darktan

First, if you want DriveMapAdd() to pick the drive letter, don't specify "X:".

Second, you need to capture the return value to a variable.

$sMapping = DriveMapAdd("*", "\\myserver\stuff")
$iErrSav = @error
$iExtSav = @extended
MsgBox(4096,"Results", "@error = " & $iErrSav & @CRLF & _
        "@extended = " & $iExtSav & @CRLF & _
        "Drive mapped as: " & $sMapping)

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

First, if you want DriveMapAdd() to pick the drive letter, don't specify "X:".

Second, you need to capture the return value to a variable.

$sMapping = DriveMapAdd("*", "\\myserver\stuff")
$iErrSav = @error
$iExtSav = @extended
MsgBox(4096,"Results", "@error = " & $iErrSav & @CRLF & _
        "@extended = " & $iExtSav & @CRLF & _
        "Drive mapped as: " & $sMapping)

:)

Thanks PsaltyDS. That did it. I needed the $sMapping to get it to work. And I have the '*'. That was a miss copy. The gas station didn't have my Mountain Dew this morning. How rude.

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