华域联盟 vbs 利用vbs脚本实现设置IE的打印页眉页脚信息

利用vbs脚本实现设置IE的打印页眉页脚信息

将下面的内容保存成.vbs文件,然后双击执行,在打开ie页面,在页面中点击右键,看看菜单中多了个什么!!:) 

    
复制代码 代码如下:

option explicit 

    dim hkey_root,hkey_path,hkey_key,filepath 

    dim fs,fso,regwsh 

    hkey_root="hkey_current_user" 

    hkey_path="\software\microsoft\internet explorer" 

    //先创建文件 

    set fs=wscript.createobject("scripting.filesystemobject") 

    filepath="c:\pagesetup_default.htm" 

    set fso=fs.createtextfile(filepath,true) 

    fso.write("<script language=""vbscript"">"+vbcrlf _ 

            +"dim hkey_root,hkey_path,hkey_key,filepath,regwsh" +vbcrlf _ 

            +"hkey_root=""hkey_current_user""" +vbcrlf _ 

            +"hkey_path=""\software\microsoft\internet explorer""" +vbcrlf _ 

            +"filepath=""c:\pagesetup_null.htm""" +vbcrlf _ 

            +"//设置网页打印的页眉页脚为默认值"+vbcrlf  _ 

            +"set regwsh = createobject(""wscript.shell"")" +vbcrlf _ 

            +"hkey_key=""\pagesetup\header""" +vbcrlf _ 

            +"regwsh.regwrite hkey_root+hkey_path+hkey_key,""&w&b页码:&p/&p""" +vbcrlf _ 

            +"hkey_key=""\pagesetup\footer""" +vbcrlf _ 

            +"regwsh.regwrite hkey_root+hkey_path+hkey_key,""&u&b&d""" +vbcrlf _ 

            +"//设置右键菜单上的显示文字" +vbcrlf _ 

            +"//首先删除原来的项,然后再设置新的项"+vbcrlf  _ 

            +"on error resume next" +vbcrlf _ 

            +"hkey_key=hkey_root+hkey_path+""\menuext\打印时恢复页眉页脚\""" +vbcrlf _ 

            +"regwsh.regdelete hkey_key" +vbcrlf _ 

            +"hkey_key=hkey_root+hkey_path+""\menuext\打印时去掉页眉页脚\""" +vbcrlf _ 

            +"regwsh.regwrite hkey_key,filepath" +vbcrlf _ 

            +"//关闭regwsh" +vbcrlf _ 

            +"set regwsh=nothing"+vbcrlf  _ 

        +"</script>") 

    fso.close 

    filepath="c:\pagesetup_null.htm" 

    set fso=fs.createtextfile(filepath,true) 

    fso.write("<script language=""vbscript"">" +vbcrlf _ 

            +"dim hkey_root,hkey_path,hkey_key,filepath,regwsh" +vbcrlf _ 

            +"hkey_root=""hkey_current_user""" +vbcrlf _ 

            +"hkey_path=""\software\microsoft\internet explorer""" +vbcrlf _ 

            +"filepath=""c:\pagesetup_default.htm""" +vbcrlf _ 

            +"//设置网页打印的页眉页脚为空" +vbcrlf _ 

            +"set regwsh =createobject(""wscript.shell"")" +vbcrlf _ 

            +"hkey_key=""\pagesetup\header""" +vbcrlf _ 

            +"regwsh.regwrite hkey_root+hkey_path+hkey_key,""""" +vbcrlf _ 

            +"hkey_key=""\pagesetup\footer""" +vbcrlf _ 

            +"regwsh.regwrite hkey_root+hkey_path+hkey_key,""""" +vbcrlf _ 

            +"//设置右键菜单上的显示文字" +vbcrlf _ 

            +"//首先删除原来的项,然后再设置新的项" +vbcrlf _ 

            +"on error resume next"+vbcrlf  _ 

            +"hkey_key=hkey_root+hkey_path+""\menuext\打印时去掉页眉页脚\""" +vbcrlf _ 

            +"regwsh.regdelete hkey_key"+vbcrlf  _ 

            +"hkey_key=hkey_root+hkey_path+""\menuext\打印时恢复页眉页脚\""" +vbcrlf _ 

            +"regwsh.regwrite hkey_key,filepath" +vbcrlf _ 

            +"//关闭regwsh" +vbcrlf _ 

            +"set regwsh=nothing"+vbcrlf  _ 

        +"</script>") 

    fso.close 

    set regwsh=wscript.createobject("wscript.shell") 

    hkey_key=hkey_root+hkey_path+"\menuext\打印时去掉页眉页脚\" 

    regwsh.regwrite hkey_key,"c:\pagesetup_null.htm" 

以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! 
您可能感兴趣的文章:

本文由 华域联盟 原创撰写:华域联盟 » 利用vbs脚本实现设置IE的打印页眉页脚信息

转载请保留出处和原文链接:https://www.cnhackhy.com/14389.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部