Windows 7 "Sleep is not recognised" etc. Error in Batch File

Elmer

Extraordinary Member
Joined
Mar 5, 2010
I have a batch file that I use to:
Create a restore point, then swap out my modified system files. I store the "Sleep.exe" file in the same folder as the batch file.
The script goes something like:

echo Please wait while a Restore Point is made.
sleep 17

Take ownership,Rename Replace, Blah, Blah, Blah.
sleep 2
cls

(repeat this 7 or so times for each system folder location)

It then deletes the iconcache and uses Delnext to delete the thumbcaches

Everything's running fine up until now. Its when it gets to the final part:

echo Finished!! :) Moving on to re-booting.
echo.
sleep 3
DEL C:\Windows\Prefetch\DELNEXT.EXE-*.pf
shutdown /r /t 0


I get an error (in the command prompt window) saying that sleep is not a recognised command, yet it's already run eight times. I'm pretty certain it used to run OK before (before what? I know not!!) but then again, and this may be hard to believe, I may be wrong :)**. Any help greatly appreciated.

**Don't let the wife see that!!

This is the full batch file
Code:
@echo off
REM ***BATCH COMMANDS***
REM takeown /f FilePathName
REM icacls FilePathName /grant administrators:F /t
REM REN FilePathName1 FilePathName2
REM COPY "FilePathName" "FilePathName"
echo.
echo PLEASE SAVE ALL DATA AND CLOSE ALL WINDOWS BEFORE RUNNING THIS SCRIPT.
echo.
echo This script will begin by creating a Restore Point. 
echo.
echo The script will then take ownership of the listed System files, rename
echo them by adding 0ld to the end of their file name and they will then be
echo replaced with their modified versions.
echo.
echo The thumbnail and icon caches will then de deleted before the
echo computer is rebooted.
set /p choice=Would you like to continue? Press "Y" for Yes or "N" for No: 
if %choice%==y goto moveon
if %choice%==n goto dontmove

:moveon
COPY "DELNEXT.EXE" "C:\Windows\System32\DELNEXT.EXE"
cscript.exe "Batch Swap Restore Point.vbs"
cls
echo.
echo.
echo Please wait while a Restore Point is made.
sleep 17
echo.
echo.

DEL C:\WINDOWS\System32\AALMER\ALMERCONS0ldie.dll
DEL C:\WINDOWS\SysWOW64\AALMER\ALMERCONS0ldie.dll
REN C:\Windows\System32\AALMER\ALMERCONS0ld.dll ALMERCONS0ldie.dll
REN C:\Windows\SysWOW64\AALMER\ALMERCONS0ld.dll ALMERCONS0ldie.dll
REN C:\Windows\System32\AALMER\ALMERCONS.DLL ALMERCONS0ld.dll
REN C:\Windows\SysWOW64\AALMER\ALMERCONS.DLL ALMERCONS0ld.dll
COPY "E:\MODIFYING\ALMERCONS\ALMERCONS.DLL" "C:\Windows\System32\AALMER\ALMERCONS.DLL"
COPY "E:\MODIFYING\ALMERCONS\ALMERCONS.DLL" "C:\Windows\SysWOW64\AALMER\ALMERCONS.DLL"

DEL C:\WINDOWS\*0ldie.*
DEL C:\Windows\Branding\Basebrd\*0ldie.*
DEL C:\WINDOWS\en-US\*0ldie.*
DEL C:\WINDOWS\System32\*0ldie.*
DEL C:\WINDOWS\System32\AALMER\*0ldie.*
DEL C:\WINDOWS\SysWOW64\*0ldie.*
DEL C:\WINDOWS\SysWOW64\AALMER\*0ldie.*
DEL C:\WINDOWS\System32\en-US\*0ldie.*
DEL C:\WINDOWS\SysWOW64\en-US\*0ldie.*
DEL "C:\Program Files\Windows NT\Accessories\en-US\*0ldie.*"
DEL "C:\Program Files (x86)\Windows NT\Accessories\en-US\*0ldie.*"
cls

REN C:\WINDOWS\*0ld.* *0ldie.*
REN C:\Windows\Branding\Basebrd\*0ld.* *0ldie.*
REN C:\WINDOWS\en-US\*0ld.* *0ldie.*
REN C:\WINDOWS\System32\*0ld.* *0ldie.*
REN C:\WINDOWS\SysWOW64\*0ld.* *0ldie.*
REN C:\WINDOWS\System32\en-US\*0ld.* *0ldie.*
REN C:\WINDOWS\SysWOW64\en-US\*0ld.* *0ldie.*
REN "C:\Program Files\Windows NT\Accessories\en-US\*0ld.*" *0ldie.*
REN "C:\Program Files (x86)\Windows NT\Accessories\en-US\*0ld.*" *0ldie.*
cls
echo.
echo *********************WINDOWS*********************

