Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - How to apply changes to "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal" (My Document)?

Reply
 
Old 05-24-2008   #1 (permalink)
GM


 
 

How to apply changes to "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal" (My Document)?

I developed a small script that changes the key relative to "My Documents"
folder AFTER the user logon.
It is a win2003 server with citrix metaframe, so many user are connected at
the same time (that's why i have to get the right explorer pid to kill)
I noticed that after changing this key, the actual folder pointed by "My
Documents" is not affected unless the user log off and then back on.
Another way to apply the change, beside logging off/on, is to kill
"explorer.exe" and run it again.

This is the code:

Dim WSHShell
Set WSHShell = CreateObject("WScript.Shell")
strComputer = "."

Set objWMIService = GetObject("winMgmts:\\localhost")
Set colItems = objWMIService.ExecQuery("Select * From Win32_Process where
Name='explorer.exe'")
Dim strUserName, strDomain, pid, base

base=WScript.Arguments.Item(0)

For Each objItem in colItems

objItem.GetOwner strUser, strDomain

If (strUser=WSHShell.ExpandEnvironmentStrings("%USERNAME%")) Then
pid=objItem.ProcessID
End If

Next

WSHShell.RegWrite
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User
Shell Folders\Personal", "w:\firma\"& base
WSHShell.Run "taskkill /pid "&pid&" /f"
WSHShell.Run "explorer.bat" 'runs explorer.exe

But i would like to find a way to apply this change without such brutal
killing.. anyone has an idea on how doing this?

Thank you for your consideration!



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Personal User Shell Folders Tutorials
Personal User Shell Folders - Move Location Tutorials
Personal folders show "Small Icons" view Vista file management
Windows Explorer: How to force ALL folders to use "All Items" template rather than "Pictures & Videos" Vista General
"User's Files" folder and Shell Folders like Documents, Desktop, M Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46