[Last Call] Learn how to a build a cloud-first strategyRegister Now


launching a random website from the command line

Posted on 2014-08-22
Medium Priority
Last Modified: 2014-08-22
"start http://www.microsoft.com" launches a website from the command line. What should I do to launch a randomly selected website from a predefined pool?
Question by:axcx

Accepted Solution

dlb6597 earned 2000 total points
ID: 40278975
bare-bones, probably better ways to accomplish if your predefined pool is rather large...

REM change the %%3 to the total number of sites in pool
set /a url=%RANDOM% %%3
goto %url%
start http://www.microsoft.com
goto end
start http://www.google.com
goto end
start http://www.ibm.com
goto end
rem create new label, start, goto end lines for additional sites
start http://www.moresites.com
goto end

Open in new window


Expert Comment

by:Liam Somerville
ID: 40278981
This might be your ticket. I've modified it a bit for you. You'll need a "websites.txt" file containing your sites:

$Sites = Get-Content C:\websites.txt

$hash = @{}

foreach ($Site in $Sites)
    $hash.add($u,(Get-Random -Maximum $Sites.count))
} #end foreach

$PickedSite = $hash.GetEnumerator() | Sort-Object -Property value | Select-Object -First 1

start $PickedSite

Open in new window

I haven't tested this. Let me know if it works.

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With Windows evolving further, the built-in protective mechanisms get better and better. Still, Microsoft is not very good at introducing those to the technical community. This article is about a new bitlocker functionality that could revolutionize …
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses
Course of the Month17 days, 17 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question