Access Denied Error Message in Windows Script Host

Article translations Article translations
Article ID: 233513 - View products that this article applies to.
This article was previously published under Q233513
Expand all | Collapse all

SYMPTOMS

When you try to use a system environment variable in Windows Script Host and you are not an administrator for the computer, you may receive an 'access denied' error message.

CAUSE

This issue can occur if the system environment variables are not defined correctly.

RESOLUTION

To resolve this issue, define the system environment variable using the Process environment. For an example about how to use the Process environment variable, view the following Visual Basic Script samples.

This script works when an administrator runs it but does not work when a user who does not have administrator permissions runs it.
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WSHEnv = WSHShell.Environment
WScript.Echo WSHEnv("OS")
				
NOTE: Notice that since there is no type specified after Environment that it will default to the "System" type.

This script works when either an administrator or non-administrator runs it.
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WSHEnv = WSHShell.Environment("Process")
WScript.Echo WSHEnv("OS")
				
NOTE: Notice that the type "Process" is specified after Environment.

Properties

Article ID: 233513 - Last Review: November 1, 2006 - Revision: 2.1
APPLIES TO
  • Microsoft Windows NT Server 4.0, Terminal Server Edition
  • Microsoft Windows NT Server 4.0 Standard Edition
  • Microsoft Windows NT Workstation 4.0 Developer Edition
Keywords: 
kbenv kbprb KB233513

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com