How to add a Python script to the Windows right-click menu

Source: Internet
Author: User

For example, I have a python program called getpath.py, which is used to get the full path name of the file I selected.
getpath.py
Import sysif __name__ = = ' __main__ ':    If Len (sys.argv)! = 2:        sys.exit (' argv error! ')    # #sys. argv[1] is the path file name entered.    # #后面是对sys. argv[1] Processing
How do I add this script to the Windows right-click menu?
Write a batch process first:
Mypath.bat
C:\Python34\python.exe d:\work\getPath.py%*

Put this batch file under C:\Windows for easy invocation.

write a registry file again
Getpath.reg
Windows Registry Editor Version 5.00[hkey_classes_root\*\shell\getpath\command]@= "mypath.bat \"%1\ ""

Import the registry, right-click on the GetPath menu.


How to add a Python script to the Windows right-click menu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.