ShaneEP
|
(MM club member)
|
2003-01-20 08:31 PM
|
|
|
|
|
WshShortCut() Question
|
|
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 ]
|
NTDOC
|
(KiX Master)
|
2003-01-20 08:58 PM
|
|
|
|
|
Re: WshShortCut() Question
|
|
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
|
Radimus
|
(KiX Supporter)
|
2003-01-20 09:58 PM
|
|
|
|
|
Re: WshShortCut() Question
|
|
$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
|
ShaneEP
|
(MM club member)
|
2003-01-20 10:06 PM
|
|
|
|
|
Re: WshShortCut() Question
|
|
That worked great...Thanks for the help.
|
NTDOC
|
(KiX Master)
|
2003-01-21 04:12 AM
|
|
|
|
|
Re: WshShortCut() Question
|
|
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.
|