hispeed_mike Posted January 24, 2006 Share Posted January 24, 2006 I have a registry key to write which needs to then refresh the registry so I can apply it without restarting windows.... I know I found it once before but forgot the dll I need to call and don't have time to sift throught the forums. Thanks again in advance. Havn't called these type of functions before so if you could give me a quick exapmle of code would be great... Thanks Mike Link to comment Share on other sites More sharing options...
Valik Posted January 24, 2006 Share Posted January 24, 2006 You don't "Refresh" the registry. When you write something, it is there. Depending on the application(s) this registry key affects, there may or may not be a way to signal the application to re-check the registry. If my answer is vague, it matches the question. Link to comment Share on other sites More sharing options...
hispeed_mike Posted January 24, 2006 Author Share Posted January 24, 2006 You don't "Refresh" the registry. When you write something, it is there. Depending on the application(s) this registry key affects, there may or may not be a way to signal the application to re-check the registry. If my answer is vague, it matches the question. Thanks Valik, I understand that once written the value is there and the program needs to check the registry. The problem is this is a windows explorer registry value namely: [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] "WebView"=dword:00000000 This regkey changes the Folder view in explorer. Normally you click apply after changing this option through the tools menu. This then applies the changes made to registry. Now I can change the value but it does not get applied until reboot when the registry gets reread by default. I need to make this change to a heap of PC's used in a kiosk environment, hence the need to make registry change then force windows to read this change and apply... Hope this helps. Any ideas? Sorry for first question being so vague, I didn't want to bore anyone with details....My mistake. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 24, 2006 Moderators Share Posted January 24, 2006 (edited) This is a Start Menu change correct? This will refresh the start menu, but don't ask me how to convert it to AutoIT. #define SM_REFRESH_START_MENU WM_APP + 67 ... HWND hwndStart = FindWindow( L"MSStart", NULL ); PostMessage(hwndStart, SM_REFRESH_START_MENU, 0, 0); Edited January 24, 2006 by big_daddy Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 24, 2006 Moderators Share Posted January 24, 2006 Nevermind I found that it wasn't a Start Menu change. This code tells windows to update all settings and policies. var c1 : dword; SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, integer(pchar('Policy')), SMTO_NORMAL or SMTO_ABORTIFHUNG, 5000, c1); Link to comment Share on other sites More sharing options...
The Kandie Man Posted January 25, 2006 Share Posted January 25, 2006 This is one way: While ProcessExists ( "explorer.exe" ) ProcessClose ( "explorer.exe" ) Wend sleep(100) Run("explorer.exe") sleep(1000) If NOT ProcessExists("explorer.exe") Then Run("explorer.exe") This is a rather violent way to apply your settings though since it is ending explorer.exe. This however will force explorer to completely re-read everything from the registry. I don't know if this is what you were looking for. "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
shaggy Posted March 6, 2006 Share Posted March 6, 2006 I have the same problem, and can't find anything else. Restart Windows Explorer - it's working, but... it's really wrong. It must be the way to refresh settings, because when we change settings through Explorer's GUI interface, they working immediatly. Probably, only professional programmers know this. If somebody can help, please write here. At any time. Thank you. Link to comment Share on other sites More sharing options...
BigDod Posted March 6, 2006 Share Posted March 6, 2006 I have the same problem, and can't find anything else.Restart Windows Explorer - it's working, but... it's really wrong.It must be the way to refresh settings, because when we change settings through Explorer's GUI interface, they working immediatly. Probably, only professional programmers know this.If somebody can help, please write here. At any time.Thank you.http://weblogs.asp.net/whaggard/archive/2003/03/12/3729.aspxorhttp://www.nirsoft.net/utils/restart_explorer.html Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
shaggy Posted March 6, 2006 Share Posted March 6, 2006 Thanks, but i don't want to kill Explorer. I need to save all existing user's Explorer windows. About Alt+Ctrl+Del - it's working sometimes and very strange. And is no good idea for automation. I need something like a "system call" for Explorer. Will try to find. Link to comment Share on other sites More sharing options...
Briegel Posted February 28, 2007 Share Posted February 28, 2007 ... I have a registry key to write which needs to then refresh the registry so I can apply it without restarting windows.... I have the same problem, and can't find anything else. Restart Windows Explorer - it's working, but... it's really wrong. ... If somebody can help, please write here. At any time. I'm late because it was a long search. Perhaps it still can help somebody. #include <misc.au3> _SendMessage(0xffff,0x1A,0,0) Please ignore, if this problem was already solved somewhere else. Link to comment Share on other sites More sharing options...
skippynz Posted March 12, 2007 Share Posted March 12, 2007 I'm late because it was a long search. Perhaps it still can help somebody. #include <misc.au3> _SendMessage(0xffff,0x1A,0,0) Please ignore, if this problem was already solved somewhere else. Hi there - i just tried your _sendmessage - but it doesnt appear to do anything - in my situation im writing a registry entry to HKEY_CURRENT_USER\Environment at the mo we are using kix scripts for login - but as they are getting bigger they are getting less reliable - so my idea was to use autoit - everything is sweet except for this registry entry - all its doing is adding a User PATH to the default machine path - this is the same place that KIX puts it so it doesnt overwrite any other path that has been set any ideas on how to get this refresh to work ? Link to comment Share on other sites More sharing options...
skippynz Posted March 12, 2007 Share Posted March 12, 2007 Send("#r") WinWait("Run") WinActivate("Run") WinWaitActive("Run") Send('cmd /k echo %TMP%{ENTER}') MsgBox(4096,"","Close DOS Window and click OK") $a = RegRead("HKCU\Environment","TMP") RegWrite("HKCU\Environment","TMP","REG_EXPAND_SZ","C:\Larry Rocks") EnvUpdate() Send("#r") WinWait("Run") WinActivate("Run") WinWaitActive("Run") Send('cmd /k echo %TMP%{ENTER}') MsgBox(4096,"","Close DOS Window and click OK") RegWrite("HKCU\Environment","TMP","REG_EXPAND_SZ",$a) EnvUpdate() Send("#r") WinWait("Run") WinActivate("Run") WinWaitActive("Run") Send('cmd /k echo %TMP%{ENTER}') MsgBox(4096,"","Close DOS Window and click OK") oh shit - i so over looked ENVUPDATE() - how stupid of me thanks larry Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 25, 2007 Share Posted August 25, 2007 (edited) Is it necessary to add 'envupdate()' after each registry editing? Or just once after all the changes made?It looks kind of redundant doesn't it?Only if you changed System or User environment variables via the registry, which become the "DOS Shell" variables like %TEMP%. EnvUpdate() updates those shell variables in the shell that AutoIt is running in. Edited August 25, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 26, 2007 Share Posted August 26, 2007 for example?i mean...can a single 'EnvUpdate()' update all the editing done in one go?Editing of what? The changes are effective in the registry as soon as they are made, and EnvUpdate() has nothing to do with that. In the special case of registry keys that are read to create the shell environment variables, one call to EnvUpdate is all that's required.But there's no need to wonder about it. Test it. A demo script would be easy to code. Exactly what change are you interested in? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 27, 2007 Share Posted August 27, 2007 maybe to disable Net Crawling or lock IE's homepage to prevent homepage editing by spywares?I'm actually curious about it because certain registry entries do not reflect their changes until rebooted.Some IE changes require you to restart IE, but not a reboot of the whole machine. But it's still very easy to test... have you done your script to test it yet? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
BrunoJ Posted July 2, 2012 Share Posted July 2, 2012 This is one way: While ProcessExists ( "explorer.exe" ) ProcessClose ( "explorer.exe" ) Wend sleep(100) Run("explorer.exe") sleep(1000) If NOT ProcessExists("explorer.exe") Then Run("explorer.exe") This is a rather violent way to apply your settings though since it is ending explorer.exe. This however will force explorer to completely re-read everything from the registry. I don't know if this is what you were looking for. I have the same problem, and can't find anything else. Restart Windows Explorer - it's working, but... it's really wrong. It must be the way to refresh settings, because when we change settings through Explorer's GUI interface, they working immediatly. Probably, only professional programmers know this. If somebody can help, please write here. At any time. Thank you. I agree with Shaggy. This is REALLY wrong. It would be my absolute last resort. I'm posting the solution so nobody else is tempted to try that kludge. Fortunately, MS actually provides a routine for such updates. Look at http://msdn.microsoft.com/en-us/library/windows/desktop/bb762118(v=vs.85).aspx. As stated by MS, "An application should use this function if it performs an action that may affect the Shell." After writing a new icon association to the registry, I call this function using the following line: SHChangeNotify SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0&, 0& (Function and constant declarations omitted from this example. See the MS reference.) The icons are then refreshed for both the desktop and all instances of explorer. 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