KangarooRIOT
KangarooRIOT

Reputation: 631

Using a script to search google

I am new to Powershell and after having a few ideas and deciding to tinker around a bit I noticed that I can write a script in Poswershell that will make a search request on a search engine that I specify.

The issue is I am not sure exactly how it works. How is this script able to know how to open my web browser when all I did was specify a string filled with an address?

I have searched up other posts and have not found anything close to what I am asking (I believe). Here is my source and I will also add an image.

[String]$SearchFor = "bing rewards"

$Query = "http://www.bing.com/search?q=$SearchFor"

Start $Query

enter image description here

Thank you all for your help.

Upvotes: 2

Views: 2116

Answers (2)

Adam Mnich
Adam Mnich

Reputation: 471

Read help on start-process

https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.management/start-process

If you specify a non-executable file, Start-Process starts the program that is associated with the file, similar to the Invoke-Item cmdlet.

So if I would have a TXT File in C:\test.txt and run

start-process c:\test.txt

It would open my default application assiociated with that file. On my PC it would open test.txt in notepad.

Hope that makes it clear now.

Upvotes: 3

sodawillow
sodawillow

Reputation: 13176

It simply uses the default application to open URLs on your desktop i.e. your default Internet browser.

Same behavior if you paste the URL (without variables) in your Start > Run box.

Upvotes: 3

Related Questions