Run Terminal as another user #14099

Closed
opened 2026-01-31 04:00:52 +00:00 by claunia · 5 comments
Owner

Originally created by @eglyn on GitHub (Jun 3, 2021).

Hi all,

is there a way to launch a new tab with a different user ?
We have differents username for a same user (with differents privileges), and we need to launch some ps command with another user than the current user.
The only way I found is to create another profile with the following command line:

"commandline": "C:\\Windows\\System32\\runas.exe /savecred /user:domain\\anotherlogin powershell.exe",

But, it opens another windows PS, that is not a terminal windows, so with no split screen option, etc...

So is there a way to open a new tab with this user instead a new PS window ?

Thx !

Originally created by @eglyn on GitHub (Jun 3, 2021). Hi all, is there a way to launch a new tab with a different user ? We have differents username for a same user (with differents privileges), and we need to launch some ps command with another user than the current user. The only way I found is to create another profile with the following command line: ``` "commandline": "C:\\Windows\\System32\\runas.exe /savecred /user:domain\\anotherlogin powershell.exe", ``` But, it opens another windows PS, that is not a terminal windows, so with no split screen option, etc... So is there a way to open a new tab with this user instead a new PS window ? Thx !
claunia added the Issue-FeatureResolution-Duplicate labels 2026-01-31 04:00:52 +00:00
Author
Owner

@rosettet commented on GitHub (Jun 3, 2021):

If you are using Remote Management then you can specify a config file for each profile by adding -config /path/to/file to the end of the command line by using the '-config' flag.
You can even run custom commands to change profile on startup by adding the '-noexit' and '-command' tags to the end of the command line.
image
image
In your case (assuming wt is in your path) your Command Line may be:
C:\Program Files\PowerShell\7\pwsh.exe -noexit -command runas /savecred /user:domain\anotherlogin wt.exe

@rosettet commented on GitHub (Jun 3, 2021): If you are using Remote Management then you can specify a config file for each profile by adding -config /path/to/file to the end of the command line by using the '-config' flag. You can even run custom commands to change profile on startup by adding the '-noexit' and '-command' tags to the end of the command line. ![image](https://user-images.githubusercontent.com/79660359/120690180-814fcc00-c46a-11eb-92a9-c18a19ba447f.png) ![image](https://user-images.githubusercontent.com/79660359/120690306-a80e0280-c46a-11eb-894a-178f0264f88c.png) In your case (assuming wt is in your path) your Command Line may be: C:\Program Files\PowerShell\7\pwsh.exe -noexit -command runas /savecred /user:domain\\anotherlogin wt.exe
Author
Owner

@eglyn commented on GitHub (Jun 4, 2021):

it does not work, it says: wt.exe not found :/
Path of wt.exe is ok, if I change wt.exe by powershell, it launch powershell with the new account (user-c) , but in another window, not in a tab -_-

If I try to open wt via a powershell already with the user-c account, it says:

Annotation 2021-06-04 094754

If I open the windows session of the user-c, wt works :/

WT is installed on both sessions.

It seems we can't execute WT with a different user in powershell

@eglyn commented on GitHub (Jun 4, 2021): it does not work, it says: wt.exe not found :/ Path of wt.exe is ok, if I change wt.exe by powershell, it launch powershell with the new account (user-c) , but in another window, not in a tab -_- If I try to open wt via a powershell already with the user-c account, it says: ![Annotation 2021-06-04 094754](https://user-images.githubusercontent.com/24936778/120765884-f4644b80-c519-11eb-9da0-5b4368150b99.png) If I open the windows session of the user-c, wt works :/ WT is installed on both sessions. It seems we can't execute WT with a different user in powershell
Author
Owner

@eglyn commented on GitHub (Jun 4, 2021):

I found a workarround, but not really perfect:

  • Download the last version 1.9
  • extract the bundle with 7zip
  • extract the x64 msix
  • in the command line of WT this command:
    "commandline": "powershell -noexit -command runas /savecred /user:domain\user-c C:\WT\WindowsTerminal.exe",

it opens another WT with privilege account, not really in the same tab, but it is WT, so I can open new tab with my privilege account

@eglyn commented on GitHub (Jun 4, 2021): I found a workarround, but not really perfect: - Download the last version 1.9 - extract the bundle with 7zip - extract the x64 msix - in the command line of WT this command: "commandline": "powershell -noexit -command runas /savecred /user:domain\\user-c C:\\WT\\WindowsTerminal.exe", it opens another WT with privilege account, not really in the same tab, but it is WT, so I can open new tab with my privilege account
Author
Owner

@zadjii-msft commented on GitHub (Jul 6, 2021):

I'm glad you found a workaround! We're not really planning on allowing mixed elevation levels / mixed users within a single terminal Window - there are unfortunately a few security issues with that which we're not willing to ship ourselves. There are more details in the threads linked to #5000.

/dup #2200

@zadjii-msft commented on GitHub (Jul 6, 2021): I'm glad you found a workaround! We're not really planning on allowing mixed elevation levels / mixed users within a single terminal Window - there are unfortunately a few security issues with that which we're not willing to ship ourselves. There are more details in the threads linked to #5000. /dup #2200
Author
Owner

@ghost commented on GitHub (Jul 6, 2021):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Jul 6, 2021): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14099