推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
chzzzy
V2EX  ›  Python

请教 Python 实现开机启动

  •  
  •   chzzzy · Dec 24, 2019 via iPhone · 3699 views
    This topic created in 2467 days ago, the information mentioned may be changed or developed.

    想要打包成 exe 后开机启动,现在通过修改注册表实现。

    1. 直接添加,失败。 报错:找不到同目录下 ico 图标资源(工作路径改变)
    2. 图标修改成绝对路径,失败。__file__函数找到的还是当前的工作路径
    3. 打包为一个 exe,失败。程序根本无法运行,报错找不到图标,不知道是不是我打包方式错误(修改 spec 文件),似乎是会生成一个临时的资源文件夹,但 pyinstaller 文档似乎没说明。
    4. 将图标编码为 base64 储存在 py 中,这个...太不优雅,下下策

    所以现在的目标基本上有两个:1.改工作路径 2.找绝对路径 3.或者有更好的方法?

    3 replies  •  2020-01-03 11:16:41 +08:00
    vanton
        1
    vanton  
       Jan 2, 2020
    用计划任务,设置下运行目录
    chzzzy
        2
    chzzzy  
    OP
       Jan 2, 2020 via iPhone
    @vanton 感谢回复,不过我要做的是软件自己完成设置开机启动(因为要分发给其他人),现在已经使用 3 的方法成功了
    sherlockgy
        3
    sherlockgy  
       Jan 3, 2020
    windows 服务
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2641 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 08:57 · PVG 16:57 · LAX 01:57 · JFK 04:57
    ♥ Do have faith in what you're doing.