start = Now
WScript.Echo("Start:" & start)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_DataFile where Extension = 'mp3' OR Extension = 'wma'")
For Each objFile in colFiles
Wscript.echo(objFile.Caption)
'objFile
'objFile.Delete
Next
finish = Now
WScript.Echo("Finish:" & finish)
WScript.Echo("Cost:" & DateDiff("n",start,finish))
Jan 23, 2008
自訂副檔名搜尋
SearchFileByExt.vbs
vbscript 版 wget
PingList.vbs
<package>
<job>
<runtime>
<named
name="SourceUrl"
helpstring="HTTP檔案位址"
type="string"
required="true"
/>
<named
name="DestinationFile"
helpstring="儲存檔案位址"
type="string"
required="true"
/>
<example>
Example : wget /SourceUrl:"http://xxx/xxx.exe" /DestinationFile:"C:\Documents and Settings\All Users\桌面\xxx.exe"
</example>
<description>
用途:下載Web檔案
版本:1.0
作者:Parkghost</description>
</runtime>
<SCRIPT language="VBScript">
If WScript.Arguments.Named.Exists("SourceUrl") And WScript.Arguments.Named.Exists("DestinationFile") Then
strUrl = WScript.Arguments.Named.Item("SourceUrl")
strFile = WScript.Arguments.Named.Item("DestinationFile")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const ForWriting = 2
Dim web, varByteArray, strData, strBuffer, lngCounter, ado
Err.Clear
Set web = Nothing
Set web = CreateObject("WinHttp.WinHttpRequest.5.1")
If web Is Nothing Then Set web = CreateObject("WinHttp.WinHttpRequest")
If web Is Nothing Then Set web = CreateObject("MSXML2.ServerXMLHTTP")
If web Is Nothing Then Set web = CreateObject("Microsoft.XMLHTTP")
web.Open "GET", strURL, False
web.Send
If Err.Number <> 0 Then
SaveWebBinary = False
Set web = Nothing
WScript.Quit
End If
If web.Status <> "200" Then
SaveWebBinary = False
Set web = Nothing
WScript.Quit
End If
varByteArray = web.ResponseBody
Set web = Nothing
'Save the file
'On Error Resume Next
Set ado = Nothing
Set ado = CreateObject("ADODB.Stream")
If ado Is Nothing Then
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(strFile, ForWriting, True)
strData = ""
strBuffer = ""
For lngCounter = 0 to UBound(varByteArray)
ts.Write Chr(255 And Ascb(Midb(varByteArray,lngCounter + 1, 1)))
Next
ts.Close
Else
ado.Type = adTypeBinary
ado.Open
ado.Write varByteArray
ado.SaveToFile strFile, adSaveCreateOverWrite
ado.Close
End If
SaveWebBinary = True
Else
WScript.Arguments.ShowUsage()
End if
</SCRIPT>
</job>
</package>
解決vbscript len function 無法判斷 double byte 字元
strText = ("中文123")
WScript.Echo(strText & ":" & Len(strText))
WScript.Echo(strText & ":" & newLen(strText))
Function newLen(text)
oldlen = Len(text)
newLen = 0
For i = 1 To oldlen
If Asc(Mid(text,i,1)) > 0 Then
newLen = newLen + 1
Else
newLen = newLen + 2
End If
Next
End Function
網路連線測式(Ping by List)
PingList.vbs
ipList.xml
Msg = "站點" & vbTab & paddingStr("位址",27) & vbTab & paddingStr("IP",15) & vbTab & "回應時間" & vbNewLine Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set objXML = CreateObject("Microsoft.XMLDOM") objXML.async = False objXML.Load "ipList.xml" If objXML.parseError.errorCode <> 0 Then WScript.Echo("設定檔載入錯誤") End If Set objList = objXML.getElementsByTagName("*") Set nodes = objList.item(i).selectSingleNode("//site").childNodes For Each node In nodes Dim ProtocolAddress Dim ResponseTime Set objNamedNodeMap = node.attributes Set objPing = objWMIService.ExecQuery("select * from Win32_PingStatus where address = '" & node.text & "'") For Each objStatus in objPing ProtocolAddress = objStatus.ProtocolAddress ResponseTime = objStatus.ResponseTime Next Msg = Msg & objNamedNodeMap.item(0).text & vbTab & paddingStr(node.text,25) & vbTab & paddingStr(ProtocolAddress,15) & vbTab & ResponseTime & vbNewLine Next WScript.Echo(Msg) Function paddingStr(str,lenght) If Len(str) > lenght then paddingStr = str Else 'todo:double byte analysis paddingStr = str & Space(lenght - Len(str)) End If End Function
ipList.xml
<?xml version="1.0" encoding="big5"?> <site> <item name="HiNet">www.hinet.net</item> <item name="Yahoo">tw.yahoo.com</item> <item name="Pchome">www.pchome.com</item> </site>
May 12, 2007
Ldap Install Guide
yum install openldap-servers.i386 openldap-devel openldap-clients compat-openldap
#加入Samba.schema
cd /etc/openldap/schema
wget http://www.samba.org/cgi-bin/cvsweb/samba/examples/LDAP/samba.schema?rev=1.1.4.1
mv samba.schema?rev=1.1.4.1 samba.schema
#編輯ldap設定檔
vi /etc/openldap/slapd.conf
#slapd.conf #add
include /etc/openldap/schema/samba.schema
#取得加密密碼
slappasswd -s root-dn-passwd {SSHA}F+zPYmGidD3HdO5eO3aidWTKjaRZDsUe
#modify
suffix "dc=im,dc=nuu,dc=edu,dc=tw" rootdn "cn=Manager,dc=im,dc=nuu,dc=edu,dc=tw" rootpw {SSHA}n9G1cmwcsikHDF1OAByZzrjr1f836S3i
#chown
chown -R ldap:ldap /var/lib/ldap/
#TLS
./CA -newcert
./CA –newca
openssl req -new -nodes -keyout newreq.pem -out newreq.pem
./CA -sign
mkdir /etc/openldap/ssl
mv demoCA/cacert.pem /etc/openldap/ssl
mv newcert.pem /etc/openldap/ssl/servercrt.pem
mv newreq.pem /etc/openldap/ssl/serverkey.pem
chown ldap:ldap /etc/openldap/ssl/serverkey.pem
chmod 600 /etc/openldap/ssl/serverkey.pem
scp /etc/openldap/ssl/cacert.pem
root@203.64.178.106:/etc/openldap/ssl/cacert.pem
在客戶端的/etc/openldap/ldap.conf 中加入
TLS_CACERT /etc/openldap/ssl/cacert.pem ,
注意此文件時從服務器上生成的。
Subscribe to:
Posts (Atom)