Skip to content

This is a super automated CMD script to install python 3.98 on windows 8/9/10/11. If you have questions, you can contact me. flo <AT> radford <dot> edu

As I had encountered some minor issue, when running this code from below on Windows 11. Often times it will pause and display nothing. To solve this problem, simply press ENTER. You wont encounter such issue when running this code on Windows 10.

github link for the code from below

@echo OFF
:: ADMIN ONLY
:: https://superuser.com/questions/667607/check-if-current-command-prompt-was-launched-as-the-administrator
goto check_Permissions
:check_Permissions
    echo Administrative permissions required. Detecting permissions...
    net session >nul 2>&1
    if %errorLevel% == 0 (
        echo Admin Permissions confirmed.
    ) else (
        echo Admin Permissions not confirmed. 
        echo Right click on the DOS Prompt and RUN AS Administrator
        echo run this script to install Python v3.9.8 Silently.
        echo Exiting....
        goto end
    )
::    pause >nul
echo.
echo.
timeout /T 4 > nul
::
cls
:: Prompt for user to Really run this script
setlocal
set Value="n"
:PROMPT
SET /P Value=Are you sure installing Python-3.9.8 (y/[n])?
IF /I "%Value%" NEQ "y" GOTO END

:: This batch file will show details Windows 10, and install Python v3.9.8
TITLE Install Python Software on Windows 7/8/9/10/11
echo.Checking system information.
timeout /T 2 > nul

:: Switch to Downloads early on
cd C:\Users\%USERNAME%\Downloads

echo.
echo.
:: Section 1: Windows 10/11 information.
echo.============================
echo.WINDOWS INFO
echo.============================
echo.
systeminfo | findstr /c:"OS Name"
systeminfo | findstr /c:"OS Version"
systeminfo | findstr /c:"Hyper-V Requirements"

:: Quick Pause
echo.
timeout /T 2 > nul

echo.
echo.
:: Section 2: Hardware information.
echo.============================
echo.HARDWARE INFO
echo.============================
echo.
systeminfo | findstr /c:"Total Physical Memory"
systeminfo | findstr /c:"Virtual Memory: In Use"

:: Quick Pause
echo.
timeout /T 2 > nul

echo.
:: Section 3: Python Download.
echo.============================
echo.Checking Existing Python
echo.============================
echo.
::
echo. Checking for existing version of Python
::
::
:: https://www.python.org/ftp/python/3.9.8/python-3.9.8-amd64.exe

