Windows Vista Forums
Vista Forums Home Join Vista Forums Tech Publications Windows 7 Forum Vista Tutorials Webcasts Tags

Welcome to Vista Forums we are your forum for Windows Vista help and discussion. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Vista Newsgroups > Vista security

Running an HTA or WSH script as administrator

Update your Vista Drivers
Reply
 
Thread Tools Display Modes
Old 01-05-2007   #1 (permalink)
Guest


 

Running an HTA or WSH script as administrator

Hi,

does anyone knows how to run an HTA file as administrator with UAC enabled ?
HTA doensn't have the "Run as administrator" in the context menu, doesn't
have the compatibility tab in the properties and seems to completely ignore
a myapp.hta.manifest file. The runas command with /trustlevel:unrestricted
doesn't work. I cannot runas built-in administrator because this is disabled
by default (and it's better to leave disabled)
I even tryed to run cmd as administrator and run the HTA from there, but it
still don't have administrative rights (I think it creates a new context
with lower trustlevel).
I've the same problem with WSH scripts (i.e. VBS).
I'm not in a domain, so I cannot use group policy.

Thanks for any help.

Massimo.



My System SpecsSystem Spec
Old 01-05-2007   #2 (permalink)
Jesper
Guest


 

RE: Running an HTA or WSH script as administrator

HTAs, and also scripts, are not applications per se. Therefore, they do not
have the "Run as administrator" in the context menu. They are simply scripts,
interpreted by mshta.exe and cscript.exe.

When I run an HTA from an elevated command prompt, however, mshta.exe is a
full admin. How are you determining that it is not in your case?

"m.piceni@newsgroup.nospam" wrote:

> Hi,
>
> does anyone knows how to run an HTA file as administrator with UAC enabled ?
> HTA doensn't have the "Run as administrator" in the context menu, doesn't
> have the compatibility tab in the properties and seems to completely ignore
> a myapp.hta.manifest file. The runas command with /trustlevel:unrestricted
> doesn't work. I cannot runas built-in administrator because this is disabled
> by default (and it's better to leave disabled)
> I even tryed to run cmd as administrator and run the HTA from there, but it
> still don't have administrative rights (I think it creates a new context
> with lower trustlevel).
> I've the same problem with WSH scripts (i.e. VBS).
> I'm not in a domain, so I cannot use group policy.
>
> Thanks for any help.
>
> Massimo.
>
>
>

My System SpecsSystem Spec
Old 01-05-2007   #3 (permalink)
Jesper
Guest


 

RE: Running an HTA or WSH script as administrator

Forgot to mention, if you want to add the "Run as administrator" item to the
context menu for HTA files or scripts you can do that by hacking the
registry. Here is a reg script that does it for HTA files:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\htafile\shell\runas]

[HKEY_CLASSES_ROOT\htafile\shell\runas\command]
@="C:\\Windows\\system32\\mshta.exe \"%1\" %*"
"IsolatedCommand"="C:\\Windows\\system32\\mshta.exe \"%1\" %*"



"Jesper" wrote:

> HTAs, and also scripts, are not applications per se. Therefore, they do not
> have the "Run as administrator" in the context menu. They are simply scripts,
> interpreted by mshta.exe and cscript.exe.
>
> When I run an HTA from an elevated command prompt, however, mshta.exe is a
> full admin. How are you determining that it is not in your case?
>
> "m.piceni@newsgroup.nospam" wrote:
>
> > Hi,
> >
> > does anyone knows how to run an HTA file as administrator with UAC enabled ?
> > HTA doensn't have the "Run as administrator" in the context menu, doesn't
> > have the compatibility tab in the properties and seems to completely ignore
> > a myapp.hta.manifest file. The runas command with /trustlevel:unrestricted
> > doesn't work. I cannot runas built-in administrator because this is disabled
> > by default (and it's better to leave disabled)
> > I even tryed to run cmd as administrator and run the HTA from there, but it
> > still don't have administrative rights (I think it creates a new context
> > with lower trustlevel).
> > I've the same problem with WSH scripts (i.e. VBS).
> > I'm not in a domain, so I cannot use group policy.
> >
> > Thanks for any help.
> >
> > Massimo.
> >
> >
> >

My System SpecsSystem Spec
Old 01-10-2007   #4 (permalink)
Guest


 

Re: Running an HTA or WSH script as administrator

Hi Jesper,

the REG script works fine. Using it you can run an HTA in elevated mode from
a script, in this simple way:

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

This will bring up the Vista confirmation box and then run c:\myhta.hta in
elevated mode.
This will run on any executable that has the "Run as Administrator" in the
context menu (BAT, COM, EXE, etc.)

Thanks.

Massimo.

"Jesper" <Jesper@discussions.microsoft.com> ha scritto nel messaggio
news:488DBE68-8D45-4197-BD80-620010925102@microsoft.com...
> Forgot to mention, if you want to add the "Run as administrator" item to
> the
> context menu for HTA files or scripts you can do that by hacking the
> registry. Here is a reg script that does it for HTA files:
>
> Windows Registry Editor Version 5.00
>
> [HKEY_CLASSES_ROOT\htafile\shell\runas]
>
> [HKEY_CLASSES_ROOT\htafile\shell\runas\command]
> @="C:\\Windows\\system32\\mshta.exe \"%1\" %*"
> "IsolatedCommand"="C:\\Windows\\system32\\mshta.exe \"%1\" %*"
>
>
>
> "Jesper" wrote:
>
>> HTAs, and also scripts, are not applications per se. Therefore, they do
>> not
>> have the "Run as administrator" in the context menu. They are simply
>> scripts,
>> interpreted by mshta.exe and cscript.exe.
>>
>> When I run an HTA from an elevated command prompt, however, mshta.exe is
>> a
>> full admin. How are you determining that it is not in your case?
>>
>> "m.piceni@newsgroup.nospam" wrote:
>>
>> > Hi,
>> >
>> > does anyone knows how to run an HTA file as administrator with UAC
>> > enabled ?
>> > HTA doensn't have the "Run as administrator" in the context menu,
>> > doesn't
>> > have the compatibility tab in the properties and seems to completely
>> > ignore
>> > a myapp.hta.manifest file. The runas command with
>> > /trustlevel:unrestricted
>> > doesn't work. I cannot runas built-in administrator because this is
>> > disabled
>> > by default (and it's better to leave disabled)
>> > I even tryed to run cmd as administrator and run the HTA from there,
>> > but it
>> > still don't have administrative rights (I think it creates a new
>> > context
>> > with lower trustlevel).
>> > I've the same problem with WSH scripts (i.e. VBS).
>> > I'm not in a domain, so I cannot use group policy.
>> >
>> > Thanks for any help.
>> >
>> > Massimo.
>> >
>> >
>> >



My System SpecsSystem Spec
Reply
Update your Vista Drivers

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Debugging or even running a script in MSE7 Bob Bridges VB Script 0 08-13-2008 12:46 AM
Problems running an app from within a script Aether PowerShell 3 01-28-2008 05:07 PM
Logon script not running? Murphy Wong Vista General 2 08-25-2007 07:44 AM
trouble running a script BJ Daniels PowerShell 3 08-20-2007 04:10 PM
Help on running a a script Toxic PowerShell 3 12-05-2006 12:35 PM


Complimentary Industry Resources

Vista Forums has joined forces with TradePub.com to offer you a new, exciting, and entirely free professional resource. Visit http://vistax64.tradepub.com today to browse our selection of complimentary Industry magazines, white papers, webinars, podcasts, and more across 34 industry sectors. No credit cards, coupons, or promo codes required. Try it today!




Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51