Restart Elevated

Features wanted...
Adequat
Posts: 95
Joined: 20 Jul 2007 12:03

Restart Elevated

Post by Adequat »

I regularly do this:
quit XY
relaunch it in administrator mode
do several stuff in this mode
quit XY
relaunch it in normal mode

To save time, it would be fine to have an option "Restart Elevated" and another one "Restart"

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: Restart Elevated

Post by Enternal »

A workaround is go to http://www.nirsoft.net/utils/nircmd.html and download nircmd. Extract both executables and put them in C:\Windows\.

Now make a new Custom Toolbar Button. For the script, use:

Code: Select all

Run """nircmd"" elevate ""<xy>"" /ini=""<xyini>"" ""<curpath>""";
2014-12-23 02_25_40-Edit User Button.png
2014-12-23 02_25_40-Edit User Button.png (32.35 KiB) Viewed 4032 times
There is some nice added benefits with the script above. XYplorer will open up a new process that is elevated. The old one will still be running so you won't lose anything. Do what you need with the elevated XYplorer process and then simply quite without saving. Voila!

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Restart Elevated

Post by PeterH »

If thinking of nircmd: use WSCC (Windows System Control Center) - it includes many many tools, also nircmd. It really can be helpful!
(Can be used portable!)
Win11 Pro 223H2 Gerrman

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: Restart Elevated

Post by Enternal »

PeterH wrote:If thinking of nircmd: use WSCC (Windows System Control Center) - it includes many many tools, also nircmd. It really can be helpful!
(Can be used portable!)
Completely agree and support! I have it on my USB drive with me as well. Excellent stuff! It's a bit of overkill but I also have GEGeek Tech Toolkit just in case zombie apocalypse. Although XYplorer during a zombie apocalypse should be my primary tool... :whistle:

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Restart Elevated

Post by bdeshi »

This might be easier. And altogether cleaner (you don;t have to download anything, not saying nircmd is bad though).
Enter

Code: Select all

::snippet; 
into the addressbar. A textbox will open. Copy the following code and paste it into that box (and ENTER).

Code: Select all

Snip: CTB 1
  XYplorer 14.80.0000, 12/23/2014 5:23:29 PM
Action
  NewUserButton
Name
  Restart...
Icon
  :refresh
ScriptL
  "Open new ELEVATED XYplorer"
    $elevator = "<xyscripts>\utils\elevXY.vbs";
      writefile($elevator, <<<#elevcontent
  set oSh = CreateObject("Shell.Application")
  oSh.ShellExecute "<xy>", "/new", "", "runas"#elevcontent,o);
    }
    //savesettings;
    run "wscript.exe ""$elevator"" ""<xy>""",,0,0;
  "-"
  "Restart with ELEVATED privileges"
    $elevator = "<xyscripts>\utils\elevXY.vbs";
      writefile($elevator, <<<#elevcontent
  set oSh = CreateObject("Shell.Application")
  oSh.ShellExecute "<xy>", "", "", "runas"#elevcontent,o);
    }
    savesettings;
    run "wscript.exe ""$elevator"" ""<xy>""",,0,0;
    exit n;
  "Restart with UNELEVATED privileges"
    savesettings;
    run "%WINDIR%\explorer.exe ""<xy>""";
    exit n;
  "Restart in current mode (saving settings)"
    exit sr;
ScriptR
  
FireClick
  0
Now a new button will get added to the toolbar.
Click it to: restart ELEVATED (using vbscript), or UNELEVATED (using explorer.exe :roll: ) or just restart in current mode. You can also open a new ELEVATED instance of XYplorer.

(edit) Don't ask me why explorer can start things in unelevated mode FROM WITHIN an elevate program. Where cmd.exe ,psExec from sysinternals, and runas /trustlevel:0x2000 all failed. I know I'll not forget this interesting and quite useful ( :shock: ) feature of WE.

(edit2: added new "Open new elevated instance" option to the ctb)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: Restart Elevated

Post by Marco »

SammaySarkar wrote: (edit) Don't ask me why explorer can start things in unelevated mode FROM WITHIN an elevate program. Where cmd.exe ,psExec from sysinternals, and runas /trustlevel:0x2000 all failed. I know I'll not forget this interesting and quite useful ( :shock: ) feature of WE.
Explorer is not the only one. CPAU ( http://www.joeware.net/freetools/tools/cpau/index.htm ) can do the same thing. But it won't be able to do the reverse on NT 6.x, i.e. where there's UAC - starting something elevated from an unelevated environment. :shock:
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: Restart Elevated

Post by Enternal »

Really? Making me all jelly with that code. Well, nircmd still has its own uses like opening cd trays and other advance features. With it I can at least claim that XYplorer can open CD trays so that I can use them as cup holders. :whistle:

Joking aside, that's actually quite neat! I really need to learn vbscript.

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Restart Elevated

Post by Filehero »

Hi,

this logic really should be made XY-intern, maybe added to the File menu as Restart Elevated and/or Start Elevated Instance.

@Sammay: :appl:

Filehero

SammaySarkar wrote:This might be easier. And altogether cleaner (you don;t have to download anything, not saying nircmd is bad though).
Enter

Code: Select all

::snippet; 
into the addressbar. A textbox will open. Copy the following code and paste it into that box (and ENTER).

Code: Select all

Snip: CTB 1
  XYplorer 14.80.0000, 12/23/2014 5:23:29 PM
Action
  NewUserButton
Name
  Restart...

    ....[/quote]

aliteralmind
Posts: 261
Joined: 02 Dec 2014 16:49

Re: Restart Elevated

Post by aliteralmind »

Why do you need to switch back and forth between elevated and not? Why not just stay elevated?

I'm genuinely curious.
Windows 8.1, 64-bit

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Restart Elevated

Post by Filehero »

aliteralmind wrote:Why not just stay elevated?
My standard account isn't a/the admin one, so I wouldn't see all my account specific folders and links (user.home, desktop, documents etc.).

In this general regard - and even if it might not be required any longer under Win 8.x - I'm truly an old-fashioned guy, I sudo on demand only. :wink:


Cheers,
Filehero

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: Restart Elevated

Post by Enternal »

aliteralmind wrote:Why do you need to switch back and forth between elevated and not? Why not just stay elevated?

I'm genuinely curious.
Problem with staying elevated all the times is elevated programs don't always play nice with all other programs that are not elevated due to permissions and such. In most cases, you don't want to elevate a program unless it's necessary.

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Restart Elevated

Post by PeterH »

aliteralmind wrote:Why do you need to switch back and forth between elevated and not? Why not just stay elevated?
Security! I generally work as a normal user, and only if it's really neccessary I run it elevated.
Win11 Pro 223H2 Gerrman

aliteralmind
Posts: 261
Joined: 02 Dec 2014 16:49

Re: Restart Elevated

Post by aliteralmind »

Well, it would be nice to bypass the UAC prompt, by calling an already-elevated shortcut. I'm guessing this isn't possible via an XY internal implementation, but perhaps it's scriptable.
Windows 8.1, 64-bit

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Restart Elevated

Post by bdeshi »

no good program wearing a white hat should try to bypass the UAC. :wink:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Restart Elevated

Post by Filehero »

aliteralmind wrote:I'm guessing this isn't possible via an XY internal implementation, but perhaps it's scriptable.
I do expect, that what Sammay's VBS script does indeed can be done with VB6.

Post Reply