|
@@ -6,6 +6,7 @@ using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
+using System.Management;
|
|
|
using System.Net;
|
|
|
using System.Reflection;
|
|
|
using System.Security;
|
|
@@ -20,7 +21,7 @@ namespace SvdCli
|
|
|
{
|
|
|
private static void Main(string[] args)
|
|
|
{
|
|
|
- if (args.Length < 3)
|
|
|
+ if (args.Length < 2)
|
|
|
{
|
|
|
Console.WriteLine(@"Usage:");
|
|
|
Console.WriteLine(@"");
|
|
@@ -36,6 +37,7 @@ namespace SvdCli
|
|
|
Console.WriteLine(@"[Install ServiceName|Service] <Mount|Server 0.0.0.0 2333> Image C:\Path\To\Your\Image.img [ReadOnly]");
|
|
|
Console.WriteLine(@"[Install ServiceName|Service] <Mount|Server 0.0.0.0 2333> Bdd C:\Path\To\Your\Bdd.bdd [ReadOnly]");
|
|
|
Console.WriteLine(@"[Install ServiceName|Service] Mount Net 192.168.233.233 2333");
|
|
|
+ Console.WriteLine(@"[Install ServiceName|Service] Mount ZTempNtfsRamDisk 10GB");
|
|
|
Console.WriteLine(@"[Install ServiceName|Service] Server 192.168.233.233 2333 Dispatch 64KB C:\Path\To\Your\Image.img C:\Path\To\Your\Dir\");
|
|
|
Console.WriteLine(@"");
|
|
|
Console.WriteLine(@"Uninstall ServiceName Safe:Restrict to register by this program");
|
|
@@ -200,6 +202,7 @@ namespace SvdCli
|
|
|
case "ramdisk":
|
|
|
case "ntfsramdisk":
|
|
|
case "tempntfsramdisk":
|
|
|
+ case "ztempntfsramdisk":
|
|
|
if (ParseDiskSize(args[1], out var value, out var unit))
|
|
|
{
|
|
|
if (false == string.IsNullOrWhiteSpace(unit) && false == unit.StartsWith("g"))
|
|
@@ -212,8 +215,27 @@ namespace SvdCli
|
|
|
if (args.Length > 3 && args[3].ToLower() == "readonly") storage.WriteProtect = true;
|
|
|
|
|
|
|
|
|
- if (op == "ntfsramdisk") FsMaker.MakeNtfsRamDisk(storage, false);
|
|
|
- if (op == "tempntfsramdisk") FsMaker.MakeNtfsRamDisk(storage, true);
|
|
|
+ if (op == "ntfsramdisk") FsMaker.MakeNtfs(storage, "RamDisk");
|
|
|
+ if (op == "tempntfsramdisk") FsMaker.MakeNtfs(storage, "RamDisk", n => n.CreateDirectory("Temp"));
|
|
|
+ if (op == "ztempntfsramdisk")
|
|
|
+ {
|
|
|
+ FsMaker.MakeNtfs(storage, "RamDisk", n => n.CreateDirectory("Temp"));
|
|
|
+ storage.Mounted += delegate
|
|
|
+ {
|
|
|
+ var volumes = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Volume");
|
|
|
+ foreach (ManagementObject volume in volumes.Get())
|
|
|
+ {
|
|
|
+ volume.Get();
|
|
|
+ var letter = volume["DriveLetter"];
|
|
|
+ var label = volume["Label"];
|
|
|
+ if (label is string str && str == "RamDisk")
|
|
|
+ {
|
|
|
+ volume["DriveLetter"] = "Z:";
|
|
|
+ volume.Put();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
return storage;
|
|
|
}
|