![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Deleting a .lnk via VBScript I have a process by which I push icons to distant Vista based PCs on our domain...it's all automated. One of these items is a shortcut (call it MYLINK.LNK) which I put in the user's Start Menu. That shortcut calls a .WSF script that, in turn, runs a JScript followed by a VBScript. The JScript installs a commercial product and the VBScript is used to clean up after itself. One of those 'clean up' jobs is to delete the icon that kicked off this entire thing. So I have : Set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.DeleteFile("C:\temp\startload.wsf") objFSO.DeleteFile("C:\temp\loadapp.jss") objFSO.DeleteFile("C:\temp\cleanup.vbs") objFSO.DeleteFile("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\QC\MYLINK.LNK") Everything gets deleted except for the .LNK file which is now useless since it points to the .WSF file which just got deleted. When I get to the .LNK the script crashes w/ a "Permission Denied". So I checked the permissions on the file. Administrators and System have full access. The shortcut is owned by Administrators. The user running the script is currently in the Administrator's group, I remove him later but for the moment the user IS in that group. So why will that file not vanish like a good little icon? I have found suggestions here and there, none of which apply specifically to this and I can't remove the folder (which would be easier I suppose, but that's a non-starter). CJ |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Deleting a .lnk via VBScript "DTSIGuy" <DTSIGuy@xxxxxx> wrote in message news:B6DD79AD-A73E-41EC-887A-11C32B6EF1C7@xxxxxx Quote: >I have a process by which I push icons to distant Vista based PCs on our > domain...it's all automated. One of these items is a shortcut (call it > MYLINK.LNK) which I put in the user's Start Menu. That shortcut calls a > .WSF > script that, in turn, runs a JScript followed by a VBScript. > > The JScript installs a commercial product and the VBScript is used to > clean > up after itself. One of those 'clean up' jobs is to delete the icon that > kicked off this entire thing. > > So I have : > > Set objFSO = CreateObject("Scripting.FileSystemObject") > objFSO.DeleteFile("C:\temp\startload.wsf") > objFSO.DeleteFile("C:\temp\loadapp.jss") > objFSO.DeleteFile("C:\temp\cleanup.vbs") > objFSO.DeleteFile("C:\ProgramData\Microsoft\Windows\Start > Menu\Programs\QC\MYLINK.LNK") > > Everything gets deleted except for the .LNK file which is now useless > since > it points to the .WSF file which just got deleted. When I get to the .LNK > the script crashes w/ a "Permission Denied". > > So I checked the permissions on the file. Administrators and System have > full access. The shortcut is owned by Administrators. The user running > the > script is currently in the Administrator's group, I remove him later but > for > the moment the user IS in that group. > > So why will that file not vanish like a good little icon? > > I have found suggestions here and there, none of which apply specifically > to > this and I can't remove the folder (which would be easier I suppose, but > that's a non-starter). > > CJ manually while logged on under the same account as the one used to run the script? |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Deleting a .lnk via VBScript Ironic; this is a UAC problem. : ) On Vista, when UAC is enabled, an application run by a user who is not the actual Administrator can't perform operations that require administrative privileges unless it requests those privileges as it starts. If you were to go to the machine in question and try to delete the shortcut as the user, you would get a dialog box that has "access denied" in the title bar (but a message that reads "you need to confirm this operation"). There are several ways to work around the problem, but here's a simple one that should fix the issue, assuming that the user is actually in attendance. If you can pass the deletion request through the Windows shell, it will raise an elevation prompt for the user to confirm. This works well enough if you're having the user do things interactively. Here's a code snippet that handles the problem: Dim sa Set sa = CreateObject("Shell.Application") Set ns = sa.NameSpace("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\QC") set link = ns.Items().Item("MYLINK.LNK") Set verbs = link.verbs for each verb in link.verbs 'WScript.Echo verb.Name if verb.Name = "&Delete" Then verb.Doit() exit for end if next "DTSIGuy" <DTSIGuy@xxxxxx> wrote in message news:B6DD79AD-A73E-41EC-887A-11C32B6EF1C7@xxxxxx Quote: > I have a process by which I push icons to distant Vista based PCs on our > domain...it's all automated. One of these items is a shortcut (call it > MYLINK.LNK) which I put in the user's Start Menu. That shortcut calls a > .WSF > script that, in turn, runs a JScript followed by a VBScript. > > The JScript installs a commercial product and the VBScript is used to > clean > up after itself. One of those 'clean up' jobs is to delete the icon that > kicked off this entire thing. > > So I have : > > Set objFSO = CreateObject("Scripting.FileSystemObject") > objFSO.DeleteFile("C:\temp\startload.wsf") > objFSO.DeleteFile("C:\temp\loadapp.jss") > objFSO.DeleteFile("C:\temp\cleanup.vbs") > objFSO.DeleteFile("C:\ProgramData\Microsoft\Windows\Start > Menu\Programs\QC\MYLINK.LNK") > > Everything gets deleted except for the .LNK file which is now useless > since > it points to the .WSF file which just got deleted. When I get to the .LNK > the script crashes w/ a "Permission Denied". > > So I checked the permissions on the file. Administrators and System have > full access. The shortcut is owned by Administrators. The user running > the > script is currently in the Administrator's group, I remove him later but > for > the moment the user IS in that group. > > So why will that file not vanish like a good little icon? > > I have found suggestions here and there, none of which apply specifically > to > this and I can't remove the folder (which would be easier I suppose, but > that's a non-starter). > > CJ > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Deleting a .lnk via VBScript Thanks guys...I'll check it out. I wonder if UAC actually stands for UnAble to Comply? <argh> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| New to VBscript, Help please! | VB Script | |||
| CSS and VBscript | VB Script | |||
| VBscript Help | VB Script | |||
| How to do No hang up VBScript (nohup for VBScript) | VB Script | |||
| vbscript and HTA help | VB Script | |||