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

On Error Resume Next
Dim objFSO

'new folder to create. The parent folder must already exists
strFldr="C:\temp"

set objFSO=CreateObject("Scripting.FileSystemObject")

objFSO.CreateFolder(strFldr)

set objFSO=Nothing

'Create Folder
On Error Resume Next
rem dim objFSO

'new folder to create. The parent folder must already exists
strFldr="C:\temp\%userprofile%"

set objFSO=CreateObject("Scripting.FileSystemObject")

objFSO.CreateFolder(strFldr)

set objFSO=Nothing


Const OverWriteFiles = True

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\Documents and Settings\%username%\Application
Data\Microsoft\Internet Explorer\Quick Launch" , "C:\temp\%username%
\quicklaunch" , OverWriteFiles

On Error Resume Next


Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\Documents and Settings\%username%\desktop" , "C:
\temp\%username%\desktop" , OverWriteFiles

On Error Resume Next


Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\Documents and Settings\%username%\Favorites" ,
"C:\temp\%username%\Favorites" , OverWriteFiles

On error Resume Next

Re: Need help for a new scripter by Tom

Tom
Fri Jan 25 14:26:11 CST 2008

On Jan 25, 1:32 pm, res0e...@verizon.net 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/

Re: Need help for a new scripter by ThatsIT

ThatsIT
Sun Jan 27 07:34:59 CST 2008

here are a couple of things that may help you

how to get a user name of the user

Set net = CreateObject("WScript.Network")
WScript.Echo net.UserName

How to get the path of a special folder

Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
WScript.Echo strDesktop


list of special folders you can get this way

AllUsersDesktop
AllUsersStartMenu
AllUsersPrograms
AllUsersStartup
Desktop
Favorites
Fonts
MyDocuments
NetHood
PrintHood
Programs
Recent
SendTo
StartMenu
Startup
Templates





<res0ew3q@verizon.net> wrote in message
news:f10807c5-c871-4941-8c03-ad4f8aa7a9ff@q21g2000hsa.googlegroups.com...
> 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
>
> On Error Resume Next
> Dim objFSO
>
> 'new folder to create. The parent folder must already exists
> strFldr="C:\temp"
>
> set objFSO=CreateObject("Scripting.FileSystemObject")
>
> objFSO.CreateFolder(strFldr)
>
> set objFSO=Nothing
>
> 'Create Folder
> On Error Resume Next
> rem dim objFSO
>
> 'new folder to create. The parent folder must already exists
> strFldr="C:\temp\%userprofile%"
>
> set objFSO=CreateObject("Scripting.FileSystemObject")
>
> objFSO.CreateFolder(strFldr)
>
> set objFSO=Nothing
>
>
> Const OverWriteFiles = True
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> objFSO.CopyFolder "C:\Documents and Settings\%username%\Application
> Data\Microsoft\Internet Explorer\Quick Launch" , "C:\temp\%username%
> \quicklaunch" , OverWriteFiles
>
> On Error Resume Next
>
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> objFSO.CopyFolder "C:\Documents and Settings\%username%\desktop" , "C:
> \temp\%username%\desktop" , OverWriteFiles
>
> On Error Resume Next
>
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> objFSO.CopyFolder "C:\Documents and Settings\%username%\Favorites" ,
> "C:\temp\%username%\Favorites" , OverWriteFiles
>
> On error Resume Next


Re: Need help for a new scripter by Adam

Adam
Sun Jan 27 08:19:25 CST 2008

Hi,

Your news in the thread are also helpful to me.
Are there any advices for beginners like those
available anywhere in the Internet? If so, please
give the address.
Or maybe any good VBS manual for beginners?

Regards,
Adam


