JimC Posted April 4, 2012 Posted April 4, 2012 i am trying to write a small function to return a user network home drive, but my results are returned as 0. I would like to return the value of the home drive or exit with an error. Thansk in for your assistance. #NoTrayIcon ;*************************************** ; ; Network HOME Drive Tool ; ;*************************************** #include <Process.au3> ; Variables $numofDrives = "" $home = "" $homedrive=gethomedrive($home) msgbox(1, "Home Drive Results", $homedrive) Func gethomedrive($home) $user=@UserName $allDrives = "" $allDrives = DriveGetDrive( "network" ) if $allDrives = "" then msgbox(1,"Home Drive Search Results", "No Network Drives Found !!! Please contact local Technical Support for assistance!!!!") else $numofDrives=$allDrives[0] For $i = 1 to $numofDrives Step 1 $curDriveLtr = $allDrives[$i] $curDrivePath = DriveMapGet($curDriveLtr) $result=StringInStr($curDrivePath, $user) msgbox(1, "Result", $result) If $result > 0 Then $home = (@UserName & $curDrivePath & ' '&$curDriveLtr) msgbox(1, "HOMEDRIVE", $home) Return EndIf Next EndIf msgbox(1,"Home Drive Search", "No Home Drive Found !!! Please contact local Technical Support for assistance!!!!") EndFunc Exit
Bert Posted April 4, 2012 Posted April 4, 2012 (edited) Here you are: #NoTrayIcon ;*************************************** ; ; Network HOME Drive Tool ; ;*************************************** #include <Process.au3> $numofDrives = "" $home = 0 gethomedrive() msgbox(1, "HOMEDRIVE test", $home) Func gethomedrive() $user=@UserName $allDrives = DriveGetDrive( "network" ) if $allDrives = "" then _nodrive() else $numofDrives=$allDrives[0] For $i = 1 to $numofDrives Step 1 $curDriveLtr = $allDrives[$i] $curDrivePath = DriveMapGet($curDriveLtr) $result=StringInStr($curDrivePath, $user) If $result > 0 Then $home = @UserName & $curDrivePath & @CRLF& "Drive letter: "& $curDriveLtr&"" Return $home EndIf Next EndIf EndFunc Exit Func _nodrive() msgbox(1,"Home Drive Search Results", "No Network Drives Found !!! "& @CRLF & "Please contact local Technical Support for assistance!!!!") EndFunc Edited April 4, 2012 by MPH The Vollatran project My blog: http://www.vollysinterestingshit.com/
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now