0

Every time I try to run a script that includes the line Set xlObj = CreateObject("excel.application") in vbscript, I get an error saying "Line Requires Elevation". I assume this is a permissions issue, but I'm an admin on the machine where I'm trying to run this script, so I'm not sure what I need to do about this.

Sudo_Nym
  • 1
  • 2
  • 1
    Are you using Windows 7 or higher? Have you tried running the script from an elevated command prompt? Right click on cmd.exe "Run as Administrator" – Matt Sep 22 '14 at 20:21
  • 1
    Does the error come from VBS\CScript.exe or from Excel? By default the built-in administrator does not get hassled by UAC. If you are an admin by virtue of being a member of the Local Administrators group then you will need to negotiate UAC. UAC kicks in when you attempt to create a process. If you can't disable UAC or run your script from a pre-elevated prompt. However Excel does not normally require elevation as it doesn't require access to system resources. Check whether Excel is trying to run a VBA macro which may need to be elevated. – Stephen Connolly Sep 22 '14 at 21:31
  • 1
    I wonder if someone has set compatability on Excel to Run As Admin. Find the exe, not a shortcut, and check (right click - Properties - Compatability tab). Also check COM security. Look up `HKCR\Excel.Application`. Read the `ClassID` and look up `HKCR\CLSID\`. Get the `AppID` and look up `HKCR\AppID\`. On Office XP you'll get to `HKCR\AppID\{00020812-0000-0000-C000-000000000046}` which by default only has the display name of Excel. – Noodles Sep 22 '14 at 23:18
  • AccessPermission, ActivateAtStorage, AppID, AuthenticationLevel, DllSurrogate, DllSurrogateExecutable, Endpoints, LaunchPermission, LocalService, RemoteServerName, RunAs, ServiceParameters, SRPTrustLevel are the possible settings. – Noodles Sep 22 '14 at 23:22
  • I'm running on Windows 7, I've got Excel set to run as an admin; I'm not the owner of the machine, but I'm included as an admin. The error comes from VBS, which spits out an error about wanting elevation before even loading Excel. – Sudo_Nym Sep 22 '14 at 23:31
  • 1
    Shift + Right Click your script and choose Copy As Path. Right click a command prompt shortcut and choose Run As Administrator. In that window right click and choose Paste. Does your script work? – Noodles Sep 22 '14 at 23:44
  • What is err.number and err.source. – Noodles Sep 23 '14 at 00:01
  • For some reason, taking Excel off admin mode seems to work. Why it works in normal mode but not in admin mode is a mystery to me, I must say. Maybe the prompt blocks the script? – Sudo_Nym Sep 23 '14 at 15:49

1 Answers1

0

There is no mystery about it. We told you and you said "No that can't be it". If set to admin then a non admin can't access it.

Noodles
  • 1,981
  • 1
  • 11
  • 4