res0ew3q
Tue Jan 29 11:47:20 CST 2008
On Jan 28, 7:44=A0pm, Tom Lavedas <tglba...@cox.net> wrote:
> On Jan 28, 1:12 pm, res0e...@verizon.net wrote:
>
>
>
>
>
> > On Jan 25, 12:26 pm, Tom Lavedas <tglba...@cox.net> wrote:
>
> > > On Jan 25, 1:32 pm, res0e...@verizon.net wrote:> hi there,
>
> > > > I am a verybasic scripter and am in need of some guidence. =A0I 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. =A0What 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 . =A0I 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. =A0bel=
ow
> > > > is my attempt at creating what I needed. =A0Please no laughing :). =
=A0Any
> > > > 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. =A0It is really only useful if you're ready to write th=
e
> > > code needed to handle resulting errors within the script. =A0In 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. =A0It ca=
n
> > > be reused.
>
> > > Environment variables need to be expanded for use in script, unlike in=
> > > batch procedures. =A0I found the USERPROFILE useful, but since it
> > > contains the USERNAME, that variable is redundant. =A0You may also wan=
t
> > > 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 =3D True
>
> > > set oWS =3D CreateObject("Wscript.Shell")
>
> > > strFldr=3D"C:\temp"
> > > sUserProfile =3D oWS.ExpandEnvironmentStrings("%userprofile%")
>
> > > set objFSO=3DCreateObject("Scripting.FileSystemObject")
>
> > > strFldr =3D strFldr & Split(sUserProfile, ":")(1) ' removes C:
> > > sBUPath =3D ""
> > > for each subfldr in Split(strFldr, "\")
> > > =A0 if sBUPath =3D "" Then
> > > =A0 =A0 sBUPath =3D subfldr
> > > =A0 else
> > > =A0 =A0 sBUPath =3D sBUPath & "\" & subfldr
> > > =A0 if not objFSO.FolderExists(sPath) then _
> > > =A0 =A0 objFSO.CreateFolder sPath
> > > =A0 end if
> > > next
>
> > > objFSO.CopyFolder sUserProfile _
> > > =A0 & "\Application Data\Microsoft\Internet Explorer\Quick Launch", _
> > > =A0 sPath & "\quicklaunch" , OverWriteFiles
>
> > > objFSO.CopyFolder sUserProfile & "\Desktop", _
> > > =A0 sPath & "\Desktop", OverWriteFiles
>
> > > objFSO.CopyFolder sUserProfile & "\Favorites", _
> > > =A0 sPath & "\Favorites", OverWriteFiles
>
> > > Tom Lavedas
> > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
http://members.cox.net/tglbatch/wsh/
>
> > Thank you for the script. =A0I have taken it as is and copied it in to a=
> > VBS file. =A0I an getting an invalid procedure call or argument in line
> > 24,5 =A0 =A0"objFSO.CreateFolder (sPath)". =A0I have been trying to figu=
re
> > out how to fix it , but am not having any luck. =A0I hate to be a PIA,
> > but what is wrong with the satement? =A0and again thank you for your
> > help with this.
>
> > Daryl =A0VanLuvanee
>
> I'm sorry, that was my error. =A0I did an on the fly edit as I posted
> and missed on line. =A0That line and the one befor it should read ...
>
> =A0 =A0if not objFSO.FolderExists(sBUPath) then _
> =A0 =A0 =A0objFSO.CreateFolder sBUPath
>
> That is change sPath to read sBUPath wherever it appears.
>
> Tom Lavedas
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D- Hide quoted text -
>
> - Show quoted text -
You da man. That worked like a dream. I'm not worthy to be in your
presence :D
Thank you very much for your help.
Daryl