Visual Basic语句结束?

时间:2014-09-23 12:42:23

标签: vbscript compiler-errors

因此,当我运行以下代码时,第三行的错误就是声明结束。有什么想法吗?

Set objShell = WScript.CreateObject("WScript.Shell")
Set lnk = objShell.CreateShortcut("C:\Users\%USERDATA%\Desktop\Shutdown.LNK")
Dim strUserProfile as String
strUserProfile = objShell.ExpandEnvironmentStrings("%USERPROFILE%")

lnk.TargetPath = "C:\Users\" & strUserProfile & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\shutdown.bat"
lnk.Arguments = ""
lnk.Description = "Shutdown"
'lnk.HotKey = "ALT+CTRL+F"
lnk.IconLocation = "C:\Users\" & strUserProfile & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\shutdown.bat, 2"
lnk.WindowStyle = "1"
lnk.WorkingDirectory = "C:\Users\" & strUserProfile &"\AppData\Roaming\Microsoft\Windows\Start Menu\Programs"
lnk.Save
Set lnk = Nothing

1 个答案:

答案 0 :(得分:1)

在VBScript中,没有" String"对象,所以你不能将Dim strMyString作为字符串。

因此,在您的情况下,您只需执行:Dim strUserProfile