用于转移文件夹结构的安装脚本问题

时间:2012-07-06 11:22:26

标签: vbscript windows-xp installation

当我们将Documents and Settings文件夹从C驱动器完全移动到D驱动器时,产品插件安装无法正常工作,这最终会弹出windowsFolderSplit(0):C和错误文件夹不存在?对于具有单个分区的系统,这可以正常工作,但仅适用于多个分区,这不起作用

以下是安装脚本中使用的vbscript代码,我需要在这里进行任何修改吗?

Dim windowsFolder      ' For finding shortcut location
Dim windowsFolderSplit ' For isolating the WINDOWS drive

windowsFolder = fso.GetSpecialFolder(WindowsFolder)
If DEBUG = "D1" Then        
   MsgBox "windowsFolder:" & windowsFolder
End If

windowsFolderSplit = Split(windowsFolder, "\", -1, 1)

If DEBUG = "D1" Then        
   MsgBox "windowsFolderSplit(0):" & windowsFolderSplit(0)
   MsgBox "windowsFolderSplit(1):" & windowsFolderSplit(1)
End If

Set docAndSetFolder = fso.GetFolder(windowsFolderSplit(0) & "\Documents and Settings")

是否将值硬编码到“C”驱动器中?

1 个答案:

答案 0 :(得分:1)

SpecialFolders(MSDN):

Dim objShell As Object
Dim strPath As String

Set objShell = Wscript.CreateObject("Wscript.Shell")
strPath = objShell.SpecialFolders("MyDocuments")
wscript.echo strPath

或可选:

Set S = CreateObject("WScript.Shell")
Set E = S.Environment
WScript.Echo E("USERPROFILE")