Unattended Cleanup Script til Terminal og Citrix Servere

Efter man har installeret sin Terminal eller Citrix Server, kan man med fordel lave et cleanup script.
Dette script sletter/ændre genvejsikoner – foldere – registry settings, som man ikke ønsker brugerne skal kunne se eller afvikle.
Jeg har udarbejdet et eksempel som nemt kan tilrettes. Se nedenstående billede.

Koden for RunOnceEx_CleanUp.cmd, er som følger:

@ECHO OFF
SET KEY=HKLMSOFTWAREMicrosoftWindowsCurrentVersionRunOnceEx

REG ADD %KEY% /V TITLE /D “Citrix XenApp – CleanUp” /f

REG ADD %KEY%00 /VE /D “Change User /install” /f
REG ADD %KEY%00 /V 1 /D “\wIN-VS-001XenAPPInstall.cmd” /f

REG ADD %KEY%05 /VE /D “Remove Applications Shortcuts from Programs Group” /f
REG ADD %KEY%05 /V 1 /D “\wIN-VS-001XenAPPCleanUpDelete_Shortcuts.vbs” /f

REG ADD %KEY%10 /VE /D “Delete Outlook Express from Default User Profile” /f
REG ADD %KEY%10 /V 1 /D “\wIN-VS-001XenAPPCleanUpDelete_OE.vbs” /f

REG ADD %KEY%15 /VE /D “Delete ICABAR from Run in Registry” /f
REG ADD %KEY%15 /V 1 /D “\wIN-VS-001XenAPPCleanUpDelete_IcaBar.vbs” /f

REG ADD %KEY%20 /VE /D “Delete Adobe Reader Speed Launcher from Run in Registry” /f
REG ADD %KEY%20 /V 1 /D “\wIN-VS-001XenAPPCleanUpDelete_AdobeR_Speed_Launcher.vbs” /f

REG ADD %KEY%25 /VE /D “Disable Spooler errors from being displayed on the server console” /f
REG ADD %KEY%25 /V 1 /D “\wIN-VS-001XenAPPCleanUpDisable_Spooler_Errors.vbs” /f

REG ADD %KEY%30 /VE /D “Disable Console System Popup Messages” /f
REG ADD %KEY%30 /V 1 /D “\wIN-VS-001XenAPPCleanUpDisable_Console_System_Messages.vbs” /f

REG ADD %KEY%35 /VE /D “Set the Name of the My Computer Icon to the Current User and Machine Name” /f
REG ADD %KEY%35 /V 1 /D “\wIN-VS-001XenAPPCleanUpMy_Computer_Username.cmd” /f

REG ADD %KEY%40 /VE /D “Set Deletion of AutoCreated Printers (http://support.citrix.com/article/CTX051476)” /f
REG ADD %KEY%40 /V 1 /D “\wIN-VS-001XenAPPCleanUpDelete_Client_Printers.vbs” /f

REG ADD %KEY%99 /VE /D “Change User /execute” /f
REG ADD %KEY%09 /V 1 /D “\wIN-VS-001XenAPPExecute.cmd” /f

REG ADD %KEY%100 /VE /D “Reboot Server” /f
REG ADD %KEY%100 /V 1 /D “\wIN-VS-001XenAPPReboot.cmd” /f

EXIT

Delete_Shortcuts.vbs:
Option Explicit
Dim StrAllUsers, StrDefaultUsers, objFSO
StrAllUsers = “C:Documents and SettingsAll UsersStart Menu”
StrDefaultUsers = “C:Documents and SettingsDefault UserStart MenuPrograms”
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
If objFSO.FileExists (StrAllUsers & “Windows Catalog.lnk”) Then objFSO.DeleteFile (StrAllUsers & “Windows Catalog.lnk”)
If objFSO.FileExists (StrAllUsers & “Windows Update.lnk”) Then objFSO.DeleteFile (StrAllUsers & “Windows Update.lnk”)
If objFSO.FileExists (StrAllUsers & “ProgramsAdobe Reader 8.lnk”) Then objFSO.DeleteFile (StrAllUsers & “ProgramsAdobe Reader 8.lnk”)
If objFSO.FolderExists (StrAllUsers & “ProgramsAccessories”) Then objFSO.DeleteFolder (StrAllUsers & “ProgramsAccessories”), True
If objFSO.FolderExists (StrDefaultUsers & “Startup”) Then objFSO.DeleteFolder (StrDefaultUsers & “Startup”), True
If objFSO.FolderExists (StrDefaultUsers & “Accessories”) Then objFSO.DeleteFolder (StrDefaultUsers & “Accessories”), True
If objFSO.FileExists (StrDefaultUsers & “Remote Assistance.lnk”) Then objFSO.DeleteFile (StrDefaultUsers & “Remote Assistance.lnk”)

Delete_OE.vbs:
Option Explicit
Dim objReg, strComputer
Dim strKeyPath1, strKeyPath2
Dim strValueName1
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath1 = “SOFTWAREMicrosoftActive SetupInstalled Components{44BBA840-CC51-11CF-AAFA-00AA00B6015C}”
strKeyPath2 = “SOFTWAREMicrosoftActive SetupInstalled Components{7790769C-0471-11d2-AF11-00C04FA35D02}”
strValueName1 = “StubPath”
strComputer = “.”
Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\”&_
strComputer & “rootdefault:StdRegProv”)
objReg.DeleteValue HKEY_LOCAL_MACHINE, strKeyPath1,strValueName1
objReg.DeleteValue HKEY_LOCAL_MACHINE, strKeyPath2,strValueName1

