Olivier AH-SON

Olivier AH-SON

(1 comments, 6 posts)

This user hasn't shared any profile information

Home page: http://oliah.net

Posts by Olivier AH-SON
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.

Windows PowerShell icon

PowerShell Optimization Script for Windows 7 Golden Image (VDI)

2

Lately, I was attempting to automate the creation of my Windows 7 Golden Image by building it from scratch in task sequences with System Center Configuration Manager (SCCM/ConfigMgr). No way I’m gonna use some old scripting language like batch or vbs and I coudln’t find any PowerShell script around so I just made one! Moreover, Windows 7 comes with PowerShell (2.0) by default so there is absolutely no reason to overlook the benefits of such a powerful scripting tool! ;)

This script is based on VMware/EMC documents, some useful resources found on Internet and my personal experience. It was made for non-persistent floating pools with Persona Management enabled!

Please review this script THOROUGHLY before use as it will drastically modify Windows. Change it to fit your environment if needed! 

Disclaimer: This script is provided “AS IS” with no warranties, confers no rights, and is not supported by VMware.

 PowerShell |  copy code |? 
001
<# 
002
 .DISCLAIMER
003
  This script is provided "AS IS" with no warranties, confers no rights, and is not supported by VMware.
004
  
005
 .SYNOPSIS 
006
 Windows 7 (Enterprise) VDI Golden Image Optimizations Script
007
 
008
    .DESCRIPTION 
009
 Made for Windows 7 (Enteprise) and VMware View non-persistent floating pools with View Persona Management enabled
010
 
011
    .NOTES 
012
        NAME:  WIN7 VDI OPT.ps1 
013
        AUTHOR: Olivier AH-SON
014
        LASTEDIT: 10/09/2013 
015
        KEYWORDS: vdi, golden image, windows 7, optimization, powershell
016
 
017
#> 
018
 
019
 
020
### Function to set a registry property value
021
### Create the registry key if it doesn't exist
022
Function Set-RegistryKey
023
{
024
 [CmdletBinding()]
025
 Param(
026
 [Parameter(Mandatory=$True,HelpMessage="Please Enter Registry Item Path",Position=1)]
027
 $Path,
028
 [Parameter(Mandatory=$True,HelpMessage="Please Enter Registry Item Name",Position=2)]
029
 $Name,
030
 [Parameter(Mandatory=$True,HelpMessage="Please Enter Registry Property Item Value",Position=3)]
031
 $Value,
032
 [Parameter(Mandatory=$False,HelpMessage="Please Enter Registry Property Type",Position=4)]
033
 $PropertyType = "DWORD"
034
 )
035
 
036
 # If path does not exist, create it
037
 If( (Test-Path $Path) -eq $False ) {
038
 
039
 $newItem = New-Item -Path $Path -Force
040
 
041
 } 
042
 
043
 # Update registry value, create it if does not exist (DWORD is default)
044
 $itemProperty = Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue
045
 If($itemProperty -ne $null) {
046
 $itemProperty = Set-ItemProperty -Path $Path -Name $Name -Value $Value
047
 } Else {
048
 
049
 $itemProperty = New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType
050
 }
051
 
052
}
053
 
054
### Get script path
055
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
056
 
057
### Set location to the root of the system drive
058
Set-Location -Path $env:SystemDrive
059
 
060
### Disable firewall on all profiles (domain, etc.) (Never disable the service!)
061
netsh advfirewall set allprofiles state off | Out-Host
062
 
063
### Disable Error Reporting
064
Set-RegistryKey -Path "HKLM:\SOFTWARE\Microsoft\PCHealth\ErrorReporting" -Name "DoReport" -Value 0
065
 
066
### Disable automatic updates
067
Set-RegistryKey -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" -Name "AUOptions" -Value 1
068
Set-RegistryKey -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" -Name "AUState" -Value 7
069
 
