Page 1 of 1

[RESOLVED] Shortcut error

Published: September 25, 2020 - 2:52 AM
by btravers
Good morning,

Every time I try to use the remove_desktop_shortcut and remove_user_desktop_shortcut functions, I get errors when running them on clients, but not when I package them in PyScripter.

So I did this:

Code: Select all

  profils = get_local_profiles()
  list_check = ['Prog1.lnk','Prog2.lnk','prog 1.lnk','prog_1.lnk']

                for chemin in profils:
                    for lnk in list_check:
                        chemin_user = makepath(chemin['profile_path'],'Desktop',lnk)
                        if isfile(chemin_user):
                            print(chemin_user)
                            remove_file(chemin_user)

                for lnk in list_check:
                    chemin_public = makepath(systemdrive,'Users','Public','Desktop',lnk)
                    if isfile(chemin_public):
                        print(chemin_public)
                        remove_file(chemin_public)
It's just to share...

Re: Shortcut error

Published: September 28, 2020 - 10:55 AM
by jpele
Hello,

the script will indeed be more effective than the functions in question for "global" cleanup on workstations.

For your information, the `remove_user_desktop_shortcut` function can only be executed within the `session_setup()` function, hence the errors that are being reported.

Regards,
Jimmy

Re: Shortcut error

Published: September 28, 2020 - 11:24 AM
by btravers
Oh yeah, makes sense, I'd forgotten about the sessionsetup.
Thanks!