创建一个可自动安装多个应用程序的HTA 它首先检查是否存在某些文件,然后将一个大文件夹从闪存驱动器复制到本地,如果它不存在,我有一个文本框,我用来更新脚本的当前状态,但它似乎只是冻结,永不更新,我也没有任何人工睡眠功能的运气。
这是片段
If Not objFSO.FileExists(Office10Dir) Then
MsgBox("Excel is missing")
BasicTextBox.Value = "Office14 Not Detected, Copying Source Files to Local"
Dim objFS, objFolder
Dim OfficeTemp
OfficeTemp = "C:\OfficeTemp"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.CreateFolder(OfficeTemp)
objFS.CopyFolder "OfficeTemp", "C:\OfficeTemp"
BasicTextBox.Value = "Local Temp Directory Created"
ELSE
MsgBox("Excel is Installed")
END IF
一旦文件复制完成,我所看到的就是“创建本地临时目录”消息
答案 0 :(得分:0)
您可以创建目标文件夹,而不是“CopyFolder”,然后遍历文件对象。
<script>
Set objFS = CreateObject("Scripting.FileSystemObject")
objOfficeTemp = objFS.GetFolder("C:\OfficeTemp")
If Not objFS.FolderExists("C:\SomeDestination") Then
objFS.CreateFolder("C:\SomeDestination")
End If
For Each objOfficeTempFile In objOfficeTemp.Files
'copy the file
'add some logic that updates your hta
'if you have nested folders, you'll
'have to copy them recursively...
objOfficeTempFile.Copy "C:\SomeDestination"
updatespan.innerhtml = "Copying file: " & objOfficeTempFile.Name
Next
</script>
<html>
<body>
<span id="updatespan"> </span>
</body>
</html>
答案 1 :(得分:0)
感谢回复人员,我能够使用'CopyHere'方法获得所需的结果,并声明一个常量来更新文件复制进度的进度条。
'copies files from current dir 'OfficeTemp' to local
Dim objFS, objFolder, oShell, oTarget
Dim OfficeTemp
OfficeTemp = "C:\OfficeTemp"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.CreateFolder(OfficeTemp)
Const FOF_CREATEPROGRESSDLG = &H0&
strTargetFolder = "C:\OfficeTemp"
Set oShell = CreateObject("Shell.Application")
Set objFolder = oShell.NameSpace(strTargetFolder)
objFolder.CopyHere "OfficeTemp\*.*", FOF_CREATEPROGRESSDLG