Windows run as a different user from CMD

 On my journey to fix my dev env I learned some cool trick on how to run stuff in windows as another user, from CMD

* For running the .exe files you need to navigate to their folders or run full path

The basic operation to run as user is

runas /netonly /user:<DOMAIN>\<USER> <COMMAND>

So, for example domain is MyDom, and user is OthrUsr

- Just open CMD

runas /netonly /user:MyDom\OthrUsr cmd

- Open PowerShell

cd "C:\Windows\System32\WindowsPowerShell\v1.0\"
runas /netonly /user:MyDom\OthrUsr PowerShell.exe

- Open SharePoint PowerShell

cd "C:\Windows\System32\WindowsPowerShell\v1.0\"
runas /netonly /user:MyDom\OthrUsr PowerShell.exe

. "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\CONFIG\POWERSHELL\Registration\SharePoint.ps1"

*According to your SP version the "16" might be 15 (for sp13) or 14 (for sp10)

- Open SQL Server Management Studio (SSMS)  (path can chage according to version)

cd "C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\"

runas /netonly /user:MyDom\OthrUsr ssms.exe


Popular posts from this blog

OverTheWire[.com] Natas Walkthrough - JUST HINT, NO SPOILERS

SOLVED The item could not be indexed successfully because the item failed in the indexing subsystem

Asp.Net Ending Response options, Response.End() vs CompleteRequest()