diff --git a/BackupEssentials/App.xaml.cs b/BackupEssentials/App.xaml.cs index bc8ab6b..b6fc69d 100644 --- a/BackupEssentials/App.xaml.cs +++ b/BackupEssentials/App.xaml.cs @@ -13,11 +13,32 @@ namespace BackupEssentials{ [DllImport("USER32.DLL")] public static extern bool SetForegroundWindow(IntPtr hwnd); + /// <summary> + /// List of arguments + /// ================= + /// -runshell = switch to backup runner + /// [ required -src and either -dest or -locid ] + /// -src = backup source (folder or file) + /// -dest = backup destination (folder) + /// -locid = backup location id + /// </summary> private void StartApp(object sender, StartupEventArgs args){ ProgramArgsParser parser = new ProgramArgsParser(args.Args); if (parser.HasFlag("runshell")){ - new BackupWindow(new BackupRunner(parser.GetValue("src",null),parser.GetValue("dest",null))).Show(); + int locid = -1; + string dest = parser.GetValue("dest",""); + + if (int.TryParse(parser.GetValue("locid","-1"),out locid) && locid >= 0){ + DataStorage.Load(DataStorage.Type.Locations); + + if (locid < DataStorage.BackupLocationList.Count){ + dest = DataStorage.BackupLocationList[locid].Directory; + } + } + + if (dest.Length > 0)Application.Current.Shutdown(); + else new BackupWindow(new BackupRunner(parser.GetValue("src",null),dest)).Show(); } else{ Process[] running = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location)); diff --git a/BackupEssentials/Backup/ExplorerIntegration.cs b/BackupEssentials/Backup/ExplorerIntegration.cs index 8cd1974..d89fc94 100644 --- a/BackupEssentials/Backup/ExplorerIntegration.cs +++ b/BackupEssentials/Backup/ExplorerIntegration.cs @@ -74,9 +74,9 @@ namespace BackupEssentials.Backup{ foreach(BackupLocation loc in valid){ string key = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\BackupEssentials"+cmd; - ++cmd; Registry.SetValue(key,null,loc.Name); - Registry.SetValue(key+@"\command",null,path+" -runshell -dest \""+loc.Directory+"\" -src \"%1\""); + Registry.SetValue(key+@"\command",null,path+" -runshell -locid "+cmd+" -src \"%1\""); + ++cmd; } return true; diff --git a/BackupEssentials/Utils/ProgramArgsParser.cs b/BackupEssentials/Utils/ProgramArgsParser.cs index 13ad28a..0c7ed40 100644 --- a/BackupEssentials/Utils/ProgramArgsParser.cs +++ b/BackupEssentials/Utils/ProgramArgsParser.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; namespace BackupEssentials.Utils{ class ProgramArgsParser{