mbiwpeoyc Posted February 9, 2006 Share Posted February 9, 2006 I'm the net admin for the company I work for. I'm trying to write an autoit script to do all the nitnoid annoying junk I have to do on machine builds. I can do all of it except I've been hitting my head against the wall trying to automate putting in the WEP key. The closest I've gotten to date is making something that instructs the users what to do and changes it's output based on what windows are open. However that's a little sloppy in my opinion and I'd seriously like to just have autoit do it all for me, no user interaction. Anyone else done this or have an idea on how to do it? I did try searching for it and came up with a couple non related discussions, some minor troubleshooting in other sections of the forums.. Thank you! Link to comment Share on other sites More sharing options...
skippynz Posted February 9, 2006 Share Posted February 9, 2006 I'm the net admin for the company I work for. I'm trying to write an autoit script to do all the nitnoid annoying junk I have to do on machine builds. I can do all of it except I've been hitting my head against the wall trying to automate putting in the WEP key. The closest I've gotten to date is making something that instructs the users what to do and changes it's output based on what windows are open. However that's a little sloppy in my opinion and I'd seriously like to just have autoit do it all for me, no user interaction. Anyone else done this or have an idea on how to do it?I did try searching for it and came up with a couple non related discussions, some minor troubleshooting in other sections of the forums..Thank you!i created a script that adds in a wireless profile for me - although its using wpa tkip encryption.it locks the keyboard access, then open network properties, wireless card, wireless profile and makes the changes there.let me know if that is the kinda thing you are after Link to comment Share on other sites More sharing options...
mbiwpeoyc Posted February 9, 2006 Author Share Posted February 9, 2006 i created a script that adds in a wireless profile for me - although its using wpa tkip encryption.it locks the keyboard access, then open network properties, wireless card, wireless profile and makes the changes there.let me know if that is the kinda thing you are afterThat sounds extremely close to what I want...shouldn't be hard for to change from wpa tkip to wep. Link to comment Share on other sites More sharing options...
skippynz Posted February 9, 2006 Share Posted February 9, 2006 That sounds extremely close to what I want...shouldn't be hard for to change from wpa tkip to wep.i just used window names and said to press what alt key corosponded to the button i wanted to press.if i could be bothered i think i would use control send on the windows..will post the code shortly. Link to comment Share on other sites More sharing options...
skippynz Posted February 9, 2006 Share Posted February 9, 2006 will post the code shortly. expandcollapse popupOpt("GUIOnEventMode", 1) AutoItSetOption("TrayIconDebug", 1) ; ---------------------------------------------------------------------------- ; checking for windows xp sp2 ; ---------------------------------------------------------------------------- #include <GUIConstants.au3> if @OSVersion = "WIN_XP" then $WINVER = "Windows XP" if @OSVersion = "WIN_2003" then $WINVER = "Windows 2003" if @OSVersion = "WIN_2000" then $WINVER = "Windows 2000" if @OSVersion = "WIN_NT4" then $WINVER = "Windows NT 4" if @OSVersion = "WIN_ME" then $WINVER = "Windows ME" if @OSVersion = "WIN_98" then $WINVER = "Windows 98" if @OSVersion = "WIN_95" then $WINVER = "Windows 95" if @OSVersion <> "WIN_XP" Then msgbox(0 , "Operating System and Service Pack Check", "This script only works on Windows XP Systems and your Operating System is " & $WINVER & " - Please contact the Helpdesk" ) Exit EndIf if @OSServicePack <> "Service Pack 2" Then MsgBox(16,"Operating System and Service Pack Check","The Wireless Profile setup will only run on Windows XP computers with Service Pack 2.") Exit EndIf ;~ -------------------------------------------------------------------------------------- ;~ checking for a program called ipass, which disables the wireless profile tab ;~ -------------------------------------------------------------------------------------- while ProcessExists ( "IPassConnectGUI.exe" ) ProcessClose ( "IPassConnectGUI.exe" ) sleep (3000) WEnd ; ---------------------------------------------------------------------------- ; Setting the Options for all Offices ; ---------------------------------------------------------------------------- Global $SSID = 'goes here' $installed = Regread("HKEY_LOCAL_MACHINE\SOFTWARE\Applications", "Wireless Profile" ) if $installed = "Installed" Then regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\Applications", "Wireless Profile" ,"REG_SZ", "Installed" ) RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Applications", "Wireless Profile" ) EndIf $installed1 = Regread("HKEY_LOCAL_MACHINE\SOFTWARE\Applications", "Wireless Profile" ) if $installed1 = "Installed" Then #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK and Cancel, Icon=Warning Dim $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(49,"Profile Exists", "The Wireless Profile already exists - if you are having problems with your connection press the OK button to delete and recreate the profile otherwise press the CANCEL button to select a different office.") Select Case $iMsgBoxAnswer = 1;OK call ("Delete") call ("Setup") Case $iMsgBoxAnswer = 2;CANCEL EndSelect #Region --- CodeWizard generated code Start --- Else call ("Setup") regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\Applications", "Wireless Profile" ,"REG_SZ", "Installed" ) EndIf ; ---------------------------------------------------------------------------- ; Setup Script ; ---------------------------------------------------------------------------- func Setup() SplashTextOn("Profile Setup","Setting up the wireless profile. Full mouse and keyboard use will return when this has finished running.","500","50","-1","50",0,"Tahoma","9","400") sleep (1000) BlockInput ( 1 ) sleep (1000) Run(@ComSpec & " /c " & 'ncpa.cpl', "C:\WINDOWS\system32\dllcache", @SW_HIDE) sleep (1000) WinWait ( 'Network Connections' ) if NOT WinActive ( 'Network Connections', '' ) then WinActivate ( 'Network Connections' ) endif WinWaitActive ( 'Network Connections' ) sleep ( 1500 ) Send ( 'wireless' ) sleep ( 1500 ) send ('{Appskey}') sleep ( 1500 ) send ( 'r' ) sleep (1000) WinWait ( 'Wireless Network Connection Properties', 'Connect using:' ) if NOT WinActive ( 'Wireless Network Connection Properties', 'Connect using:' ) then WinActivate ( 'Wireless Network Connection Properties', 'Connect using:' ) endif WinWaitActive ( 'Wireless Network Connection Properties', 'Connect using:' ) sleep ( 1500 ) Send ( '+{Tab}' ) sleep ( 1500 ) send ( '+{Tab}' ) sleep ( 1500 ) send ('{Right}' ) sleep (1000) WinWait ( 'Wireless Network Connection Properties', 'Wireless Networks' ) if NOT WinActive ( 'Wireless Network Connection Properties', 'Wireless Networks' ) then WinActivate ( 'Wireless Network Connection Properties', 'Wireless Networks' ) endif WinWaitActive ( 'Wireless Network Connection Properties', 'Wireless Networks' ) sleep ( 1500 ) Send ( '!a' ) sleep (1000) WinWait ( 'Wireless network properties', 'Association' ) if NOT WinActive ( 'Wireless network properties', 'Association' ) then WinActivate ( 'Wireless network properties', 'Association' ) endif WinWaitActive ( 'Wireless network properties', 'Association' ) sleep ( 1500 ) Send ( $SSID ) sleep ( 1500 ) send ('!a') sleep ( 1500 ) send ('w') sleep ( 1500 ) send ('!d') ;tkip option remove if you want AES sleep ( 1500 );tkip option remove if you want AES send ('t') ;tkip option remove if you want AES sleep ( 1500 );tkip option remove if you want AES send ('!n') sleep ( 1500 ) send ('+{Tab}') sleep ( 1500 ) send ('{Right}' ) sleep (1000) WinWait ( 'Wireless network properties', 'Authentication' ) if NOT WinActive ( 'Wireless network properties', 'Authentication' ) then WinActivate ( 'Wireless network properties', 'Authentication' ) endif WinWaitActive ( 'Wireless network properties', 'Authentication' ) sleep ( 1500 ) Send ( '!r' ) sleep (1000) WinWait ( 'Smart Card or other Certificate Properties', 'When connecting:' ) if NOT WinActive ( 'Smart Card or other Certificate Properties', 'When connecting:' ) then WinActivate ( 'Smart Card or other Certificate Properties', 'When connecting:' ) endif WinWaitActive ( 'Smart Card or other Certificate Properties', 'When connecting:' ) sleep ( 1500 ) Send ( '!r') sleep ( 1500 ) send ('' ); certificate name goes here sleep ( 1500 ) Send ( '{Space}' ) sleep ( 1500 ) Send ( '{Enter}' ) sleep (1000) WinWait ( 'Wireless network properties', 'Authentication' ) if NOT WinActive ( 'Wireless network properties', 'Authentication' ) then WinActivate ( 'Wireless network properties', 'Authentication' ) endif WinWaitActive ( 'Wireless network properties', 'Authentication' ) sleep ( 1500 ) Send ( '{Enter}' ) sleep (1000) WinWait ( 'Wireless Network Connection Properties', 'Wireless Networks' ) if NOT WinActive ( 'Wireless Network Connection Properties', 'Wireless Networks' ) then WinActivate ( 'Wireless Network Connection Properties', 'Wireless Networks' ) endif WinWaitActive ( 'Wireless Network Connection Properties', 'Wireless Networks' ) Send ( '+{Tab}') sleep ( 1500 ) send ('+{Tab}') sleep ( 1500 ) send ('{Enter}' ) sleep ( 1500 ) sleep (1000) WinWaitClose ( 'Wireless Network Connection Properties' ) sleep (1000) WinClose ( 'Network Connections' ) sleep (1000) Splashoff ( ) sleep (1000) BlockInput ( 0 ) sleep (1000) endfunc ; ---------------------------------------------------------------------------- ; Delete Script ; ---------------------------------------------------------------------------- func Delete() SplashTextOn("Wireless Profile Exists","Deleting the wireless profile.","450","30","-1","50",0,"Tahoma","9","400") sleep (1000) BlockInput ( 1 ) sleep (1000) Run(@ComSpec & " /c " & 'ncpa.cpl', "C:\WINDOWS\system32\dllcache", @SW_HIDE) sleep (1000) WinWait ( 'Network Connections' ) if NOT WinActive ( 'Network Connections', '' ) then WinActivate ( 'Network Connections' ) endif WinWaitActive ( 'Network Connections' ) sleep ( 1500 ) Send ( 'wireless' ) sleep ( 1500 ) send ('{Appskey}') sleep ( 1500 ) send ( 'r' ) sleep (1000) WinWait ( 'Wireless Network Connection Properties', 'Connect using:' ) if NOT WinActive ( 'Wireless Network Connection Properties', 'Connect using:' ) then WinActivate ( 'Wireless Network Connection Properties', 'Connect using:' ) endif WinWaitActive ( 'Wireless Network Connection Properties', 'Connect using:' ) sleep ( 1500 ) Send ( '+{Tab}' ) sleep ( 1500 ) send ( '+{Tab}' ) sleep ( 1500 ) send ('{Right}' ) sleep (1000) WinWait ( 'Wireless Network Connection Properties', 'Wireless Networks' ) if NOT WinActive ( 'Wireless Network Connection Properties', 'Wireless Networks' ) then WinActivate ( 'Wireless Network Connection Properties', 'Wireless Networks' ) endif WinWaitActive ( 'Wireless Network Connection Properties', 'Wireless Networks' ) sleep ( 1500 ) Send ( '!p' ) sleep ( 1500 ) Send ( $SSID ) sleep ( 1500 ) Send ( '!r' ) sleep ( 1500 ) Send ( '+{Tab 5}' ) sleep ( 1500 ) Send ( '{Enter}' ) WinWaitClose ( 'Wireless Network Connection Properties' ) sleep ( 1000 ) WinClose ( 'Network Connections' ) sleep ( 1000 ) Splashoff ( ) sleep ( 1000 ) EndFunc Link to comment Share on other sites More sharing options...
mbiwpeoyc Posted February 9, 2006 Author Share Posted February 9, 2006 Thank you! Link to comment Share on other sites More sharing options...
KegRaider Posted July 1, 2006 Share Posted July 1, 2006 Good work craig.gill !! I have used parts of your code for my specific needs. However, I had to add a check to see if the wireless connection is infact enabled, rather crude if i do say so myself Run(@ComSpec & " /c " & 'ncpa.cpl', "C:\WINDOWS\system32\dllcache", @SW_HIDE) sleep (1200) WinWait ( 'Network Connections' ) if NOT WinActive ( 'Network Connections', '' ) then WinActivate ( 'Network Connections' ) endif WinWaitActive ( 'Network Connections' ) sleep ( 1000 ) Send ( 'wireless' ) sleep ( 1000 ) send ('{Appskey}') sleep ( 1000 ) ; Enable connection if disabled send ( 'a' ) sleep ( 100 ) send ( '{ESC}' ) sleep ( 3000 ) ; Launch Properties of wireless connection send ('{Appskey}') sleep ( 1000 ) send ( 'r' ) sleep (1000) And also, whether "Use Windows to configure my wireless network setting" is checked, and tick it if not already ticked. ; Try to get "Use Windows to configure my wireless network setting" checked if not already..... ; Find the green pixel (tick box) in the range 0,0-1024,768 $coord = PixelSearch( 0, 0, 1024, 768, 0x21A121 ) If @error then ;MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1]) send ( '!w' ) EndIf sleep ( 2500 ) ; Add new wireless connection Send ( '!a' ) sleep (1000) WinWait ( 'Wireless network properties', 'Association' ) if NOT WinActive ( 'Wireless network properties', 'Association' ) then WinActivate ( 'Wireless network properties', 'Association' ) endif WinWaitActive ( 'Wireless network properties', 'Association' ) sleep ( 1000 ) Send ( $SSID );type the key in for us Also, the profile wasn't saving using your script, so i changed it a little again... ;WinClose ( 'Wireless Network Connection Properties' , 'Wireless Networks' ) ; Removed ^ as it wasn't saving the new setup, WinClose seems to cancel the settings we just set. Send ( '{Tab}' ) sleep ( 1000 ) send ('{Enter}' ) WinClose ( 'Network Connections' ) sleep (1000) Thanks for the headstart tho, saved me heaps of effort. Will probably try and use CtrlClicks instead of send, when i get some free time. -->KegRaider 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