TAKEOWN /F C:\Windows\EXPLORER.EXE
ICACLS C:\Windows\EXPLORER.EXE /grant administrators:F /t
REN C:\Windows\EXPLORER.EXE EXPLORER0ld.EXE
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\WINDOWS\EXPLORER.EXE" "C:\Windows\EXPLORER.EXE"

TAKEOWN /F C:\Windows\REGEDIT.EXE
ICACLS C:\Windows\REGEDIT.EXE /grant administrators:F /t
REN C:\Windows\REGEDIT.EXE REGEDIT0ld.EXE
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\WINDOWS\REGEDIT.EXE" "C:\Windows\REGEDIT.EXE"

TAKEOWN /F C:\Windows\Branding\Basebrd\BASEBRD.DLL
ICACLS C:\Windows\Branding\Basebrd\BASEBRD.DLL /grant administrators:F /t
REN C:\Windows\Branding\Basebrd\BASEBRD.DLL basebrd0ld.dll
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\WINDOWS\BRANDING\BASEBRD\BASEBRD.DLL" "C:\Windows\Branding\Basebrd\BASEBRD.DLL"
sleep 2
cls
echo.
echo *********************WINDOWS/EN-US*********************

TAKEOWN /F C:\Windows\en-US\EXPLORER.EXE.MUI
ICACLS C:\Windows\en-US\EXPLORER.EXE.MUI /grant administrators:F /t
REN C:\Windows\en-US\EXPLORER.EXE.MUI EXPLORER0ld.EXE.MUI
COPY "E:\MODIFYING\7 MUI W.I.P.s\WINDOWS\en-US\EXPLORER.EXE.MUI" "C:\Windows\en-US\EXPLORER.EXE.MUI"
sleep 2
cls
echo.
echo *********************SYSTEM32*********************

TAKEOWN /F C:\Windows\System32\CMD.EXE
ICACLS C:\Windows\System32\CMD.EXE /grant administrators:F /t
REN C:\Windows\System32\CMD.EXE CMD0ld.EXE
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\CMD.EXE" "C:\WINDOWS\system32\CMD.EXE"

TAKEOWN /F C:\Windows\System32\DDORES.DLL
ICACLS C:\Windows\System32\DDORES.DLL /grant administrators:F /t
REN C:\Windows\System32\DDORES.DLL DDORES0ld.DLL
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\System32\DDORES.DLL" "C:\Windows\System32\DDORES.DLL"

TAKEOWN /F C:\Windows\System32\IMAGERES.DLL
ICACLS C:\Windows\System32\IMAGERES.DLL /grant administrators:F /t
REN C:\Windows\System32\IMAGERES.DLL IMAGERES0ld.DLL
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\IMAGERES.DLL" "C:\Windows\System32\IMAGERES.DLL"

TAKEOWN /F C:\Windows\System32\PNIDUI.DLL
ICACLS C:\Windows\System32\PNIDUI.DLL /grant administrators:F /t
REN C:\Windows\System32\PNIDUI.DLL PNIDUI0ld.DLL
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\System32\PNIDUI.DLL" "C:\Windows\System32\PNIDUI.DLL"

TAKEOWN /F C:\Windows\System32\SHELL32.DLL
ICACLS C:\Windows\System32\SHELL32.DLL /grant administrators:F /t
REN C:\Windows\System32\SHELL32.DLL SHELL320ld.dll
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\System32\SHELL32.DLL" "C:\Windows\System32\SHELL32.DLL"

TAKEOWN /F C:\Windows\System32\TASKMGR.EXE
ICACLS C:\Windows\System32\TASKMGR.EXE /grant administrators:F /t
REN C:\Windows\System32\TASKMGR.EXE TASKMGR0ld.EXE
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\System32\TASKMGR.EXE" "C:\Windows\System32\TASKMGR.EXE"

TAKEOWN /F C:\Windows\System32\ZIPFLDR.DLL
ICACLS C:\Windows\System32\ZIPFLDR.DLL /grant administrators:F /t
REN C:\Windows\System32\ZIPFLDR.DLL ZIPFLDR0ld.DLL
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\System32\ZIPFLDR.DLL" "C:\Windows\System32\ZIPFLDR.DLL"
sleep 2
cls
echo.
echo *********************SYSTEM32/EN-US*********************

