Creating an output file

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hey guys,
Before I start, I have looked through several threads on this and other forums and I still cant get exactly what I need. I am not a coder so this problem may be easy for some of you and harder for others. Anyways, I have set up a new print server
on my network and I found a script that will move the printers from the new print server to the old one. Here is the code:
<pre class="prettyprint strOldServer = "CABERNET"
strNewServer = "PrintServer1"




strComputer = "."
Set WSHNetwork = CreateObject("WScript.Network")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\" & strComputer & "rootcimv2")
Set colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_Printer")

strOldServer = prepServer(strOldServer)
strNewServer = prepServer(strNewServer)

For Each objPrinter in colInstalledPrinters
strName = objPrinter.Name
iPrinterLocation = InStr(UCase(objPrinter.Name),UCase(strOldServer))
If iPrinterLocation > 0 then
strPrinter = strNewServer & Right(strName, Len(strName) - Len(strOldServer))
objPrinter.Delete_
WSHNetwork.AddWindowsPrinterConnection strPrinter
If objPrinter.Default = True Then
WSHNetwork.SetDefaultPrinter strPrinter
End If
End If
Next


Function prepServer(strServer)
If Left(strServer, 2) <> "\" then
strServer = "\" & strServer
End If
If Right(strServer, 1) <> "" then
strServer = strServer & ""
End If
prepServer = strServer
End Function[/code]
The script works fine but I need it to:

Display an output file that shows which computers switched over as well as the printers that switched over.Figure out a way to check if the script has run via the output file. If it has run, skip over the script.
I plan on deploying this as a start-up script.
I know we got some gear heads out there!! Can anyone help me with this? Thanks!!

View the full article
 
Back
Top