利用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"

以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3