Copying a folder...

I need a vbscript to create a folder in C:\Program files, then copy a folder from a network share into that directory...

I also need to copy a lnk file from that folder to the users desktop...

Thanks!!
Marc_CoolAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

prashanthdCommented:
Try the following code...

Replace the folder paths and file name


Set objFSO = CreateObject("Scripting.FileSystemObject")

objfso.CreateFolder("C:\program files\test")

objfso.CopyFolder "\\servername\drive$\test1" "C:\program files\test\"

objfso.CopyFile "C:\program files\test\test.lnk" "C:\Documents and Settings\username\Desktop\"
0
Bill PrewCommented:
Is this really a solution needed for OS/2 ???

~bp
0
Bill PrewCommented:
Since the users desktop folder moved around a bit in Vista and Win7, I prefer to locate it dynamically.  Take a look at the following code as a solution.  Note though that while there is VBS support to locate the program files dynamically, this may or may not be the path you want on a Vista or Win7 machine, so I have hard coded your mentioned path for now.

' Define several needed constants
Const conNewFolder = "New Folder"
Const conFromFolder = "X:\Template"
Const conLinkFile = "Link To Copy.lnk"

' Create objects needed during script
Set objShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Locate path to users desktop
strDesktop = objShell.SpecialFolders("Desktop") & "\"

' Locate path to users program files
' strPrograms = objShell.SpecialFolders("Programs") & "\"
strPrograms = "c:\program files\"

' Create new folder
objfso.CreateFolder strPrograms & conNewFolder

' Copy base files over
objfso.CopyFolder conFromFolder, strPrograms & conNewFolder

' Copy link over
objfso.CopyFile conFromFolder & "\" & conLinkFile, strDesktop

Open in new window

~bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Marc_CoolAuthor Commented:
Sorry about that! No it is definitely NOT needed for OS2. That's a first time user mistake.

But thanks much for the code!!
0
TolomirAdministratorCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.