-3

i made a fake virus to try on my friends :P But i was wondering if there is a code that disables the command-option-escape feature until the application finishes. I just want them to experience the whole process of my experiment without them force quitting it halfway through. Thanks

:edit- It's just a simple script that i thought i could show my friends but i just didn't want them to force quit it after the first few seconds, they still have full control over their mac

display dialog "Play MagroXELA's game" buttons {"Play", "Quit"} default button 1 if the button returned of the result is "Play" then

set volume 5

beep 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
    We surely don't help you preventing somebody from gaining back control over his computer. Why should we believe you it's harmless script you will just give to your friends? – idmean Sep 20 '14 at 12:49
  • i posted the script to show what it does, just thought there would be a script that disabled force quit or even just hide the application from the force quit menu. I wouldn't want them to lose control over their computer –  Sep 20 '14 at 12:59
  • indeed there's a way to achieve this. While the script you have posted doesn't look very dangerous you still could use the information I gave you for another really evil script. And one looses the control over his Mac when it starts opening several apps and many windows. – idmean Sep 20 '14 at 14:13
  • hmm i guess so, but i am using school macs right now for another few years until i finish school, so i take full responsibility if i mess up their mac due to this. I don't intend it to use it for evil scripts, i'm only a newb on this applescript :P but i get what you are saying –  Sep 20 '14 at 23:21

2 Answers2

2

You can also do it this way:

  1. Save the script as application (File > Save and choose as File Format Application) anywhere on your Mac. Then close the AppleScript Editor.

  2. Then navigate to the application in Finder and right click it and choose Show Package Contents

  3. A directory containing the directory Contents will show up. Inside this folder there will be a file named Info.plist

  4. Open this file with your favorite text editor (e.g. TextEdit).

Then add this code at the end of the file before the last </dict>:

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

So that the last four lines of the file are looking like this:

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

Save the file and you're ready to go. You can close the text editor and double click the application.

This property causes OS X to run the app as background process and background processes don't show up in the Dock and they don't show up in the Force Quit window. Of course you can still force quit the application by using Activity Monitor.

Be aware of that this property doesn't allow any User Interaction like display dialog or choose folder.

(If you open the application in the AppleScript Editor you have to repeat this steps because the script editor overrides Info.plist on every save)

idmean
  • 14,540
  • 9
  • 54
  • 83
  • yea i just found that out a few hours ago, except with LSUIelement instead, thanks for the help. Btw what did you mean by "Be aware of that this property doesn't allow any User Interaction like display dialog or choose folder". Both the LSBackground and LSUIelement are similar yet i'm able to see display dialog and can click the buttons. –  Sep 21 '14 at 10:44
  • @AlexDylanMagri AppleScript sometimes quit the app with the message "UI not allowed" when you are displaying a dialog that's what I meant. If my or any answer has solved your question please consider [accepting it](http://meta.stackexchange.com/q/5234/179419) by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this. – idmean Sep 21 '14 at 10:49
  • alright thanks, i clicked the check mark, as i'm sure others would find this useful. thankyou. New to this site also –  Sep 21 '14 at 11:03
1

You can execute any applescript code using the command line tool "osascript". Running command line tools don't show up in the force-quit menu so this method should work for you. For example suppose this was your applescript...

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

Here's how to run that using 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 &"

So basically all you have to do is convert your applescript code into text and then send it to osascript as shown.

Good luck.

regulus6633
  • 18,848
  • 5
  • 41
  • 49