// POST api/estimatediskusage
        public DiskUsage Post([FromBody] Computer computer)
        {
            string IPAddress = computer.IPAddress;

            Process proc = new Process();

            proc.StartInfo.UserName = AdminAccounts.GetAdminAccount1().UserName;
            SecureString secure = AdminAccounts.GetAdminAccount1().SecurePassword;

            proc.StartInfo.Domain                 = Domain.GetDomain();
            proc.StartInfo.Password               = secure;
            proc.StartInfo                        = new ProcessStartInfo(@"cmd.exe", String.Format(@"/c getDiskUsage.bat {0} C:", IPAddress));
            proc.StartInfo.WorkingDirectory       = @"C:\Manage\EstimateDiskSpace";
            proc.StartInfo.UseShellExecute        = false;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.Start();

            string output = proc.StandardOutput.ReadToEnd();

            proc.WaitForExit(10);

            string[] lines = output.Split(new string[] { "\r\n" }, StringSplitOptions.None);

            DiskUsage diskUsage = new DiskUsage()
            {
                TotalSpace  = lines[0].Substring(13, lines[0].Length - 13),
                FreeSpace   = lines[1].Substring(12, lines[1].Length - 12),
                UsedSpace   = lines[2].Substring(12, lines[2].Length - 12),
                PercentUsed = lines[3].Substring(14, lines[3].Length - 14),
                PercentFree = lines[4].Substring(14, lines[4].Length - 14)
            };

            return(diskUsage);
        }
Ejemplo n.º 2
0
        // POST api/wordperfect
        public void Post([FromBody] Computer value)
        {
            comp = value;

            Process proc = new Process();

            proc.StartInfo.UserName = AdminAccounts.GetAdminAccount1().UserName;
            proc.StartInfo.Password = AdminAccounts.GetAdminAccount1().SecurePassword;
            proc.StartInfo.Domain   = Domain.GetDomain();

            proc.StartInfo = new ProcessStartInfo(@"cmd.exe", String.Format(@"/c installWordPerfect.cmd {0}", value.IPAddress));
            proc.StartInfo.WorkingDirectory       = @"C:\Manage\WordPerfect";
            proc.StartInfo.UseShellExecute        = false;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.RedirectStandardError  = true;
            //proc.EnableRaisingEvents = true;
            proc.OutputDataReceived += (sender, args) => UpdateStatus(args.Data);
            proc.ErrorDataReceived  += (sender, args) => UpdateStatus(args.Data);

            noErrorCount = 0;

            proc.Start();
            proc.BeginOutputReadLine();
            proc.BeginErrorReadLine();
            proc.WaitForExit(60);
        }
Ejemplo n.º 3
0
        public ActionResult EnableAD(string computerName)
        {
            Process proc = new Process();

            proc.StartInfo.UserName = AdminAccounts.GetAdminAccount1().UserName;
            proc.StartInfo.Password = AdminAccounts.GetAdminAccount1().SecurePassword;

            proc.StartInfo.Domain                 = Domain.GetDomain();
            proc.StartInfo                        = new ProcessStartInfo(@"cmd.exe", "/c enable.cmd " + computerName);
            proc.StartInfo.WorkingDirectory       = @"C:\Manage\EnableAD";
            proc.StartInfo.UseShellExecute        = false;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.Start();
            proc.WaitForExit(10);

            ViewBag.ComputerName = computerName;
            return(View());
        }
Ejemplo n.º 4
0
        public ActionResult MoveInADConfirmed(string computerName, string ADPath)
        {
            ViewBag.ComputerName = computerName;

            string DistinguishedName = GetObjectDistinguishedName(objectClass.computer, returnType.distinguishedName, computerName, Domain.GetDomain());

            Process proc = new Process();

            proc.StartInfo.UserName = AdminAccounts.GetAdminAccount1().UserName;
            SecureString secure = AdminAccounts.GetAdminAccount1().SecurePassword;

            proc.StartInfo.Password         = secure;
            proc.StartInfo                  = new ProcessStartInfo(@"cmd.exe", "/c move.cmd \"" + DistinguishedName.Replace("LDAP://", "") + "\" \"" + ADPath + "\"");
            proc.StartInfo.WorkingDirectory = @"C:\Manage\MoveAD";
            proc.StartInfo.UseShellExecute  = false;

            proc.StartInfo.RedirectStandardOutput = true;
            proc.Start();
            proc.WaitForExit(10);

            return(View());
        }