Re: invokeVerb method in Vista



Alex,

I ran into the same problem when I started running scripts using verbs on Vista. I don't know exactly _why_ this happens, but I have found how to work around it.

Instead of going to the item and invoking the verb by name, I retrieve the item's verb collection and test for the verb name, so I have the actual verb object. I then invoke the verb's DoIt() method. So where you have the
objFolderItem.invokeVerb("P&in to Start Menu")
line, I would instead substitute something like this:

For each verb in objFolderItem.Verbs()
if verb.Name = "P&in to Start Menu" then verb.DoIt()
Next

I haven't the foggiest idea why this happens. To tell the truth, I didn't even try to find out since looping through the verbs worked fine.

<alexwu99@xxxxxxxxx> wrote in message news:07d07d5c-56a6-41a7-b47e-f5a3f73ecc48@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

I have read answers from you about scripting in windows and some of
the really useful to me!

I have a question about vbscripting in windows vista.
I have written a vbscript to pin a exe file on desktop to start menu
by using "invokeVerb("P&in to Start Menu").

Set objShell = CreateObject("Shell.Application")
strdesktopFld = objShell.SpecialFolders("Desktop")
Set objFolder = objShell.Namespace(strdesktopFld&"\")
Set objFolderItem = objFolder.ParseName("calc.exe")
objFolderItem.invokeVerb("P&in to Start Menu")
msgbox "wait.."

I have tried to use msgbox or wscript.sleep 1000 at the end but it
just nothing happen.

This script is work in XP and I just wonder if there is any scripting
tricks in vista.

Bests,
Alex
p.s. I have put this question in "microsoft.public.scripting.wsh"
groups.google

.


Loading