Hi
Need help with my python functions
Where or How can I put def get_startupapps_path(): function in def install(): ?
so that when program copy it self to windows homdir,it will be start my ipScript every time at windows startup.Becuse my machine has dynamisk IP-adress.

import sys
import os
import getpass
import platform
import shutil

HOME = os.path.join(os.environ['HOMEDRIVE'], os.environ['HOMEPATH'])

def get_startupapps_path():
    user = getpass.getuser()
    if platform.release() == '7':
        return 'C:\Users\%s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\ ' % user
    elif platform.release().lower() == 'xp':
        return 'C:\Documents and Settings\%s\Start Menu\Programs\Startup\ ' % user




def install():
    path = sys.argv[0]  # get path to script
    head, tail = os.path.split(path)  # return dir and file name
    shutil.copy(path, HOME)  # copy executable to %LOCALAPPDATA%
    executable = os.path.join(HOME, tail)
    head, tail = os.path.split(sys.argv[0])
    if HOME != head:
        install()

    #get_startupapps_path()

Edited 3 Years Ago by tony75

I would just add both directories to the PYTHONPATH variable in .bashrc. You can also add something like
export PYTHONSTARTUP=$HOME/.pythonstartup
to .bashrc to execute a given file when python starts.

Edit: Sorry, I see now from the "7" and "xp" that you are probably using a windows OS, but am going to leave the reply for any future searchers

Edited 3 Years Ago by woooee

This article has been dead for over six months. Start a new discussion instead.