Need VBScript to open a local image file using the command line

I need Vbscript, which should open the image file from my PC and in a few minutes, which will automatically close. I plan to run the script through the command line, any help is very noticeable.

+3
source share
1 answer

This might be easier to do with an HTML application rather than a simple VBScript. Here's an example HTML application that displays an image in a popup that automatically closes after 5 seconds (you didn’t say if you need to have an image name and a timeout, so I assume they are predefined and can be hardcoded):

<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>

, , .HTA(, showimage.hta).

HTAs ,

showimage.hta

HTA VBScript, WshShell.Run:

CreateObject("WScript.Shell").Run "showimage.hta"
+5

Source: https://habr.com/ru/post/1714195/


All Articles