Re: Vista UAC problem with WScript.Shell Run method



Hi Luke,

sorry for late reply.

Yes, your suggestion make a lot of sense...

This is very similar to what I was trying, but I was invoking the wrong
verb. If I invoke the "runas" verb, even from a VBS, without writing a
special application, it works fine. My mistake was invoking the "RunAs
Administrator" verb (this is the verb returned by the Verbs collection of a
shell item), but this is just the "cosmetic" version of the verb, not the
actual one. In this Vista is very different from XP. In XP you need to
invoke verbs exactly as you get from the Verbs collection, while in Vista
not.
A simple VBS script that run a BAT with elevation is the following:

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\")
Set objFolderItem = objFolder.ParseName("mybat.bat")
objFolderItem.InvokeVerb "runas"

This will bring up the UAC elevation confirmation box and (if allowed) run
mybat.bat in elevated privilege mode.
This means that, if mybat.bat runs several programs that require elevation,
you'll get the confirmation box only once instead of many if you simply run
the mybat.bat alone.

Hope this may help other people.

Thanks a lot.

Massimo.

"Luke Zhang [MSFT]" <lukezhan@xxxxxxxxxxxxxxxxxxxx> ha scritto nel messaggio
news:LwY77fJNHHA.2300@xxxxxxxxxxxxxxxxxxxxxxxxx
Hello,

Did my previous reply make sense on this issue? If you need more
information on this issue, please feel free to let us know.

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.





.



Relevant Pages

  • RFC: new module Net::SMTP::PostfixExt
    ... I'm working on a module that adds support for some Postfix ... The XCLIENT and XFORWARD protocols are extensions to the ... HELO Set the value for the HELO/EHLO verb ... F Verb supported by the XFORWARD extension ...
    (comp.lang.perl.modules)
  • Re: Print a file of any type given file path
    ... images only support the "printto" verb and I am not sure how to ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Detect/Set printer online state
    ... Alex K. Angelopoulos wrote: ... I tried it with just verb and got "Type mismatch". ... verb.DoItalso returns "Object doesn't support this property or ...
    (microsoft.public.scripting.vbscript)
  • RE: Elevate permission of code
    ... As for the privilege elevation, I'm afraid you're limited to the Vista ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.platformsdk.security)
  • RE: Elevate permission of code
    ... As for the privilege elevation, I'm afraid you're limited to the Vista ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.platformsdk.security)