Welcome to Dream.In.Code
Become a C# Expert!

Join 150,390 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,058 people online right now. Registration is fast and FREE... Join Now!




Needing to know if...

 
Reply to this topicStart new topic

Needing to know if..., Needing to know if...

ajax-maxx
27 Feb, 2008 - 12:18 PM
Post #1

New D.I.C Head
*

Joined: 16 Dec, 2007
Posts: 8


My Contributions
Just needing to know if there is a way of blocking selective programs from running from inside a C# program...

crazy.gif

This post has been edited by ajax-maxx: 27 Feb, 2008 - 12:18 PM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Needing To Know If...
27 Feb, 2008 - 12:25 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
I'm not sure I'm completely understanding your question here. Can you be a little more specific please smile.gif
User is online!Profile CardPM
+Quote Post

ajax-maxx
RE: Needing To Know If...
27 Feb, 2008 - 12:41 PM
Post #3

New D.I.C Head
*

Joined: 16 Dec, 2007
Posts: 8


My Contributions
QUOTE(PsychoCoder @ 27 Feb, 2008 - 01:25 PM) *

I'm not sure I'm completely understanding your question here. Can you be a little more specific please smile.gif



Yes I am writing a service app that runs in the background That prevents Users from accessing The fallowing CMD, Control Panel, Installations", Internet, and Task-Manager from inside my app w/o setting User Admin Rights...

How do I do this???

The code I am looking for will be activated by a check-box for each item...

Sorry about the confusion blink.gif

This post has been edited by ajax-maxx: 27 Feb, 2008 - 02:50 PM
User is offlineProfile CardPM
+Quote Post

ajax-maxx
RE: Needing To Know If...
27 Feb, 2008 - 01:21 PM
Post #4

New D.I.C Head
*

Joined: 16 Dec, 2007
Posts: 8


My Contributions
Is there a way to do this???

It would be ober helpful
User is offlineProfile CardPM
+Quote Post

ajax-maxx
RE: Needing To Know If...
28 Feb, 2008 - 09:18 AM
Post #5

New D.I.C Head
*

Joined: 16 Dec, 2007
Posts: 8


My Contributions
Ok I found two ways of doing this One was to place a registry edit that hooked and unhooked the Processes I wanted to disable... (alot of code)

Then I found this page by PsychoCoder that had this code...
CODE
//Namespaces needed
using System.Diagnostics;

public bool FindAndKillProcess(string name)
{
    //here we're going to get a list of all running processes on
    //the computer
    foreach (Process clsProcess in Process.GetProcesses) {
        //now we're going to see if any of the running processes
        //match the currently running processes by using the StartsWith Method,
        //this prevents us from incluing the .EXE for the process we're looking for.
        //. Be sure to not
        //add the .exe to the name you provide, i.e: NOTEPAD,
        //not NOTEPAD.EXE or false is always returned even if
        //notepad is running
        if (clsProcess.ProcessName.StartsWith(name))
        {
            //since we found the proccess we now need to use the
            //Kill Method to kill the process. Remember, if you have
            //the process running more than once, say IE open 4
            //times the loop thr way it is now will close all 4,
            //if you want it to just close the first one it finds
            //then add a return; after the Kill
            clsProcess.Kill();
            //process killed, return true
            return true;
        }
    }
    //process not found, return false
    return false;
}


And am wondering if this could be made into a Constant Loop to kill the process everytime its started???

This post has been edited by ajax-maxx: 28 Feb, 2008 - 09:35 AM
User is offlineProfile CardPM
+Quote Post

zakary
RE: Needing To Know If...
29 Feb, 2008 - 04:54 AM
Post #6

D.I.C Regular
Group Icon

Joined: 15 Feb, 2005
Posts: 420



Thanked: 8 times
Dream Kudos: 175
My Contributions
Why do you want to block
QUOTE
CMD, Control Panel, Installations", Internet, and Task-Manager from inside my app w/o setting User Admin Rights...
everyday users should have accesses to them unless you are writing a virus that is the only reason I can see for not allowing access to
QUOTE
CMD, Control Panel, Installations", Internet, and Task-Manager


User is offlineProfile CardPM
+Quote Post

