illwizard Posted June 9, 2010 Share Posted June 9, 2010 (edited) 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 June 9, 2010 by illwizard Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 9, 2010 Moderators Share Posted June 9, 2010 illwizard,Welcome to the AutoIt forum. It looks like you have syntax problems with your DriveMapGet line - you cannot use multiple drive letters. 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") EndIfI hope that helps. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
prunesquallor Posted June 9, 2010 Share Posted June 9, 2010 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 More sharing options...
illwizard Posted June 9, 2010 Author Share Posted June 9, 2010 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 More sharing options...
Moderators Melba23 Posted June 9, 2010 Moderators Share Posted June 9, 2010 illwizard, Yup - I am afraid to say it is an error on your part. However, to keep you company, I can also see where my original code could fail as well. See if you can spot the changes: $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! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
illwizard Posted June 9, 2010 Author Share Posted June 9, 2010 Ahhhhhh, I can explain my error! It was supposed to be 48, Exclamation-point icon and not 46! Whooops! By the way that all works great now! Thank you very much for your help! Link to comment Share on other sites More sharing options...
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