ThinApp

VMware_ThinApp_v4.0_icon

[ThinApp] Register an app based on the OS language

0

I came across a post on the VMware ThinApp forum of a user looking for a way to register with thinreg an app based on the OS language (french or english) so as I’m working in a similar environment I came up with a little VBS script for this.

First, the package.ini; two entry points, one for the english shortcut, the other one for the french shortcut:

 

[Readme.exe]
Source=%ProgramFilesDir%\App\app.exe
Shortcut=App.dat
WorkingDirectory=%ProgramFilesDir%\App
 
[Lisez-moi.exe]
Source=%ProgramFilesDir%\App\app.exe
Shortcut=App.dat
WorkingDirectory=%ProgramFilesDir%\App

 

Second, the script:

 

 Visual Basic |  copy code |? 
01
02
'=================================================
03
' Initialize vars
04
'=================================================
05
Dim strComputer, strOSLanguage
06
Dim strThinregPath, strAppToRegister, strThinregCmdLine
07
 
08
'=================================================
09
' Set thinreg path and params
10
'=================================================
11
strThinregPath = "\\fileserver\share\thinreg.exe"
12
 
13
'=================================================
14
' Get Computer OS Language
15
' See: http://msdn.microsoft.com/en-us/library/aa394239%28v=vs.85%29.aspx
16
'=================================================
17
strComputer = "."
18
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
19
Set oss = objWMIService.ExecQuery ("Select OSLanguage FROM Win32_OperatingSystem")
20
 
21
For Each os in oss
22
	strOSLanguage = os.OSLanguage
23
Next
24
 
25
If strOSLanguage = 1036 or strOSLanguage = 3084 Then
26
	REM Wscript.Echo "OS Language: French – France / Canada"
27
	strAppToRegister = "\\fileserver\share\Lisez-moi.exe"
28
ElseIf strOSLanguage = 1033 or strOSLanguage = 4105 Then
29
	REM Wscript.Echo "OS Language: English – US / Canada"
30
	strAppToRegister = "\\fileserver\share\Readme.exe"
31
End If 
32
 
33
'=================================================
34
' Register the app
35
'=================================================
36
Set WSHShell = WScript.CreateObject("WScript.Shell")
37
strThinregCmdLine = strThinregPath & " " & strAppToRegister
38
WSHShell.Run "" & strThinregCmdLine & "", 0, True
39

 

And here you go! Happy Scripting!

SCC_Computer_logo

Virtualizing SoftLab/SoftPath with VMware ThinApp 4.7.3/5.0

0

While trying to virtualize the softwares, SoftLab and SoftPath, from SCC Soft Computer with ThinApp 4.7.3, I ran into this issue:

SCC SoftLab Issue

I was able to get to the main window but after opening a module and doing stuff or closing it, the program was stopping to respond. The process module was hanging. By closing it, the program started to respond again.

SCC SoftLab Issue Processes

After working with VMware Support, adding this parameter to the package.ini solved everything in SoftLab/SoftPath:

ExternalDLLs=orb_r.dll

For reference:

ExternalDLLs Parameter

 

 

The ExternalDLLs parameter can force Windows to load specific DLL files from the virtual file system.

 

ThinApp sets an initial value that loads DLL files from the virtual file system and passes the loading process to Windows for DLL files on the physical file system. In some circumstances, Windows must load a DLL file in the virtual file system. You might have a DLL file that inserts itself into other processes using Windows hooks. The DLL file that implements the hook must be available on the host file system and Windows must load that file. When you specify a DLL file in the ExternalDLLs parameter, ThinApp extracts the file from the virtual file system to the sandbox and instructs Windows to load it. Virtual dictation software is a type of software that might interface with native applications that pass information between DLLs. ThinApp can pass the loading of DLLs in the virtual environment to Windows to ensure that local applications can interface with the DLLs.

 

 

The ExternalDLLs parameter does not support a DLL file that depends on other DLL files in the virtual file system. In this case, Windows cannot load the DLL file.

Note that at the moment I’m writing this post, the virtualization of this software is not supported by the editor, SCC Soft Computer.

VMware_ThinApp_v4.0_icon

Installing a driver with VMware ThinApp

0

