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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbs to html or java script

Status
Not open for further replies.

nomad27

Technical User
Oct 20, 2010
4
US
Guys,

I have a working vb script that installs a printer and then asks if it should be set as the default printer. The script works great. However, I want to convert it so it is webpage friendly. I want this to run when someone clicks on a link. If I just use the file itself, it asks to run or save, than prompts the user if they are sure they want to run the script. I don't want any of that to happen. I want them to click the link and have it run, thats it. I originally posted this on another forum in here since I thought it could be simply converted to html, but someone there suggested it was better to try and get this to work in java script, so I wanted to repost it to you guys. Any help would be appreciated.

Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection "\\server\printer"
PrinterPath = "\\server\printer"
msg="Do you want " & PrinterPath & " to be Default printer?"
answ=msgbox(msg,vbYesNoCancel,"Add Printer")
If answ=vbYes then
WshNetwork.AddWindowsPrinterConnection PrinterPath
WshNetwork.SetDefaultPrinter PrinterPath
elseif answ=vbNo then
WshNetwork.AddWindowsPrinterConnection PrinterPath
end if
 
HTML is a static markup language, as as such it has no way of interacting with Windows or its printers in any way.

Javascript would have to make use of Activex controls which only work on IE and would have to be trusted or IE set to allow all activex controls, otherwise you'll get annoying pop-ups to confirm the user wants to install the activex control.

Added to that is the fact that VBscript is already Web friendly at least on IE.

If you are going to end up only catering to IE I would skip out the Javascript portion and just use your VB script directly, though you'll have to set IE to trust your script.








----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top