070
###  Remove Windows components
071
$featuresToDisable = @(
072
 "MediaPlayback",
073
 # If "WindowsMediaPlayer" removed, be aware WMV embedded videos on websites won't work (typically videos on Microsoft website)
074
 # Removed because another player is used as the standard
075
 "WindowsMediaPlayer", 
076
 "MediaCenter", 
077
 "OpticalMediaDisc", 
078
 "TabletPCOC", 
079
 "Printing-Foundation-InternetPrinting-Client", 
080
 "Printing-Foundation-Features", 
081
 "FaxServicesClientPackage",
082
 # If you want to keep the Start Menu search bar,
083
 # don't remove the "SearchEngine-Client-Package" component 
084
 "SearchEngine-Client-Package", 
085
 "WindowsGadgetPlatform"
086
)
087
 
088
foreach($feature in $featuresToDisable)
089
{
090
 dism /online /Disable-Feature /Quiet /NoRestart /FeatureName:$feature  | Out-Host
091
}
092
 
093
### Disable NTFS last access timestamp
094
fsutil behavior set disablelastaccess 1  | Out-Host
095
 
096
### Disable TCP/IP / Large Send Offload
097
Set-RegistryKey -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -Name "DisableTaskOffload" -Value 1
098
 
099
### Disable hard disk timeouts 
100
POWERCFG /SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 0012ee47-9041-4b5d-9b77-535fba8b1442 6738e2c4-e8a5-4a42-b16a-e040e769756e 0  | Out-Host
101
POWERCFG /SETDCVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 0012ee47-9041-4b5d-9b77-535fba8b1442 6738e2c4-e8a5-4a42-b16a-e040e769756e 0  | Out-Host
102
 
103
### Disable hibernation
104
powercfg /hibernate off | Out-Host
105
 
106
### Disable monitor time out (never)
107
powercfg -change -monitor-timeout-ac 0
108
 
109
###Disable system restore
110
# System Restore will be disabled on the system drive (usually C:)
111
Disable-ComputerRestore -Drive $env:SystemDrive 
112
Set-RegistryKey -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -Name "DisableSR" -Value 1
113
 
114
### Disable memory dumps (system crashes, BSOD)
115
Set-RegistryKey -Path "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" -Name "CrashDumpEnabled" -Value 0
116
Set-RegistryKey -Path "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" -Name "LogEvent" -Value 0
117
Set-RegistryKey -Path "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" -Name "SendAlert" -Value 0
118
Set-RegistryKey -Path "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" -Name "AutoReboot" -Value 1
119
 
120
### Disable default system screensaver
121
Set-RegistryKey -Path "Registry::\HKEY_USERS\.DEFAULT\Control Panel\Desktop" -Name "ScreenSaveActive" -Value 0
122
 
123
### Increase service startup timeouts
124
Set-RegistryKey -Path "HKLM:\SYSTEM\CurrentControlSet\Control" -Name "ServicesPipeTimeout" -Value 180000
125
 
126
### Increase Disk I/O Timeout to 200 seconds
127
Set-RegistryKey -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Disk" -Name "TimeOutValue" -Value 200
128
 
129
### Disable paging the executive
130
Set-RegistryKey -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" -Name "DisablePagingExecutive" -Value 1
131
 
132
### Size virtual machine RAM
133
# Disable the automatic management of the paging filing size
134
$ComputerSystem = gwmi Win32_ComputerSystem -EnableAllPrivileges
135
$ComputerSystem.AutomaticManagedPagefile = $False
136
$AutomaticManagedPagefile = $ComputerSystem.Put()
137
 
138
# Modify the existing page file of the C drive to set a fixed size of 2048MB
139
# Keeping the pagefile at a single size prevents the system from expanding, which creates a significant amount of IO
140
$CurrentPageFile = gwmi -query "Select * FROM Win32_PageFileSetting WHERE Name='C:\\pagefile.sys'"
141
$CurrentPageFile.InitialSize = [int]2048
142
$CurrentPageFile.MaximumSize = [int]2048
143
$pageFile = $CurrentPageFile.Put()
144
 
145
### Disable Machine Account Password Changes
146
Set-RegistryKey -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters" -Name "DisablePasswordChange" -Value 1
147
 
148
### Configure Event Logs to 1028KB (Minimum size under Vista/7) and overflowaction to "overwrite" 
149
$logs = Get-EventLog -LogName * | foreach{$_.Log.ToString()}
150
$limitParam = @{
151
  logname = ""
152
  Maximumsize = 1024KB
153
  OverflowAction = "OverwriteAsNeeded"
154
}
155
 
156
foreach($log in $logs) {
157
 
158
    $limitParam.logname = $log 
159
    Limit-EventLog @limitParam | Where {$_.Log -eq $limitparam.logname}
160
    Clear-EventLog -LogName $log
161
 
162
}
163
 
164
### Set PopUp Error Mode to "Neither" 
165
Set-RegistryKey -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Windows" -Name "ErrorMode" -Value 2
166
 
167
### Disable UAC secure desktop prompt
168
Set-RegistryKey -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "PromptOnSecureDesktop" -Value 0
169
 
170
### Disable New Network dialog
171
$newNetworkDialog = New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff" -Force
172
 
173
### Disable AutoUpdate of drivers from WU
174
Set-RegistryKey -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "searchorderConfig" -Value 0
175
 
176
### Turn off Windows SideShow
177
Set-RegistryKey -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Sideshow" -Name "Disabled" -Value 1
178
 
179
### Disable IE First Run Wizard and RSS Feeds
180
Set-RegistryKey -Path "HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer\Main" -Name "DisableFirstRunCustomize" -Value 1
181
 
182
### Disable the ability to clear the paging file during shutdown 
183
Set-RegistryKey -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SessionManager\Memory Management" -Name "ClearPageFileAtShutdown" -Value 0
184
 
185
###############################################
186
# Disable unnecessary services
187
###############################################
188
$servicesToDisable = @(
189
 "SensrSvc", # Adaptive Brightness
190
 "ALG", # Application Layer Gateway Service
191
 "BITS", # Background Intelligent Transfer Service
192
 "BDESVC", # BitLocker Drive Encryption Service
193
 "wbengine", # Block Level Backup Engine Service
194
 "bthserv", # Bluetooth Support Service
195
 "PeerDistSvc", # BranchCache
196
 "Browser", # Computer Browser
197
 "UxSms", # Desktop Window Manager Session Manager - Disable only if Aero not necessary
198
 "DPS", # Diagnostic Policy Service
199
 "WdiServiceHost", # Diagnostic Service Host
200
 "WdiSystemHost", # Diagnostic System Host
201
 "defragsvc", # Disk Defragmenter
202
 "TrkWks", # Distributed Link Tracking Client
203
 "EFS", # Encrypting File System (EFS)
204
 "Fax", # Fax - Not present in Windows 7 Enterprise
205
 "fdPHost", # Function Discovery Provider Host
206
 "FDResPub", # Function Discovery Resource Publication
207
 #"HomeGroupListener", # HomeGroup Listener - Not present in Windows 7 Enterprise
208
 "HomeGroupProvider", # HomeGroup Provider
209
 "UI0Detect", # Interactive Services Detection
210
 "iphlpsvc", # IP Helper
211
 "Mcx2Svc", # Media Center Extender Service
212
 "MSiSCSI", # Microsoft iSCSI Initiator Service
213
 "netprofm", # Network List Service
214
 "NlaSvc", # Network Location Awareness
215
 "CscService", # Offline Files
216
 "WPCSvc", # Parental Controls
217
 "wercplsupport", # Problem Reports and Solutions Control Panel Support
218
 "SstpSvc", # Secure Socket Tunneling Protocol Service
219
 "wscsvc", # Security Center
220
 "ShellHWDetection", # Shell Hardware Detection
221
 "SNMPTRAP", # SNMP Trap
222
 "SSDPSRV", # SSDP Discovery
223
 "SysMain", # Superfetch
224
 "TabletInputService", # Tablet PC Input Service
225
 "TapiSrv", # Telephony
226
 "Themes", # Themes - Disable only if you want to run in Classic interface
227
 "upnphost", # UPnP Device Host
228
 "SDRSVC", # Windows Backup
229
 "WcsPlugInService", # Windows Color System
230
 "wcncsvc", # Windows Connect Now - Config Registrar
231
 "WinDefend", # Windows Defender
232
 "WerSvc", # Windows Error Reporting Service
233
 "ehRecvr", # Windows Media Center Receiver Service
234
 "ehSched", # Windows Media Center Scheduler Service
235
 "WMPNetworkSvc", # Windows Media Player Network Sharing Service
236
 "WSearch", # Windows Search
237
 "wuauserv", # Windows Update
238
 "Wlansvc", # WLAN AutoConfig
239
 "WwanSvc" # WWAN AutoConfig
240
)
241
 
242
foreach($service in $servicesToDisable)
243
{
244
    Stop-Service -Name $service -Force # 'Force' parameter stops dependent services 
245
    Set-Service -Name $service -StartupType Disabled
246
}
247
###############################################
248
 
249
# Disable SuperFetch
250
# Service stopped and disabled
251
Set-RegistryKey -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters" -Name "EnableSuperfetch" -Value 0
252
 
253
### Disable schedule tasks
254
$tasksToDisable = @(
255
 "microsoft\windows\Application Experience\AitAgent",
256
 "microsoft\windows\Application Experience\ProgramDataUpdater",
257
 "microsoft\windows\Autochk\Proxy",
258
 "microsoft\windows\Bluetooth\UninstallDeviceTask", 
259
 "microsoft\windows\Customer Experience Improvement Program\Consolidator", 
260
 "microsoft\windows\Customer Experience Improvement Program\KernelCeipTask",
261
 "microsoft\windows\Customer Experience Improvement Program\UsbCeip",
262
 "microsoft\windows\Defrag\ScheduledDefrag",
263
 "microsoft\windows\Diagnosis\Scheduled",
264
 "microsoft\windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector",
265
 "microsoft\windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticResolver", 
266
 "microsoft\windows\Maintenance\WinSAT", 
267
 "microsoft\windows\MobilePC\HotStart", 
268
 "microsoft\windows\RAC\RacTask",
269
 "microsoft\windows\Ras\MobilityManager",
270
 "microsoft\windows\Registry\RegIdleBackup",
271
 "microsoft\windows\SideShow\AutoWake", 
272
 "microsoft\windows\SideShow\GadgetManager",
273
 "microsoft\windows\SideShow\SessionAgent",
274
 "microsoft\windows\SideShow\SystemDataProviders",
275
 "microsoft\windows\SystemRestore\SR",
276
 "microsoft\windows\UPnP\UPnPHostConfig",
277
 "microsoft\windows\WDI\ResolutionHost",
278
 "microsoft\windows\Windows Filtering Platform\BfeOnServiceStartTypeChange", 
279
 "microsoft\windows\Windows Media Sharing\UpdateLibrary", 
280
 "microsoft\windows\WindowsBackup\ConfigNotification"
281
)
282
 
283
foreach ($task in $tasksToDisable) 
284
{
285
 schtasks /change /tn $task /Disable | Out-Host
286
}
287
 
288
### Disable unnecessary boot features (for the current operating system)[A]
289
# Disable the boot debugging 
290
bcdedit /bootdebug off
291
bcdedit /debug off
292
# Disable the bootlog
293
bcdedit /set bootlog no
294
# Disable the boot screen animation
295
# Note: bootux - Not supported in Windows 8 and Windows Server 2012.
296
bcdedit /set bootux disabled
297
# Note: Do not use the quietboot option in Windows 8 as it will prevent the display of bug check data in addition to all boot graphics.
298
bcdedit /set quietboot on
299
 
