Jump to content

Recommended Posts

Posted

Hello folks,

 

I really want to start using Google's App Inventor in the classroom. The Network Manager at my school says that we won't be able to use it, as batch files are disabled on student logons. The App Inventor emulator is started with a batch file. Does anybody have any experience that might get us around this?

 

Best wishes,

Richard

Posted

As with all things - there will be a way but the experts here would need to know what sort of network/restrictions are used :)

 

But the (politically) best way would be to introduce your network manager to this place (as its full of network managers) and get them to ask the question rather than you (a teacher I presume) going back to them with possible solutions :)

 

regards

 

Simon

Guest TheLibrarian
Posted
I'd have thought that the obvious way would be to convert the .bat to an AutoIT executable.
Posted

^ That's what I was thinking too, since you can compile your scripts into EXEs and give them a pretty icon. :)

 

My attempt at converting the 'Run-Emulator' and 'Kill-Emulator' batch files into AutoIt is shown below - some things could probably be improved but both scripts worked perfectly when I tested them. If you don't need to make any changes to the scripts, you can download them in EXE form here (along with the icons). Extract 'Run-Emulator.exe' and 'Kill-Emulator.exe' to the AppInventor folder (usually %ProgramFiles%\AppInventor\commands-for-AppInventor) and then create a shortcut to them on the Start Menu.

 

Run-Emulator.au3

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=Android_Green.ico
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Description=AppInventor Launcher
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_Run_After=upx.exe --best --compress-resources=0 "%out%"
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include "CmdLine.au3"     ; Source: http://goo.gl/dyR50
_CmdLine_Parse("/")

; Is this running on a 64-bit version of Windows?
If @OSArch = "X64" Then
   $ProgramFilesDir = EnvGet('ProgramFiles(x86)')
Else
   $ProgramFilesDir = @ProgramFilesDir
EndIf

; ===============================================================================================================================
; VARIABLES
; ===============================================================================================================================
$AppInvData = FileGetShortName(@UserProfileDir) & "\.appinventor"
$AppInvDir  = FileGetShortName($ProgramFilesDir) & "\AppInventor\commands-for-AppInventor"
$AppInvEmu  = FileGetShortName($ProgramFilesDir) & "\AppInventor\commands-for-AppInventor\emulator.exe"
$MkSDCard   = FileGetShortName($ProgramFilesDir) & "\AppInventor\commands-for-AppInventor\mksdcard.exe"
$SDCardSize = '64M'

; Command-line switches for the emulator
$Kernel  = "from-Android-SDK\platforms\android-8\images\kernel-qemu"
$RAMDisk = "from-Android-SDK\platforms\android-8\images\ramdisk.img"
$System  = "from-Android-SDK\platforms\android-8\images\system.img"
$SDCard  = FileGetShortName(@UserProfileDir) & "\.appinventor\emulator\sdcard.img"
$SkinDir = "from-Android-SDK\platforms\android-8\skins"
$Skin    = "WVGA854" ; Skins: HVGA, HVGA-AppInventor, QVGA, WQVGA400, WQVGA432, WVGA800, WVGA854
$SysDir  = @TempDir
$Data    = $AppInvData & "\emulator\AppInventor-Emulator-Data"
$Scale   = "0.7"

$s1 = "-kernel" & " " & $Kernel & " " & "-ramdisk" & " " & $RAMDisk & " " & "-system" & " " & $System & " "
$s2 = "-sdcard" & " " & $SDCard & " " & "-skindir" & " " & $SkinDir & " " & "-skin"   & " " & $Skin   & " "
$s3 = "-sysdir" & " " & $SysDir & " " & "-data"    & " " & $Data    & " " & "-scale"  & " " & $Scale  & " "
$s4 = "-no-boot-anim"
$Switches = $s1 & $s2 & $s3 & $s4

; ===============================================================================================================================
; RUN EMULATOR
; ===============================================================================================================================

; Check if '/s' is used on the shortcut to this launcher and then run the emulator
If CmdLine("s") Then
_Setup()
RunWait($AppInvEmu & " " & $Switches, $AppInvDir, @SW_HIDE)
_CleanUp()
Else
_Setup()
RunWait($AppInvEmu & " " & $Switches, $AppInvDir, @SW_HIDE)
EndIf




; ===============================================================================================================================
; FUNCTIONS
; ===============================================================================================================================

