Re: CopyFolder logon script Windows 2003 Server

From: Al Dunbar [MS-MVP] (alan-no-drub-spam_at_hotmail.com)
Date: 04/11/04


Date: Sun, 11 Apr 2004 09:59:36 -0600


"jblaze" <jham@roomfulexpress.com> wrote in message
news:c2a3c17.0404090626.778706ac@posting.google.com...
> Hi All,
>
> I'm new to the whole scriping thing and i'm trying to brush up on my
> rusty programming skills. I would like to create a script that will
> run at a user's logon that will copy there 'My documents' folder to a
> designated network share location.
>
> We will be upgrading our network to Windows 2003 Server in a few days
> and are hoping to centralizing user data on the fileserver (which will
> also be our PDC running Win 2k3 server).
>
> I will send an email to all of the users to move all of their
> necessary data to their 'My Documents' which will be copied to the
> network using the following script....
>
> **************************************************************************
>
> Dim objMyDocs
> Set objMyDocs = CreateObject("Scripting.FileSystemObject")
> If (objMyDocs.FolderExists("C:\Documents and Settings\john_h\My
> Documents")) Then
> objMyDocs.CopyFolder "C:\Documents and Settings\john_h\My
> Documents", "\\Server1\Users\Main Office Users\%username%"
> Else
> WScript.Echo("Folder does not exist")
> End if
>
***************************************************************************
>
> when testing this script it returns a 'folder does not exist'. I'm
> certain that this folder exists. Obviously, I could replace
> '%username%' with the actual username, but that wouldn't be very
> useful.

But isn't that exactly what "john_j" is in the rest of your script?

> If anyone could tell me why this isn't working I would
> greatly appreciate it.

The File System Object does not expand environment variables in filenames,
because environment variable substitution is not in the domain of the file
system. Rather, this is a service provided by various command processors
(CMD.EXE, command.com), and/or perhaps as understood by some individual
commands.

You could use the .expandenvironmentstrings method of the WshShell object,
or, more directly, the .username property of the WshNetwork object to build
the filename/filepath strings you pass to the various FSO methods.

Another thing I would consider would be to use the .specialfolders method
(property?) to locate the user's my documents folder, which, theoretically,
could be named differently or located elsewhere:

    set shell = createobject("wscript.shell")
    mydocpath = shell.specialfolders("My Documents")

> Also, is there a way to have these script only run once for each user.

Simplest would be to check to see if the user's folder already exists on the
server share. If not, then copy.

> I wouldn't want this to run everytime a user logs in. But to make
> sure that these folders get migrated I would have to keep this script
> in place for a coupld days.....any ideas????

If your script runs only once per user, any changes they make to their local
documents or new documents they create will be lost, will they not?

A few other points for you to consider:

- How long do you think the script will need to be in operation before you
are guaranteed that all user documents have been copied? Mathematically (and
from my practical experience) it can be much longer than a few days. We have
people on maternity leave for a year, for one example. You might consider
writing a script to examine the server share and produce a list of those
whose files have not yet been processed.

- Do your users each use only one computer, or is there a chance that some
will have important documents on more than one computer? If this is a
possibility, then consider adding the computername as an element of the path
where the files are stored on the share.

- In production, your script should give some error message more informative
to the user than: "folder does not exist". It needn't go into any gory
detail, but could be something like: "There is a problem saving your
documents to the server. Please contact the IT department who can assist
you.".

A bit of a task you have there for yourself. But imagine how great it will
be for you (and your users) when their documents are managed solely on the
file server. Have you given any thought as to how you will prevent them from
storing their files on local hard drives? We have a departmental policy
against the practice, but no technical means to prevent it.

/Al



Relevant Pages

  • Re: filename is too long or contains illegal caracters
    ... server because I can publish the same web site over the same connection using ... past told me they don't know anything about Publisher). ... When I ADD NETWORK LOCATION, I get "folder ... Per you suggestion, I tried to Add a Network Location in "Computer", ...
    (microsoft.public.publisher.webdesign)
  • Re: SBS Add User wizard problem
    ... It turned out that the reason was script's folder ... The rest of settings are ok (it means they are like You said they ... Say I have a script on server which checks every 15 ...
    (microsoft.public.windows.server.sbs)
  • Re: "you might not have permission to use this network resource"
    ... Contact the administrator of this server to find out if you> have ... Networking, Internet, Routing, VPN Troubleshooting on ... How to Setup Windows, Network, VPN & Remote Access on ... When I attempt to access a private folder or a public folder ...
    (microsoft.public.windows.vista.networking_sharing)
  • Re: HELP ME PLEASE! Very bad performance of file sharing
    ... I ran the Microsoft Network Monitor on both machines and ... folder contents from Server. ... File Monitor showed no activity (perhaps folder contents are read ... On the client File Monitor showed explorer.exe reading the folder. ...
    (microsoft.public.windowsxp.network_web)
  • Re: DHCP Reservation issues
    ... but what about your login script details/reasons for doing this/etc? ... You may be able to set up your network more efficiently if you provide ... new problem I have is that the SBS server where the DHCP ... even though I set a reservation for them in the DHCP console ...
    (microsoft.public.windows.server.sbs)

Loading