How to disable auto sleep on external USB hard drive in Windows XP - windows

I've seen a related question on this website regarding a Linux system. I have the same question on a Windows XP OS. I bought a Winchester USB external HD, and found out from technical support that the sleep feature is in the firmware and cannot be turned off. I'm looking for an application that will automatically read/write to that drive periodically to keep that timer resetting (every 5 minutes?). Is anyone aware of a small application for Windows XP that will do that?
Thanks for your help.

I have tried nearly everything to fix this problem on my external which is shared out containing my movies. Nothing ever worked. I have a WD Mybook, and I think the sleep is occurring internally in the drive.
I have a solution that works for me, and should for anyone else. The key is to keep the USB drive doing something. Not a lot, but something simple, causes some type of change on the drive.
Windows XP does not have a SLEEP command, but you can download one and add it to the SYSTEM32 folder. Then all you need to do is make a simple batch file, and put it in your startup folder so it executes when you log in.
Make sure you have write access to the drive. Change the drive letter to yours...
Make a batch file.
:start
#echo off
#cls
#echo Keeping USB Drive Awake. Do not close this window!
#sleep 60
#dir E: /S /B >E:\keepawake.txt
#echo Drive Accessed %date% at %time% >keepawake.txt
goto start
This will write the full directory structure to a file on the E: drive in a file called keepawake.txt. Then it will overwrite it with a simple note containing the date and time. This will always be different. It will do it every 60 seconds.
Problem solved...
-Krehator

Make batch (.BAT) file something like this:
#echo off
:start
copy c:\windows\notepad.exe g:\ (Or whatever your external drive is)
choice /N /D Y /T 120 (The 120 is the delay in seconds)
goto :start

You could try NoSleepHD.
http://nosleephd.codeplex.com/
It writes an empty text file to your chosen drive every few minutes (you can choose the minutes) to stop the drive going to auto-sleep mode.
google: nosleephd
Ashx

I'm using the free/open source Windows program KeepAliveHD (http://keepalivehd.codeplex.com/) to accomplish this. Works well.

Any text editor with an autosave function would do it.
You could also write a batch file to get a directory listing, and have it act recursively (call itself) after a set time period. Or use windows scheduler to execute it.

use this batch file
change the 1st two lines letter t: to your drive letter.
it works in all versions of windows
#echo off
:start
REM --- Change the drive letter below to match your HDDs. To add another drive replicate the copy and del lines ---
copy NUL t:\HDDActive.txt
del t:\HDDActive.txt
TIMEOUT /T 30 /NOBREAK
goto start

Related

I'm trying to copy my game saves from the appdata directory to another drive for backup purposes but the files wont copy

I'm trying to copy my save files for my games from my AppData directory to another drive on my system but the files fail to copy. I'm using robocopy to try to achieve this and am not sure what is going wrong.
The Script I'm using is:
#echo off
set "source=C:\Users\MyUser\AppData"
set "destination=F:\Game_Saves"
robocopy "%source%" "%destination%" /E /Z /J /EFSRAW /W:1 /R:0 /REG /XJ
exit /b
I've had times where I went to play a game after some drive failure or general errors from my ISCSI drives changing letters and losing my save for my games through Epic Games because of the crappy download system they use and i just want to backup my saves to the other drive and then using duplicati to do a more long term backup and cant seem to find out why the files wont copy. If anyone can help me troubleshoot this I'd be very greatful.
I tried changing flags in my script and setting flags I thought might be helpful to my usage but it hasn't worked. I just dont want to lose my saves as some of them have 100s of hours in them. I should also mention that I want my script to complete as fast as possible which is why I don't have any retries set as the only errors I was running into were "Permission Denied" errors for folders I don't need to backup.
Drive F:\ is just a slow SATA hard drive in my PC and not an ISCSI drive and "copy.bat" my batch script is in the root of F:\
Task Scheduler Settings:
General:
Run whether user is logged in or not - yes
Run with highest privileges - yes
Triggers:
Run weekly - yes
Stop task if it runs for longer than - 4 hours
Enabled - yes
Actions:
Start a Program - yes
Program/Script - F:\copy.bat
Removing the /EFSRAW flag worked to copy the files though I'm still unsure as to why it was causing interference in the first place unless it just doesn't allow the copy of un-encrypted files in the first place with that flag set.
Updated script for others if they want to use it though it is clunky as it copies all of AppData and that is around 80 GB for my computer so this is not recommended.
#echo off
set "source=C:\Users\MyUser\AppData"
set "destination=F:\Game_Saves"
robocopy "%source%" "%destination%" /E /Z /J /W:1 /R:0 /REG /XJ /LOG+:copylog.txt
exit /b

Bat file to remove all user folders with 20 in the name bat file

I just started working in a school and the way we have the computers set up they automatically download a students user from the network when a student logs into any computer. We're working on making a script to run this command for cleaning them :
for /D %f in (*20**) do rmdir %f /s /q
In command prompt it shows every user with 20 in the name and deletes them from the computer along with everything in these folders.
We can't just change the file name to .bat instead of storing it in a note pad to copy to a command prompt window.
The batch file we currently have is
#echo off
pause
for /d %%f in (*20**) do rmdir C:\Users\%%f /s /q
pause
Which shows each pause to try to help me debug it but doesn't delete the folder. What am I doing wrong here?
I wouldn't do this. As I assume it's something like:
Regular%20User
%20 is basically a space.
To address your issue of wanting to clean them, as I assume it is the temp profile that is created when they login(from a network profile), rather than making the script clean anything with 20 in it, make a script that removes users locally that are of a certain Group Policy group. That way your admin accounts stay locally, and if your script is done right, your student's profiles are autocleaned after a set delay. (I would recommend 30 days, as you can use the temp profile as evidence if a student is caught on a computer he/she shouldn't be on :)