TAKEOWN /F C:\Windows\System32\en-US\SHELL32.DLL.MUI
ICACLS C:\Windows\System32\en-US\SHELL32.DLL.MUI /grant administrators:F /t
REN C:\Windows\System32\en-US\SHELL32.DLL.MUI SHELL320ld.DLL.MUI
COPY "E:\MODIFYING\7 MUI W.I.P.s\System32\SHELL32.DLL.MUI" "C:\Windows\System32\en-US\SHELL32.DLL.MUI"

TAKEOWN /F C:\Windows\System32\en-US\FONTVIEW.EXE.MUI
ICACLS C:\Windows\System32\en-US\FONTVIEW.EXE.MUI /grant administrators:F /t
REN C:\Windows\System32\en-US\FONTVIEW.EXE.MUI FONTVIEW0ld.exe.MUI
COPY "E:\MODIFYING\7 MUI W.I.P.s\System32\FONTVIEW.EXE.MUI" "C:\Windows\System32\en-US\FONTVIEW.EXE.MUI"

TAKEOWN /F C:\Windows\System32\en-US\WININIT.EXE.MUI
ICACLS C:\Windows\System32\en-US\WININIT.EXE.MUI /grant administrators:F /t
REN C:\Windows\System32\en-US\WININIT.EXE.MUI WININIT0ld.EXE.MUI
COPY "E:\MODIFYING\7 MUI W.I.P.s\System32\WININIT.EXE.MUI" "C:\Windows\System32\en-US\WININIT.EXE.MUI"

TAKEOWN /F C:\Windows\System32\en-US\WINLOGON.EXE.MUI
ICACLS C:\Windows\System32\en-US\WINLOGON.EXE.MUI /grant administrators:F /t
REN C:\Windows\System32\en-US\WINLOGON.EXE.MUI WINLOGON0ld.EXE.MUI
COPY "E:\MODIFYING\7 MUI W.I.P.s\System32\WINLOGON.EXE.MUI" "C:\Windows\System32\en-US\WINLOGON.EXE.MUI"

TAKEOWN /F C:\Windows\System32\en-US\ZIPFLDR.DLL.MUI
ICACLS C:\Windows\System32\en-US\ZIPFLDR.DLL.MUI /grant administrators:F /t
REN C:\Windows\System32\en-US\ZIPFLDR.DLL.MUI ZIPFLDR0ld.DLL.MUI
COPY "E:\MODIFYING\7 MUI W.I.P.s\System32\ZIPFLDR.DLL.MUI" "C:\Windows\System32\en-US\ZIPFLDR.DLL.MUI"
sleep 2
cls
echo.
echo *********************SYSWOW64*********************

TAKEOWN /F C:\Windows\SysWOW64\CMD.EXE
ICACLS C:\Windows\SysWOW64\CMD.EXE /grant administrators:F /t
REN C:\Windows\SysWOW64\CMD.EXE CMD0ld.EXE
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\CMD.EXE" "C:\Windows\SysWOW64\CMD.EXE"

TAKEOWN /F C:\Windows\SysWOW64\DDORES.DLL
ICACLS C:\Windows\SysWOW64\DDORES.DLL /grant administrators:F /t
REN C:\Windows\SysWOW64\DDORES.DLL DDORES0ld.DLL
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\SysWOW64\DDORES.DLL" "C:\Windows\SysWOW64\DDORES.DLL"


TAKEOWN /F C:\Windows\SysWOW64\EXPLORER.EXE
ICACLS C:\Windows\SysWOW64\EXPLORER.EXE /grant administrators:F /t
REN C:\Windows\SysWOW64\EXPLORER.EXE EXPLORER0ld.EXE
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\SysWOW64\EXPLORER.EXE" "C:\Windows\SysWOW64\EXPLORER.EXE"

TAKEOWN /F C:\Windows\SysWOW64\IMAGERES.DLL
ICACLS C:\Windows\SysWOW64\IMAGERES.DLL /grant administrators:F /t
REN C:\Windows\SysWOW64\IMAGERES.DLL IMAGERES0ld.DLL
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\IMAGERES.DLL" "C:\Windows\SysWOW64\IMAGERES.DLL"

