Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBS Script Progress Bar

Status
Not open for further replies.

maccten2000

Programmer
May 13, 2003
37
EU
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>
 
Set NS=SA.NameSpace(destdir)
is where you create the object NS.
Does the destdir really exist? what is the value of destdir when you get these problems?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top