Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Create lnk file in desktop

2 views
Skip to first unread message

Carlos

unread,
Jan 12, 2004, 12:15:40 AM1/12/04
to
Anyone knows what is wrong in this procedure?

ZSet WSHShell=$ZCreateObject("WScript.Shell")
S DesktopPath=WSHShell.SpecialFolders("Desktop")
S MyShortcut=WSHShell.CreateShortcut(DesktopPath_"\Notepad Shortcut.lnk")
S Windir=WSHShell.ExpandEnvironmentStrings("%windir%")
S MyShortcut.TargetPath=WinDir_"\notepad.exe"
S MyShortcut.WorkingDirectory=WinDir
S MyShortcut.WindowStyle=4
S MyShortcut.IconLocation=WinDir_"\notepad.exe, 0"
D MyShortcut.Save
K WSHShell

Thansk

Denver Braughler

unread,
Jan 12, 2004, 12:41:13 AM1/12/04
to
Carlos wrote:
> Does anyone know what is wrong in this procedure?

Did you check that everything works as expected?

> ZSet WSHShell=$ZCreateObject("WScript.Shell")
> S DesktopPath=WSHShell.SpecialFolders("Desktop")

W DesktopPath,!

> S MyShortcut=WSHShell.CreateShortcut(DesktopPath_"\Notepad Shortcut.lnk")
> S Windir=WSHShell.ExpandEnvironmentStrings("%windir%")

W Windir,!

John Murray

unread,
Jan 12, 2004, 4:37:54 AM1/12/04
to
"Carlos" <cal...@hotmail.com> wrote in message
news:58adc7a4.04011...@posting.google.com...

> Anyone knows what is wrong in this procedure?

For the benefit of other readers, this os MSM-Workstation stuff.

>
> ZSet WSHShell=$ZCreateObject("WScript.Shell")
> S DesktopPath=WSHShell.SpecialFolders("Desktop")
> S MyShortcut=WSHShell.CreateShortcut(DesktopPath_"\Notepad Shortcut.lnk")

Make that a ZSET rather than a SET, because you want to store the object
that CreatShortcut() returns. A simple SET lets you store the default
property of that object, so MyShortcut holds a string rather than an object.

> S Windir=WSHShell.ExpandEnvironmentStrings("%windir%")

That should be WinDir, not Windir.

> S MyShortcut.TargetPath=WinDir_"\notepad.exe"
> S MyShortcut.WorkingDirectory=WinDir
> S MyShortcut.WindowStyle=4
> S MyShortcut.IconLocation=WinDir_"\notepad.exe, 0"
> D MyShortcut.Save
> K WSHShell

Now it works (for me), creating a desktop shortcut called "Notepad
Shortcut".

HTH

John

Carlos

unread,
Jan 14, 2004, 11:26:33 AM1/14/04
to
Thanks, thanks and thanks. Now, works fine.

Carlos Alberto

0 new messages