Page 1 of 1 1
Topic Options
#72662 - 2003-01-20 08:31 PM WshShortCut() Question
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Hello people...

I am trying to add a desktop icon that locks the workstation. I am trying to use the following without any luck.

WshShortCut()

code:
 
$DesktopPath = ReadValue ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Desktop")

WshShortCut($DesktopPath+"\Lock Workstation.lnk","rundll32.exe user32.dll,LockWorkStation",,,"%SystemRoot%\system32\SHELL32.dll,47")
Function WshShortCut($path,$targetpath,optional $arguments, optional $startdir, optional $iconpath)
dim $shell,$shortcut
$shell = createobject("wscript.shell")
if $shell
$shortcut = $shell.createshortcut("$path")
if $shortcut
$shortcut.targetpath = $targetpath
if $arguments
$shortcut.arguments = $arguments
endif
if $startdir
$shortcut.workingdirectory = $startdir
endif
if $iconpath
$shortcut.iconlocation = $iconpath
endif
$shortcut.save
$shortcut = 0
endif
$shell = 0
endif
exit @error
EndFunction

It creates the icon ok but when I look at properties it has nothing in the target. Just a syntax problem on my part?

[ 20. January 2003, 20:44: Message edited by: CitrixMan ]

Top
#72663 - 2003-01-20 08:58 PM Re: WshShortCut() Question
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Hi CitrixMan,

Try this code out. It should take care of the problem for you. You had the comma position off I think.

code:
Break On
$DesktopPath=ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Desktop")
WshShortCut($DesktopPath+"\Lock Workstation.lnk","rundll32.exe", "user32.dll,LockWorkStation",,"%SystemRoot%\system32\SHELL32.dll,47")

Function WshShortCut($path,$targetpath,optional $arguments, optional $startdir, optional $iconpath)
dim $shell,$shortcut
$shell = createobject("wscript.shell")
if $shell
$shortcut = $shell.createshortcut("$path")
if $shortcut
$shortcut.targetpath = $targetpath
if $arguments
$shortcut.arguments = $arguments
endif
if $startdir
$shortcut.workingdirectory = $startdir
endif
if $iconpath
$shortcut.iconlocation = $iconpath
endif
$shortcut.save
$shortcut = 0
endif
$shell = 0
endif
exit @error
EndFunction


Top
#72664 - 2003-01-20 09:58 PM Re: WshShortCut() Question
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
$HKCUSMWCV ="$HKCUS\Microsoft\Windows\CurrentVersion"
$appdata =readvalue("$HKCUSMWCV\Explorer\Shell Folders","AppData")
$qlbar = "$appdata\Microsoft\Internet Explorer\Quick Launch"

if exist("$qlbar\LockWorkstation.lnk")=0 WshShortCut("$qlbar\LockWorkstation.lnk","C:\WINNT\system32\rundll32.exe"," user32.dll,LockWorkStation",,"C:\WINNT\system32\winlogon.exe") endif
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#72665 - 2003-01-20 10:06 PM Re: WshShortCut() Question
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
That worked great...Thanks for the help.
Top
#72666 - 2003-01-21 04:12 AM Re: WshShortCut() Question
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Rad,

Just a small possible issue wiht XP. Seems that by default the Quick Launch is not on... not sure why as most people seem to like it. Desktop target if Quick Launch is not on would be better then Quick Launch alone. [Smile]

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 515 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.056 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org