利用vbs脚本设置IE的打印页眉页脚信息(原创)
发表于:2007-06-30来源:作者:点击数:
标签:
将下面的内容保存成. vb s文件,然后双击执行,在打开ie页面,在页面中点击右键,看看菜单中多了个什么!!:) Option Explicit dim hkey_root,hkey_path,hkey_key,filePath dim fs,fso,RegWsh hkey_root=HKEY_CURRENT_USER hkey_path=\Software\Microsoft\I
将下面的内容保存成.
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\Inte
.net 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"
原文转自:http://www.ltesting.net