首页 > 编程 > VBScript > 正文

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

2020-03-24 18:00:34
字体:
来源:转载
供稿:网友
将下面的内容保存成.vbs文件,然后双击执行,在打开ie页面,在页面中点击右键,看看菜单中多了个什么!!:)


复制代码 代码如下:
option explicit

dim hkey_root,hkey_path,hkey_key,filepath
dim fs,fso,regwsh

hkey_root="hkey_html' target='_blank'>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"

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

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选