· Nov 3, 2017

How to open a cmd prompt as administrator using terminal

Hi guys,

   I am trying to run a command line code using $zf(-1) in cache terminal. it is returning access denied error.

I have tried to run the code in cmd itself it is also throwing Access denied error. But if opened cmd as administrator and run the same code it is working perfectly. I am using windows system. 

Hence i need to know how can i run the cmd line code as administrator using our terminal or studio. Please help me out.



Discussion (4)0
Log in or sign up to continue

There's no embedded or native way of doing so, due to, well... security concerns.

There're scripts and third party programs that allow you to do something close to it.

However, should you really be executing it with admin privileges? Why not make your executable accessible for your Caché user, so that you won't need to elevate your prompt?

No, you need to grant the group/user you're using for Caché permission to access the executable that's being denied.
On Windows, Caché uses the same user that started the process. Remember that you're trying to access a resource natively from your OS, so your Caché user is NOT what you should check.


If you need to know which you should be looking for, open a cmd and type "whoami".

Now you'll need to have an account with Administrator privileges, otherwise you won't be able to edit your executable's permissions. If you're working in company network, then your user probably wont have enough privileges for changing that file's permissions, so I'd recommend leaving this task for your IT technician.


The technician should know what to do,  just ask him to add your user to list of groups/users that are allowed to execute your file. Normally you would only need "read and execute", unless that executable also generates some file somewhere, so also grant your user the permission to write.

Anything launched by $zf(-1) is going to run as the user that is running the original process. In the case of a Caché terminal session, that will just run as whatever user is running the terminal, and there's no way to get around that. 

If you were to use another method to run the $zf command, such as a Telnet connection, or running it via the Caché task manager, the process would instead run as the user who owns the Caché Controller services. So, if you REALLY need to be able to run cmd as an administrator, the best way would be to make the user who owns Caché  the system administrator user, and then run this code via the task manager (you could use a RunLegacyTask).

All that said, I have to agree with Rubens, this is not an ideal setup for security reasons, why can't you just make it such that your executable will run without the need for administrator access? Is there a particular reason why it requires administrator rights?