Page 1 of 1

Command at PC startup

Published: May 17, 2016 - 5:10 PM
by gaelds
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.

Re: PC startup command

Published: May 17, 2016 - 10:57 PM
by sfonteneau
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.

Re: PC startup command

Published: May 19, 2016 - 08:32
by gaelds
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"

Re: PC startup command

Published: May 19, 2016 - 9:03 PM
by sfonteneau
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?

Re: PC startup command

Published: May 20, 2016 - 07:01
by gaelds
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?

Re: PC startup command

Published: May 20, 2016 - 08:35
by sfonteneau
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

Re: PC startup command

Published: May 24, 2016 - 11:40 AM
by Jacki
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