1

I would like to be able to run commands on the command prompt on a windows pc from an Android phone.

I am currently doing it by a wpf app on windows which listens for files with .dev in their file name.

This method is very annoying to use on a phone as I have to type out the command in a .bat file and then copy the file to D:\Shared using an app like File Manager to transfer the file via windows share

using Microsoft.Win32;
using System.Diagnostics;

namespace Dev
{
    public partial class Dev : ApplicationContext
    {
        class Var
        {
            public static string temp = Path.GetTempPath();
        }
        public Dev()
        {

            RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce", true);
            key.SetValue("Remote Dev", Application.ExecutablePath);

            // Create a new FileSystemWatcher and set its properties.
            FileSystemWatcher watcher = new()
            {
                Path = "D:\\Shared",
                /* Watch for changes in LastAccess and LastWrite times, and
                   the renaming of files or directories. */
                NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
               | NotifyFilters.FileName | NotifyFilters.DirectoryName,
                // Only watch text files.
                Filter = "*.dev.*"
            };

            // Add event handlers.
            watcher.Created += new FileSystemEventHandler(Create);

            // Begin watching.
            watcher.EnableRaisingEvents = true;

            //This method is called when a file is created.
            static void Create(object source, FileSystemEventArgs e)
            {
                string tempPath = Var.temp + Path.GetFileName(e.FullPath);

                if (File.Exists(tempPath)) File.Delete(tempPath);
                File.Move(e.FullPath, tempPath);
                Thread.Sleep(1000);
                Process.Start("explorer", tempPath);
            }
        }
    }
}

I would like to create an app that can automate the process of creating the .bat file and coping it to the D:\Shared without the need of any third party app.

! Please help me in the Maui part as I am new to it. Thanks

User not found
  • 479
  • 3
  • 15
  • CIFS is the protocol used for dealing with shared folders. There are .NET libraries for it, but everything I've read says it is generally a nightmare to deal with. Why don't you just use `ssh` (there are many available client apps for Anrdoid) to execute shell commands on your PC? – Jason Oct 06 '22 at 21:55
  • @Jason Can you please send some examples. I need to be able to send commands from an Android phone and run them on the windows PC without any popup window (I need it to be a background process). – User not found Oct 07 '22 at 18:02
  • Just search the play Store for “ssh” apps. It will not display anything on your PC while executing – Jason Oct 08 '22 at 11:59

0 Answers0