Page 1 of 1
Remove network printer
Published: May 25, 2016 - 10:13
by gaelds
Hello,
I'm trying to uninstall a shared printer from a package on the server, but the following command returns "access denied" when I test it (even in cmd as administrator): `
run(r'rundll32 printui.dll,PrintUIEntry /dl /n "\\172.18.80.1\Pedagogique EDS"')`.
Do you know of another method?
The installation using the command below works, however:
`run(r'rundll32 printui.dll,PrintUIEntry /in /q /n "\\172.18.80.1\Pedagogique EDS"')`.
Re: Remove network printer
Published: May 25, 2016 - 10:35
by sfonteneau
The printer is linked to the user account, right?
Re: Remove network printer
Published: May 26, 2016 - 1:46 PM
by gaelds
Ah yes, that's possible... Ultimately, the printer installation isn't working either. I tested it by right-clicking on "install" in PyScripter, but when installing the package on one machine, nothing is installed. Do I need to put that in session_setup?
Re: Remove network printer
Published: May 26, 2016 - 2:00 PM
by sfonteneau
When you test with PyScripter, you run the command as the current user.
Therefore, you've installed the printer in that user's session.
When you deploy your package, it's executed under the system account.
So yes, session_setup is indeed the solution.
Re: Remove network printer
Published: May 27, 2016 - 08:51
by gaelds
So the installation works in session_setup, but it is not silent despite the "/q" in the command, which is annoying because the user can cancel (and some will!

)
So deletion isn't possible in this package then?
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey = []
def install():
print('Lancement client Papercut au demarrage')
registry_set(HKEY_LOCAL_MACHINE,"software\\Microsoft\\Windows\\CurrentVersion\\Run\\","UIT","\\\\172.18.80.1\PCClient\win\pc-client-local-cache.exe")
def uninstall():
print('Suppression valeur de registre UIT au demarrage')
registry_delete(HKEY_LOCAL_MACHINE,"software\\Microsoft\\Windows\\CurrentVersion\\Run\\","UIT")
run(r'rundll32 printui.dll,PrintUIEntry /dl /n "\\172.18.80.1\Pedagogique EDS"')
def session_setup():
print('Ajout des zones Intranet dans IE')
run (r'regedit.exe /s \\172.16.80.1\netlogon\scripts\registre\ZoneIntranetIE.reg')
run(r'rundll32 printui.dll,PrintUIEntry /in /q /n "\\172.18.80.1\Pedagogique EDS"')
Re: Remove network printer
Published: May 27, 2016 - 11:10
by sfonteneau
Nothing is executed by wapt when the session closes, so no.
To be honest, I don't use wapt for printers.
I use a VBScript at login and login, or with GPOs
.
Re: Remove network printer
Published: May 31, 2016 - 08:38
by gaelds
Okay, never mind about uninstalling then, since I'm not on a domain I have no other choice than Wapt to send this kind of script.
Re: Remove network printer
Published: May 31, 2016 - 11:45 AM
by sfonteneau
You can, however, install a logout script with Wapt!
It looks tricky though, to comply with Microsoft standards.
You can take an example from add_shutdown_script (computer shutdown script):
https://dev.tranquil.it/sphinxdocs/_mod ... own_script