TAKEOWN /F C:\Windows\SysWOW64\PNIDUI.DLL
ICACLS C:\Windows\SysWOW64\PNIDUI.DLL /grant administrators:F /t
REN C:\Windows\SysWOW64\PNIDUI.DLL PNIDUI0ld.DLL
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\SysWOW64\PNIDUI.DLL" "C:\Windows\SysWOW64\PNIDUI.DLL"

TAKEOWN /F C:\Windows\SysWOW64\REGEDIT.EXE
ICACLS C:\Windows\SysWOW64\REGEDIT.EXE /grant administrators:F /t
REN C:\Windows\SysWOW64\REGEDIT.EXE REGEDIT0ld.EXE
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\SysWOW64\REGEDIT.EXE" "C:\Windows\SysWOW64\REGEDIT.EXE"

TAKEOWN /F C:\Windows\SysWOW64\SHELL32.DLL
ICACLS C:\Windows\SysWOW64\SHELL32.DLL /grant administrators:F /t
REN C:\Windows\SysWOW64\SHELL32.DLL SHELL320ld.dll
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\SysWOW64\SHELL32.DLL" "C:\Windows\SysWOW64\SHELL32.DLL"

TAKEOWN /F C:\Windows\SysWOW64\TASKMGR.EXE
ICACLS C:\Windows\SysWOW64\TASKMGR.EXE /grant administrators:F /t
REN C:\Windows\SysWOW64\TASKMGR.EXE TASKMGR0ld.EXE
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\SysWOW64\TASKMGR.EXE" "C:\Windows\SysWOW64\TASKMGR.EXE"

TAKEOWN /F C:\Windows\SysWOW64\ZIPFLDR.DLL
ICACLS C:\Windows\SysWOW64\ZIPFLDR.DLL /grant administrators:F /t
REN C:\Windows\SysWOW64\ZIPFLDR.DLL ZIPFLDR0ld.DLL
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\SysWOW64\ZIPFLDR.DLL" "C:\Windows\SysWOW64\ZIPFLDR.DLL"
sleep 2
cls
echo.
echo *********************SYSWOW64/EN-US*********************

TAKEOWN /F C:\Windows\SysWOW64\en-US\EXPLORER.EXE.MUI
ICACLS C:\Windows\SysWOW64\en-US\EXPLORER.EXE.MUI /grant administrators:F /t
REN C:\Windows\SysWOW64\en-US\EXPLORER.EXE.MUI EXPLORER0ld.EXE.MUI
COPY "E:\MODIFYING\7 MUI W.I.P.s\SysWOW64\EXPLORER.EXE.MUI" "C:\Windows\SysWOW64\en-US\EXPLORER.EXE.MUI"

TAKEOWN /F C:\Windows\SysWOW64\en-US\SHELL32.DLL.MUI
ICACLS C:\Windows\SysWOW64\en-US\SHELL32.DLL.MUI /grant administrators:F /t
REN C:\Windows\SysWOW64\en-US\SHELL32.DLL.MUI SHELL320ld.DLL.MUI
COPY "E:\MODIFYING\7 MUI W.I.P.s\SysWOW64\SHELL32.DLL.MUI" "C:\Windows\SysWOW64\en-US\SHELL32.DLL.MUI"

TAKEOWN /F C:\Windows\SysWOW64\en-US\FONTVIEW.EXE.MUI
ICACLS C:\Windows\SysWOW64\en-US\FONTVIEW.EXE.MUI /grant administrators:F /t
REN C:\Windows\SysWOW64\en-US\FONTVIEW.EXE.MUI FONTVIEW.0ld.exe.MUI
COPY "E:\MODIFYING\7 MUI W.I.P.s\SysWOW64\FONTVIEW.EXE.MUI" "C:\Windows\SysWOW64\en-US\FONTVIEW.EXE.MUI"

TAKEOWN /F C:\Windows\SysWOW64\en-US\WININIT.EXE.MUI
ICACLS C:\Windows\SysWOW64\en-US\WININIT.EXE.MUI /grant administrators:F /t
REN C:\Windows\SysWOW64\en-US\WININIT.EXE.MUI WININIT0ld.DLL.MUI
COPY "E:\MODIFYING\7 MUI W.I.P.s\SysWOW64\WININIT.EXE.MUI" "C:\Windows\SysWOW64\en-US\WININIT.EXE.MUI"

