Page 1 of 1 1
Topic Options
#106097 - 2003-10-18 12:40 AM editshortcut problem
anna Offline
Getting the hang of it

Registered: 2001-08-21
Posts: 71
Loc: Los Angeles, cA
Hi guys,

I need your help again. I am trying to change the target location of a shortcut to a batch file. Here's code:

$desktop = "c:\documents and settings\@userid\desktop"
$x = EditShortcut($desktop,"Backup Username.bat.lnk","\\labup2\scripts$\2000backup.bat username","\\labup2\scripts$\2000backup.bat @userid")

It won't make the change. What am I doing wrong? any suggestions?
thanks
Anna

Top
#106098 - 2003-10-18 01:11 AM Re: editshortcut problem
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
not sure of edit shortcut but windows is really explicit with usage of long filenames or whitespace with shortcuts.
_________________________
!

download KiXnet

Top
#106099 - 2003-10-18 02:37 AM Re: editshortcut problem
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The problem is most likely the fact that you supply parameters in addition to the batch file call. This might confuse EditShortcut.
_________________________
There are two types of vessels, submarines and targets.

Top
#106100 - 2003-10-18 03:30 AM Re: editshortcut problem
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
may need to edit the UDF and enable an additional parameter...

oShellLink.Arguments = "C:\myFile.txt"
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#106101 - 2003-10-18 04:21 AM Re: editshortcut problem
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Hello Anna,

Please give this code sample a try.

Howard found an issue with this UDF that I'll post to Shawn. Copy the code below and edit as required.

Let us know if you have problems with it.

code:
dim $Desktop,$UpdateBackupLink,$Pause
$Desktop=readvalue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders','Desktop')

$UpdateBackupLink = WshShortCut($Desktop+'\'+'Backup Username.bat.lnk','\\labup2\scripts$\2000backup.bat',@USERID,'\\labup2\scripts$\','%SystemRoot%\system32\SHELL32.dll,6')
? 'Shortcut creation: '+@error+' '+@serror
get $Pause

Function WshShortCut( $path, $targetpath, optional $arguments, optional $startdir, optional $iconpath, optional $style)
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
if $style
$shortcut.windowstyle = $style
endif
$shortcut.save
$shortcut = 0
endif
$shell = 0
endif
exit @error
EndFunction


Top
Page 1 of 1 1


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

Who's Online
0 registered and 476 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.055 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