[SOLVED] Copy desktop shortcuts for logged-in users

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
vgrafte
Messages: 1
Registration: June 29, 2023 - 10:03

January 15, 2025 - 3:23 PM

Good morning,

I created a package to paste links onto the desktop; here is the script:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

import os
import glob

def session_setup():
  username=os.getlogin()
def install():
  chemin = (r'C:\Users\{}\Desktop'.format(username))
    filecopyto(lnk, chemin)
I can't understand why it's not working.
The console displays this error message:

Code: Select all

Traceback (most recent call last):
  File "C:\Program Files (x86)\wapt\common.py", line 4235, in install_wapt
    exitstatus = setup.install()
  File "C:\WINDOWS\TEMP\wapt257aezdq\setup.py", line 13, in install
  File "shutil.py", line 435, in copy2
  File "shutil.py", line 264, in copyfile
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Système\\Desktop'

2 : No such file or directory
I can see that the username returns System and not the logged-in user, but the command in Python does return the correct user.

Thank you for your help.
fschelfaut
Messages: 30
Registration: Nov 7, 2024 - 12:22

January 15, 2025 - 4:30 PM

Good morning,

If you want to execute code within the user's session, for example, adding a shortcut to the user's desktop
So you need to execute all your code within the function session-setup

Note that the code executed in the function install is as a system user

To achieve what you want, you have two options:

Code: Select all

def session_setup():
    # Create a desktop shortcut link for current user
    create_user_desktop_shortcut(label='', target='', arguments='')
    
def install():
    # Create a desktop shortcut link for all users
    create_desktop_shortcut(label='', target='', arguments='')
Flavien,
Locked