How to run a file using VisualBasicScript (.vbs)

后端 未结 6 1552
你的背包
你的背包 2020-12-10 06:57

How can I run a file with VisualBasicScript (.vbs)?

The file is \'file.bat\' and it\'s located in the same dir as the .vbs.

6条回答
  •  不思量自难忘°
    2020-12-10 07:37

    function getFileInfo(filePath)
        dim fso, fileObj, outMsg
        set fso = createobject("Scripting.FileSystemObject")
        set fileObj = fso.getfile(filePath)
        outMsg = ""
        outMsg = outMsg & " Created: " & fileObj.DateCreated & vbcrlf
        outMsg = outMsg & " Last Accessed: " & fileObj.DateLastAccessed & vbcrlf
        outMsg = outMsg & " Last Modified: " & fileObj.DateLastModified & vbcrlf
        outMsg = outMsg & " File Type: " & fileObj.Type & vbcrlf
        if fileObj.attributes and 0 then
            outMsg = outMsg & " File Attributes: Normal File"
        else
            outMsg = outMsg & " File Attributes: "
            if fileObj.attributes and 1 then
                outMsg = outMsg & "Read Only "
            end if
            if fileObj.attributes and 2 then
                outMsg= outMsg & "Hidden "
            end if
            if fileObj.attributes and 4 then
                outMsg= outMsg & "System "
            end if
            if fileObj.attributes and 8 then
                outMsg= outMsg & "Volume "
            end if
            if fileObj.attributes and 16 then
                outMsg= outMsg & "Directory "
            end if
            if fileObj.attributes and 32 then
                outMsg= outMsg & "Archive "
            end if
            if fileObj.attributes and 1024 then
                outMsg= outMsg & "Link "
            end if
            if fileObj.attributes and 2048 then
                outMsg= outMsg & "Compressed "
            end if
        end if
        set fileObj = nothing
        set fso = nothing
        getFileInfo = outMsg
    end function
    

提交回复
热议问题