Click here to Skip to main content
15,038,345 members

S Douglas - Professional Profile


    Blog RSS
Just another hack, who manages to take care of issues that would otherwise go unsolved. Smile | :)



Weekly Data. Recent events may not appear immediately. For information on Reputation please see the FAQ.


Members need to achieve at least one of the given member levels in the given reputation categories in order to perform a given action. For example, to store personal files in your account area you will need to achieve Platinum level in either the Author or Authority category. The "If Owner" column means that owners of an item automatically have the privilege. The member types column lists member types who gain the privilege regardless of their reputation level.

ActionAuthorAuthorityDebatorEditorEnquirerOrganiserParticipantIf OwnerMember Types
Have no restrictions on voting frequencysilversilversilversilver
Bypass spam checks when posting contentsilversilversilversilversilversilvergoldSubEditor, Mentor, Protector, Editor
Store personal files in your account areaplatinumplatinumSubEditor, Editor
Have live hyperlinks in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Have the ability to include a biography in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Edit a Question in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Edit an Answer in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Delete a Question in Q&AYesSubEditor, Protector, Editor
Delete an Answer in Q&AYesSubEditor, Protector, Editor
Report an ArticlesilversilversilversilverSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending ArticlegoldgoldgoldgoldSubEditor, Mentor, Protector, Editor
Edit other members' articlesSubEditor, Protector, Editor
Create an article without requiring moderationplatinumSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending QuestionProtector
Approve/Disapprove a pending AnswerProtector
Report a forum messagesilversilverbronzeProtector, Editor
Approve/Disapprove a pending Forum MessageProtector
Create a new tagsilversilversilversilver
Modify a tagsilversilversilversilver

Actions with a green tick can be performed by this member.

GeneralRe: Code formatting Pin
S Douglas21-Feb-09 9:20
professionalS Douglas21-Feb-09 9:20 
GeneralWhats happening Pin
S Douglas21-Feb-09 13:13
professionalS Douglas21-Feb-09 13:13 
GeneralHEHE Pin
S Douglas21-Feb-09 13:15
professionalS Douglas21-Feb-09 13:15 
GeneralMap printer, vbscript Pin
S Douglas23-Jan-09 19:11
professionalS Douglas23-Jan-09 19:11 
GeneralDelete files, vbscript Pin
S Douglas23-Jan-09 19:07
professionalS Douglas23-Jan-09 19:07 
GeneralAnother Script Pin
S Douglas23-Jan-09 19:00
professionalS Douglas23-Jan-09 19:00 
GeneralWOOT - New Job Pin
S Douglas23-Jan-09 18:55
professionalS Douglas23-Jan-09 18:55 
Generalvbscript and errors Pin
S Douglas26-Jun-08 7:32
professionalS Douglas26-Jun-08 7:32 
I've been doing a little scripting lately, really some simple automation stuff like mapping an IP printer to a user’s machine. Below is an error message that through me off for quite some time.

<br />
---------------------------<br />
Windows Script Host<br />
---------------------------<br />
Script:	Add.Printer.vbs<br />
Error:	Generic failure <br />
Code:	80041001<br />
Source: 	SWbemObjectEx<br />
<br />
---------------------------<br />
OK   <br />
---------------------------<br />

What is a very generic error is really a simple problem. The root of the problem is that I created the port with one name and tried to add the printer with a second name. Understandably it errored out, but a slightly more meaningful error would have been helpful. Here is the script or most of it. The buisiness stuff has been stripped but it should be functional for those who want to know how to create printer ports, load printer device drivers, and add printers.

Option Explicit
'*** Printer Script by S Douglas					***'
'*** Contact add a message to the board				***' 
'*** No warranties express or implied use at your own risk	***' 
'*** You are free to use as you see fit 					***'
' Requirements as defined by Ricky 06/20/2008
' 1: Install the "Brother PCL5e Driver" Printer driver
' 2. Create a port for a network based printer, "IP_xxxx"
' 3. Add the printer to the local machine "Store- Store Num Brother Printer

Call Main()

'*** Start script ***' SFD 06.25.2008
Sub Main()
On Error Resume Next
Dim sIP, sNum

		'sIP = CalcIP(sNum) // Function Removed, set sIP to the ip you want to use
		'sNum = reference number
		if Len(sIP) > 0 Then
			if Not InstallDriver("Brother PCL5e Driver", "BHPCL5E.INF") Then
				Call CreatePort("IP_" & sNum, sIP)
				Call AddPrinter("Brother PCL5e Driver", "IP_" & sNum, "Store-" &  sNum & " Brother Laser Printer" )
				MsgBox "Finished! Printer Name: " & vbNewLine & "Store-" &  sNum & " Brother Laser Printer" 
				MsgBox "Error! Unable to Install the print driver"
			End If
			MsgBox "Error! Unable to calculate the Printers IP Address"
		End If

'*** Error Handling ***'
If Err.Number <> 0 Then
	Call ErrorHandling("Unresolved Error in script ", Err.Number, Err.Description)
