Guys,
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 any help is much appreciatable.
Guys,
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 any help is much appreciatable.
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"