pete1234 Posted February 9, 2008 Posted February 9, 2008 (edited) so this is my first post - i'm new to autoit and am still figuring things out. i'm not sure if this question is actually related to autoit, but i figure it can't hurt to ask. i'm trying to create a script that will sort the start menu by name. this is what i have so far: RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder","") If @Error <> 0 THEN RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder") $PID = ProcessExists("explorer.exe") If $PID Then ProcessClose($PID) ProcessWaitClose("explorer.exe") ShellExecute("explorer.exe") when i follow this process manually, everything works fine. killing explorer.exe removes the taskbar, and then starting the process again restores it and creates the new reg key, thereby sorting the start menu. now the script i've created does all this too and works, but the shellexec function restores the taskbar and also opens windows explorer. when i do it by hand windows explorer doesnt open. any ideas as to why this is happening? fwiw, im using xp pro sp2, and ive tried this with windows explorer both running and not and with Run instead of ShellExecute. thanks! Edited February 9, 2008 by pete1234
MHz Posted February 9, 2008 Posted February 9, 2008 (edited) Welcome to the AutoIt forum, The system reserves the 1st instance of Explorer for the shell and any extra instances open "My Documents" folder if no switch is passed. On Win XP and above, Explorer will restart within a few seconds if ProcessClose() is used on it. A CLI tool like TaskKill.exe in Win XP Pro can kill Explorer without it restarting but that is something else. Your script will open "My Documents" folder by Explorer as the shell opens just prior automatically by the OS. Checking the process after 5 seconds maybe adequate to ensure Explorer restarts OK. ; Check menu order registry key and delete $regKey = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder","") If Not @Error Then If RegDelete("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder") = 1 Then ; Return the Explorer ProcessID and then close it $PID = ProcessExists("explorer.exe") If $PID Then ProcessClose($PID) ; Start explorer if it does not exist in 5 seconds If Not ProcessWait("explorer.exe", 5) Then Run("explorer.exe") EndIf EndIf EndIf EndIf Edit: Added condition check on RegDelete Edited February 9, 2008 by MHz
i542 Posted February 9, 2008 Posted February 9, 2008 Well, a simple way to keep Explorer "killed" is: AdlibEnable("_KillExplorer") ;your script Func _KillExplorer() If ProcessExists("explorer.exe") Then ProcessKill("explorer.exe") EndFunc Later you just disable adlib and run explorer. I can do signature me.
Swift Posted February 9, 2008 Posted February 9, 2008 While 1 Sleep(250) Processclose("explorer.exe") WEnd then just go into the proccess's and disable it...(run this as a seperat file) thats what I did
pete1234 Posted February 9, 2008 Author Posted February 9, 2008 thanks for all the quick replies, i love that there's many different ways to accomplish the same task. MHz - your method worked great, thanks!
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