Solved

Need a simple batch-script to start and close software, with a time delay in between.

Posted on 2010-11-23
7
593 Views
Last Modified: 2012-05-10
I need a simple batch-script to open up an image in Internet Explorer (to display a warning). The IE-windows needs to be open for about 3-4 seconds before it automatically closes. After that I want another application to start.

How do I accomplish this?

As for the first line, it should look something like this:

%ProgramFiles%\Internet Explorer\Iexplore.exe" -k "%programfiles%\software\image.jpg"

But how do I configure the time delay, termination of IE - and finally making the other application start?
0
Comment
Question by:andre_st
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 5

Expert Comment

by:Tompa99
ID: 34195847
Hi

I can do that for you in one vbscript for you,
This one first shows a picture for 4 seconds and then starts notepad.

You can modify the explorer with stuff like size status bar add one of the following before
objExplorer.Visible = 1  

      objExplorer.ToolBar = 0
      objExplorer.StatusBar = 0
      objExplorer.Width = 400
      objExplorer.Height = 250
      objExplorer.Left = 300
      objExplorer.Top = 200

by this you can play with how the Internet explorer is shown.

Save the code in to a vbs file and change the path for you jpg
from c:\temp\FI.593.0.1.jpg to your choice and test.

Best Regards Tompa



ShowPicture
RunNotePad

private function RunNotePad
	Dim objWshShell 
	Set objWshShell = WScript.CreateObject("WScript.Shell.1")
	objWshShell.Exec("notepad.exe")
end function

private function ShowPicture()
	set objExplorer = WScript.CreateObject ("InternetExplorer.Application", "IE_")
	objExplorer.Visible = 1             
	objExplorer.Navigate "file:///c:\temp\FI.593.0.1.jpg"   
	Wscript.Sleep 4000
	objExplorer.Quit
end function

Open in new window

0
 

Author Comment

by:andre_st
ID: 34196204
Hi!

Thanks for a quick answer! IE starts up the image without problems. However, the script is giving me some errors on line 15 (se attached error-image). Any idea how to fix that?




error-message.png
0
 
LVL 5

Expert Comment

by:Tompa99
ID: 34196339
Hi

I think if you close the windows before timeout you get that message.
But if you change the code to the following you should be alright.

Best Regards Tompa
private function ShowPicture()
	Dim objExplorer
	set objExplorer = WScript.CreateObject ("InternetExplorer.Application", "IE_")
	objExplorer.Visible = 1             
	objExplorer.Navigate "file:///c:\temp\FI.593.0.1.jpg"   
	Wscript.Sleep 4000
	on error resume next	
		objExplorer.Quit
	on error goto 0
end function

Open in new window

0
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 

Author Comment

by:andre_st
ID: 34203389
Hello again!

The new version seems to work ,-) At least I get no errormessages, and both applications start.

But there is one small thing. Instad of IE starting first, closing down after a few seconds - and then Notepad starts up. What I am experiencing on my computer is that Notepad starts off first, for only a millisecond or so. You can see it flash on the screen, and then IE starts - and finally Notpad opens when IE closes.

Is there a way to getting Notepad to only show up when IE terminates?

Thanks again for your time!
0
 
LVL 5

Accepted Solution

by:
Tompa99 earned 500 total points
ID: 34203657
Hi,

Strange I have tested it on my computer and notepad never starts before IE is terminated.
But I did add one part to the complete script that shouldn't be needed but here you go.

Best Regards Tompa
Dim status
status = ShowPicture
if status = 1 then
	RunNotePad
end if

private function RunNotePad()
	Dim objWshShell 
	Set objWshShell = WScript.CreateObject("WScript.Shell.1")
	objWshShell.Exec("notepad.exe")
end function

private function ShowPicture()
	Dim objExplorer
	set objExplorer = WScript.CreateObject ("InternetExplorer.Application", "IE_")
	objExplorer.Visible = 1             
	objExplorer.Navigate "file:///c:\temp\FI.593.0.1.jpg"   
	Wscript.Sleep 4000
	on error resume next	
		objExplorer.Quit
	on error goto 0
	ShowPicture = 1
end function

Open in new window

0
 

Author Comment

by:andre_st
ID: 34203906
Hi Tompa!

My mistake, what was "flashing" on the screen was not "Notepad" :-P

I was using the variables for setting the size settings in IE - as you mentioned early in this thread. And the flashing windows was in fact IE - "before" it had processed the image, and size settings.

To me it looked like Notepad, as IE is at the time of the "flashing", is stripped clean of navigation etc. and not showing any image. But as soon as I removed the size-variables, it all looks normal.

Setting the size-variables is however not a very important thing, so it´s not something that has to be solved.

So I am quite happy with the script!

Thanks a bunch for your time and effort!! :-)

Kind regards,

André
0
 

Author Comment

by:andre_st
ID: 34228961
Hello again Tompa!

I discovered a problem with the script. It works well on Win XP, but on Windows 7 - Internet Explorer doesn´t terminate before running the other appliaction...Since we are going to use this almost entirely on Win 7, I would really appreciate if you could take a quick look into the problem :-O
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question