@echo off setlocal rem Check if the script is running with administrative privileges net…
- User
@echo off setlocal rem Check if the script is running with administrative privileges net session >nul 2>&1 if %errorlevel% neq 0 ( echo Requesting administrative privileges... powershell -Command "Start-Process cmd -Argument '/c %~s0 %*' -Verb runAs" exit /b )
rem Set the rule name and software name set "ruleName=hola" set "softwareName=AndroidEmulatorEn" set "executablePath="
rem Check if the firewall is enabled netsh advfirewall show allprofiles state | find "State" | find "ON" >nul if %errorlevel% neq 0 ( echo Windows Firewall is disabled. Please enable the firewall to use this fixer. pause exit /b )
rem Check if the process is running and get the path for /f "tokens=1" %%i in ('tasklist /fo csv ^| find /I "AndroidEmulatorEn.exe"') do ( set "processName=%%~i" )
rem Get the executable path based on the process name for /f "tokens=2 delims=," %%i in ('wmic process where "name='AndroidEmulatorEn.exe'" get ExecutablePath /format:csv ^| find /I "AndroidEmulatorEn.exe"') do ( set "executablePath=%%~i" )
rem If the path was not found, exit if "%executablePath%"=="" ( echo Gameloop is not running. Please ensure it is running. pause exit /b )
rem Check the command line argument and call respective subroutine if "%~1"=="start" ( call :start_fixer ) else if "%~1"=="stop" ( call :stop_fixer ) else if "%~1"=="no_match" ( call :no_match_found_fix ) else ( echo Invalid option. pause exit /b )
goto end
:start_fixer echo Starting Fixer.. netsh advfirewall firewall add rule name="%ruleName%" protocol=TCP remoteport=80-17500 dir=out action=block program="%executablePath% powershell -c "[console]::beep(1500,500)" >nul 2>&1 powershell -c "[console]::beep(1500,500)" >nul 2>&1 exit /b
:stop_fixer timeout /t 15 >nul echo Stopping Fixer...please wait inorder to avoid restricted area error netsh advfirewall firewall delete rule name="%ruleName%" >nul 2>&1 powershell -c "[console]::beep(500,1000)" >nul 2>&1 exit /b
:no_match_found_fix echo Applying No Match Found Fix... netsh advfirewall firewall add rule name="%ruleName%" protocol=TCP remoteport=80-17500 dir=out action=block program="%executablePath% timeout /t 15 >nul echo Stopping Fixer...please wait inorder to avoid restricted area error powershell -c "[console]::beep(1500,500)" >nul 2>&1 powershell -c "[console]::beep(1500,500)" >nul 2>&1 timeout /t 3 >nul netsh advfirewall firewall delete rule name="%ruleName%" >nul 2>&1 powershell -c "[console]::beep(500,1000)" >nul 2>&1 exit /b
:end exit /b fix this code such that if start_fixer, stop_fixer or no_match_found_fix is called then a new terminal should not pop up
- Assistant
- User
the script is not working now and terminal windows still popped and closed
- Assistant
- User
same
- Assistant
- User
i am using this AHK V2 script with it , does it need to be modified too ? ; AutoHotkey v2 Script to trigger batch file actions
#SingleInstance Force
; Set the current working directory to the script's directory SetWorkingDir A_ScriptDir
; Hotkey for ALT + F (Start Fixer) !f:: { Run A_ScriptDir "\fixer_control.bat start" }
; Hotkey for ALT + G (Stop Fixer) !g:: { Run A_ScriptDir "\fixer_control.bat stop" }
; Hotkey for ALT + H (No Match Found Fix) !h:: { Run A_ScriptDir "\fixer_control.bat no_match" }
- Assistant
The AutoHotkey v2 script you've provided is designed to call a batch file with different parameters based on specific hotkeys. Given that it's a simple trigger mechanism for the batch script, it may not necessarily need modification unless there is a specific issue with how the commands are being executed.
However, to properly integrate with the changes we discussed for the batch file, we should ensure that:
- The paths used in
Runare correctly formatted. - The batch file is correctly interpreted and executed without unintended duplicate backslashes.
- The paths used in
- User
Warning: This local variable appears to never be assigned a value.
Specifically: Hide
004: SetWorkingDir(A_ScriptDir) 007: {▶ 009: Run('"' A_ScriptDir "\fixer_control.bat" '" start',, Hide) 010: } 013: {
For more details, read the documentation for #Warn.
- Assistant
The warning you're encountering suggests that the use of
Hidein theRunfunction is incorrect because in AutoHotkey v2, theRunfunction's parameters have changed from previous versions. Let's adjust the script to correctly use theRuncommand in AutoHotkey v2.In AutoHotkey v2, the
Runfunction uses named parameters, and the approach for executing without showing a window is handled slightly differently. Here's how you can modify your script:#SingleInstance Force ; Set the current working directory to the script's directory SetWorkingDir(A_ScriptDir) ; Hotkey for ALT + F (Start Fixer) !f:: { ; Correct usage of Run with window options in AHK v2 Run(A_ScriptDir "\fixer_control.bat start", , "Hide") } ; Hotkey for ALT + G (Stop Fixer) !g:: { Run(A_ScriptDir "\fixer_control.bat stop", , "Hide") } ; Hotkey for ALT + H (No Match Found Fix) !h:: { Run(A_ScriptDir "\fixer_control.bat no_match", , "Hide") } - User
- Assistant
If you are not seeing the
echostatements printed on the terminal, especially the"Stopping Fixer...please wait inorder to avoid restricted area error"line, it could be due to thetimeoutcommand redirecting the output and delays preventing the message from being visible. Let's ensure that the messages get a chance to appear before the script performs actions that may obscure them.Another possibility is if there are some logical issues in the code execution path, but based on the provided script structure, it looks logically integrated. Here's an adjusted version of the
:stop_fixersection to ensure that messages are displayed as expected: - User
not working
- Assistant
To address the issue where the message is not being displayed as expected, let's ensure that the logic flow is correct and the output is not being accidentally redirected or masked by other commands. Here's a refined approach with some additional diagnostic steps you can take to troubleshoot:
- User
it is functioning but echo is not being displayed
- Assistant
If the
echooutputs in the batch script are not being displayed, but the actual functionality (e.g., firewalls rules being toggled) is working as expected, it might be an issue with how and when those messages are being presented.Here are a few steps to ensure you're able to view the outputs:
- User
I am using this AHK V2 script with the above code which i gave : #SingleInstance Force
; Set the current working directory to the script's directory SetWorkingDir(A_ScriptDir)
; Hotkey for ALT + F (Start Fixer) !f:: { ; Correct usage of Run with window options in AHK v2 Run(A_ScriptDir "\fixer_control.bat start", , "Hide") }
; Hotkey for ALT + G (Stop Fixer) !g:: { Run(A_ScriptDir "\fixer_control.bat stop", , "Hide") }
; Hotkey for ALT + H (No Match Found Fix) !h:: { Run(A_ScriptDir "\fixer_control.bat no_match", , "Hide") }
- Assistant
Given the AutoHotkey v2 script you are using to call the batch file, it seems that you are executing the batch script in hidden mode with the
"Hide"option, which is likely why you cannot see theechooutputs from your batch script in the console.When the
Runfunction in AutoHotkey is used with the option, it prevents the console window from displaying, which means any output from the batch script, including statements, will not be visible to the user. To troubleshoot this or to see the output temporarily, you can remove the option for the command to let the console window appear. - User
- Assistant
- User
fixer_menu code is already open in one terminal so i want the output of fixer_control.bat to be displayed on fixer_menu window itself and not seperate window
- Assistant
- User
i want adb batch code to refresh internet connectivity of a particular app in emulator : set ACTIVITY=com.pubg.imobile/com.epicgames.ue4.SplashActivity
adb shell dumpsys activity activities | findstr /C:"%ACTIVITY%" if %errorlevel% equ 0 ( echo The activity %ACTIVITY% is running. adb shell am force-stop com.pubg.imobile ) else ( echo The activity %ACTIVITY% is not running. )
- Assistant
To create a batch script that refreshes the internet connectivity of a particular app in an Android emulator, you'll need to perform these steps: check if the app's activity is running, force-stop the app if it is running, and then restart the app. This process effectively refreshes the app's network connectivity. Here's how you can write the script:
- User
i just want to refresh internet connectivity of that app , dont want to restart the app
- Assistant
If you want to refresh the internet connectivity of an app without restarting it, you can achieve this by briefly disabling and then re-enabling the network interface on the emulator. This method simulates a network toggle, which effectively refreshes the app's internet connectivity without force-stopping or restarting the app itself.
Here is a batch script to achieve this using
adb:@echo off setlocal :: Define the network interface to toggle set "NETWORK_INTERFACE=wifi" :: Disable the network interface echo Disabling network interface... adb shell svc %NETWORK_INTERFACE% disable timeout /t 3 >nul :: Enable the network interface echo Enabling network interface... adb shell svc %NETWORK_INTERFACE% enable timeout /t 3 >nul echo Internet connectivity has been refreshed for the app. endlocal