launching a random website from the command line

Posted on 2014-08-22
Last Modified: 2014-08-22
"start" launches a website from the command line. What should I do to launch a randomly selected website from a predefined pool?
Question by:axcx
    LVL 9

    Accepted Solution

    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%
    goto end
    goto end
    goto end
    rem create new label, start, goto end lines for additional sites
    goto end

    Open in new window

    LVL 3

    Expert Comment

    by:Liam Somerville
    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

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Security measures require Windows be logged in using Standard User login (not Administrator).  Yet, sometimes an application has to be run “As Administrator” from a Standard User login.  This paper describes how to create a shortcut icon to launch a…
    If you use NetMotion Mobility on your PC and plan to upgrade to Windows 10, it may not work unless you take these steps.
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now