顯示具有 VBScript 標籤的文章。 顯示所有文章
顯示具有 VBScript 標籤的文章。 顯示所有文章

2008年3月20日 星期四

用Vbscript 改檔名

Set objFSO = CreateObject("Scripting.FileSystemObject")
SourceFile=Server.MapPath("c:/test.asp") '要改的原始檔
TargetFile=Server.MapPath("c:/test1.asp") '新的檔名
objFSO.MoveFile SourceFile, TargetFile

在DTS中使用Activex 工作處理檔案

'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************

Function Main()
dim fs,strfullpath,f
set fs=createobject("Scripting.FileSystemObject")
if (fs Is Nothing) then

Main=DTSTaskExecResult_Failure
'msgbox "1"
exit function

end if
strfullpath="D:\SFBAFK\BISsys\DATA\lnctbtt.dat"
if not fs.fileexists(strfullpath) then

Main=DTSTaskExecResult_Failure
'msgbox "2"
set fs=nothing
exit function
end if

Set f = fs.GetFile(strfullpath)


if f.size =0 then

Main=DTSTaskExecResult_Failure
'msgbox ""
set fs=nothing
exit function
end if
set fs=nothing
'msgbox "4"
'Main=DTSTaskExecResult_Failure
Main=DTSTaskExecResult_Success
End Function

在DTS中使用Active 工作執行DTS

'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************

Function Main()

dtsname="ImportBISTwd"
usrname="sa"
servername="MA03XXBXX"
pwd="sapwd"
DTSSQLStgFlag_Default2=0


dim objDTSPackage
dim objDTSStep
dim strResult
dim blnSucceeded

const DTSSQLStgFlag_Default = 0
const DTSStepExecResult_Failure = 1

set objDTSPackage = CreateObject("DTS.Package")

objDTSPackage.LoadFromSQLServer servername, usrname, pwd, DTSSQLStgFlag_Default2, "", "", "", dtsname
objDTSPackage.Execute

Main = DTSTaskExecResult_Success
End Function