Page 1 of 1

[SOLVED] Error creating a desktop shortcut for a user

Published: March 18, 2024 - 1:43 PM
by Guillaume_I
Good morning,

I want to create a shortcut for the Wapt console:
I'm following the documentation: 2.1.3.5. Create a desktop shortcut for a logged-in user
(I've noted that I need to use the setup_session function, but I don't understand how to use it... I'm starting from -1 in Python)

Code: Select all

from setuphelpers import *

def install():
    create_user_desktop_shortcut(r'WAPT Console Management', target='C://Program Files (x86)//wapt//waptconsole.exe')
It works perfectly with Pyscripter (I tried with different paths: c:\pro.., c:/pro...)

But via the wapt console, I get the following error:

Code: Select all

Traceback (most recent call last):
  File "C:\Program Files (x86)\wapt\common.py", line 4234, in install_wapt
    exitstatus = setup.install()
  File "C:\WINDOWS\TEMP\wapt8x3n6idv\setup.py", line 5, in install
  File "C:\Program Files (x86)\wapt\setuphelpers_windows.py", line 3993, in create_user_desktop_shortcut
    sc_path = os.path.join(desktop(0), label)
  File "C:\Program Files (x86)\wapt\lib\site-packages\winshell.py", line 159, in desktop
    return get_path ((shellcon.CSIDL_DESKTOP, shellcon.CSIDL_COMMON_DESKTOPDIRECTORY)[common])
  File "C:\Program Files (x86)\wapt\lib\site-packages\winshell.py", line 140, in get_path
    return shell.SHGetFolderPath (0, folder_id, None, 0)
pywintypes.com_error: (-2147024894, 'Le fichier spécifié est introuvable.', None, None)

0x80070002 : Le fichier spécifié est introuvable
If anyone has any leads, thank you in advance.

Installed WAPT version (2.5.4.15342)
- Server OS (Debian 12)
- Operating system of the administration/package creation machine (Windows 10 - 22H2)

Re: Error creating a desktop shortcut for a user

Published: March 18, 2024 - 1:56 PM
by sfonteneau
Good morning

You should not use `create_user_desktop_shortcut` in the `install` function, but rather `create_desktop_shortcut`

Code: Select all

create_user_desktop_shortcut 
Utilisable en session_setup() (bureau de l’utilisateur)


create_desktop_shortcut 
Utilisable dans fonction install()   (all users)

Re: Error creating a desktop shortcut for a user

Published: March 18, 2024 - 2:09 PM
by Guillaume_I
Good morning,

Yes, it works, thank you for the reply.

However, if I want to use create_user_desktop_shortcut, it seems I'm making a mistake again:

Code: Select all

from setuphelpers import *

def session_setup():
    create_user_desktop_shortcut(r'WAPT Console Management', target='C://Program Files (x86)//wapt//waptconsole.exe')
The error in the console is:

Code: Select all

Traceback (most recent call last):
  File "C:\Program Files (x86)\wapt\common.py", line 4234, in install_wapt
    exitstatus = setup.install()
AttributeError: module '__waptsetup_ng97cnyb6o__' has no attribute 'install'

AttributeError: module '__waptsetup_ng97cnyb6o__' has no attribute 'install'
Can you tell me what's wrong?

Installed WAPT version (2.5.4.15342)
- Server OS (Debian 12)
- Operating system of the administration/package creation machine (Windows 10 - 22H2)

Re: Error creating a desktop shortcut for a user

Published: March 18, 2024 - 4:45 PM
by dcardon
Hello Guillaume,

There must be a `def install()` function in `setup.py`. You can add a simple `pass` to the `setup.py` file if there is only a `session_setup()` function

Code: Select all

from setuphelpers import *

def install():
    pass
    
def session_setup():
    create_user_desktop_shortcut(r'WAPT Console Management', target='C://Program Files (x86)//wapt//waptconsole.exe')
Sincerely,

Denis

[SOLVED] Error creating a desktop shortcut for a user

Published: March 25, 2024 - 2:08 PM
by Guillaume_I
Hello Denis,

thank you for your feedback.

I had initial training at the end of last week, and these points are clearer to me now.

Sincerely,

Guillaume Leduc.

Re: [SOLVED] Error creating a desktop shortcut for a user

Published: March 29, 2024 - 10:42
by dcardon
Thanks for the feedback, Guillaume. :-)
Have a good weekend and a happy Easter,
Denis.