- LAPS in Windows 11: Password encryption and DSRM account management - Wed, Jun 29 2022
- Install subsystem for Linux 2 (WSL2) on Windows Server - Wed, Jun 22 2022
- Next version of Exchange to arrive in 2025; meanwhile, new features for Exchange 2019 - Fri, Jun 10 2022
Start-Process for directories ^
If you want to open File Explorer from your current location on the command line, you could do this with the following command:
cmd.exe knows the start command, which offers a variety of additional optional commands for the execution of a program. The next simple command also opens Explorer in the current folder:
In PowerShell, the start command exists as an alias of the Start-Process cmdlet. If you pass the name of a directory as an argument, it will open Explorer at this location. In the above case, this would be “.\”; however, you can use any other path.
Starting File Explorer in the current folder
Of course, in addition to explicitly passing a directory, you can also work with variables here. For instance, the following command displays the home directory of the currently logged-on user in File Explorer:
Other useful environment variables are SystemRoot and TEMP.
Executing with administrative rights ^
You can also execute a new process with administrative rights by passing the parameter runas:
Start explorer.exe $pwd -verb runas
In most cases, you don’t need this feature when starting Explorer. It would be more interesting for a new command line with administrative rights. This works, but cmd.exe and PowerShell ignore the working directory if you pass it as a variable with the above pattern.
Full screen or normal window ^
If you want, you can also determine if the corresponding program will start in a normal window, minimized, or in full screen mode:
Start . -WindowStyle Maximized
The alternatives to Maximized are Minimized, Normal, and Hidden, although the latter is rarely useful in practice.
Opening multiple directories simultaneously ^
A restriction of Start-Process is that it can only start one process per call. For example, if you want to open two folders in Explorer in order to copy files between them, Invoke-Item is the better option:
Invoke-Item .\Documents, .\Downloads
This call would display the current folder's subdirectories Documents and Downloads in Explorer. In this case, you can’t use the WindowStyle parameter.