vbs script to copy folder and create dir and folder if not exist

Hi, i require a vbs script for the following,please help ,thank you:
if not exist c:\rock md c:\rock
if not exist copy  c:\windows\ copy \\networkshare\xx.doc c:\windows\ /Y
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.

Add a reference to Microsoft Scripting Runtime and Use File System Object. You could do all the stuff you mentioned.

Dim fso as new FileSystemObject

Shankar3003Author Commented:
i am not that good with vbs script can you show me a sample script, thank you.
Where are you writing your vbs? Is it from VB IDE or Excel  or any other IDE?
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Shankar3003Author Commented:
// Instantiate a File System ActiveX Object:
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (not fso.FolderExists("c:\rock "))
fso.CreateFolder("c:\rock ")
end if
if not fso.FileExists("c:\windows\xx.doc") then
fso.copyfile "\\networkshare\xx.doc", "c:\windows\xx.doc"
end if
Was the solution helpful?
Shankar3003Author Commented:
HI Sri, i have tried to place it in my current vbs script but it seem not to work. I cannot seem to create or copy although permission and admin access is there.

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
Shahan AyyubSenior Software EngineerCommented:
Try this one:

Option Explicit
Dim objFSO, objFolder, objShell,  strDirectory
strDirectory = "c:\logs"

' Create the File  System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

'  Note If..Exists. Then, Else ... End If construction
If  objFSO.FolderExists(strDirectory) Then
   Set objFolder =  objFSO.GetFolder(strDirectory)
   WScript.Echo strDirectory & "  already created "
   Set objFolder =  objFSO.CreateFolder(strDirectory)
WScript.Echo "Just created " &  strDirectory
End If

If err.number = vbEmpty then
   Set  objShell = CreateObject("WScript.Shell")
   objShell.run ("Explorer"  &" " & strDirectory & "\" )
Else WScript.echo  "VBScript Error: " & err.number
End If


Found from here: Click to see
Shankar3003Author Commented:
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
Microsoft Server Apps

From novice to tech pro — start learning today.