aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Notes/Tango.Notes/PanelPC/Remote Debugging.txt
blob: a7d1ef40a84fbc874e0bda3843b260b42ba1d07d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
To use PsExec on a Windows 10 remote machine we need to apply a registry patch:

1. Open RegEdit on your remote server
2. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
3. Add a new DWORD value called LocalAccountTokenFilterPolicy
4. Set its value to 1

Example Usage:

-> User Name
-> Password
-> HostName
-> Absolute/relative file path.
-> '-d' means don't wait for the process to exit. (Not sure it is working)
-> '-accepteula' means suppress the license dialog.

psexec -u panel-pc -p Aa123456 -i \\panel-pc "\\Twine01\data\Roy BACKUP\Debug\PanelTest.exe" -d -accepteula
0 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;

namespace Tango.SharedUI.Components
{
    /// <summary>
    /// Represents an MVVM TextBox controller
    /// </summary>
    /// <seealso cref="System.Windows.DependencyObject" />
    public class TextController : DependencyObject
    {
        private TextBox _textBox;
        private bool _isMouseDown;

        /// <summary>
        /// Determines whether an element is Controller.
        /// </summary>
        public static readonly DependencyProperty ControllerProperty =
            DependencyProperty.RegisterAttached("Controller",
            typeof(TextController), typeof(TextController),
            new FrameworkPropertyMetadata(null,ControllerChanged));

        /// <summary>
        /// On controller changed.
        /// </summary>
        /// <param name="d">The d.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.ArgumentException">The text controller component can only handle elements of type TextBox.</exception>
        private static void ControllerChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d != null && e.NewValue != null)
            {
                if (!(d is TextBox))
                {
                    throw new ArgumentException("The text controller component can only handle elements of type TextBox.");
                }

                (e.NewValue as TextController).SetTextBox(d as TextBox);
            }
        }

        /// <summary>
        /// Sets the Controller attached property.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="value">if set to <c>true</c> [value].</param>
        public static void SetController(FrameworkElement element, TextController value)
        {
            element.SetValue(ControllerProperty, value);
        }

        /// <summary>
        /// Gets the Controller attached property.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns></returns>
        public static TextController GetController(FrameworkElement element)
        {
            return (TextController)element.GetValue(ControllerProperty);
        }

        /// <summary>
        /// Gets or sets a value indicating whether to automatically scroll to end of text.
        /// </summary>
        public bool AutoScrollToEnd { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="TextController"/> class.
        /// </summary>
        public TextController()
        {
            AutoScrollToEnd = true;
        }

        /// <summary>
        /// Sets the text box.
        /// </summary>
        /// <param name="textBox">The text box.</param>
        private void SetTextBox(TextBox textBox)
        {
            _textBox = textBox;
            _textBox.PreviewMouseDown += (_, __) => _isMouseDown = true;
            _textBox.PreviewMouseUp += (_, __) => _isMouseDown = false;
        }

        /// <summary>
        /// Appends the specified text.
        /// </summary>
        /// <param name="text">The text.</param>
        public void WriteLine(String text)
        {
            Write(text + Environment.NewLine);
        }

        /// <summary>
        /// Appends the specified text.
        /// </summary>
        /// <param name="text">The text.</param>
        public void Write(String text)
        {
            Invoke(() =>
            {
                _textBox.AppendText(text);

                if (AutoScrollToEnd && !_isMouseDown)
                {
                    ScrollToEnd();
                }
            });
        }

        /// <summary>
        /// Sets the specified text.
        /// </summary>
        /// <param name="text">The text.</param>
        public void Set(String text)
        {
            Invoke(() =>
            {
                _textBox.Text = text;

                if (AutoScrollToEnd && !_isMouseDown)
                {
                    ScrollToEnd();
                }
            });
        }

        /// <summary>
        /// Clears the text.
        /// </summary>
        public void Clear()
        {
            Invoke(() =>
            {
                _textBox.Clear();
            });
        }

        /// <summary>
        /// Scrolls to the end of the text.
        /// </summary>
        public void ScrollToEnd()
        {
            _textBox.ScrollToEnd();
        }

        /// <summary>
        /// Invokes the specified action.
        /// </summary>
        /// <param name="action">The action.</param>
        private void Invoke(Action action)
        {
            Dispatcher.BeginInvoke(action);
        }
    }
}