VBS copy folder to variable destination

  • Thread starter Thread starter T T
  • Start date Start date
T

T T

Hi
I need to copy a folder from a network share (pre
determined) to a variable folder on my C: drive.
I have a script that does this to set location but when it
comes to a variable destination I have no idea how to do
it.
My variable destination is: c:\Documents and Settings\
Username\Application data\Microsoft\Templates.

Username is the unknown variable.

Any assistance would be appreciated.

Cheers,
 
Hi
I need to copy a folder from a network share (pre
determined) to a variable folder on my C: drive.
I have a script that does this to set location but when it
comes to a variable destination I have no idea how to do
it.
My variable destination is: c:\Documents and Settings\
Username\Application data\Microsoft\Templates.

Username is the unknown variable.

Any assistance would be appreciated.

Cheers,


This should really be posted on a VB related newsgroup. But before you do,
you will want to clarify some things:

1) Do you need only the Currently logged in user
or
2) To loop through all users on the machine
or
3) whatever else you had in mind
 
T said:
I need to copy a folder from a network share (pre
determined) to a variable folder on my C: drive.
I have a script that does this to set location but when it
comes to a variable destination I have no idea how to do
it.
My variable destination is: c:\Documents and Settings\
Username\Application data\Microsoft\Templates.

Username is the unknown variable.

Hi

FYI, you should ask this type of vbscript questions in the newsgroup
microsoft.public.scripting.wsh...

For the current user, this is how to do it:

sDestination = "%APPDATA%\Microsoft\Templates"

Set oShell = CreateObject("Wscript.Shell")
sDestination = oShell.ExpandEnvironmentStrings(sDestination)
WScript.Echo sDestination


If you want it to work on NT 4.0 as well, use this instead:

sDestination = "%USERPROFILE%\Application Data\Microsoft\Templates"


WSH 5.6 documentation (local help file) can be downloaded from here if you
haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp
 
Best way to do this is read the Registry for the AppData value in the Shell Folders key.

Set ws = CreateObject("WScript.Shell")
sAppData = ws.RegRead("HKCU\Software\Microsoft\Windows\Current" & _
"Version\Explorer\Shell Folders\AppData")
sTemplates = sAppData & "\Microsoft\Templates"
WScript.Echo sTemplates

Follow-up questions should be directed to one of the scripting groups such as microsoft.public.scripting.vbscript. If you don't have the Windows Script documentation, you really need that as a reference if you are going to do scripting, http://www.microsoft.com/downloads/...48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en.

--

Bill James
Microsoft MVP - Shell/User

Win9x VBScript Utilities » www.billsway.com/vbspage/
Windows Tweaks & Tips » www.billsway.com/notes_public/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top