Delete_IcaBar.vbs:
Option Explicit
Dim objReg, strComputer
Dim strKeyPath1
Dim strValueName1
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath1 = “SOFTWAREMicrosoftWindowsCurrentVersionRun”
strValueName1 = “IcaBar”
strComputer = “.”
Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\”&_
strComputer & “rootdefault:StdRegProv”)
objReg.DeleteValue HKEY_LOCAL_MACHINE, strKeyPath1,strValueName1

Delete_AdobeR_Speed_Launcher.vbs:
Samme som ovenstående, men udskift IcaBar med “Adobe Reader Speed Launcher”

Disable_Spooler_Errors.vbs:
Option Explicit
Dim objReg, strComputer
Dim strKeyPath1
Dim strValueName1
Dim DisableDWord
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath1 = “SYSTEMCurrentControlSetServicesSpooler”
strValueName1 = “ErrorControl”
DisableDWord = 00000002
strComputer = “.”
Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\”&_
strComputer & “rootdefault:StdRegProv”)
objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath1
objReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath1,strValueName1,DisableDWord

Disable_Console_System_Messages.vbs:
Option Explicit
Dim objReg, strComputer
Dim strKeyPath1
Dim strValueName1
Dim DisableDWord
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath1 = “SYSTEMCurrentControlSetControlWindows”
strValueName1 = “ErrorMode”
DisableDWord = 00000002
strComputer = “.”
Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\”&_
strComputer & “rootdefault:StdRegProv”)
objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath1
objReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath1,strValueName1,DisableDWord

My_Computer_Username.cmd:
@ECHO OFF
ECHO Set the Name of the My Computer Icon to the Current User and Machine Name
START /WAIT regedit /s \win-vs-001XenAppCleanUpMy_Computer_Username.reg

My_Computer_Username.reg: (Username on Servername)
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOTCLSID{20D04FE0-3AEA-1069-A2D8-08002B30309D}]
@=”My Computer”
“LocalizedString”=hex(2):25,00,55,00,53,00,45,00,52,00,4e,00,41,00,4d,00,45,00,
25,00,20,00,6f,00,6e,00,20,00,25,00,43,00,4f,00,4d,00,50,00,55,00,54,00,45,
00,52,00,4e,00,41,00,4d,00,45,00,25,00,00,00

Delete_Client_Printers.vbs:
Option Explicit
Dim objReg, strComputer
Dim strKeyPath1
Dim strValueName1, strValueName2
Dim EnableDWord
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath1 = “SYSTEMCurrentControlSetControlCitrixClientPrinterProperties”
strValueName1 = “fPurgeAnyWay”
strValueName2 = “fNotInheritKeepPrintedJobs”
EnableDWord = 00000001
strComputer = “.”
Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\”&_
strComputer & “rootdefault:StdRegProv”)
objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath1
objReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath1,strValueName1,EnableDWord
objReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath1,strValueName2,EnableDWord

Comments are closed.