|
|
|||||||
I am building a script that will delete a mapped network drive and the desktop shortcut which relates to this network drive. My pdc and bdc platforms are NT and my workstation platforms are XP, 2000, 98, NT. I have no problem with deleting the mapped network drive was just wondering how to delete the desktop shortcut. Aany help much appreciated guys. |
||||||||
|
|
|||||||
if it's named properly that would not be problem. if it's named whatever, you can't do anything about it without some nice cracks. anyway, you will locate users desktop with: $desktop=readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Desktop") and to delete known named link: $file="mydrive.lnk" del $desktop+"\$file" if you then have no idea of the name, you would need to dir the desktop and check all files if they are lnk and if yes, then check if they point to that location... can write that for you too if you need it... just say |
||||||||
|
|
|||||||
Sorry about this i just tested my script on an NT workstation and nothing happened. What scipt would you write which would delete a network connection t: "fileserver\net_share" and a desktop shortcut named - shortcut to net_share on 'fileserver' (t). |
||||||||
|
|
|||||||
I would add some file content scanning in there... like: code:not tested as did it just from head...$desktop=readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Desktop") |
||||||||
|
|
|||||||
It really depends on where the shortcut is stored, either in the 'All Users' profile, the 'Default User' profile, or the current user's profile. If it's in 'All Users' or 'Default Users' then you'll need administrative permissions to delete that file. |
||||||||
|
|
|||||||
try this code:Break on |
||||||||
|
|
|||||||
mmm... so rad you have spent time with this... anyway the shortcut gets deleted if it has in it's name the drive... |
||||||||
|
|
|||||||
Radimus you have really confused me. i am only new to this. Right. Every user has their t drive mapped to the same network path. I wish to remove this and the desktop shortcut which is named the same on every user's desktop. |
||||||||
|
|
|||||||
but is it on users desktop? if it is in all users\desktop you can't probably delete it in logonscript as most likely normal user has no rights to delete it. |
||||||||
|
|
|||||||
you can because when i configure a new machine i manually mapp the network drive in the user profile. Therefore you dont need administrative rights to delete it. |
||||||||
|
|
|||||||
so, I can't see why my first sample didn't work for you. |
||||||||
|
|
|||||||
im sorry i haven't tested your script yet, was just confused by radimus. Could you please explain what happens at each stage of the script, so it can understand the process. |
||||||||
|
|
|||||||
well, it scans all link files in desktop folder and if it links to the pointed place it deletes the link. anyway, if you know the name of the link-file you just need to specify it and use my first sample. it reads from registry the place of users desktop folder and deletes the file from there: code:;your filename here: |
||||||||
|
|
|||||||
it only deletes the shortcut if the servername and sharename are in the 'shortcut to' Driveprop() is a UDF described in the UDF forum, and it's purpose is to return and array of values of the types described in the $DrivePara array The Deldrive() function only will operate if it is passed a drive letter that it a network drive type (not a CD drive letter) it will only function if you give it a network drive to delete. beyond that, just read the code line by line... it is just little steps |
||||||||
|
|
|||||||
Lets start from the beginning in simple terms to a beginner(me). what would be the command to delete a mapped network drive. I have mapped T to \\fileserver\net_share. deldrive t: "\\fileserver\net_share" This does not work can someone please explain in simple terms explaining what each stage of the script does. |
||||||||
|
|
|||||||
To for example delete a mapped drive T: you just need to do a code:However, the question was more related to how to delete an shortcut on the user's desktop.use T: /delete /persistent |
||||||||
|
|
|||||||
Thanks sealeopard. Now could you show me how to delete the shortcut on the desktop which is called - shortcut to net_share on 'fileserver' (T). I woiuld really appreciate it if you could explain what is happening at each stage. |
||||||||
|
|
|||||||
$desktop=readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Desktop") del "$desktop\shortcut to net_share on 'fileserver' (T).lnk" Click here for more detail [ 06. August 2002, 17:42: Message edited by: Radimus ] |
||||||||
|
|
|||||||
It didnt work. sorry. |
||||||||
|
|
|||||||
more detail.... |
||||||||
|
|
|||||||
I checked the help file, but i can't quite grasp the idea of com automation and variables yet. Below is what i have created for a user called - smithb. Everything is fine except it doesn't seem to delete the desktop shortcut. I am off home now so any ideas overnight are much appreciated. If @userid = 'smithb' use t: /delete /persistent $desktop=readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurentVersion\Explorer\User Shell Folders","Desktop") $file="shortcut to net_share on 'fileserver'(T).lnk" del $desktop+"\$file" Endif |
||||||||
|
|
|||||||
the shortcut can be with another extension. anyway, if you change the del line to: del "$desktop\shortcut to net_share on 'fileserver' (T)*" there is no way it can stay there. |
||||||||
|
|
|||||||
you may need to do: $desktop=readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Desktop") $desktop=expandenvironmentvars($desktop) |
||||||||
|
|
|||||||
code:I hope this is extensive enough, if you need an even more detailed explanation, then I would suggest you play around with the examples in the KiXtart manual to understand what each command/function/macro is doing.use T: /delete /persistent [ 06. August 2002, 19:26: Message edited by: sealeopard ] |
||||||||
|
|
|||||||
btw... if you use my code, you only need to do: deldrive("h") or deldrive("t") as long as you have the 2 functions located somewhere in the script... commonly in the end. refer to the usages of functions. requires kix 4+ If you need it, I can repost it with the test code still in. |
||||||||
|
|
|||||||
Finally completed this stage, thanks to all you guys, the help is much appreciated. |