OCX Registration

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
Idaho
Messages: 1
Registration: March 8, 2018 - 9:15 AM

March 8, 2018 - 09:47

Hello everyone,

I installed WAPT in my company environment to install software remotely, I'm quite satisfied. My goal is to create packages for all the software we use; however, there are many and some are very poorly packaged. I'm currently preparing a package for SRIM 2013 ( http://www.srim.org/SRIM/SRIMLEGL.htm The software doesn't have an installer, but it still requires registering OCX files, installing DLLs, and a font to function correctly. I've found solutions for the font and DLLs, but registering the OCX files—I don't know why—doesn't work with the command `Regsvr32 /s`. So I'm posting here to see if anyone else has encountered the same problem registering OCX files and if they have a solution. My software launches, but some functions refuse to run because the OCX files aren't present



- Installed WAPT version 1.3.13
- Server OS: Linux Debian 9
- Operating system of the administration/package creation machine: Windows 7

I'm testing the following code which isn't working. I've correctly placed the OCX files in the root directory of the package, and I also previously tested the Regsvr32 command on its own without success. :/

Code: Select all

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

uninstallkey = []

targetdir = makepath(programfiles64,'SRIM 2013')
exename = 'SRIM.exe'

def install():
    print('installing pgip-srim2013')
    run(r'install.cmd')
    run(r'IF EXIST C:\Windows\SysWOW64 (C:\Windows\SysWOW64\regsvr32.exe /S COMCTL32.OCX) ELSE (C:\Windows\System32\regsvr32.exe  /S COMCTL32.OCX)')
    run(r'IF EXIST C:\Windows\SysWOW64 (C:\Windows\SysWOW64\regsvr32.exe /S COMDLG32.OCX) ELSE (C:\Windows\System32\regsvr32.exe /S COMDLG32.OCX)')
    run(r'IF EXIST C:\Windows\SysWOW64 (C:\Windows\SysWOW64\regsvr32.exe /S MSFLXGRD.OCX) ELSE (C:\Windows\System32\regsvr32.exe /S MSFLXGRD.OCX)')
    run(r'IF EXIST C:\Windows\SysWOW64 (C:\Windows\SysWOW64\regsvr32.exe /S TABCTL32.OCX) ELSE (C:\Windows\System32\regsvr32.exe /S TABCTL32.OCX)')
    run (r'IF EXIST C:\Windows\SysWOW64 (C:\Windows\SysWOW64\regsvr32.exe /S  RICHTX32.OCX) ELSE (C:\Windows\System32\regsvr32.exe /S RICHTX32.OCX)')
    register_windows_uninstall(control)

def uninstall():
    print('uninstalling pgip-srim2013')
    killalltasks(exename)
    killalltasks('SR.exe')
    if isdir(targetdir):
        remove_tree(targetdir)
    remove_file(r'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\SRIM 2013.lnk')
    unregister_uninstall('pgip-srim2013')
The code for the installation script (if I'm creating a shortcut myself and not using the function provided by WAPT, it's because I was getting an error when launching the software that I don't encounter when doing it this way; I don't really understand why, actually):

Code: Select all

@ECHO OFF
ECHO INSTALLING SRIM 2013
xcopy SRIM_2013 "C:\Program Files\SRIM 2013" /S /I
CLS
xcopy "SRIM 2013.lnk" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs" /S /I
CLS
ECHO ADDING FONTS
addfonts.cmd
CLS
ECHO DONE
The code for the font addition script that I found online basically scans the directory and silently adds the font files it contains (it's a shame the same thing doesn't exist for those darn OCX files). I'm posting it here mainly because it might help some people who want to create packages to install fonts:

Code: Select all

REM http://www.msfn.org/board/topic/119612-how-to-install-a-font-via-the-command-line/

@ECHO OFF
TITLE Adding Fonts..
REM Filename: ADD_Fonts.cmd
REM Script to ADD TrueType and OpenType Fonts for Windows
REM By Islam Adel
REM 2012-01-16

REM How to use:
REM Place the batch file inside the folder of the font files OR:
REM Optional Add source folder as parameter with ending backslash and dont use quotes, spaces are allowed
REM example "ADD_fonts.cmd" C:\Folder 1\Folder 2\

IF NOT "%*"=="" SET SRC=%*
ECHO.
ECHO Adding Fonts..
ECHO.
FOR /F %%i in ('dir /b "%SRC%*.*tf"') DO CALL :FONT %%i
REM OPTIONAL REBOOT
REM shutdown -r -f -t 10 -c "Reboot required for Fonts installation"
ECHO.
ECHO Done!
EXIT

:FONT
ECHO.
REM ECHO FILE=%~f1
SET FFILE=%~n1%~x1
SET FNAME=%~n1
SET FNAME=%FNAME:-= %
IF "%~x1"==".otf" SET FTYPE=(OpenType)
IF "%~x1"==".ttf" SET FTYPE=(TrueType)

ECHO FILE=%FFILE%
ECHO NAME=%FNAME%
ECHO TYPE=%FTYPE%

COPY /Y "%SRC%%~n1%~x1" "%SystemRoot%\Fonts\"
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "%FNAME% %FTYPE%" /t REG_SZ /d "%FFILE%" /f
GOTO :EOF
Finally, here is the content of the package directory:

Code: Select all

 Répertoire de C:\waptdev\pgip-srim2013-wapt

08/03/2018  10:24    <REP>          .
08/03/2018  10:24    <REP>          ..
06/03/2018  15:53             1ÿ133 addfonts.cmd
23/05/2000  00:58           608ÿ448 ComCtl32.ocx
23/05/2000  00:58           140ÿ488 ComDlg32.ocx
08/03/2018  09:55               255 install.cmd
20/03/1996  06:00            80ÿ008 Linedraw.ttf
22/05/2000  22:58           244ÿ416 MSFlxGrd.ocx
09/03/2004  23:45           212ÿ240 RichTx32.ocx
07/03/2018  10:56             1ÿ322 setup.py
07/03/2018  10:57             1ÿ767 setup.pyc
06/03/2018  16:58             1ÿ331 SRIM 2013.lnk
06/03/2018  14:28    <REP>          SRIM_2013
30/08/2001  22:43           209ÿ192 TabCtl32.ocx
07/03/2018  08:48    <REP>          WAPT
              11 fichier(s)        1ÿ500ÿ600 octets
               4 R‚p(s)   1ÿ215ÿ844ÿ352 octets libres
Thank you in advance for your answers :)
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

March 9, 2018 - 4:47 PM

The problem is most likely related to the automatic rewriting of system paths by Windows in the case of a 32-bit app on a 64-bit Windows system.

WAPT is 32-bit, so by default Windows presents a 32-bit "view" of the system.
To disable the redirection, you need to use the context helper

Code: Select all

disable_file_system_redirection

Code: Select all

def install():
    with disable_file_system_redirection():
        run(r'...')
To register OCX files, the setuphelpers register_dll() function must work

Code: Select all

import winshell

def install():
    filecopyto('MY.OCX',makepath(winshell.get_folder_by_name('SYSTEMX86'),'MY.OCX'))
    register_dll(makepath(winshell.get_folder_by_name('SYSTEMX86'),'MY.OCX'))
        
Tranquil IT
Locked