IF EXIST "python-3.10.0-*.<" (
  echo.Found existing version of Python 3.10.0
  del python-3.10.0-amd64.exe
  echo.Deleting existing version of Python
  echo.
  timeout /T 2 > nul
) ELSE (
  timeout /T 2 > nul
  echo.No existing version of python 3.10.0 Found.
  echo.
)
::
:: Quick Pause
timeout /T 2 > nul
::
IF EXIST "python-3.9.*.<" (
  echo.Found existing version of Python 3.9.*
  del python-3.9.*.*
  echo.Deleting existing version of Python
  echo.
  timeout /T 2 > nul
) ELSE (
  timeout /T 2 > nul
  echo.No existing version of python 3.9 Found.
  echo.
)
echo.
echo.you may need to press ENTER, 
echo.If the wait time is more than 10 seconds.
::
:: Quick Pause
timeout /T 2 > nul
::
IF EXIST "python-3.8.*.<" (
  echo.Found existing version of Python 3.8.*
  del python-3.8.*.*
  echo.Deleting existing version of Python
  echo.
  timeout /T 2 > nul
) ELSE (
  timeout /T 2 > nul
  echo.No existing version of python 3.8 Found.
  echo.
)
echo.
echo.you may need to press ENTER, 
echo.If the wait time is more than 10 seconds.
::
:: Quick Pause
echo.
timeout /T 2 > nul
::
:: Check to see if bitsadmin is located here
echo.
echo.
:: Section 3: Bitsadmin Download.
echo.============================
echo.Checking Bitsadmin
echo.============================
echo.
::
IF EXIST C:\Windows\SysWOW64\bitsadmin.exe (
  echo.Bitsadmin is installed on your Windows 7/8/9/10/11 system.
  echo.Will download Python 3 software.
  echo.
  timeout /T 2 > nul
) ELSE (
  timeout /T 2 > nul
  echo.Apparently, Bitsadmin.exe not found.
  echo.Raise your hand and ask Your Local IT Shop
  echo Can you feel the sorrow ?
  echo.
  goto end
)
::
:: Quick Pause
timeout /T 2 > nul
::
echo.
echo.
:: Section 3: Python Download.
echo.============================
echo.Downloading Python
echo.============================
echo.
::
timeout /T 2 > nul
echo.
echo.
C:\Windows\SysWOW64\bitsadmin.exe /transfer PythonDownload /download /priority normal https://www.python.org/ftp/python/3.9.8/python-3.9.8-amd64.exe C:\Users\%USERNAME%\Downloads\python-3.9.8-amd64.exe
::
echo.
echo.
timeout /T 2 > nul
timeout /T 4 > nul
echo.Checking to see if this python file has been downloaded.
timeout /T 2 > nul
timeout /T 4 > nul
::
IF EXIST python-3.9.8-amd64.exe (
  echo.Python file has been Found.
  echo.Will now Install this Software.
  echo.
  timeout /T 2 > nul
) ELSE (
  timeout /T 2 > nul
  echo.Software not found.
  echo.Perhaps, try to run this file again.
  echo.
  goto end
)

echo.
echo.======================================
echo.Finish downloading the Python Software
echo.======================================
echo.
::
echo.
echo.
:: Section 4: Python Installation.
echo.============================
echo.Installing Python
echo.============================
echo.
echo.Installing Python version 3.9.8
echo.This process will take as much as 15 mins if there is no SSD.
echo.
echo.Go grab Koffie or something before coming back to your Laptop.
:: Installing Python
::
C:\Users\%USERNAME%\Downloads\python-3.9.8-amd64.exe /quiet InstallAllUsers=0 TargetDir=C:\Python398 AssociateFiles=1 CompileAll=1 PrependPath=0 Shortcuts=0 Include_doc=1 Include_debug=0 Include_dev=1 Include_exe=1 Include_launcher=1 InstallLauncherAllUsers=1 Include_lib=1 Include_pip=1 Include_symbol=0 Include_tcltk=1 Include_test=1 Include_tools=1
::
echo.
echo.=======================================
echo.Compiling and Installing Python Modules
echo.=======================================
echo.
:: Quick Pause
timeout /T 2 > nul
echo.
set num=15
for /L %%I IN (1, 1, %num%) do (
  echo. | set /p="%%I " 
  timeout /T 1 > nul
)
echo.
echo.===================================
echo.Finished Installing Python Software
echo.===================================
echo.
::
echo.Be Patient, 60%% Completed
::
echo.
echo.
::
:: Checking the file to see if it was made
::
echo.
echo.
:check
if exist C:\Python398\Tools\pynche\Main.py (
    echo.Checking Files if Python has been installed.....
    timeout /T 3 > nul
    echo.
    echo. Python Software has been Installed.
) else (
    echo. Python has not been installed.
    timeout /T 1 > nul
    echo.
    timeout /T 1 > nul
    echo.Problem with installation. PRESS: CTRL-C to End Installation process only if after three printed messages.
    goto check
)
::
echo.
echo.========================
echo.Updating pip the modules
echo.========================
echo.
echo Starting....
::
:: Updating pip on Windows
C:\Python398\python.exe -m pip install --upgrade pip
::
:: Quick Pause
timeout /T 2 > nul
echo.
echo.======================
echo.Finished Updating pip
echo.======================
echo.
echo done
::
:: Waiting for the previous process to finish
::
echo.
echo.=============================
echo.Installing Additional Modules
echo.=============================
echo.
:: Quick Pause
timeout /T 1 > nul
C:\Python398\Scripts\pip.exe install --user wheel
timeout /T 1 > nul
echo done
::
echo.
echo.===========================
echo.Finished installing Modules
echo.===========================
echo.
echo. 85%% Completed.
echo done
::
echo.
echo.
:: Section 4: Execute runme.bat.
echo.============================
echo.Execute runme.bat
echo.============================
::
echo set PATH=C:\Python398;%PATH% > C:\Users\%USERNAME%\runme.bat
del /s C:\Users\%USERNAME%\Downloads\python-3.9.8-amd64.exe >nul 2>&1
call C:\Users\%USERNAME%\runme.bat
echo.
echo.
python -c "print(\"Welcome, Python installation Success.\")"
echo.
echo.
echo 100%% Completed !
:end

