Jump to content

how can you make desktop refresh automatically?

Recommended Posts

there are some changes after RunOnceEx happens that can only be seen if the desktop refreshes(the registry option for showing file extensions.)

does anyone know a quick VBS script that could refresh the desktop? ive been learning some VBS, i can do appactivate and some basic stuff, but i can't find a resource that tells how to 'activate' the desktop and then from there i could perform a sendkey f5.

Link to comment
Share on other sites

Well i don't know vbs but i know that desktop is a "device context" from the explorer.exe service so u can go to task manager and "end task" the explorer -- it will close the GUI and restart it (maybe that should work) -- if not a restart always does it.

U can restart even during GUIRunOnce and u can kill almost any service using taskkill app in windows or get pskill from sysinternals.com.

U might want to get a good habit of testing first then applying :)

Edited by wolfshade
Link to comment
Share on other sites

argh, for some reason after i run this:

pskill explorer.exe

start exporer.exe

my documents window pops in explore mode. i have no clue why. i didn't tell it to. and if i do the above using the gui the my documents window doesnt pop up. any ideas? im trying to make this as clean as possible so that window isn't acceptable

Link to comment
Share on other sites

yes but u lose your settings

some tweak programs (xptweak I think) manages to restart the shell I still couldn't find how it does that.

but there are other ways..

ok the reason for my documents poping up is :

u have 2 explorer.exe's running(obviously at sepeare memories)

after u close one explorer.exe and re open it it will give u the my documents folder

in order to get back the full explorer u need to close both..

Link to comment
Share on other sites

found it :

the WM_SETTINGCHANGE message is used to to refresh the windowssettings,

(as set in the registry e.g. system variables)

Declare Auto Function SendMessageTimeout Lib "User32" ( _

ByVal hWnd As Integer, _

ByVal Msg As UInt32, _

ByVal wParam As Integer, _

ByVal lParam As Integer, _

ByVal fuFlags As UInt32, _

ByVal uTimeout As UInt32, _

ByRef lpdwResult As IntPtr _

) As Long



Private Const SMTO_ABORTIFHUNG = &H2

Public Sub EnvRefresh ( )

Dim dwResult As IntPtr '

SendMessageTimeout(HWND_BROADCAST, _


0, 0, _


Convert.ToUInt32(5000), _



gr /\/\o\/\/

Link to comment
Share on other sites

  • 2 years later...

Can you explain the above code in a little more detail?

What settings are you in danger of losing when you kill explorer.exe and how does the above code remedy this problem?

Should you kill explorer.exe and [i]then[/i] run the above code in a *.vbs file or vice versus?

Link to comment
Share on other sites


This refreshes the desktop, but it doesn't refresh the taskbar.

I'm adding additional items to quick-launch and they only show once you've logged out and logged back in again.

Ending a restarting explorer.exe works, your code doesn't.

Thanks for your suggestion though.

Link to comment
Share on other sites

the code /\/\o\/\/ posted cant be used in vbs, it is VB code
the only way i have seen to make API calls from vbs is using a 3rd party activex control like wshAPItoolkit.ocx
you dont have to register the control if you run your script from the same folder as the ocx

you might also try searching the web for something like 'refreshscreen.exe' or something similar Edited by selyb
Link to comment
Share on other sites

What about something like this?[code]Set Wmi = getobject("winmgmts:")
sQuery = "select * from win32_process where name='explorer.exe'"
Set processes = Wmi.execquery(sQuery)
For each process in processes
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.

  • Create New...