JonCross Posted November 7, 2007 Posted November 7, 2007 I am trying to create an easy way for my users to map to their home directory from a computer that is not logged in as them. The dos command that I am using is: CODEC:\>net use Z: \\app-67-server05\users\USERNAME PASSWORD /user:67-nis\USERNAME The AutoIT Code I have been playing with looks like: $Question = Msgbox (4, "Map Home Dive", "Would you like to map your home dirive to this computer?") If $Question = 7 Then MsgBox(0, "System", "OK. Bye!") Exit EndIf $username = InputBox ("User Name", "Please enter your username.") $Password = InputBox ("Password", "Please Enter Your Password.", "", "$") Run(@ComSpec & " /c " & 'net use Z: \\app-67-server05\users\'& $username & $password,' /user:67-nis\'& $username , "", @SW_HIDE) msgbox (0, "H Drive Mapped", "Your H Drive has been Maped") Any Suggestions as to how i could get this script to work? Thanks, JonCross
Joon Posted November 7, 2007 Posted November 7, 2007 DriveMapAdd("Z:", "\\app-67-server05\users\" & $username, 0, "/user:67-nis\" & $username, $password)
Klaatu Posted November 7, 2007 Posted November 7, 2007 Or, if you want to stick with code basically like you're using: Run(@ComSpec & " /c " & 'net use Z: \\app-67-server05\users\'& $username & ' ' & $password,' /user:67-nis\'& $username , "", @SW_HIDE) should work. Looks like you're only problem was not putting a space between the username and password. My Projects:DebugIt - Debug your AutoIt scripts with DebugIt!
JonCross Posted November 7, 2007 Author Posted November 7, 2007 Thanks I got the mapping part down, but now I cant figure how to get this script to skip an if statement. $question = Msgbox (3, "Home Dive", "If you want to connect your Home Drive Click yes. If you want to close your Home Drive Click No.") If $question = 2 Then MsgBox(64, "Bye..", "OK. Bye!") Exit elseif $question = 7 Then $Close = Drivemapdel ("Z:") elseif $question = 6 Then $username = InputBox ("User Name", "Please enter your username.") $Password = InputBox ("Password", "Please Enter Your Password.", "", "$") $open = DriveMapAdd("Z:", "\\app-67-server05\users\"& $username, 0,"" & $username, $password) Endif if $close = 1 Then Msgbox (0, "Disconnected", "Your Home Drive has been Disconnected") exit elseif $close = 0 Then msgbox (0, "Failure:", "The disconnection was unsuccessful.") exit endif if $open = 1 Then msgbox (0, "Connected", "Your Home Drive has been Connected") Exit elseif $open = 0 Then msgbox (0, "Try Again", "Your drive did not connect please try again.") exit Endif I know I am doing something wrong. I can complete a No and a Cancel command, but i get stuck once i click yes. any ideas? Thanks
JamesDover Posted November 7, 2007 Posted November 7, 2007 $Question = Msgbox (4, "Map Home Dive", "Would you like to map your home dirive to this computer?")Might want to check your spell checker.
JonCross Posted November 7, 2007 Author Posted November 7, 2007 $Question = Msgbox (4, "Map Home Dive", "Would you like to map your home dirive to this computer?")Might want to check your spell checker. Thanks, I would have sent it out like that too.
Joon Posted November 7, 2007 Posted November 7, 2007 $question = MsgBox(3, "Home Dive", "If you want to connect your Home Drive Click yes. If you want to close your Home Drive Click No.") If $question = 2 Then MsgBox(64, "Bye..", "OK. Bye!") Exit ElseIf $question = 7 Then $Close = DriveMapDel("Z:") If $Close = 1 Then MsgBox(0, "Disconnected", "Your Home Drive has been Disconnected") Exit ElseIf $Close = 0 Then MsgBox(0, "Failure:", "The disconnection was unsuccessful.") Exit EndIf ElseIf $question = 6 Then $username = InputBox("User Name", "Please enter your username.") $Password = InputBox("Password", "Please Enter Your Password.", "", "$") $open = DriveMapAdd("Z:", "\\app-67-server05\users\" & $username, 0, "" & $username, $Password) If $open = 1 Then MsgBox(0, "Connected", "Your Home Drive has been Connected") Exit ElseIf $open = 0 Then MsgBox(0, "Try Again", "Your drive did not connect please try again.") Exit EndIf EndIf
JonCross Posted November 7, 2007 Author Posted November 7, 2007 Thanks... That makes a lot of sense. I guess I have just been looking at it too long.
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