Page 1 of 1

Problem executing .VBS script

Published: February 28, 2022 - 2:56 PM
by raigan
Good morning,

I'm about to go bald because I can't understand why my script doesn't work in production, even though it works perfectly when I test it directly through PyScripter. Can you shed some light on this?

Here is the Setup.py file.

Code: Select all

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


def install():
    print ('Installation de l imprimante')
    with disable_file_system_redirection():
        run('WScript.exe "Install_imp.vbs"')
    print ('Installation terminee')

def uninstall():
    print ('Suppression de l imprimante')
    with disable_file_system_redirection():
        run('WScript.exe "remove_imp.vbs"')   
    print ('Suppression terminee')
Thank you very much for your help.

Precision:
- Wapt version 1.8.2 Community edition
- Dedian Linux Server
- OS administration machine: Windows 11

Re: Problem executing .VBS script

Published: March 3, 2022 - 4:32 PM
by dcardon
Hello Raignan,

when the `install()` script is run through PyScripter, it executes in the user account (which is running PyScripter)
. When a package is deployed, it's done in the LOCAL System account.

In the case of your script, I imagine it connects a printer in the user context. Therefore, when the package is deployed by the service, it will be deployed in the LOCAL System account (and not the current user).

To execute a script in the user's session, you need to use a `session_setup()` function.

Regards,

Denis