Display copy progress with the copy command
Moderators: Dorian (MJT support), JRL
Display copy progress with the copy command
Hi,
The copy function works great.
But for copying a large file, I wish that there is a way to pop up the usual window copying progress so user know something is going on.
Could this be done?
Thanks
The copy function works great.
But for copying a large file, I wish that there is a way to pop up the usual window copying progress so user know something is going on.
Could this be done?
Thanks
Hi,
You can do this with the shell.application object in VBScript:
VBSTART
Const FOF_ALLOWUNDO = 64
Const FOF_CONFIRMMOUSE = 2
Const FOF_COPYFLAGS = 989
Const FOF_DELETEFLAGS = 340
Const FOF_FILESONLY = 128
Const FOF_MOVEFLAGS = 989
Const FOF_MULTIDESTFILES = 1
Const FOF_NOCONFIRMATION = 16
Const FOF_NOCONFIRMMKDIR = 512
Const FOF_RENAMEFLAGS = 989
Const FOF_RENAMEONCOLLISION = 8
Const FOF_SILENT = 4
Const FOF_SIMPLEPROGRESS = 256
Const FOF_WANTMAPPINGHANDLE = 32
Sub CopyProgress(destfolder,sourcefile)
set winShell = createObject("shell.application")
winShell.namespace(destfolder).CopyHere sourcefile, FOF_SIMPLEPROGRESS
End Sub
VBEND
VBRun>CopyProgress,f:\,d:\test\test.txt
You can do this with the shell.application object in VBScript:
VBSTART
Const FOF_ALLOWUNDO = 64
Const FOF_CONFIRMMOUSE = 2
Const FOF_COPYFLAGS = 989
Const FOF_DELETEFLAGS = 340
Const FOF_FILESONLY = 128
Const FOF_MOVEFLAGS = 989
Const FOF_MULTIDESTFILES = 1
Const FOF_NOCONFIRMATION = 16
Const FOF_NOCONFIRMMKDIR = 512
Const FOF_RENAMEFLAGS = 989
Const FOF_RENAMEONCOLLISION = 8
Const FOF_SILENT = 4
Const FOF_SIMPLEPROGRESS = 256
Const FOF_WANTMAPPINGHANDLE = 32
Sub CopyProgress(destfolder,sourcefile)
set winShell = createObject("shell.application")
winShell.namespace(destfolder).CopyHere sourcefile, FOF_SIMPLEPROGRESS
End Sub
VBEND
VBRun>CopyProgress,f:\,d:\test\test.txt
MJT Net Support
[email protected]
[email protected]
Thanks greatly for the help.
I tried with a replacements for the 'desfolder' and 'sourcefile' in the two statements:
Sub CopyProgress(destfolder,sourcefile)
. . . . .
winShell.namespace(destfolder) . . . . .
and some other changes, but could not get it to work.
Most cases, I got error message " MS VBScript compilation error:1006, Expect ')', Line xx, column xx."
I would much appreciate a little more help as to how to use it.
Thanks greatly
I tried with a replacements for the 'desfolder' and 'sourcefile' in the two statements:
Sub CopyProgress(destfolder,sourcefile)
. . . . .
winShell.namespace(destfolder) . . . . .
and some other changes, but could not get it to work.
Most cases, I got error message " MS VBScript compilation error:1006, Expect ')', Line xx, column xx."
I would much appreciate a little more help as to how to use it.
Thanks greatly
Line xx, Column xx or did it actually give a proper line and column number? Then we can know where the problem is.
MJT Net Support
[email protected]
[email protected]
Hi Support,
Yes, the error is "MS VBScript compilation error: 1006. Expect ')', Line 16, Column 18".
And here is the test script:
(line 16 seems to be the "Sub CopyProgress(C:\downloads\,C:\TempDVD\Myfile.iso).
Thanks
VBSTART
Const FOF_ALLOWUNDO = 64
Const FOF_CONFIRMMOUSE = 2
Const FOF_COPYFLAGS = 989
Const FOF_DELETEFLAGS = 340
Const FOF_FILESONLY = 128
Const FOF_MOVEFLAGS = 989
Const FOF_MULTIDESTFILES = 1
Const FOF_NOCONFIRMATION = 16
Const FOF_NOCONFIRMMKDIR = 512
Const FOF_RENAMEFLAGS = 989
Const FOF_RENAMEONCOLLISION = 8
Const FOF_SILENT = 4
Const FOF_SIMPLEPROGRESS = 256
Const FOF_WANTMAPPINGHANDLE = 32
Sub CopyProgress(C:\downloads\,C:\TempDVD\Myfile.iso)
set winShell = createObject("shell.application")
winShell.namespace(C:\downloads\).CopyHere sourcefile, FOF_SIMPLEPROGRESS
End Sub
VBEND
VBRun>CopyProgress,C:\temp\,d:\test\test.txt
Yes, the error is "MS VBScript compilation error: 1006. Expect ')', Line 16, Column 18".
And here is the test script:
(line 16 seems to be the "Sub CopyProgress(C:\downloads\,C:\TempDVD\Myfile.iso).
Thanks
VBSTART
Const FOF_ALLOWUNDO = 64
Const FOF_CONFIRMMOUSE = 2
Const FOF_COPYFLAGS = 989
Const FOF_DELETEFLAGS = 340
Const FOF_FILESONLY = 128
Const FOF_MOVEFLAGS = 989
Const FOF_MULTIDESTFILES = 1
Const FOF_NOCONFIRMATION = 16
Const FOF_NOCONFIRMMKDIR = 512
Const FOF_RENAMEFLAGS = 989
Const FOF_RENAMEONCOLLISION = 8
Const FOF_SILENT = 4
Const FOF_SIMPLEPROGRESS = 256
Const FOF_WANTMAPPINGHANDLE = 32
Sub CopyProgress(C:\downloads\,C:\TempDVD\Myfile.iso)
set winShell = createObject("shell.application")
winShell.namespace(C:\downloads\).CopyHere sourcefile, FOF_SIMPLEPROGRESS
End Sub
VBEND
VBRun>CopyProgress,C:\temp\,d:\test\test.txt
Hi,
The subroutine definition should not have literals in it. These should be parameters. Your code should look like this:
VBSTART
Const FOF_ALLOWUNDO = 64
Const FOF_CONFIRMMOUSE = 2
Const FOF_COPYFLAGS = 989
Const FOF_DELETEFLAGS = 340
Const FOF_FILESONLY = 128
Const FOF_MOVEFLAGS = 989
Const FOF_MULTIDESTFILES = 1
Const FOF_NOCONFIRMATION = 16
Const FOF_NOCONFIRMMKDIR = 512
Const FOF_RENAMEFLAGS = 989
Const FOF_RENAMEONCOLLISION = 8
Const FOF_SILENT = 4
Const FOF_SIMPLEPROGRESS = 256
Const FOF_WANTMAPPINGHANDLE = 32
Sub CopyProgress(destfolder,sourcefile)
set winShell = createObject("shell.application")
winShell.namespace(destfolder).CopyHere sourcefile, FOF_SIMPLEPROGRESS
End Sub
VBEND
VBRun>CopyProgress,C:\downloads\,C:\TempDVD\Myfile.iso
It is the VBRun line you should put the literals into and these are passed into the subroutine via the destfolder and sourcefile parameters which are declared in the subroutine declaration and used in the subroutine.
The subroutine definition should not have literals in it. These should be parameters. Your code should look like this:
VBSTART
Const FOF_ALLOWUNDO = 64
Const FOF_CONFIRMMOUSE = 2
Const FOF_COPYFLAGS = 989
Const FOF_DELETEFLAGS = 340
Const FOF_FILESONLY = 128
Const FOF_MOVEFLAGS = 989
Const FOF_MULTIDESTFILES = 1
Const FOF_NOCONFIRMATION = 16
Const FOF_NOCONFIRMMKDIR = 512
Const FOF_RENAMEFLAGS = 989
Const FOF_RENAMEONCOLLISION = 8
Const FOF_SILENT = 4
Const FOF_SIMPLEPROGRESS = 256
Const FOF_WANTMAPPINGHANDLE = 32
Sub CopyProgress(destfolder,sourcefile)
set winShell = createObject("shell.application")
winShell.namespace(destfolder).CopyHere sourcefile, FOF_SIMPLEPROGRESS
End Sub
VBEND
VBRun>CopyProgress,C:\downloads\,C:\TempDVD\Myfile.iso
It is the VBRun line you should put the literals into and these are passed into the subroutine via the destfolder and sourcefile parameters which are declared in the subroutine declaration and used in the subroutine.
MJT Net Support
[email protected]
[email protected]
Hi Support,
I have the same question as mydave. The subroutine and functions are created by some one else and used before. So they shouldn't have any problem. But when I try to use it as VBEval>SetCell("B_Operations",%cc%,8,%TS1%),nul it doesn't work. And give me the same error message "Error 1006 Expected ")"". Could you take a look and tell me what's wrong with my code? Thank you very much.
[/code]
I have the same question as mydave. The subroutine and functions are created by some one else and used before. So they shouldn't have any problem. But when I try to use it as VBEval>SetCell("B_Operations",%cc%,8,%TS1%),nul it doesn't work. And give me the same error message "Error 1006 Expected ")"". Could you take a look and tell me what's wrong with my code? Thank you very much.
Code: Select all
VBSTART
Dim xlApp
Dim xlBook
'Opens the Excel file in Excel
Sub OpenExcelFile(filename)
Set xlApp = CreateObject("Excel.Application")
xlApp.visible = false
Set xlBook = xlApp.Workbooks.open(filename)
end sub
'Use this to close Excel later
Sub CloseExcel
xlBook.Save
xlApp.quit
Set xlApp = Nothing
End Sub
'Retrieves a cell value from the specified
'worksheet
Function GetCell(Sheet,Row,Column)
Dim xlSheet
Set xlSheet = xlBook.Worksheets(Sheet)
GetCell = xlSheet.Cells(Row,Column).Value
End Function
'Sets specified cell of specified worksheet
Function SetCell(Sheet,Row,Column,NewValue)
Dim xlSheet
Set xlSheet = xlBook.Worksheets(Sheet)
xlSheet.Cells(Row,Column).Value = NewValue
End Function
VBEND
VBRun>OpenExcelFile,B:\PRODUCTION\MASTER_AUDIT\ScoreCard\Score_Card_Template.xls
DayOfWeek>days
GetDate>date
let>c=6
let>r=8
If>days>2
FileTime>B:\T_Folder\T_Confirm_%YYYY%%MM%%DD%.txt,time1
MidStr>time1,1,2,Hour1
MidStr>time1,3,2,Min1
Let>TS1=%date%%SPACE%%Hour1%:%Min1%
Let>cc=c+%days%
VBEval>SetCell("B_Operations",%cc%,8,%TS1%),nul
endIf
VBRun>CloseExcel
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
TS1 is the new value which is a string, so you need:
VBEval>SetCell("B_Operations",%cc%,8,"%TS1%"),nul
VBEval>SetCell("B_Operations",%cc%,8,"%TS1%"),nul
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?