Batch file fails on startup, but works when I click it

I have a small problem with my batch script. The idea is simple:
I have an app that checks for updates periodically (checks for one exe file). If it finds one it then downloads it, renames it and puts it in the same directory as the old file. Then the app creates a .bat file and also puts it in the same directory. The contents of .bat file are :
#ECHO OFF
ECHO Waiting while old application closes...
ping 127.0.0.1 -n 5
taskkill /IM myApp.exe /f
ECHO Updating application
move /y myApp_TEMP.exe myApp.exe
START myApp.exe
pause
Before I close my application (myApp.exe) I instruct it to execute the .bat file, ant wait 5 sec. so it will properly close, that’s why the ping 127.0.0.1 -n 5 is here for. So ideally this script should:
Close myApp.exe
Rename myApp_TEMP.exe to myApp.exe
Overwrite old myApp.exe with new myApp.exe
Start myApp.exe
And it works when I double click on the .bat file, the problem occurs when I put myApp.exe in Windows startup list.
So the app start's, downloads update, generates the .bat file (keep in mind that everything is happening in the same directory) and then runs it. After some digging i found out that the line move /y myApp_TEMP.exe myApp.exe is not executing. But when I run this script manually everything works. Maybe someone has already experienced similar issues?
You are using relative paths in your filenames. Check that it's being run with the correct current directory or switch to absolute paths.
I would suggest using a CD /D <directory of the .exe file> before the move, that way you always know for sure you're in the right directory. Also, you can use timeout 5 /NOBREAK to wait for 5 seconds in regular batch-files
Might need to add some redundancy to the script. Such as:
#ECHO OFF
ECHO Waiting while old application closes...
taskkill /IM myApp.exe /f
timeout 5 /nobreak >nul
ECHO Updating application
IF EXIST "%cd%\MyApp_TEMP.exe" move /y myApp_TEMP.exe myApp.exe
IF EXIST "%cd%\MyApp.exe" GOTO STARTAPP
ECHO File not found. Unable to update.
pause
exit
:STARTAPP
START myApp.exe
pause
The problem seems to stem from a problem in directory searching. While this could be solved with a rather long search time, it'd be easier to make sure that the batch is in the same directory as "MyApp_TEMP.exe" or using
cd <path to MyApp_TEMP.exe>
ECHO Updating application
move /y myApp_TEMP.exe myApp.exe
START myApp.exe
pause
You could also use an ELSE if the file is not found, I just Personally prefer to use label jumping with GOTO.

Batch file to start all programmes in the start folder of XP

I need start all folders in a the Windows "Start/Programs/Startup folder" of an XP machine, explorer is disabled to stop top people playing and remove the Start and Task-bar.
I can run a batch file at start-up but how do I write the batch to run ALL programs in the "Start/Programs/Startup folder" the programs in the folder may change but the batch needs to remain the same
I am able to open each file individually using the below code but I really need to be able to open everything in the folder to avoid problems in the future
start "" /b "C:\Documents and Settings\User\Start Menu\Programs\Startup\PROG.appref-ms"
I have tried the code below, that batch starts but nothing starts
%DIR%=C:\Documents and Settings\Pete\Start Menu\Programs\Startup
for %%a in (%DIR%\*) do "%%a"
Running the batch from the desktop also doesn't run the programs in the start folder, the DIR address is taken from windows explorer when I navigated to the folder with the short cuts in
This is an interesting request--one that I would question the motive behind, but since you asked, here's a way you could accomplish it:
#echo off
set DIR=C:\Your\Directory
for %%a in ("%DIR%\*") do "%%a"

My batch file is closing a program too early

Thank you, for those whom took the time to read my question. I am a gamer and would like to execute a few things. First, I would like to Trigger a batch file when I click a program, how do you do that or is it even possible? Basically, activating a game, triggers the batch file.
NOw for the batch file problem, I want to execute Xpadder when I activate games (this is an mmo) and when I close the game I want Xpadder's process/service to close. Ultimately, it's auto trigger,activate,wait,terminate.
That's kind of the process I want it to go if all can be done.
Batch File:
#echo off
start "Blade" "C:\Users\user\Documents\Blade.xpadderprofile" Blade.xpadderprofile
ECHO Blade.xpadderprofile STARTED
start /w "C:\Program Files (x86)\game\games.exe" games.exe
ECHO games STARTED
taskkill /f /im Xpadder.exe
This actually works but the problem is there are two ".exe" files with mmo's. I'll start the game and it would close Xpadder too early because one launcher starts another launcher/client. Xpadder works for the first launcher but the first launcher closes so the game will start. I hope I am explaining myself clear enough.
Reference link: How to automatically close App_A when I close App_B using batchfile
Essentially, this is the same question I have but it's not very clear. What is the batch code to get Xpadder to stay on until the second launcher/client is closed not the first one?
P.S
The game has to open through the launcher then into the second launcher/client or it will not work.
here is the other clients name and path i think:
C:\Program Files (x86)\game\gamer\bin\gam.exe
How about the use of the PsExec, a small MS ulility? Using it, your batch should work:
cmd /c psexec -d "Blade" "C:\Users\user\Documents\Blade.xpadderprofile" Blade.xpadderprofile
start /w "C:\Program Files (x86)\game\games.exe" games.exe
taskkill /f /im Xpadder.exe
The file psexec.exe must be placed in folder enlisted in the system variable WINDIR or PATH, or, otherwise, you should call it with its full path, eg. *C:\Program Files\Others\pstools.exe".
You can add #echo off, salt, pepper or some green Tabasco if you have mon€y for this :D

Resources