This Tiny PowerShell Script Is My Daily Dose of Motivation

This Tiny PowerShell Script Is My Daily Dose of Motivation

Generate a summary of this story Here is a fact-based summary of the story contents: Here is a simplified version of the story contents: Here is a lighthearted take on the story contents: Explore a different perspective: Show me the facts Explain it like I’m 5 Give me a lighthearted recap

If you want to kick off your day with a dose of motivation, like I do, you can get your Windows 11 PC to show you your chosen motivational quotes every morning. Setting this up is easier than you think, and I’ll walk you through the steps.

Step 1: Create a Text File With Your Quotes

The first thing to do is to create a text file containing your favorite quotes. Your PC will pick a random quote from this file and show it to you every morning.

To do that, launch Windows Search (press Windows+S), type Notepad, and open the app. In a new document, type your quotes (one per line). For example:

Be yourself; everyone else is already taken.
Be who you are and say what you feel, because those who mind don’t matter, and those who matter don’t mind.
Be the change that you wish to see in the world.

After you’ve added all your favorite quotes, from Notepad’s menu bar, select File > Save. Choose the folder where you want to save the file. Click the «File Name» field and type quotes.txt. Then, choose «Save.»

This Tiny PowerShell Script Is My Daily Dose of Motivation

Step 2: Make a Batch File That Randomly Picks a Quote

You’ll now create a batch file that chooses a random quote from your quotes file.

This Tiny PowerShell Script Is My Daily Dose of Motivation

To do this, open Windows Search (press Windows+S), type Notepad, and launch the app. In a new document, type the following:

@echo off
setlocal enabledelayedexpansion
set «file=C:Motivationquotes.txt»
for /f %%A in (‘find /v /c «» ^set /a «rand=(%random% %% lines) + 1»
set /a count=0
for /f «usebackq delims=» %%a in («%file%») do (
set /a count+=1
if !count! equ !rand! set «quote=%%a»
)
mshta «javascript:var sh=new ActiveXObject(‘WScript.Shell’); sh.Popup(‘!quote!’, 10, ‘Motivation’, 64);close();»

In the script, make sure to replace the given path with the path to your quotes file. Also, at the end of the file, you’ll notice 10. It means the file will show your quote for 10 seconds. If you want it to display the quote until you manually dismiss it, replace 10 with 0.

Then, save the file by choosing File > Save. Select a folder to save the file in. Click the «Save as Type» drop-down menu and choose «All Files.» Select the «File Name» field and type showquote.bat. Then, click «Save.»

This Tiny PowerShell Script Is My Daily Dose of Motivation

Step 3: Schedule Quotes With Task Scheduler

You’ll now make your PC launch the batch file you created every morning using Windows 11’s built-in Task Scheduler utility. To do that, open Windows Search (press Windows+S), type Task Scheduler, and open the utility. On the right pane, click «Create Task.»

This Tiny PowerShell Script Is My Daily Dose of Motivation

Click the «Name» field and type something like Motivational Quote. Access the «Triggers» tab and choose «New.» Select the «Begin the Task» drop-down menu and choose «At Log On.» This launches your batch file each time you boot your PC. Then, click «OK.»

This Tiny PowerShell Script Is My Daily Dose of Motivation

Open the «Actions» tab and click «New.» For the «Program/Script» field, click «Browse» and choose the batch file you created earlier (not the quotes file). Then, click «OK.»

This Tiny PowerShell Script Is My Daily Dose of Motivation

Select «OK» to save your task.

From now on, every time you log in to your PC, Task Scheduler will run the batch file and show you one of your chosen quotes. This way, you get a new quote on your screen every morning.

To keep it fresh, you can keep updating and modifying your quotes file to add and remove quotes.

Use PowerShell to Display Quotes

If you want to see quotes in a PowerShell window, launch the Notepad app.

This Tiny PowerShell Script Is My Daily Dose of Motivation

Type the following code, replacing the quotes file path with the path to your quotes file.

$quotes = Get-Content «C:Motivationquotes.txt»
$quote = Get-Random -InputObject $quotes
Add-Type -AssemblyName PresentationFramework
[System.Windows.MessageBox]::Show($quote, «Motivation»)

In Notepad’s menu bar, select File > Save As. Select a folder to save the file in. Click the «Save as Type» drop-down menu and choose «All Files.» Click the «File Name» field and type showquote.ps1. Then, choose «Save.»

This Tiny PowerShell Script Is My Daily Dose of Motivation

Launch the Task Scheduler utility, edit your task, and edit the action in it. In the «Program/Script» field, type powershell.exe. In the «Add Arguments (Optional)» field, type the following. Make sure to replace the path in this code with the path of your PowerShell script.

-ExecutionPolicy Bypass -File «C:Motivationshowquote.ps1»

This Tiny PowerShell Script Is My Daily Dose of Motivation

Select «OK» and choose «OK» again to save the task.

And that’s how you can get your Windows 11 PC to automatically motivate you with a new quote every morning. Like that, you can automate many other tasks using batch files on your Windows 11 PC.

Понравилась статья? Поделиться с друзьями: