2013-08-07 17 views
0

이 게시물을 따라 sllauncher에 인수를 프로그램 방식으로 전달하는 Silverlight Out of Browser 응용 프로그램을 제거하려고합니다 : http://timheuer.com/blog/archive/2010/03/25/using-sllauncher-for-silent-install-silverlight-application.aspx 그러나 출처가 주어지면 응용 프로그램이 제거되지 않습니다.프로그래밍 방식으로 SIlverlight 브라우저 외부에서 응용 프로그램을 제거 할 수 없습니다

답변

3

자동으로 브라우저 외부 실행 응용 프로그램을 업데이트하면 Silverlight는 각 응용 프로그램 Uri에 C : \ Users \ Trevor \ AppData \ Local의 응용 프로그램 폴더에있는 시간 스탬프를 스탬프 처리합니다 \ Microsoft \ Silverlight \ OutOfBrowser (AppFolderName) 메타 데이터 파일. 그래서 우리의 새로운 일에 대비하여 우리의 응용 프로그램의 제거를 용이하게하기 위해, 내가 구현 다음

UninstallExisting(GetInstalledAppUri()); // This is how it's called 
//This is the two method's implementation 

// TODO: Change to your app name.  
const string appName = "YourAppNameHere"; 

static string silverlightOutOfBrowserFolder = 
    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) 
    + @"\Microsoft\Silverlight\OutOfBrowser"; 

private static string GetInstalledAppUri() 
    { 
     string xapFolderPath = Path.Combine(silverlightOutOfBrowserFolder, GetXapFolder()); 
     string[] lines = File.ReadAllLines(Path.Combine(xapFolderPath, "metadata"), Encoding.Unicode); 
     string finalAppUriLine = lines.First(i => i.Contains("FinalAppUri=")); 
     return "\"" + finalAppUriLine.Replace("FinalAppUri=", "") + "\""; 
    } 

    private static string GetXapFolder() 
    { 
     string AppXapFolder = ""; 
     foreach (var dir in Directory.GetDirectories(silverlightOutOfBrowserFolder)) 
     { 
      if (dir.Contains(appName)) 
      { 
       AppXapFolder = dir; 
      } 
     } 
     return AppXapFolder ; 
    } 

private static string silverlightExe 
    { 
     get 
     { 
      return Path.Combine(
      Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), 
      @"Microsoft Silverlight\sllauncher.exe"); 
     } 
    } 

private static void UninstallExisting(string xapUriToRemove) 
    { 
     string installArgs = "/uninstall" + " /origin:" + xapUriToRemove; 
     ProcessStartInfo pstart = new ProcessStartInfo(silverlightExe, installArgs); 
     Process p = new Process(); 
     pstart.UseShellExecute = false; 
     p.StartInfo = pstart; 
     p.Start(); 
     p.WaitForExit(); 
    } 

나는이 다른 사람이 메타 데이터 파일에 대해 알아 내기 위해 나를 데려 시간의 시간을 저장하는 역할을 희망 sllauncher.exe의 모든 특색

+0

+1 자신의 질문에 대답 :) –