- Community Home
- >
- Servers and Operating Systems
- >
- Legacy
- >
- Windows Server 2003
- >
- USER BACKUP -What is wrong on the script?
Windows Server 2003
1823079
Members
3196
Online
109645
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2006 03:38 AM
10-04-2006 03:38 AM
USER BACKUP -What is wrong on the script?
with this script the backup is not working correctly, can someone find where is the problem? We have 15 computers in our network and with this script it is not going correctly. If someone can find the problem I’ll be grateful.
This is the script:
on error resume next
countup = 0
Const READFILE = 1 ' text file constants
const HTML = 0
const NORMAL = 1
Dim fso, f, ts, shell, foldersfound, foldersNOTfound, errormsg, foldersmade, oldFolders
dim author, recipient, subject, body, i, temp, fo
Set fso = CreateObject( "Scripting.FileSystemObject" )
Set f = fso.GetFile( "x:\backup.txt" )
Set ts = f.OpenAsTextStream( READFILE, false )
set shell = CreateObject("WScript.Shell")
Do While ( ts.AtEndOfLine <> True )
backupstring = ts.Readline
if NOT fso.FolderExists(backupstring) then
foldersNOTfound = foldersNOTfound & ", " & backupstring
end if
'msgbox str
countup = countup + 1
position1 = InStr(1, backupstring, "\")
position2 = InStr(1, backupstring, "$")
position3 = InStr(position2, backupstring, "\")
position4 = InStr(position3 + 1, backupstring, "\")
position5 = Instr(position4 +1, backupstring, "\")
position9 = Len(backupstring)
computername = Mid(backupstring, 3, position2 - position1 - 4)
lastfolder = mid(backupstring, position5, position9 - position5)
If position4 > 0 Then
folder_name = Mid(backupstring, position2 + 2, position4 - position3 - 1)
'MsgBox folder_name
End If
backuppath = backupstring
If position4 > 0 Then
directory_path = "x:\" & computername & "\" & folder_name & lastfolder & "\"
Else
directory_path = "x:\" & computername
End If
'MsgBox directory_path
directory1 = "x:\" & computername
if NOT fso.FolderExists(directory1) then
'foldersNOTfound = foldersNOTfound & ", " & directory1
'wscript.echo directory1
fso.CreateFolder(directory1)
'shell.run "MkDir " & directory1
else
'foldersfound = foldersfound & ", " & directory1
'Set fo = fso.GetFolder(directory1)
'if DateDiff("ww", fo.DateLastModified, Now()) >= 2 then
' oldFolders = oldFolder & ", " & directory1
'end if
'set fo = nothing
end if
if err.number <> 0 then
errormsg = errormsg & "; " & err.number & "--" & err.source & "--" & err.description
err.clear
end if
'UserName = Mid$(backupstring, position2 + 1, position3 - position2 - 1)
'MsgBox directory_path
if NOT fso.FolderExists(directory_path) then
'foldersNOTfound = foldersNOTfound & ", " & directory_path
'MsgBox checkone
'wscript.echo directory_path
'shell.run "MkDir " & directory_path
fso.CreateFolder(directory_path)
else
'Set fo = fso.GetFolder(directory_path)
'if DateDiff("ww", fo.DateLastModified, Now()) >= 2 then
' oldFolders = oldFolder & ", " & directory_path
'end if
'set fo = nothing
end if
if err.number <> 0 then
errormsg = errormsg & "; " & err.number & "--" & err.source & "--" & err.description
err.clear
end if
shell_send = "xcopy " & Chr(34) & backuppath & "*.*" & Chr(34) & " " & Chr(34) & directory_path & Chr(34) & " /s /y /c /d"
'msgbox backuppath
'msgbox directory_path
'msgbox lastfolder
shell.run shell_send
if err.number <> 0 then
errormsg = errormsg & "; " & err.number & "--" & err.source & "--" & err.description
err.clear
end if
Loop
ts.Close
Set ts = Nothing
Set f = Nothing
set fso = nothing
set shell = nothing
author = "ex7@example.com"
recipient = "ex2@example.com; ex4@example.com; ex5@example.com; ex6@example.com"
'recipient = "ex2@example.com"
subject = "user backup generated email"
body = "
"
Email author, recipient, "", subject, body, HTML, "", NORMAL
'------------------------------------------------------------------------------------------------------------------------------------------------------------
' FUNCTION - Email
'------------------------------------------------------------------------------------------------------------------------------------------------------------
' strAuthorEmail - The author of the email
' strRecipientEmail - The person that will receive the email
' strCC - Carbon Copy
' strSubject - Subject header
' strBody - Email content, message
' intMailFormat - Send the email as HTML or TEXT
' 0 - HTML
' 1 - TEXT
' strAttachmentPath - Send an attachment
' intPriority - Urgency of message
' 0 - Low
' 1 - Normal
' 2 - High
'------------------------------------------------------------------------------------------------------------------------------------------------------------
' Use:
' Call Email("ex1@example.com", "ex2@example.com", "CCtoex3@example.com", "RE: Hello.", "Hi, today was a good day.", HTML, ".../books.xls", Normal)
'------------------------------------------------------------------------------------------------------------------------------------------------------------
Private Sub Email(strAuthorEmail, strRecipientEmail, strCC, strSubject, strBody, intMailFormat, strAttachmentPath, intPriority)
Dim ObjMail
Set ObjMail = CreateObject("CDONTS.NewMail")
ObjMail.FROM = strAuthorEmail
ObjMail.TO = strRecipientEmail
If strCC <> "" Then
ObjMail.Cc = strCC
End If
ObjMail.Subject = strSubject
ObjMail.BodyFormat = intMailFormat
ObjMail.MailFormat = intMailFormat
ObjMail.Body = strBody
ObjMail.Importance = intPriority
If strAttachmentPath <> "" Then
ObjMail.AttachFile strAttachmentPath
End If
ObjMail.Send
Set ObjMail = Nothing
End Sub
Function alternateColor(n)
if (n mod 2 = 0) then
alternateColor = "#efefef"
else
alternateColor = "white"
end if
End Function
This is the script:
on error resume next
countup = 0
Const READFILE = 1 ' text file constants
const HTML = 0
const NORMAL = 1
Dim fso, f, ts, shell, foldersfound, foldersNOTfound, errormsg, foldersmade, oldFolders
dim author, recipient, subject, body, i, temp, fo
Set fso = CreateObject( "Scripting.FileSystemObject" )
Set f = fso.GetFile( "x:\backup.txt" )
Set ts = f.OpenAsTextStream( READFILE, false )
set shell = CreateObject("WScript.Shell")
Do While ( ts.AtEndOfLine <> True )
backupstring = ts.Readline
if NOT fso.FolderExists(backupstring) then
foldersNOTfound = foldersNOTfound & ", " & backupstring
end if
'msgbox str
countup = countup + 1
position1 = InStr(1, backupstring, "\")
position2 = InStr(1, backupstring, "$")
position3 = InStr(position2, backupstring, "\")
position4 = InStr(position3 + 1, backupstring, "\")
position5 = Instr(position4 +1, backupstring, "\")
position9 = Len(backupstring)
computername = Mid(backupstring, 3, position2 - position1 - 4)
lastfolder = mid(backupstring, position5, position9 - position5)
If position4 > 0 Then
folder_name = Mid(backupstring, position2 + 2, position4 - position3 - 1)
'MsgBox folder_name
End If
backuppath = backupstring
If position4 > 0 Then
directory_path = "x:\" & computername & "\" & folder_name & lastfolder & "\"
Else
directory_path = "x:\" & computername
End If
'MsgBox directory_path
directory1 = "x:\" & computername
if NOT fso.FolderExists(directory1) then
'foldersNOTfound = foldersNOTfound & ", " & directory1
'wscript.echo directory1
fso.CreateFolder(directory1)
'shell.run "MkDir " & directory1
else
'foldersfound = foldersfound & ", " & directory1
'Set fo = fso.GetFolder(directory1)
'if DateDiff("ww", fo.DateLastModified, Now()) >= 2 then
' oldFolders = oldFolder & ", " & directory1
'end if
'set fo = nothing
end if
if err.number <> 0 then
errormsg = errormsg & "; " & err.number & "--" & err.source & "--" & err.description
err.clear
end if
'UserName = Mid$(backupstring, position2 + 1, position3 - position2 - 1)
'MsgBox directory_path
if NOT fso.FolderExists(directory_path) then
'foldersNOTfound = foldersNOTfound & ", " & directory_path
'MsgBox checkone
'wscript.echo directory_path
'shell.run "MkDir " & directory_path
fso.CreateFolder(directory_path)
else
'Set fo = fso.GetFolder(directory_path)
'if DateDiff("ww", fo.DateLastModified, Now()) >= 2 then
' oldFolders = oldFolder & ", " & directory_path
'end if
'set fo = nothing
end if
if err.number <> 0 then
errormsg = errormsg & "; " & err.number & "--" & err.source & "--" & err.description
err.clear
end if
shell_send = "xcopy " & Chr(34) & backuppath & "*.*" & Chr(34) & " " & Chr(34) & directory_path & Chr(34) & " /s /y /c /d"
'msgbox backuppath
'msgbox directory_path
'msgbox lastfolder
shell.run shell_send
if err.number <> 0 then
errormsg = errormsg & "; " & err.number & "--" & err.source & "--" & err.description
err.clear
end if
Loop
ts.Close
Set ts = Nothing
Set f = Nothing
set fso = nothing
set shell = nothing
author = "ex7@example.com"
recipient = "ex2@example.com; ex4@example.com; ex5@example.com; ex6@example.com"
'recipient = "ex2@example.com"
subject = "user backup generated email"
body = "
" 'body = body & "
'body = body & " | ||
" body = body & "
body = body & " | ||
" body = body & "
body = body & " |
Email author, recipient, "", subject, body, HTML, "", NORMAL
'------------------------------------------------------------------------------------------------------------------------------------------------------------
' FUNCTION - Email
'------------------------------------------------------------------------------------------------------------------------------------------------------------
' strAuthorEmail - The author of the email
' strRecipientEmail - The person that will receive the email
' strCC - Carbon Copy
' strSubject - Subject header
' strBody - Email content, message
' intMailFormat - Send the email as HTML or TEXT
' 0 - HTML
' 1 - TEXT
' strAttachmentPath - Send an attachment
' intPriority - Urgency of message
' 0 - Low
' 1 - Normal
' 2 - High
'------------------------------------------------------------------------------------------------------------------------------------------------------------
' Use:
' Call Email("ex1@example.com", "ex2@example.com", "CCtoex3@example.com", "RE: Hello.", "Hi, today was a good day.", HTML, ".../books.xls", Normal)
'------------------------------------------------------------------------------------------------------------------------------------------------------------
Private Sub Email(strAuthorEmail, strRecipientEmail, strCC, strSubject, strBody, intMailFormat, strAttachmentPath, intPriority)
Dim ObjMail
Set ObjMail = CreateObject("CDONTS.NewMail")
ObjMail.FROM = strAuthorEmail
ObjMail.TO = strRecipientEmail
If strCC <> "" Then
ObjMail.Cc = strCC
End If
ObjMail.Subject = strSubject
ObjMail.BodyFormat = intMailFormat
ObjMail.MailFormat = intMailFormat
ObjMail.Body = strBody
ObjMail.Importance = intPriority
If strAttachmentPath <> "" Then
ObjMail.AttachFile strAttachmentPath
End If
ObjMail.Send
Set ObjMail = Nothing
End Sub
Function alternateColor(n)
if (n mod 2 = 0) then
alternateColor = "#efefef"
else
alternateColor = "white"
end if
End Function
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP