#72662 - 2003-01-20 08:31 PM
WshShortCut() Question
|
ShaneEP
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
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
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
|
Top
|
|
|
|
#72666 - 2003-01-21 04:12 AM
Re: WshShortCut() Question
|
NTDOC
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.
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 515 anonymous users online.
|
|
|