#185103 - 2008-02-06 07:33 AM
Re: Loop : Desktop Shortcut Check
[Re: Allen]
|
henkie32
Fresh Scripter
Registered: 2008-02-01
Posts: 17
|
thx for your replies so far...
it still doesnt work the way i would like it to...
im using this code:
Dim $List ; array of LNK files
Dim $Lnk ; array enumerator
Dim $Path ; target path
$List = DirList('C:\Documents and Settings\Thijs\Bureaublad\*.lnk', 2)
For Each $Lnk in $List
'Processing ' $Lnk ?
$Path = GetShortCutProperties($Lnk, 'Path')
'Path: ' $Path ?
$fExcel = 1
Select
Case InStr($Path, 'xlicons') ; found - don't need to install
$fExcel = 0
EndSelect
Next
; Should shortcut be defined
If $fExcel
del c:\test\test1.txt
EndIf
The Script has some weird thingies
When i use 'word' in the instr it works fine having a [censored] of crap on my desktop. when i use 'xlico' or 'ppt' in the intr it worke fine when exel is the only office shortcut on my desktop.. but when i place other office shortcuts on the desktop.. it sets the flag to 0. so i guess it cant find it?
what am i doing wrong?
Edited by henkie32 (2008-02-06 08:24 AM)
|
Top
|
|
|
|
#185108 - 2008-02-06 10:17 AM
Re: Loop : Desktop Shortcut Check
[Re: Richard H.]
|
henkie32
Fresh Scripter
Registered: 2008-02-01
Posts: 17
|
that did the trick... i now created two scripts
one for office 2003 one for office 2007
the script checks if powerpoint, excel and word are present on users desktop by checking shortcut targets.
if they dont exists shortcuts are created.. (not copied)
shall i post the complete script here?
Edit:
when testing i found out one last problem: what if the shortcut is present in "all users"? can i use an "or" to also check in all users?
thx for your help!!
Edited by henkie32 (2008-02-06 10:20 AM)
|
Top
|
|
|
|
#185110 - 2008-02-06 12:36 PM
Re: Loop : Desktop Shortcut Check
[Re: Richard H.]
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Here is the code to do it, don't forget to include the GetShortCutProperties udf.
Break ON $=SetOption("Explicit","ON")
Dim $sTargets
$sTargets=udfGetTargets(%ALLUSERSPROFILE%+"\Desktop")+@CRLF+udfGetTargets(%USERPROFILE%+"\Desktop")
If Not InStr($sTargets,"xlicons") "No XLICONS present - will install..."+@CRLF EndIf
Function udfGetTargets($sPath) Dim $asDirEntries Dim $sLink
$sLink=Dir($sPath+"\*.lnk") While $sLink $udfGetTargets=$udfGetTargets+@CRLF+GetShortCutProperties($sPath+"\"+$sLink,'Path') $sLink=Dir() Loop $udfGetTargets=SubStr($udfGetTargets,3) EndFunction
| |
|
Top
|
|
|
|
#185130 - 2008-02-07 12:06 PM
Re: Loop : Desktop Shortcut Check
[Re: Richard H.]
|
henkie32
Fresh Scripter
Registered: 2008-02-01
Posts: 17
|
thx for your reply Richard, i got it to work with the script above
|
Top
|
|
|
|
#185172 - 2008-02-08 03:21 PM
Re: Loop : Desktop Shortcut Check
[Re: henkie32]
|
henkie32
Fresh Scripter
Registered: 2008-02-01
Posts: 17
|
Script works like a charm.. only thing is it doesnt list shortcuts that are in "all users"
so when i have word and exel for example in all users and not on the current desktop.. the script will place two new shortcuts so my current desktop then has double word and exel shortcuts.
so what iam trying to do now is listing two directorys with dirlist and put them in one array..
what would be the best way to do this?
1) use one dirlist command to list two directories if possible so the output would be in one array directly 2) use two dirlist commands and concat the output in one array
i tried option one but i didnt came further. now trying option two but i cant find some material on concatinating arrays on the forum perhaps someone can point me in the right direction?
cheers. example.
$sublist1 = DirList('C:\Documents and Settings\%username%\Bureaublad\*.lnk', 2)
$sublist2 = DirList('C:\Documents and Settings\All Users\Bureaublad*.lnk', 2)
$List = $sublist1.$sublist2
Edited by henkie32 (2008-02-08 03:43 PM)
|
Top
|
|
|
|
#185180 - 2008-02-08 05:01 PM
Re: Loop : Desktop Shortcut Check
[Re: Richard H.]
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Here you go - it take quite a bit longer to run (on my machine at least) so you might want to limit the scope a bit more:
Break ON $=SetOption("Explicit","ON")
Dim $sTargets
$sTargets=udfGetTargets(%ALLUSERSPROFILE%)+@CRLF+udfGetTargets(%USERPROFILE%)
If Not InStr($sTargets,"xlicons") "No XLICONS present - will install..."+@CRLF EndIf
Function udfGetTargets($sPath) Dim $asDirEntries Dim $sLink
$asDirEntries=DirList($sPath+"\*.lnk", 2+4)
For Each $sLink in $asDirEntries "Getting path from: "+$sLink+@CRLF $udfGetTargets=$udfGetTargets+@CRLF+GetShortCutProperties($sLink,'Path') Next $udfGetTargets=SubStr($udfGetTargets,3) EndFunction
|
This code gives me a much larger list which I can't post here as it has sensitive information
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 436 anonymous users online.
|
|
|