Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 22-01-2010
Member
 
Join Date: Dec 2009
Posts: 23
Server config file - batch editing script

I had seen this question somewhere earlier but can't find the thread. Here is the question reworded.

Quote:
Need a script on each computer to open file C:\PLM\...\server1.xml, and replace each "LOCAL_PC_NAME" with the actual name of the computer running the script.

Here is the script to do that in biterscripting.

Code:
# Script Substitute.txt
var str file, xml, computer
# Get the computer mame.
set $computer = getcomputer()
# Read file in.
cat $file > $xml
# Replace each instance of "LOCAL_PC_NAME" with $computer.
while ( { sen "^LOCAL_PC_NAME^" $xml } > 0 )
    sal "^LOCAL_PC_NAME^" $computer $xml  > null
# Write file back
echo $xml > { echo $file }



Call the script with the following command.

Code:
script "Substitute.txt" file("C:\PLM\...\server1.xml")
Put the script in C:/Scripts or in some directory that's in $path.

Use the correct full path for the file() argument instead of "C:\PLM\...\server1.xml".
Reply With Quote
  #2  
Old 25-01-2010
Member
 
Join Date: Jan 2006
Posts: 3,782
Re: Server config file - batch editing script

Hey thanks a lot for giving this post that will be helpful for me to set the my server configuration. I have the same problem and looking for the same so that i can create my own and finally got it here. Need more help actually i am looking for the print server script so help me with that too. A help may be appreciated.
Reply With Quote
  #3  
Old 25-01-2010
Member
 
Join Date: Aug 2006
Posts: 122
Re: Server config file - batch editing script

Code:
On Error Resume Next
Dim strComputer, strExcelPath, objExcel, objSheet, k, objGroup
Dim objWMIService, colItems, ErrState, Sheet
'Sheet = spreadsheet page, k = row in sheet
Sheet = 1
k = 2
strComputer = InputBox ("Please type the print server name to check, " & vbCrLf & _
   "Else enter ALL for all CC print servers", "Server Name")
if strComputer = "" then
  WScript.quit
end if
strExcelPath = InputBox ("Please enter the path to save file to: ", "File path", "c:\")
strExcelPath = strExcelPath & "Printers_" & strComputer & ".xls"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer",,48)
' Bind to Excel object.
On Error Resume Next
Set objExcel = CreateObject("Excel.Application")
If Err.Number <> 0 Then
  On Error GoTo 0
  Wscript.Echo "Excel application not found."
  Wscript.Quit
End If
On Error GoTo 0
' Create a new workbook.
objExcel.Workbooks.Add
'Change this to fit your server situation
Select Case UCase(strComputer)
  Case "ALL"
    PrintServer("CCPS01")
    Sheet = Sheet + 1
    PrintServer("IRGFS01")
    Sheet = Sheet + 1
    PrintServer("CCFLDR01")
  Case Else
    PrintServer(strComputer)
End Select
Function PrintServer(strComputer)
k=2
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer",,48)
' Bind to worksheet.
Set objSheet = objExcel.ActiveWorkbook.Worksheets(Sheet)
objSheet.Name = strComputer
' Populate spreadsheet cells with printer attributes.
objSheet.Cells(1, 1).Value = "Name"
objSheet.Cells(1, 2).Value = "ShareName"
objSheet.Cells(1, 3).Value = "Comment"
objSheet.Cells(1, 4).Value = "Error"
objSheet.Cells(1, 5).Value = "DriverName"
objSheet.Cells(1, 6).Value = "EnableBIDI"
objSheet.Cells(1, 7).Value = "JobCount"
objSheet.Cells(1, 8).Value = "Location"
objSheet.Cells(1, 9).Value = "PortName"
objSheet.Cells(1, 10).Value = "Published"
objSheet.Cells(1, 11).Value = "Queued"
objSheet.Cells(1, 12).Value = "Shared"
objSheet.Cells(1, 13).Value = "Status"
For Each objItem in colItems
'put error code into human readable form
Select Case objItem.DetectedErrorState
  Case 4
    ErrState = "Out of Paper"
  Case 5
    ErrState = "Toner low"
  Case 6
    ErrState = "Printing"
  Case 9
    ErrState = "Offline"
  Case Else
    ErrState = objItem.DetectedErrorState
End Select
'populate the row with this printer's data
objSheet.Cells(k, 1).Value = objItem.Name
objSheet.Cells(k, 2).Value = objItem.ShareName
objSheet.Cells(k, 3).Value = objItem.Comment
objSheet.Cells(k, 4).Value = ErrState
objSheet.Cells(k, 5).Value = objItem.DriverName
objSheet.Cells(k, 6).Value = objItem.EnableBIDI
objSheet.Cells(k, 7).Value = objItem.JobCountSinceLastReset
objSheet.Cells(k, 8).Value = objItem.Location
objSheet.Cells(k, 9).Value = objItem.PortName
objSheet.Cells(k, 10).Value = objItem.Published
objSheet.Cells(k, 11).Value = objItem.Queued
objSheet.Cells(k, 12).Value = objItem.Shared
objSheet.Cells(k, 13).Value = objItem.Status
k = k + 1
Next
' Format the spreadsheet.
objSheet.Range("A1:M1").Font.Bold = True
objSheet.Select
objSheet.Range("A2").Select
objExcel.ActiveWindow.FreezePanes = True
objExcel.Columns(3).ColumnWidth = 25
objExcel.Columns(5).ColumnWidth = 25
objExcel.Columns(6).ColumnWidth = 10
objExcel.Columns(8).ColumnWidth = 25
objExcel.Columns(1).ColumnWidth = 20
objExcel.Columns(9).ColumnWidth = 14
objExcel.Columns(2).ColumnWidth = 15
End Function
' Save the spreadsheet and close the workbook.
objExcel.ActiveWorkbook.SaveAs strExcelPath
objExcel.ActiveWorkbook.Close
' Quit Excel.
objExcel.Application.Quit
' Clean Up
Set objUser = Nothing
Set objGroup = Nothing
Set objSheet = Nothing
Set objExcel = Nothing
WScript.Echo "Printer listing is done"
This script will work on 2003 server. Using this script you can access a print server, get information about all printers on the server. Hope that you were looking for the same.
__________________
As you simplify your life, the laws of the universe will be simpler; solitude will not be solitude, poverty will not be poverty, nor weakness.Henry David Thoreau
Reply With Quote
  #4  
Old 28-01-2010
Member
 
Join Date: Dec 2009
Posts: 23
Re: Server config file - batch editing script

Nice print server script.
Reply With Quote
Reply

  TechArena Community > Software > Windows Software
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Server config file - batch editing script"
Thread Thread Starter Forum Replies Last Post
batch script to find a file stevenwhite Software Development 1 10-04-2012 12:55 PM
Editing text file using a batch file beelow Software Development 8 09-03-2010 12:27 AM
Batch Script Text file parse tator.usenet@gmail.com Windows Server Help 5 25-03-2009 02:12 AM
How can I play a Wav file from batch/cmd script? NaFula Windows Vista Performance 3 13-09-2008 09:21 PM
How to create a script in a DOS batch file to do a loop? Jon Osborn Windows Server Help 2 27-05-2008 06:41 PM


All times are GMT +5.5. The time now is 03:58 AM.