; Check to see if the emulator data and SD card image files already exist? If not, copy or create them. AppInventor won't start otherwise.
Func _Setup()
If FileExists($Data) Then
Sleep(100)
Else
FileCopy($AppInvDir & "\Extras\AppInventor-Emulator-Data", $AppInvData & "\emulator\", 9)
EndIf

If FileExists($SDCard) Then
Sleep(100)
Else
RunWait($MkSDCard & " " & $SDCardSize & " " & $SDCard, $AppInvDir, @SW_HIDE)
EndIf
EndFunc

; Remove $AppInvData folder (> 130MB). Run when emulator closes to save disk space or to start from scratch.
Func _CleanUp()
If FileExists($AppInvData) Then
DirRemove($AppInvData, 1)
EndIf
EndFunc

 

Kill-Emulator.au3

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=Android_Red.ico
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Description=Kills AppInventor Emulator
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Run_After=upx.exe --best --compress-resources=0 "%out%"
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

$Process = "Emulator.exe"

While ProcessExists($Process)
ProcessClose($Process)
WEnd

 

CmdLine.au3

Global $CmdLine_Cache[1][2] = [[0, False]]

; #FUNCTION# ====================================================================================================================
; Name ..........: CmdLine
; Description ...: Returns the value of the command line parameter.
; Syntax ........: CmdLine( [ $sParam ] )
; Parameters ....: $sParam          - [optional] A string specifying the command line parameter to retrieve. Default is a blank
;                                     string, which is the parameter that does not have a named flag first.
; Return values .: Success          - If the parameter has a value, then that is returned. If not then True is.
;                  Failure          - False. Usually means that the parameter wasn't in the command line.
; Author(s) .....: Matt Diesel (Mat)
; Modified ......:
; Remarks .......:
; Related .......: _CmdLine_Parse
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func CmdLine($sParam = "")
   If $CmdLine_Cache[0][0] = 0 And $CmdLine[0] > 0 Then _CmdLine_Parse()

   If $sParam = "" Then
       Return $CmdLine_Cache[0][1]
   Else
       For $i = 1 To UBound($CmdLine_Cache) - 1
           If $CmdLine_Cache[$i][0] = $sParam Then Return $CmdLine_Cache[$i][1]
       Next
       Return False
   EndIf
EndFunc   ;==>CmdLine

; #FUNCTION# ====================================================================================================================
; Name ..........: _CmdLine_Parse
; Description ...:
; Syntax ........: _CmdLine_Parse( [ $sPrefix [, $asAllowed [, $sOnErrFunc ]]] )
; Parameters ....: $sPrefix         - [optional] The prefix for command line arguments. Default is '--'. It is recommended that
;                                     it is one of the following standards (although it could be anything):
;                                   |GNU     - uses '--' to start arguments. Page. '--' on it's own sets the
;                                              unnamed argument but always uses the next parameter, even if prefixed by '--'.
;                                              E.g. '-- --file' will mean CmdLine() = '--file'.
;                                   |MS      - uses '-'. Arguments with values are seperated by a colon: ':'. ;                                              href="http://technet.microsoft.com/en-us/library/ee156811.aspx">Page
;                                   |Slashes - Not sure where it's a standard, but using either backslash ( '\' ) or slash
;                                              ( '/' ) is fairly common. AutoIt uses it  Just make sure the user knows which
;                                              one it is.
;                  $asAllowed       - [optional] A zero based array of possible command line arguments that can be used. When an
;                                     argument is found that does not match any of the values in the array, $sOnErrFunc is called
;                                     with the first parameter being "Unrecognized parameter: PARAM_NAME".
;                  $sOnErrFunc      - [optional] The function to call if an error occurs.
; Return values .: None
; Author(s) .....: Matt Diesel (Mat)
; Modified ......:
; Remarks .......:
; Related .......: This function must be called (rather than used in #OnAutoItStartRegister), as it uses a global array.
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _CmdLine_Parse($sPrefix = "--", $asAllowed = 0, $sOnErrFunc = "")
   If IsString($asAllowed) Then $asAllowed = StringSplit($asAllowed, "|", 3)

   For $i = 1 To $CmdLine[0]
       If $CmdLine[$i] = "--" Then
           If $i <> $CmdLine[0] Then
               $CmdLine_Cache[0][1] = $CmdLine[$i + 1]
               $i += 1
           Else
               $CmdLine_Cache[0][1] = True
           EndIf
       ElseIf StringLeft($CmdLine[$i], StringLen($sPrefix)) = $sPrefix Then
           $CmdLine_Cache[0][0] = UBound($CmdLine_Cache)
           ReDim $CmdLine_Cache[$CmdLine_Cache[0][0] + 1][2]

           If StringInStr($CmdLine[$i], "=") Then
               $CmdLine_Cache[$CmdLine_Cache[0][0]][0] = StringLeft($CmdLine[$i], StringInStr($CmdLine[$i], "=", 2) - 1)
               $CmdLine_Cache[$CmdLine_Cache[0][0]][0] = StringTrimLeft($CmdLine_Cache[$CmdLine_Cache[0][0]][0], StringLen($sPrefix))
               $CmdLine_Cache[$CmdLine_Cache[0][0]][1] = StringTrimLeft($CmdLine[$i], StringInStr($CmdLine[$i], "=", 2))
           ElseIf StringInStr($CmdLine[$i], ":") Then
               $CmdLine_Cache[$CmdLine_Cache[0][0]][0] = StringLeft($CmdLine[$i], StringInStr($CmdLine[$i], ":", 2) - 1)
               $CmdLine_Cache[$CmdLine_Cache[0][0]][0] = StringTrimLeft($CmdLine_Cache[$CmdLine_Cache[0][0]][0], StringLen($sPrefix))
               $CmdLine_Cache[$CmdLine_Cache[0][0]][1] = StringTrimLeft($CmdLine[$i], StringInStr($CmdLine[$i], ":", 2))
           Else
               $CmdLine_Cache[$CmdLine_Cache[0][0]][0] = StringTrimLeft($CmdLine[$i], StringLen($sPrefix))
               If ($i <> $CmdLine[0]) And (StringLeft($CmdLine[$i + 1], StringLen($sPrefix)) <> $sPrefix) Then
                   $CmdLine_Cache[$CmdLine_Cache[0][0]][1] = $CmdLine[$i + 1]
                   $i += 1
               Else
                   $CmdLine_Cache[$CmdLine_Cache[0][0]][1] = True
               EndIf
           EndIf

           If $asAllowed <> 0 Then
               For $n = 0 To UBound($asAllowed) - 1
                   If $CmdLine_Cache[$CmdLine_Cache[0][0]][0] = $asAllowed[$n] Then ContinueLoop 2
               Next

               If $sOnErrFunc <> "" Then Call($sOnErrFunc, "Unrecognized parameter: " & $CmdLine_Cache[$CmdLine_Cache[0][0]][0])
           EndIf
       Else
           If Not $CmdLine_Cache[0][1] Then
               $CmdLine_Cache[0][1] = $CmdLine[$i]
           Else
               If $sOnErrFunc <> "" Then Call($sOnErrFunc, "Unrecognized parameter: " & $CmdLine[$i])
           EndIf
       EndIf
   Next
EndFunc   ;==>_CmdLine_Parse

  • Thanks 2
Guest TheLibrarian
Posted
Top notch post Arthur, I've added thanks because I can't add rep for some reason.
Posted
Hello folks,

 

I really want to start using Google's App Inventor in the classroom. The Network Manager at my school says that we won't be able to use it, as batch files are disabled on student logons. The App Inventor emulator is started with a batch file. Does anybody have any experience that might get us around this?

 

Best wishes,

Richard

Hi

There may be ways around it but I wouldnt do it, if your school blocks running bats and you found a way to get around you could easily end up in trouble.

 

Top notch post Arthur, I've added thanks because I can't add rep for some reason.

You have probably given him +rep recently which prevents you.

Guest TheLibrarian
Posted
You have probably given him +rep recently which prevents you.

 

I suspect that's correct - I just can't remember the last time I did give rep.

Posted

can someone explain why it is a problem running batch files?

presumably the batch file can only run with the users permissions - so what is the worst that can happen? Is windows really that insecure - or are you all just paranoid?

Posted
can someone explain why it is a problem running batch files?

presumably the batch file can only run with the users permissions - so what is the worst that can happen? Is windows really that insecure - or are you all just paranoid?

 

Sigh..... there are valid reasons and its not because windows is insecure.... funnily the same reasons people would want to block scripts on linux/mac as well....

Posted
Sigh..... there are valid reasons and its not because windows is insecure.... funnily the same reasons people would want to block scripts on linux/mac as well....

 

what are they?

it is in userspace.

can you give an example of how this is going to damage the system.

Posted
Batch files in user space can still do damage - mass wiping documents, mass copying emails from inboxes, etc... They're just dangerous.

 

so whats the issue with allowing a file from a fixed read only location?

Posted
so whats the issue with allowing a file from a fixed read only location?

 

How do you allow a batch file in windows from one location but not all other locations?

Posted
How do you allow a batch file in windows from one location but not all other locations?

 

off the top of my head:

 

software restriction policy

banning files saved in home areas

antivirus solution

Posted
funnily the same reasons people would want to block scripts on linux/mac as well....

 

can't see why you would want to do this on linux/mac either - half the O/S runs on shell scripts....

Posted
off the top of my head:

 

software restriction policy

banning files saved in home areas

antivirus solution

 

Or, use the GPO that exists for preventing scripts running... Which is what most places do, as this is standard practice in most schools I've ever come across.

Posted
Or, use the GPO that exists for preventing scripts running... Which is what most places do, as this is standard practice in most schools I've ever come across.

 

A software restriction policy would work just as well.

Sounds to me like the NM concerned can't be arsed to work out a solution. Shame.

  • 2 years later...
Posted

Apologies for resurrecting a 2 year old thread.. but i suspect i'm not the first (and won't be the last) to wind up here!!

 

Like most people, i have the "Prevent Access To The Command Prompt" GPO set which i intend to keep.

 

The AutoIt scripts are great and work well to get my emulator running, but i can't seem to get the "Blocks Editor" to load from the appinventor.mit.edu website at all.. Much like the emulator, the editor works if the "prevent access to the command prompt" gpo is not set.

 

Has anyone got around this? Or am i missing the point?

 

Again, sorry for the resurrect, but this seemed the post which had the most useful guidance in it so far!

 

Matt

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...