0

创建一个 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

文件复制完成后,我看到的只是“已创建本地临时目录”消息

4

2 回答 2

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">&nbsp;</span>
</body>
</html>
于 2012-04-06T23:25:51.047 回答
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
于 2012-04-10T19:36:19.473 回答