+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
Educational Software Thread, App Inventor Batch File Issue in Technical; Hello folks, I really want to start using Google's App Inventor in the classroom. The Network Manager at my school ...
  1. #1

    Join Date
    May 2007
    Posts
    4
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    App Inventor Batch File Issue

    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

  2. #2

    SimpleSi's Avatar
    Join Date
    Jun 2005
    Location
    Lancashire
    Posts
    5,812
    Thank Post
    1,476
    Thanked 592 Times in 444 Posts
    Rep Power
    168
    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

  3. #3
    round2it's Avatar
    Join Date
    May 2009
    Location
    UK
    Posts
    999
    Thank Post
    198
    Thanked 144 Times in 102 Posts
    Rep Power
    36
    we block .bat here also it is a standard thing we do
    Last edited by round2it; 14th February 2011 at 08:23 AM.

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

  5. #5


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,893
    Thank Post
    226
    Thanked 2,674 Times in 1,971 Posts
    Rep Power
    786
    ^ 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
    Code:
    #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
    Code:
    #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
    Code:
    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. <a href="http://www.gnu.org/prep/standards/
    ;                                              html_node/Command_002dLine-Interfaces.html">Page</a>. '--' 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: ':'. <a
    ;                                              href="http://technet.microsoft.com/en-us/library/ee156811.aspx">Page</a>
    ;                                   |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

  6. 3 Thanks to Arthur:

    MrRubbs (10th April 2013), Potts (15th February 2011)

  7. #6
    TheLibrarian
    Guest
    Top notch post Arthur, I've added thanks because I can't add rep for some reason.

  8. #7

    ZeroHour's Avatar
    Join Date
    Dec 2005
    Location
    Edinburgh, Scotland
    Posts
    5,705
    Thank Post
    904
    Thanked 1,321 Times in 803 Posts
    Blog Entries
    1
    Rep Power
    445
    Quote Originally Posted by Potts View Post
    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.

    Quote Originally Posted by TheLibrarian View Post
    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.

  9. #8
    TheLibrarian
    Guest
    Quote Originally Posted by ZeroHour View Post
    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.

  10. #9


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339
    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?

  11. #10

    ZeroHour's Avatar
    Join Date
    Dec 2005
    Location
    Edinburgh, Scotland
    Posts
    5,705
    Thank Post
    904
    Thanked 1,321 Times in 803 Posts
    Blog Entries
    1
    Rep Power
    445
    Quote Originally Posted by CyberNerd View Post
    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....

  12. #11


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339
    Quote Originally Posted by ZeroHour View Post
    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.

  13. #12

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,684
    Thank Post
    516
    Thanked 2,452 Times in 1,898 Posts
    Blog Entries
    24
    Rep Power
    832
    Batch files in user space can still do damage - mass wiping documents, mass copying emails from inboxes, etc... They're just dangerous.

  14. #13


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339
    Quote Originally Posted by localzuk View Post
    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?

  15. #14

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,684
    Thank Post
    516
    Thanked 2,452 Times in 1,898 Posts
    Blog Entries
    24
    Rep Power
    832
    Quote Originally Posted by CyberNerd View Post
    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?

  16. #15


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339
    Quote Originally Posted by localzuk View Post
    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

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. autodesk inventor 2008 hell - inventor studio not showing up
    By Oops_my_bad in forum Educational Software
    Replies: 4
    Last Post: 26th January 2011, 12:55 PM
  2. Android App Inventor
    By Dos_Box in forum Netbooks, PDA and Phones
    Replies: 4
    Last Post: 10th September 2010, 08:50 AM
  3. Copy Batch file
    By spider6986 in forum Windows
    Replies: 10
    Last Post: 8th February 2010, 04:15 PM
  4. Batch File (select random file) help
    By fil_b in forum Windows Server 2000/2003
    Replies: 5
    Last Post: 5th November 2009, 04:13 AM
  5. batch file help
    By beeswax in forum Scripts
    Replies: 9
    Last Post: 3rd March 2006, 07:48 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •