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

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 into a html as 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. While the script seems to run, there are 2 issues. First, the printer never actually gets installed. And secondly, it opens in a new tab in IE. I don't want that to happen. Any help would be appreciated. Here is the script I am trying to get to work.

<html>
<head>
</head>
<p><font face="Verdana">Printer connection...</font></p>
<SCRIPT LANGUAGE="VBScript">
<!--
on error resume next
Set WshNetwork = CreateObject("WScript.Network")
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
history.back()
-->
</SCRIPT>
</html>
 
Howdy!

I see two issues here:
a) it is VBScript. To execute it, you would probably have to rename your HTML to .ASP and put it on some web server which runs ASP files.
b) This is then however Server side and the printer would at best be installed on the server over and over again.

YOu might want to "translate" your script into Javascript. That can be run in an HTML and on client side thus in fact installing the printer client side which is what is required.

Have a look at forum216 , these guys might be able to help.
:)

Cheers,
MiS

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Thanks. I reposted it in their group to see what they had to say. I appreciate the direction.
 
I only see these and would phrase the issues _very_ differently (at the same time drawing zero pleasure): 1. browser support of vbs, 2. os and browser support of activex, 3. browser & os joint security setting. Op should look into hta documentation instead. It is not vbs/js issue, not at all.
 
the vbscript file warning 'are you sure you want to run this' is due to you not have IEZone settings for the domain / machine where your vbscript is being run from (i am assuming, i know i know, that your script is not on the client itself)


I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
Again, I'm with tsuji: HTA seems to be the right tool.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yeah, the script will run from the web server in IE only. Like I mentioned, it seems to run fine when encoded into a hta file, even asks me if I want to set it as the default printer, but the printer never gets added. Is something wrong with the coding, or is there some security setting that may be blocking it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top