Re: Need help for a new scripter



On Jan 28, 1:12 pm, res0e...@xxxxxxxxxxx wrote:
On Jan 25, 12:26 pm, Tom Lavedas <tglba...@xxxxxxx> wrote:



On Jan 25, 1:32 pm, res0e...@xxxxxxxxxxx wrote:> hi there,

I am a verybasic scripter and am in need of some guidence. I have
been tasked with comming up with a script that will allow me to move
folders from the logged in user's profile to a share on the network
and to create a folder the same name as the user it was copied from.
I have found some snipets that have allowed me to copy the files I
want, but need to know the exact path. What I am looking for is a way
to get the logged on user or last logged on users name, create a
folder on a share on the network or even the local drive and copy
folders from the profile into it . I can create the folders thru a
script and move files, but don't want to have to write 75 different
scripts for each indiviual computer to get the folders moved. below
is my attempt at creating what I needed. Please no laughing :). Any
help or input would be greatly appreated.

Daryl

{snip}

A few comments:

Remove or comment out the ON ERROR statements (only one needed) until
you are positive the script will run the way it is intended - and
maybe forever. It is really only useful if you're ready to write the
code needed to handle resulting errors within the script. In all
other instances it just hides the problems making finding solutions
that mush harder.

The objFSO needs to be created just once in this application. It can
be reused.

Environment variables need to be expanded for use in script, unlike in
batch procedures. I found the USERPROFILE useful, but since it
contains the USERNAME, that variable is redundant. You may also want
to look at the documentation for the SpecialFolders function for
another way to locate the desired folders.

Finally, you realize this script can only be used once on any given
machine as written, since the CopyFolder method used this way fails if
the destination already exists.

Having said that, try this ...

Dim objFSO, oWS
Dim sUserProfile, sBUPath
Const OverWriteFiles = True

set oWS = CreateObject("Wscript.Shell")

strFldr="C:\temp"
sUserProfile = oWS.ExpandEnvironmentStrings("%userprofile%")

set objFSO=CreateObject("Scripting.FileSystemObject")

strFldr = strFldr & Split(sUserProfile, ":")(1) ' removes C:
sBUPath = ""
for each subfldr in Split(strFldr, "\")
if sBUPath = "" Then
sBUPath = subfldr
else
sBUPath = sBUPath & "\" & subfldr
if not objFSO.FolderExists(sPath) then _
objFSO.CreateFolder sPath
end if
next

objFSO.CopyFolder sUserProfile _
& "\Application Data\Microsoft\Internet Explorer\Quick Launch", _
sPath & "\quicklaunch" , OverWriteFiles

objFSO.CopyFolder sUserProfile & "\Desktop", _
sPath & "\Desktop", OverWriteFiles

objFSO.CopyFolder sUserProfile & "\Favorites", _
sPath & "\Favorites", OverWriteFiles

Tom Lavedas
===========http://members.cox.net/tglbatch/wsh/

Thank you for the script. I have taken it as is and copied it in to a
VBS file. I an getting an invalid procedure call or argument in line
24,5 "objFSO.CreateFolder (sPath)". I have been trying to figure
out how to fix it , but am not having any luck. I hate to be a PIA,
but what is wrong with the satement? and again thank you for your
help with this.

Daryl VanLuvanee

I'm sorry, that was my error. I did an on the fly edit as I posted
and missed on line. That line and the one befor it should read ...

if not objFSO.FolderExists(sBUPath) then _
objFSO.CreateFolder sBUPath

That is change sPath to read sBUPath wherever it appears.

Tom Lavedas
===========
.



Relevant Pages

  • Re: CLean out all users Temp Dir Folder
    ... I've built the script you need with ScriptAhead a tool we have just ... ' Get Folders that match the following criteria: ... Sub AppendCollectionToArray ... GetSubFolders strFolderName ...
    (microsoft.public.windows.server.scripting)
  • RE: Deleting 1 folder across multiple Mailboxes
    ... I too am looking to delete about 30 folders that came over from a linux ... are over 200 mailboxes that is a whole lot of click delete click delete. ... I found this script, but it seems to only work on Exchange 2000. ... Dim objCommand, objConnection, strBase, strFilter, strAttributes ...
    (microsoft.public.exchange.admin)
  • Re: Script for Folder View Customization - Beta
    ... but vbcsript's capabilities are equal to or better than our ... Should be no problem for folders such as "c:\docs & ... the file system object, SAPI.SpFileStream, SAPI.Voice, etc. ... I also wrote a script that recurses a folder hierarchy and calls SAPI5 ...
    (microsoft.public.scripting.vbscript)
  • Re: Deny _WRITE_ access to a file
    ... First of all, regarding LOGON SCRIPT, the mistake is mine: ... and folders they don't ... "Everyone", so even if "RestrictedG" has only READ acces, as they are ...
    (microsoft.public.windows.server.security)
  • Re: Deny _WRITE_ access to a file
    ... First of all, regarding LOGON SCRIPT, the mistake is mine: ... and folders they don't ... "Everyone", so even if "RestrictedG" has only READ acces, as they are ...
    (microsoft.public.security)