[SOLVED] DELL bios setup package

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
seb b
Messages: 23
Registration: Oct 26, 2017 - 3:12 p.m.

December 17, 2019 - 3:35 PM

Hello everyone,

I am trying to create a configuration package for DELL UEFI BIOS using their cctk tool.
Some computers have a BIOS password, others do not. We also don't want BIOS passwords to be transmitted in plain text, so I generated executables using CCT, one that removes the password and one that resets it.

I would like to follow these steps in my WAPT package:
  • Check if the password is set
  • If so, run the executable that deletes it
  • make the scripted changes
  • launch the executable that resets the password
The only way I've found to check if the password is set is to cause an error in cctk with a bad password; it then gives me a return code that tells me whether a password is set or not.
My problem is that I can't capture this return code.

When I place my order:

Code: Select all

run (r'"C:\Program Files (x86)\Dell\Command Configure\X86_64\cctk.exe" --numlock=enabled --valsetuppwd=impossiblepasswd'")
I have a CalledProcessErrorOutput (normal) which displays this return code

Code: Select all

Traceback (most recent call last):
  File "C:\Program Files (x86)\wapt\common.py", line 3851, in install_wapt
    exitstatus = setup.install()
  File "C:\waptdev\iut-dell-bios-configuration-wapt\setup.py", line 39, in install
    run (r'"C:\Program Files (x86)\Dell\Command Configure\X86_64\cctk.exe" --numlock=enabled --valsetuppwd=impossiblepasswd', return_stderr=errlist, accept_returncodes=[0,3])
  File "C:\Program Files (x86)\wapt\common.py", line 3630, in run
    return ensure_unicode(setuphelpers.run(*arg,pidlist=self.pidlist,**args))
  File "C:\Program Files (x86)\wapt\setuphelpers.py", line 1066, in run
    raise CalledProcessErrorOutput(proc.returncode,cmd,''.join(output+return_stderr))
CalledProcessErrorOutput: Command '"C:\\Program Files (x86)\\Dell\\Command Configure\\X86_64\\cctk.exe" --numlock=enabled --valsetuppwd=impossiblepasswd' returned non-zero exit status 58.
Output:
The setup password provided is incorrect. Please try again.
I would like to be able to retrieve this exit code (58 and 106 in my specific case) in order to be able to verify my first condition.

I tried a try/except on the command to capture the return code, it works great in pyscripter but impossible to launch a package on the clients.

Code: Select all

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

uninstallkey = []


def ispwddefined():

    try:
        print (subprocess.check_output(["C:\Program Files (x86)\Dell\Command Configure\X86_64\cctk.exe", "--numlock=enabled", "--valsetuppwd=impossiblepasswd "]).decode())
    except subprocess.CalledProcessError, e:
        cctkerrorcode = e.returncode
        print cctkerrorcode

    if (cctkerrorcode == 58):
        print "password configured"
        return True;
    elif(cctkerrorcode == 106):
        print ("no password configured")
        return False


def install():

    print ispwddefined()
    
In the PyScripter environment, launching the execution configuration "install" correctly displays the True or False value as well as the relevant return code.

Code: Select all

Ligne de Commande : install "C:\waptdev\iut-dell-bios-configuration-wapt\WAPT\.."
Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
Installing WAPT files C:\waptdev\iut-dell-bios-configuration-wapt
58
password configured
True
Once the package is in the repository and deployed to a test machine, I get this error:

Code: Select all

UnboundLocalError: local variable 'cctkerrorcode' referenced before assignment
I tried defining the cctkerrorcode variable at the beginning of the ispwddefined() function, and here's something even more curious: the package is successful, and the result is:

Code: Select all

NumLock=Enabled

None
I have the impression that in this case, he doesn't see the cctk error...

I must admit that I'm starting to fall short of what I know how to do...

Does anyone know how to capture return codes in a more basic way?

Thank you in advance for your help.

Seb.
seb b
Messages: 23
Registration: Oct 26, 2017 - 3:12 p.m.

December 17, 2019 - 3:46 PM

Hello again,

I'm adding fuel to the fire, and I apologize in advance...

I just tested it by running the command that should throw an error, specifying that it should accept return code 58 (a password is defined, you didn't provide the correct one), and there was no error. The return code I'm trying to retrieve is indeed returned to the 'run' command. Is it possible to retrieve this code (easily) into a variable?

Code: Select all

run (r'"C:\Program Files (x86)\Dell\Command Configure\X86_64\cctk.exe" --numlock=enabled --valsetuppwd=impossiblepasswd', accept_returncodes=[0,58])
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

December 17, 2019 - 3:54 PM

The `run` command returns a slightly enriched string...
a returncode attribute gives the return code.

Code: Select all

result = run (r'"C:\Program Files (x86)\Dell\Command Configure\X86_64\cctk.exe" --numlock=enabled --valsetuppwd=impossiblepasswd'")
if result.returncode == 58:
    print('Probleme mot de passe')
seb b
Messages: 23
Registration: Oct 26, 2017 - 3:12 p.m.

December 17, 2019 - 4:12 PM

THANKS!

Unfortunately, it seems that the result of `run` is not an object but Unicode (I'm not sure of my terminology, I admit) :oops: ).

Code: Select all

AttributeError: 'unicode' object has no attribute 'returncode'
I tried directly printing the run command with exactly the same result.

Code: Select all

print (run (r'"C:\Program Files (x86)\Dell\Command Configure\X86_64\cctk.exe" --numlock=enabled --valsetuppwd=impossiblepasswd', accept_returncodes=[0,58]).returncode)
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

December 17, 2019 - 7:04 PM

With wapt 1.7.4, it's Unicode enriched with the attribute...
Which version do you have?
Tranquil IT
seb b
Messages: 23
Registration: Oct 26, 2017 - 3:12 p.m.

December 18, 2019 - 8:10 AM

Hello,

we are on version 1.7.4.6229.
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

December 18, 2019 - 09:32

I see the problem...
The `run` command in the Wapt class (the one available in the package's `install` function) is patched to return Unicode (for obscure backward compatibility reasons)
But the setuphelpers.run command returns either unicode or bytes (raw string output from the launched command) with the returncode attribute depending on whether the launched command is in unicode or bytes.

https://github.com/tranquilit/WAPT/blob ... rs.py#L949

https://github.com/tranquilit/WAPT/blob ... s.py#L1075

In your case, you should therefore use the direct run function of setuphelpers:

Code: Select all

import setuphelpers

def install():
    result = setuphelpers.run (r'"C:\Program Files (x86)\Dell\Command Configure\X86_64\cctk.exe" --numlock=enabled --valsetuppwd=impossiblepasswd'")
    if result.returncode == 58:
        print('Probleme mot de passe')
Tranquil IT
seb b
Messages: 23
Registration: Oct 26, 2017 - 3:12 p.m.

December 18, 2019 - 10:07 AM

Great!

It works, thank you so much.
Now I just have to do the rest of the package.

Thanks again!
Gaelds
Messages: 254
Registration: Nov 22, 2015 - 08:37

November 29, 2023 - 4:21 PM

Good morning,
I'm trying to do the same thing as "Seb b" but I can't retrieve the return code with `result.returncode`. I think the installation crashes on the first run with the errors below. When the provided password matches the BIOS password, the script displays "Return code = 0.".
Dell BIOS setup with pass
Error installing ['dst-Bios_DELL_Update-wapt']: errors in packages [[PackageRequest(package='dst-Bios_DELL_Update-wapt',architectures=['x64'],locales=['fr'],maturities=['PROD', 'DEV'],tags=['windows-10', 'win-10', 'w-10', 'windows10', 'win10', 'w10', 'windows', 'win', 'w'], min_os_version=Version('10.0.22621'), max_os_version=Version('10.0.22621')), PackageEntry('dst-Bios_DELL_Update-wapt','1.0.0-62' maturity='DEV'), 'Traceback (most recent call last):\n File "C:\\Program Files (x86)\\wapt\\common.py", line 5192, in install\n result = self.install_wapt(p.localpath,\n File "C:\\Program Files (x86)\\wapt\\common.py", line 4176, in install_wapt\n raise e\n File "C:\\Program Files (x86)\\wapt\\common.py", line 4083, in install_wapt\n exitstatus = setup.install()\n File "C:\\Windows\\TEMP\\waptpzh4plq3\\setup.py", line 16, in install\n File "C:\\Program Files (x86)\\wapt\\common.py", line 3860, in run\n return ensure_unicode(run(*arg, pidlist=self.pidlist,**args))\n File "C:\\Program Files (x86)\\wapt\\waptutils.py", line 2118, in run\n raise CalledProcessErrorOutput(proc.returncode, cmd, \'\'.join(output))\nwaptutils.CalledProcessErrorOutput: Command \'"C:\\\\Program Files (x86)\\\\Dell\\\\Command Configure\\\\X86_64\\\\cctk.exe" -i cctk.ini --valsetuppwd=password -lc:\\\\dell_cctk.log\' returned non-zero exit status 58.\nOutput:CCTKAppEngVer=4.10.1.11\r\n\r\nThe setup password provided is incorrect. Please try again.\r\n\n']]
Traceback (most recent call last):
File "C:\Program Files (x86)\wapt\waptservice\service.py", line 1910, in run
self.running_task.run()
File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 716, in run
self._run()
File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 1288, in _run
raise Exception(_('Error during install of {}: errors in packages {}').format(
Exception: Error during installation of ['dst-Bios_DELL_Update-wapt']: errors in packages [[PackageRequest(package='dst-Bios_DELL_Update-wapt',architectures=['x64'],locales=['fr'],maturities=['PROD', 'DEV'],tags=['windows-10', 'win-10', 'w-10', 'windows10', 'win10', 'w10', 'windows', 'win', 'w'],min_os_version=Version('10.0.22621'),max_os_version=Version('10.0.22621')), PackageEntry('dst-Bios_DELL_Update-wapt','1.0.0-62' maturity='DEV'), 'Traceback (most recent call last):\n File "C:\\Program Files (x86)\wapt\common.py", line 5192, in install\n result = self.install_wapt(p.localpath,\n File "C:\\Program Files (x86)\\wapt\\common.py", line 4176, in install_wapt\n raise e\n File "C:\\Program Files (x86)\\wapt\\common.py", line 4083, in install_wapt\n exitstatus = setup.install()\n File "C:\\Windows\\TEMP\\waptpzh4plq3\\setup.py", line 16, in install\n File "C:\\Program Files (x86)\\wapt\\common.py", line 3860, in run\n return ensure_unicode(run(*arg, pidlist=self.pidlist,**args))\n File "C:\\Program Files (x86)\\wapt\\waptutils.py", line 2118, in run\n raise CalledProcessErrorOutput(proc.returncode, cmd, \'\'.join(output))\nwaptutils.CalledProcessErrorOutput: Command \'"C:\\\\Program Files (x86)\\\\Dell\\\\Command Configure\\\\X86_64\\\\cctk.exe" -i cctk.ini --valsetuppwd=password -lc:\\\\dell_cctk.log\' returned non-zero exit status 58.\nOutput:CCTKAppEngVer=4.10.1.11\r\n\r\nThe setup password provided is incorrect. Please try again.\r\n\n']]

Exception: Error installing ['dst-Bios_DELL_Update-wapt']: errors in packages [[PackageRequest(package='dst-Bios_DELL_Update-wapt',architectures=['x64'],locales=['fr'],maturities=['PROD', 'DEV'],tags=['windows-10', 'win-10', 'w-10', 'windows10', 'win10', 'w10', 'windows', 'win', 'w'], min_os_version=Version('10.0.22621'), max_os_version=Version('10.0.22621')), PackageEntry('dst-Bios_DELL_Update-wapt','1.0.0-62' maturity='DEV'), 'Traceback (most recent call last):\n File "C:\\Program Files (x86)\\wapt\\common.py", line 5192, in install\n result = self.install_wapt(p.localpath,\n File "C:\\Program Files (x86)\wapt\common.py", line 4176, in install_wapt\n raise e\n File "C:\\Program Files (x86)\\wapt\\common.py", line 4083, in install_wapt\n exitstatus = setup.install()\n File "C:\\Windows\\TEMP\\waptpzh4plq3\\setup.py", line 16, in install\n File "C:\\Program Files (x86)\\wapt\\common.py", line 3860, in run\n return ensure_unicode(run(*arg, pidlist=self.pidlist,**args))\n File "C:\\Program Files (x86)\\wapt\\waptutils.py", line 2118, in run\n raise CalledProcessErrorOutput(proc.returncode, cmd, \'\'.join(output))\nwaptutils.CalledProcessErrorOutput: Command \'"C:\\\\Program Files (x86)\\\\Dell\\\\Command Configure\\\\X86_64\\\\cctk.exe" -i cctk.ini --valsetuppwd=password -lc:\\\\dell_cctk.log\' returned non-zero exit status 58.\nOutput:CCTKAppEngVer=4.10.1.11\r\n\r\nThe setup password provided is incorrect. Please try again.\r\n\n']]
Traceback (most recent call last):
File "C:\Program Files (x86)\wapt\waptservice\service.py", line 1910, in run
self.running_task.run()
File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 716, in run
self._run()
File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 1288, in _run
raise Exception(_('Error during install of {}: errors in packages {}').format(
Exception: Error during installation of ['dst-Bios_DELL_Update-wapt']: errors in packages [[PackageRequest(package='dst-Bios_DELL_Update-wapt',architectures=['x64'],locales=['fr'],maturities=['PROD', 'DEV'],tags=['windows-10', 'win-10', 'w-10', 'windows10', 'win10', 'w10', 'windows', 'win', 'w'],min_os_version=Version('10.0.22621'),max_os_version=Version('10.0.22621')), PackageEntry('dst-Bios_DELL_Update-wapt','1.0.0-62' maturity='DEV'), 'Traceback (most recent call last):\n File "C:\\Program Files (x86)\\wapt\\common.py", line 5192, in install\n result = self.install_wapt(p.localpath,\n File "C:\\Program Files (x86)\\wapt\\common.py", line 4176, in install_wapt\n raise e\n File "C:\\Program Files (x86)\\wapt\\common.py", line 4083, in install_wapt\n exitstatus = setup.install()\n File "C:\\Windows\\TEMP\\waptpzh4plq3\\setup.py", line 16, in install\n File "C:\\Program Files (x86)\\wapt\\common.py", line 3860, in run\n return ensure_unicode(run(*arg, pidlist=self.pidlist,**args))\n File "C:\\Program Files (x86)\\wapt\\waptutils.py", line 2118, in run\n raise CalledProcessErrorOutput(proc.returncode, cmd, \'\'.join(output))\nwaptutils.CalledProcessErrorOutput: Command \'"C:\\\\Program Files (x86)\\\\Dell\\\\Command Configure\\\\X86_64\\\\cctk.exe" -i cctk.ini --valsetuppwd=password -lc:\\\\dell_cctk.log\' returned non-zero exit status 58.\nOutput:CCTKAppEngVer=4.10.1.11\r\n\r\nThe setup password provided is incorrect. Please try again.

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey = []
cctk_binaries = makepath(programfiles32,'Dell','Command Configure','X86_64','cctk.exe')

def install():
    import wmi
    c = wmi.WMI()
    for computersystem in c.Win32_ComputerSystem():
        if(computersystem.Manufacturer == "Dell Inc."):
            if(isfile(cctk_binaries)):
                print(r'Configuration BIOS Dell avec pass')
                result = run (r'"%s" -i cctk.ini --valsetuppwd=password -l c:\dell_cctk.log' %cctk_binaries)
                print(f"Code retour = {result.returncode}.")
                if result.returncode == 58:
                    print(r"Le mot de passe BIOS n'est pas le pass habituel !")
                if result.returncode == 106:
                    print(r"Le mot de passe BIOS est vide, tentative d'ajout du mot de passe")
                    run (r'"%s" -i cctk.ini --setuppwd=password  ' %cctk_binaries)
                    print(r'Configuration BIOS Dell avec pass')
                    run (r'"%s" -i cctk.ini --valsetuppwd=password  -l c:\dell_cctk.log' %cctk_binaries)
                else:
                    print(r"Resultat de la config CCTK ok")
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

November 29, 2023 - 10:45 PM

The message in your case is: The setup password provided is incorrect. Please try again with exit code 58

So if you want to catch code 58, I recommend using accept_returncodes:

Code: Select all

result = run (r'"%s" -i cctk.ini --valsetuppwd=password -l c:\dell_cctk.log' %cctk_binaries,accept_returncodes=[0, 3010,58])
if result.returncode = 58:
    print(r"Le mot de passe de configuration fourni est incorrect")
or to switch it to error:

Code: Select all

result = run (r'"%s" -i cctk.ini --valsetuppwd=password -l c:\dell_cctk.log' %cctk_binaries,accept_returncodes=[0, 3010,58])
if result.returncode = 58:
    error(r"Le mot de passe de configuration fourni est incorrect")
Locked