Jump to content

help with code


Recommended Posts

I am new to coding and want to make a simple app that asks for user name and password then maps a drive based on that info. I am close to getting it but i don't know enough to fix my app. Any help would be great.

; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("MyGUI", 392, 316,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Input_1 = "$user"

$Input_2 = "$pass"

$Input_1 = GuiCtrlCreateInput("username", 90, 110, 230, 30)

$Input_2 = GuiCtrlCreateInput("password", 90, 170, 230, 30)

$Button_3 = GuiCtrlCreateButton("Submit", 290, 260, 70, 30)

GUICtrlSetOnEvent($Button_3, "OKPressed")

GuiSetState()

While 1

Sleep(10)

WEnd

exit

Func OKPressed()

$MapReturn = DriveMapAdd("Z:", "\\server\folder", 1, "domain\$user", "$pass")

EndFunc

Func SpecialEvents()

If @GUI_CTRLID = $GUI_EVENT_CLOSE Then Exit

EndFunc

Link to comment
Share on other sites

doesnt give me any errors...

try this out And your putting your variables in quotes to make it simpler

#include <GuiConstants.au3>


GuiCreate("MyGUI", 392, 316,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$user = GuiCtrlCreateInput("username", 90, 110, 230, 30)
$pass = GuiCtrlCreateInput("password", 90, 170, 230, 30)
$Button_3 = GuiCtrlCreateButton("Submit", 290, 260, 70, 30)
Do
    $msg = GUIGetMsg ()
    Select

Case $msg = $Button_3
$MapReturn = DriveMapAdd("Z:", "\\server\folder", 1, "domain\" & $user, $pass)
EndSelect
Until $msg = $GUI_EVENT_CLOSE
Edited by thatsgreat2345
Link to comment
Share on other sites

Thanks for the help! I did a little editing but when i hit the submit, i get nothing?

#include <GuiConstants.au3>


GuiCreate("MyGUI", 392, 316,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$user = GuiCtrlCreateInput("username", 90, 110, 230, 30)
$pass = GuiCtrlCreateInput("password", 90, 170, 230, 30)
$Button_3 = GuiCtrlCreateButton("Submit", 290, 260, 70, 30)
Do
    $msg = GUIGetMsg ()
    Select

Case $msg = $Button_3
$MapReturn = DriveMapAdd("Z:", "\\computername\sharename", 0, "Domain\" & $user, $pass)
EndSelect
Until $msg = $GUI_EVENT_CLOSE
Link to comment
Share on other sites

that is because you didnt supply a computername drive sharenmae or domain u must do all that, cuz idk what ur comp name and all that stuff is u got to get it urself

nono i did i just took it out. It's strange, =/

If there is a delay in when it sends the request to connect to the share and the request for the username and password will it mess it up?

Link to comment
Share on other sites

WOW AM I STUPID OR WHAT I FORGOT THE GUICTRLREADS HOLY CRAP AHHAHA

#include <GuiConstants.au3>


GuiCreate("MyGUI", 392, 316,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$user = GuiCtrlCreateInput("username", 90, 110, 230, 30)
$pass = GuiCtrlCreateInput("password", 90, 170, 230, 30)
$Button_3 = GuiCtrlCreateButton("Submit", 290, 260, 70, 30)
Do
    $msg = GUIGetMsg ()
    Select

Case $msg = $Button_3
$MapReturn = DriveMapAdd("Z:", "\\computername\sharename", 0, "Domain\" & Guictrlread($user), Guictrlread($pass))
EndSelect
Until $msg = $GUI_EVENT_CLOSE
Edited by thatsgreat2345
Link to comment
Share on other sites

yes im pretty sure it can, try this it will give you a number and check the help file for the error your getting

When the function fails (returns 0) @error contains extended information:

1 = Undefined / Other error

2 = Access to the remote share was denied

3 = The device is already assigned

4 = Invalid device name

5 = Invalid remote share

6 = Invalid password

use the new one changed the msgbox to

MsgBox (0, 'Title', $MapReturn)

#include <GuiConstants.au3>


GuiCreate("MyGUI", 392, 316,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$user = GuiCtrlCreateInput("username", 90, 110, 230, 30)
$pass = GuiCtrlCreateInput("password", 90, 170, 230, 30)
$Button_3 = GuiCtrlCreateButton("Submit", 290, 260, 70, 30)
Do
    $msg = GUIGetMsg ()
    Select

Case $msg = $Button_3
$MapReturn = DriveMapAdd("Z:", "\\computername\sharename", 0, "Domain\" & Guictrlread($user), Guictrlread($pass))
if @error Then
    MsgBox(0, 'Title', $MapReturn)
    endif
EndSelect
Until $msg = $GUI_EVENT_CLOSE
Edited by thatsgreat2345
Link to comment
Share on other sites

could i ask what you are even trying to do?, add a drive?

correct. have it add a drive then open a app on that drive then wait till the app closes then disconnect

disconnect is not needed. I think it should be simple to make it pop open a exe after i get the mapped drive up

Edited by appleaday3k
Link to comment
Share on other sites

Any comments on this one?

#include <GuiConstants.au3>


GuiCreate("MyGUI", 392, 316,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$user = GuiCtrlCreateInput("username", 90, 110, 230, 30)
$pass = GuiCtrlCreateInput("password", 90, 170, 230, 30)
$Button_3 = GuiCtrlCreateButton("Submit", 290, 260, 70, 30)
Do
    $msg = GUIGetMsg ()
    Select
Case $msg = $Button_3
_RunDOS("net use Z: \\ComputerName\Share /USER:Domain\" & $user & \ & $pass)
EndSelect
Until $msg = $GUI_EVENT_CLOSE

I think i am close :o

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