When updating homebrew with your new M1 Apple machine as a web dev machine by developing backend applications with PHP with Homebrew along with MongoDB, where there is an issue when you compile mongoDB driver using PHP from homebrew. We always run into this minor problem, which is somewhat irritating to an extend as we update via the brew command. The main issue we had encountered was that whenever we run

./brew update

the mongodb.so lib driver file will get deleted automatically in the PHP modules location. Since, we've decided to install mongoDB manually from source code, we knew there would be some type of problems we would encounter.

There were two issues:
1) missing pcre2.h file upon compilation
2) automatic deletion of mongodb.so inside a php module dir, after issuing a brew update command.

We will first remedy the missing pcre2.h file in the following section, so that we could compile mongoDB as a driver to be used with PHP@7.4. We will then copy over the mongodb module into the PHP module location.

Using PHP.net 's instructions on how to retrieve the source code for MongoDB. There is a process to get this done relatively with ease.

Compilation of PHP MongoDB Driver

$ git clone https://github.com/mongodb/mongo-php-driver.git
$ cd mongo-php-driver
$ git submodule update --init
$ phpize
$ ./configure

At this Point, pcre2.h is not available from the github repo for this php-mongodb driver package, you can now copy from the default location from your M1 to get this header file to be copied over to this mongo-php-driver directory.

This pcre2.h file should be in this area on your M1 machine, depending on your version of pcre2 from your brew update command. If you don't currently have the pcre2.h file, you then must install the pcre dev header package for pcre from homebrew first. This version i have installed is listed below.

/opt/homebrew/Cellar/pcre2/10.38_1/include/pcre2.h
$ cp /opt/homebrew/Cellar/pcre2/10.38_1/include/pcre2.h . 
$ ./configure 
$ make all

This should take care of the missing pcre2.h file after placing the pcre2.h unto the mongo-php-driver directory for compilation. Once it has finished compiling, you can cd to the modules directory and copy over the mongodb.so file to /opt/homebrew/Cellar/php@7.4/7.4.26/lib/php/20190902/ or whichever directory location it needs to be copied to that location.

If you do have PHP@7.4 in your PATH, you can enter in php -v to check

if that missing --mongodb.so-- lib error has gone away.

flo@hobbit: $ php -i | grep -i mongo

mongodb
MongoDB support => enabled
MongoDB extension version => 1.12.0-dev
MongoDB extension stability => devel
libmongoc bundled version => 1.11.1-20211103+gitb93e345178
libmongoc SSL => enabled
libmongoc SSL library => Secure Transport
libmongoc crypto => enabled
libmongoc crypto library => Common Crypto
libmongoc crypto system profile => disabled
libmongoc SASL => enabled
libmongoc ICU => disabled
libmongoc compression => enabled
libmongoc compression snappy => disabled
libmongoc compression zlib => enabled
libmongoc compression zstd => enabled
libmongocrypt bundled version => 1.2.1
libmongocrypt crypto => enabled
libmongocrypt crypto library => Common Crypto
mongodb.debug => no value => no value
mongodb.mock_service_id => Off => Off



The reason for compiling is that one can easily obtain the latest and greatest software.

How to install MongoDB unto Apple M1.

