Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need VB Script to automate file and registry edit

Posted on 2009-04-01
7
Medium Priority
?
266 Views
Last Modified: 2012-05-06
I need a VB Script to do the below:

Write the following to the file name appsrv.ini within the below directory:

Compress=Off

EncryptionLevelSession=EncRC5-0

C:\Program Files\Citrix\ICA Client\

I would like for it to add those entries to the ini during a startup script I will create.

It also needs to create the following registry entry:

HKLM\Software\Citrix\ICA Client\Engine\Configuration\Advanced\Canonicalization\TCP/IP

Add new REG_SZ

String Value  Name:Compress

Data:Compress  

0
Comment
Question by:bbanis2k
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 24040408
Try this...
Const iniName = "appsrv.ini"
Const iniLocation = "C:\Program Files\Citrix\ICA Client\"
Const ForAppending = 8   
Const HKLM = &H80000002
 
'Create/update file
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFile
If Not objFSO.FolderExists(iniLocation) Then wscript.quit
If objFSO.FileExists (iniLocation & iniName) Then
  Set objFile = objFSO.OpenTextFile(iniLocation & iniName, ForAppending)
Else
  Set objFile = objFSO.CreateTextFile(iniLocation & iniName)
End If
 
objFile.WriteLine "Compress=Off"
objFile.WriteLine "EncryptionLevelSession=EncRC5-0"
objFile.Close
Set objFile = Nothing
 
'Create registry entry
Dim oReg : Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
strKeyPath = "Software\Citrix\ICA Client\Engine\Configuration\Advanced\Canonicalization\TCP/IP"
strValueName = "Compress"
strValue = "Compress"
oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue
 
Set oReg = Nothing
 

Open in new window

0
 

Author Comment

by:bbanis2k
ID: 24040727
Can you configure it to resume on error and then exit without output to the client computer?

0
 
LVL 67

Expert Comment

by:sirbounty
ID: 24040954
I don't follow?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bbanis2k
ID: 24040975
What happens if it does not see that directory or has an issue reading the registry?
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 24041002
If the folder doesn't exist, it quits:

If Not objFSO.FolderExists(iniLocation) Then wscript.quit

The following will continue on registry update error...
Const iniName = "appsrv.ini"
Const iniLocation = "C:\Program Files\Citrix\ICA Client\"
Const ForAppending = 8   
Const HKLM = &H80000002
 
'Create/update file
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFile
If Not objFSO.FolderExists(iniLocation) Then wscript.quit
If objFSO.FileExists (iniLocation & iniName) Then
  Set objFile = objFSO.OpenTextFile(iniLocation & iniName, ForAppending)
Else
  Set objFile = objFSO.CreateTextFile(iniLocation & iniName)
End If
 
objFile.WriteLine "Compress=Off"
objFile.WriteLine "EncryptionLevelSession=EncRC5-0"
objFile.Close
Set objFile = Nothing
 
'Create registry entry
On Error Resume Next
Dim oReg : Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
strKeyPath = "Software\Citrix\ICA Client\Engine\Configuration\Advanced\Canonicalization\TCP/IP"
strValueName = "Compress"
strValue = "Compress"
oReg.SetStringValue HKLM,strKeyPath,strValueName,strValue
 
Set oReg = Nothing
 

Open in new window

0
 

Author Closing Comment

by:bbanis2k
ID: 31565356
This works great!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 24041253
Glad I could help - thanx for the grade! :^)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question