AzKay Posted June 28, 2006 Share Posted June 28, 2006 I want it to: if the script has ended, delete the files IpChangeOn.bat & IpChangeOff.bat Cant seem to find a way to do it ( Other than using the "FileDelete" function in the _Exit, function, but thats not what I want. expandcollapse popupHotKeySet("^!{END}", "_IpConfig") HotKeySet("^!{PGUP}", "_IpChangeOn") HotKeySet("^!{PGDN}", "_IpChangeOff") HotKeySet("^!{HOME}", "_Exit") MsgBox(0, "", "Write down on a piece of paper your: SubnetMask & DefaultGateway. ( Located using the IpConfig Hotkey )") MsgBox(0, "", "Ctrl + Alt + End = IpConfig") MsgBox(0, "", "Ctrl + Alt + Page Up = New IP") MsgBox(0, "", "Ctrl + Alt + Page Down = Old IP") MsgBox(0, "", "Ctrl + Alt + Home = Exit") While 1 Sleep(25) WEnd Func _IpConfig() Opt("WinTitleMatchMode", 2) Run(@Comspec) WinWaitActive("cmd.exe") Send("ipconfig") Send("{ENTER}") EndFunc Func _IpChangeOn() $IP_ADDY = InputBox("", "NewIP:", "", "", -1, 10) $SUBNET_MASK = InputBox("", "SubnetMask:", "", "", -1, 10) $DEFAULT_GATEWAY = InputBox("", "DefaultGateway", "", "", -1, 10) $IpChangeOn = FileOpen("IpChangeOn.bat", 1) If $IpChangeOn = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWriteLine($IpChangeOn, "@Echo Setting IP address to " & $IP_ADDY) FileWriteLine($IpChangeOn, "@Echo Off") FileWriteLine($IpChangeOn, "") FileWriteLine($IpChangeOn, "netsh interface ip set address name=""Local Area Connection"" static " & $IP_ADDY & " " & $SUBNET_MASK & " " & $DEFAULT_GATEWAY & " " & "1") FileClose($IpChangeOn) Run("IpChangeOn.bat") EndFunc Func _IpChangeOff() Opt("WinTitleMatchMode", 2) $IpChangeOff = FileOpen("IpChangeOff.bat", 1) If $IpChangeOff = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWriteLine($IpChangeOff, "@Echo Setting IP address to DHCP assigned.") FileWriteLine($IpChangeOff, "@Echo Off") FileWriteLine($IpChangeOff, "netsh interface ip set address ""Local Area Connection"" dhcp") FileWriteLine($IpChangeOff, "@Echo Setting DNS to DHCP assigned.") FileWriteLine($IpChangeOff, "@Echo Off") FileWriteLine($IpChangeOff, "netsh interface ip set dns ""Local Area Connection"" dhcp") FileClose($IpChangeOff) Run("IpChangeOff.bat") EndFunc Func _Exit() Exit EndFunc # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
Skruge Posted June 28, 2006 Share Posted June 28, 2006 (edited) RunWait("IpChangeOn.bat") FileDelete("IpChangeOn.bat")You should probably write to @TempDir instead of the current directory. Edited June 28, 2006 by Skruge [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
ChrisL Posted June 28, 2006 Share Posted June 28, 2006 I want it to: if the script has ended, delete the files IpChangeOn.bat & IpChangeOff.bat Cant seem to find a way to do it ( Other than using the "FileDelete" function in the _Exit, function, but thats not what I want. Add a function at the bottom of your script onAutoITExit with your file deletes and whatever else you want to do, when the script exits it will perform those tasks Func OnAutoItExit() FileDelete("myfile.bat") FileDelete("MyFile.exe") EndFunc [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Xenobiologist Posted June 28, 2006 Share Posted June 28, 2006 HI, Func _SelfDelete() Local $cmdfile FileDelete(@TempDir & "\scratch.cmd") $cmdfile = ':loop' & @CRLF _ & 'del "' & @ScriptFullPath & '"' & @CRLF _ & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _ & 'del ' & @TempDir & '\scratch.cmd' FileWrite(@TempDir & "\scratch.cmd", $cmdfile) Run(@TempDir & "\scratch.cmd", @TempDir, @SW_HIDE) EndFunc ;==>_SelfDelete So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times 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