Exemplo n.º 1
0
        public bool Run(DtoImagePrepOptions imagePrepOptions)
        {
            if (imagePrepOptions == null)
            {
                Logger.Info("Image Prep Cancelled.");
                return(false);
            }


            Logger.Info("Preparing Computer For Image: ");
            Logger.Info("Checking Toec Service");
            var servResult = new ServiceSystemService().StopToec();

            if (!servResult)
            {
                Logger.Info("Toec Service Must Be Stopped Before Preparing Image.");
                return(false);
            }

            _imagePrepOptions = imagePrepOptions;

            ResetToec();

            File.Create($"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)}\\Toec\\image_prepped");
            Logger.Info("Prepare Image Finished");
            return(true);
        }
Exemplo n.º 2
0
        public StartRemoteControl()
        {
            try
            {
                var scope = new ManagementScope(String.Format("\\\\{0}\\root\\CIMV2", "localhost"), null);
                scope.Connect();

                var deletionQuery = "Select * From __InstanceDeletionEvent Within 1 " +
                                    "Where TargetInstance ISA 'Win32_Process' AND TargetInstance.SessionId != 0 AND TargetInstance.Name = 'Remotely_Desktop.exe'";

                _deletionWatcher = new ManagementEventWatcher(scope, new EventQuery(deletionQuery));
                _deletionWatcher.EventArrived += InstanceEventHandler;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
            }
            _systemServices = new ServiceSystemService();
        }
Exemplo n.º 3
0
        public bool Run()
        {
            Logger.Info("Preparing Toec For Image: ");
            Logger.Info("Checking Toec Service");
            var servResult = new ServiceSystemService().StopToec();

            if (!servResult)
            {
                Logger.Error("Toec Service Must Be Stopped Before Preparing Image.");
                return(false);
            }

            //Wait another 30 secs for anything to finish
            Logger.Info("Resetting Toec ...");
            System.Threading.Thread.Sleep(30000);

            ServiceCertificate.DeleteAllDeviceCertificates();
            ServiceCertificate.DeleteIntermediate();

            var serviceSetting = new ServiceSetting();

            var installationId = serviceSetting.GetSetting("installation_id");

            installationId.Value = null;
            serviceSetting.UpdateSettingValue(installationId);


            var encryptionKey = serviceSetting.GetSetting("encryption_key");

            encryptionKey.Value = null;
            serviceSetting.UpdateSettingValue(encryptionKey);

            var entropy = serviceSetting.GetSetting("entropy");

            entropy.Value = null;
            serviceSetting.UpdateSettingValue(entropy);

            var computerIdentifier = serviceSetting.GetSetting("computer_identifier");

            computerIdentifier.Value = null;
            serviceSetting.UpdateSettingValue(computerIdentifier);

            var deviceThumbprint = serviceSetting.GetSetting("device_thumbprint");

            deviceThumbprint.Value = null;
            serviceSetting.UpdateSettingValue(deviceThumbprint);

            var intermediateThumbprint = serviceSetting.GetSetting("intermediate_thumbprint");

            intermediateThumbprint.Value = null;
            serviceSetting.UpdateSettingValue(intermediateThumbprint);

            new PolicyHistoryServices().DeleteAll();
            new ServiceUserTracker().DeleteAll();
            new ServiceAppMonitor().DeleteAll();

            var provisionStatus = serviceSetting.GetSetting("provision_status");

            provisionStatus.Value = "0";
            serviceSetting.UpdateSettingValue(provisionStatus);


            var updatedStatus = serviceSetting.GetSetting("provision_status");
            var updatedId     = installationId = serviceSetting.GetSetting("installation_id");

            if (!updatedStatus.Value.Equals("0") && !string.IsNullOrEmpty(updatedId.Value))
            {
                Logger.Error("Prepare Image Failed.  Could Not Reset ID's");
                return(false);
            }


            Logger.Info("Toec Prepare Image Finished");
            return(true);
        }