利用vbs脚本实现设置IE的打印页眉页脚信息
利用vbs脚本实现设置IE的打印页眉页脚信息
发布时间:2016-12-28 来源:查字典编辑
摘要:将下面的内容保存成.vbs文件,然后双击执行,在打开ie页面,在页面中点击右键,看看菜单中多了个什么!!:)复制代码代码如下:optione...

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

复制代码 代码如下:

optionexplicit

dimhkey_root,hkey_path,hkey_key,filepath

dimfs,fso,regwsh

hkey_root="hkey_current_user"

hkey_path="softwaremicrosoftinternetexplorer"

//先创建文件

setfs=wscript.createobject("scripting.filesystemobject")

filepath="c:pagesetup_default.htm"

setfso=fs.createtextfile(filepath,true)

fso.write("<scriptlanguage=""vbscript"">"+vbcrlf_

+"dimhkey_root,hkey_path,hkey_key,filepath,regwsh"+vbcrlf_

+"hkey_root=""hkey_current_user"""+vbcrlf_

+"hkey_path=""softwaremicrosoftinternetexplorer"""+vbcrlf_

+"filepath=""c:pagesetup_null.htm"""+vbcrlf_

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

+"setregwsh=createobject(""wscript.shell"")"+vbcrlf_

+"hkey_key=""pagesetupheader"""+vbcrlf_

+"regwsh.regwritehkey_root+hkey_path+hkey_key,""&w&b页码:&p/&p"""+vbcrlf_

+"hkey_key=""pagesetupfooter"""+vbcrlf_

+"regwsh.regwritehkey_root+hkey_path+hkey_key,""&u&b&d"""+vbcrlf_

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

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

+"onerrorresumenext"+vbcrlf_

+"hkey_key=hkey_root+hkey_path+""menuext打印时恢复页眉页脚"""+vbcrlf_

+"regwsh.regdeletehkey_key"+vbcrlf_

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

+"regwsh.regwritehkey_key,filepath"+vbcrlf_

+"//关闭regwsh"+vbcrlf_

+"setregwsh=nothing"+vbcrlf_

+"</script>")

fso.close

filepath="c:pagesetup_null.htm"

setfso=fs.createtextfile(filepath,true)

fso.write("<scriptlanguage=""vbscript"">"+vbcrlf_

+"dimhkey_root,hkey_path,hkey_key,filepath,regwsh"+vbcrlf_

+"hkey_root=""hkey_current_user"""+vbcrlf_

+"hkey_path=""softwaremicrosoftinternetexplorer"""+vbcrlf_

+"filepath=""c:pagesetup_default.htm"""+vbcrlf_

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

+"setregwsh=createobject(""wscript.shell"")"+vbcrlf_

+"hkey_key=""pagesetupheader"""+vbcrlf_

+"regwsh.regwritehkey_root+hkey_path+hkey_key,"""""+vbcrlf_

+"hkey_key=""pagesetupfooter"""+vbcrlf_

+"regwsh.regwritehkey_root+hkey_path+hkey_key,"""""+vbcrlf_

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

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

+"onerrorresumenext"+vbcrlf_

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

+"regwsh.regdeletehkey_key"+vbcrlf_

+"hkey_key=hkey_root+hkey_path+""menuext打印时恢复页眉页脚"""+vbcrlf_

+"regwsh.regwritehkey_key,filepath"+vbcrlf_

+"//关闭regwsh"+vbcrlf_

+"setregwsh=nothing"+vbcrlf_

+"</script>")

fso.close

setregwsh=wscript.createobject("wscript.shell")

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

regwsh.regwritehkey_key,"c:pagesetup_null.htm"

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

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新vbs学习
热门vbs学习
脚本专栏子分类