Replace function ins VBS



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é



.



Relevant Pages

  • RE: Replace function ins VBS
    ... But, when i run my script, nothing is displayed. ... Dim objFileSystem ... Dim szPrinter ...
    (microsoft.public.scripting.vbscript)
  • RE: export user accounts from NT 4.0 domain
    ... ATTENTION THE SCRIPT MUST BE RUNNED FROM A COMPUTER WHERE EXCEL IS ... from the information in a Microsoft Excel spreadsheet. ... Dim strLast, strFirst, strMiddle, strPW, intRow, intCol ... On Error GoTo 0 ...
    (microsoft.public.windows.server.scripting)
  • Re: Password Expire
    ... We have one fron end Edge server in our DMZ which passes email onto two ... I used to schedule a script to run every 24 hours on my Exchange 2003 ... Dim fso, txtarray, BodyText ... Call ProcessFolder (objContainer, numDays) ...
    (microsoft.public.exchange.admin)
  • Re: LDAP query information
    ... a "Dim" statement. ... execution of the script. ... ' Filter on computer object. ... ' Construct LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)
  • Re: ADSI Problem
    ... Right I've got the script working now with my ASP applications by passing the ... If you are doing forms authentication using ADSI (which it sounds like you ... Restarting IIS usually gets it working again. ... Dim strUserName ...
    (microsoft.public.windows.server.active_directory)

Loading