-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaj40fwupdate.bat
More file actions
104 lines (87 loc) · 3.04 KB
/
Copy pathaj40fwupdate.bat
File metadata and controls
104 lines (87 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
@echo off
title Lenovo Dock Force-Updater
:: -------------------------------------------------------------------
:: 1. Check for Administrator Privileges
:: -------------------------------------------------------------------
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
:: Relaunch this script as an Admin and exit the current one
powershell -command "Start-Process -FilePath '%~f0' -Verb RunAs"
exit
)
:: We are now running as Admin
:: -------------------------------------------------------------------
:: 2. Find the Lenovo Firmware on the Desktop
:: -------------------------------------------------------------------
echo --- Lenovo Dock Force-Updater ---
echo Searching your Desktop for the Lenovo firmware .exe...
echo.
set "SEARCH_DIR=%USERPROFILE%\Desktop"
set "EXTRACT_DIR=C:\dockfw"
:: The official file usually starts with "fwud"
for %%F in ("%SEARCH_DIR%\fwud*.exe") do (
set "LENOVO_EXE_PATH=%%~fF"
goto :FoundIt
)
:: Fallback for other possible names
for %%F in ("%SEARCH_DIR%\n20pf*.exe") do (
set "LENOVO_EXE_PATH=%%~fF"
goto :FoundIt
)
echo ERROR: Could not find the Lenovo firmware .exe on your Desktop.
echo Please download the file from the Lenovo support site,
echo save it to your Desktop, and run this script again.
echo.
pause
exit /b
:FoundIt
echo Found firmware: %LENOVO_EXE_PATH%
echo.
:: -------------------------------------------------------------------
:: 3. Extract the Updater
:: -------------------------------------------------------------------
echo Extracting firmware files...
:: Clean up any old attempts
rmdir /s /q "%EXTRACT_DIR%" 2>nul
mkdir "%EXTRACT_DIR%"
"%LENOVO_EXE_PATH%" /VERYSILENT /EXTRACT="YES" /DIR="%EXTRACT_DIR%"
:: Check if the real tool was extracted
if not exist "%EXTRACT_DIR%\cs18_cmd.exe" (
echo.
echo ERROR: File extraction failed!
echo The Lenovo .exe file may be a new, unrecognized version.
pause
exit /b
)
echo Extraction complete.
echo.
:: -------------------------------------------------------------------
:: 4. Run the Force Flash
:: -------------------------------------------------------------------
echo --- Starting Force-Flash ---
echo This will take 3-6 minutes. Your dock lights may flash.
echo DO NOT UNPLUG THE DOCK OR LAPTOP.
echo This window will stay open.
echo.
:: Navigate to the extracted folder and run the command
cd /d "%EXTRACT_DIR%"
cs18_cmd.exe /u /f /s
:: -------------------------------------------------------------------
:: 5. Report the Result
:: -------------------------------------------------------------------
:: %ERRORLEVEL% holds the return code from the last command
if %ERRORLEVEL% == 0 (
echo.
echo SUCCESS! The firmware has been updated.
echo We will run the version check now to confirm:
echo.
cs18_cmd.exe /v
) else (
echo.
echo ERROR: The update failed with code %ERRORLEVEL%.
echo (A -41 error means the dock's PD chip is faulty)
)
echo.
echo All done. You can close this window.
pause