Как запустить программу от другого пользователя, запустить как в windows

How-to-Open-Windows-PowerShell-as-an-Admin-in-Windows-11

powershell run executable

Step 1: Win + R to open the Run dialog.

How-to-Open-PowerShell-as-Admin-Using-Run-Dialog

Step 1:Windows PowerShell” in the Windows Search bar.

How-to-Open-PowerShell-as-Admin-Using-Windows-Search

How-to-Run-PowerShell-as-Admin-from-CMD

Step 3:

powershell Start-Process powershell -Verb runAs

How-to-Run-PowerShell-as-Admin-from-CMD-1

Step 1: Open the Control Panel.

Step 2: “System and SecurityWindows Tools.”

How-to-Open-PowerShell-as-Admin-Using-Control-Panel

Как запустить программу от другого пользователя, запустить как в windows

Add “Run As” Option to Start Menu in Windows 10

windows 11 start menu item to runas another user

List the Microsoft Store apps on your computer using PowerShell:

You can find a specific app:

Step 1: To open the quick access menu, right-click on Start or use the keyboard shortcut Win + X.

Administrator-Using-Win--X

Running Programs with Elevated Privileges using Start-Process Command

Start-Process -FilePath "powershell.exe" -Verb RunAs
Start-Process -FilePath "C:\Temp\Log.txt" -Verb Print

Run Windows PowerShell Using Task Manager

Step 1:Task Manager” in the search bar or press Ctrl + Shift + Esc to open Task Manager.

Step 2: Run new task.”

How-to-Run-Windows-PowerShell-Using-Task-Manager

Step 1: Right-click on the desktop.

Step 2: NewShortcut

How-to-Open-PowerShell-as-Admin-With-a-Desktop-Shortcut

Step 3: “powershell.exe” as the location.

Step 4: Next” and give your shortcut a name.

How-to-Open-PowerShell-as-Admin-With-a-Desktop-Shortcut--1

Step 1: Click on the start button, then the search box, and type “Windows tools”.

Step 2: Then, Right-click on “Windows PowerShell” from the list.

Windows-PowerShell-as-an-Administrator-From-the-Start-Menu

Step 1: Open file explores by using the shortcut Win + E or type “File Explorer” on search bar

Step 2: Type the command in the File Explorer address bar and press Enter.

C:\Windows\System32\WindowsPowerShell\v1.0\

How-to-Open-PowerShell-as-Admin-Using-Windows-File-Explorer

Introduction to PowerShell’s Start-Process Command

The PowerShell Start-Process command is a powerful tool that is used to start a new program or script in a new process. This cmdlet lets us launch external programs directly from the command line or a PowerShell script. You can use it to start any program, including batch files, executables, and PowerShell scripts.

Running PowerShell Scripts with Start-Process Command

The PowerShell Start-Process command can also be used to start PowerShell scripts. To start a PowerShell script, you need to specify the location of the script using the FilePath parameter. Additionally, you can pass arguments to the script using the ArgumentList parameter.

Start-Process -FilePath "powershell.exe" -ArgumentList "-File C:\Scripts\MyScript.ps1"

This command would start the MyScript.ps1 script in a new PowerShell process.

Running executables as a different user with Start-Process in PowerShell

Start-Process -FilePath "powershell.exe" -Credential (Get-Credential)
powershell start-process
# Parameters
$FilePath = "C:\Scripts\RunMe.bat"
$UserName = "Crescent\salaudeen"
$Password = "Password goes here"
#Prepare the Credentials
$SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force
$Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $UserName, $SecurePassword
#Start a process with
Start-Process -FilePath $FilePath -Wait -Credential $Credential

Running Executables with Start-Process Command

Running executables with Start-Process in PowerShell is a straightforward process. By simply specifying the path of the executable as an argument to the Start-Process cmdlet, PowerShell launches the program and executes it. This method is particularly useful when you want to run standalone executables without any additional parameters or customization. Let’s take a look at an example:

To start an executable, you need to specify the location of the executable using the FilePath parameter.

Start-Process -FilePath "C:\MyProgram\MyProgram.exe"

This command would start the MyProgram.exe executable.

Running Batch Files with Start-Process Command

PowerShell is not limited to running standalone executables only; it can also execute scripts and batch files effortlessly. By utilizing the Start-Process cmdlet, we can launch scripts and batch files in PowerShell and automate complex tasks. This provides us with the flexibility to integrate PowerShell with other scripting languages and leverage their capabilities. Let’s take a look at an example of running a PowerShell script using Start-Process:

To start a batch file, you need to specify the location of the batch file using the FilePath parameter.

Start-Process -FilePath "C:\MyBatchFile.bat"

When you run the powershell command there are switches you can provide to pass through commands and other settings, see them all by running powershell /?

$Command = {Disable-PnPDevice -InstanceId (Get-PnpDevice -FriendlyName *"Int"* -Class "Camera" -Status OK).InstanceID -Confirm:$false}
Start-Process PowerShell -verb runas -WindowStyle Hidden -ArgumentList "-Command",$Command 

Or as a single-line like this:

