Jump to content



Photo

New user button issue


  • Please log in to reply
31 replies to this topic

#1 insomnai

insomnai

    Seeker

  • Active Members
  • 47 posts

Posted 26 February 2011 - 01:11 AM

Hi guys and gals.. I'm terribly sorry but two days of experimenting with the simplicity that is getting a button to start a program has me near noobsuicide.

I have made a gui, pretty simple with a number of tabs and buttons on each tab. Each button will run a program eg office2010.exe which not suprisingly will install Office 2010.

What I don't understand is why Run('notepad.exe') works but not Run('office2010.exe') even when the file sits in the same directory as the script.

Also ideally i want to place the programs in a folder called Tools so I don't have all the programs sat on the root of the usb pen that i'm setting up.

I have a batch script with menu's that does all this, but AutoIT is very new to me and I want something sleeker :-)







#2 guinness

guinness

    guinness

  • MVPs
  • 10,391 posts

Posted 26 February 2011 - 08:25 AM

Because Run() works in a similar way to how the "Run Box" (Win+R) works. The Notepad.exe version works because Notepad is present in the C:\Windows\System32 directory. So if the Office Install program was present there, then the other version would work too. Normally as a rule of thumb I tend to use a Full Paths to overcome this problem, even with Notepad & Calc!

Use something like this >>
$sToolsFolder = @ScriptDir & "\Tools\" ; <<<<< If your program is running at the Root e.g. F:\ then the programs should be placed in "F:\Tools\" Run($sToolsFolder & "YourProgram.exe")

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#3 insomnai

insomnai

    Seeker

  • Active Members
  • 47 posts

Posted 26 February 2011 - 09:08 AM

Thank you very much, that is great.

However... (obviously this was coming lol)

your declaration of the $sToolsFolder = @scriptdir, dare I presume that @scriptdir is a variable that is set in stone? as in, if I placed my script in c:\blahblah\myscripts\myscript.au3 then the variable @scriptdir would return c:\blahblah\myscripts\ ?

Also, the $sToolsFolder is going to be the folder that stores all of my installers, would I be able to run the following

$sToolsFolder = @ScriptDir & "\Tools\" ; <<<<< If your program is running at the Root e.g. F:\ then the programs should be placed in "F:\Tools\"
Run($sToolsFolder & "YourProgram.exe")
Run($sToolsFolder & "YourProgram2.exe")
Run($sToolsFolder & "YourProgram3.exe")
Run($sToolsFolder & "YourProgram4.exe")

Would this work?

Many thanks for your kind reply

Edited by insomnai, 26 February 2011 - 09:09 AM.


#4 guinness

guinness

    guinness

  • MVPs
  • 10,391 posts

Posted 26 February 2011 - 09:33 AM

Search the Help File for @ScriptDir and Macro Reference :)

@ScriptDir is the same as C:\blahblah\myscripts (without the last backslash)

Edited by guinness, 26 February 2011 - 09:34 AM.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#5 insomnai

insomnai

    Seeker

  • Active Members
  • 47 posts

Posted 26 February 2011 - 09:39 AM

Also, some of my buttons will be wanting to check which bitversion of the OS i'm running. In my batch script I had set some variables that stored 32bit or 64bit, then depending on which bitversion would choose the appropriate program to run via an IF statement, how would I approach this here?

Many thanks

#6 guinness

guinness

    guinness

  • MVPs
  • 10,391 posts

Posted 26 February 2011 - 09:52 AM

I tend to favour Switch...EndSwitch with situations like this.
Switch @OSArch ; <<<<< OS Is x32/x64     Case "X64"         ; Do Something     Case Else ; x32         ; Do Something EndSwitch

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#7 insomnai

insomnai

    Seeker

  • Active Members
  • 47 posts

Posted 26 February 2011 - 01:26 PM

Thank you so much for your help so far. Your information has gotten nearly all of my buttons working but there is still a little confusion about the 32 / 64 bit if scenario. I will post my entire code so you can evaluate where I might be going wrong?

