[APP]FTP Server v1.0.1.2 [LastUpdate 9/9/2013] - Windows RT Development and Hacking
A Ftp Server program base on .net 4.5
Default admin username and password both are "admin".
Default root path is "C:\"
Anonymous is disabled default.
Input "hide" to hide console window.
Input "help" to view all command.
Input "help [a command]" to view this command description.
Input "quit" to stop service and exit.
For now there is no GUI of setting.
You can only change configuration by command or edit config file.
If you know XSD. You can see this : http://schema.wodsoft.com/FtpService.xsd
HTML:
<FtpService DefaultPath="C:\" MaxConnection="-1" AutoHide="true" Debug="false" Log="true" Port="21" Welcome="" xmlns="http://schema.wodsoft.com/FtpService.xsd">
<Groups>
<Group Name="Guests" List="true" Read="true" Write="false" Delete="false" /> <!--DO NOT DELETE-->
<Group Name="Administrators" List="true" Read="true" Write="true" Delete="true" Admin="true" /> <!--DO NOT DELETE-->
</Groups>
<Rules Mode="Denied or Allowed">
<Rule StartIP="192.168.1.1" EndIP="192.168.1.100" />
</Rules>
<Security>
<Item Path="/Users">
<SecurityGroups>
<SecurityGroup Name="Guests" List="true" Read="true" Write="true" Delete="true" />
</SecurityGroups>
</Item>
</Security>
<Users>
<User Username="Anonymous" Group="Guests" Enabled="false"/>
<User Username="admin" Password="admin" Group="Administrators"/>
<User Username="username" Password="pssword" Group="Guests" MaxConnection="1" RootPath="C:\Users" Enabled="true"/>
</Users>
</FtpService>
Run it then you can share your file to other computer!
ftp://your surface rt ip
Remember to confirm firewall access!
If you get some exception when you use this program. Please reply the log file where the exception step here. I will repair it.
Change Logs:
V1.0.1.2
- Fixed a bug that FileZilla can not list files of directory.
V1.0.1.1
- Fixed a bug about NullReferenceException.
v1.0.1.0
- Fixed thread probram that cpu will be fine.
- Add Timeout feature. When a client in 60s without any command, it will be kick.
- Add Windows Service feature(Of course, RT not support).
- Add Virtual Directory feature. A directory can be add to a user's rootpath.
- Configuration element name Changed. From "Groups" to "SecurityGroups", "Group" to "SecurityGroup".
Cool stuff! Is this your personal project? If not, please link the origin; if so, take credit for your work!
EDIT: No, software, you may not run as Admin. Not by default, anyhow. Not until I've decompiled your binary (or read the source, if it's posted somewhere) and am satisfied that it isn't going to break anything.
Hey Folks! I wrote a small Configurator-script for this FTP-Service, since no GUI is available atm, I think some Users might be happy with it...
Just extract it in the same Folder as the ftp-Service and enjoy
Cheers
Blade
P.S.:
Source-Code for intrested peoples:
Code:
@echo off
:BEG
if not exist "Backup.config" copy /y "Wodsoft.FtpService.exe.config" "Backup.config"
cls
ECHO ------------------------------------
ECHO Blade's Menu for FTP-Service
ECHO ------------------------------------
ECHO.
ECHO [1] Change Username and Password
ECHO [2] Change DefaultPath and MaxConnection
ECHO [3] Restore Default Settings
ECHO [4] Exit
ECHO.
ECHO -----------------------------------
set /P id=What do you want to do? %=%
if not exist "Backup.config" copy /y "Wodsoft.FtpService.exe.config" "Backup.config"
IF "%id%" == "1" GOTO Username
IF "%id%" == "2" GOTO DefaultPath
IF "%id%" == "3" GOTO Restore
IF "%id%" == "4" GOTO END
:Restore
copy /y "Backup.config" "Wodsoft.FtpService.exe.config"
del Backup.config
CLS
ECHO Default Settings restored! Press any key to exit...
PAUSE >NUL
GOTO END
:Username
CLS
set /P user=New Username: %=%
set /P pass=New Password: %=%
set ReplaceLine=25
set InFile=Wodsoft.FtpService.exe.config
set TempFile=Backup1.config
if exist "%TempFile%" del "%TempFile%"
setlocal enabledelayedexpansion
set /A Cnt=1
for /F "tokens=*" %%a in (%InFile%) do (
echo.%%a>> "%TempFile%"
set /A Cnt+=1
if !Cnt! GEQ %ReplaceLine% GOTO :ExitLoop
)
:ExitLoop
endlocal
echo.^<User Username="%user%" Password="%pass%" Group="Administrators"/^> >> "%TempFile%"
setlocal enabledelayedexpansion
set /A Cnt2=1
for /F "tokens=*" %%a in (%InFile%) do (
if !Cnt2! GEQ 26 echo.%%a>> "%TempFile%"
set /A Cnt2+=1
if !Cnt2! GEQ 29 GOTO :ExitLoop3
)
:ExitLoop3
endlocal
copy /y "%TempFile%" "%InFile%"
del "%TempFile%"
cls
GOTO BEG
:DefaultPath
CLS
set /P path=New default Path: %=%
set /P maxC=New Max Connections: %=%
set ReplaceLine2=9
set InFile=Wodsoft.FtpService.exe.config
set TempFile=Backup1.config
if exist "%TempFile%" del "%TempFile%"
setlocal enabledelayedexpansion
set /A Cnt=1
for /F "tokens=*" %%a in (%InFile%) do (
echo.%%a>> "%TempFile%"
set /A Cnt+=1
if !Cnt! GEQ %ReplaceLine2% GOTO :ExitLoop2
)
:ExitLoop2
endlocal
echo.^<FtpService DefaultPath="%path%" MaxConnection="%maxC%"^> >> "%TempFile%"
setlocal enabledelayedexpansion
set /A Cnt2=1
for /F "tokens=*" %%a in (%InFile%) do (
if !Cnt2! GEQ 10 echo.%%a>> "%TempFile%"
set /A Cnt2+=1
if !Cnt2! GEQ 29 GOTO :ExitLoop3
)
:ExitLoop3
endlocal
copy /y "%TempFile%" "%InFile%"
del "%TempFile%"
cls
GOTO BEG
:END
P.P.S.: I have also got a modified Version of @netham45's ClassiStartMenu, with working Skins and a script which restarts the Explorer after execution, but I wanted to wait for his permission to share it with you.
Wow, that's some hardcore batch scripting! I probably would have gone with Powershell's XML tools, but that works nicely. Being able to change the default port number, and possibly to add or edit non-admin users, would be cool, but your script should cover most use cases nicely. By the way, did you intend to create the backup file twice at the beginning?
Something else to consider would be starting/restarting/stopping the server, too.
EDIT: As for the CSM update, that would be fantastic. I suggest PMing Netham45, though he should see it soon enough. It's probable that the CSM license permits you to redistribute modifications of it freely, but it might not apply to derivitive works (didn't check) and asking is polite anyhow.
GoodDayToDie said:
Cool stuff! Is this your personal project? If not, please link the origin; if so, take credit for your work!
EDIT: No, software, you may not run as Admin. Not by default, anyhow. Not until I've decompiled your binary (or read the source, if it's posted somewhere) and am satisfied that it isn't going to break anything.
Click to expand...
Click to collapse
Yeah, this is my personal project. I will put the source code when it was done.
There are more detail like VirtualDirectory and GUI setting I'm going to do.
GUI setting will be last.
ps: without admin power. There are some directory can not visit. If you want, I will remove the admin power require for program.
BIade said:
Hey Folks! I wrote a small Configurator-script for this FTP-Service, since no GUI is available atm, I think some Users might be happy with it...
Just extract it in the same Folder as the ftp-Service and enjoy
Cheers
Blade
P.S.:
Source-Code for intrested peoples:
Code:
@echo off
:BEG
if not exist "Backup.config" copy /y "Wodsoft.FtpService.exe.config" "Backup.config"
cls
ECHO ------------------------------------
ECHO Blade's Menu for FTP-Service
ECHO ------------------------------------
ECHO.
ECHO [1] Change Username and Password
ECHO [2] Change DefaultPath and MaxConnection
ECHO [3] Restore Default Settings
ECHO [4] Exit
ECHO.
ECHO -----------------------------------
set /P id=What do you want to do? %=%
if not exist "Backup.config" copy /y "Wodsoft.FtpService.exe.config" "Backup.config"
IF "%id%" == "1" GOTO Username
IF "%id%" == "2" GOTO DefaultPath
IF "%id%" == "3" GOTO Restore
IF "%id%" == "4" GOTO END
:Restore
copy /y "Backup.config" "Wodsoft.FtpService.exe.config"
del Backup.config
CLS
ECHO Default Settings restored! Press any key to exit...
PAUSE >NUL
GOTO END
:Username
CLS
set /P user=New Username: %=%
set /P pass=New Password: %=%
set ReplaceLine=25
set InFile=Wodsoft.FtpService.exe.config
set TempFile=Backup1.config
if exist "%TempFile%" del "%TempFile%"
setlocal enabledelayedexpansion
set /A Cnt=1
for /F "tokens=*" %%a in (%InFile%) do (
echo.%%a>> "%TempFile%"
set /A Cnt+=1
if !Cnt! GEQ %ReplaceLine% GOTO :ExitLoop
)
:ExitLoop
endlocal
echo.^<User Username="%user%" Password="%pass%" Group="Administrators"/^> >> "%TempFile%"
setlocal enabledelayedexpansion
set /A Cnt2=1
for /F "tokens=*" %%a in (%InFile%) do (
if !Cnt2! GEQ 26 echo.%%a>> "%TempFile%"
set /A Cnt2+=1
if !Cnt2! GEQ 29 GOTO :ExitLoop3
)
:ExitLoop3
endlocal
copy /y "%TempFile%" "%InFile%"
del "%TempFile%"
cls
GOTO BEG
:DefaultPath
CLS
set /P path=New default Path: %=%
set /P maxC=New Max Connections: %=%
set ReplaceLine2=9
set InFile=Wodsoft.FtpService.exe.config
set TempFile=Backup1.config
if exist "%TempFile%" del "%TempFile%"
setlocal enabledelayedexpansion
set /A Cnt=1
for /F "tokens=*" %%a in (%InFile%) do (
echo.%%a>> "%TempFile%"
set /A Cnt+=1
if !Cnt! GEQ %ReplaceLine2% GOTO :ExitLoop2
)
:ExitLoop2
endlocal
echo.^<FtpService DefaultPath="%path%" MaxConnection="%maxC%"^> >> "%TempFile%"
setlocal enabledelayedexpansion
set /A Cnt2=1
for /F "tokens=*" %%a in (%InFile%) do (
if !Cnt2! GEQ 10 echo.%%a>> "%TempFile%"
set /A Cnt2+=1
if !Cnt2! GEQ 29 GOTO :ExitLoop3
)
:ExitLoop3
endlocal
copy /y "%TempFile%" "%InFile%"
del "%TempFile%"
cls
GOTO BEG
:END
P.P.S.: I have also got a modified Version of @netham45's ClassiStartMenu, with working Skins and a script which restarts the Explorer after execution, but I wanted to wait for his permission to share it with you.
Click to expand...
Click to collapse
Thank you for make a tool for this program.
If you have any idea please reply me:good:
GoodDayToDie said:
Wow, that's some hardcore batch scripting! I probably would have gone with Powershell's XML tools, but that works nicely.
Click to expand...
Click to collapse
That would have been better I think, but I'm just a noob
GoodDayToDie said:
Being able to change the default port
Click to expand...
Click to collapse
Done
GoodDayToDie said:
By the way, did you intend to create the backup file twice at the beginning?
Click to expand...
Click to collapse
No that was a mistake, (it was late yesterday)
GoodDayToDie said:
Something else to consider would be starting/restarting/stopping the server, too.
Click to expand...
Click to collapse
Starting FTP-Service is done
But stopping the Service using taskkill Needs the bat-file to run as admin right now (working on that)
GoodDayToDie said:
and possibly to add or edit non-admin users, would be
Click to expand...
Click to collapse
That is my last step
GoodDayToDie said:
EDIT: As for the CSM update, that would be fantastic. I suggest PMing Netham45, though he should see it soon enough. It's probable that the CSM license permits you to redistribute modifications of it freely, but it might not apply to derivitive works (didn't check) and asking is polite anyhow.
Click to expand...
Click to collapse
I already sent him a PM a while ago, but i don't want to bother him furthermore. He is such a nice dev and I don't want to steal his time...
Cheers Blade
Hey, here is my updated Version of the Menu. All suggestions but one included. The missing one is the "add non-admin user"-Feature.
- This script now asks for admin-rights, to be able to Stop the ftpService
- After starting the FtpService, I finally managed to get Focus back on the menu
- Change port is included
- Also included is the new config file, as the provided one doesn't have the port-Feature
EDIT: actually we don't Need this, as my script will add it. So ist just for restoring
-And a bit "design"-work
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Please tell me which Color you would like to have (forground and Background):
I used "4F"
Cheers
Blade
P.S.: New Code:
Code:
[user=279333]@ECHO[/user] off
mode con: cols=15 lines=1
:: Get ADMIN Privs
:-------------------------------------
mkdir "%windir%\BatchGotAdmin"
cls
if '%errorlevel%' == '0' (
rmdir "%windir%\BatchGotAdmin" & goto gotAdmin
) else ( goto UACPrompt )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute %0, "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
:-------------------------------------
:: End Get ADMIN Privs
:: [user=279333]@ECHO[/user] off
:BEG
mode con: cols=52 lines=15
TITLE Blade's Configurator
color 4F
if not exist "Backup.config" copy /y "Wodsoft.FtpService.exe.config" "Backup.config"
cls
ECHO ---------------------------------------------------
ECHO Blade's Menu for FTP-Service
ECHO ---------------------------------------------------
ECHO.
ECHO [1] Change Username and Password
ECHO [2] Change DefaultPath, Default Port, MaxConnection
ECHO [3] Restore Default Settings
ECHO [4] Start FTP-Service
ECHO [5] Stop FTP-Service
ECHO [x] Exit
ECHO.
ECHO ---------------------------------------------------
ECHO.
set /P id=What do you want to do? %=%
IF "%id%" == "1" GOTO Username
IF "%id%" == "2" GOTO DefaultPath
IF "%id%" == "3" GOTO Restore
IF "%id%" == "4" GOTO Open
IF "%id%" == "5" GOTO Close
IF "%id%" == "x" EXIT
:Close
taskkill /F /IM Wodsoft.FtpService.exe
GOTO BEG
:eek:pen
Start "" Wodsoft.FtpService.exe
Start "" call %~s0 :BEG
EXIT
:Restore
copy /y "Backup.config" "Wodsoft.FtpService.exe.config"
del Backup.config
CLS
ECHO Default Settings restored! Press any key to exit...
PAUSE >NUL
GOTO END
:Username
CLS
set /P user=New Username: %=%
set /P pass=New Password: %=%
set ReplaceLine=25
set InFile=Wodsoft.FtpService.exe.config
set TempFile=Backup1.config
if exist "%TempFile%" del "%TempFile%"
setlocal enabledelayedexpansion
set /A Cnt=1
for /F "tokens=*" %%a in (%InFile%) do (
echo.%%a>> "%TempFile%"
set /A Cnt+=1
if !Cnt! GEQ %ReplaceLine% GOTO :ExitLoop
)
:ExitLoop
endlocal
echo.^<User Username="%user%" Password="%pass%" Group="Administrators"/^> >> "%TempFile%"
setlocal enabledelayedexpansion
set /A Cnt2=1
for /F "tokens=*" %%a in (%InFile%) do (
if !Cnt2! GEQ 26 echo.%%a>> "%TempFile%"
set /A Cnt2+=1
if !Cnt2! GEQ 29 GOTO :ExitLoop3
)
:ExitLoop3
endlocal
copy /y "%TempFile%" "%InFile%"
del "%TempFile%"
cls
GOTO BEG
:DefaultPath
CLS
set /P path=New default Path: %=%
set /P port=New default Port: %=%
set /P maxC=New Max Connections: %=%
set ReplaceLine2=9
set InFile=Wodsoft.FtpService.exe.config
set TempFile=Backup1.config
if exist "%TempFile%" del "%TempFile%"
setlocal enabledelayedexpansion
set /A Cnt=1
for /F "tokens=*" %%a in (%InFile%) do (
echo.%%a>> "%TempFile%"
set /A Cnt+=1
if !Cnt! GEQ %ReplaceLine2% GOTO :ExitLoop2
)
:ExitLoop2
endlocal
echo.^<FtpService DefaultPath="%path%" MaxConnection="%maxC%" AutoHide="true" Debug="false" Log="true" Port="%port%" Welcome=""^> >> "%TempFile%"
setlocal enabledelayedexpansion
set /A Cnt2=1
for /F "tokens=*" %%a in (%InFile%) do (
if !Cnt2! GEQ 10 echo.%%a>> "%TempFile%"
set /A Cnt2+=1
if !Cnt2! GEQ 29 GOTO :ExitLoop3
)
:ExitLoop3
endlocal
copy /y "%TempFile%" "%InFile%"
del "%TempFile%"
cls
GOTO BEG
:END
Ok, now I have everything included. Was a bit difficult, but I somehow managed it
Cheers
Blade
P.S. Source-Code (It's getting wicked)
Code:
[URL="http://pastebin.com/SnfDtP5A"]http://pastebin.com/SnfDtP5A[/URL]
I cannot put it in here, the parsing here destroys my whole code: i.e.: from ":open" to ":eek:pen"
I got this message when try to open C:\user folder
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at Wodsoft.Net.FtpServerUser.<ReadCommand>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__1(Ob
ject state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object sta
te)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionCo
ntext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWor
kItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Click to expand...
Click to collapse
Then it crash and force close.
Next. When I disable anonymous login. I open FTP by internet explorer it ask for login then FtpService crash before I login (but login dialog still
open). This the error.
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at Wodsoft.Net.FtpServerUser.<ReadCommand>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__1(Ob
ject state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object sta
te)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionCo
ntext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWor
kItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Click to expand...
Click to collapse
Then I start FtpService again and login with admin:admin (from login dialog open before last time crash). It can login and list default folder list (C:\) but when I try to open C:\user again I got this before it force close again.
Unhandled Exception: 25/9/9 (?) 15:52:52 User 127.0.0.1:56509(admin) command "CW
D /Users/".
25/9/9 (?) 15:52:52 User 127.0.0.1:56509(admin) command "TYPE A".
System.NullReferenceException: Object reference not set to an instance of an obj
ect.
at Wodsoft.Net.FtpServerUser.<ReadCommand>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__1(Ob
ject state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object sta
te)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionCo
ntext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWor
kItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
25/9/9 (?) 15:52:52 User 127.0.0.1:56509(admin) command "PASV".
25/9/9 (?) 15:52:52 User 127.0.0.1:56509(admin) command "LIST".
Click to expand...
Click to collapse
hisoft said:
I got this message when try to open C:\user folder
Then it crash and force close.
Next. When I disable anonymous login. I open FTP by internet explorer it ask for login then FtpService crash before I login (but login dialog still
open). This the error.
Then I start FtpService again and login with admin:admin (from login dialog open before last time crash). It can login and list default folder list (C:\) but when I try to open C:\user again I got this before it force close again.
Click to expand...
Click to collapse
Thank you for your report.
I solved this problem.
Download version 1.0.1.1 and have fun.
P.S: Some directory require administrator level. Better start ftp service with administrator level.
Kation said:
Thank you for your report.
I solved this problem.
Download version 1.0.1.1 and have fun.
P.S: Some directory require administrator level. Better start ftp service with administrator level.
Click to expand...
Click to collapse
Thank you for this very fast fix. :laugh:
And yes. I start it as administrator. (Windows RT)
---------- Post added at 07:53 PM ---------- Previous post was at 07:27 PM ----------
I can use it with Internet Explorer now. But not with FileZilla. It can't list directory. Both for anonymous and admin.
Status: Connecting to 192.168.80.41:21...
Status: Connection established, waiting for welcome message...
Response: 220 Wodsoft FTP Service.
Command: USER admin
Response: 331 Password required for admin.
Command: PASS *****
Response: 230 User logged in success
Command: SYST
Response: 215 Microsoft Windows NT 6.2.9200.0
Command: FEAT
Response: 211-Extension supported:
Response: MDTM
Response: OPTS
Response: REST STREAM
Response: SCMD COMMAND
Response: SIZE
Response: 211 END.
Status: Connected
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/" is current directory.
Command: TYPE I
Response: 220 Type set to I.
Command: PASV
Response: 227 Entering Passive Mode (192,168,80,41,227,48).
Command: LIST
Response: 150 Opening Binary mode data connection.
Response: 125 Data connection already open. Transfer starting.
Error: Failed to retrieve directory listing
Response: 226 Transfer complete.
Response: 221 Timeout.
Error: Connection closed by server
Click to expand...
Click to collapse
Done.
Kation said:
Done.
Click to expand...
Click to collapse
Hey, can you share the source code? Would love to integrate it into my app to add ftp server capability.
sala91 said:
Hey, can you share the source code? Would love to integrate it into my app to add ftp server capability.
Click to expand...
Click to collapse
http://files.cnblogs.com/Kation/Wodsoft.Net.Ftp.rar
Related
[Script]Universal Quick Flasher
While I was pushing some files trough adb I thought it would be handy to have a script which automates it, a simple bat file in this case, can become very handy if you need to push some system apps for testing. It will show several reboot options afterwards and additionally it can flash a kernel to your device. I know it's better to just upgrade my Quick Flasher tool, but this was written in 10 min so why not share and upgrade later co credits: - stepie22 (helped me in expanding it) It requires adb in it's directory and the files you want to push as well. Kernelflasher.bat: Code: @echo off REM /* REM * cd to the current directory REM */ cd /d %~dp0 mode con:lines=30 REM /* REM * Check if adb is available in the path variable, the default path or the current directory. REM * Asks user if they want to download it if it is not found. REM */ set found= set quotedPath="%PATH:;="; "%" set prog=adb.exe for %%i in (%quotedPath%) do if exist %%i\%prog% set found=%%i :adbdetected REM /* REM * Added incase usb isn't properly connected REM */ title Universal Quick Flasher v1.04 - Waiting for device... echo Waiting for device... echo Please plugin android device with usb debugging enabled adb wait-for-device cls adb root adb remount title Universal Quick Flasher v1.04 goto main if not ""==%found% goto adbdetected if exist adb.exe goto adbdetected if exist "%programfiles%\Android\android-sdk\platform-tools\adb.exe" goto adbdetected REM /* REM * Added Windows 7 Default location for android-sdk REM */ if exist "%USERPROFILE%\android-sdks\platform-tools\adb.exe" goto adbdetected if exist "%USERPROFILE%\android-sdk\platform-tools\adb.exe" goto adbdetected goto noadb :main cls echo. echo ************************************* echo * Universal Quick Flasher v1.04 * echo * * echo * By broodplank1337 * echo * and * echo * stepie22 * echo * * echo * All Filenames are CaseSensitive! * echo ************************************* echo. echo What do you want to flash? echo. echo [1] App (system app or regular app) echo [2] Kernel echo. echo Optional echo. echo [3] Reboot echo [4] Visit project page echo. echo [79] exit echo. echo. set /p choice=: if "%choice%"=="1" goto app if "%choice%"=="2" goto kernel if "%choice%"=="3" goto rmenu if "%choice%"=="4" goto ppage if "%choice%"=="79" goto exit REM /* REM * Display error if no valid option was chosen REM */ echo Error, no option found for '%choice%'. pause goto main :kernel cls echo. echo Enter kernel name (zImage or boot.img) set /p kername= Kernel name: echo. echo Enter kernel partition number echo As in (/dev/block/mmcblk0p*) where * is your number set /p kernum= Kernel Partition Number: echo. cls :kernelck REM /* REM * Display for rewiew REM */ echo. echo Kernel name: %kername% echo FLash to : /dev/block/mmcblk0p%kernum% echo. set /p valid=Correct (y or n): if "%valid%"=="y" goto kernelcont if "%valid%"=="Y" goto kernelcont if "%valid%"=="n" goto kernel if "%valid%"=="N" goto kernel set msg=Incorrent option goto kernelck :kernelcont if not exist %kername% ( set returnto=kernel goto nofile ) echo. echo Flashing %kername% to /dev/block/mmcblk0p%kernum% adb push %kername% /sdcard/%kername% adb -d shell su -c "dd if=/sdcard/%kername% of=/dev/block/mmcblk0p%kernum%" echo. echo Done! Rebooting Device... echo. adb reboot pause goto goagain :app set /p name=APK Name: cls echo. echo APK Name: %name% echo APK Type: echo. echo [1] System App (/system/app) echo [2] Framework App (/system/framework) echo [3] Regular App (/data/system) echo. set /p type=: if "%type%"=="1" goto sysapp if "%type%"=="2" goto frameapp if "%type%"=="3" goto normapp REM /* REM * Display error if no valid option was chosen REM */ echo Error, no option found for '%type%'. pause cls goto app :sysapp if not exist %name% ( set returnto=app goto nofile ) adb push %name% /system/app/%name% adb -d shell chmod 644 /system/app/%name% cls echo. echo Do you want to reboot your device (y/n)? echo. set /p choice=: if "%choice%"=="n" goto goagain if "%choice%"=="N" goto goagain if "%choice%"=="y" goto rmenu if "%choice%"=="Y" goto rmenu echo ERROR, no option found for '%choice%' pause goto sysapp REM /* REM * Display error if no valid option was chosen REM */ echo Error, no option found for '%reboot%'. pause cls goto sysapp :frameapp if not exist %name% ( set returnto=app goto nofile ) adb push %name% /system/framework/%name% adb -d shell chmod 644 /system/framework/%name% cls echo. echo Do you want to reboot your device (y/n)? echo. set /p choice=: if "%choice%"=="n" goto goagain if "%choice%"=="N" goto goagain if "%choice%"=="y" goto rmenu if "%choice%"=="Y" goto rmenu echo ERROR, no option found for '%choice%' pause goto frameapp REM /* REM * Display error if no valid option was chosen REM */ echo Error, no option found for '%reboot%'. pause cls goto frameapp :normapp if not exist %name% ( set returnto=app goto nofile ) adb install %name% goto goagain :rmenu cls echo. echo [1] Shutdown echo [2] Reboot Normaly echo [3] Reboot fast echo [4] Reboot into Recovery echo [5] Reboot into Bootloader (Download Mode) echo [9] Main Menu echo [79] Exit echo. set /p rmenu=: if "%rmenu%"=="1" goto shutdown if "%rmenu%"=="2" goto reboot if "%rmenu%"=="3" goto rebootf if "%rmenu%"=="4" goto rebootr if "%rmenu%"=="5" goto rebootdl if "%rmenu%"=="9" goto main if "%rmenu%"=="79" goto exit echo. echo No option found for '%rmenu%' pause goto rmenu :ppage start http://broodplank.net/?p=729 goto main :shutdown echo. echo Shutting down device. adb shell reboot -p goto goagain :reboot echo. echo Rebooting Device Completely. adb reboot echo Done! goto goagain :rebootf echo. echo Rebooting Device Fast (kill system_server) adb -d shell su -c "busybox killall system_server" echo Done! goto goagain :rebootr echo. echo Rebooting Device into Recovery. adb reboot recovery goto goagain :rebootdl echo. echo Rebooting Device into Bootloader (Download Mode) adb reboot bootloader goto goagain :nofile cls echo. echo ******************************** echo * That file could not be found * echo ******************************** echo. echo Press enter to try again. set /p nofile= goto %returnto% :noadb cls echo. echo ************************ echo * ADB was not detected * echo ************************ echo. echo Download?? (y/n) set /p choice=: if "%choice%"=="n" goto exit if "%choice%"=="N" goto exit if "%choice%"=="y" goto dl if "%choice%"=="Y" goto dl echo ERROR, no option found for '%choice%' pause goto noadb :dl cls echo. echo ************************ echo * ADB was not detected * echo ************************ echo. echo Downloading adb.rar from broodplank.net... echo Extract it in: %~dp0 start http://broodplank.net/files/ADB.rar pause goto exit :goagain cls echo. echo Press m to go to the Main Menu, echo Press any other key to exit. echo. set /p goagain=: if "%goagain%"=="m" goto main if "%goagain%"=="M" goto main :exit echo. echo. echo Exiting... pause exit
Really useful one..thank u.. Sent from my GT-I9001 using Tapatalk 2
VERY VERY NICE SCRIPT! Omg you're a monster Inviato dal mio GT-I9001 che di originale non ha più nulla con la CyanogenMod RC1 usando Tapatalk 2.
lontu said: Really useful one..thank u.. Sent from my GT-I9001 using Tapatalk 2 Click to expand... Click to collapse You're welcome umb3rts said: VERY VERY NICE SCRIPT! Omg you're a monster Inviato dal mio GT-I9001 che di originale non ha più nulla con la CyanogenMod RC1 usando Tapatalk 2. Click to expand... Click to collapse Haha, I develop all the time (like 90% of the time that I spend on my computer) so I have a lot of things like these. I will keep producing more and more without question
Usefull as always.. The tools and roms are growing like trees here. I cant update the index on androidworld so fast :silly:
I wish I had enough free time to spend on developing, i have some ideas sometime... but not enough time to learn/write, altough i'm a native Linux user. brood, you are fantastic as always Inviato dal mio GT-I9001 che di originale non ha più nulla con la CyanogenMod RC1 usando Tapatalk 2.
if i may give you an idea: you could write an app which does basically this Code: :rebootf echo. echo Rebooting Device Fast (kill system_server) adb -d shell su -c "busybox killall system_server" echo Done! exit untill now i had to kill system_server using terminal emulator.
Hey Brood. Could you make something like a bat to get quick to my adb.exe? I hate it to cd through all the directorys to get to it. Example: I want to go to cmd.exe then type "adb" then for example "adb devices" and adb should start? Is that possible? P.S: As always i love your work. The script is really nice and wellmade with the logo and etc
mrjraider said: Usefull as always.. The tools and roms are growing like trees here. I cant update the index on androidworld so fast :silly: Click to expand... Click to collapse Thanks and yes it's growing very fast idd! umb3rts said: I wish I had enough free time to spend on developing, i have some ideas sometime... but not enough time to learn/write, altough i'm a native Linux user. brood, you are fantastic as always Inviato dal mio GT-I9001 che di originale non ha più nulla con la CyanogenMod RC1 usando Tapatalk 2. Click to expand... Click to collapse The key is to not spend your computer time on gaming but on developing hehe (works for me). but if you don't have enough time it will become hard And you're welcome ^^ dr.wtf said: if i may give you an idea: you could write an app which does basically this Code: :rebootf echo. echo Rebooting Device Fast (kill system_server) adb -d shell su -c "busybox killall system_server" echo Done! exit untill now i had to kill system_server using terminal emulator. Click to expand... Click to collapse Of course I can make that, I'm in linux right now so when i'm back in windows, I will make the app and send it to you. XeLLaR* said: Hey Brood. Could you make something like a bat to get quick to my adb.exe? I hate it to cd through all the directorys to get to it. Example: I want to go to cmd.exe then type "adb" then for example "adb devices" and adb should start? Is that possible? P.S: As always i love your work. The script is really nice and wellmade with the logo and etc Click to expand... Click to collapse Yes that can be achieved by adding: "cd /d %~dp0" in the batch script, the command will automatically cd to it's directory. And you need to enter "adb shell" to enter the adb shell , else it will close. adb shell > normal shell usage adb -d shell ".." > command here And you're welcome btw
broodplank1337 said: Yes that can be achieved by adding: "cd /d %~dp0" in the batch script, the command will automatically cd to it's directory. And you need to enter "adb shell" to enter the adb shell , else it will close. adb shell > normal shell usage adb -d shell ".." > command here And you're welcome btw Click to expand... Click to collapse Thank you very much!! :good:
Hey Brood do you know a nice howto about building an app wich base is a batch file ? Or is ot not possible to buold an android app with batch commands ? Sent from my GT-I9001 using xda app-developers app
Diablob555 said: Hey Brood do you know a nice howto about building an app wich base is a batch file ? Or is ot not possible to buold an android app with batch commands ? Sent from my GT-I9001 using xda app-developers app Click to expand... Click to collapse i think that its impossible because DOS uses its own functions. means that batch commands are especially for windows. Sent from my GT-I9001 using xda app-developers app
So I'll need java commands ? Sent from my GT-I9001 using xda app-developers app
What, you haven't updated it here? I feel offended! Na, just joking. To people who don't know what I'm talking about: http://broodplank.net/?p=729 Sent from my GT-I9001 using xda app-developers app
stepie22 said: What, you haven't updated it here? I feel offended! Na, just joking. To people who don't know what I'm talking about: http://broodplank.net/?p=729 Sent from my GT-I9001 using xda app-developers app Click to expand... Click to collapse True, well it's my site so it's not very strange if it gets priority but it's good that you take a look at my site, it has more hidden stuff v1.4 Code: @echo off REM /* REM * cd to the current directory REM */ cd /d %~dp0 mode con:lines=30 REM /* REM * Check if adb is available in the path variable, the default path or the current directory. REM * Asks user if they want to download it if it is not found. REM */ set found= set quotedPath="%PATH:;="; "%" set prog=adb.exe for %%i in (%quotedPath%) do if exist %%i\%prog% set found=%%i :adbdetected REM /* REM * Added incase usb isn't properly connected REM */ title Universal Quick Flasher v1.04 - Waiting for device... echo Waiting for device... echo Please plugin android device with usb debugging enabled adb wait-for-device cls adb root adb remount title Universal Quick Flasher v1.04 goto main if not ""==%found% goto adbdetected if exist adb.exe goto adbdetected if exist "%programfiles%\Android\android-sdk\platform-tools\adb.exe" goto adbdetected REM /* REM * Added Windows 7 Default location for android-sdk REM */ if exist "%USERPROFILE%\android-sdks\platform-tools\adb.exe" goto adbdetected if exist "%USERPROFILE%\android-sdk\platform-tools\adb.exe" goto adbdetected goto noadb :main cls echo. echo ************************************* echo * Universal Quick Flasher v1.04 * echo * * echo * By broodplank1337 * echo * and * echo * stepie22 * echo * * echo * All Filenames are CaseSensitive! * echo ************************************* echo. echo What do you want to flash? echo. echo [1] App (system app or regular app) echo [2] Kernel echo. echo Optional echo. echo [3] Reboot echo [4] Visit project page echo. echo [79] exit echo. echo. set /p choice=: if "%choice%"=="1" goto app if "%choice%"=="2" goto kernel if "%choice%"=="3" goto rmenu if "%choice%"=="4" goto ppage if "%choice%"=="79" goto exit REM /* REM * Display error if no valid option was chosen REM */ echo Error, no option found for '%choice%'. pause goto main :kernel cls echo. echo Enter kernel name (zImage or boot.img) set /p kername= Kernel name: echo. echo Enter kernel partition number echo As in (/dev/block/mmcblk0p*) where * is your number set /p kernum= Kernel Partition Number: echo. cls :kernelck REM /* REM * Display for rewiew REM */ echo. echo Kernel name: %kername% echo FLash to : /dev/block/mmcblk0p%kernum% echo. set /p valid=Correct (y or n): if "%valid%"=="y" goto kernelcont if "%valid%"=="Y" goto kernelcont if "%valid%"=="n" goto kernel if "%valid%"=="N" goto kernel set msg=Incorrent option goto kernelck :kernelcont if not exist %kername% ( set returnto=kernel goto nofile ) echo. echo Flashing %kername% to /dev/block/mmcblk0p%kernum% adb push %kername% /sdcard/%kername% adb -d shell su -c "dd if=/sdcard/%kername% of=/dev/block/mmcblk0p%kernum%" echo. echo Done! Rebooting Device... echo. adb reboot pause goto goagain :app set /p name=APK Name: cls echo. echo APK Name: %name% echo APK Type: echo. echo [1] System App (/system/app) echo [2] Framework App (/system/framework) echo [3] Regular App (/data/system) echo. set /p type=: if "%type%"=="1" goto sysapp if "%type%"=="2" goto frameapp if "%type%"=="3" goto normapp REM /* REM * Display error if no valid option was chosen REM */ echo Error, no option found for '%type%'. pause cls goto app :sysapp if not exist %name% ( set returnto=app goto nofile ) adb push %name% /system/app/%name% adb -d shell chmod 644 /system/app/%name% cls echo. echo Do you want to reboot your device (y/n)? echo. set /p choice=: if "%choice%"=="n" goto goagain if "%choice%"=="N" goto goagain if "%choice%"=="y" goto rmenu if "%choice%"=="Y" goto rmenu echo ERROR, no option found for '%choice%' pause goto sysapp REM /* REM * Display error if no valid option was chosen REM */ echo Error, no option found for '%reboot%'. pause cls goto sysapp :frameapp if not exist %name% ( set returnto=app goto nofile ) adb push %name% /system/framework/%name% adb -d shell chmod 644 /system/framework/%name% cls echo. echo Do you want to reboot your device (y/n)? echo. set /p choice=: if "%choice%"=="n" goto goagain if "%choice%"=="N" goto goagain if "%choice%"=="y" goto rmenu if "%choice%"=="Y" goto rmenu echo ERROR, no option found for '%choice%' pause goto frameapp REM /* REM * Display error if no valid option was chosen REM */ echo Error, no option found for '%reboot%'. pause cls goto frameapp :normapp if not exist %name% ( set returnto=app goto nofile ) adb install %name% goto goagain :rmenu cls echo. echo [1] Shutdown echo [2] Reboot Normaly echo [3] Reboot fast echo [4] Reboot into Recovery echo [5] Reboot into Bootloader (Download Mode) echo [9] Main Menu echo [79] Exit echo. set /p rmenu=: if "%rmenu%"=="1" goto shutdown if "%rmenu%"=="2" goto reboot if "%rmenu%"=="3" goto rebootf if "%rmenu%"=="4" goto rebootr if "%rmenu%"=="5" goto rebootdl if "%rmenu%"=="9" goto main if "%rmenu%"=="79" goto exit echo. echo No option found for '%rmenu%' pause goto rmenu :ppage start http://broodplank.net/?p=729 goto main :shutdown echo. echo Shutting down device. adb shell reboot -p goto goagain :reboot echo. echo Rebooting Device Completely. adb reboot echo Done! goto goagain :rebootf echo. echo Rebooting Device Fast (kill system_server) adb -d shell su -c "busybox killall system_server" echo Done! goto goagain :rebootr echo. echo Rebooting Device into Recovery. adb reboot recovery goto goagain :rebootdl echo. echo Rebooting Device into Bootloader (Download Mode) adb reboot bootloader goto goagain :nofile cls echo. echo ******************************** echo * That file could not be found * echo ******************************** echo. echo Press enter to try again. set /p nofile= goto %returnto% :noadb cls echo. echo ************************ echo * ADB was not detected * echo ************************ echo. echo Download?? (y/n) set /p choice=: if "%choice%"=="n" goto exit if "%choice%"=="N" goto exit if "%choice%"=="y" goto dl if "%choice%"=="Y" goto dl echo ERROR, no option found for '%choice%' pause goto noadb :dl cls echo. echo ************************ echo * ADB was not detected * echo ************************ echo. echo Downloading adb.rar from broodplank.net... echo Extract it in: %~dp0 start http://broodplank.net/files/ADB.rar pause goto exit :goagain cls echo. echo Press m to go to the Main Menu, echo Press any other key to exit. echo. set /p goagain=: if "%goagain%"=="m" goto main if "%goagain%"=="M" goto main :exit echo. echo. echo Exiting... pause exit
[SCRIPT] Common ADB/FASTBOOT Functions
DISCLAIMER: I TAKE NO RESPONSIBILITY FOR DAMAGE CAUSED TO ANYONE OR ANYTHING BY USING MY SCRIPT. USE THIS AT YOUR OWN RISK. So pretty much this is a script that can: 1. Flash a new boot animation without going through all the hassle of entering remounting commands. (Main reason why I wrote this) (Requires root and maybe adb insecure by chainfire) 2. Flash a new startup logo. (Requires unlocked bootloader) 3. Basic reboot commands with the press of a number. 4. Push and Pull files without entering commands, just need to specify the file location by dragging and dropping into the command window. (Some cases may need root. If your case does not need root, and the script says failed to restart adb as root, your command will still work, hopefully) 5. Install an apk the same way as 4. (If it says failed to restart as root it will still work in most cases) 6. Extremely noob friendly :laugh:. Just a small little script to make your life a bit easier. I tested this numerous times on a Moto G xt1032 running cyanogenmod 11 m4 and it showed no flaws. If this does not work for you try installing adb insecure by chainfire. This works on windows only (I think). If you find any bugs please tell me and I will try to fix even though I am just starting out with the wonders of developing. Some of the functions of the script need root access! To use this, just copy and paste the lines below into a notepad window. Then save the file as something.bat Make sure to change the dropdown menu from txt document to all files when saving. Put the script in the folder where adb.exe and fastboot.exe are located. Double-click and enjoy! Press "Click to show content" below! @ECHO off echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo IF YOUR DEVICE IS LISTED BELOW TYPE 1 echo ELSE TYPE 2 TO EXIT echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ adb devices SET /p startcheck= Type your choice: if "%startcheck%" =="1" goto menu if "%startcheck%" =="2" goto exit :menu cls echo Type 0 for Device Check echo Type 1 to Flash Boot Animation (ADB root required) echo Type 2 to Flash Startup Logo echo Type 3 to Reboot to Bootloader echo Type 4 to Reboot echo Type 5 to Pull a File echo Type 6 to Push a File echo Type 7 to Install Apk echo Type 8 to Run ADB as Root echo Type 9 to Browse and Copy Apps to Computer (ADB root required) echo Type 10 to Browse and Copy SYSTEM Apps to Computer (ADB root required) echo Type 11 to Exit SET /p choice= Type your choice: if "%choice%" =="0" goto devcheck if "%choice%" =="1" goto anim if "%choice%" =="2" goto logo if "%choice%" =="3" goto rebootloader if "%choice%" =="4" goto reboot if "%choice%" =="5" goto adbpull if "%choice%" =="6" goto adbpush if "%choice%" =="7" goto apk if "%choice%" =="8" goto adbroot if "%choice%" =="9" goto apps if "%choice%" =="10" goto sysapps if "%choice%" =="11" goto exit goto end :end cls echo Type 1 to restart program echo Type 2 to exit SET /p restart= Type your choice if "%restart%" =="1" goto menu if "%restart%" =="2" goto exit :exit exit :anim cls adb kill-server adb start-server cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo IF YOUR DEVICE IS LISTED BELOW TYPE 1 echo ELSE TYPE 2 TO EXIT echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ adb devices SET /p adb= Type your choice if "%adb%" =="2" goto menu cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo TYPE THE PATH FOR YOUR bootanimation.zip echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SET /p bapath= Type your path here and press enter: cls adb wait-for-device root timeout -t 1 > nul echo Remounting system in read-write mode! adb wait-for-device remount timeout -t 2 > nul adb wait-for-device shell "su -c 'mount -o rw,remount -t yaffs2 /dev/block/mtdblock1 /system'" echo Deleting existing bootanimation! adb wait-for-device shell "su -c 'rm /system/media/bootanimation.zip'" echo Sending new bootanimation! adb push %bapath% /system/media echo Remounting system in read-only mode! adb wait-for-device shell "su -c 'mount -o ro,remount -t yaffs2 /dev/block/mtdblock1 /system'" echo Done! echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo Press 1 to reboot! echo Press 2 to exit! SET /p dm= Type your choice if "%dm%" =="1" goto reboot if "%dm%" =="2" goto end :logo cls echo Rebooting to bootloader... adb reboot-bootloader echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo When device is in bootloader press any key to continue! echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PAUSE cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo IF YOUR DEVICE IS LISTED BELOW TYPE 1 echo ELSE TYPE 2 TO EXIT echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fastboot devices SET /p fbdev= Type your choice if "%fbdev%" =="2" goto menu cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo TYPE THE PATH FOR YOUR logo.bin echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SET /p lopath= Type your path here and press enter: cls echo Sending new logo! fastboot flash logo %lopath% echo Rebooting... fastboot reboot echo Done! echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo Press any key to return to menu! PAUSE goto menu :reboot cls adb reboot echo Rebooting... timeout -t 3 > nul goto menu :rebootloader cls adb reboot-bootloader echo Rebooting to bootloader... timeout -t 3 > nul goto menu :adbpull cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo TYPE THE PATH FOR THE FILE TO PULL echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SET /p adbpullpath= Type your path here and press enter: cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo TYPE THE PATH FOR THE FILE TO SAVE echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SET /p adbpullsave= Type your path here and press enter: cls echo !!!IF THIS ACTION NEEDS ROOT RUN OPTION 8 FROM MENU FIRST!!! timeout -t 2 > nul echo Pulling File! adb wait-for-device pull %adbpullpath% %adbpullsave% echo Done! echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo Press any key to return to menu! PAUSE goto menu :adbpush cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo TYPE THE PATH FOR THE FILE TO PUSH echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SET /p adbpushpath= Type your path here and press enter: cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo TYPE THE PATH FOR THE DIRECTORY TO PUSH TO echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SET /p adbpushsave= Type your path here and press enter: cls echo !!!IF THIS ACTION NEEDS ROOT RUN OPTION 8 FROM MENU FIRST!!! timeout -t 2 > nul echo Pushing File! adb wait-for-device push %adbpushpath% %adbpushsave% echo Done! echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo Press any key to return to menu! PAUSE goto menu :apk cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo IF YOUR DEVICE IS LISTED BELOW TYPE 1 echo ELSE TYPE 2 TO EXIT echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ adb devices SET /p apkcheck= Type your choice if "%apkcheck%" =="2" goto exit cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo TYPE THE PATH FOR THE APK TO INSTALL echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SET /p apkinstall= Type your path here and press enter: cls echo !!!IF THIS ACTION NEEDS ROOT RUN OPTION 8 FROM MENU FIRST!!! timeout -t 2 > nul echo Installing Apk! adb wait-for-device install %apkinstall% echo Done! echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo Press any key to return to menu! PAUSE goto menu :devcheck cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo DEVICE CONNECTION CHECK echo Your device should be listed below! echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ adb devices PAUSE goto menu :adbroot cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo Trying to run ADB as root! adb wait-for-device root echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo !!!ONCE DEVICE RECONNECTS TO COMPUTER PRESS ANY KEY TO GET TO MENU!!! PAUSE goto menu :apps cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ adb wait-for-device shell "su -c 'ls /data/app'" echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo Do you want to copy an app to the computer? set /p appans= (Y or N): if "%appans%" =="N" goto menu if "%appans%" =="n" goto menu if "%appans%" =="no" goto menu if "%appans%" =="No" goto menu if "%appans%" =="NO" goto menu cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ adb wait-for-device shell "su -c 'ls /data/app'" echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo Type the app's name EXACTLY including the .apk extension echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ set /p appcp= Type the name EXACTLY as it appears: cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo Type the destination directory echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ set /p appdd= Destination Directory: cls echo Copying App! adb pull /data/app/%appcp% %appdd% echo Done! PAUSE goto menu :sysapps cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ adb wait-for-device shell "su -c 'ls /system/app'" echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo Do you want to copy an app to the computer? set /p sappans= (Y or N): if "%sappans%" =="N" goto menu if "%sappans%" =="n" goto menu if "%sappans%" =="no" goto menu if "%sappans%" =="No" goto menu if "%sappans%" =="NO" goto menu cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ adb wait-for-device shell "su -c 'ls /system/app'" echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo Type the app's name EXACTLY including the .apk extension echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ set /p sappcp= Type the name EXACTLY as it appears: cls echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo Type the destination directory echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ set /p sappdd= Destination Directory: cls echo Copying App! adb pull /system/app/%sappcp% %sappdd% echo Done! PAUSE goto menu
Question Is it possible to do a factory reset without data loss?
Is it possible to do a factory reset without data loss?
To uninstall all apps installed for Android's actual user ( default user 0 ) in one go and also backup actual user's data you can run a Windows CMD script what looks like this draft: Code: @echo off & setlocal set "pc_bkup_fldr=C:\ANDROID-USER-DATA-BKUP" rem add timestamp in ISO 8601 format to backup folder for /F "tokens=2 delims==" %%a in ('wmic os get localdatetime /VALUE 2^>NUL') do ( set "datetime=%%a" ) if not "?%datetime%"=="?" ( for /F "tokens=1 delims=." %%a in ("%datetime%") do ( set "retval=%%a" ) if not "?%retval%"=="?" ( set yyyy=%retval:~0,4% set mm=%retval:~4,2% set dd=%retval:~6,2% set "pc_bkup_fldr=%pc_bkup_fldr%-%yyyy%-%mm%-%dd%" ) ) for /F "skip=1" "tokens=*" %%a in ('adb devices 2^>nul') do ( set "retval=%%a" ) if "?%retval%"=="?" ( goto :end ) mkdir "%pc_bkup_fldr%" 2>nul >nul rem retrieve user id for /F %%a in ('adb shell "am get-current-user"') do ( set "uid=%%a" ) rem Below command will return all the android user-app packages installed rem on the connected Android device. for /F "tokens=2 delims=:" %%a in ('adb shell "pm list packages --user %uid% -3"') do ( set "pkg_name=%%a" if not "?%pkg_name%"=="?" rem clear all application data (including application cache) adb shell "pm clear --user %uid% %pkg_name%" rem uninstall app by app package name adb shell "pm uninstall --user %uid% %pkg_name%" timeout /t 2 /nobreak >nul ) ) rem Next command will return all the android user-data stored in /sdcard rem partition of the connected Android device. set "int_sdcard=/storage/emulated" for /F "skip=1" "tokens=1,9 delims= " %%a in ('adb shell "ls -l %int_sdcard%/%uid%"') do ( set "dir_flag=%%a" & set "dir_name=%%b" if not "?%dir_flag%"=="?"" ( echo %dir_flag% | findstr /C:"d" >nul if %errorlevel% equ 0 ( set "data_fldr=%int_sdcard%/%uid%/%dir_name%" rem backup the folder to pc adb exec-out "tar -c %data_fldr%" > "%pc_bkup_fldr%\%dir_name%.tar" rem delete contents of Android folder adb shell "rm -f %data_fldr%/*" timeout /t 2 /nobreak >nul ) ) ) rem Next command reboots Android thus changes made take effect adb reboot :end endlocal & @echo on exit DL: https://www.mediafire.com/file/b2qkflgiqhcni8i/my-factory-reset.bat/file
monica lewinsky said: Is it possible to do a factory reset without data loss? Click to expand... Click to collapse No
mah dude is confused factory reset is basically wiping your data partition
ineedroot69 said: mah dude is confused factory reset is basically wiping your data partition Click to expand... Click to collapse ROFL
jwoegerbauer said: To uninstall all apps installed for Android's actual user ( default user 0 ) in one go and also backup actual user's data you can run a Windows CMD script what looks like this draft: Code: @echo off & setlocal set "pc_bkup_fldr=C:\ANDROID-USER-DATA-BKUP" rem add timestamp in ISO 8601 format to backup folder for /F "tokens=2 delims==" %%a in ('wmic os get localdatetime /VALUE 2^>NUL') do ( set "datetime=%%a" ) if not "?%datetime%"=="?" ( for /F "tokens=1 delims=." %%a in ("%datetime%") do ( set "retval=%%a" ) if not "?%retval%"=="?" ( set yyyy=%retval:~0,4% set mm=%retval:~4,2% set dd=%retval:~6,2% set "pc_bkup_fldr=%pc_bkup_fldr%-%yyyy%-%mm%-%dd%" ) ) for /F "skip=1" "tokens=*" %%a in ('adb devices 2^>nul') do ( set "retval=%%a" ) if "?%retval%"=="?" ( goto :end ) mkdir "%pc_bkup_fldr%" 2>nul >nul rem retrieve user id for /F %%a in ('adb shell "am get-current-user"') do ( set "uid=%%a" ) rem Below command will return all the android user-app packages installed rem on the connected Android device. for /F "tokens=2 delims=:" %%a in ('adb shell "pm list packages --user %uid% -3"') do ( set "pkg_name=%%a" if not "?%pkg_name%"=="?" rem clear all application data (including application cache) adb shell "pm clear --user %uid% %pkg_name%" rem uninstall app by app package name adb shell "pm uninstall --user %uid% %pkg_name%" timeout /t 2 /nobreak >nul ) ) rem Next command will return all the android user-data stored in /sdcard rem partition of the connected Android device. set "int_sdcard=/storage/emulated" for /F "skip=1" "tokens=1,9 delims= " %%a in ('adb shell "ls -l %int_sdcard%/%uid%"') do ( set "dir_flag=%%a" & set "dir_name=%%b" if not "?%dir_flag%"=="?"" ( echo %dir_flag% | findstr /C:"d" >nul if %errorlevel% equ 0 ( set "data_fldr=%int_sdcard%/%uid%/%dir_name%" rem backup the folder to pc adb exec-out "tar -c %data_fldr%" > "%pc_bkup_fldr%\%dir_name%.tar" rem delete contents of Android folder adb shell "rm -f %data_fldr%/*" timeout /t 2 /nobreak >nul ) ) ) rem Next command reboots Android thus changes made take effect adb reboot :end endlocal & @echo on exit DL: https://www.mediafire.com/file/b2qkflgiqhcni8i/my-factory-reset.bat/file Click to expand... Click to collapse thanks for this. it's exactly i was looking for.
How Can i Batch Sign Zip Files On Windows?
I asked this previously. But i did not specify the problem correctly When i unpack the: build-tools_r30.0.1-windows.zip to the C drive i get this: C:\android-11\ If i try to use the ApkSigner.JAR in the: C:\android-11\lib\ Folder Directly through those two commands: cd C:\Program Files\AdoptOpenJDK\jre-16.0.1.9-hotspot\bin\ Followed by: java.exe C:\android-11\lib\apksigner.jar sign --key C:\keys\mykey.pk8 --cert C:\certificates\mycert.pem --min-sdk-version 20 C:\files\MyZipFile.zip I get this: Error: Could not find or load main class C:\android-11\lib\apksigner.jar Caused by: java.lang.ClassNotFoundException: C:\android-11\lib\apksigner.jar If i use the ApkSigner.JAR INDIRECTLY Through the ApkSigner.BAT File in the: C:\android-11\ Folder Through those two commands: cd C:\android-11\ Followed by: apksigner.bat sign --key C:\keys\mykey.pk8 --cert C:\certificates\mycert.pem --min-sdk-version 20 C:\files\MyZipFile.zip Than it works But the apksigner.BAT File does not work with the batch signer i mentioned in this post: https://forum.xda-developers.com/t/how-to-batch-sign-zip-files.4258547/ Which is why Batch signing is not working for me with the current apksigner.JAR File. Since because of this Error: Could not find or load main class C:\android-11\lib\apksigner.jar Caused by: java.lang.ClassNotFoundException: C:\android-11\lib\apksigner.jar I cannot use it directly. The script from the apksigner.BAT File is this: @Echo off REM Copyright (C) 2016 The Android Open Source Project REM REM Licensed under the Apache License, Version 2.0 (the "License"); REM you may not use this file except in compliance with the License. REM You may obtain a copy of the License at REM REM http://www.apache.org/licenses/LICENSE-2.0 REM REM Unless required by applicable law or agreed to in writing, software REM distributed under the License is distributed on an "AS IS" BASIS, REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. REM See the License for the specific language governing permissions and REM limitations under the License. REM don't modify the caller's environment setlocal REM Locate apksigner.jar in the directory where apksigner.bat was found and start it. REM Set up prog to be the path of this script, including following symlinks, REM and set up progdir to be the fully-qualified pathname of its directory. set prog=%~f0 @Rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if "%ERRORLEVEL%" == "0" goto init echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. exit /b 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto init echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. exit /b 1 :init set jarfile=apksigner.jar set "frameworkdir=%~dp0" rem frameworkdir must not end with a dir sep. set "frameworkdir=%frameworkdir:~0,-1%" if exist "%frameworkdir%\%jarfile%" goto JarFileOk set "frameworkdir=%~dp0lib" if exist "%frameworkdir%\%jarfile%" goto JarFileOk set "frameworkdir=%~dp0..\framework" :JarFileOk set "jarpath=%frameworkdir%\%jarfile%" set javaOpts= set args= REM By default, give apksigner a max heap size of 1 gig and a stack size of 1meg. rem This can be overridden by using "-JXmx..." and "-JXss..." options below. set defaultXmx=-Xmx1024M set defaultXss=-Xss1m REM Capture all arguments that are not -J options. REM Note that when reading the input arguments with %1, the cmd.exe REM automagically converts --name=value arguments into 2 arguments "--name" REM followed by "value". apksigner has been changed to know how to deal with that. set params= :firstArg if [%1]==[] goto endArgs set "a=%~1" if [%defaultXmx%]==[] goto notXmx if "%a:~0,5%" NEQ "-JXmx" goto notXmx set defaultXmx= :notXmx if [%defaultXss%]==[] goto notXss if "%a:~0,5%" NEQ "-JXss" goto notXss set defaultXss= :notXss if "%a:~0,2%" NEQ "-J" goto notJ set javaOpts=%javaOpts% -%a:~2% shift /1 goto firstArg :notJ set params=%params% %1 shift /1 goto firstArg :endArgs set javaOpts=%javaOpts% %defaultXmx% %defaultXss% call "%java_exe%" %javaOpts% -jar "%jarpath%" %params% The script From the SignEm v2.0 Tool: From this Post: https://forum.xda-developers.com/t/...iles-no-signature-verification-error.1966007/ By @Ryuinferno is this @Ryuinferno said: @Echo off COLOR 70 title "Sign-em! 2.0" ECHO. ECHO Sign-em! v2.0 by Ryuinferno @ XDA 2013 ECHO. ECHO This script signs multiple zip files automatically... ECHO. ECHO **REMINDER!!! Do not leave spaces when you name your zip files...** ECHO. FOR %%A in (.\Input\*.zip) do ( ECHO Signing - %%~nA.zip java -jar .\Tools\signapk.jar -w .\Tools\testkey.x509.pem .\Tools\testkey.pk8 %%A .\Output\%%~nA-signed.zip ) FOR %%A in (.\Output\*.zip) do ( ECHO Calculating md5 checksum .\Tools\md5sums.exe -u %%A >> ./Output/md5.txt ) ECHO. ECHO Files signed successfully if no errors above... ECHO. ECHO Hope you enjoyed my work... ECHO Ryuinferno @ XDA 2013 ECHO. pause Click to expand... Click to collapse And the Script created by: @jwoegerbauer As this answer: https://forum.xda-developers.com/t/how-to-batch-sign-zip-files.4258547/post-84798393 To my earlier post is here: @jwoegerbauer said: @Echo off & setlocal pushd "%~dp0" set "InFiles=%CD%\Infiles" set "OutFiles=%CD%\OutFiles" set "Signer=%CD%\Tools\signapk.jar" set "Keys=%CD%\Keys" for /F %%a in ('dir %InFiles%\*.zip /B') do ( set "ZIP=%%a" if NOT "?%ZIP%"=="?" ( java -jar %Signer% %Keys%\certificate.pem %Keys%\key.pk8 %ZIP% %OutFiles%\signed-%ZIP% ) ) popd endlocal & @ECHO on & exit Click to expand... Click to collapse And I wery much Hope someone can help me with this problem.
Are you sure that apksigner.jar is in the folder of 'C:\android-11\lib'?
James_Watson said: Are you sure that apksigner.jar is in the folder of 'C:\android-11\lib'? Click to expand... Click to collapse Yes i am sure about that.
General Permission Denier Tool
Hey! This is like my first genuine post anywhere on XDA besides my introduction, but I got really fed up today with typing out ADB commands manually and created myself a little menu to deny permissions using APPOPS, and I decided to share it. This is a .BAT file or a Windows batch file. Make sure that if you want to use this script, you put it in the same folder as adb.exe. This should generally work for any Android device, not just the Galaxy A32 5G. Code: @echo off :menu set currentlocation=menu echo Package Permission Denier by Platless. goto appops :appops set currentlocation=appops echo What is the name of the package? set /p "packname=>" adb shell pm list packages ^| grep -x package:%packname% if %errorlevel% == 1 goto notapackage adb shell appops get %packname% ^| grep -v deny > temp.txt for %%I in (temp.txt) do echo %%~zI > output.txt set /p size=<output.txt del output.txt if %size% == 0 goto noperms setlocal ENABLEDELAYEDEXPANSION set COUNT=0 for /F %%i in ( temp.txt ) do ( set /A COUNT=!COUNT! + 1 echo !COUNT!: %%i set perm[!COUNT!]=%%i set choice=!choice!!COUNT! ) if %COUNT% LSS 10 ( choice /C %choice% /M "Type the number of the permission you want to deny." set permnumber=!ERRORLEVEL! ) else set /P permnumber="Type the number of the permission you want to deny.: " set permthing=!perm[%permnumber%]::= ! adb shell appops set %packname% %permthing% deny del temp.txt pause goto %currentlocation% :noperms echo This app either doesn't have any permissions or they are all denied. Well done. pause goto menu :notapackage echo Package not found. adb shell pm list packages ^| grep -w %packname% > didyoumean.txt set /p didyoumean= <didyoumean.txt for %%I in (didyoumean.txt) do echo %%~zI > size.txt set /p size=<size.txt del size.txt del didyoumean.txt if %size% == 0 goto %currentlocation% echo Did you mean%didyoumean:package:= %? goto %currentlocation%