SCRIPT modificar txt

28/09/2007 - 12:57 por ZIDAC | Informe spam
Hola, necesito hacer mediante un script lo siguiente:
1) parar un servicio
2) abrir un txt y modificar una linea
3) guardar los cambios
4) iniciar el servicio

Es posible?
Cómo se hace esto?

GRACIAS,
ZIDAC

Preguntas similare

Leer las respuestas

#1 ZIDAC
28/09/2007 - 14:21 | Informe spam
Es siempre el mismo archivo y la misma línea.

En esa línea pone lo siguiente:
Tiempo`
debo cambiarlo por:
Tiempo=1

Gracias,
ZIDAC
#2 Fernando Reyes [MS MVP]
28/09/2007 - 16:27 | Informe spam
Cierto, se me olvidó esa posibilidad.

Un saludo
Fernando Reyes [MS MVP]
MCSE Windows 2000 / 2003
MCSA Windows Server 2003
http://freyes.svetlian.com
http://urpiano.wordpress.com
RSS: http://urpiano.wordpress.com/feed
freyes.champú@champú.mvps.org
(Aclárate la cabeza si quieres escribirme)


"Ramon Jiménez" escribió en el mensaje
de noticias news:
Mostrar la cita
#3 ZIDAC
28/09/2007 - 18:57 | Informe spam
No veo nada
¿Dónde está eso que hicieste hace años?
#4 Ramon Jiménez
28/09/2007 - 21:33 | Informe spam
es un adjunto

'+--+
'| Copyright (C) 1997-2004 F. Hoffmann-La Roche Ltd
|
'+--+--+
'| File: | FindReplace.VBS
|
'| Purpose: | Find all ocurences of a String1 in a given file and
replace |
'| | it with String 2
|
'+--+--+
'| Author: | Ramon Jimenez
|
'| Date: | Nov 25, 2004
|
'+--+
'| Parameters | Filename, StrtoReplace, StrReplacement
|
'+--+
'| Requirements | none
|
'+--+--+
'| Version | 1.0
|
'+--+--+
'| File History:
|
'|
+-+-++
|
'| Name: Ramon Jimenez
|
'| Date: Nov 25, 2004
|
'| Desc: Creation and version 1.0
|
'|
+-+-++
|
'+--+
Option Explicit
CONST ForReading = 1
CONST ForWriting = 2

'Example
FindAndReplace ".\\TEST.TXT", "Cadena1", "Cadena2"

Sub FindAndReplace (StrFilename, strPattern, StrReplace)
Dim oFSO, oFile, oRegExp, strData

' We open the File in ReadOnly mode and read it completely storing the
'content into a variable. Then close the file

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.OpenTextFile(strFileName, ForReading)
strData = oFile.ReadAll
oFile.Close

' Once we have the variable we search the String we want to replace
' using a Regular Expression type variable. Then we use a method from
' this class to replace all ocurrences

Set oRegexp = New Regexp
oRegexp.Pattern = strPattern
oRegexp.Global = TRUE
oRegexp.IgnoreCase = True
strData = oRegexp.Replace(strData, strReplace)

' We open again the file in Write mode and dump the content of the variable
' into the file
Set oFile = oFSO.OpenTextFile(strFileName, ForWriting)
oFile.Write strData
oFile.Close
End Sub
"ZIDAC" wrote in message
news:
Mostrar la cita
#5 ZIDAC
29/09/2007 - 23:37 | Informe spam
La caña, perfecto. Gracias, me ha funcionado de maravilla.

Ahora me surge una inquietud, ya que me gustaría aprender:

Qué lenguaje es este, Visual Basic?
Algún enlace o tutorial para aprender a realizar scripts?
Algún programa en concreto para editarlos o se hace a pelo en un txt?

Gracias,
ZIDAC
Ads by Google
Search Busqueda sugerida