vbscript调用fso
function getVersion(strPath)
Dim fver, fso
Set fso = CreateObject("Scripting.FileSystemObject")
fver = fso.GetFileVersion(strPath)
getVersion=fver
end function
sub saveResult(strOutPath,str)
Dim fver, fso
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set fileObj = fso.opentextfile(strOutPath+"\\version.xml",2,true) '使用FSO创建文件写入对象
fileObj.Write str '向文件写入数据,覆盖形式写入
fileObj.close '推送内容写入并关闭写入通道
end sub
'Create an arguments object
Dim oArgs
Set oArgs = WScript.Arguments
'Get the named arguments
Dim oNamed
Set oNamed = oArgs.Named
'Get the computer name argument
Dim strPath
strPath = oNamed("strPath")
Dim strOutPath
strOutPath = oNamed("outPath")
dim tmp
tmp=getVersion(strPath+"\\install.exe")
tmp=tmp+"test"
msgbox tmp
saveResult strOutPath, tmp
msgbox strOutPath
dos命令行中:
CScript "getFileVer.vbs" /strPath:C:\ /outPath:c:\