sandin Posted February 19, 2009 Share Posted February 19, 2009 I'm trying to figure out how to selfrename a working script. Any help is more than welcome here's my attempt: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> MsgBox(0, "scriptname", @ScriptName) Global $filename = "temp_batch.bat" if FileExists($filename) then FileDelete($filename) $Form1 = GUICreate("Set your script's filename here", 320, 65) $Input1 = GUICtrlCreateInput(@ScriptName, 5, 5, 305, 20) $Button1 = GUICtrlCreateButton("OK", 190, 30, 120, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 if @Compiled Then FileWrite($filename, '@echo off' & @CRLF _ & 'pause' & @CRLF _ & 'rename ' & '"' & @ScriptName & '"' & ' ' & '"' & GUICtrlRead($Input1) & '"' & @CRLF _ & '"' & @ScriptDir & "\" & GUICtrlRead($Input1) & '"') ShellExecute($filename, "", @ScriptDir) Exit Else MsgBox(0, "error", "script must be compiled") EndIf EndSwitch WEnd I thought of making a batch file that will do the work for me, but the "pause" part is annoying, and if the user press any key to continue, it remains working... I tried the "sleep" instead of "pause" but not all windows has "sleep.exe". A winexist batch command would be most useful, but I couldn't find any... Is there a way to rename the script (without having 2 of them working in the same time, like Copy @scriptname then run it, and then exit the current working one. Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
youknowwho4eva Posted February 19, 2009 Share Posted February 19, 2009 Just a thought, but what if when your script ran it automatically copied itself in the temp folder ran the copy and closed the original. Then where you have it placed originally can be changed around, because you're running the copy in the temp folder. Giggity Link to comment Share on other sites More sharing options...
sandin Posted February 19, 2009 Author Share Posted February 19, 2009 wouldn't work, the original script (the one I presented is just an example) is connected to another script, and by running copy of this script, it couldn't connect to the other script since it's protected, so I can't have 2 of the same scripts running in the same time... Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
LarryDalooza Posted February 19, 2009 Share Posted February 19, 2009 There is "self delete" code here that could easily be modified to handle rename. It's in the forum... you just need to go find it. Lar. AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
sandin Posted February 19, 2009 Author Share Posted February 19, 2009 (edited) tnx, I've found itI'll try to modify it for renamingedit: ok, I tried, but still requires "pause" to hit any key and then continue... Edited February 19, 2009 by sandin Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 19, 2009 Share Posted February 19, 2009 tnx, I've found itI'll try to modify it for renamingedit: ok, I tried, but still requires "pause" to hit any key and then continue...Larry meant the one from the FAQ #Q12 (doesn't use pause) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
sandin Posted February 19, 2009 Author Share Posted February 19, 2009 gr8, tnx ;] Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll 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