Page 1 of 1

Problem during file copy

Published: May 20, 2021 - 2:18 PM
by Louis
Good morning !

I am currently packaging LibreOffice for my company, with some features that I have added to the LibreOffice configuration files located in the Roaming.

I would like my pre-configured "LibreOffice" file to be moved from the package to my user directory during the installation of my package. I therefore made a copy of the file located in the package to the root of my PC.

then with the def session setup(): I move it into the file usersUnfortunately, it doesn't work, and I've been racking my brains for a while now without finding a solution.

The copy doesn't even go to the PC's root directory, so it's impossible to move it to the user folder.

Here is my code:

Code: Select all

def install():

    copytree2('LibreOffice','C:\Program Files (x86)')
    argument = {}
    if not installed_softwares('Microsoft Office'):
        argument = {'SELECT_WORD':1,'SELECT_EXCEL':1,'SELECT_POWERPOINT':1,'CREATEDESKTOPLINK':0,'RebootYesNo':'No','ALLUSER':1,'ISCHECKFORPRODUCTUPDATES':0,'QUICKSTART':0}
    else:
        argument = {'CREATEDESKTOPLINK':0,'RebootYesNo':'No','ALLUSER':1,'ISCHECKFORPRODUCTUPDATES':0,'QUICKSTART':0}
    install_msi_if_needed('LibreOffice_7.0.5_Win_x64.msi',properties=argument)

    # Suppression des raccourcis
    for wrongshortcutname in wrongshortcutnames:
        remove_desktop_shortcut(wrongshortcutname)
        remove_programs_menu_shortcut(wrongshortcutname)
        if isdir(makepath(r'C:\ProgramData\Microsoft\Windows\Start Menu\Programs', wrongshortcutname)):
            remove_tree(makepath(r'C:\ProgramData\Microsoft\Windows\Start Menu\Programs', wrongshortcutname))

    # Creation du raccourci dans le bon dossier
    if not matiere == '':
        if default_target != '':
            target = default_target

        else:
            softs = get_softs()
            if len(softs) > 0:
                if (softs[0]['install_location'] == ''):
                    raise Exception('install_location', 'Impossible de trouver le dossier d\'installation, veuillez remplir la variable default_target')
                target = makepath(softs[0]['install_location'], tasks_to_kill[0])

            if not isfile(target):
                raise Exception('target', 'Impossible de trouver l\'executable pour creer le raccourci')

        create_programs_menu_shortcut(shortcutname, target=target, folder=matiere)

def session_setup():

    copytree2('C:\Program Files (x86)\LibreOffice',makepath(user_appdata(),'LibreOffice'),onreplace=default_overwrite)

Re: Problem copying a file

Published: May 26, 2021 - 2:43 PM
by Louis
If someone could give me an answer, that would be amazing, thank you!

Re: Problem copying a file

Published: June 1, 2021 - 10:03 PM
by dcardon
Based on the line `copytree2('LibreOffice','C:\Program Files (x86)')`, it doesn't seem to me that the LibreOffice folder is being copied to the root directory. Is it actually located there or not?