cumminbk Posted September 18, 2007 Posted September 18, 2007 (edited) i wonder if you could help me with this batch file. The issue i am having is i want the file to delete itself after it has preformed its function. I have been able to do this before but i can no longer get it working. @echo offSET D=%SYSTEMROOT%\system32\REM delete oeminfo.ini if existsIF EXIST "%D%oeminfo.ini" DEL "%D%oeminfo.ini" /qFOR %%d IN (c: d: e: f: g: h: i: j: k: l: m: n: o: p: q: r: s: t: u: v: w: x: y: z:) DO IF EXIST %%d\WIN51IP SET CDROM=%%decho [General] >> "%D%oeminfo.ini"echo Manufacturer=Unattended Windows Install >> "%D%oeminfo.ini"echo Model=" Version: (09.18.07)" >> "%C%oeminfo.ini"echo [Support Information] >> "%D%oeminfo.ini"echo Line1=Installation Date: %date% >> "%D%oeminfo.ini"echo Line2= >> "%D%oeminfo.ini"echo Line3=Slipstreamed Hotfixes:>> "%D%oeminfo.ini"echo Line4= >> "%D%oeminfo.ini"REM Line NumberSET i=5REM List slipstreamed fixesFor /F "TOKENS=1 delims=.CA_" %%j in ( 'dir /B %CDROM%\I386\svcpack\KB*.CA_' )do ( ( set kbname=%%j ) & (call :myprint) )For /F "TOKENS=1 delims=.CA_" %%j in ( 'dir /B %CDROM%\I386\svcpack\IE7*.CA_' )do ( ( set kbname=%%j ) & (call :myprint) )For /F "TOKENS=1 delims=.CA_" %%j in ( 'dir /B %CDROM%\I386\svcpack\WMP11*.CA_' )do ( ( set kbname=%%j ) & (call :myprint) )GOTO :NEXT:myprintecho Line%i%=%kbname% >> "%D%oeminfo.ini"SET /A i+=1:NEXTDEL /F "%UserProfile%\Desktop\Cleanup.cmd" Edited September 18, 2007 by Yzöwl
Yzöwl Posted September 18, 2007 Posted September 18, 2007 The answer you are looking for is@ECHO OFF&SETLOCAL ENABLEEXTENSIONSSET "d=%SYSTEMROOT%\SYSTEM32\oeminfo.ini"FOR /F %%? IN ('MOUNTVOL^|FIND ":\"^|FIND /V "A:\"') DO ( IF EXIST %%?WIN51IP SET "CDSPDIR=%%?I386\SVCPACK")IF NOT DEFINED CDSPDIR GOTO ENDIT>"%d%" (ECHO/[General] ECHO/Manufacturer=Unattended Windows Install ECHO/Model=" Version: (18.09.07)" ECHO/[Support Information] ECHO/Line1=Installation Date: %DATE% ECHO/Line2= ECHO/Line3=Slipstreamed Hotfixes: ECHO/Line4=)SET n=4PUSHD %CDSPDIR%FOR /F "DELIMS=" %%? IN ('DIR/B/A-D *.CA_^|FINDSTR/IB "KB IE7 WMP11"') DO ( CALL :ADDIT %%~n?)POPD&GOTO ENDIT:ADDITSET/A n+=1>>"%d%" ECHO/Line%n%=%1 GOTO :EOF:ENDITENDLOCAL&DEL %0I haven't tested it, but I'm fairly sure it should work for you.
jaclaz Posted September 18, 2007 Posted September 18, 2007 (edited) Maybe stupid question , but does the file resides in %UserProfile%\Desktop\ ?Personally I would use "%~dpnx0"Other possibility, it is a timing problem of some kind. If this is the case, you may want to try a loop similar to the one detailed here:http://www.catch22.net/tuts/selfdel.aspBTW, you seem to be missing a GOTO :EOF to return from the calls in FOR loops. jaclazEDIT: Sorry Yzöwl, cross-posting. Edited September 18, 2007 by jaclaz
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now