Hit a command in Python (Windows)

Python that executes commands as if you hit the command prompt.


# coding:utf-8
import os

cmd = "ipconfig /all > D:\\ipconfig.txt"
os.system(cmd)

cmd = "tree D:\\Doc /f > D:\\tree.txt"
os.system(cmd)

If you make it an executable file, you can distribute it like .bat.

Please let me know if there is a smarter way to write it.

Ijo

Recommended Posts

Hit a command in Python (Windows)
[Python] [Windows] Take a screen capture in Python
Call a command from Python (Windows version)
Hit Mastodon's API in Python
Create a function in Python
Create a dictionary in Python
Execute external command in python
Make a bookmarklet in Python
External command execution in Python
Draw a heart in Python
Python install in 2 lines @Windows
Specify a subcommand as a command line argument in Python
Until drawing a 3D graph in Python on windows10
How to execute a command using subprocess in Python
I implemented a Vim-like replacement command in Slackbot #Python
Maybe in a python (original title: Maybe in Python)
[Python] Show multiple windows in Tkinter
[python] Manage functions in a list
Put MeCab in "Windows 10; Python3.5 (64bit)"
How to run a Python file at a Windows 10 command prompt
Create a DI Container in Python
Hit the Sesami API in Python
Run shell command / python in R
Draw a scatterplot matrix in python
ABC166 in Python A ~ C problem
Write A * (A-star) algorithm in Python
In the python command python points to python3.8
Create a binary file in Python
Windows10: Install MeCab library in python
Solve ABC036 A ~ C in Python
Write a pie chart in Python
Hit the web API in Python
Write a vim plugin in Python
Write a depth-first search in Python
[python] Manage functions in a dictionary (command table, function table, function pointer)
Implementing a simple algorithm in Python 2
Create a Kubernetes Operator in Python
Solve ABC037 A ~ C in Python
Run a simple algorithm in Python
Draw a CNN diagram in Python
Create a random string in Python
When you want to hit a UNIX command on Python
Schedule a Zoom meeting in Python
When writing a program in Python
Create a Python environment for professionals in VS Code on Windows
How to get a string from a command line argument in python
Mouse operation using Windows API in Python
Spiral book in Python! Python with a spiral book! (Chapter 14 ~)
Solve ABC175 A, B, C in Python
Use print in a Python2 lambda expression
A simple HTTP client implemented in Python
Do a non-recursive Euler Tour in Python
Using venv in Windows + Docker environment [Python]
I made a payroll program in Python!
Precautions when pickling a function in python
[LLDB] Create your own command in Python
Write the test in a python docstring
Display a list of alphabets in Python 3
Try sending a SYN packet in Python
Try drawing a simple animation in Python
Learn the design pattern "Command" in Python