windows 8 - How to allow VB scripts to run on an admin account
2014-07
I'm encountering an issue with the VBscripts while I try to run them. I'm working on Windows 8.1 update 1 Enterprise, connected to an Enterprise domain, and I'm logged with a domain account. This domain account has been added to the Administrators group.
My VBscript must create a folder and a log file into the Program Files (x86) directory. If I run this VBscript by double-clicking on it with the local administrator account, it works perfectly. But if I try to run the same VBscript with my domain account, I get the error message Access denied.
One solution is to totally deactivate the UAC (with the enableLUA registry value set to 1), but this method blocks the Modern UI applications, and we need to keep these applications execution.
Is it possible to grant the full control to VBScripts execution on any admin account, like it is the case under the local administrator built-in account ? I didn't yet find any solution to this problem, and I can't believe that no solution exists, especially in enterprise.
the way I normally do this is to stick the following code at the top of my script:
If Not WScript.Arguments.Named.Exists("elevate") Then
CreateObject("Shell.Application").ShellExecute WScript.FullName _
, WScript.ScriptFullName & " /elevate", "", "runas", 1
WScript.Quit
End If
This way, if I launch the VBS as a non admin - it tries to run, notices I'm not an admin and then relaunches - prompting me to run as admin and away we go.
I know its a pain, but its a fairly simple solution.
Hope this helps
This trick is useful if you are using command-line:
- Go to
System32
(orSyswow4
for x64) - Copy
cscript.exe
andwscript.exe
and name themcsadmin.exe
andwsadmin.exe
- Open their properties, set "Run as admin" flag.
Now if you want to run your script as admin, use one of these:
csadmin myscript.vbs
wsadmin myscript.vbs
(And if you want to run as default, use wscript
and cscript
)
Note: If you want to run all scripts as admin (UAC window will appear each time), then just set "Run as admin" flag on cscript.exe
and wscript.exe
.
Hope it helps.
I'm using Windows 8 Pro. When I try to save an attachment from Outlook 2010 into a specific Program Files folder I get the following message:
"C:\Program Files (x86)... You don't have permission to save in this location. Contact the administrator to obtain permission.
Would you like to save in the folder instead?"
I upgraded my Win7 pc to Win8. The first time I used Windows 8 I signed in via my email address (4 or 5?). But then I added it to our domain and signed in with my domain account (3).
Now when I look at the "Control Panel > User Accounts > User Accounts" I see the following things:
(1) HomeGroupUser$ | <pcname> | HomeUsers
(2) UpdateusUser | <pcname> | HomeUsers
(3) <my current domain user (globe icon)> | <my domain> | HomeUsers; Administrators
(4) <my first sign in user email address (pc icon)> | MicrosoftAccount | HomeUsers; Administrators
(5) <my first sign in user email address (globe icon)> | MicrosoftAccount | Administrators
the "my domain user (globe icon)" (3) is the account that I use currently and It has been added to the "HomeUsers; Administrators" groups, but still that message tells me i'm not an administrator.
I also linked my MicrosoftAccount (4 or 5?) with my current domain user account (3)
Any suggestions on how to make myself an administrator on the pc so that I don't have these annoying UAC messages and that I can write in my own program files (and other folders)? I thought I was an administrator now, because my domain account (3) is in the groups "HomeUsers; Administrators" but that doesn't seem to be 100% ok.
Thanks in advance (sorry if this explanation is a bit messy).
You are still an administrator - The exact same thing happens in Windows Vista and Windows 7... Unless you launch Outlook as an administrator, you will not have the ability to save to or write to protected paths.