300
 
301
### Perform a disk cleanup 
302
# Automate by creating the reg checks corresponding to "cleanmgr /sageset:100" so we can use "sagerun:100" 
303
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders" -Name "StateFlags0100" -Value 2
304
Set-RegistryKey -Path "HKLM:\software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files" -Name "StateFlags0100" -Value 2
305
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files" -Name "StateFlags0100" -Value 2
306
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory Dump Files" -Name "StateFlags0100" -Value 2
307
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Offline Pages Files" -Name "StateFlags0100" -Value 2
308
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old ChkDsk Files" -Name "StateFlags0100" -Value 2
309
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations" -Name "StateFlags0100" -Value 0
310
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin" -Name "StateFlags0100" -Value 2
311
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup Log Files" -Name "StateFlags0100" -Value 2
312
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files" -Name "StateFlags0100" -Value 2
313
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error minidump files" -Name "StateFlags0100" -Value 2
314
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files" -Name "StateFlags0100" -Value 2
315
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files" -Name "StateFlags0100" -Value 2
316
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache" -Name "StateFlags0100" -Value 2
317
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Upgrade Discarded Files" -Name "StateFlags0100" -Value 0
318
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Archive Files" -Name "StateFlags0100" -Value 2
319
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Queue Files" -Name "StateFlags0100" -Value 2
320
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Archive Files" -Name "StateFlags0100" -Value 2
321
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Queue Files" -Name "StateFlags0100" -Value 2
322
Set-RegistryKey -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Upgrade Log Files" -Name "StateFlags0100" -Value 2
323
 
324
cleanmgr.exe /sagerun:100  | Out-Host
325
 
326
# Customization of the default user 
327
$defaultUserHivePath = $env:SystemDrive + "\Users\Default\NTUSER.DAT"
328
$userLoadPath = "HKU\TempUser" 
329
 
330
# Load Hive
331
reg load $userLoadPath $defaultUserHivePath | Out-Host
332
# Create PSDrive
333
$psDrive = New-PSDrive -Name HKUDefaultUser -PSProvider Registry -Root $userLoadPath
334
# Reduce menu show delay 
335
Set-RegistryKey -Path "HKUDefaultUser:\Control Panel\Desktop" -Name "MenuShowDelay" -Value 0
336
# Disable cursor blink 
337
Set-RegistryKey -Path "HKUDefaultUser:\Control Panel\Desktop" -Name "CursorBlinkRate" -Value -1
338
Set-RegistryKey -Path "HKUDefaultUser:\Control Panel\Desktop" -Name "DisableCursorBlink" -Value 1
339
# Force off-screen composition in IE 
340
Set-RegistryKey -Path "HKUDefaultUser:\Software\Microsoft\Internet Explorer\Main" -Name "Force Offscreen Composition" -Value 1
341
# Disable screensavers
342
Set-RegistryKey -Path "HKUDefaultUser:\Software\Policies\Microsoft\Windows\Control Panel\Desktop" -Name "ScreenSaveActive" -Value 0
343
Set-RegistryKey -Path "HKUDefaultUser:\Control Panel\Desktop\" -Name "ScreenSaveActive" -Value 0
344
Set-RegistryKey -Path "Registry::\HKEY_USERS\.DEFAULT\Control Panel\Desktop" -Name "ScreenSaveActive" -Value 0
345
# Don't show window contents when dragging 
346
Set-RegistryKey -Path "HKUDefaultUser:\Control Panel\Desktop" -Name "DragFullWindows" -Value 0
347
# Don't show window minimize/maximize animations
348
Set-RegistryKey -Path "HKUDefaultUser:\Control Panel\Desktop\WindowMetrics" -Name "MinAnimate" -Value 0
349
# Disable font smoothing 
350
Set-RegistryKey -Path "HKUDefaultUser:\Control Panel\Desktop" -Name "FontSmoothing" -Value 0
351
 
352
# Disable most other visual effects 
353
Set-RegistryKey -Path "HKUDefaultUser:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" -Name "VisualFXSetting" -Value 3
354
Set-RegistryKey -Path "HKUDefaultUser:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewAlphaSelect" -Value 0
355
Set-RegistryKey -Path "HKUDefaultUser:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAnimations" -Value 0
356
Set-RegistryKey -Path "HKUDefaultUser:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewWatermark" -Value 0
357
Set-RegistryKey -Path "HKUDefaultUser:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewShadow" -Value 0
358
Set-RegistryKey -Path "HKUDefaultUser:\Control Panel\Desktop" -Name "UserPreferencesMask" -Value ([byte[]](0x90,0x12,0x01,0x80)) -PropertyType "Binary"
359
 
360
# Disable Action Center Icon
361
Set-RegistryKey -Path "HKUDefaultUser:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "HideSCAHealth" -Value 1
362
 
363
# Disable Network Icon
364
Set-RegistryKey -Path "HKUDefaultUser:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "HideSCANetwork" -Value 1
365
 
366
# Disable IE Persistent Cache 
367
Set-RegistryKey -Path "HKUDefaultUser:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Cache" -Name "Persistent" -Value 0
368
Set-RegistryKey -Path "HKUDefaultUser:\Software\Microsoft\Feeds" -Name "SyncStatus" -Value 0
369
 
370
# Remove PSDrive
371
$psDrive = Remove-PSDrive HKUDefaultUser
372
# Clean up references not in use
373
$variables = Get-Variable | Where { $_.Name -ne "userLoadPath" } | foreach { $_.Name }
374
foreach($var in $variables) { Remove-Variable $var -ErrorAction SilentlyContinue }
375
[gc]::collect()
376
# Unload Hive
377
reg unload $userLoadPath | Out-Host
378
 
379
# Hide the VMWare tray icon for all users
380
Set-RegistryKey -Path "HKLM:\SOFTWARE\VMware, Inc.\VMware Tools" -Name "ShowTray" -Value 0
381
 
382
Exit 0
383
 
384

If you want to use it in a Task Sequence like me, create a package without program and run a command line:

powershell -ExecutionPolicy Unrestricted -File “WIN7 VDI OPT.ps1″

This can be also used with Microsoft Deployment Toolkit (MDT).

A few notes:

References:

Windows PowerShell icon

Import-CSV Change file encoding

0

If your CSV file contains accented characters, typically french words or names, you will get into trouble with Import-CSV.

The reason why the accented characters won’t display properly is that the CSV was saved in ANSI. For example, it’s the default encoding when creating a text file with notepad, Excel generates ANSI encoded CSV file, etc.

An easy fix would be to encode the file in Unicode. This can be done when saving the file with notepad or through PowerShell commands:

 PowerShell |  copy code |? 
1
Get-Content .\user_list.csv | Out-File .\user_list_unicode.csv -Encoding Unicode
2
Import-CSV .\user_list_unicode.csv -Delimiter ','

Result:

OVF environment not supported. Please deploy on compatible vCenter Server.

0

You might have the following error after deploying the vCloud Director appliance:

Generating SSL certifications for sfcb in /opt/vmware/etc/sfcb

Generating SSL certifications for lighttpd in /opt/vmware/etc/lighttpd

No value found

No value found

Unable to determine the cdrom devices, perhaps none have been configured: [Errno 2] No such file or directory: ‘/proc/sys/dev/cdrom/info’

Unable to find the ovf environment.

FAILURE: OVF environment not supported. Please deploy on compatible vCenter Server.

You have this error because you have deployed the OVF from an ESX host. To fix this, redeploy the appliance from your vCenter Server.

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! ;-)

Olivier AH-SON's RSS Feed
Go to Top