Solved

Scheduled Task to open browser/URL then close.

Posted on 2014-11-03
9
1,011 Views
Last Modified: 2014-11-06
Hi All - I have a Windows Server 2012 machine and I need to create a task that executes a URL and after about a minute, closes the browser.  

Using the "Create Basic Task Wizard" I was able to create the task to Open the browser and launch the URL BUT I cannot figure out how to close the browser a minute later.

Can you please provide with with instructions on how to do this?  Thanks!
0
Comment
Question by:cdemott33
  • 4
  • 4
9 Comments
 
LVL 18

Accepted Solution

by:
x-men earned 500 total points
ID: 40421283
create a powershell script (C:\myscripts\openCloseIE.ps1):
-------------------------------------------------------------------------------------------------------------
$oIE = New-Object -ComObject internetexplorer.application;
$oIE.Navigate("http://myurl.sufix/mypage.html")
$oIE.Visible = $true #...or false, if you what it appear on the desktop, or not
start-sleep -seconds 60
$oIE.quit()
-------------------------------------------------------------------------------------------------------------
Create a task that Starts a program: C:\Windows\system32\WindowsPowershell\v1.0\powershell.exe
Add arguments: C:\myscripts\openCloseIE.ps1
0
 

Author Closing Comment

by:cdemott33
ID: 40421429
Thank you.  I will try this.
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40421908
@cdemott33 - I'd try the suggestion before I accept :)

I tried and got a security warning, powershell did not start a browser, so nothing happened.

@x-men - Anything you need to add maybe?
0
 
LVL 18

Expert Comment

by:x-men
ID: 40423448
@Gerwin Jansen care to share the message, maybe?
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40424811
@x-men - No problem, I tried both as a scheduled task as well as from a cmd (administrative) prompt:
C:\Temp>C:\Windows\system32\WindowsPowershell\v1.0\powershell.exe c:\temp\ee.ps1
c:\temp\ee.ps1 : File C:\temp\ee.ps1 cannot be loaded because running scripts is disabled on this system. For more info
http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ c:\temp\ee.ps1
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

C:\Temp>

Open in new window

I just got curious as the asker closed with ".. I will try this".
0
 
LVL 18

Expert Comment

by:x-men
ID: 40425723
"cannot be loaded because running scripts is disabled on this system."

recommend executing the following:

PS >get-help about_Execution_Policies
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40426421
Or just:

PS> Set-ExecutionPolicy Unrestricted

and it is working ;)
0
 
LVL 18

Expert Comment

by:x-men
ID: 40426538
"Set-ExecutionPolicy Unrestricted" Not recomended
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40426699
Any better advice then for the asker?
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In my previous 24 VMware Articles (http://www.experts-exchange.com/ARTH_1864316.html?arthOrderBy=3&arthSort=1#arth), most featured Intermediate VMware Topics. My next series of articles concentrated on topics for the VMware Novice;   If you would…
The reason that corporations and businesses use Windows servers is because it supports custom modifications to adapt to the business and what it needs. Most individual users won’t need such powerful options. Here I’ll explain how you can enable Wind…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now