Go to mongoDB website and download their community version of their product. Download not just the Community Server but also their MongoDB Tools. There are Shell, Compass and Db Tools. I initially had installed Mongosh inside tools inside /opt/mongodb after installing the Mongo Db engine directly inside /opt/mongodb. The remaining items are Compass and a special software called RoboMongo. This is a GUI interface to the connect to the mongoDB engine.

Location of MongoDB and Mongosh.

After those two items were installed, I had to configure the MongoDB engine and would very much like to run it using a config file rather than supplying the mongod command with tons of parameters. So i then worked on the configuration file to make some changes.

MongoDB Configuration.

fork : true doesnt seem to work and had resorted to false instead. The only other items on this install where i had to work on was giving those paths an ownership of the user who needed to be used in order to run these items. My mongodb.conf file is hiding inside my /opt/homebrew/etc location


sudo mkdir -p /usr/local/var/log/mongodb
sudo touch /usr/local/var/log/mongodb/mongod.log
sudo chown -R username:group /usr/local/var/log/mongodb

sudo mkdir -p /usr/local/var/mongodb
sudo chown -R username:group /usr/local/var/mongodb


sudo mkdir -p /var/run/mongodb
sudo touch /var/run/mongod.pid
sudo chown -R username:group /var/run/mongodb

# to run the MangoDB
/opt/mongodb/bin/mongod -f /opt/homebrew/etc/mongod.conf

After downloading this CentOS boot iso (~740MB) file instead of the full-blown (~4.1GB) from CentOS website on windows 10, I've decided to install CentOS Stream inside VMPlayer instead of Virtualbox. Installing main stream flavors of linux on either Hypervisor client software would be perfectly fine. Many of the linux distros will work inside either software.

BTW: Kubuntu, Xubuntu and Manjaro are working Great inside VMPlayer. There is one unique linux distribution where i wish i could use on a daily basis due to its sheer GUI using the Pantheon GUI Engine. This is elementary linux. Please support and donate to many of these wonderful linux opensource communities. 🙂

Configurations:
-- 8096 MB RAM
-- 20 GB HD
-- 2 CPUs

Installation Process:
After realizing i had installed CentOS v8 on a laptop before end of October 2020. This CentOS version 8 was no longer able to be downloaded and was replaced with this new version of the fedora like CentOS Stream which will get upgraded every 6 - 8 months unlike the previous CentOS version 8. The installation process was extremely similar to CentOS version 8 and 7. The only one section which differed from previous versions were the section to insert a link for the installation source location which is a repo of packages. This time, CentOS install force users to manually enter this URL
mirror.centos.org/centos/8/BaseOS/x86_64/os/

One can also add additional repository onto their CentOS server. I could never seem to remember this added on magical repo for all Redhat like OS. These two repos were the two i've used when i was in the IT industry on the Redhat like OSes.

https://fedoraproject.org/wiki/EPEL
https://rpms.remirepo.net

After choosing a few server packages and it was off to download and installation process. At the end of this process after a reboot. You would then add your user(s) to this newly deployed system. Super easy to get this up and running on VMPlayer workstation.

Instructions on how to install CentOS stream if you want to use it as a Guide.

There had been a major software security breach in the world of software management. I've been following this event in order to grasp the magnitude or scale of this breach which had ensnared public and private organizations. It does appear this security breach had affected a wide range of companies not only in the US and also agencies in the US Fed Gov as well. There was a joint write-up between Microsoft and Fireeye on how this breach was completed.

https://www.fireeye.com/blog/threat-research/2020/12/evasive-attacker-leverages-solarwinds-supply-chain-compromises-with-sunburst-backdoor.html

https://cyber.dhs.gov/ed/21-01/

https://us-cert.cisa.gov/ncas/alerts/aa20-352a

Many of the IT Security has been using security tools to decipher what was done in the code (dll) file by the following software:

https://www.fireeye.com/blog/threat-research/2020/12/evasive-attacker-leverages-solarwinds-supply-chain-compromises-with-sunburst-backdoor.html

