DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   HTML and CSS (http://www.daniweb.com/forums/forum143.html)
-   -   windows script host - help me pls (http://www.daniweb.com/forums/thread70620.html)

jamello Feb 21st, 2007 12:00 pm
windows script host - help me pls
 
: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

MattEvans Feb 22nd, 2007 4:31 am
Re: windows script host - help me pls
 
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.

jamello Feb 27th, 2007 6:39 am
Re: windows script host - help me pls
 
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


Quote:

Originally Posted by MattEvans (Post 318787)
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.



All times are GMT -4. The time now is 4:10 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC