Jump to content

New user


Recommended Posts

Hello,

I'm new to writing scripts and new to autoit, as in only picked it up a couple of hours ago.

I've wrote a script to map some drives when a user is connected via VPN, I would like to display a message that if they haven't been mapped it displays an error and if there are successful they receive a welcome message.

I can get the arguements to work indivually but not together, this is the script

$user = InputBox("Username","Please enter your username")
$pass = InputBox("Password","Please enter your password","","*")

; AutoIt-Version
DriveMapDel("Y:")
DriveMapDel("U:")
DriveMapAdd( "Y:", "\\172.17.2.2\shared" ,0, "company\" & $user , $pass )
DriveMapAdd( "U:", "\\172.17.2.2\home" ,0, "company\" & $user , $pass )
Sleep(5000);5 seconds
DriveMapGet("Y:"And"U:")
if @error = 1 then
    MsgBox(46,"COMPANY NAME","There has been a problem") 
Else
    MsgBox(64,"COMPANY NAME","Welcome to the Network")
EndIf

Any help would be appreicated.

Thanks

Edited by illwizard
Link to comment
Share on other sites

  • Moderators

illwizard,

Welcome to the AutoIt forum. :mellow:

It looks like you have syntax problems with your DriveMapGet line - you cannot use multiple drive letters. :party:

Try something like this:

$user = InputBox("Username","Please enter your username")
$pass = InputBox("Password","Please enter your password","","*")

; AutoIt-Version
DriveMapDel("Y:")
DriveMapDel("U:")
DriveMapAdd( "Y:", "\\172.17.2.2\shared" ,0, "company\" & $user , $pass )
DriveMapAdd( "U:", "\\172.17.2.2\home" ,0, "company\" & $user , $pass )
Sleep(5000);5 seconds
; Set error flag to 0
$iError = 0
DriveMapGet("Y:")
; Save error state for this drive
$iError = @error
DriveMapGet("U:")
; Save error state for this drive
$iError = @error
; Now see if an error occurred above
if $iError > 0 then
    MsgBox(46,"COMPANY NAME","There has been a problem")
Else
    MsgBox(64,"COMPANY NAME","Welcome to the Network")
EndIf

I hope that helps. :P

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Running something similar under SciTE I get the following errors:

C:\Data\DevelopmentAutoIt\DrivesExp\Test1.au3 (6) : ==> Missing separator character after keywRunningord.:

DriveMapGet("Y:"And"Z:")

DriveMapGet("Y:"And^ ERROR

[\quote]

... it doesn't seem to like the And in DriveMapGet (although I'm new to this myself!). Looking at the docs you'll have to check for each drive separately?

ATB

Prune

Link to comment
Share on other sites

Hi Melba,

I thought that might be the case, but was unsure how to tie it together as one, many thanks for taking a look. I have just applied this and the mapping of drives goes through fine and displays the message box "welcome to the network".

However if for example I removed my network cable and run the exe, obviously this would have the same effect if the user wasn't connected to the VPN. It does not display the "There has been a problem"?

Any ideas?

Link to comment
Share on other sites

  • Moderators

illwizard,

Yup - I am afraid to say it is an error on your part. :P However, to keep you company, I can also see where my original code could fail as well. :mellow:

See if you can spot the changes: :party:

$user = InputBox("Username","Please enter your username")
$pass = InputBox("Password","Please enter your password","","*")

; AutoIt-Version
DriveMapDel("Y:")
DriveMapDel("U:")
DriveMapAdd( "Y:", "\\172.17.2.2\shared" ,0, "company\" & $user , $pass )
DriveMapAdd( "U:", "\\172.17.2.2\home" ,0, "company\" & $user , $pass )
Sleep(5000);5 seconds
; Set error flag to 0
$iError = 0
DriveMapGet("Y:")
; Save error state after checking this drive
$iError += @error
DriveMapGet("U:")
; Save error state after checking this drive
$iError += @error
; Now see if an error occurred above
if $iError > 0 then
    MsgBox(64,"COMPANY NAME","There has been a problem")
Else
    MsgBox(64,"COMPANY NAME","Welcome to the Network")
EndIf

If you cannot see them:

Yours first. You had 46 and not 64 as the first MsgBox parameter. This is not valid - therefore no MsgBox!

Now mine. I did not sum the errors, so originally if the first comand failed and the second succeeded we would not get an error. Now we do!

I think we will call that one a draw! :party:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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