[Batch] Deleting file at first run

Discussion in 'Scripting' started by bertikul, Jan 26, 2011.

  1. bertikul

    bertikul MDL Member

    Nov 2, 2007
    204
    21
    10
    #1 bertikul, Jan 26, 2011
    Last edited: Jan 26, 2011
    Hello everyone

    I want to delete a file created by automated windows 7 crack (integrated in windows 7 DVD). I added the bold line " del /f /q %systemroot%\setup" to the script. It does delete the files in "%systemroot%\setup", but it does not restart automatically after windows installation as before adding that line. I know i messed it up (my fault). What shoul I do to make it work/restart?

    Thanks

    Script:

    @echo off

    for %%A 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 %%A\bootmgr (
    if not exist %%A\setup.exe (
    echo.
    echo Installing to drive %%A
    echo.
    if exist %%A\menu.lst attrib %%A\menu.lst -h -r -s
    if exist %%A\menu.lst ren %%A\menu.lst menu_lst.bak
    if exist %%A\grldr attrib %%A\grldr -h -r -s
    copy %systemroot%\setup\scripts\grldr %%A\grldr
    attrib %%A\grldr +h +s +r
    %systemroot%\setup\scripts\bootinst /nt60 %%A
    del /f /q %systemroot%\setup\
    )
    )
    )

    shutdown /r
     
  2. Calistoga

    Calistoga MDL Senior Member

    Jul 25, 2009
    421
    199
    10
    #2 Calistoga, Jan 26, 2011
    Last edited by a moderator: Apr 20, 2017
    If %systemroot%\setup\ is a folder, this would be a more appropriate command :)
    Code:
    rmdir /s /q %systemroot%\setup\
    del = delete files
    rmdir = delete directories
     
  3. bertikul

    bertikul MDL Member

    Nov 2, 2007
    204
    21
    10
    #3 bertikul, Jan 26, 2011
    Last edited: Jan 26, 2011
    (OP)
    .
    --------------------------------------------------------------------------------

    Thanks Calistoga for your reply.

    My problem is not deleting the files and I don't want to delete the derectory. The problem is that it won't restart after adding that line. Finnishing installation the computer restarted before I added "del /f /q %systemroot%\setup" to the script. So I'm missing something with the script syntax
     
  4. wulai

    wulai MDL Novice

    Mar 24, 2011
    5
    0
    0
    the last line should be:
    shutdown -r
    not shutdown /r