On the standard web you can not do this. I'll tell you more about this on this answer .
With ActiveX it is possible but it only runs in Internet Explorer, a browser at the end of the line. The new browser from Microsoft is Edge, which will make IE receive much less attention, or even be almost abandoned.
Certainly there are other plugins to resolve the issue in other browsers , but it's something so complicated that it's not worth the effort. Remembering that it is rare for someone to install something just to access a site . People are already revolting themselves from having to install Java to access their bank.
An applet Java could do the same but trying to use what was stated in the question:
<!DOCTYPE html>
<html>
<head>
<title>Print Test</title>
<script language="VBScript">
sub Print()
OLECMDID_PRINT = 6
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_PROMPTUSER = 1
call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
End Sub
document.write "<object id='WB' width='0' height='0' classid='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"
</script>
</head>
<body>
<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"> </object>
<a href="#" onclick="Print()">Clique aqui para imprimir</a>
</body>
</html>
Retired from this answer in the SO .