Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Migrating Print Queues from linux to W2003 R2

Status
Not open for further replies.

MikeStoneAus

IS-IT--Management
May 29, 2007
1
AU
Hello,

Does any have information on a good process on migrating print queues from Samba to W2003 R2.

I have about 500 print queues to migrate so manually migrating would be painful to say the least

There is a heap of info on going the other way round but I can't seem to find anything on migrating to windows.

Thanks

Michael
 
Well I can't think of a really good way to do that, I do have an idea that might work for you. If you make a copy of your /etc/cups/printers.conf file. Then basicly write a script against that file to add the printers to your windows box.
 
Now there is a concept!

I'm not aware of any other way, either. Unfortunately, the print migration tool only works on Windows.

Pat Richard, MCSE MCSA:Messaging CNA
Microsoft Exchange MVP
Want to know how email works? Read for yourself -
 
'This Script Requires 2 files to be made First Needs a copy of printers.conf file
'named printconf.txt and a file called printermodels.txt which is created on your
'linux system by running the following command in the /etc/cups/ppd directory:
' grep ModelName * | tee $HOME/printermodels.txt
'this will create the second file you need in your home directory.
'Both files need to be in the root of your C: drive on your windows machine.



Set WSHNetwork = WScript.CreateObject("WScript.Network")

set shell = WScript.CreateObject( "WScript.Shell" )
CompName = shell.ExpandEnvironmentStrings("%COMPUTERNAME%")
Set objWMIService = GetObject("winmgmts:\\" & CompName & "\root\cimv2")

Set objNewPort = objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_

Set oShell = WScript.CreateObject("WScript.shell")

Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\printconf.txt", 1)
Set objFile2 = objFSO.OpenTextFile("C:\printermodels.txt", 1)

SkipLines(2)
strPrinterName = ReadPrinterInfo(10,10)
SkipLines(2)
strPrinterIP = ReadPrinterInfo(20,24)
SkipLines(7)

i = 0
Do Until objFile.AtEndOfStream

strPrinterName = ReadPrinterInfo(10,10)
'WScript.Echo strPrinterName
objFile.SkipLine
objFile.SkipLine
strPrinterIP = ReadPrinterInfo(20,24)
'WScript.Echo strPrinterIP
createPort ("IP_" & StrPrinterIP, StrPrinterIP)
If i = 0 Then
strDriverName = GetDriver
'WScript.Echo strDriverName
i = i + 1
Else
SkipLines2(i)
strDriverName = GetDriver
'WScript.Echo strDriverName
i = i + 1
End If
addPrinter(strDriverName, "IP_" & StrPrinterIP, strPrinterName)
SkipLines(7)
Loop


WScript.Echo "Done"





'x is the character starting point, y is total number of charaters not used
Function ReadPrinterInfo(x,y)
strReadLine = objFile.ReadLine
strReadLineLength = (Len(strReadLine) - y)
Call Mid(strReadLine, x, strReadLineLength)
End Function


Function GetDriver()
strReadLine2 = objFile2.ReadLine
strReadLineLengh3 = strReadLineLegnth + 21
strReadLineLength2 = (Len(strReadLine2)-strReadLineLengh3)
Call Mid(strReadLine2, strReadLineLengh3 + 1, strReadLineLength2)
End Function


Function createPort (Name, IP)

objNewPort.Name = Name
objNewPort.Protocol = 1
objNewPort.HostAddress = IP
objNewPort.SNMPEnabled = False
objNewPort.Put_

End Function


Function addPrinter (driver, port, name)

objPrinter.DriverName = driver
objPrinter.PortName = port
objPrinter.DeviceID = name
objPrinter.Network = True
objPrinter.Shared = True
objPrinter.ShareName = name
objPrinter.Put_

End Function

Function SkipLines(j)
Do until j = 0
objFile.SkipLine
j = j -1
Loop
End Function

Function SkipLines2(k)
Do until k = 0
objFile2.SkipLine
k = k - 1
Loop
End Function
 
