0

:confused: I have a challenge. I want to print some text based data on the client client side based on some input. I am to associate the client printer as a dos device ie LPT2 using window script host technologies but cannot just make it work. What am I doing wrong? Pls help! below is the example of what I want to do. If this can work I can implement for required scenarios.:confused: :confused: :confused:

<script language="VBScript">
sub doInitialise()
dim objPrinter, objFS, objWSHNet
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objWSHNet = CreateObject("WScript.Network")


// ' Connect to Network Printer from Windows Script Host
objWSHNet.AddPrinterConnection "LPT2", "\\TESTBENCH\TicketPr"

// ' Open Print device as a file using the File System Object
Set objPrinter = objFS.CreateTextFile("LPT2:", True)
// ' Send text to print device using the File System Object
// '
objPrinter.Write("This is a test print to the ticket printer.")

objWSHNet.RemovePrinterConnection "LPT2:"
set objWSHNet = nothing
end sub

2
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by jamello
0

Do you really think VB script in a browser is going to be allowed unrestricted access to the FileSystemObject? Or any kind of file/network interface access for that matter.

That might work as a desktop VBScript application; but I'm sure even I.E would notice you're trying to do something potentially dangerous if you put that on a webpage.

I know you're just trying to print and it seems quite harmless, but if IE allowed you, as a web developer, to have access to a user's filesystem or the windows script host, it wouldn't be able to reliably stop you doing what you pleased with either of them. Because of that, you'll likely find that attempting to access either of them on any level is made illegal.

0

Y'know you are right! I was looking at a sample code in a particular tutoial and was not looking close enough. I tired those same codes as a server side script and it responded without errors. Though the response is not yet want I want but at least I have some light. I am still working on it and I am sure it would be solved. thanks. Do yuou know of any web site I can have a complete tutorial on windows script host? Thanks

Do you really think VB script in a browser is going to be allowed unrestricted access to the FileSystemObject? Or any kind of file/network interface access for that matter.

That might work as a desktop VBScript application; but I'm sure even I.E would notice you're trying to do something potentially dangerous if you put that on a webpage.

I know you're just trying to print and it seems quite harmless, but if IE allowed you, as a web developer, to have access to a user's filesystem or the windows script host, it wouldn't be able to reliably stop you doing what you pleased with either of them. Because of that, you'll likely find that attempting to access either of them on any level is made illegal.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.