Need a VBScript for Open a local Image File by using Command prompt

后端 未结 1 1974
我寻月下人不归
我寻月下人不归 2020-12-21 10:14

I need a Vbscript that should open a image file from my PC and after some minutes that will get close automatically. I am planning to run the script through Command prompt a

相关标签:
1条回答
  • 2020-12-21 10:54

    It might be easier to do this with an HTML Application rather than plain VBScript. Here's a sample HTML app that display an image in a popup window that automatically closes after 5 seconds (you didn't say whether you needed to have the image name and the timeout parameterized, so I assume they are predefined and can be hard-coded):

    <html>
        <hta:application id="oHTA"
            border="none"
            caption="no"
            contextmenu="no"
            innerborder="no"
            scroll="no"
            showintaskbar="no"
        />
        <script language="VBScript">
            Sub Window_OnLoad
                ' Resize and position the window
                width = 500 : height = 400
                window.resizeTo width, height
                window.moveTo screen.availWidth\2 - width\2, screen.availHeight\2 - height\2
    
                ' Automatically close the windows after 5 seconds
                idTimer = window.setTimeout("vbscript:window.close", 5000)
            End Sub
        </script>
    <body>
        <table border=0 width="100%" height="100%">
            <tr>
                <td align="center" valign="middle">
                    <img src="myimage.jpg"/>
                </td>
            </tr>
        </table>
    </body>
    </html>
    

    Simply paste this code into a text editor, replace the window width and height, the timeout and the image file name with your values and save as an .HTA file (e.g. showimage.hta).

    HTAs can be run from command line by their name, e.g.

    showimage.hta
    

    To run an HTA from VBScript, you can use the WshShell.Run method:

    CreateObject("WScript.Shell").Run "showimage.hta"
    
    0 讨论(0)
提交回复
热议问题