Board index » Visual Studio » VB Script & UAC - Permission Denied

VB Script & UAC - Permission Denied

Visual Studio327
Hello,



I'm trying to get a VB Script to delete a shortcut in the

'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\' folder.



I'm logged on the PC as an administrator with UAC enabled, however the VB

Script is running as a standard user (UAC's Job) and I'm getting a 800A0046

Permission denied.



If I disable UAC then the script runs fine. However I do not want to disable

UAC everytime I run this script.



I would like UAC to pick up the script and ask permission to run with

administrator rights, is this possible?



Thanks

Richard


-
 

Re:VB Script & UAC - Permission Denied

RichardG_UK wrote:



Quote
I'm trying to get a VB Script to delete a shortcut in the

'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\' folder.



I'm logged on the PC as an administrator with UAC enabled, however the VB

Script is running as a standard user (UAC's Job) and I'm getting a

800A0046

Permission denied.



If I disable UAC then the script runs fine. However I do not want to

disable

UAC everytime I run this script.



I would like UAC to pick up the script and ask permission to run with

administrator rights, is this possible?



The only solution I know of is to launch a command window with "Run as

administrator" and run the script in that window. You can have a shortcut to

a command window configured on the Compatibility tab to "Run as

administrator", or you can find cmd.exe, right click the exe file, and

select "Run as administrator".



Unfortunately, you cannot right click a *.vbs file and select "Run as

administrator", and the properties dialog for *.vbs files has no

Compatibility tab. I have searched for a way to include a manifest or

otherwise flag a script to prompt for UAC permissions, but so far no luck.



--

Richard Mueller

Microsoft MVP Scripting and ADSI

Hilltop Lab - www.rlmueller.net">www.rlmueller.net

--





-

Re:VB Script & UAC - Permission Denied

Thanks Richard for the quick reply.



I have managed to get close to the solution I want by creating a shortcut to

wscript.exe and the path of the VB script after. e.g wscript "\path to

script\script.exe"



I'm now also able to use the RunAs Administrator under the properties for

the shortcut.



UAC picks up the script too.



Thanks

Richard



"Richard Mueller [MVP]" wrote:



Quote
RichardG_UK wrote:



>I'm trying to get a VB Script to delete a shortcut in the

>'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\' folder.

>

>I'm logged on the PC as an administrator with UAC enabled, however the VB

>Script is running as a standard user (UAC's Job) and I'm getting a

>800A0046

>Permission denied.

>

>If I disable UAC then the script runs fine. However I do not want to

>disable

>UAC everytime I run this script.

>

>I would like UAC to pick up the script and ask permission to run with

>administrator rights, is this possible?



The only solution I know of is to launch a command window with "Run as

administrator" and run the script in that window. You can have a shortcut to

a command window configured on the Compatibility tab to "Run as

administrator", or you can find cmd.exe, right click the exe file, and

select "Run as administrator".



Unfortunately, you cannot right click a *.vbs file and select "Run as

administrator", and the properties dialog for *.vbs files has no

Compatibility tab. I have searched for a way to include a manifest or

otherwise flag a script to prompt for UAC permissions, but so far no luck.



--

Richard Mueller

Microsoft MVP Scripting and ADSI

Hilltop Lab - www.rlmueller.net">www.rlmueller.net

--







-

Re:VB Script & UAC - Permission Denied

You can configure any exe to "Run as administrator", so creating a shortcut

to wscript or cscript is a good idea. My concern is that I sometimes send

scripts to people I support, either to patch something or troubleshoot. If

the script requires administrator privileges the instructions I must now

supply to run the script seem daunting.



--

Richard Mueller

Microsoft MVP Scripting and ADSI

Hilltop Lab - www.rlmueller.net">www.rlmueller.net

--



"RichardG_UK" <RichardGUK@discussions.microsoft.com>wrote in message

Quote
Thanks Richard for the quick reply.



I have managed to get close to the solution I want by creating a shortcut

to

wscript.exe and the path of the VB script after. e.g wscript "\path to

script\script.exe"



I'm now also able to use the RunAs Administrator under the properties for

the shortcut.



UAC picks up the script too.



Thanks

Richard



"Richard Mueller [MVP]" wrote:



>RichardG_UK wrote:

>

>>I'm trying to get a VB Script to delete a shortcut in the

>>'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\' folder.

>>

>>I'm logged on the PC as an administrator with UAC enabled, however the

>>VB

>>Script is running as a standard user (UAC's Job) and I'm getting a

>>800A0046

>>Permission denied.

>>

>>If I disable UAC then the script runs fine. However I do not want to

>>disable

>>UAC everytime I run this script.

>>

>>I would like UAC to pick up the script and ask permission to run with

>>administrator rights, is this possible?

>

>The only solution I know of is to launch a command window with "Run as

>administrator" and run the script in that window. You can have a shortcut

>to

>a command window configured on the Compatibility tab to "Run as

>administrator", or you can find cmd.exe, right click the exe file, and

>select "Run as administrator".

>

>Unfortunately, you cannot right click a *.vbs file and select "Run as

>administrator", and the properties dialog for *.vbs files has no

>Compatibility tab. I have searched for a way to include a manifest or

>otherwise flag a script to prompt for UAC permissions, but so far no

>luck.

>

>--

>Richard Mueller

>Microsoft MVP Scripting and ADSI

>Hilltop Lab - www.rlmueller.net">www.rlmueller.net

>--

>

>

>





-