TAKEOWN /F C:\Windows\SysWOW64\en-US\ZIPFLDR.DLL.MUI
ICACLS C:\Windows\SysWOW64\en-US\ZIPFLDR.DLL.MUI /grant administrators:F /t
REN C:\Windows\SysWOW64\en-US\ZIPFLDR.DLL.MUI ZIPFLDR0ld.DLL.MUI
COPY "E:\MODIFYING\7 MUI W.I.P.s\SysWOW64\en-US\ZIPFLDR.DLL.MUI" "C:\Windows\SysWOW64\en-US\ZIPFLDR.DLL.MUI"
sleep 2
cls
echo.
echo *********************PROGRAM FILES And PROGRAM FILES (X86)*********************

TAKEOWN /F "C:\Program Files\Windows NT\Accessories\en-US\WORDPAD.EXE.MUI"
ICACLS "C:\Program Files\Windows NT\Accessories\en-US\WORDPAD.EXE.MUI" /grant administrators:F /t
REN "C:\Program Files\Windows NT\Accessories\en-US\WORDPAD.EXE.MUI" WORDPAD0ld.EXE.MUI
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\Program Files\WORDPAD.EXE.MUI" "C:\Program Files\Windows NT\Accessories\en-US\WORDPAD.EXE.MUI"

TAKEOWN /F "C:\Program Files (x86)\Windows NT\Accessories\en-US\WORDPAD.EXE.MUI"
ICACLS "C:\Program Files (x86)\Windows NT\Accessories\en-US\WORDPAD.EXE.MUI" /grant administrators:F /t
REN "C:\Program Files (x86)\Windows NT\Accessories\en-US\WORDPAD.EXE.MUI" WORDPAD0ld.EXE.MUI
COPY "E:\MODIFYING\7 DLL+ W.I.P.s\Program Files (x86)\WORDPAD.EXE.MUI" "C:\Program Files (x86)\Windows NT\Accessories\en-US\WORDPAD.EXE.MUI"
sleep 2
cls

CD /d %userprofile%\AppData\Local
DEL IconCache.db /a
DELNEXT /d"%userprofile%\AppData\Local\Microsoft\Windows\Explorer" /nologo thumbcache_32.db thumbcache_96.db thumbcache_256.db thumbcache_1024.db thumbcache_idx.db thumbcache_sr.db
cls
echo.
echo. 
echo Finished!! :-) Moving on to re-booting.
echo.
sleep 3
DEL C:\Windows\Prefetch\DELNEXT.EXE-*.pf
shutdown /r /t 0
exit

:dontmove
echo.   
echo The batch file operation has been cancelled.
sleep 3
echo.
exit
Be aware that this batch file was also written with very little (none) experience of writing batch files, I just sort of played it by ear, with google as my aid.
 
hi

i just want to check the actual use of sleep, is this to wait a specific time before the next command is actioned?
 
Thanks for the response Kaos.

The first 17sec sleep is to give time for a restore point to be generated. The 2sec sleeps down the list just give me enough time to check the files just changed over for errors. I suppose really the last 3sec sleep only serves the function of letting me read my "finished" message before it disappears.

Apart from the restore point one they are really superfluous to the operation. I have another batch file that does exactly the same thing except I call it my "silent" version. Once the restore is made that's it. The next thing you see is the PC rebooting.

The first set up was mainly done when (a) I wasn't sure if I had written it properly and (b) so I could adapt, or shorten it down, for someone else to use, but giving them a view of what was actually taking place. By breaking it up into smaller sections (that one didn't have the clear screens command in it, btw.) of swapping a couple of files at a time, it gave just enough info to fill a normal command prompt window without reams of details flying past their eyes.
 
your very welcome Elmer

as a replacement for a "wait" command you can use this, it does the EXACT same job and i use this on all my wait commands

ping localhost -n 5 > nul

the number represents seconds as such so this would wait 5 seconds, very practical and never let me down, complete silent too so try this and let me no how it goes :)

also so u dont have streams of of info cant u use the commands in that style of format?


command here
cls
echo finished
ping localhost -n 3 >nul

next command
cls
echo finished
ping localhost -n 3 >nul
cls


so on and so on

im sure this would work??
 
Thanks a lot Kaos. That did the trick!!

I always thought using ping (my way) looked a bit "amateurish", and me an amateur!! But that silent ping is letting on nothing.

It also means that if I pass a batch file on, I no longer have to include sleep.exe and go through stressing to the recipient that it must be located in the same folder as the batch file.

Thanks again!!
 
as i see it, no command is noobish or amateurish, at the end of the day if the output of the batch file gets results and it works in the way it was intented then who cares how it was written, i think its an achievement for what you have done so far

well done!
 
Back
Top Bottom