https://github.com/cybercdh/hacks/tree/master/sunburst

https://www.winitor.com/

https://ghidra-sre.org/

We will provide some software which can easily be installed on windows, linux, and Mac as a standalone software package.

-- https://www.apachefriends.org/download.html
-- https://bitnami.com/stack/wamp/installer
-- https://www.mamp.info/en/downloads/
-- https://www.appserv.org/en/download/
-- https://ampps.com/downloads
-- https://www.wampserver.com/en/

installation to install these things separately as three different packages
-- https://www.znetlive.com/blog/how-to-install-apache-php-and-mysql-on-windows-10-machine/

-- mariaDB: https://mariadb.org/download/
-- mysql: https://dev.mysql.com/downloads/
-- mysql: https://dev.mysql.com/downloads/mysql/
-- php: https://www.php.net/downloads
-- https://downloads.apache.org/httpd/

Notable mention of a super-fast HTTP Engine
-- https://nginx.org/en/download.html

We will plan to write some documentation on how to install mariaDB+php+apache+odbc on a later Chapter.

Special linux distro LAMP installation guide
-- https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mariadb-php-lamp-stack-on-debian-10
-- https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mariadb-php-lamp-stack-on-centos-8
-- https://www.itzgeek.com/post/how-to-install-linux-apache-mariadb-php-lamp-stack-on-ubuntu-20-04/

// ADD DNS to your mac machine on CMD
sudo networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4 185.228.168.9 208.67.222.222

// Change your mac hostname, pcname, localhostname
sudo scutil --set HostName <NEWMACHINENAME>
sudo scutil --set ComputerName <NEWMACHINENAME>
sudo scutil --set LocalHostName <NEWMACHINENAME>



@echo OFF
::
:: This was one of the most complicated software i had ever written
:: DOS scripting is Crazy HARD !
:: 
cls
:: Prompt for user to Really run this script
setlocal
set Value="n"
:PROMPT
SET /P Value=Are you sure (y/[n])?
IF /I "%Value%" NEQ "y" GOTO END

:: This batch file will show details Windows 10, and install Python v3.8.6.
TITLE Install Python Software on Windows 7/8/9/10
echo.Checking system information.
TIMEOUT /T 2 > nul

:: Switch to Downloads early on
cd %userprofile%/Downloads

echo.
echo.
:: Section 1: Windows 10 information.
echo.============================
echo.WINDOWS INFO
echo.============================
echo.
systeminfo | findstr /c:"OS Name"
systeminfo | findstr /c:"OS Version"
systeminfo | findstr /c:"Hyper-V Requirements"

:: Quick Pause
echo.
TIMEOUT /T 2 > nul

echo.
echo.
:: Section 2: Hardware information.
echo.============================
echo.HARDWARE INFO
echo.============================
echo.
systeminfo | findstr /c:"Total Physical Memory"
systeminfo | findstr /c:"Virtual Memory: In Use"
:: wmic diskdrive GET index,caption,name,size /format:table
:: wmic diskdrive GET index,Model,SerialNumber,Size,Status

:: Quick Pause
echo.
TIMEOUT /T 10 > nul

echo.
echo.
:: Section 3: Python Download.
echo.============================
echo.Downloading Python
echo.============================
echo.
::
echo.Downloading Python Software.
::
::
TIMEOUT /T 4 > nul
echo.
echo.
bitsadmin /transfer PythonDownload /download /priority normal https://www.python.org/ftp/python/3.8.6/python-3.8.6-amd64.exe %userprofile%\Downloads\python-3.8.6-amd64.exe

:: Quick Pause
echo.
echo.
TIMEOUT /T 2 > nul
TIMEOUT /T 2 > nul
echo.Checking to see if this python file has been downloaded.

