Solved

# Scheduled Task to open browser/URL then close.

Posted on 2014-11-03
Medium Priority
1,953 Views
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
Question by:cdemott33
• 4
• 4

LVL 18

Accepted Solution

x-men earned 2000 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
0

Author Closing Comment

ID: 40421429
Thank you.  I will try this.
0

LVL 38

Expert Comment

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

ID: 40423448
@Gerwin Jansen care to share the message, maybe?
0

LVL 38

Expert Comment

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
At line:1 char:1
+ c:\temp\ee.ps1
+ ~~~~~~~~~~~~~~
+ CategoryInfo          : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

C:\Temp>

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

LVL 18

Expert Comment

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

recommend executing the following:

0

LVL 38

Expert Comment

ID: 40426421
Or just:

PS> Set-ExecutionPolicy Unrestricted

and it is working ;)
0

LVL 18

Expert Comment

ID: 40426538
"Set-ExecutionPolicy Unrestricted" Not recomended
0

LVL 38

Expert Comment

ID: 40426699
0

## Featured Post

Question has a verified solution.

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

For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
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 steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
###### Suggested Courses
Course of the Month8 days, 15 hours left to enroll