public async Task ProcessAsync(string[] arguments) { string origin = null; var originIndex = Array.IndexOf(arguments, "update") + 1; if (originIndex != arguments.Length) { origin = arguments[originIndex]; } var isOriginFromInstallPath = origin == null || origin.StartsWith(InstallationInformation.TargetDirectory); if (!isOriginFromInstallPath) { await fileManager.DeleteFileIfExistsAsync(origin); await fileManager.CopyFileAsync(CurrentProcessInformation.GetCurrentProcessFilePath(), origin); processManager.LaunchFileWithAdministrativeRights(origin); } else { processManager.LaunchFileWithAdministrativeRights(CurrentProcessInformation.GetCurrentProcessFilePath(), "install"); } }
static Program() { if (InstallationInformation.TargetExecutableFile != CurrentProcessInformation.GetCurrentProcessFilePath()) { CosturaUtility.Initialize(); } }
async Task UpdateFromAssetAsync(ReleaseAsset asset) { var localFilePath = await DownloadUpdateToDiskAsync(asset); processManager.LaunchFile( localFilePath, "update \"" + CurrentProcessInformation.GetCurrentProcessFilePath() + "\""); }
public async Task ProcessAsync(string[] arguments) { var updateIndex = Array.IndexOf(arguments, "postinstall"); var targetDirectory = arguments[updateIndex + 1]; logger.Information("Attempting to delete file {file}.", targetDirectory); await fileManager.DeleteFileIfExistsAsync(targetDirectory); logger.Verbose("Old file has been cleaned up."); processManager.LaunchFileWithAdministrativeRights(CurrentProcessInformation.GetCurrentProcessFilePath()); }
async Task InstallAsync() { maintenanceWindow.Show("Installing ..."); PrepareInstallDirectory(); await InstallToInstallDirectoryAsync(); ConfigureDefaultSettings(); logger.Information("Default settings have been configured."); LaunchInstalledExecutable( CurrentProcessInformation.GetCurrentProcessFilePath()); logger.Information("Launched installed executable."); }
public void ChangingStartWithWindowsToTrueWritesRunKey() { Container .Resolve <IRegistryManager>() .GetValue( GetRunRegistryPath(), "Shapeshifter") .Returns((string)null); SystemUnderTest.StartWithWindows = true; Container .Resolve <IRegistryManager>() .Received() .AddValue( GetRunRegistryPath(), "Shapeshifter", @"""" + CurrentProcessInformation.GetCurrentProcessFilePath() + @""""); }
async Task WriteExecutableAsync() { await fileManager.CopyFileAsync( CurrentProcessInformation.GetCurrentProcessFilePath(), InstallationInformation.TargetExecutableFile); }
void Install() { processManager.LaunchFileWithAdministrativeRights( CurrentProcessInformation.GetCurrentProcessFilePath(), "install"); }