Jump to content

Recommended Posts

Posted

Im working for an IT business and I am trying to make a GUI that accepts a username and password, and then launches a .bat script.

What this script does, is maps network drives for users at the company when they are remote (Such as accessing from a home computer) so first the user needs to be connected to our VPN.

Once they have this I have made a .bat script that contains commands to map a network drive, pretty simple stuff. But since they are on a computer at home, you must type in your user name and password to authenticate with our servers.

So what I would like to do, is make an AutoIt script that lets the users put in their user name and password, and basically hit a "go" button that runs these command prompt commands, and whenever the command prompt asks for the user name and password, it puts this information in. Is this possible? I dont know if you can check for specific phrases while the script is running.

thanks for looking and I hope this was not too confusing. I have the GUI set up how I like but it currently just does not do anything, haha

Posted

Sorry I didnt see an edit button... But basically this is what I have so far (sorry i dont know much about the language, im trying to read up on it a bit though)

but I think I declared

GUICtrlCreateLabel("User Name", 10, 5, 30)

$TITLE = GUICtrlCreateInput("", 10, 20, 250, 20)

GUICtrlCreateLabel("Password", 10, 45, 75)

$PASS = GUICtrlCreateInput("", 10, 65, 250, 20)

incorrectly, or using them incorrectly.

And once those are filled in I want the code to run

Case $msg = $okbutton

MsgBox(0, "Launching", "Please wait...")

$CmdLine[0] = "net use I: \\server\directory\$TITLE /user:itt\$TITLE $PASS"

But Im confused about running command prompt lines. Im sorry for me being a bit of a newb, but I would love any help that I can get, thanks!

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $filemenu, $fileitem, $recentfilesmenu, $separator1
    Local $exititem, $helpmenu, $aboutitem, $okbutton, $cancelbutton
    Local $msg, $file
    Local $TITLE, $PASS
    #forceref $separator1

    GUICreate("GUI menu", 300, 200)

    $filemenu = GUICtrlCreateMenu("File")
    $fileitem = GUICtrlCreateMenuItem("Open...", $filemenu)
    $recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu)
    $separator1 = GUICtrlCreateMenuItem("", $filemenu)
    $exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
    $helpmenu = GUICtrlCreateMenu("?")
    $aboutitem = GUICtrlCreateMenuItem("About", $helpmenu)
    GUICtrlCreateLabel("User Name", 10, 5, 30)
    $TITLE = GUICtrlCreateInput("", 10, 20, 250, 20)
    GUICtrlCreateLabel("Password", 10, 45, 75)
    $PASS = GUICtrlCreateInput("", 10, 65, 250, 20)

    $okbutton = GUICtrlCreateButton("Launch", 50, 130, 70, 20)

    $cancelbutton = GUICtrlCreateButton("Cancel", 180, 130, 70, 20)

    GUISetState()

    While 1
        $msg = GUIGetMsg()


        Select
            Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton
                ExitLoop

            Case $msg = $fileitem
                $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
                If @error <> 1 Then GUICtrlCreateMenuItem($file, $recentfilesmenu)

            Case $msg = $exititem
                ExitLoop

            Case $msg = $okbutton
                MsgBox(0, "Launching", "Please wait...")
                $CmdLine[] = "net use I: \\server\directory\$TITLE /user:itt\$TITLE $PASS"
            Case $msg = $aboutitem
                MsgBox(0, "About", "GUI Menu Test")
        EndSelect
    WEnd

    GUIDelete()

    Exit
EndFunc   ;==>_Main
Posted (edited)

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $filemenu, $fileitem, $recentfilesmenu, $separator1
    Local $exititem, $helpmenu, $aboutitem, $okbutton, $cancelbutton
    Local $msg, $file
    Local $TITLE, $PASS
    #forceref $separator1

    GUICreate("GUI menu", 300, 200)

    $filemenu = GUICtrlCreateMenu("File")
    $fileitem = GUICtrlCreateMenuItem("Open...", $filemenu)
    $recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu)
    $separator1 = GUICtrlCreateMenuItem("", $filemenu)
    $exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
    $helpmenu = GUICtrlCreateMenu("?")
    $aboutitem = GUICtrlCreateMenuItem("About", $helpmenu)
    GUICtrlCreateLabel("User Name", 10, 5, 30)
    $TITLE = GUICtrlCreateInput("", 10, 20, 250, 20)
    GUICtrlCreateLabel("Password", 10, 45, 75)
    $PASS = GUICtrlCreateInput("", 10, 65, 250, 20)

    $okbutton = GUICtrlCreateButton("Launch", 50, 130, 70, 20)

    $cancelbutton = GUICtrlCreateButton("Cancel", 180, 130, 70, 20)

    GUISetState()

    While 1
        $msg = GUIGetMsg()


        Select
            Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton
                ExitLoop

            Case $msg = $fileitem
                $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
                If @error <> 1 Then GUICtrlCreateMenuItem($file, $recentfilesmenu)

            Case $msg = $exititem
                ExitLoop

            Case $msg = $okbutton
                Local $TITLE = "title"
                Local $PASSWORD = GUICtrlRead($PASS)
                RunWait(@ComSpec & " /C " & "net use I: \\server\directory\" & $TITLE & "/user:itt\" & $TITLE & $PASSWORD, "", @SW_SHOW)
            Case $msg = $aboutitem
                MsgBox(0, "About", "GUI Menu Test")
        EndSelect
    WEnd

    GUIDelete()

    Exit
EndFunc   ;==>_Main

use @SW_SHIDE to make command prompt invisible

Edited by Godless

_____________________________________________________________________________

Posted

awesome, no errors. The command prompt pops up for a split second.

But it seems that it goes through, but does not work yet.

in RunWait(@ComSpec & " /C "

what does the /C accomplish?

thanks for the quick reply

Posted (edited)

" /c" required to run DOS commands, and these symbols not puts into command prompt

Edited by Godless

_____________________________________________________________________________

Posted (edited)

great got it to work!

RunWait(@ComSpec & " /C " & "net use I: \\server\directory\" & $TITLE & "/user:itt\" & $TITLE & $PASSWORD, "", @SW_SHOW)

needed "net use I: \\server\directory\" & $TITLE &" " & "/user:itt\" & $TITLE &" " & $PASSWORD

for the spaces in the command, thanks!

Last question.

How can I set the password field to show up as * and not show the letters, I looked up the command, but did not see anything to do this, is it possible?

Edited by ICANSEEYOU7687
  • 2 months later...
Posted

Try this:

$PASS = GUICtrlCreateInput("", 10, 65, 250, 20,$ES_PASSWORD)

great got it to work!

RunWait(@ComSpec & " /C " & "net use I: \\server\directory\" & $TITLE & "/user:itt\" & $TITLE & $PASSWORD, "", @SW_SHOW)

needed "net use I: \\server\directory\" & $TITLE &" " & "/user:itt\" & $TITLE &" " & $PASSWORD

for the spaces in the command, thanks!

Last question.

How can I set the password field to show up as * and not show the letters, I looked up the command, but did not see anything to do this, is it possible?

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
×
×
  • Create New...