Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 

Sign in to follow this  
freedavis

VBscript to move from one server to next.

Recommended Posts

freedavis    0

I have the below vbscript and need to add a line to be able to move this to three servers. Any help appreciated on this questions.

Set FSO =CreateObject("scripting.FileSystemObject")

FSO.CopyFolder "C:\inetpub\wwwroot\Pre-Release\*", "C:\inetpub\wwwroot\ErOne" ,True

FSO.CopyFile "C:\inetpub\wwwroot\Pre-Release\*", "C:\inetpub\wwwroot\ErOne", True

MsgBox"Deployment completed, Goodbye", vbInformation, "Script Informer"

This vbscript when executed, copied entire folder content from pre-release folder to the ErOne folder.

Is there a way edit this script to do this on two others servers from one server? Would like to be able to execute this on one server and it pushes to two other servers also.

Edited by freedavis

Share this post


Link to post
Share on other sites
allen2    1

This should work.

Set FSO =CreateObject("scripting.FileSystemObject")
'local deploy
FSO.CopyFolder "C:\inetpub\wwwroot\Pre-Release\*", "C:\inetpub\wwwroot\ErOne" ,True
FSO.CopyFile "C:\inetpub\wwwroot\Pre-Release\*", "C:\inetpub\wwwroot\ErOne", True
'remote server1 deploy
FSO.CopyFolder "C:\inetpub\wwwroot\Pre-Release\*", "\\server1\C$\inetpub\wwwroot\ErOne" ,True
FSO.CopyFile "C:\inetpub\wwwroot\Pre-Release\*", "\\server1\C$\inetpub\wwwroot\ErOne", True
'remote server2 deploy
FSO.CopyFolder "C:\inetpub\wwwroot\Pre-Release\*", "\\server2\C$\inetpub\wwwroot\ErOne" ,True
FSO.CopyFile "C:\inetpub\wwwroot\Pre-Release\*", "\\server2\C$\inetpub\wwwroot\ErOne", True

MsgBox"Deployment completed, Goodbye", vbInformation, "Script Informer"

Share this post


Link to post
Share on other sites

Using allen2 example path here is another way using an array and a loop


Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim FPath, Obj, SvrPath
'->Array For Path To Local And Server Folders
SvrPath = Array("C:\inetpub\wwwroot\ErOne", _
"\\server1\C$\inetpub\wwwroot\ErOne", _
"\\server2\C$\inetpub\wwwroot\ErOne")
'-> Copy This
FPath = "C:\inetpub\wwwroot\Pre-Release\*"
'-> Loop Threw The Array
For Each Obj In SvrPath
'-> Code For Copy
Fso.CopyFolder FPath, Obj ,True
Fso.CopyFile FPath, Obj, True
'-> UnComment For Out Put
' WScript.Echo "Fso.CopyFolder " & FPath & ", " & Obj & ",True" & _
' vbCrLf & "Fso.CopyFile " & FPath & ", " & Obj & ",True" & vbCrLf
Next

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×