Change the registry, in a certain period of time can only run the specified program, know that with Group Policy manager, you can achieve, but I want to use the method of programming. __ Programming

Source: Internet
Author: User


What I can do is step, if I can't achieve the expected effect after reboot then I have to find a way.
The following is my request for help in the Forum of the original:
Change the registry, in a certain period of time can only run the specified program, know that with Group Policy manager, you can achieve, but I want to use the method of programming.
The following is my code, but can not achieve the purpose, has been studied n times, did not find a problem, please master, advice. Thank you. The first solution, the hundred distributed.
Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Text;
Using System.Windows.Forms;
Using Microsoft.Win32;

namespace Restrict
{
public partial class Form1:form
{
Public Form1 ()
{
InitializeComponent ();

Flower Pure Spring, http://ike.126.com
RegistryKey HKCU = Registry.currentuser;

RegistryKey cu = HKCU. CreateSubKey (@ "Software/microsoft/windows/currentversion/policies/explorer/restrictrun");
RegistryKey cu1 = HKCU. CreateSubKey (@ "Software/microsoft/windows/currentversion/policies/explorer");

Cu1. SetValue ("Restrictrun", 1);
Cu. SetValue ("**delvals.", "");

Cu. SetValue ("1", "notepad.exe");
Cu. SetValue ("2", "Bitcomet.exe");
Cu. SetValue ("3", "gpedit.msc");
Cu. SetValue ("4", "Regedit.exe");
Cu. SetValue ("5", "Tmshell.exe");
Cu. SetValue ("6", "Kav.exe");
Cu. SetValue ("7", "TTraveler.exe");
Cu. SetValue ("8", "Iexplore.exe");
Cu. SetValue ("9", "mmc.exe");
Cu. SetValue ("Ten", "Restrict.exe");

Hkcu. Close ();

}
int delflag = 1;
public void Delres ()//delete related registry keys, clear restrictions
{
RegistryKey HKCU = Registry.currentuser;
RegistryKey HKLM = Registry.localmachine;


           
             RegistryKey cu = HKCU. OpenSubKey (@ "Software/microsoft/windows/currentversion/policies", true);
            cu. Deletesubkeytree ("explorer");
            HKCU. Close ();
            delflag = 0;

}

private void Timer1_Tick (object sender, EventArgs e)
{

if ((DateTime.Now.Hour >=) && (DateTime.Now.Hour <=) && (delflag==1))//12 O'Clock to 2 o'clock in the afternoon from noon, remove the restriction
{

Delres ();

}

}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.