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