aleph01 Posted June 14, 2017 Posted June 14, 2017 #include <IE.au3> ; delete previous user data $ClearID = "511" Run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID) DirRemove ("C:\Users\" & @UserName & "\AppData\Local\Google\", 1) ; open two tabs in Chrome Run("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe http://www.forsythpl.org https://www.google.com --new-window --incognito", "", @SW_SHOWMAXIMIZED) ; meter $meteringSite = "http://opac.forsythpl.org/launchcommand/sf/GoogleChrome.htm" $meteringWindow = _IECreate($meteringSite, 0, 0, 1) _IEQuit($meteringWindow) In my workplace (library), we use the above script, compiled, to allow patrons to open the Chrome browser. It works great, except on some older machines, the DirRemove line takes about 27 seconds, leaving patrons confused and frustrated. (That is to say, if I rem out the DirRemove line, Chrome starts in 2 – 3 seconds.) I would like to run the DirRemove line only the first time the script is run. Subsequent times, the Google directory won’t be storing user data since we’re running in incognito mode. I know I could put a RegRead line in there and if the reg entry doesn’t exist, write it and run the DirRemove line. If it does exist, that means this script has run before and the Google directory doesn’t have any user data in it and doesn‘t need to be deleted. I was wondering if there’s some standard method to do this, or if the registry method I described is as good as any other. Also, if there isn't what might be called a "standard" method, I'm open to other suggestions for performing the same task. Thanks, _aleph_ Meds. They're not just for breakfast anymore.
Developers Jos Posted June 14, 2017 Developers Posted June 14, 2017 Wouldn't this do the same without hanging, but simply removing the old data in the background? #include <IE.au3> ; delete previous user data $ClearID = "511" Run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID) DirMove ("C:\Users\" & @UserName & "\AppData\Local\Google\", "C:\Users\" & @UserName & "\AppData\Local\GoogleOld\",1) Run(@ComSpec & ' /c rmdir /S /Q "C:\Users\' & @UserName & '\AppData\Local\GoogleOld\"',Default,@SW_HIDE) ; open two tabs in Chrome Run("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe http://www.forsythpl.org https://www.google.com --new-window --incognito", "", @SW_SHOWMAXIMIZED) ; meter $meteringSite = "http://opac.forsythpl.org/launchcommand/sf/GoogleChrome.htm" $meteringWindow = _IECreate($meteringSite, 0, 0, 1) _IEQuit($meteringWindow) Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
aleph01 Posted June 14, 2017 Author Posted June 14, 2017 Jos, Thanks for responding. I'll see if DirMove is faster than DirRemove. As it turns out, none of our older, slower computers will be running this script, so at this point it's academic. But if DirMove is faster, it'll make the first run more palatable (on the slower machines.) Meds. They're not just for breakfast anymore.
Developers Jos Posted June 14, 2017 Developers Posted June 14, 2017 Dirmove is just a rename so guess it should be instant. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
aleph01 Posted June 14, 2017 Author Posted June 14, 2017 (edited) Actually, Jos, with DirMove, my slow machine took right at 25 seconds to open Chrome. It seems DirMove is only marginally faster (if at all) than DirRemove. Anyway, the pressure's off, with the newer machines running the original script in a timely manner, but I'm still curious if there's a better method to skip a section of code after first run than the RegRead/RegWrite method I described earlier. I would have guessed renaming should be faster, but not in this case for whatever reason. Edited June 14, 2017 by aleph01 Meds. They're not just for breakfast anymore.
Developers Jos Posted June 14, 2017 Developers Posted June 14, 2017 mmm ... strange as it should only de a rename of the folder when its on the same drive. Is it the actual Delete/move taking that long of just the fact that the Google subdirectory isn't there? Anyway... was just wondering but understand it's a moot point now. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
aleph01 Posted June 14, 2017 Author Posted June 14, 2017 The Google directory is there, Chrome creates it every time it's run if it doesn't exist. Moot because of current applicability, but it inspired me to write some code: #include <IE.au3> ; delete previous user data in IE $ClearID = "511" Run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID) If NOT RegRead("HKEY_CURRENT_USER\Software\Google\Chrome\StabilityMetrics", "ScriptRunOnce") Then ; delete previous user data in Chrome DirRemove ("C:\Users\" & @UserName & "\AppData\Local\Google\", 1) ;DirMove ("C:\Users\" & @UserName & "\AppData\Local\Google\", "C:\Users\" & @UserName & "\AppData\Local\GoogleOld\", 1) RegWrite ("HKEY_CURRENT_USER\Software\Google\Chrome\StabilityMetrics", "ScriptRunOnce", "REG_SZ", 1) EndIf ; open Chrome Run("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe http://www.forsythpl.org http://www.google.com --new-window --incognito", "", @SW_SHOWMAXIMIZED) ; meter $meteringSite = "http://opac.forsythpl.org/launchcommand/sf/GoogleChrome.htm" $meteringWindow = _IECreate($meteringSite, 0, 0, 1) _IEQuit($meteringWindow) It works like a charm. About 30 seconds to start Chrome the first time, about 3 seconds on subsequent times. Thanks, _aleph_ Meds. They're not just for breakfast anymore.
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