Jump to content
Sign in to follow this  
JonCross

Net Use Command

Recommended Posts

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:

CODE
C:\>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

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

$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

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...