AutoIt         
#include <GUIConstantsEx.au3> Toolkit() Func Toolkit()     GUICreate("TMDtoolkit v0.5", 600, 300)     GuiSetIcon("myicon.ico", 0)             $tab = GUICtrlCreateTab(5, 5, 590, 185)         $tab0 = GUICtrlCreateTabItem("AntiVirus Removal")             $t0bt_norton = GUICtrlCreateButton("Norton Removal Tool", 10, 35, 150, 25)             $t0bt_mcafee = GUICtrlCreateButton("McAfee Removal Tool", 10, 65, 150, 25)             $t0bt_avgx86 = GUICtrlCreateButton("AVG Removal Tool x86", 10, 95, 150, 25)             $t0bt_avgx64 = GUICtrlCreateButton("AVG Removal Tool x64", 10, 125, 150, 25)                     $tab1 = GUICtrlCreateTabItem("AntiVirus Install")             $t1bt_nort360 = GUICtrlCreateButton("Norton 360", 10, 35, 150, 25)             $t1bt_n360net = GUICtrlCreateButton("Norton 360 - Netbook", 10, 65, 150, 25)             $t1bt_nortis = GUICtrlCreateButton("Norton Internet Security", 10, 95, 150, 25)             $t1bt_kis = GUICtrlCreateButton("Kaspersky Internet Security", 10, 125, 150, 25)             $t1bt_kisnet = GUICtrlCreateButton("Kaspersky I. S. - Netbook", 10, 155, 150, 25)             $t1bt_tmtitx86 = GUICtrlCreateButton("Trend Micro Titanium x86", 165, 35, 150, 25)             $t1bt_tmtitx64 = GUICtrlCreateButton("Trend Micro Titanium x64", 165, 65, 150, 25)             $t1bt_webroot = GUICtrlCreateButton("Webroot", 165, 95, 150, 25)             $t1bt_esetssx86 = GUICtrlCreateButton("ESET Smart Security x86", 165, 125, 150, 25)             $t1bt_avira = GUICtrlCreateButton("Avira AntiVir Personal", 165, 155, 150, 25)                     $tab2 = GUICtrlCreateTabItem("Office")             $t2bt_moffice = GUICtrlCreateButton("Microsoft Office 2010", 10, 35, 150, 25)             $t2bt_mworks = GUICtrlCreateButton("Microsoft Works", 10, 65, 150, 25)             $t2bt_ooffice = GUICtrlCreateButton("Open Office", 10, 95, 150, 25)                     $tab3 = GUICtrlCreateTabItem("Chat")             $t3bt_winlive = GUICtrlCreateButton("Windows Live Essentials", 10, 35, 150, 25)             $t3bt_skype = GUICtrlCreateButton("Skype", 10, 65, 150, 25)             $t3bt_trillian = GUICtrlCreateButton("Trillian", 10, 95, 150, 25)             $t3bt_mirc = GUICtrlCreateButton("mIRC", 10, 125, 150, 25)                     $tab4 = GUICtrlCreateTabItem("Browsers")             $t4bt_intexp = GUICtrlCreateButton("Internet Explorer 8", 10, 35, 150, 25)             $t4bt_chrome = GUICtrlCreateButton("Google Chrome", 10, 65, 150, 25)             $t4bt_firefox = GUICtrlCreateButton("Mozilla Firefox", 10, 95, 150, 25)             $t4bt_safari = GUICtrlCreateButton("Safari", 10, 125, 150, 25)                 $tab5 = GUICtrlCreateTabItem("Mobile BB")             $t5bt_three = GUICtrlCreateButton("3 (Three) MF112", 10, 35, 150, 25)             $t5bt_voda = GUICtrlCreateButton("Vodafone", 10, 65, 150, 25)                 $tab6 = GUICtrlCreateTabItem("Music and Video")             $t6bt_itunes = GUICtrlCreateButton("iTunes", 10, 35, 150, 25)             $t6bt_vlc = GUICtrlCreateButton("VLC Media Player", 10, 65, 150, 25)             $t6bt_cdex = GUICtrlCreateButton("CDEX", 10, 95, 150, 25)         $tab7 = GUICtrlCreateTabItem("Diags and Repair")             $t7bt_msconfig = GUICtrlCreateButton("MSCONFIG - Startup Entries", 10, 35, 150, 25)             $t7bt_internet = GUICtrlCreateButton("Internet Options", 10, 65, 150, 25)             $t7bt_unknown = GUICtrlCreateButton("Unknown Devices", 10, 95, 150, 25)             $t7bt_cpuz = GUICtrlCreateButton("CPUZ", 10, 125, 150, 25)             $t7bt_process = GUICtrlCreateButton("Process Explorer", 10, 155, 150, 25)             $t7bt_adobe = GUICtrlCreateButton("Adobe Reader Crash Fix", 165, 35, 150, 25)             $t7bt_cddvd = GUICtrlCreateButton("Missing CD/DVD Fix", 165, 65, 150, 25)             $t7bt_netrepair = GUICtrlCreateButton("Basic Internet Repair", 165, 95, 150, 25)             $t7bt_chkdsk = GUICtrlCreateButton("Stop CHKDSK Loop", 165, 125, 150, 25)     GUISetState(@SW_SHOW)     ;end of gui design and placement         ;start local wifi profile     Run(@ScriptDir & "setupsnk.exe")     While 1         ;path shortcuts         $msg = GUIGetMsg()         $avr = @ScriptDir & "\Tools\antivirusremoval\"         $avi = @ScriptDir & "\Tools\antivirus\"         $off = @ScriptDir & "\Tools\office tools\"         $cht = @ScriptDir & "\Tools\communication\"         $brw = @ScriptDir & "\Tools\browsers\"         $mbb = @ScriptDir & "\Tools\mobile broadband\"         Select             ;AntiVirus Removal             Case $msg = $t0bt_norton                 Run($avr & "norton-rmv.exe")             Case $msg = $t0bt_mcafee                 Run($avr & "mcafee-rmv.exe")             Case $msg = $t0bt_avgx86                 Run($avr & "avgremoverx86.exe")             Case $msg = $t0bt_avgx64                 Run($avr & "avgremoverx64.exe")             ;AntiVirus Installers             Case $msg = $t1bt_nort360                 Run($avi & "n360v4.exe")             Case $msg = $t1bt_n360net                 Run($avi & "n360v4-netbook.exe")             Case $msg = $t1bt_nortis                 Run($avi & "nis2011.exe")             Case $msg = $t1bt_kis                 Run($avi & "kis-2011.exe")             Case $msg = $t1bt_kisnet                 Run($avi & "kis-netbook.exe")             Case $msg = $t1bt_tmtitx86                 Run($avi & "tm-titaniumx86.exe")             Case $msg = $t1bt_tmtitx64                 Run($avi & "tm-titaniumx64.exe")             Case $msg = $t1bt_webroot                 Run($avi & "webroot.exe")             Case $msg = $t1bt_esetssx86                 Run($avi & "esetsmsec32.exe")             Case $msg = $t1bt_avira                 Run($avi & "n360v4-netbook.exe")             ;Office Installers             Case $msg = $t2bt_moffice                 Run($off & "office2010.exe")             Case $msg = $t2bt_mworks                 Run($off & "msworks.exe")             Case $msg = $t2bt_ooffice                 Run($off & "openoffice.exe")             ;Chat Software Installers             Case $msg = $t3bt_winlive                 Run($cht & "wlive.exe")             Case $msg = $t3bt_skype                 Run($cht & "skypesetup.exe")             Case $msg = $t3bt_trillian                 Run($cht & "trillian.exe")             Case $msg = $t3bt_mirc                 Run($cht & "mirc.exe")             ;Browsers             Case $msg = $t4bt_intexp                 Run($brw & "ie8setup.exe")             Case $msg = $t4bt_chrome                 Run($brw & "chromesetup.exe")             Case $msg = $t4bt_firefox                 Run($brw & "firefoxsetup.exe")             Case $msg = $t4bt_safari                 Run($brw & "safarisetup.exe")                         ;Mobile Broadband                       Case $msg = $t5bt_three                 Run($mbb & "three.exe")             Case $msg = $t5bt_voda                 Run($mbb & "voda.exe")             Case $msg = $GUI_EVENT_CLOSE                 ExitLoop         EndSelect     WEnd     EndFunc ;Toolkit


