通过AD域远程修改计算机名(含批量脚本)

  • using System.Collections.Generic;
  • using System.Linq;
  • using System.Text;
  • using System.Threading.Tasks;
  • using System.IO;
  • namespace userFliter
  • {
  • class Program
  • {
  • static void Main(string[] args)
  • {
  • String[] org = File.ReadAllLines(“d:/1.csv”, Encoding.Default);
  • String newText = null;
  • newText = coding(org, newText);
  • StreamWriter sw = new StreamWriter(“d:/code.bat”);
  • sw.Write(newText);
  • sw.Flush();
  • sw.Close();
  • }
  • static private String coding(String[] oldLine, String newText)
  • {
  • String oldName = null;
  • String newName = null;
  • for (int i = 0; i
  • {
  • oldName = oldLine[i].Substring(0, oldLine[i].IndexOf(“,”));
  • newName = oldLine[i].Substring(oldLine[i].IndexOf(“,”) + 1);
  • newText = newText + “echo “+oldName+” >>D:\log.txtrn”;
  • newText = newText + “netdom renamecomputer “ + oldName + ” /newname:” + newName + ” /userd:域\管理员 /passwordd:管理员密码 /force>>D:\log.txtrn”;
  • newText = newText + “echo.>>D:\log.txtrn”;
  • }
  • newText = newText + “echo ok!rn”;
  • newText = newText + “pausern”;
  • return newText;
  • }
  • }
  • }
  • 生成的脚本打开后能看到管理员密码,可以通过软件转化为exe文件,而后加壳,避免该问题。

    声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

    上一篇 2016年7月17日
    下一篇 2016年7月17日

    相关推荐