maccten2000
Programmer
Hi All,
I have recently tried with the help of these forums to create a script that simply backs up a folder giving the user feedback by creating a progress bar.
My script is below. The error i am getting is on Line 51, char 4. Object required NS.
The error is puzzling because d'ont I create the object NS by setting Set SA=CreateObject("Shell.Application")
The code is Below
Thanks for all the help
Regards
John
Dim srcfile
Dim destdir
Dim strMinNum
Dim strHourNum
dim strDayNum
dim strMonthNum
Dim strYearNum
Dim strDateSuffix
strYearNum = Right(Cstr(Year(Now())),2)
strMonthNum = Cstr(Month(Now()))
if Len(strMonthNum)<2 then strMonthNum = "0" & strMonthNum
strDayNum = cStr(Day(Now()))
if Len(strDayNum)<2 then strDayNum = "0" & strDayNum
strHourNum = cStr(Hour(Now()))
if Len(strHourNum)<2 then strHourNum = "0" & strHourNum
strMinNum = cStr(Minute(Now()))
if Len(strMinNum)<2 then strMinNum= "0" & strMinNum
strDateSuffix = strDayNum & "-" & strMonthNum & "-" & strYearNum & " " & strHourNum & strMinNum
strDate = strDayNum & "-" & strMonthNum & "-" & strYearNum
srcfile="Sample Origin Folder"
destdir="Sample Backup Location"
destfile=destdir & "\bigfile"
Set Sh=WScript.CreateObject("WScript.Shell")
msg="Are you sure you wish to copy file?"
If Sh.Popup(msg,0,srcfile,33)<2 Then
Set fso=CreateObject("Scripting.FileSystemObject")
If fso.FileExists(destfile) Then
msg="Do you want to overwrite file?"
If Sh.Popup(msg,0,destfile,33)>1 Then
WScript.Quit
End If
End If
Set SA=CreateObject("Shell.Application")
Set NS=SA.NameSpace(destdir)
NS.CopyHere srcfile,16
WScript.Echo "Copy done"
End If </code>
I have recently tried with the help of these forums to create a script that simply backs up a folder giving the user feedback by creating a progress bar.
My script is below. The error i am getting is on Line 51, char 4. Object required NS.
The error is puzzling because d'ont I create the object NS by setting Set SA=CreateObject("Shell.Application")
The code is Below
Thanks for all the help
Regards
John
Dim srcfile
Dim destdir
Dim strMinNum
Dim strHourNum
dim strDayNum
dim strMonthNum
Dim strYearNum
Dim strDateSuffix
strYearNum = Right(Cstr(Year(Now())),2)
strMonthNum = Cstr(Month(Now()))
if Len(strMonthNum)<2 then strMonthNum = "0" & strMonthNum
strDayNum = cStr(Day(Now()))
if Len(strDayNum)<2 then strDayNum = "0" & strDayNum
strHourNum = cStr(Hour(Now()))
if Len(strHourNum)<2 then strHourNum = "0" & strHourNum
strMinNum = cStr(Minute(Now()))
if Len(strMinNum)<2 then strMinNum= "0" & strMinNum
strDateSuffix = strDayNum & "-" & strMonthNum & "-" & strYearNum & " " & strHourNum & strMinNum
strDate = strDayNum & "-" & strMonthNum & "-" & strYearNum
srcfile="Sample Origin Folder"
destdir="Sample Backup Location"
destfile=destdir & "\bigfile"
Set Sh=WScript.CreateObject("WScript.Shell")
msg="Are you sure you wish to copy file?"
If Sh.Popup(msg,0,srcfile,33)<2 Then
Set fso=CreateObject("Scripting.FileSystemObject")
If fso.FileExists(destfile) Then
msg="Do you want to overwrite file?"
If Sh.Popup(msg,0,destfile,33)>1 Then
WScript.Quit
End If
End If
Set SA=CreateObject("Shell.Application")
Set NS=SA.NameSpace(destdir)
NS.CopyHere srcfile,16
WScript.Echo "Copy done"
End If </code>