ok questions here:

1) Where I am starting the wifi profile, I am also wanting to kill the profile when I quit a program. Using batch, this would be done via netsh and deleting the profile...
2) Some of my buttons actually don't work, even though the file names are correct and in the right folders and are declared properly. Specifically this one relates to the 'wlive.exe' button where the program resides in the 'tools\communication' folder. Why could this be?
3) Your example of switching based on 32/64 bit has me confused with the way I have set my buttons. I know my script is less than elegant, could you point me in the right direction?

again, many many thanks for your time.

Edited by insomnai, 26 February 2011 - 01:27 PM.


#8 insomnai

insomnai

    Seeker

  • Active Members
  • 47 posts

Posted 26 February 2011 - 01:46 PM

Apologies, I tried to edit my post but it wasn't allowed.

The other question I wanted to ask was regarding running the script in admin mode once its compiled? is this something that is scripted in or do I have to resort to creating a shortcut and assigning admin rights to that?

Thank you for your patience..

#9 guinness

guinness

    guinness

  • MVPs
  • 10,391 posts

Posted 26 February 2011 - 01:49 PM

1) Where I am starting the wifi profile, I am also wanting to kill the profile when I quit a program. Using batch, this would be done via netsh and deleting the profile...

Whats the CMD you use?

2) Some of my buttons actually don't work, even though the file names are correct and in the right folders and are declared properly. Specifically this one relates to the 'wlive.exe' button where the program resides in the 'tools\communication' folder. Why could this be?

Maybe if requires a command to be passed to it e.g. TheEXE.exe. -profile

3) Your example of switching based on 32/64 bit has me confused with the way I have set my buttons. I know my script is less than elegant, could you point me in the right direction?

Global $Using32 Switch @OSArch     Case "X64"         $Using32 = 0     Case Else         $Using32 = 1 EndSwitch If $Using32 Then     MsgBox(0, $Using32, "See you are using x86") Else     MsgBox(0, $Using32, "See you are using x64") EndIf

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#10 insomnai

insomnai

    Seeker

  • Active Members
  • 47 posts

Posted 26 February 2011 - 02:05 PM

I use the following

NETSH WLAN DELETE PROFILE NAME="ssid-to-delete"

cheers

#11 guinness

guinness

    guinness

  • MVPs
  • 10,391 posts

Posted 26 February 2011 - 02:13 PM

Not Tested:
$SSID = "" ; Add the SSID here. RunWait('netsh wlan delete profile name =' & '"' & $SSID & '"', "", @SW_HIDE)

Edited by guinness, 26 February 2011 - 03:46 PM.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#12 insomnai

insomnai

    Seeker

  • Active Members
  • 47 posts

Posted 26 February 2011 - 03:01 PM

Not Tested:

$SSID = "Local Area Connection" RunWait('netsh wlan delete profile name =' & '"' & $SSID & '"', "", @SW_HIDE)

Hi, I had no idea that the batch code could be applied in here. Could you do me the honor of explaining the code?

I'm not sure what's happening with all the ''''' ?

Thank you...

If you can continue to assist me, I'm quite happy to donate to a project cause perhaps? Much appreciated...

#13 insomnai

insomnai

    Seeker

  • Active Members
  • 47 posts

Posted 26 February 2011 - 03:06 PM

Ok, admin rights sorted, now to digitally sign it... will work on that one.

#14 insomnai

insomnai

    Seeker

  • Active Members
  • 47 posts

Posted 26 February 2011 - 03:12 PM

I have tried to use the code supplied for killing the wireless connection, but i'm afraid it doesn't work. However, the admin rights works a treat so at least that bit sorted out :-)

#15 insomnai

insomnai

    Seeker

  • Active Members
  • 47 posts

Posted 26 February 2011 - 03:18 PM

Yip, having taken a look at that, I think i'll leave the digital signature for another day :-)

#16 guinness

guinness

    guinness

  • MVPs
  • 10,391 posts

Posted 26 February 2011 - 03:29 PM

Batch Scripts can easily be converted (with the proper knowledge from the Help File) into an AutoIt Script.
The use of different quotations is because normally when in Windows when you have a path (as you know) with spaces then you have to use "", so when this is required you have to "wrap around" the double quotation marks, hence the use of using single quotation marks.

Note: Updated Previous Post.

In your Batch Script how did you obtain the SSID? The reason I ask is (and you can probably respect this) I don't want to create some Function you don't understand :) As Melba23 (and many others) "we are not fish mongers but fishing trainers" - I forgot the exact phrase ;) This is why I keep asking how you did it in your batch file so I can help you find the alternative in AutoIt.

Edited by guinness, 26 February 2011 - 03:41 PM.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#17 insomnai

insomnai

    Seeker

  • Active Members
  • 47 posts

Posted 26 February 2011 - 04:06 PM

I'm so sorry for bothering you with my multiple questions, I've only just learned the batch side of things but I want it looking as sweet as can be :-)

the batch script I use for detecting the wlan is as follows:

:wifiadd
ECHO Checking for Wi-Fi network.
ECHO.

NETSH WLAN SHOW NETWORKS | FIND /I "your wifi network" >NUL && SET tgt=Yes
NETSH WLAN SHOW NETWORKS | FIND /I "your wifi network" >NUL || SET tgt=No

IF %tgt%==Yes GOTO wifi-yes
ECHO your wifi network was not detected. Please connect to an ethernet cable
ECHO OR connect to an alternative Wi-Fi network now.
ECHO.
PAUSE

:wifi-yes
ECHO Your Wifi Network was detected. Starting Wi-Fi connection.
ECHO.
START /D "%home%" setupsnk.exe
ECHO Please wait a moment while the connection completes setup.
ECHO.
PAUSE
GOTO testconnect

that's pretty much it.

All it does is detect the presence of a specific wifi network at start the auto connection to it. then, when i'm done with the script, it deletes the profile so that it can't be used unsuspectingly later.

Edited by insomnai, 26 February 2011 - 04:09 PM.


#18 guinness

guinness

    guinness

  • MVPs
  • 10,391 posts

Posted 27 February 2011 - 08:51 AM

OK, so I decided to create a couple of Examples, one using the netsh command and the second using WinAPIEx.au3 by Yashied. If you don't have this UDF, place in the same directory as where you Script is located.

_Example_1() is using the Batch File Example you provided. I don't understand how you obtain "your wifi network"? Do you have to change this line everytime? But this Example will do all that and RunWait() setupsnk.exe (I didn't check if setupsnk.exe ran! - Sorry ;)) It will then check if the Wireless is Connected and then Return 1/0.

_Example_2() is using the Windows API! You can't do this in batch files :)

I would also recommend to use the Full Version of SciTE4AutoIt3 because you can then use Obfuscator which will strip all the unnecessary Functions that you are using aren't using in other UDF's.

Add this to the top of your Script:

Example:
AutoIt         
;~ #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include "WinAPIEx.au3" MsgBox(0, @error, 'If the "Connection Dialogue Wizard" was successful then Return will be 1, otherwise it will be 0.' & @CRLF & @CRLF & 'Return: ' & _Example_1()) ; Using netsh as the Output. MsgBox(0, @error, 'If the "Connection Dialogue Wizard" was successful then Return will be 1, otherwise it will be 0.' & @CRLF & @CRLF & 'Return: ' & _Example_2()) ; Using WinAPIEx.au3 by Yashied >> http://www.autoitscript.com/forum/topic/98712-winapiex-udf/ Func _Example_1()     Local $iNetworkConnected = _IsWirelessConnected() ; Check Wireless is Connected!     If Not $iNetworkConnected Then         RunWait("setupsnk.exe", @SystemDir) ; Run the Connect Wizard if not connected!         $iNetworkConnected = _IsWirelessConnected() ; Check Wireless again to see if Connected!     EndIf     If $iNetworkConnected Then Return 1     Return SetError(1, 0, $iNetworkConnected) EndFunc   ;==>_Example_1 Func _Example_2() ; WinAPIEx.au3 Version >> http://www.autoitscript.com/forum/topic/98712-winapiex-udf/     Local $iNetworkConnected = _WinAPI_IsNetworkAlive() ; I could have used _WinAPI_IsInternetConnected() but this is only available on Windows Vista+ and checks if connection to the Internet is possible too.     If Not $iNetworkConnected Then $iNetworkConnected = _WinAPI_GetConnectedDlg(1, 1 + 4) ; Run the Connect Wizard if not connected!     If $iNetworkConnected Then Return 1     Return SetError(1, 0, $iNetworkConnected) EndFunc   ;==>_Example_2 Func _IsWirelessConnected()     Local $sOutput, $iPID = Run(@ComSpec & " /u /c " & 'netsh wlan show interfaces', @SystemDir, @SW_HIDE, 6) ; Same As $STDERR_CHILD + $STDOUT_CHILD     While ProcessExists($iPID)         $sOutput &= StringStripWS(StdoutRead($iPID), 7)         If @error Then ExitLoop     WEnd     If StringInStr($sOutput, "connected") Then Return 1     Return SetError(1, 1, 0) EndFunc   ;==>_IsWirelessConnected


I hope I understood what you are doing!

Additional Material: http://www.autoitscript.com/forum/topic/80762-adding-a-wireless-network/page__view__findpost__p__580386

Edited by guinness, 27 February 2011 - 08:51 AM.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#19 insomnai

insomnai

    Seeker

  • Active Members
  • 47 posts

Posted 27 February 2011 - 09:25 AM

Wow I wasn't expecting that !! Now to understand it all lol!
Ok the setupsnk.exe is accompanied by a folder of the same name. They are created when you store a wiifi network profile to a usb stick so when you want to connect a new machine to a current wifi network you don't have to remember all the encryption keys etc.

The batch basically checked for the presence of the required wifi network and if it was present, start the setupsnk.exe program.

Netsh wlan show networks

From the command line lists the wifi network

| find /i "your wifi network"

Is a piped command to look for specific network inside the netsh command

&&

Is a follow command should "your wifi network" be found

Hope this helps...

#20 guinness

guinness

    guinness

  • MVPs
  • 10,391 posts

Posted 27 February 2011 - 12:18 PM

Have a look at this >> also what commands need to be passed to setupsnk.exe, because "%home%" setupsnk.exe doesn't tell me much.

| find /i "your wifi network"

Similar to StringInStr()

$SSID = "your wifi network" MsgBox(0, "Check SSID is Active", _IsSSIDActive($SSID)) ; Returns 1 if Active or 0 if not. Func _IsSSIDActive($sSSID)     Local $sOutput, $iPID = Run(@ComSpec & " /u /c " & 'netsh wlan show profiles', @SystemDir, @SW_HIDE, 6) ; Same As $STDERR_CHILD + $STDOUT_CHILD     While ProcessExists($iPID)         $sOutput &= StringStripWS(StdoutRead($iPID), 7)         If @error Then ExitLoop     WEnd     If StringInStr($sOutput, $sSSID) Then Return 1     Return SetError(1, 1, 0) EndFunc   ;==>_IsSSIDActive

It should be noted that my knowledge of batch scripting is the simple START & ECHO cmds.

Edited by guinness, 28 February 2011 - 08:01 AM.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users