troubleshooting Question

How to edit a file using VB script or a batch file.

Avatar of rgn2121
rgn2121Flag for United States of America asked on
ProgrammingWindows BatchMultimedia Programming
16 Comments2 Solutions2006 ViewsLast Modified:
Here's the deal...

I currently have a file that needs editing to correct an error on multiple pc's.  I would like to create a script to do this, but I am getting hung up.

For example lets call the file TEST...it resides in c:\program files\Testing\TEST.EXPL on a Windows 2000 system with 2 partitons C and D...D for user profiles, etc.

I am using the EXPL extension because the file is not a normal file extension and can either be edited using notepad or using the DOS Edit functionality which I prefer.

I need the script to be able to allow me to edit a file...save it and then restart the pc.  

The contents of the file TEST are displayed:

[Profile]
ID=WS
Version=8
[Telnet3270]
HostName=
HostPortNumber=
Security=N
LastConfigHostDoesNotTimeout=N
[Communication]
Link=
[3270]
QueryReplyMode=Auto
HostCodePage=
[Keyboard]

I need to insert a couple lines between [3270] and [Keyboard] such as:

[LT]
UnidetifiedVar=Y
UnidetifiedChar=Y

This is what I have for vb so far...it will let me remotely connect to any pc by name and I can reboot that pc, but I don't know how to edit the file.  I don't have to be able to do this remotely, but it would make things easier.

strComputer = InputBox("Enter a Computer Name")
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
        strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    objOperatingSystem.Reboot()
Next

Here is what I have for a batch file so far:

@ECHO OFF
ECHO "Enter the pc name"
c:
pause
cd c:\program files\testing\
pause
dir
pause
EDIT TEST.EXPL

Please help...

Thanks rgn






Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 16 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros