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

2019-01-16 12:23:15王旭

    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=""softwaremicrosoftinternet explorer""" +vbcrlf _ 
            +"filepath=""c:pagesetup_default.htm""" +vbcrlf _ 
            +"//设置网页打印的页眉页脚为空" +vbcrlf _ 
            +"set regwsh =createobject(""wscript.shell"")" +vbcrlf _ 
            +"hkey_key=""pagesetupheader""" +vbcrlf _ 
            +"regwsh.regwrite hkey_root+hkey_path+hkey_key,""""" +vbcrlf _ 
            +"hkey_key=""pagesetupfooter""" +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