A few days ago, I ran into a troublesome situation in a VDI environment with linked-clones. There was an application a customer wanted to have virtualized but this application was involving the use of a barcode scanner. Unfortunately, this scanner required the installation of a driver and ThinApp does not support driver virtualization. Adding a driver implied a modification to the current XP golden image then a recompose of hundreds virtual machines. This wasn’t desired since a few people were using this application with a barcode scanner. So I set up a little trick with the scripting possibilities offered by the ThinApp API Calls.

A little recap of the application:

It had several entry points and for only one of them the driver was required. Each entry point had a PermittedGroup assigned. The application requires a COM port installed on the system to execute without error. The golden image had no serial port so the application was giving some errors about no COM port detected. The driver was installing a fake COM port allowing USB redirection of the scanner (well, it’s a really old app…). The COM port must be installed before the application start or the scanner won’t work even if it was installed just a few seconds after the app started.

Regarding the script, in this situation, I didn’t have a lot of choices among ThinApp APIs Calls. Plus, I had to pass local admin credentials to make the device installation possible (no need for a domain account). As example, I’ll used PsExec from the Sysinternals tools to pass the credentials but you can use any third-party tools allowing you to do so. Better, if you have PowerShell in your golden image you can use a PSCredential object to accomplish this.

Note: If you have a Windows 7 golden image, you can follow this procedure in order to avoid passing a local admin credentials.

Here is a list of third-party tools you might find around Internet (didnt’t test them personally):

The script is easily customizable and might help people in a similar situation:

01
' Declare variables
02
Dim objWSHShell, objFSO, strLogonServer, strPsExec, strDriverPath, strUsername, strPassword, strParameters 
03
Dim objWMIService, strWMIQuery, objProcess, colProcess
04
Dim strComputer, strProcessToFind
05
 
06
' Set global variables
07
Set objWSHShell = CreateObject("Wscript.Shell")
08
Set objFSO = CreateObject("Scripting.FileSystemObject")
09
 
10
' This Thinapp API function is called only when an application first locks the sandbox
11
Function OnFirstSandboxOwner
12
 
13
	' If the driver folder exists, does nothing
14
	If objFSO.FolderExists("C:\Program Files\Driver") Then
15
		' Does nothing
16
	Else
17
		strComputer = "."
18
		strProcessToFind = "Entry_Point_Name.exe"
19
 
20
		If IsProcessRunning(strComputer, strProcessToFind) = True Then
21
 
22
			' Driver setup variables
23
			strLogonServer = EnvString("LOGONSERVER")
24
			strPsExec = strLogonServer & "\NETLOGON\PsExec.exe"
25
			strDriverPath = "Driver_Path"
26
			strParameters = "Installer_parameters"
27
 
28
			' Local admin account credentials
29
			strUsername = "Local_Administrator"
30
			strPassword = "Password"
31
 
32
			' Driver installation
33
			id = ExecuteExternalProcess(strPsExec & "  /accepteula -u " & strUsername & " -p " & strPassword & " cmd /c " & Chr(34) & strDriverPath & Chr(34) & " " & strParameters)
34
			' Wait for process to finish
35
			exitCode = WaitForProcess(id, 0)
36
		End If
37
	End If
38
 
39
End Function 
40
 
41
' Custom functions
42
Function EnvString(variable)
43
	variable = "%" & variable & "%"
44
	EnvString = objWSHShell.ExpandEnvironmentStrings(variable)
45
End Function
46
 
47
Function IsProcessRunning(ByVal strComputer,ByVal strProcessName)
48
 
49
	strWMIQuery = "SELECT * FROM Win32_Process WHERE Name LIKE '" & strProcessName & "'"
50
 
51
	Set objWMIService = GetObject("winmgmts:" _
52
	& "{impersonationLevel=impersonate}!\\" _ 
53
	& strComputer & "\root\cimv2") 
54
 
55
	If objWMIService.ExecQuery(strWMIQuery).Count > 0 Then
56
		IsProcessRunning = True
57
	Else
58
		IsProcessRunning = False
59
	End If
60
 
61
End Function 
62

Since I wanted to install the driver only when a specific entry point was executed, I had to make a specific verification. I couldn’t use the API Call GetCurrentProcessName as it would return the data container name, not very helpful here.
Also, in order to prevent a driver setup inside a same session I chose to check if a certain folder of the driver exists because it doesn’t exist in the golden image and a refresh happens at the user logoff.

This little workaround might be helpful for you and give others some nice scripting ideas! ;-)

Go to Top