Start-Process PowerShell -verb runas -WindowStyle Hidden -ArgumentList "-Command",{Disable-PnPDevice -InstanceId (Get-PnpDevice -FriendlyName *"Int"* -Class "Camera" -Status OK).InstanceID -Confirm:$false}

Rather than double-clicking a .ps1 script file, I recommend asking people people to right-click > Run With PowerShell, it’s still fairly simple and doesn’t require further configuration that goes against Microsoft’s security recommendations:
enter image description here

:/>  Получить значение по ключу в вложенном словаре в powershell

Running Programs with PowerShell’s Start-Process Command

Start-Process -FilePath "notepad.exe"

This command would start Notepad in a new process.

PowerShell Run Exe

If you want to run an executable in the background without displaying any windows or prompts, you can use the -WindowStyle Hidden parameter of the Start-Process cmdlet. Similarly, you can open any specified file (Non-executable file, such as a doc file) in a new window using:

Start-Process -FilePath "C:\Docs\AppLog.txt" -WindowStyle Maximized

This opens the file “C:\Docs\AppLog.txt” in a maximized window.

PowerShell to Open Files

To open a file in PowerShell, you can use the Start-process (or its alias: Start) command:

Start "C:\Temp\Archive.zip"

This method allows you to open files in the associated programs in PowerShell. In the above case, the zip file will be opened in WinRAR/WinZip/Windows Explorer, depending on your computer’s default program associations.

Open File Explorer from PowerShell
To open Windows File Explorer from PowerShell, Use: Start-Process Explorer

Common Errors and Troubleshooting Tips with Start-Process Command

While the PowerShell Start-Process command is a powerful tool, there are a few common errors that you may encounter.

  1. Access is denied: One common error is the “Access is denied” error. This error occurs when you try to run a program or script with elevated privileges, but you do not have permission to do so. To fix this error, you will need to log in as an administrator or use the RunAs parameter to run the program with elevated privileges.
  2. File not found: Another common error is the “File not found” error. This error occurs when you specify an incorrect file path. To fix this error, you will need to double-check the file path and make sure that it is correct. This includes verifying file permissions and network access if the executable resides on a remote machine. Always use the full path of the executable to avoid any ambiguity or reliance on the system’s PATH environment variable.
  3. Invalid Arguments: If the executable requires specific arguments, ensure that they are passed correctly using the ArgumentList parameter of the Start-Process cmdlet.

Using Arguments with Start-Process Command

As mentioned earlier, the PowerShell Start-Process command allows you to pass arguments to the program or script you are starting. This can be useful if you need to customize the behavior of the program or script.

For example, if you are starting a program that requires command-line arguments, you can pass those arguments using the ArgumentList parameter.

Start-Process -FilePath "myprogram.exe" -ArgumentList "-arg1 value1", "-arg2 value2"

This command would start the myprogram.exe program with the arguments “-arg1 value1” and “-arg2 value2”. The parameter values depend on the application you are running. Let’s take an example: Suppose you want to open a URL in Google Chrome. Here’s how you can do it:

Start-Process -FilePath "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -ArgumentList "https://www.google.com" -Wait -WindowStyle Maximized
start-process argument

In this example, the -FilePath parameter specifies the path to the executable file for Chrome and the -ArgumentList parameter provides the URL to open in Chrome. The arguments are passed as a string, where a space separates each argument. It also uses a wait switch to wait for the process to close and Windowstyle parameters. This enables us to provide multiple args to the executable and customize its behavior.

:/>  Диагностика оперативной памяти. Пошаговая инструкция Memtest

Understanding the Start-Process Command

Run an Executable in PowerShell

The PowerShell Start-Process command has a number of different parameters that you can use to customize the way that the command runs. The most important parameter is the FilePath parameter, which specifies the location of the program or script that you want to start.

Another important parameter is the ArgumentList parameter, which allows you to pass arguments to the program or script you are starting. For example, if you are starting a PowerShell script, you can pass in parameters to the script using the ArgumentList parameter.

The Start-Process command also has parameters that let you specify the working directory, window style, and priority of the process you’re starting. These parameters can be useful if you need to start a program or script in a specific way. Along with other default parameters, Here is the list of important parameters of start-process cmdlet:

ParameterDescription
-FilePathSpecify the executable, application, file, batch, or script to run
-ArgumentListSpecifies parameters to use with the process to start
-CredentialUser account to run the process
-NoNewWindowOpen a window in the current console process
-PassthruReturns the process object of the process started. You can get the process ID from it.
-RedirectStandardErrorSpecify text file to redirect error output to
-RedirectStandardInputText file with input for the process
-RedirectStandardOutputSpecify text file to redirect output to
-UseNewEnvironmentThe process will use new environment variables specified for the process instead default, under: Machine and user
-WindowStyleSpecifies the state of the window: Normal, Hidden, Minimized, or Maximized
-LoadUserProfileLoads the Windows user profile from the HKEY_USERS registry key for the current user. This does not affect the PowerShell profiles.
-WaitWait for the process to complete before continuing with the script
-WorkingDirectoryThe location where the process should start in
CommonParametersVerbose, Debug,ErrorAction, ErrorVariable, WarningAction, WarningVariable,OutBuffer, PipelineVariable, and OutVariable

