# Solved: Shutdown script for iexplore.exe in Win XP



## Lostarin (Aug 15, 2008)

Hi!

 I need a script that wel be activ wen you start iexplore.exe and close the proses after 1h,
I't shud only be acktiv for low previlider status not the admins.

i prefer c++ script becus i can alitel abaut it but eny ladvidge wel go finde if you tell me hau to youse it ^.^

Hears an link of an code i cod probobly rebild but im as an beginer dont understand haw i wod compilate or wear i wod put it to get it work
http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb06/hey0228.mspx
Thx for the help.
And sry for the bade english


----------



## -Fabez- (Jul 28, 2008)

Just catch its handle and destroy the handle after the hour is up.


----------



## Lostarin (Aug 15, 2008)

Well how do i get it to work sry for beeing sotsh a nobb but vear do i put the code ? and do i compilate it and in that case VB or c++? 
*Ican probobly fidgur aut the code if i understod wear 2 handel it ^^


----------



## mt2002 (Sep 14, 2005)

I would not use C++ for this. While it is possible, you will need to go through your system API. You stated that you are new to C++. If this is true, this may be to advanced for you.

Also, please do not confuse scripting with programming--they are very different from each other.


----------



## Lostarin (Aug 15, 2008)

Tru, tru but i dont need that information wery mutsh nowing it wod be dificult in c++ i alredy nyue but can eny of you pleas actshualy anser my question like in wat landguidge the link is and how i youse it

exempel
its an **** code and you hawe to putt/compilate it hear (addres) to get it to work =S

Hope to get an anser this time

I still hawe hopes upp fore this site ^^


----------



## avisitor (Jul 13, 2008)

The link is WSH VBScript. It's an interpreted language, not compiled. It's not that it would be difficult in C++/C#/VB if you wrote a launcher that remembered its process ID and killed it if it's running after an hour.

Something like this in C#.NET 2008:


```
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "iexplore.exe";
process.Start();
System.Threading.Thread.Sleep(3600000); //Sleep for one hour. Wake up and kill the process.
if (process.HasExited==false)
{
            process.Kill();
}
```
You would launch that instead of iexplore. It would launch IE, sleep for an hour, then kill IE, then terminate itself. You could add stuff about not killing IE for administrators, etc.

Doing it with a launcher is significantly better than doing it with WSH. If you do it with WSH, you have to constantly poll the process table to find if IE is running, then you have to cache the PID and the time. Then you have to wait for an hour, then you have to poll to see if it's running again and if it is, kill it. But in the mean time, you needed to constantly keep polling to see if it was closed and a new instance wasn't open. So, doing it that way is far more complicated. All that polling is nasty, anyway .


----------



## Lostarin (Aug 15, 2008)

O my good your the best ewer xD im wery gratfull and imprest thx alot m8 i wel trye your code insted seams like al i need
Thx agen avisitor ^^


----------



## Lostarin (Aug 15, 2008)

avisitor said:


> The link is WSH VBScript. It's an interpreted language, not compiled. It's not that it would be difficult in C++/C#/VB if you wrote a launcher that remembered its process ID and killed it if it's running after an hour.
> 
> Something like this in C#.NET 2008:
> 
> ...


Hmm i wonder wat im doing wrong meby a liberary mising?
*Compiler: Default compiler
Building Makefile: "C:\****"
Executing make...
make.exe -f "C:\****\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/C++/devcpp15/Dev-Cpp/include"

main.cpp: In function `int main(int, char**)':

main.cpp:9: error: `System' was not declared in this scope
main.cpp:9: error: expected `;' before "process"
main.cpp:10: error: `process' was not declared in this scope

make.exe: *** [main.o] Error 1

Execution terminated

*

Meby its an exrealmy noobish question but i love an anser xD
Hope you hawe time avisitor ^^


----------



## mt2002 (Sep 14, 2005)

The code posted is not C++, its C#. ie, it will not work with g++ or Dev C++ (or any C++ compiler actually)

I don't know C# so cannot help much with that...


----------



## Lostarin (Aug 15, 2008)

oki that cod be a problem but wen im locking 4 an c# compilator only c++ and VB is coming aut so i fidgurd it wod work =S

Thx enywey meby he gets back 2 this tred end fix it fore me hehe


----------



## Lostarin (Aug 15, 2008)

oki I well trye those end se if i can fix it


Microsoft Visual Studio, IDE for C#
SharpDevelop, an open-source C# IDE for Windows
QuickSharp 2008, a simplified development environment for C#


----------



## avisitor (Jul 13, 2008)

You want Visual Studio C# Express Edition. You need to encode it in some methods as well, it's just a snippet.


----------



## Lostarin (Aug 15, 2008)

=s deddent realy understand wat i hawe to do to get the cod going but i vel tryge gett Visual Studio C# Express Edition and compilate it?

If somwan hawe time 2 craate the exe and post it and the sorce and witsh compilator and libarary you yoused i wood be wery gratefull ^^ in the meantime thx 4 all the ansers i only hope i wel lern somting fom them ^^


----------



## avisitor (Jul 13, 2008)

Fine I'll do it, but I'm not going to waste the time to test it. You can do that.


----------



## avisitor (Jul 13, 2008)

This does what you want: happy? 

So you change the shortcuts for internet explorer to point to that application, then that launches IE, and kills it after an hour if you're not an Administrator. Change the code as necessary. Caveat emptor.


----------



## mt2002 (Sep 14, 2005)

Lostarin:

You need to learn a programming language. Learning by having others write code for you and for you to "learn" from the code will not work and is a very bad way to learn.

It is okay asking us to write a program for you (assuming its an easy task); but if you want to get into programming this is not a good way to learn it.


----------



## Lostarin (Aug 15, 2008)

yes im realy happy And your grate.

And im realy sry if i hawe bean iretating you becus it seams that wey =(
but im very gratful and hop you dont regret helping me.

So thx and i well tes the program 2 dey cya


----------



## Lostarin (Aug 15, 2008)

mt2002 said:


> Lostarin:
> 
> You need to learn a programming language. Learning by having others write code for you and for you to "learn" from the code will not work and is a very bad way to learn.
> 
> It is okay asking us to write a program for you (assuming its an easy task); but if you want to get into programming this is not a good way to learn it.


yes i now but in this task i was aut of time so it wasent realy for lerning i only needed it for my computer.

thx enywey ^^


----------