ajax-maxx
RE: Needing To Know If...
29 Feb, 2008 - 10:06 AM
Post #7

New D.I.C Head
*

Joined: 16 Dec, 2007
Posts: 8


My Contributions
QUOTE(zakary @ 29 Feb, 2008 - 05:54 AM) *

Why do you want to block
QUOTE
CMD, Control Panel, Installations", Internet, and Task-Manager from inside my app w/o setting User Admin Rights...
everyday users should have accesses to them unless you are writing a virus that is the only reason I can see for not allowing access to
QUOTE
CMD, Control Panel, Installations", Internet, and Task-Manager




Yeah I write viruses for a hobby tongue.gif LOL

I am creating a program that allows you (The Admin) to control a computer that has multiple Admin accounts, and multiple users... (One thing I hate about using Limited user accounts is that in order for me to do anything in them I either A. have to log off and do it from my account or B. I have to consistantly put my username and password into a the run as box to preform the tasks that need to be done)...

This program allows me to preform all tasks just by a small shortcut...

This program once set; limits the time that any one person can be logged in, and sets the accounts according to what I will allow. There is a kill key for this program so I can run installs of new programs or other admin tasks for them that key is (alt+ctr+F12) then reset it using (alt+ctr+F11) so they can then play there games...

Here is a Screen shot of the program: IPB Image

LOL a Managed C# .Net Virus hahaha rolleyes.gif

Whats up with the forum calling every body a DIC Head???

This post has been edited by ajax-maxx: 29 Feb, 2008 - 10:39 AM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Needing To Know If...
29 Feb, 2008 - 10:10 AM
Post #8

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
@ajax-maxx: You could put that code inside a timer event that runs in its own thread and set the timers interval to the interval you wish to have it check the list of processes.
User is online!Profile CardPM
+Quote Post

ajax-maxx
RE: Needing To Know If...
29 Feb, 2008 - 10:17 AM
Post #9

New D.I.C Head
*

Joined: 16 Dec, 2007
Posts: 8


My Contributions
QUOTE(PsychoCoder @ 29 Feb, 2008 - 11:10 AM) *

@ajax-maxx: You could put that code inside a timer event that runs in its own thread and set the timers interval to the interval you wish to have it check the list of processes.



Thanks I'll give it a try... cool.gif
User is offlineProfile CardPM
+Quote Post

ajax-maxx
RE: Needing To Know If...
29 Feb, 2008 - 12:42 PM
Post #10

New D.I.C Head
*

Joined: 16 Dec, 2007
Posts: 8


My Contributions
QUOTE(ajax-maxx @ 29 Feb, 2008 - 11:17 AM) *

QUOTE(PsychoCoder @ 29 Feb, 2008 - 11:10 AM) *

@ajax-maxx: You could put that code inside a timer event that runs in its own thread and set the timers interval to the interval you wish to have it check the list of processes.



Thanks I'll give it a try... cool.gif


Ok Here is the code written so far tell me what I did wrong LOL...

CODE
         private void checkBox1_Checked(object sender, EventArgs e)
        {
            if (checkBox1.Checked) timer1.Enabled = true;  
        }
        
        private void timer1_Tick(object sender, EventArgs e)
        }
    // Name of Process to Kill
            public bool FindAndKillProcess(string taskmgr)
    {
    // Get Processes
    foreach (Process clsProcess in Process.GetProcesses)
    {
    // Check for process Name
        if (clsProcess.ProcessName.StartsWith(taskmgr))
        {
    // Kill Named
            clsProcess.Kill();
            //process killed, return true
            return true;
        }
    }
    // process not found, return false
    return false;
    }
}


bool shows up as Red tagged and it says I am Missing a ; after private void timer1_Tick(object sender, EventArgs e)

be gentile I am a n00b!3
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Needing To Know If...
29 Feb, 2008 - 12:52 PM
Post #11

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Your're missing your semi-colon after this line

csharp

// Name of Process to Kill
public bool FindAndKillProcess(string taskmgr)


Change it to


csharp

// Name of Process to Kill
public bool FindAndKillProcess(string taskmgr);


and that error should go away

This post has been edited by PsychoCoder: 29 Feb, 2008 - 12:53 PM
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 05:44PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month