End If
End Sub

'*** Create the network port to mapp the printer to when adding the printer *** ' SFD 06.25.2008
Sub CreatePort (name, ip)
On Error Resume Next
Dim objWMIService, objNewPort

	Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
	Set objNewPort = objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_

    objNewPort.Name = name
    objNewPort.Protocol = 1
    objNewPort.HostAddress = ip
    objNewPort.SNMPEnabled = False
	Set objNewPort = Nothing
	Set objWMIService = Nothing
'*** Error Handling ***'
If Err.Number <> 0 Then
	Call ErrorHandling("Creating the network port ", Err.Number, Err.Description)
End If	
end sub

'*** Add the printer, based on the information provided thus far  *** ' SFD 06.25.2008
Function AddPrinter (sDriver, sPort, sName)
On Error Resume Next
Dim objWMIService, objPrinter
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

	objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True
	Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

	objPrinter.DriverName = sDriver 
	objPrinter.PortName = sPort 
	objPrinter.DeviceID = sName
	objPrinter.Location = ""
	objPrinter.Network = True

	Set objWMIService =  Nothing
	Set objPrinter = Nothing
'*** Error Handling ***'
If Err.Number <> 0 Then
	Call ErrorHandling("Adding the Printer ", Err.Number, Err.Description)
End If	
End Function

'*** Install the printer driver  *** ' SFD 06.25.2008
Function InstallDriver(sName, sINF)
On Error Resume Next
Dim objWMIService, objDriver, intResult 

	Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
	objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege",	True

	set objDriver = objWMIService.Get("Win32_PrinterDriver")

	objDriver.Name =  sName 
	objDriver.SupportedPlatform = "Windows NT x86"
	objDriver.FilePath = ".\\"
	objDriver.Infname = ".\\" & sINF
	intResult = objDriver.AddPrinterDriver(objDriver)
	InstallDriver = intResult
	Set objWMIService = Nothing
	Set objDriver     = Nothing
'*** Error Handling ***'
If Err.Number <> 0 Then
	Call ErrorHandling("Installing Printer Driver ", Err.Number, Err.Description)
End If
End Function

'*** Central error notification  *** ' SFD 06.25.2008
Sub ErrorHandling(sSub, sNum, sDes)
Dim sSupport
	sSupport = vbNewLine & vbNewLine & " Please contact support the following error message" & vbNewLine & vbNewLine

	Msgbox "Error - " & sSub _
			& sSupport _ 
			& " Error Number: " & sNum  & vbNewLine _
			& " Error Description: " & sDes & vbNewLine
End Sub

Common sense is admitting there is cause and effect and that you can exert some control over what you understand.

GeneralPSDK Links Pin
S Douglas1-May-08 18:12
professionalS Douglas1-May-08 18:12 
JokeTo Funny! Pin
S Douglas16-Apr-08 18:41
professionalS Douglas16-Apr-08 18:41 
GeneralIIS, .NET and ASP.NET Rant [modified] Pin
S Douglas1-Sep-07 11:39
professionalS Douglas1-Sep-07 11:39 
GeneralSubversion Pin
S Douglas24-Aug-07 13:00
professionalS Douglas24-Aug-07 13:00 
GeneralC# Pin
S Douglas22-Jun-07 8:10
professionalS Douglas22-Jun-07 8:10 
GeneralJust the standard memory issues Pin
S Douglas12-Jun-07 5:38
professionalS Douglas12-Jun-07 5:38 
GeneralCommunity Forums Pin
S Douglas5-Mar-07 20:28
professionalS Douglas5-Mar-07 20:28 
GeneralFisher Price Pin
S Douglas3-Feb-07 23:55
professionalS Douglas3-Feb-07 23:55 
GeneralNo title, just some aimless rambling. [modified] Pin
S Douglas27-Jan-07 23:32
professionalS Douglas27-Jan-07 23:32 
GeneralRe: No title, just some aimless rambling. Pin
Paul Conrad23-Apr-07 5:57
professionalPaul Conrad23-Apr-07 5:57 
GeneralRe: No title, just some aimless rambling. Pin
S Douglas24-Apr-07 1:23
professionalS Douglas24-Apr-07 1:23 
GeneralRe: No title, just some aimless rambling. Pin
Paul Conrad24-Apr-07 3:08
professionalPaul Conrad24-Apr-07 3:08 
GeneralNewer Truck Pin
S Douglas25-Dec-06 21:25
professionalS Douglas25-Dec-06 21:25 
GeneralWhat's happening Pin
S Douglas20-Dec-06 0:03
professionalS Douglas20-Dec-06 0:03 
GeneralFirst Post Pin
S Douglas3-Dec-06 13:35
professionalS Douglas3-Dec-06 13:35 
GeneralVS2005 & C++ Pin
S Douglas26-Nov-06 15:05
professionalS Douglas26-Nov-06 15:05 
GeneralRemembrance Pin
S Douglas13-Nov-06 1:01
professionalS Douglas13-Nov-06 1:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.