Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Best way to edit .ini file

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,36714
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Best way to edit .ini file
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Best way to edit .ini file - 8/3/2006 4:52:26 AM   
  techspaces

 

Posts: 4
Score: 0
Joined: 8/3/2006
Status: offline
Hey everybody,
I have a question about the best way to edit an ini file.  It's basically a find and replace operation.  Here's the jist:

I'm running an app on a server that requires a unique ini file for each machine that access it. (This is for a logging function in the app).  The only two unique lines in the ini file are:

LOGIN_ID: "ComputerName"
MACHINE_ID: "Last two characters of ComputerName"

These are the basic steps that need to happen at login:
1. Check for c:\%COMPUTERNAME% directory
2. If not present, create it
3. Check for c:\%COMPUTERNAME%\server.ini
4. If not present copy from c:\Application\server.ini to c:\%COMPUTERNAME%\
5. Then make find/replace changes

I know how to do some of this with obj.File, but I suspect there might be better ways to accomplish this.  And I'm not exactly sure how to incorporate the %COMPUTERNAME% variable.  Anybody got a good idea?
 
 
Post #: 1
 
 RE: Best way to edit .ini file - 8/3/2006 5:31:10 AM   
  techspaces

 

Posts: 4
Score: 0
Joined: 8/3/2006
Status: offline
One other thing I forgot to mention.  This script will be running on Thin Clients using Citrix Program Neighborhood.

(in reply to techspaces)
 
 
Post #: 2
 
 RE: Best way to edit .ini file - 8/3/2006 5:32:06 AM   
  Country73


Posts: 735
Score: 10
Status: offline
This will give you the Computer Name of the machine the script is ran from:

  
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oNet = CreateObject("Wscript.Network")
   strComputer = oNet.ComputerName
   If Not oFS.FileExists("C:\" & strComputer)Then
       oFS.CreateFolder "C:\" & strComputer
   End If

That should get you started.
  

(in reply to techspaces)
 
 
Post #: 3
 
 RE: Best way to edit .ini file - 8/3/2006 6:20:00 AM   
  techspaces

 

Posts: 4
Score: 0
Joined: 8/3/2006
Status: offline
How does this look so far?


      

< Message edited by techspaces -- 8/3/2006 6:32:54 AM >

(in reply to Country73)
 
 
Post #: 4
 
 RE: Best way to edit .ini file - 8/3/2006 6:26:17 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: online
Doing this:

strNewText = strComputer

before this:

strComputer = oNet.ComputerName

won't work.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to techspaces)
 
 
Post #: 5
 
 RE: Best way to edit .ini file - 8/3/2006 6:33:27 AM   
  techspaces

 

Posts: 4
Score: 0
Joined: 8/3/2006
Status: offline
Thx, fixed that error.  Anything else look wrong?

(in reply to ebgreen)
 
 
Post #: 6
 
 RE: Best way to edit .ini file - 8/3/2006 7:26:56 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: online
I don't see any other obvious gotchas.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to techspaces)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Best way to edit .ini file Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts