123456789101112131415161718192021222324252627282930313233343536 |
- using System;
- using System.Diagnostics;
- namespace Mtp2Dav.Utilities
- {
- internal static class Cmd
- {
- public static int Execute(string cmd, string args)
- {
- Console.WriteLine($">{cmd} {args}");
- var p = new Process
- {
- StartInfo =
- {
- FileName = cmd,
- Arguments = args,
- UseShellExecute = false,
- CreateNoWindow = false,
- }
- };
- p.Start();
- p.WaitForExit();
- return p.ExitCode;
- }
- public static int NetUse(string driveLetter, string unc)
- {
- return Execute("net", $"use {driveLetter}: {unc}");
- }
- public static int NetUseDriveLetterDelete(string driveLetter)
- {
- return Execute("net", $"use {driveLetter}: /d /y");
- }
- }
- }
|