“Run As Different User” Option is Missing in Windows

On Windows, you can hide or show the RunAs menu item in File Explorer using two registry parameters:

  • The HideRunAsVerb parameter (REG_DWORD) under the registry key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer (1 – hide the RunAs item, 0 – show it);
  • EnableSecureCredentialPrompting (REG_DWORD) under HKLM\ Software\Microsoft\Windows\CurrentVersion\Policies\CredUI (1 – hide, 0 – show).

GPO: Require trusted path for credential entry

Using RunAs in PowerShell

$Cred = (Get-Credential)

Start-Process -FilePath "powershell.exe" -Credential $Cred

Or a third-party ShelExec tool:

ShelExec /Verb:runas cmd.exe

How to Use RunAs Without Password Prompt?

After specifying the password, it will be saved to the Windows Credential Manager.

rundll32.exe keymgr.dll, KRShowKeyMgr

windows runas with savecred option

Note. In addition, /savecred option doesn’t work in the Windows Home edition versions.

In the same way, you can run any other snap-in (if you know its name).

:/>  Ярлык rdp с параметрами

FAQs to Open Windows PowerShell

A number of PowerShell opening methods include via Run dialogue box, task manager, window search among other options even within file explorer. Every option is suitable for someone depending on there preference and convenience

Please to comment…

How to Run Apps as Different User from File Explorer

  • If you want to run the program as an Active Directory user, you must specify its name in the userPrincipalName ( [email protected] ) or samAccountName ( DomainName\UserName ) format ;
  • If your computer is joined to an AD domain, then to run the program on behalf of a local user account, specify its name in the following format: .\localusername .

taskmanager the application is running under different user

Run a Program Under a Different User from CMD

using runas in command prompt

Enter the password for admin

Enter the password for corp\server_admin:
Attempting to start C:\Windows\system32\notepad.exe C:\ps\region.txt as user "corp\server_admin " ...
RUNAS ERROR: Unable to run - yourcommand
1326: The user name or password is incorrect.
RUNAS ERROR: Unable to acquire user password

Table of contents

  • Introduction to PowerShell’s Start-Process Command
  • Understanding the Start-Process Command
  • Running Programs with PowerShell’s Start-Process Command
  • Running Programs with Elevated Privileges using Start-Process Command
  • Running executables as a different user with Start-Process in PowerShell
  • Running PowerShell Scripts with Start-Process Command
  • Using Arguments with Start-Process Command
  • Running Executables with Start-Process Command
  • Running Batch Files with Start-Process Command
  • Common Errors and Troubleshooting Tips with Start-Process Command
  • Conclusion and Best Practices

How to Create a Shortcut to Run as a Different User

shortcut with runas command

Conclusion and Best Practices

When using the Start-Process command, it is important to double-check your file paths and arguments to avoid common errors. Additionally, it is a good practice to test your commands in a test environment before running them in a production environment.

Now that you have a better understanding of the PowerShell Start-Process command, you can start using it to automate your tasks and streamline your workflow!

How do I run a PowerShell script like an EXE?

How do I run an EXE file in PowerShell?

To run an EXE file in PowerShell, you can use the “Start-Process” cmdlet. Here’s an example of the command you can use: “Start-Process -FilePath 'C:\Path\to\file.exe'“. Replace ‘C:\Path\to\file.exe‘ with the actual path to your EXE file.

How do I install an EXE file in PowerShell silently?

To install an EXE file silently using PowerShell, you can use the Start-Process cmdlet with the -ArgumentList parameter. Here’s an example of the command you can use: Start-Process -FilePath "path\to\file.exe" -ArgumentList "/silent"

How do I open an application in PowerShell?

How to run an exe file from the command line?

To run an EXE file from the command line, you need to navigate to the directory where the file is located using the “cd” command. Once you are in the current directory, you can simply type the name of an executable file and press enter to run it.

How do I run PS from the command prompt?

How can I wait for a process to finish before proceeding?

To make PowerShell wait for a process to finish before continuing, you can use the -Wait parameter with Start-Process. This parameter ensures that PowerShell waits for the process and all its descendants to exit before returning control.

Can I pass arguments to the executable with Start-Process?

Yes, you can pass arguments to the executable using the -ArgumentList parameter. Start-Process -FilePath "notepad.exe" -ArgumentList "C:\Temp\Logs.txt"

Can I capture the output of a process started with Start-Process?

Yes, you can capture the output of a process by using the -RedirectStandardOutput parameter and specifying a file path to store the output. For example:
Start-Process -FilePath "ping.exe" -ArgumentList "google.com" -RedirectStandardOutput "output.txt"
This command will start the ping command, ping google.com, and redirect the output to the “output.txt” file.

Can I start a process in a minimized or maximized window?

Yes, you can control the window state of the process using the -WindowStyle parameter. The available options are “Normal”, “Hidden”, “Minimized”, and “Maximized”. For example: Start-Process -FilePath "notepad.exe" -WindowStyle Minimized