我正在编写一个 VBScript 来进行一些注册表更改,所以在进行更改之前,我会尝试将注册表备份到一个文件中。这在我的 Win7 64 位中运行良好,但是当我尝试在 WinXP 32 位中运行它时,它说它可以工作,但不会创建文件。代码如下所示。为什么这在 Xp 中不起作用,我该如何纠正?
Sub BackupRegistry()
regFile = "%USERPROFILE%\Desktop\regBackup.reg"
Set oShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(regFile) Then
regCmd = "regedit.exe /E " & regFile
oShell.Run regCmd, 0, True
MsgBox("Registry backed up to " & regFile)
End If
End Sub