0

我正在使用以下 VBSript,它工作正常,但是当我尝试将其添加到我创建的 .hta 应用程序时,它无法正常工作。

首先,'strValue' 没有显示在 MsgBox 中,其次出现脚本错误,例如“类型不匹配:'fso.FolderExists'”

任何帮助将不胜感激,因为我一直在努力解决这个问题。

sub LyncFix

dim oReg, strKeyPath, strValueName, strValue, oWS, userProfile

Const HKEY_LOCAL_MACHINE = &H80000002

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\C7376A18AE70EB645A6EA7E5F5CE44F9"
strValueName = "71B0EB18B3654D541B8975126E6C56DC"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
MsgBox "Folder required to resolve Lync Install prompt: " & strValue


Dim fso
Dim Folder

Set fso = CreateObject("Scripting.FileSystemObject")

If (fso.FolderExists(strValue)) Then
    MsgBox("The folder '" + strValue + "' already exists")
end If

If NOT (fso.FolderExists(strValue)) Then
    ' Delete this if you don't want the MsgBox to show
    MsgBox("Local folder doesn't exist, creating...")
    ' Create folder
    MsgBox("'" + strValue + "'" + " created")
    fso.CreateFolder(strValue)
    MsgBox("Please now try launching Lync again")
End If

end sub
4

1 回答 1

0

只有两个旁注:

  • HTML使用方法查询GetStringValue会为不同的Windows Script Host可执行版本(32 位与 64 位,如下一个示例所示)提供不同的结果;
  • CreateFolder方法可能需要提升的权限。

示例:有strComputer = "."和下一个修正

  '
  oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
  ' the amendment in 29026643.vbs as follows:
  Wscript.Echo VarType(strValue) & vbTab & TypeName(strValue)
  '

我在 Windows 8、64 位上得到了下一个输出:

==>%windir%\sysWOW64\cscript.exe D:\VB_scripts\SO\29026643.vbs
1       Null

==>%windir%\system32\cscript.exe D:\VB_scripts\SO\29026643.vbs
8       String

==>

具有echo不同版本的wscript.exe.

sub LyncFix具有基本定义和使用的模拟输出hta(用msgbox代替Wscript.Echo)和不同版本mshta.exe如下:

==>%winDir%\sysWOW64\mshta.exe D:\VB_scripts\SO\29026643.hta

==>%winDir%\system32\mshta.exe D:\VB_scripts\SO\29026643.hta
于 2015-03-15T17:40:43.487 回答