Eric Lopushansky
Eric Lopushansky

Reputation: 31

Visual Basic End of statement?

So when I run the following code it errors on line three saying end of statement. Any ideas?

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

Upvotes: 0

Views: 94

Answers (1)

Postlagerkarte
Postlagerkarte

Reputation: 7127

In VBScript, there's no such thing as a "String" object, so you can't do a Dim strMyString As String.

So in your case, you would simply do: Dim strUserProfile

Upvotes: 1

Related Questions