Jump to content

DriveMapAdd() @error not reporting


 Share

Recommended Posts

Hi, i have this script that attempts to map a network drive useing DriveMapadd(), iam trying to make it so if the command fails i will get a message as to why, by reading @Error the only problem is @error is never set it always returns 0, weather the command fails or not, any ideas?

Here's the Script

CODE

$drvcall = DriveMapAdd("", "\\192.168.100.1\ADMIN$", 0, "Username", "Psssword")

Msgbox(0,"syscall",$drvcall)

Msgbox(0,"@error",@error)

if $drvcall = 1 then

MSgbox(0,"Mapped","Drive Mapped")

else

Switch @error

case "1"

MSgbox(0,"error","undefined Error")

Msgbox(0,"API Error Code",@extended)

case "2"

MSgbox(0,"error","access denied Error")

Case "3"

MSgbox(0,"error","Device already mapped")

Case "4"

MSgbox(0,"error","Invalid Device NAme")

Case "5"

MSgbox(0,"error","Invalid remote share")

Case "6"

MSgbox(0,"error","Invalid Password")

EndSwitch

EndIf

Link to comment
Share on other sites

Hi, i have this script that attempts to map a network drive useing DriveMapadd(), iam trying to make it so if the command fails i will get a message as to why, by reading @Error the only problem is @error is never set it always returns 0, weather the command fails or not, any ideas?

Here's the Script

CODE

$drvcall = DriveMapAdd("", "\\192.168.100.1\ADMIN$", 0, "Username", "Psssword")

Msgbox(0,"syscall",$drvcall)

Msgbox(0,"@error",@error)

if $drvcall = 1 then

MSgbox(0,"Mapped","Drive Mapped")

else

Switch @error

case "1"

MSgbox(0,"error","undefined Error")

Msgbox(0,"API Error Code",@extended)

case "2"

MSgbox(0,"error","access denied Error")

Case "3"

MSgbox(0,"error","Device already mapped")

Case "4"

MSgbox(0,"error","Invalid Device NAme")

Case "5"

MSgbox(0,"error","Invalid remote share")

Case "6"

MSgbox(0,"error","Invalid Password")

EndSwitch

EndIf

Hi,

try this:

DriveMapAdd("", "\\192.168.100.1\ADMIN$", 0, "Username", "Psssword")

Switch @error
case 0
    MSgbox(0,"Mapped","Drive Mapped")
case 1
    MSgbox(0,"error","undefined Error")
    Msgbox(0,"API Error Code",@extended)
case 2
    MSgbox(0,"error","access denied Error")
Case 3
    MSgbox(0,"error","Device already mapped")
Case 4
    MSgbox(0,"error","Invalid Device NAme")
Case 5
    MSgbox(0,"error","Invalid remote share")
Case 6
    MSgbox(0,"error","Invalid Password")
EndSwitch

;-))

Stefan

Link to comment
Share on other sites

yeah, the script works fine, but everytime there is an error, @error always seems to return 1, even if its ment to return 5 for if the share isnt found or 6 if the password is wrong.

Hi,

just use DriveMapAdd("*", "\\192.168.100.1\ADMIN$", 0, "Username", "Psssword") or

DriveMapAdd("x:", "\\192.168.100.1\ADMIN$", 0, "Username", "Psssword")

;-))

Stefan

Link to comment
Share on other sites

Hi,

just use DriveMapAdd("*", "\\192.168.100.1\ADMIN$", 0, "Username", "Psssword") or

DriveMapAdd("x:", "\\192.168.100.1\ADMIN$", 0, "Username", "Psssword")

;-))

Stefan

That was not what i was asking, i understand how to use that function, but i cant get any @error codes out of it.

Link to comment
Share on other sites

Hi,

i used

$drvcall = DriveMapAdd("", "\\192.168.100.1\ADMIN$", 0, "Username", "Psssword")

@error always return 1

if i use

$drvcall = DriveMapAdd("*", "\\192.168.100.1\ADMIN$", 0, "Username", "Psssword")

then i get other errorcodes, e.g. 5 Invalid remote share

;-))

Stefan

Edited by 99ojo
Link to comment
Share on other sites

@uplink477,

In your first post you are testing for the @Error of your

Msgbox(0,"syscall",$drvcall)
call.

This will always be 0.

Either use what 99ojo posted in the 2nd post, or modify your code like this to preserve the @Error of DriveMapAdd().

$drvcall = DriveMapAdd("", "\\192.168.100.1\ADMIN$", 0, "Username", "Psssword")
$drvCallError = @Error
Msgbox(0,"syscall",$drvcall)
Msgbox(0,"@error",$drvCallError)

if $drvcall = 1 then
MSgbox(0,"Mapped","Drive Mapped")
else
Switch $drvCallError
case "1"
MSgbox(0,"error","undefined Error")
Msgbox(0,"API Error Code",@extended)
case "2"
MSgbox(0,"error","access denied Error")
Case "3"
MSgbox(0,"error","Device already mapped")
Case "4"
MSgbox(0,"error","Invalid Device NAme")
Case "5"
MSgbox(0,"error","Invalid remote share")
Case "6"
MSgbox(0,"error","Invalid Password")
EndSwitch
EndIf
Edited by ResNullius
Link to comment
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
 Share

  • Recently Browsing   0 members

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