#89646 - 2002-11-27 04:40 PM
Re: help with creating shortcuts with shellLinkObject
|
DonKing
Fresh Scripter
Registered: 2002-11-27
Posts: 22
|
Well call me a nono, but so far I'm unsuccesful in copying these shortcuts.
When I use xcopy to copy a shortcut it creates a folder with a target.lnk file in it. The shortcut then doesn't function anymore.
The goal of this all is to supply users with the shortcuts to network resources they need to have access to. So some users need to get more shortcuts then others depending on their profile. Either the shortcuts are created per user at logon, or centrally stored shortcuts are distributed to users folders whichever is the most efficient/feasable.
Using folder shortcuts solves the problem of users being able to see folders they don't have access to. This is a big disadvantage of Windows. Novell offers the Filescan permission that MS lacks.
|
Top
|
|
|
|
#89648 - 2002-11-27 04:59 PM
Re: help with creating shortcuts with shellLinkObject
|
DonKing
Fresh Scripter
Registered: 2002-11-27
Posts: 22
|
That would be great!
I'm sure a lot more people will be very grateful when there is a solution to this problem.
I've seen many posts in forums asking how folders can be made invisible to users. If this works they can!
I'll check again tomorrow.
Don
|
Top
|
|
|
|
#89651 - 2002-11-28 02:12 AM
Re: help with creating shortcuts with shellLinkObject
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
and, the code. I don't know do I have enough will to post this in UDF library but here it is:
code:
function Link($LinkDest, optional $workdir, optional $description, optional $saveas) dim $Shell,$LinkDestFolderItems,$item,$verb,$new,$Shortcut $Shell=createobject("Shell.application") $LinkDest=$Shell.namespace($LinkDest).self
for each $item in $LinkDest.parent.items if $item.islink $LinkDestFolderItems=$LinkDestFolderItems+$item.modifydate+chr(10) endif next
for each $verb in $LinkDest.verbs if instr(join(split($verb,"&"),""),readvalue("HKEY_CLASSES_ROOT\lnkfile","")) $LinkDest.invokeverb(""+$verb) endif next
for each $item in $LinkDest.parent.items if $item.islink $new=1 for each $itemBefore in split(left($LinkDestFolderItems,len($LinkDestFolderItems)-1),chr(10)) if $itemBefore=$item.modifydate $new=0 endif next if $new $Shortcut=$item.getlink del $item.path endif endif next if not vartype($Shortcut) exit 4 endif $Shortcut.description=""+$description $Shortcut.workingdirectory=""+$workdir $Shortcut.save(""+$saveas) endfunction
you call it like: link("c:\targetOFtheShortcut","Workindirectorysetting for the shortcut","description, what ever","fully qualified name of the shortcut to saveas")
so, I had these: link("C:\Documents and Settings\lonkero\desktop\KiXforms\mine","x:\","testing...","c:\dude.lnk")
and it worked fine.
_________________________
!download KiXnet
|
Top
|
|
|
|
#89659 - 2002-11-28 03:01 AM
Re: help with creating shortcuts with shellLinkObject
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
|
Top
|
|
|
|
#89662 - 2002-11-28 09:18 AM
Re: help with creating shortcuts with shellLinkObject
|
DonKing
Fresh Scripter
Registered: 2002-11-27
Posts: 22
|
First, it wasn't my intention to hijaak this thread. Sorry for that....
Let me clarify myself by explaining the whole story:
We supply our users with a driveletter connection to their department data. But requests have come in to give users access to multiple department folders. One option is to connect multiple driveletters, but we have only 26 and we have little driveletters left. The second option is to map the drive one share up, but then the user can see ALL subfolders (departments) including the ones the users doesn't have access to. It is impossible to hide these folders by changing NTFS permissions our other tricks.
Then I came up with another solution. What if we map a driveletter to an empty folder in the users roaming profile and copy the appropriate folder shortcuts (to different shares on the network) to that mapping during logon. Then the user only sees the folders he needs to see, and is still using only one driveletter. This would be a very flexible solution as there is no limit to the amount of shortcuts. The problem with folder shortcuts however is that distribution or creation through a logonscript is a bit of a problem. Ordinary shortcuts won't do as browsing back and forth through the folderstructure goes bad as soon as you go back up the structure. Then the user will see the entire network instead of the path he came from.
So using folder shortcuts is a workaround for the problem of not being able to hide folders in a Windows network.
The not hiding part is a problem that comes up frequently on network admins forums. If we can create a workaround as described many would be happy I think. At least I would!
So indeed I mean the shortcuts as one can create under My Network places, but I want to create them through a script OR be able to copy the shortcuts I make myself during logon. Both solutions are a problem for me.
I hope this clarifies the goal of my questions.
Don
|
Top
|
|
|
|
#89663 - 2002-11-28 09:54 AM
Re: help with creating shortcuts with shellLinkObject
|
DonKing
Fresh Scripter
Registered: 2002-11-27
Posts: 22
|
Lonkero,
I've tried the code and it stops at: if not vartype($Shortcut) exit 4
When debugging (/D) the script loops a few times at: if $item.islink ... next and then jumps to the line above (if not vartype($Shortcut) exit 4).
I called the function as follows: Link("\\s300-100\software$","g:\","TESTLINK...","e:\ff\testlink")
|
Top
|
|
|
|
#89664 - 2002-11-28 10:20 AM
Re: help with creating shortcuts with shellLinkObject
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
well, like I said, it needs access to parent item which it doesn't have. and, if it would work, you would still need to call it with proper ending (.lnk) Link("\\s300-100\software$","g:\","TESTLINK...","e:\ff\testlink.lnk")
anyway, I checked on that folder link thing. it is nothing more than a link file inside a folder...
I might explain a little. the link user sees actually is a folder and in that folder there is two files. target.lnk and the faker. with faker I mean the normal "hide" util of windows world, desktop.ini
I got tired coding it but everything else has worked fine but I've been unable to do shortcuts to shares... well proper shortcuts.
share shortcuts are easy to do with .url: [InternetShortcut] URL=file://gws_pikval/e IconIndex=9 IconFile=C:\WINNT\system32\SHELL32.DLL
anyway, will have to see more on that once I get my eyes open.
_________________________
!download KiXnet
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 331 anonymous users online.
|
|
|