It is currently December 3rd, 2020, 10:44 am

Run CMD.EXE as Administrator from Rainmeter

Help with creating, editing & fixing problems with skins
learninginsight
Posts: 6
Joined: April 16th, 2014, 12:38 am

Run CMD.EXE as Administrator from Rainmeter

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!
You do not have the required permissions to view the files attached to this post.
moshi
Posts: 1837
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

Code: Select all

LeftMouseUpAction=["path\to the\name of your new shortcut.lnk"]
learninginsight
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 ...
You do not have the required permissions to view the files attached to this post.
tk_
Posts: 9
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.

tk_
fonpaolo
Moderator
Posts: 1397
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".
tk_
Posts: 9
Joined: March 30th, 2015, 1:50 am

Re: Run CMD.EXE as Administrator from Rainmeter

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_
jn_meter
Posts: 65
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.
SilverAzide
Rainmeter Sage
Posts: 1029
Joined: March 23rd, 2015, 5:26 pm

Re: Run CMD.EXE as Administrator from Rainmeter

jn_meter wrote: November 16th, 2020, 4:39 pm 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.
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).
jn_meter
Posts: 65
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.
SilverAzide
Rainmeter Sage
Posts: 1029
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:

Code: Select all

# test if current process is elevated; if not, relaunch
<your command goes here>