Command at PC startup

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
Gaelds
Messages: 254
Registration: Nov 22, 2015 - 08:37

May 17, 2016 - 5:10 PM

I'd like to add a command to some PCs to run at session startup to launch the "Papercut" client. Here's the command:

`cmd /c "start \\srv-papercut\PCClient\win\pc-client-local-cache.exe --silent --minimized"`.

Is it possible to create a shortcut in the Start menu using this command as the target? If not, is there another solution using WAPT?

PS: The PCs are not on a domain, so I can't create a Group Policy Object (GPO) for this.
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

May 17, 2016 - 10:57 PM

I also have PaperCut at home.

One solution would be to create a package with a session-setup component and intentionally set it to an error to force it to restart on the next boot.

Alternatively, you could copy a script using Wapt to:

%ALLUSERSPROFILE%\Start Menu\Programs. For XP:

%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup. For Vista/7/10: %ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup.

And there are surely other solutions.
Gaelds
Messages: 254
Registration: Nov 22, 2015 - 08:37

May 19, 2016 - 08:32

So I started a script that adds the command to the registry, however the registry_deletekey command doesn't work, is it incorrectly written in the code below?
Also, the import of "IErange.reg" fails, even though it works when run manually on the PC. The reg script adds the server 172.18.80.1 to the IE Intranet zone to prevent a message from appearing when launching the Papercut client.

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 --silent --minimized")
    run(r'regedit.exe /s "IErange.reg" ')

def uninstall():
    print('Suppression raccourci Papercut au demarrage')
    registry_deletekey(HKEY_LOCAL_MACHINE,"software\\Microsoft\\Windows\\CurrentVersion\\Run\\","UIT")

IErange.reg:

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges]
@=""

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range12]
"*"=dword:00000001
":Range"="172.18.80.1"
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

May 19, 2016 - 9:03 PM

What is the value type for `registry_set`?
By default, here's how `registry_set` behaves if no type is added:
https://github.com/tranquilit/WAPT/blob ... s.py#L1559

Example by adding `type` and replacing `\\` with `/`:

`registry_set(HKEY_LOCAL_MACHINE, r'SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/System','MaxGPOScriptWait',0,type=REG_DWORD)`

For your registry entry, you want to add a key to `HKEY_CURRENT_USER`, and it's different for the system account:
https://social.msdn.microsoft.com/Forum ... =vcgeneral

So, should this be placed in a session setup file?
Gaelds
Messages: 254
Registration: Nov 22, 2015 - 08:37

May 20, 2016 - 07:01

Thanks, Simon. Regarding `register_deletekey`, I just realized that `registry_delete` is the correct `registry`:
`registry_delete(HKEY_LOCAL_MACHINE,"software\\Microsoft\\Windows\\CurrentVersion\\Run\\","UIT")`.

As for the part to import into HKCU, I hadn't considered that it couldn't be processed as System... Is there any documentation somewhere for `session_setup`? I've never used it. Alternatively, I was thinking of an AutoIt script that would import my value and schedule the AutoIt executable to launch at each startup in the Run dialog?
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

May 20, 2016 - 08:35

Example for session_setup:

Code: Select all

def session_setup():
   registry_setstring(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows Live\\Common",'TOUVersion','16.0.0.0', type=REG_SZ)
Basically, it starts when the session begins
Jacki
Messages: 8
Registration: May 17, 2016 - 10:05

May 24, 2016 - 11:40

Good morning,

This information is interesting to me; I'd like to set a registry value at each login or in case it's modified
I tested this command

Code: Select all

def session_setup():
	registry_setstring(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",'CertificateRevocation','00000000', type=REG_DWORD)
	registry_setstring(HKEY_CURRENT_USER, "Software\\Microsoft\Windows\\CurrentVersion\\WinTrust\\Trust Providers\\Software Publishing",'State','146944', type=REG_DWORD)
But the value does not change
Locked