执行脚本文件CreateSybaseMenus.vbs一直报题中的错误。
文件的内容如下代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
Dim objShell
dim strAllUsersPrograms
dim objFolder
dim objShellLink

Dim OsType
Dim WshShell
Dim sProgramFiles
Dim sWindows

Set WshShell = WScript.CreateObject("WScript.Shell")

OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
'SQLAny12 Environment variable is not consistently available so I am making some assumptions.


If OsType = "x86" then
'wscript.echo "Windows 32bit system detected"
sProgramFiles = "C:\Program Files"
sWindows = "%windir%\system32"
elseif OsType = "AMD64" then
'wscript.echo "Windows 64bit system detected"
sProgramFiles = "C:\Program Files (x86)"
sWindows = "%windir%\SysWoW64"
end if

'WshShell.Run sWindows & "\msiexec /qb /i ""SQL Anywhere 12 Deployment.msi"

Set objShell = createobject("Wscript.Shell")
Set objFso = CreateObject("Scripting.FileSystemObject")

strAllUsersPrograms= objShell.SpecialFolders("AllUsersPrograms")

if objFSO.FolderExists( strAllUsersPrograms & "\SQL Anywhere 12")=false then
'具体是以下这行报错'
Set objFolder = objFSO.CreateFolder( strAllUsersPrograms & "\SQL Anywhere 12")
end if

if objFSO.FolderExists( strAllUsersPrograms & "\SQL Anywhere 12\Administration Tools")=false then
Set objFolder = objFSO.CreateFolder( strAllUsersPrograms & "\SQL Anywhere 12\Administration Tools")
end if

if objFSO.FolderExists( strAllUsersPrograms & "\SQL Anywhere 12\SQL Anywhere")=false then
Set objFolder = objFSO.CreateFolder( strAllUsersPrograms & "\SQL Anywhere 12\SQL Anywhere")
end if


If (objFso.FileExists(strAllUsersPrograms & "\SQL Anywhere 12\Administration Tools\Interactive SQL.lnk")) = false Then
Set objShellLink = objShell.CreateShortcut(strAllUsersPrograms & "\SQL Anywhere 12\Administration Tools\Interactive SQL.lnk")
objShellLink.TargetPath = sProgramFiles & "\SQL Anywhere 12\Bin32\dbisql.exe"
objShellLink.Description = "Interactive SQL"
objShellLink.Save
set objShellLink = nothing
end if

If (objFso.FileExists(strAllUsersPrograms & "\SQL Anywhere 12\Administration Tools\ODBC Data Source Administrator (32-bit).lnk")) = false Then
Set objShellLink = objShell.CreateShortcut(strAllUsersPrograms & "\SQL Anywhere 12\Administration Tools\ODBC Data Source Administrator (32-bit).lnk")
objShellLink.TargetPath = sWindows & "\odbcad32.exe"
objShellLink.Description = "ODBC Data Source Administrator (32-bit)"
objShellLink.Save
set objShellLink = nothing
end if

If (objFso.FileExists(strAllUsersPrograms & "\SQL Anywhere 12\Administration Tools\Sybase Central.lnk")) = false Then
Set objShellLink = objShell.CreateShortcut(strAllUsersPrograms & "\SQL Anywhere 12\Administration Tools\Sybase Central.lnk")
objShellLink.TargetPath = sProgramFiles & "\SQL Anywhere 12\Bin32\scjview.exe"
objShellLink.Description = "Sybase Central"
objShellLink.Save
Set objSystemFolder = nothing
end if

If (objFso.FileExists(strAllUsersPrograms & "\SQL Anywhere 12\SQL Anywhere\Network Server.lnk")) = false Then
Set objShellLink = objShell.CreateShortcut(strAllUsersPrograms & "\SQL Anywhere 12\SQL Anywhere\Network Server.lnk")
objShellLink.TargetPath = sProgramFiles & "\SQL Anywhere 12\Bin32\dbsrv12.exe"
objShellLink.Description = "Network Server"
objShellLink.Save
Set objSystemFolder = nothing
end if

If (objFso.FileExists(strAllUsersPrograms & "\SQL Anywhere 12\SQL Anywhere\Personal Server.lnk")) = false Then
Set objShellLink = objShell.CreateShortcut(strAllUsersPrograms & "\SQL Anywhere 12\SQL Anywhere\Personal Server.lnk")
objShellLink.TargetPath = sProgramFiles & "\SQL Anywhere 12\Bin32\dbeng12.exe"
objShellLink.Description = "Personal Server"
objShellLink.Save
Set objSystemFolder = nothing
end if

Set objFolder = nothing
Set objFSO = nothing
set objShell = nothing

Call MsgBox("Installation Complete!",vbSystemModal, "SQL Anywhere 12")

具体是35行报错。可以看出是新建文件夹时的问题,找到其路径C:\ProgramData\Microsoft\Windows\Start Menu\Programs,给文件夹安全选项里添加相应的权限用户,再次执行即可。