Page 1 of 1

[SOLVED] Deleting a directory in a user profile

Published: May 31, 2024 - 11:41
by Mikael_S
WAPT 2.5.4.15342 Enterprise under Ubuntu
Windows 11

Hello,

I'm trying to create a package that would delete a directory located here:

C:\Users\XXX\AppData\Local\Programs

I tried using "def session_setup():" and parameters to retrieve the user:
user_appdata()
user_local_appdata()
get_current_user()

But I consistently end up using the "system" account.

I don't think it's complicated, but I'm not very familiar with scripting under WAPT; I've thoroughly reviewed the documentation, but perhaps I'm doing it incorrectly.

Re: Deleting a directory from a user profile

Published: May 31, 2024 - 11:48
by sfonteneau
Hello

, could you post your setup.py file?


Without the code, it's difficult to know what's wrong.

Re: Deleting a directory from a user profile

Published: May 31, 2024 - 2:10 PM
by Mikael_S
To simplify my test and see how it works, I visualize the values ​​returned by the different commands I saw in the documentation, then I create a directory and see what happens

Code: Select all

def install():
        print(user_appdata())
        print(get_current_user())
        print(user_local_appdata())
        mkdirs(makepath(user_local_appdata,'TEST'))
        mkdirs(makepath(user_local_appdata,'TEST1'))
        mkdirs(makepath(user_appdata,'TEST2'))
pass
The result of the printouts:
C:\windows\system32\config\systemprofile\AppData\Roaming
System
C:\windows\system32\config\systemprofile\AppData\Local


And it does create the test folders, but not in the user's appdata folder

Re: Deleting a directory from a user profile

Published: May 31, 2024 - 2:54 PM
by sfonteneau
`user_appdata()` is not available in `def install()`;

it will work in `session_setup`.

You must run the installer, then `session_setup` when you test (note that if you have already run `session_setup`, you will need to increment the version number in the `control` file with each test).