Hostname needs to be change in .cfg file

My application package creating the .cfg file after installation and this file having the hostname information. Hostname should be changed as per the machine hostname. How can i include this in the Package? If i want to edit the .cfg file using vbscript, how can i do this? Any idea please...

0 Comments   [ + ] Show comments

Answers (3)

Posted by: shweta_kar 12 years ago
Blue Belt
Dim WshShell,cmd_line
Set WshShell = CreateObject("WScript.shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile(Session.Property("INSTALLDIR") & "<location of the .cfg file", 1) ' check whether the file resides under INSTALLDIR else need to edit it
cmd_line = objFile.ReadAll
cmd_line = Replace(cmd_line, "<HostName>", WshShell .ExpandEnvironmentStrings("%COMPUTERNAME%"))

Note:<Provide the name which you want to replace it value with ,this will replace wherever the value of Hostname to %COMPUTERNAME% to get the desired result.
Posted by: anonymous_9363 12 years ago
Red Belt
Careful! The posted script replaces every occurence of the word, which may not be the effect you want.
Posted by: ekniranjan 12 years ago
Purple Belt
Thanks for your reply. the .cfg file is residing in AllUsersProfile>Application Data>...\..\
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