Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
Credits 430 Posts 177 Joined 2006-09-20 12:00 19-year member UID 63170 From 广东深圳
Status Offline
Let me give an example.
I don't know where the QQ.EXE file is. There isn't a shortcut on the desktop either,
so I want to make a batch file that can find its path on the hard drive, (for example: C:\TENCENT\QQ\QQ.EXE and save this path in another file). Save this path into another batch file, then use the CALL command to call that batch file... and then exit
Can this be done?
[[i] Last edited by namejm on 2007-2-5 at 09:39 AM [/i]]
Credits 1,218 Posts 485 Joined 2006-07-21 21:24 19-year member UID 58987 From 湖南.娄底
Status Offline
@echo off
for %%a in (c d) do (
for /f "tokens=*" %%i in ('dir /s /a-d /b %%a:\qq.exe') do (
start "" "%%i"
)
)
I don't know which drive the OP installed QQ on, so by default it searches drives C and D. If you want to improve efficiency, just enter the drive letter where QQ is installed.
Credits 430 Posts 177 Joined 2006-09-20 12:00 19-year member UID 63170 From 广东深圳
Status Offline
It's my fault. I described it wrong.
It should be like this.
I just don't know where that file is. For example, where is the LANDTIMER.INI file? I want to find it and get a few lines of text information from inside the file.
The file contents are written like this
[option]
TYPE=0
IP=192.168.151.153
PROXY=*.COM
……
and so on
I just want to write them separately into different files. The filenames just need to match the letters before the equals sign...
Credits 5,226 Posts 1,737 Joined 2006-03-10 00:38 20-year member UID 51697 From 成都
Status Offline
Try the code below and see whether it works (administrator privileges required, efficiency isn't very high):
@echo off
setlocal enabledelayedexpansion
for /f "delims=\" %%i in ('fsutil fsinfo drives^|find /v ""') do (
set var=%%i
set drive=!var:~-2!
fsutil fsinfo drivetype !drive!|find "固定">nul && (
for /f "tokens=*" %%j in ('dir /a-d /b /s !drive!\LANDTIMER.INI 2^>nul') do (
set filename=%%~nj
for /f "tokens=1 delims==" %%k in ("%%j") do (
if /i "!filename!"=="%%k" echo "%%j">>test.bat
)
)
)
)
Credits 2,013 Posts 718 Joined 2006-02-18 07:07 20-year member UID 50550
Status Offline
@echo off
setlocal ENABLEDELAYEDEXPANSION
for /f "skip=1 tokens=*" %%i in ('wmic datafile where "filename='LANDTIMER' and Extension='ini'" get caption') do set str="%%i" !str!
for /f "skip=1 usebackq delims== tokens=1,2*" %%i in (%str%) do echo %%j>>%%i.txt
Only tested in the case where there is only one landtimer.ini on the whole drive; by default it processes them all.
Credits 845 Posts 375 Joined 2007-03-03 01:58 19-year member UID 80606 Gender Male
Status Offline
::The following code can search for and open QQ!
@echo off
for %%i in (c,d,e,f) do for /f "delims=" %%n in ('dir /s /b %%i:\qq.exe') do start "" "%%n"
pause