Table of Contents
Our script will open the Windows Calculator application at Windows startup and login based on the solution you will choose from. To meet your requirements, you can replace the script in
file.ps1with your script.
Using Startup Folder
Use the Startup folder to run the PowerShell script at startup. To do this, we must follow this section’s step-by-step instructions.
Create .ps1 File
Open Notepad, write the following command, and save the file with any name of your choice but with the .ps1 extension. You can store this PowerShell script file at any location on your local machine; we saved this file with the file.ps1 name at the E:\Test location.
|
1 2 3 |
powerShell "c:\windows\system32\calc.exe" |
This command would open the calculator on the local computer.
Create .cmd File
Launch Notepad, write the following commands, and save the file with a name but with the extension .cmd at %AppData%\Microsoft\Windows\Start Menu\Programs\Startup path. We named this file Startup.cmd and placed it in the Startup Folder.
While saving the .cmd file, don’t forget to select All Files for the Save as type: option and ANSI for the Encoding option; see the screenshot after the following script for clear understanding.
|
1 2 3 4 |
PowerShell -Command "Set-ExecutionPolicy Unrestricted" -Scope CurrentUser >> "%TEMP%\StartupLog.txt" 2>&1 PowerShell E:\Test\file.ps1 >> "%TEMP%\StartupLog.txt" 2>&1 |

The above script did two things. First, it sets the execution policy to Unrestricted, and the second is to use PowerShell to run the .ps1 script file in the given path. Let’s break down the above commands to learn them in detail.
The first command:
- Runs the PowerShell with the
-Commandparameter to execute theSet-ExecutionPolicy Unrestrictedcommand, which modifies the PowerShell execution policy to let us run unsigned scripts. - The
-Scopparameter applies changes to the current user instead of the entire system. - The redirection operator represented by
>>redirects the command output (if any) to theStartupLog.txtfile in the user’s%TEMP%directory. The>>operator appends the output to the end of theStartupLog.txtfile if it already exists; otherwise, it creates it. - The
2>&1operator redirects the command’s error output (2) to the exact file as the standard output (&1).
The second command:
- Runs PowerShell with the E:\Test\file.ps1 script as an argument. You might have a different path if you have stored your
.ps1file in a different location on your PC. - The redirection operator (
>>) does the same as in the first command. - The
2>&1operator also does the same thing as in the first command.
Overall, both commands use the >> and 2>&1 operators to capture the errors and output of the PowerShell command or script and write them to a StartupLog.txt file in the user’s %TEMP% directory.
Restart Your PC
Now, you have the .ps1 file and .cmd file at the required locations, so it’s time to restart your computer. Once the computer is on, the script will be executed and open the Calculator app for you.
Using Task Scheduler
Use Task Scheduler to run PowerShell script at startup. Following the below steps to do it.
Open Task Scheduler
Press Windows+R key from the keyboard, type taskschd.msc in the Run prompt and hit OK. It will open the Task Scheduler window for you. See the following screenshot.

Otherwise, you can use the Windows search menu to open Task Scheduler.
Create a Task
-
In the
Task Schedulerwindow, clickCreate Taskas demonstrated below.
-
Ensure you are on the
Generaltab in theCreate Taskwindow. Then, write the name of the task (step-1), select theRun only when the user is logged onradio button (step-2), check theRun with highest privilegescheckbox (step-3), and click on theActionstab (step-4).
-
Once you are on the
Actionstab, click on theNewbutton (step-2), make sure theStart a programoption is selected forActions:option (step-3), writepowershell.exeforProgram/scriptoption (step-4), addE:\Test\file.ps1as the value ofAdd arguments (optional)option (step-5) and clickOKbutton (step-6). Remember, you can specify your arguments for step-5.
-
Now, click on the
Triggerstab (step-1), click on theNewbutton (step-2), selectAt log onforBegin the task:option (step-3), choose theAny userorSpecific userbased on your requirements (step-4), clickOK(step-5), and clickOKagain (step-6).
Your task must be listed in the
Task Schedulerwindow (see the following); if it is there, you have done everything right, close this window.
Log Out and Login Your PC
Log out and log in again to your computer. You don’t need to reboot the computer to run this script. This script will open the Windows Calculator application.
Further reading:
Using Registry Editor
Use Task Scheduler to run PowerShell script at startup. Following the below steps to do it.
Open Registry Editor
Press Windows+R key from the keyboard, type regedit.msc in the Run prompt and hit OK. It will open the registry editor window.

Add Entry to the Windows Registry Editor
-
Navigate to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run in the registry editor (step-1).
-
Right-click the
Runkey and chooseNew->String Value(step-2). -
Give a new entry a meaningful name as we named it
PSfile. Note that this name must be unique; otherwise, you will get an error.
-
Double-click on the new entry (
PSfile) to open theEdit Stringwindow. -
In the
Edit Stringwindow, you can confirm the new entry’s name (step-3). For theValue datafield, enter thepowershell "E:\Test\file.ps1"command (step-4); you can replace the path to point your PowerShell script file. Remember to surround the path with double quotes. -
Click
OKto exit theEdit Stringwindow (step-5). -
Close the Registry Editor.
Restart Your PC
Restart your computer to run the script automatically every time Windows starts up. This script will open the Windows Calculator application for you.