windows script host - help me pls

Reply

Join Date: Oct 2006
Posts: 216
Reputation: jamello is an unknown quantity at this point 
Solved Threads: 6
jamello's Avatar
jamello jamello is offline Offline
Posting Whiz in Training

windows script host - help me pls

 
0
  #1
Feb 21st, 2007
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.

<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
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

Re: windows script host - help me pls

 
0
  #2
Feb 22nd, 2007
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.
Plato forgot the nullahedron..
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 216
Reputation: jamello is an unknown quantity at this point 
Solved Threads: 6
jamello's Avatar
jamello jamello is offline Offline
Posting Whiz in Training

Re: windows script host - help me pls

 
0
  #3
Feb 27th, 2007
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


Originally Posted by MattEvans View Post
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC