private void executeButton_Click(object sender, RoutedEventArgs e)
        {
            String SrcName = Profile.SelectedItem as String;

            String DestName = null;

            if (_domain)
            {
                DestName = domain.Text + "\\" + uname.Text;
            }
            else
            {
                DestName = DestAcct.SelectedItem as String;
            }

            TransferStatus status = ProfileTransfer.CheckAccounts(SrcName, DestName);

            if (status != TransferStatus.COMPLETE)
            {
                TransferComplete(status);
                return;
            }

            MessageBoxResult result = MessageBox.Show(this, "The profile belonging to " + SrcName + " will be transfered to " + DestName
                                                      + ". Are you sure you want to continue?", "Confirm", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                progress       = new Window2();
                progress.Owner = this;
                progress.Show();
                ProfileTransfer.TransferWithCallback(SrcName, DestName, TransferComplete,
                                                     _replace.IsChecked.GetValueOrDefault(), _deleteProfile.IsChecked.GetValueOrDefault(),
                                                     ".", _deleteAcct.IsChecked.GetValueOrDefault());
            }
        }
Пример #2
0
        static void RunConsole(String[] args)
        {
            Boolean deleteAccount = true;
            Boolean overwrite     = false;
            Boolean deleteProfile = false;
            String  user1         = null;
            String  user2         = null;
            String  computer      = ".";

            foreach (String arg in args)
            {
                switch (arg)
                {
                case "/?":
                    showHelp();
                    return;

                case "/k":
                    deleteAccount = false;
                    break;

                case "/y":
                    overwrite = true;
                    break;

                case "/d":
                    deleteProfile = true;
                    break;

                default:
                    if (arg.StartsWith("/c:"))
                    {
                        computer = arg.Substring(3);
                    }
                    else if (user1 == null)
                    {
                        user1 = arg;
                    }
                    else if (user2 == null)
                    {
                        user2 = arg;
                    }
                    else
                    {
                        showHelp();
                        return;
                    }
                    break;
                }
            }
            if (user1 == null)
            {
                showHelp();
                return;
            }
            else if (user1.Contains("/"))
            {
                user1 = user1.Replace("/", "\\");
            }
            else if (!user1.Contains("\\"))
            {
                user1 = Environment.MachineName + "\\" + user1;
            }

            if (user2 == null)
            {
                showHelp();
                return;
            }
            else if (user2.Contains("/"))
            {
                user2 = user2.Replace("/", "\\");
            }
            else if (!user2.Contains("\\"))
            {
                user2 = Environment.MachineName + "\\" + user2;
            }

            Console.Out.WriteLine("Please wait while your user profile is transferred.\n");
            TransferStatus status = ProfileTransfer.Transfer(user1, user2, overwrite, deleteProfile, computer, deleteAccount);

            switch (status)
            {
            case TransferStatus.BAD_USER1:
                Console.Out.WriteLine("The source account that you entered is not valid.  Please try again.");
                break;

            case TransferStatus.BAD_USER2:
                Console.Out.WriteLine("The destination account that you entered is not valid.  Please try again.");
                break;

            case TransferStatus.SRC_IS_DEST:
                Console.Out.WriteLine("The source and destination profiles cannot be the same.");
                break;

            case TransferStatus.PROFILE_EXISTS:
                Console.Out.WriteLine("The destination account already has a profile. Please use /y to overwrite the destination profile.");
                break;

            case TransferStatus.FAILED_OTHER:
                Console.Out.WriteLine("Profile transfer failed.  Make sure that you're running this program as an administrator.");
                break;

            case TransferStatus.NO_PROFILE:
                Console.Out.WriteLine("The source user does not have a valid user profile.  Please try again.");
                break;

            case TransferStatus.COMPLETE:
                Console.Out.WriteLine("Profile successfully transfered.");
                break;
            }
        }