Re: Need help for a new scripter
- From: Tom Lavedas <tglbatch@xxxxxxx>
- Date: Mon, 28 Jan 2008 19:44:13 -0800 (PST)
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
===========
.
- References:
- Re: Need help for a new scripter
- From: Tom Lavedas
- Re: Need help for a new scripter
- Prev by Date: Re: VB Script for Legato Networker
- Next by Date: Re: some further comments...
- Previous by thread: Re: Need help for a new scripter
- Next by thread: Re: Need help for a new scripter
- Index(es):
Relevant Pages
|