1. include this javascript in header section of aspx page
<script language="vbscript" src="Defaultprinter.vbs" type="text/vbscript"></script>
<script language="javascript" type="text/javascript">
function printercall()
{
document.getElementById("<%=Put some ID here%>").value=Printertest();
}
</script>
2.We need to create a vbscript(Defaultprinter.vbs) that will access client pc default printer and call its method from javascript as mention above.In the same way you can access client PC drive as well.
Function Printertest()
Dim strKey, wshShell,printerreturn
' Create WScript Shell object to read the registry
Set wshShell = CreateObject( "WScript.Shell" )
' Read the current default printer from registry
strKey = "HKEY_CURRENT_USER\Software\Microsoft" _
& "\Windows NT\CurrentVersion\Windows\Device"
'msgbox(strKey)
printerreturn=Trim( Split( wshShell.RegRead( strKey ), "," )(0) )
msgbox (printerreturn)
' Release the Shell object
Set wshShell = Nothing
Printertest=printerreturn
End Function
3. call javascript usually as we call on button click or page load or as per ur wish.
btnPrint.Attributes.Add("OnClick", "printercall()");
Hope this help you.
<script language="vbscript" src="Defaultprinter.vbs" type="text/vbscript"></script>
<script language="javascript" type="text/javascript">
function printercall()
{
document.getElementById("<%=Put some ID here%>").value=Printertest();
}
</script>
2.We need to create a vbscript(Defaultprinter.vbs) that will access client pc default printer and call its method from javascript as mention above.In the same way you can access client PC drive as well.
Function Printertest()
Dim strKey, wshShell,printerreturn
' Create WScript Shell object to read the registry
Set wshShell = CreateObject( "WScript.Shell" )
' Read the current default printer from registry
strKey = "HKEY_CURRENT_USER\Software\Microsoft" _
& "\Windows NT\CurrentVersion\Windows\Device"
'msgbox(strKey)
printerreturn=Trim( Split( wshShell.RegRead( strKey ), "," )(0) )
msgbox (printerreturn)
' Release the Shell object
Set wshShell = Nothing
Printertest=printerreturn
End Function
3. call javascript usually as we call on button click or page load or as per ur wish.
btnPrint.Attributes.Add("OnClick", "printercall()");
Hope this help you.
Thanks for posting such a terrific site. this blog was not only knowledgeable but also very inventive too. There normally are a limited number of bloggers who can create technical stuff that creatively. we look for articles about a subject like this. I have gone in detail through many websites to find knowledge regarding this.Keep writing in !!
ReplyDeleteIt is super,it brings up super idea to mind..Thanks a lot AJAY and keep writing...
ReplyDeleteHow to add vb page to web application???
ReplyDelete