Link to home
Start Free TrialLog in
Avatar of Tek Info
Tek Info

asked on

Opening a gif file within a bat file

I would like to within a .bat file open a .gif file so that it displays for perhaps 5 seconds and then exits.
how can this be incorporated into a .bat script?
Avatar of Hello There
Hello There

This should work.
C:\Users\tek.info\Desktop\something.gif
timeout /t 5 /nobreak > NUL
taskkill /f /im dllhost.exe

Open in new window

Avatar of Tek Info

ASKER

It opens the gif but the gif stays open after the script ends.
What app do you use to open it? You need to kill the process that opens the .gif file so edit the last line.
@Tek Info,

What are you really trying to accomplish here?  Opening an image file with either a specified application, or using the default, is likely to not be very "pretty".  Depending on the program doing the displaying, and perhaps the last state it was closed in (maximized, etc) then I suspect it may not give you the effect you want.

Just want to understand how you want it to work, what the image will represent, what else will be happening on the computer at the same time, etc.  It may be that you are better off using a free "installer" type utility, like Inno Setup.

Or perhaps a Windows Scripting Host HTA file with a bit more of a UI to it where you can display info during the process, and an image it you want, etc.

Just brainstorming a bit...


»bp
Hi Bill.
During the execution of a script, while the user is waiting for the script to end I wanted a .gif file to pop up on their screen up until the script ends.
Does this help?
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Bill Prew

Hi Bill,
Yes this is a very good start.
I would probably minimize the bat file which is running.
Perhaps I can incorporate the bat commands in my bat script and then hopefully when my bat file ends it will kill the script and the gif image as well.
Glad that was helpful.

Feel free to experiment, but I think since we launch the PS script with the START command when you end the BAT script it won't kill the PS process.


»bp
@Bill Prew
Works very well actually.. thanks a lot.
One last request..
Can I position the gif somewhere specifically on the page?
Currently it's overlapping another message popup...
Yes, you can position.  Here are a couple of examples, and if you search for something like "powershell position form" you can probably get some other examples.

Here's an addition to center the form on the screen (although on my system it seems to be a little low on the screen, but try it), and then commented out right below that is an alternative where you can specify pixel offsets (just be aware screen sizes vary from system to system).


Add-Type -AssemblyName System.Windows.Forms
$pic =  New-Object System.Windows.Forms.PictureBox
$pic.BackColor = [System.Drawing.Color]::Transparent
$pic.Dock = [System.Windows.Forms.DockStyle]::Fill
$pic.SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::AutoSize
$pic.ImageLocation = ".\wait.gif"
$form = New-Object System.Windows.Forms.Form
$form.Text = "Processing..."
$form.AutoSize=$true
$form.AutoSizeMode= "GrowAndShrink"
$form.StartPosition = "CenterScreen"
# $form.StartPosition = "Manual"
# $form.Location = "300,300"
$form.Controls.Add($pic)
$form.ShowDialog() | Out-Null
$form.Dispose()

Open in new window


»bp
Thank you Bill, works great especially after the tweak with the positioning of the gif.
Many thanks.
Welcome, glad that was useful.


»bp