troubleshooting Question

Create Logs while transferring folder from one server to another server through vbscript

Avatar of Sudhanshum
Sudhanshum asked on
VB ScriptVisual Basic.NET
6 Comments1 Solution89 ViewsLast Modified:
Hi I have one folder present on my server and I have created script to transfer that folder everyday to different server,What i am looking is that while transferring it should maintain logs and if any error comes then i want to send email to me ,So i should be aware that transfer got failed.Below is script I am using,Please help.

Public Str4
 Public topath
 Public Frompath
 Public Filename

'Values of variables set
strDriveLetter = "Z:"
strRemotePath = "\\\dumpsDB1"
strUser = "User"
strPassword = "User"
strProfile = "false"

' ************** Setting Network Drive **************

Set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, _
strProfile, strUser, strPassword

' ************** System Parameters **************

 Frompath= strDriveLetter

Str4= "cmd /C copy " &  Frompath &"\"&Filename &" " & topath 
'msgbox Str4

	On Error Resume Next
	Set oShell = CreateObject("WScript.Shell")
	retval = oShell.Run( Str4, 1, True)
	Set oShell = Nothing

' ************** Deleting Network Drive **************

objNetwork.RemoveNetworkDrive strDriveLetter
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros