Changing My Documents in logon script

T

Tom Del Rosso

I have users' "My Documents" folders pointing to their own document
folders on a server. I did that with "My Documents" properties, but it
doesn't work if a user logs on to a different workstation.

I'd like to make logon scripts to map their drives and point their
default documents folder to the right place, but is the latter possible?
 
P

Patrice Valiquette

Try something like this on your logon script. Hope it help.

Set objWshNet = WScript.CreateObject("WScript.Network")

strUserFolder= fcnUserName

objWshNet.MapNetworkDrive "U:",\\ServerName\strUserFolder



'***************************************************************************
******************
'fcnUserName
'***********
Function fcnUserName()

' Wait for the user to connect...
on error resume next

While strUserName = ""
Set objWshNet = CreateObject("WScript.Network")
on error resume next
strUserName = UCASE(objWshNet.UserName)
Wscript.sleep(200)
Set objWshNet = Nothing
Wend
fcnUserName = strUserName

End Function

'***************************************************************************
 
T

Tom Del Rosso

In Patrice Valiquette typed:
Try something like this on your logon script. Hope it help.

Set objWshNet = WScript.CreateObject("WScript.Network")

strUserFolder= fcnUserName

objWshNet.MapNetworkDrive "U:",\\ServerName\strUserFolder
[snip]

Thank you very much. Does the variable strUserFolder refer to the "My
Documents" folder on the desktop? I can't find a reference that says
so.
 
P

Patrice Valiquette

Note :Group policy are ok with W2K and WXp but won't work with W9X clients.

strUserFolder refer to the home folder of the user on the server.

I think I understand better what you want to do...so I add little to the
script.

This is a part of logon script I do use on a network with 2000 computers. It
work well with W9X, NT, W2K, WXP clients.


To use this script you should have a share folder on your server for every
user who log on.
If the logon name of the user is jerry then you should have a share folder
on the server named jerry and on witch the user have access right. =
strUserFolder
You should also create a sub folder named My Documents under eachs User
folders (Home)

This script map a drive "U:" to the User home folder (\\ServerName\UserName)
and redirect the system folder My Documents to the User home folder on the
server.

Hope it help

Patrice


Set objWshNet = WScript.CreateObject("WScript.Network")
Set objShell = Wscript.CreateObject("Wscript.Shell")
strUserFolder= fcnUserName

objWshNet.MapNetworkDrive "U:",\\ServerName\strUserFolder

objShell.RegWrite
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
Folders\Personal","U:\My Documents"
objShell.RegWrite
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell
Folders\Personal","U:\My Documents"

'***************************************************************************
******************
'fcnUserName
'***********
Function fcnUserName()

' Wait for the user to connect...
on error resume next

While strUserName = ""
Set objWshNet = CreateObject("WScript.Network")
on error resume next
strUserName = UCASE(objWshNet.UserName)
Wscript.sleep(200)
Set objWshNet = Nothing
Wend
fcnUserName = strUserName

End Function

'***************************************************************************


Tom Del Rosso said:
In Patrice Valiquette typed:
Try something like this on your logon script. Hope it help.

Set objWshNet = WScript.CreateObject("WScript.Network")

strUserFolder= fcnUserName

objWshNet.MapNetworkDrive "U:",\\ServerName\strUserFolder
[snip]

Thank you very much. Does the variable strUserFolder refer to the "My
Documents" folder on the desktop? I can't find a reference that says
so.
 
J

Jetro

Appropriate policy is created for the downlevel members (9x/Me and/or NT) of
W2k domain using Policy Editor (poledit.exe). Actually, folder redirection
policy modifies the keys in
'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserShellFolders'
and one-line .reg file also can do the trick, if that's the only policy
someone needs.

BTW, NT w/o ActiveDesktop and W95 systems don't have 'MyDocuments'.
 
T

Tom Del Rosso

In Patrice Valiquette typed:
Note :Group policy are ok with W2K and WXp but won't work with W9X
clients.

This is an all-XP LAN, so in this case would you agree with Jetro that I
should use group policy?

To use this script you should have a share folder on your server for
every user who log on.
If the logon name of the user is jerry then you should have a share
folder on the server named jerry and on witch the user have access
right. = strUserFolder
You should also create a sub folder named My Documents under eachs
User folders (Home)

This script map a drive "U:" to the User home folder

That's exactly the way I have them set up now, with U:\My Documents
where U: is mapped to the "user" folder.

(\\ServerName\UserName) and redirect the system folder My Documents
to the User home folder on the server.

That's great Patrice. I'll test it on Monday. Thank you!
 
T

Tom Del Rosso

In Jetro typed:
Appropriate policy is created for the downlevel members (9x/Me and/or
NT) of W2k domain using Policy Editor (poledit.exe). Actually, folder
redirection policy modifies the keys in
'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserShellFolder
s'
and one-line .reg file also can do the trick, if that's the only
policy someone needs.

There are no group policies set up as yet, but the boss did talk once
about making floppies R/O, so he might want more policies in the future.

BTW, NT w/o ActiveDesktop and W95 systems don't have 'MyDocuments'.

How do you mean? They have the folder of course, but do you mean it's
not defined in Group Policy?
 
J

Jetro

W95 and NT w/o AD don't have an object 'My Documents' on the Desktops and
downlevel default directory is %userprofile%\Personal. That was changed in
W2k and XP to %userprofile%\My Documents; Nevertheless, the UserShellFolders
key's still named 'Personal'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top