Page 1 of 1 1
Topic Options
#188321 - 2008-06-23 09:21 AM WriteValue donīt work me!!
Jlmartinez Offline
Getting the hang of it

Registered: 2008-05-20
Posts: 75
Loc: Sevilla, Spain
I have a script that modifies several registry keys of windows, it works all but this:

WriteValue ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Personal","D:\%username%\My Documents","REG_SZ")

It also change the key "User Shell Folders".
I killed the process "explorer.exe" before, and I launch it after all
Can you help me??? Thanks everyone.

Top
#188322 - 2008-06-23 10:52 AM Re: WriteValue donīt work me!! [Re: Jlmartinez]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
So the settings are being written to the registry but the changes are not reflected to the user’s environment? Some settings are effective immediately, others just require a reload and others require a reboot. I'm not sure about the settings you want to change but what happens after a reboot?
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#188324 - 2008-06-23 11:42 AM Re: WriteValue donīt work me!! [Re: Mart]
Jlmartinez Offline
Getting the hang of it

Registered: 2008-05-20
Posts: 75
Loc: Sevilla, Spain
When I reboot my pc, change donīt apply.
Key "User Shell Folders" settings is effective immediately, i want to redirect the folder "My documents" to server and I need to change this two keys.
What is wrong???
Can I do otherwise?

Top
#188325 - 2008-06-23 11:56 AM Re: WriteValue donīt work me!! [Re: Jlmartinez]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
I'm going to ask it again. Are the setting actually written to the registry?

An other way would be to use a GPO for this.
Redirecting the My Documents Folder for All Users in Windows 2000
Group Policy - Folder Redirection for Windows Server 2003
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#188326 - 2008-06-23 12:38 PM Re: WriteValue donīt work me!! [Re: Mart]
Jlmartinez Offline
Getting the hang of it

Registered: 2008-05-20
Posts: 75
Loc: Sevilla, Spain
Sorry, no, the setting arenīt actually written to the registry
Top
#188327 - 2008-06-23 01:43 PM Re: WriteValue donīt work me!! [Re: Jlmartinez]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Ok. The writevalue function should return an error code if it is the offending part of your script. Adding some debugging lines on strategic places in the script always helped me out.
Can you add the code below directly after the writevalue line and let us know what you get back?

 Code:
?@error
?@serror
sleep 10
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#188328 - 2008-06-23 04:45 PM Re: WriteValue donīt work me!! [Re: Mart]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Instead of using %username%, why not replace it with @userid?
 Code:
WriteValue ("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Personal","D:\"+@userid+"\My Documents","REG_SZ")

Thanks,

Kent Dyer
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#188330 - 2008-06-23 11:34 PM Re: WriteValue donīt work me!! [Re: Kdyer]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You should NEVER use either %username% or @userid to build out the path. Pull the path directly from the registry.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#188331 - 2008-06-24 12:43 AM Re: WriteValue donīt work me!! [Re: Les]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
@Les, He's just defining his own path for the My Documents folder. What would be the alternative here?
_________________________
(... better days ahead)

Top
#188332 - 2008-06-24 01:28 AM Re: WriteValue donīt work me!! [Re: Allen]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... if he is creating the folder structure and can guarantee that the UserID NEVER changes, then fine but I often see UserIDs change. I suppose if the person renaming users is the same person naming the folders then they could keep them in sync but if not, problems are inevitable.

If the folder is setup as a one-time thing, the path could be written only once to the HKCU part of the registry and not every time the user logs on. That way a name change won't change the path since HKCU is mapped by SID.

Alternately, maybe a relative path pointing to the user's home folder depending on if it is immune to name changes, or use the SID for the folder name.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.073 seconds in which 0.038 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org