ChangeEnvironmentTool 总结

来源:互联网 发布:英语小说阅读软件 编辑:程序博客网 时间:2024/06/11 13:21

文件夹选择:

FolderBrowserDialog fbd = newFolderBrowserDialog();

if (fbd.ShowDialog() == DialogResult.OK)

{

    this.txtPath.Text = fbd.SelectedPath;

}

直接实例化该类,不需要控件就能实现。


在C#中直接运行PowerShell命令:

publicstaticvoid RunPS(string command)

{

     PowerShell ps = PowerShell.Create();

     ps.AddScript(command);

     ps.Invoke();

     ps.Dispose();

}

调用这个类需要引用System.Management.Automation.dll

另外 PowerShell 有 AddCommand、AddParameter等命令。


命令总结:

清理IE:Powershell.AddScript("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255");

这条命令基于 C:\WINDOWS\system32\inetcpl.cpl DLL文件

还有一下命令也相同

清除Internet临时文件:RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

清除Cookies:RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

清除历史记录:RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

清除表单数据:RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16

清除密码:RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32

清除上述全部以及IE7中使用加载项保存的数据:RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351


C#操作iis基本命令:

调用ServerManager类 需要引用 Microsoft,Web.Administration,dll

创建一个基本的website

ServerManager iis = newServerManager();

iis.Sites.Add(webname,"http", Port(*:80:), physicalpath);

iis.CommitChanges();


删除website

ServerManager iis = newServerManager();

Site site = iis.Sites[this.txtDelete.Text];

if (site != null)

{

    iis.Sites.Remove(site);

    iis.CommitChanges();

    MessageBox.Show("success");

}


0 0
原创粉丝点击