So, I can run CMD.exe from Rainmeter ... but I would like to run it as Administrator.
LeftMouseUpAction=["%windir%\system32\cmd.exe"] opens a window and let's me enter commands, but I want to run the program as Administrator.
I tried googling for a quick solution, but just found info on ShellExecute and Runas which didn't help me much.
Any help or pointers in the right direction would be appreciated.
Thanks!
It is currently April 24th, 2024, 10:56 pm
Run CMD.EXE as Administrator from Rainmeter
-
- Posts: 6
- Joined: April 16th, 2014, 12:38 am
Run CMD.EXE as Administrator from Rainmeter
You do not have the required permissions to view the files attached to this post.
-
- Posts: 1740
- Joined: November 13th, 2012, 9:53 pm
Re: Run CMD.EXE as Administrator from Rainmeter
not really a Rainmeter, but rather a "how do i use Windows question"
create a shortcut as described here: http://www.sevenforums.com/tutorials/3718-elevated-command-prompt-shortcut.html
create a shortcut as described here: http://www.sevenforums.com/tutorials/3718-elevated-command-prompt-shortcut.html
Code: Select all
LeftMouseUpAction=["path\to the\name of your new shortcut.lnk"]
-
- Posts: 6
- Joined: April 16th, 2014, 12:38 am
Re: Run CMD.EXE as Administrator from Rainmeter
Thanks for the pointer. It was helpful.
I use Rainmeter to avoid creating shortcuts on my desktop and run everything directly. Thought I could do the same thing in this situation ... which is why I was asking for help.
As I mentioned previously, my google efforts came up short, because I obviously didn't know what to google for ... your link did provide a work around.
However, even when I create a shortcut and designate it as "run as admin", and then use Rainmeter to reference that shortcut, CMD.exe is still not run as admin. When I click on the shortcut in Windows, it works as expected. When I reference the shortcut in Rainmeter, it executes CMD.exe but not as Admin.
As a workaround, I created a copy of the CMD.EXE file locally and designated it as "run as admin" and then referenced that in Rainmeter. It works, but is kludgy and problematic for other reasons, but I can live with it for now.
I realize that this is a Windows issue, but I am still kinda wondering is it possible to run CMD as Admin through Rainmeter without my kludgy solution?
Just wondering ...
I use Rainmeter to avoid creating shortcuts on my desktop and run everything directly. Thought I could do the same thing in this situation ... which is why I was asking for help.
As I mentioned previously, my google efforts came up short, because I obviously didn't know what to google for ... your link did provide a work around.
However, even when I create a shortcut and designate it as "run as admin", and then use Rainmeter to reference that shortcut, CMD.exe is still not run as admin. When I click on the shortcut in Windows, it works as expected. When I reference the shortcut in Rainmeter, it executes CMD.exe but not as Admin.
As a workaround, I created a copy of the CMD.EXE file locally and designated it as "run as admin" and then referenced that in Rainmeter. It works, but is kludgy and problematic for other reasons, but I can live with it for now.
I realize that this is a Windows issue, but I am still kinda wondering is it possible to run CMD as Admin through Rainmeter without my kludgy solution?
Just wondering ...
You do not have the required permissions to view the files attached to this post.
-
- Posts: 11
- Joined: March 30th, 2015, 1:50 am
Re: Run CMD.EXE as Administrator from Rainmeter
(Yes, I realize this topic is nearly a year old, but...)
I am wanting to do specifically what the OP was wanting to do. That is, discover if there is a native way in Rainmeter to open a command prompt with elevated privileges (i.e. as admin). Creating a link as shown above isn't really what I'm looking for, and I don't want to use a kluge solution either.
It seems like no one answered the OP in this respect, so I'm poking again to see if this is possible.
Thanks in advance,
tk_
I am wanting to do specifically what the OP was wanting to do. That is, discover if there is a native way in Rainmeter to open a command prompt with elevated privileges (i.e. as admin). Creating a link as shown above isn't really what I'm looking for, and I don't want to use a kluge solution either.
It seems like no one answered the OP in this respect, so I'm poking again to see if this is possible.
Thanks in advance,
tk_
-
- Moderator
- Posts: 1387
- Joined: April 11th, 2013, 8:08 pm
- Location: Italy
Re: Run CMD.EXE as Administrator from Rainmeter
The only other suggestion that comes to my mind is to right click on the CMD.exe file, and set "Run as Administrator" in the Properties, without making a copy.
...but remember that, then it will always run "as Administrator".
...but remember that, then it will always run "as Administrator".
-
- Posts: 11
- Joined: March 30th, 2015, 1:50 am
Re: Run CMD.EXE as Administrator from Rainmeter
Thank you for the reply.fonpaolo wrote:The only other suggestion that comes to my mind is to right click on the CMD.exe file, and set "Run as Administrator" in the Properties, without making a copy.
...but remember that, then it will always run "as Administrator".
Right, and that's not doing it with Rainmeter.
So, anyone else? Is there no way to do this within Rainmeter?
Thanks
tk_
-
- Posts: 136
- Joined: December 27th, 2016, 12:04 pm
Re: Run CMD.EXE as Administrator from Rainmeter
I too would like a way of running a program - any program, not just cmd.exe - elevated from within Rainmeter. I feel Rainmeter should have this function built-in.
-
- Rainmeter Sage
- Posts: 2604
- Joined: March 23rd, 2015, 5:26 pm
Re: Run CMD.EXE as Administrator from Rainmeter
Not possible. The Windows operating system itself controls elevation, so the only way to launch a program from Rainmeter in an elevated mode is to run Rainmeter itself elevated. Windows doesn't want you to run stuff elevated, that's why it nags you with a prompt. It is possible to write a PowerShell script that will self-elevate (after the usual prompting that you can't avoid).
-
- Posts: 136
- Joined: December 27th, 2016, 12:04 pm
Re: Run CMD.EXE as Administrator from Rainmeter
Thanks. Perhaps I was not clear, though: I am not trying to skip the elevation prompt; rather, when I use (unelevated) Rainmeter to run a program that need elevation, I do not see an elevation prompt. Rather, nothing at all happens. I suppose I'll have to implement one of the workarounds documented on this page.
-
- Rainmeter Sage
- Posts: 2604
- Joined: March 23rd, 2015, 5:26 pm
Re: Run CMD.EXE as Administrator from Rainmeter
Probably the elevation prompt is getting lost if the CMD or PowerShell window is hidden. Perhaps the following will help. Save the following as a .ps1 script and run it using PowerShell and see if it works:
P.S.: Obviously, this will not work if you want to retrieve the results of the command, since this launches a secondary process that Rainmeter won't know about. If you just want to run something, though, it should work... (I didn't try it.)
Code: Select all
# test if current process is elevated; if not, relaunch
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
# Relaunch as an elevated process:
Start-Process powershell.exe "-File",('"{0}"' -f $MyInvocation.MyCommand.Path) -Verb RunAs
exit
}
<your command goes here>