make sure that your txt files are formated correctly when I did it, the file was one big line, I think because I used the ASCII verson instead of Binary when brought over from my linux to windows. As long as your formating of the files are correct this script should work. Didn't fully test it though.
 
OH and BTW you need to have all the print drivers install on the windows box as well. There maybe a couple of syntax error, but you get the idea.
 
Couple of changes
Call Mid(strReadLine, x, strReadLineLength) should be

ReadPrinterInfo = Mid(strReadLine, x, strReadLineLength)

and

Call Mid(strReadLine2, strReadLineLengh3 + 1, strReadLineLength2)should be

GetDriver = Mid(strReadLine2, strReadLineLengh3 + 1, strReadLineLength2)
 
OK I think I got it

Code:
'This Script Requires 2 files to be made First Needs a copy of printers.conf file
'named printconf.txt and a file called printermodels.txt which is created on your
'linux system by running the following command in the /etc/cups/ppd directory:
' grep ModelName * | tee $HOME/printermodels.txt
'this will create the second file you need in your home directory.
'Both files need to be in the root of your C: drive on your windows machine.



Set WSHNetwork = WScript.CreateObject("WScript.Network")

set shell = WScript.CreateObject( "WScript.Shell" )
CompName = shell.ExpandEnvironmentStrings("%COMPUTERNAME%")
Set objWMIService = GetObject("winmgmts:\\" & CompName & "\root\cimv2")

Set objNewPort = objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_

Set oShell = WScript.CreateObject("WScript.shell")

Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\printconf.txt", 1)
Set objFile2 = objFSO.OpenTextFile("C:\printermodels.txt", 1)

SkipLines(2)
strPrinterName = ReadPrinterInfo(10,10)
SkipLines(2)
strPrinterIP = ReadPrinterInfo(20,24)
SkipLines(7)

i = 0
Do Until objFile.AtEndOfStream

	strPrinterName = ReadPrinterInfo(10,10)
	'WScript.Echo strPrinterName
	objFile.SkipLine
	objFile.SkipLine
	strPrinterIP = ReadPrinterInfo(20,24)
	'WScript.Echo strPrinterIP
	createPort ("IP_" & StrPrinterIP, StrPrinterIP)
	If i = 0 Then
		strDriverName = GetDriver
		'WScript.Echo strDriverName
		i = i + 1
	Else
		SkipLines2(i)
		strDriverName = GetDriver
		'WScript.Echo strDriverName
		i = i + 1
	End If
	addPrinter(strDriverName, "IP_" & StrPrinterIP, strPrinterName)
	SkipLines(7)
Loop


WScript.Echo "Done"





'x is the character starting point, y is total number of charaters not used
Function ReadPrinterInfo(x,y)
	strReadLine = objFile.ReadLine
	strReadLineLength = (Len(strReadLine) - y)
	ReadPrinterInfo = Mid(strReadLine, x, strReadLineLength)
End Function
	

Function GetDriver()
	strReadLine2 = objFile2.ReadLine
	strReadLineLengh3 = strReadLineLegnth + 21
	strReadLineLength2 = (Len(strReadLine2)-strReadLineLengh3)
	GetDriver = Mid(strReadLine2, strReadLineLengh3 + 1, strReadLineLength2)
End Function


Function createPort (Name, IP)

	objNewPort.Name = Name
	objNewPort.Protocol = 1
	objNewPort.HostAddress = IP
	objNewPort.SNMPEnabled = False
	objNewPort.Put_

End Function


Function addPrinter (driver, port, name)

	objPrinter.DriverName = driver
	objPrinter.PortName = port
	objPrinter.DeviceID = name
	objPrinter.Network = True
	objPrinter.Shared = True
	objPrinter.ShareName = name
	objPrinter.Put_

End Function

Function SkipLines(j)
	Do until j = 0
		objFile.SkipLine
		j = j -1
	Loop
End Function

Function SkipLines2(k)
	Do until k = 0
		objFile2.SkipLine
		k = k - 1
	Loop
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top