Home » vbscript

Tag: vbscript

VBSCRIPT to merge multiple text files

Const ForReading = 1

Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objOutputFile = objFSO.CreateTextFile(“output.txt”)

strComputer = “.”
Set objWMIService = GetObject(“winmgmts:\” & strComputer & “rootcimv2”)

Set FileList = objWMIService.ExecQuery _
(“ASSOCIATORS OF {Win32_Directory.Name=’c:temp’} Where ” _
& “ResultClass = CIM_DataFile”)

For Each objFile In FileList
Set objTextFile = objFSO.OpenTextFile(objFile.Name, ForReading)
strText = objTextFile.ReadAll
objTextFile.Close
objOutputFile.WriteLine strText
Next

objOutputFile.Close

App-V Registry Keys to force offline operation

Setting the following keys will allow app-v packages to be installed from the packages MSI (if the option is ticked for said package when sequencing) this should then allow for the packages to be run in offline / disconnect mode indefinitely.

MSI Install Example:

msiexec.exe /i “app-v msi package” sftpath=”path to matching package sft file”

Registry keys (taken from vbscript attached below)

HKEY_LOCAL_MACHINE,”SOFTWAREWow6432NodeMicrosoftSoftGrid4.5ClientNetwork”,”LimitDisconnectedOperation”,0
HKEY_LOCAL_MACHINE,”SOFTWAREWow6432NodeMicrosoftSoftGrid4.5ClientNetwork”,”Online”,0
HKEY_LOCAL_MACHINE,”SOFTWAREWow6432NodeMicrosoftSoftGrid4.5ClientConfiguration”,”AutoLoadTriggers”,0
HKEY_LOCAL_MACHINE,”SOFTWAREWow6432NodeMicrosoftSoftGrid4.5ClientConfiguration”,”AutoLoadTarget”,0
HKEY_LOCAL_MACHINE,”SOFTWAREWow6432NodeMicrosoftSoftGrid4.5ClientConfiguration”,”RequireAuthorizationIfCached”,0
HKEY_LOCAL_MACHINE,”SOFTWAREWow6432NodeMicrosoftSoftGrid4.5ClientConfiguration”,”AllowIndependentFileStreaming”,0
HKEY_LOCAL_MACHINE,”SOFTWAREWow6432NodeMicrosoftSoftGrid4.5ClientPermissions”,”ToggleOfflineMode”,0

App-V Change Tray Visibility (taken from vbscript attached below)

HKEY_LOCAL_MACHINE, “SOFTWAREWow6432NodeMicrosoftSoftGrid4.5ClientCustomSettings”
HKEY_LOCAL_MACHINE,”SOFTWAREWow6432NodeMicrosoftSoftGrid4.5ClientCustomSettings”,”TrayVisibility”,2
objReg.GetStringValue

Citrix Keys to prevent citrix thin wire session detection from ‘logging off’ the published App-V application (taken from vbscript attached below)

HKEY_LOCAL_MACHINE,”SYSTEMCurrentControlSetControlCitrixwfshellTWI”,”LogoffCheckSysModules”, strValue
objReg.SetStringValue HKEY_LOCAL_MACHINE,”SYSTEMCurrentControlSetControlCitrixwfshellTWI”,”LogoffCheckSysModules”, strValue & “,sftdcc.exe”

VBScript File (rename from .doc to .vbs)

appv_disconnected

SCRIPT: loop through users CN, tsprofile paths and userParameters

‘vbscript
Option Explicit
Dim objCommand, objConnection, strBase, strFilter, strAttributes, objUser
Dim strQuery, objRecordset, strdistinguishedName, strTSPath, strCN, objFSO,
Set objCommand = CreateObject(“ADODB.Command”)
Set objConnection = CreateObject(“ADODB.Connection”)
objConnection.Provider = “ADsDSOObject”
objConnection.Open “Active Directory Provider”
objCommand.ActiveConnection = objConnection
Const ForWriting = 2
‘…set the base DN
strBase = “<ldap://DC=domain,DC=/local>”
strFilter = “(&(objectCategory=person)(objectClass=user))”
strAttributes = “sAMAccountName,cn,distinguishedName”
strQuery = strBase & “;” & strFilter & “;” & strAttributes & “;subtree”
objCommand.CommandText = strQuery
objCommand.Properties(“Page Size”) = 100
objCommand.Properties(“Timeout”) = 30
objCommand.Properties(“Cache Results”) = False
Set objRecordSet = objCommand.Execute
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Do Until objRecordSet.EOF
  strdistinguishedName = objRecordSet.Fields(“distinguishedName”).Value
  Set objUser = GetObject(“LDAP://” & strdistinguishedName)
  On error resume next
 wscript.echo “User:” & objUser.cn & vbtab &  “UserParameters:” & objUser.userParameters & vbtab & ” TSProfilePath:” & objUser.TerminalServicesProfilePath
 ‘ & objUser.sAMAccountName _
  ‘& “,” & objUser.TerminalServicesProfilePath & “,” & objUser.profilePath _
 ‘ & “,” & objUser.homeDirectory & “,” &objUser.ScriptPath
 ‘ objRecordSet.MoveNext
  objRecordSet.MoveNext
Loop
objConnection.Close