IF EXIST python-3.8.6-amd64.exe (
  echo.Python file has been Found.
  echo.Will now Install this Software.
  echo.
  TIMEOUT /T 2 > nul
) ELSE (
  TIMEOUT /T 2 > nul
  echo.Software not found.
  echo.Perhaps, try to run this file again.
  echo.
  goto end
)
echo.Finish downloading the Python Software.
echo.

echo.
echo.
:: Section 4: Python Installation.
echo.============================
echo.Installing Python
echo.============================
echo.

echo.
echo.Installing Python version 3.8.6.
echo.This process will take as much as 15 mins if there is no SSD.
echo.
echo.Go grab Koffie or something before coming back to your Laptop.
:: This python install process is weird, it will simply return prompt once it had been executed but the process
:: will not be 100 percent completed before continuing as we have learned.
%userprofile%\Downloads\python-3.8.6-amd64.exe /quiet InstallAllUsers=1 TargetDir=c:\Python38 AssociateFiles=1 CompileAll=1 PrependPath=0 Shortcuts=0 Include_doc=1 Include_debug=0 Include_dev=0 Include_exe=1 Include_launcher=1 InstallLauncherAllUsers=1 Include_lib=1 Include_pip=1 Include_symbol=0 Include_tcltk=1 Include_test=1 Include_tools=1
::
::
:: This is quite sensitive wait time during installation.
:: It is compiling and creating all the dirs before all
:: files are compiled. It then do other things too.
:: Not sure what would be a good wait time before moving onto the next process.
:: it is wise to wait for atleast 3 mins actually due to compilation
:: of lots of tiny files inside python.
::
echo.
echo.Still compiling Python modules........
:: TIMEOUT 400
:: Buffer Zone
TIMEOUT /T 2 > nul
echo.
SET num=60
for /L %%I IN (1, 1, %num%) do (
  echo. | set /p="%%I " 
  TIMEOUT /T 1 > nul
)
echo.
echo.
echo.Finished Installing Python Software
echo.
echo.
::
::
echo.Be Patient, Almost done.
::
::
echo.
echo.
:: Section 4: Third Party Software Installation.
echo.============================
echo.Installing Third Party Software
echo.============================
echo.
::
:: Checking the file to see if it was made
::
echo.
:check
if exist C:\Python38\Tools\pynche\Main.py (
    echo.Checking Files if they were Created.....
    TIMEOUT /T 3 > nul
    echo.
    echo.They were created.
) else (
    echo.Files still not created.....
    TIMEOUT /T 2 > nul
    echo.
    TIMEOUT /T 3 > nul
    echo.Problem with installation. PRESS: CTRL-C to End Installation process only if after two messages printed.
    goto check
)

echo.
echo.
echo.Updating pip the module manager tool.
::
:: Updating pip on Windows
C:\Python38\python.exe -m pip install --upgrade pip
::
TIMEOUT /T 3 > nul
echo.
echo.Finished Updating pip.
::
:: Waiting for the previous process to finish
::
echo.
echo.
echo.Installing Additional required Modules
TIMEOUT /T 4 > nul
C:\Python38\scripts\pip.exe install --user requests diceware scipy numpy pandas matplotlib seaborn
TIMEOUT /T 8 > nul
::
echo.
echo.Finished installing Required Modules.

echo.
echo.
:: Section 4: Execute runme.bat.
echo.============================
echo.Execute runme.bat
echo.============================
echo.

echo set PATH=C:\Python38;%PATH% > %userprofile%\runme.bat
del /s %userprofile%\Downloads\python-3.8.6-amd64.exe >nul 2>&1
echo."Done Installing"
call %userprofile%\runme.bat
python -c "print(\"Welcome, Python installation Success !\")"
:END
The above code should do the trick in order to install python v3.8.6 onto a windows 10 x86_64 machine. Run it as admin since stuff will needed to be installed in C:\, mk dir and compile all kinds of stuff.  We were hesitant to install v3.9.0 Python since there might not many supported third party library as of this writing, so we defaulted in using the latest previous version. We have tested this script on windows 10. It has been Functioning three times since 20201125. Tested on both windows 10 v1907 and v20H2