2011-11-22 59 views
1

我想檢查我們域上的用戶是否安裝了某個Firefox插件。也許我們可以有一個腳本,檢查插件創建的文件夾是否存在。如果不提高某種警告給用戶。如何在用戶登錄時檢查Firefox插件是否存在?

插件文件夾的一個例子如下。有隨機生成的部分可能會使它更復雜。

C:\ Documents and Settings \ username \ Application Data \ Mozilla \ Firefox \ Profiles {random}。{profile name(「default」)} \ {random-id} @jetpack \ resources {same random- ID}特技的噴氣揹包,pluginname數據\


  1. 我有關於Windows腳本不知道,這是第一次我甚至想着它
  2. 這個問題有點的「請爲我做」,因爲1.

回答

0

下面是一些PowerShell,它將搜索appdata目錄中包含該特殊插件名稱的所有文件夾。出現錯誤時,應提醒用戶並強制他們與警報(Read-Host)進行交互。當它們繼續時,您可以直接將Firefox啓動到安裝程序頁面。

if(-not(Get-ChildItem "$env:appdata\Mozilla\Firefox" -recurse -include "*@jetpack" | ?{ $_.PSIsContainer })) 
{ 
    Read-Host "The Firefox 'jetpack' plugin was not found. You will be redirected to the plugin page now. Please install the 'jetpack' plugin. (press any key to continue)" 
    & 'path\to\firefox.exe' 'http:\\path.to.plugin.com' 
} 

控制檯上的輸出應該是這個樣子

The Firefox 'jetpack' plugin was not found. You will be redirected to the plugin page now. Please install the 'jetpack' plugin. (press any key to continue): 
+0

在技術方面一點,但我確定它。很好的想法馬上啓動Firefox到安裝程序,甚至沒有想到這種可能性。 – danneth

+0

我肯定會拋棄'Write-Error',在'Read-Host'中打印友好的東西(迫使用戶響應警報),並啓動firefox(我更新了答案)。我假設你已經熟悉了將腳本放在[startup](http://goo.gl/NWCeE)上運行的地方? –

1

這可能嗎?當然。我不確定最好的方法,但是我會從PowerShell的角度來攻擊它。

可能很難使用PowerShell,因爲您需要驗證是否每個人都安裝了PowerShell。如果你可以驗證,這是一個非常簡單的請求。

使用

$firefoxfiles = Get-ChildItem -Path ($env:appdata + "\Mozilla\Firefox\Profiles") -Recurse 

這會給你在該目錄中的所有文件的列表...把所有的代碼在這個答案作爲一個例子,你肯定要改變它。

if (!($firefoxfiles | Where-Object {$_.Name -eq "PluginFileName"}) { 
...code for pop up...} 

從PowerShell中可以看到大量的樣本。

祝你好運!