Replace function ins VBS
- From: "André" <andre.heublein@xxxxxxxxxxx>
- Date: Mon, 21 Apr 2008 08:28:17 +0200
Hi,
with the following script, i want to read out a file, in which some printers
ar written in, one printer in one line.
Then, i want to put these strings and replace the CR and LF with Two ;;
oder something else.
But, when i run my script, nothing is displayed.
------------
<script language="vbscript">
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer",,48)
For Each objItem in colItems
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objLog = objFso.CreateTextFile("c:\temp\printerlog.txt",True)
objLog.WriteLine objItem.Name
Next
' Define Variables
Dim objFileSystem
Dim objFile
Dim objTextStream
Dim szConfigFile
Dim szPrinter
Dim szMessage
Dim szPrinterReplace
Dim szCRLFDef
' Setting path for logfile
szConfigFile = "c:\temp\printerlog.txt"
' which Object?
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
' which methode to the object?
Set objFile = objFileSystem.OpenTextFile(szConfigFile)
' Read the complete file to the end of it....
If not objFile.atEndOfStream THEN
strArray = objFile.readAll
' define CR & LF
szCRLFDef = CHR(13) & CHR(10)
' replace CR&LF with ;;
szPrinterReplace = StrArray.replace(szCRLFDef,";;")
' print out the string with the replaced chars
document.writeln "Installierte Drucker: " , szPrinterReplace
' close file
objFile.close
End If
</script>
-------------------
When i replace the szPrinterReplace with strArray , the complete content
of the file is displayed.
So, can anyone help me to debug my script or help me with i tip?
Thanks, André
.
- Follow-Ups:
- RE: Replace function ins VBS
- From: urkec
- RE: Replace function ins VBS
- Prev by Date: Re: Detect/Set printer online state
- Next by Date: Re: What to code in now that VS2008 has depreciated VBScript?
- Previous by thread: RE: free editor and debugger
- Next by thread: RE: Replace function ins VBS
- Index(es):
Relevant Pages
|
Loading