New
#30
Ran it and the script window reported errors as follows
But the wifi (don't use the Network) usage was cleared - well it showed 0.23MB on resetting.Commensing with Data Usage Reset:
Stopping Data Usage Services
[SC] OpenService FAILED 1060:
The specified service does not exist as an installed service.
Resetting Data Usage
Restarting Data Usage Services
[SC] OpenService FAILED 1060:
The specified service does not exist as an installed service.
Data Usage was Reset to 0
Press any key to exit.
@pewe please try this script. I have removed the command to disable the Data Usage service(DusmSvc).
Code:@ECHO OFF :: BatchGotAdmin (Run as Admin code starts) REM --> Check for permissions >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" REM --> If error flag set, we do not have admin. if '%errorlevel%' NEQ '0' ( echo Requesting administrative privileges... goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" echo UAC.ShellExecute "%~s0", "", "", "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" :: BatchGotAdmin (Run as Admin code ends) :: Your codes should start from the following line COLOR 1F ECHO Commensing with Data Usage Reset: ECHO. ECHO Stopping Data Usage Services ECHO. net stop DusmSvc > NUL 2>&1 net stop diagnosticshub.standardcollector.service > NUL 2>&1 net stop DPS > NUL 2>&1 ECHO. ECHO Resetting Data Usage echo Y | del /f /q "C:\Windows\System32\sru\*.*" > nul ECHO. ECHO Restarting Data Usage Services ECHO. net start DusmSvc > NUL 2>&1 net start diagnosticshub.standardcollector.service > NUL 2>&1 net start DPS > NUL 2>&1 ECHO. ECHO. ECHO Data Usage was Reset to 0 ECHO. ECHO Press any key to exit. pause > nul :end
I've updated the script. Only the Diagnostic Policy Service(DPS) is required to be stopped when resetting the Data Usage. I have also changed the wording that is displayed and the script will now also automatically exit when the task is completed. Any feedback will be appreciated.
Code:@ECHO OFF :: BatchGotAdmin (Run as Admin code starts) REM --> Check for permissions >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" REM --> If error flag set, we do not have admin. if '%errorlevel%' NEQ '0' ( echo Requesting administrative privileges... goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" echo UAC.ShellExecute "%~s0", "", "", "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" :: BatchGotAdmin (Run as Admin code ends) :: Your codes should start from the following line COLOR 1F ECHO Commencing with Data Usage Reset: ECHO. ECHO Stopping Diagnostic Policy Service ECHO. net stop DPS > NUL 2>&1 ECHO. ECHO Resetting Data Usage echo Y | del /f /q "C:\Windows\System32\sru\*.*" > nul ECHO. ECHO Restarting Diagnostic Policy Service ECHO. net start DPS > NUL 2>&1 ECHO. ECHO Data Usage was Reset to 0 ECHO. ECHO Closing in 5 Seconds.... ping 127.0.0.1 -n 6 >nul 2>&1 exit
I have updated the script again. I added a Y/N option and a color change when yes is selected.
Code:@ECHO OFF :: BatchGotAdmin (Run as Admin code starts) REM --> Check for permissions >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" REM --> If error flag set, we do not have admin. if '%errorlevel%' NEQ '0' ( echo Requesting administrative privileges... goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" echo UAC.ShellExecute "%~s0", "", "", "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" :: BatchGotAdmin (Run as Admin code ends) :: Your codes should start from the following line COLOR 1F CHOICE /C:YN /M "Do you want to reset the Data Usage now?" IF ERRORLEVEL 2 goto no IF ERRORLEVEL 1 goto yes :yes COLOR 2F ECHO. ECHO Commencing with Data Usage Reset: ECHO. ECHO Stopping Diagnostic Policy Service ECHO. net stop DPS > NUL 2>&1 ECHO Resetting Data Usage ECHO Y | del /f /q "C:\Windows\System32\sru\*.*" > nul ECHO. ECHO Restarting Diagnostic Policy Service ECHO. net start DPS > NUL 2>&1 ECHO. CLS ECHO Data Usage was Reset to 0 ECHO. ECHO Closing in 5 Seconds.... ping 127.0.0.1 -n 6 >nul 2>&1 exit :no exit