> here are a couple of things that may help you
>
> how to get a user name of the user
>
> Set net = CreateObject("WScript.Network")
> WScript.Echo net.UserName
>
> How to get the path of a special folder
>
> Set WshShell = WScript.CreateObject("WScript.Shell")
> strDesktop = WshShell.SpecialFolders("Desktop")
> WScript.Echo strDesktop
>
>
> list of special folders you can get this way
>
> AllUsersDesktop
> AllUsersStartMenu
> AllUsersPrograms
> AllUsersStartup
> Desktop
> Favorites
> Fonts
> MyDocuments
> NetHood
> PrintHood
> Programs
> Recent
> SendTo
> StartMenu
> Startup
> Templates
>
>
>
>
>
> <res0ew3q@verizon.net> wrote in message
> news:f10807c5-c871-4941-8c03-ad4f8aa7a9ff@q21g2000hsa.googlegroups.com...
>> 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
>>
>> On Error Resume Next
>> Dim objFSO
>>
>> 'new folder to create. The parent folder must already exists
>> strFldr="C:\temp"
>>
>> set objFSO=CreateObject("Scripting.FileSystemObject")
>>
>> objFSO.CreateFolder(strFldr)
>>
>> set objFSO=Nothing
>>
>> 'Create Folder
>> On Error Resume Next
>> rem dim objFSO
>>
>> 'new folder to create. The parent folder must already exists
>> strFldr="C:\temp\%userprofile%"
>>
>> set objFSO=CreateObject("Scripting.FileSystemObject")
>>
>> objFSO.CreateFolder(strFldr)
>>
>> set objFSO=Nothing
>>
>>
>> Const OverWriteFiles = True
>>
>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> objFSO.CopyFolder "C:\Documents and Settings\%username%\Application
>> Data\Microsoft\Internet Explorer\Quick Launch" , "C:\temp\%username%
>> \quicklaunch" , OverWriteFiles
>>
>> On Error Resume Next
>>
>>
>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> objFSO.CopyFolder "C:\Documents and Settings\%username%\desktop" , "C:
>> \temp\%username%\desktop" , OverWriteFiles
>>
>> On Error Resume Next
>>
>>
>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> objFSO.CopyFolder "C:\Documents and Settings\%username%\Favorites" ,
>> "C:\temp\%username%\Favorites" , OverWriteFiles
>>
>> On error Resume Next
>

Re: Need help for a new scripter by ThatsIT

ThatsIT
Sun Jan 27 12:03:51 CST 2008

well there is my site
http://dev.thatsit.net.au/wsh/

and of cause Microsoft
http://www.microsoft.com/technet/scriptcenter/default.mspx



"Adam" <atr@pa.pl> wrote in message news:fni48n$cdk$1@nemesis.news.tpi.pl...
> Hi,
>
> Your news in the thread are also helpful to me.
> Are there any advices for beginners like those
> available anywhere in the Internet? If so, please
> give the address.
> Or maybe any good VBS manual for beginners?
>
> Regards,
> Adam
>
>
>> here are a couple of things that may help you
>>
>> how to get a user name of the user
>>
>> Set net = CreateObject("WScript.Network")
>> WScript.Echo net.UserName
>>
>> How to get the path of a special folder
>>
>> Set WshShell = WScript.CreateObject("WScript.Shell")
>> strDesktop = WshShell.SpecialFolders("Desktop")
>> WScript.Echo strDesktop
>>
>>
>> list of special folders you can get this way
>>
>> AllUsersDesktop
>> AllUsersStartMenu
>> AllUsersPrograms
>> AllUsersStartup
>> Desktop
>> Favorites
>> Fonts
>> MyDocuments
>> NetHood
>> PrintHood
>> Programs
>> Recent
>> SendTo
>> StartMenu
>> Startup
>> Templates
>>
>>
>>
>>
>>
>> <res0ew3q@verizon.net> wrote in message
>> news:f10807c5-c871-4941-8c03-ad4f8aa7a9ff@q21g2000hsa.googlegroups.com...
>>> 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
>>>
>>> On Error Resume Next
>>> Dim objFSO
>>>
>>> 'new folder to create. The parent folder must already exists
>>> strFldr="C:\temp"
>>>
>>> set objFSO=CreateObject("Scripting.FileSystemObject")
>>>
>>> objFSO.CreateFolder(strFldr)
>>>
>>> set objFSO=Nothing
>>>
>>> 'Create Folder
>>> On Error Resume Next
>>> rem dim objFSO
>>>
>>> 'new folder to create. The parent folder must already exists
>>> strFldr="C:\temp\%userprofile%"
>>>
>>> set objFSO=CreateObject("Scripting.FileSystemObject")
>>>
>>> objFSO.CreateFolder(strFldr)
>>>
>>> set objFSO=Nothing
>>>
>>>
>>> Const OverWriteFiles = True
>>>
>>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>>> objFSO.CopyFolder "C:\Documents and Settings\%username%\Application
>>> Data\Microsoft\Internet Explorer\Quick Launch" , "C:\temp\%username%
>>> \quicklaunch" , OverWriteFiles
>>>
>>> On Error Resume Next
>>>
>>>
>>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>>> objFSO.CopyFolder "C:\Documents and Settings\%username%\desktop" , "C:
>>> \temp\%username%\desktop" , OverWriteFiles
>>>
>>> On Error Resume Next
>>>
>>>
>>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>>> objFSO.CopyFolder "C:\Documents and Settings\%username%\Favorites" ,
>>> "C:\temp\%username%\Favorites" , OverWriteFiles
>>>
>>> On error Resume Next
>>


Re: Need help for a new scripter by Adam

Adam
Sun Jan 27 14:06:42 CST 2008

Thanks a lot.

Adam

U¿ytkownik "ThatsIT.net.au" <me@thatsit> napisa³ w wiadomo¶ci news:69B6D51E-7D22-47CD-B8DF-DB724039BDB5@microsoft.com...
> well there is my site
> http://dev.thatsit.net.au/wsh/
>
> and of cause Microsoft
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>
>
>
> "Adam" <atr@pa.pl> wrote in message news:fni48n$cdk$1@nemesis.news.tpi.pl...
>> Hi,
>>
>> Your news in the thread are also helpful to me.
>> Are there any advices for beginners like those
>> available anywhere in the Internet? If so, please
>> give the address.
>> Or maybe any good VBS manual for beginners?
>>
>> Regards,
>> Adam
>>
>>
>>> here are a couple of things that may help you
>>>
>>> how to get a user name of the user
>>>
>>> Set net = CreateObject("WScript.Network")
>>> WScript.Echo net.UserName
>>>
>>> How to get the path of a special folder
>>>
>>> Set WshShell = WScript.CreateObject("WScript.Shell")
>>> strDesktop = WshShell.SpecialFolders("Desktop")
>>> WScript.Echo strDesktop
>>>
>>>
>>> list of special folders you can get this way
>>>
>>> AllUsersDesktop
>>> AllUsersStartMenu
>>> AllUsersPrograms
>>> AllUsersStartup
>>> Desktop
>>> Favorites
>>> Fonts
>>> MyDocuments
>>> NetHood
>>> PrintHood
>>> Programs
>>> Recent
>>> SendTo
>>> StartMenu
>>> Startup
>>> Templates
>>>
>>>
>>>
>>>
>>>
>>> <res0ew3q@verizon.net> wrote in message news:f10807c5-c871-4941-8c03-ad4f8aa7a9ff@q21g2000hsa.googlegroups.com...
>>>> 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
>>>>
>>>> On Error Resume Next
>>>> Dim objFSO
>>>>
>>>> 'new folder to create. The parent folder must already exists
>>>> strFldr="C:\temp"
>>>>
>>>> set objFSO=CreateObject("Scripting.FileSystemObject")
>>>>
>>>> objFSO.CreateFolder(strFldr)
>>>>
>>>> set objFSO=Nothing
>>>>
>>>> 'Create Folder
>>>> On Error Resume Next
>>>> rem dim objFSO
>>>>
>>>> 'new folder to create. The parent folder must already exists
>>>> strFldr="C:\temp\%userprofile%"
>>>>
>>>> set objFSO=CreateObject("Scripting.FileSystemObject")
>>>>
>>>> objFSO.CreateFolder(strFldr)
>>>>
>>>> set objFSO=Nothing
>>>>
>>>>
>>>> Const OverWriteFiles = True
>>>>
>>>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>>>> objFSO.CopyFolder "C:\Documents and Settings\%username%\Application
>>>> Data\Microsoft\Internet Explorer\Quick Launch" , "C:\temp\%username%
>>>> \quicklaunch" , OverWriteFiles
>>>>
>>>> On Error Resume Next
>>>>
>>>>
>>>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>>>> objFSO.CopyFolder "C:\Documents and Settings\%username%\desktop" , "C:
>>>> \temp\%username%\desktop" , OverWriteFiles
>>>>
>>>> On Error Resume Next
>>>>
>>>>
>>>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>>>> objFSO.CopyFolder "C:\Documents and Settings\%username%\Favorites" ,
>>>> "C:\temp\%username%\Favorites" , OverWriteFiles
>>>>
>>>> On error Resume Next
>>>
>


Re: Need help for a new scripter by res0ew3q

res0ew3q
Mon Jan 28 12:12:01 CST 2008

On Jan 25, 12:26=A0pm, 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. =A0below
> > is my attempt at creating what I needed. =A0Please no laughing :). =A0An=
y
> > 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 the
> 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 can
> 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 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 =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=3Dhttp://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

Re: Need help for a new scripter by Tom

Tom
Mon Jan 28 21:44:13 CST 2008

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. 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
===========

Re: Need help for a new scripter by res0ew3q

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=3Dhttp://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

Re: Need help for a new scripter by Tom

Tom
Tue Jan 29 11:50:41 CST 2008

On Jan 29, 12:47 pm, res0e...@verizon.net wrote:
> On Jan 28, 7:44 pm, Tom Lavedas <tglba...@cox.net> wrote:
{snip}
>
> 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

Thanks. You're welcome. Glad I could help.

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