#178735 - 2007-08-06 07:55 PM
Loop : Desktop Shortcut Check
|
vt_techie2006
Lurker
Registered: 2006-09-20
Posts: 3
|
Hello All !
I think the best route to what I'm trying to accomplish is via the following methodology, though I am open to alternative methods :
Purpose of Script : Check to see if there is an 'Outlook' shortcut on the Desktop. If there is, do nothing. If there is not, copy the shortcut to the desktop.
As per the 'purpose,' I'm looking to write a 'while-loop' to determine whether or not a user has the Outlook shorcut on their desktop.
For each shortcut, I'd check the name of the shortcut to see if it contains the word 'Outlook' as desktops are not all uniform.
If one shortcut CONTAINED the name 'Outlook,' I would do nothing.
If however at the end of the loop, there was no Outlook shortcut, I'd create one.
Any help in this regard would be greatly appreciated !
I just downloaded the doc, but didn't want to recreate the wheel if it already exists.
Thanks for any insight,
V.
|
Top
|
|
|
|
#185004 - 2008-02-01 10:08 AM
Re: Loop : Desktop Shortcut Check
[Re: Mart]
|
henkie32
Fresh Scripter
Registered: 2008-02-01
Posts: 17
|
hey guys,
i was looking for a script that does the same thing you want it to, but then with word, poweroint and exel.
i was thinking about checking the target of the shortcut in order to see if it really is a shortcut to an office program
there any script like this yet?
thx in advance!
|
Top
|
|
|
|
#185025 - 2008-02-01 04:18 PM
Re: Loop : Desktop Shortcut Check
[Re: Mart]
|
henkie32
Fresh Scripter
Registered: 2008-02-01
Posts: 17
|
yeah i could check the names.. but what happends if a user renamed the shortcut to something else then "word"....
i want to make a script for each office application:
the script has to list all .lnk files on the desktop. perform a check on that list, if a file in the list contains a shortcut to "c:\program files\office12\msword.exe" do nothing if not then it has to copy over a new shortcut and then die
i only want shortcuts to word, powerpoint and exel so 3 scripts should do the job.
also i still have the problem of having a network with office 2003 and office 2007... but i kinda solved that using a batch script wich checks for the existence of office12 in program files (wich means 2007 is present)
if im unclear pls notice me
|
Top
|
|
|
|
#185030 - 2008-02-01 05:03 PM
Re: Loop : Desktop Shortcut Check
[Re: Mart]
|
henkie32
Fresh Scripter
Registered: 2008-02-01
Posts: 17
|
so basicly what i need to do:
- use dirlist to create a list of .lnk files and put them in an array
- use shortcuttarget to retrieve the targets of each .lnk in the array
- use some script to check the array for word, powerpoint and exel. if not present copy over new shortcuts
so the thing im still missing is a script to check an array for values
|
Top
|
|
|
|
#185040 - 2008-02-02 09:21 PM
Re: Loop : Desktop Shortcut Check
[Re: Gargoyle]
|
henkie32
Fresh Scripter
Registered: 2008-02-01
Posts: 17
|
ok, will try this wednessday.. will post the results here.. thx for your replies so far!
|
Top
|
|
|
|
#185080 - 2008-02-05 02:53 PM
Re: Loop : Desktop Shortcut Check
[Re: henkie32]
|
henkie32
Fresh Scripter
Registered: 2008-02-01
Posts: 17
|
thx, i changed the script to:
$List = DirList("C:\Documents and Settings\Thijs\Bureaublad") For each $lnk in $list $Path = GetShortCutProperties($lnk,"Path") If Instr($path,"notes.exe") del c:\test\test1 Else del c:\test\test2 EndIf Next
so when test1 is delled, the script finds a link containing lotus.exe
But i cant get this to work.. i got a shortcut on my desktop wich holds: C:\Lotus\Notes\notes.exe
so i let the script look for notes.exe.. it doesnt seem to find it
what am i doing wrong?
|
Top
|
|
|
|
#185082 - 2008-02-05 03:38 PM
Re: Loop : Desktop Shortcut Check
[Re: Mart]
|
henkie32
Fresh Scripter
Registered: 2008-02-01
Posts: 17
|
test1 and test2 are files with no extension..
the script does del test2..
but there is a word shortcut on the desktop wich it cant seem to find so it wont del test1
|
Top
|
|
|
|
#185084 - 2008-02-05 04:14 PM
Re: Loop : Desktop Shortcut Check
[Re: henkie32]
|
Glenn Barnas
KiX Supporter
Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
|
Not really sure how any of this is working...
You're using DirList with no optional arguments; specifying a full path, but getting back file names; and exepect to find a "file" that you found in "path" without looking in "path\file"??? You're also returning a list of ALL files, not just shortcuts.
The way you're defining DirList("path"), you're getting an array of FILE NAMES - ie: "Word", "Excel", and so on. When you call the GetShortcutProperties UDF, you pass this name, but not the path, so the UDF has no clue where to look. You have two choices to make this work - add the path to the GetShortcutProperties UDF, or specify the optional arg in DirList to return full paths.
Here's a working example, with comments and debugging messages:
Dim $List ; array of LNK files
Dim $Lnk ; array enumerator
Dim $Path ; target path
; Get list of LNK files (shortcuts), returning full paths
$List = DirList('%USERPROFILE%\Desktop\*.lnk', 2)
; Enumerate the array
For Each $Lnk in $List
'Processing ' $Lnk ?
$Path = GetShortCutProperties($Lnk, 'Path')
'Path: ' $Path ?
If Instr($Path, 'IExplore.exe')
'Found Explorer!' ?
Else
'Explorer was not found' ?
EndIf
Next
Try this script WITHOUT the "2" argument in DirList and you'll see why GetShortcutProperties won't work reliably. Also, using "%USERPROFILE%" is recommended over hard coding the documents path, although you might need to change the "desktop" reference.
I searched for Explorer, since that is a link I had on my desktop. I'd suggest you start there and then modify your code.
Also - from a command prompt, run "DIR %USERPROFILE%\Desktop" and see what file names are returned - you might be surprised.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
Top
|
|
|
|
#185086 - 2008-02-05 04:24 PM
Re: Loop : Desktop Shortcut Check
[Re: Glenn Barnas]
|
henkie32
Fresh Scripter
Registered: 2008-02-01
Posts: 17
|
this did the trick for me.. the only thing left now is to create the shortcut if it doesnt exists...
but im sure there's an udf for it thx for your help!
|
Top
|
|
|
|
#185087 - 2008-02-05 04:31 PM
Re: Loop : Desktop Shortcut Check
[Re: henkie32]
|
henkie32
Fresh Scripter
Registered: 2008-02-01
Posts: 17
|
hmm..
so now it runs through every .lnk checking if it holds a string true/false
how should i configure it?
true -> do nothing false -> copy shortcut ;it will still copy if the first shortcut doesnt hold the string, but the last one does for example.. how can i secure this?
perhaps put the results of the strings in an array? and test the array for strings later on in the script..
Edited by henkie32 (2008-02-05 04:33 PM)
|
Top
|
|
|
|
#185092 - 2008-02-05 05:19 PM
Re: Loop : Desktop Shortcut Check
[Re: Glenn Barnas]
|
henkie32
Fresh Scripter
Registered: 2008-02-01
Posts: 17
|
jup i want to verify if a user has the shortcuts to powerpoint, exel and word on his desktop.. if not copy them over
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 84 anonymous users online.
|
|
|