2014-02-22 47 views
2

上創建快捷方式我使用Qt框架安裝1.5Qt的安裝框架:在桌面

安裝完畢後,我想在桌面上添加快捷方式。

在我的文件installscript.qs,我想:

Component.prototype.createOperationsForPath = function() 
{ 
    if (installer.value("os") === "win") 
    { 
    try { 
     component.addOperation("CreateShortcut", "@[email protected]/App.exe", "@[email protected]/App.lnk"); 
    } 
    catch (e) { 
     print(e); 
    } 
    } 
} 

但它不工作,不創建快捷方式,我沒有任何錯誤消息。 互聯網上的文檔真的很輕。

有什麼想法? 謝謝

+0

嘗試在函數的第一行添加'component.createOperations();'。 –

+0

它不起作用:/ –

+0

當您嘗試在「開始」菜單上創建快捷方式時它工作嗎?您是否將腳本添加到包XML文件中?你是否聲明瞭組件(即'function Component(){}')? –

回答

7

試試這個。它爲我工作。

Component.prototype.createOperations = function() 
{ 
    try { 
     // call the base create operations function 
     component.createOperations(); 
     if (installer.value("os") == "win") { 
      try { 
       var userProfile = installer.environmentVariable("USERPROFILE"); 
       installer.setValue("UserProfile", userProfile); 
       component.addOperation("CreateShortcut", "@[email protected]\\MiamPlayer.exe", "@[email protected]\\Desktop\\MiamPlayer.lnk"); 
      } catch (e) { 
       // Do nothing if key doesn't exist 
      } 
     } 
    } catch (e) { 
     print(e); 
    } 
}