2014-09-20 27 views
-3

我做了一個假病毒來嘗試我的朋友:P但我想知道是否有代碼禁用命令選項轉義功能,直到應用程序完成。我只是希望他們體驗我實驗的整個過程,而不會讓他們在半途中退出。由於有沒有辦法在applescript應用程序仍在運行時禁用強制退出?

:編輯 - 這只是一個簡單的腳本,我想我可以告訴我的朋友,但我只是不想讓他們逼的最初幾秒鐘後退出的話,他們還是可以完全掌控自己的MAC

顯示對話框「播放MagroXELA的遊戲」的按鈕{「播放」,「退出」}默認按鈕1 如果結果的返回按鈕是「播放」,則

設定容積5

蜂鳴5

display dialog "Virus is downloading." buttons "Stop" default button "Stop" with title "Malware Initiating" with icon 2 
delay 2 
set volume 5 
do shell script "say -v Zarvox Virus has Down loaded Successfully" 
delay 2 
do shell script "say -v Zarvox Wifi terminated" 
beep 1 
-- 
-- Toggle Airport Power On and Off 
-- 
if (offset of "On" in (do shell script "networksetup -getairportpower en1")) > 0 then 
    do shell script "networksetup -setairportpower en1 off" 

end if 

tell application "Finder" 
    activate 
    open application file "Activity Monitor.app" of folder "Utilities" of folder "Applications" of startup disk 
    open application file "AirPort Utility.app" of folder "Utilities" of folder "Applications" of startup disk 
    open application file "Boot Camp Assistant.app" of folder "Utilities" of folder "Applications" of startup disk 
    open application file "Bluetooth File Exchange.app" of folder "Utilities" of folder "Applications" of startup disk 
    open application file "Disk Utility.app" of folder "Utilities" of folder "Applications" of startup disk 
    open application file "Keychain Access.app" of folder "Utilities" of folder "Applications" of startup disk 
    open application file "Terminal.app" of folder "Utilities" of folder "Applications" of startup disk 
    open application file "System Information.app" of folder "Utilities" of folder "Applications" of startup disk 
end tell 


tell application "Finder" 
    activate 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    make new Finder window 
    set target of Finder window 1 to startup disk 
    set target of Finder window 1 to startup disk 
    open application file "Terminal.app" of folder "Utilities" of folder "Applications" of startup disk 
    set target of Finder window 1 to startup disk 
    set target of Finder window 1 to folder "Applications" of startup disk 
end tell 

delay 6 
tell application "DigitalColor Meter" to quit 
tell application "Grab" to quit 
tell application "Network Utility" to quit 
tell application "System Information" to quit 
tell application "Terminal" to quit 
tell application "Keychain Access" to quit 
tell application "Disk Utility" to quit 
tell application "Bluetooth File Exchange" to quit 
tell application "Boot Camp Assistant" to quit 
tell application "AirPort Utility" to quit 
tell application "Activity Monitor" to quit 
tell application "App Store" to quit 
tell application "iTunes" to quit 
tell application "Finder" 
    repeat while window 1 exists 
     close window 1 
    end repeat 
    delay 2 
    set volume 5 
    do shell script "say -v Alex YOU GOT TROLLED HUH HUH HUH HUH" 
    delay 2 
    do shell script "say -v Zarvox Wifi activated" 

    -- 
    -- Toggle Airport Power On and Off 
    -- 
    if (offset of "On" in (do shell script "networksetup -getairportpower en1")) > 0 then 
     do shell script "networksetup -setairportpower en1 off" 
    else 
     do shell script "networksetup -setairportpower en1 on" 
    end if 
    delay 4 
+1

我們當然不會幫助你防止有人從後面獲得控制自己電腦。爲什麼我們應該相信你這是無害的腳本,你會給你的朋友? – idmean 2014-09-20 12:49:17

+0

我發佈了腳本來顯示它的功能,只是認爲會有一個禁用強制退出的腳本,甚至只是將應用程序從強制退出菜單中隱藏起來。我不希望他們失去對他們的電腦的控制 – 2014-09-20 12:59:56

+0

確實有辦法實現這一點。雖然你發佈的腳本看起來不是很危險,但你仍然可以使用我給你的信息來製作另一個非常邪惡的腳本。當它開始打開幾個應用程序和多個窗口時,就會失去對Mac的控制權。 – idmean 2014-09-20 14:13:30

回答

3

你也可以這樣來做:

  1. 保存腳本爲應用程序(文件>保存,然後選擇作爲文件格式應用)在Mac上的任何地方。然後關閉AppleScript編輯器。

  2. 然後導航到搜索應用程序並右鍵單擊它並選擇Show Package Contents

  3. 一個包含目錄Contents將顯示目錄。在這個文件夾裏面會有一個文件名爲Info.plist

  4. 用你最喜歡的文本編輯器(例如TextEdit)打開這個文件。

    <key>LSBackgroundOnly</key> 
    <true/> 
    

    ,以便該文件的最後四行正在尋找這樣的:

    <key>LSBackgroundOnly</key> 
        <true/> 
    </dict> 
    </plist> 
    

然後在文件結束最後</dict>之前添加此代碼

保存文件,你準備好了。您可以關閉文本編輯器並雙擊應用程序。

此屬性將導致OS X運行應用程序的後臺進程和後臺進程不會在Dock中顯示,他們並不在強制顯示退出窗口。當然,您仍然可以使用Activity Monitor強制退出應用程序。

請注意,此屬性不允許任何用戶交互,如display dialogchoose folder

(如果打開的AppleScript的編輯器的應用程序,您必須,因爲腳本編輯器覆蓋的Info.plist每次保存重複此步驟)

+0

是的,我剛剛發現,幾個小時前,除了與LSUIelement,而不是感謝您的幫助。順便說一句,你是什麼意思,「請注意,此屬性不允許任何用戶交互像顯示對話框或選擇文件夾」。 LSBackground和LSUIelement都很相似,但我可以看到顯示對話框,並可以單擊按鈕。 – 2014-09-21 10:44:53

+0

@AlexDylanMagri AppleScript有時在顯示對話框時顯示消息「UI不允許」,退出應用程序。如果我的或任何答案已解決您的問題,請點擊複選標記,考慮[接受](http://meta.stackexchange.com/q/5234/179419)。這向更廣泛的社區表明,您已經找到了解決方案,併爲答覆者和您自己提供了一些聲譽。沒有義務這樣做。 – idmean 2014-09-21 10:49:57

+0

好吧,謝謝,我點擊了複選標記,因爲我確信其他人會覺得這很有用。謝謝。此網站也是新手 – 2014-09-21 11:03:14

1

您可以使用命令行工具「osascript」執行任何applescript代碼。運行命令行工具不會顯示在強制退出菜單中,所以此方法應該適用於您。例如,假設這是你的AppleScript ...

tell application "TextEdit" to activate 
delay 5 
tell application "TextEdit" to quit 

下面介紹如何在使用osascript運行。

set theCode to "tell application \"TextEdit\" to activate 
delay 5 
tell application \"TextEdit\" to quit" 

do shell script "echo " & quoted form of theCode & " | osascript > /dev/null 2>&1 &" 

所以基本上所有你需要做的就是將您的AppleScript代碼轉換成文本,然後將其發送到osascript如圖所示。

祝你好運。

+0

我會嘗試,看看。謝謝:) – 2014-09-20 23:18:51

相關問題