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

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"

Related

Program started from batch file starts in background

I have a batch file that I run from a flash drive. This file attempts to
1. Close 2 programs
2. Update data on the computer based on the data on the flash drive
3. Restart the programs
The code in this batch is:
taskkill /IM "MyProgram".exe
taskkill /f /fi "imagename eq MyProgram.exe"
copy e:\File1.xml C:\Folder\SubFolder1\Themes\Data\File1.xml /Y
copy e:\File2.xml C:\Folder\SubFolder1\Themes\Data\File2.xml /Y
copy e:\File3.xml C:\Folder\SubFolder2\Themes\Data\File3.xml /Y
copy e:\File4.xml C:\Folder\SubFolder2\Themes\Data\File4.xml /Y
start /MAX "" "C:\Folder\SubFolder2\MyProgram.exe"
start /MAX "" "C:\Folder\SubFolder1\MyProgram.exe"
The first two steps work fine, with the commands that are on lines 1-6. My issue starts with step 3 and the commands on lines 7 and 8.
Is there something wrong with the batch commands?
EDIT: After digging a little more, I have found that the programs appear to be starting in the background. When looking at task manager, the programs appear in the "Background Processes" section instead of showing in the foreground as expected.
What I believe is happening is your program does not know where the configuration files are located because the working directory is where the batch file started itself. So your program is looking for its files on your usb drive. By using the /D option with the START command it will switch the working directory to whatever path you set it to.
start "" /MAX /D "C:\Folder\SubFolder2\" MyProgram.exe

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

shell:Common Startup as a parameter to XCOPY

I have a simple batch script that copies a file to the startup folder, but it appears that I can't use shell:Common Startup as a parameter to xcopy. I have tried this
xcopy hurrdurr.exe "shell:Common Startup"
and many other variations, and they don't work. As an aside, if this did work, "hurrdurr.exe" would run on every startup right, assuming I got clearance via uac to do the xcopy operation? Would using a environment variable be better? The os in question is Windows XP and proceeding.
I'm not sure why your shell command won't work, but if you need to get your program to load on startup then I would much prefer using the registry, it's cleaner and simpler, and it means you don't have to copy the file somewhere else, especially if that file is dependant on other things.
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v "Hurrdurr" /d "hurrdurr.exe" /f
Just run cmd as admin and it will work :)
If you do want to use the startup folder though, on Win7 you can use
"%appdata%\Microsoft\Windows\Start Menu\Programs\Startup"
I would also use a shortcut as #David suggested instead of copying the actual file.

Copy a .bat off a USB and copy it to the Startup folder script - WinXP

I'm a Mac/iPhone dev so I don't know very much about Windows scripting...
The point is I have to install a startup app on many computers, so I'd like to have a USB stick with two .bat files:
would be the actual "app"
would be the script that would copy the 1st.bat off my USB to the Windows startup folder...
How can I do that?
the name of my usb is "USB" and the name of my startup app is "startup.bat".
How I already said, I'm extremely lame in Windows programing, and I need it acutely ;)
Thanks A LOT!
Try the following script. This will cause the application to run whenever the current user logs in. Without administrative privilages, you won't be able to do it for all users in one go.
#Echo Off
CD /D %~dp0
Set StartupFolder=%AppData%\Microsoft\Windows\Start Menu\Programs\Startup
If Exist "%StartupFolder%" Goto :FoundStartup
Set StartupFolder=%UserProfile%\Start Menu\Programs\Startup
If Exist "%StartupFolder%" Goto :FoundStartup
Echo Cannot find Startup folder.
Exit /B
:FoundStartup
Copy "MyApp" "%StartupFolder%"
Each line does the following:
Turn off command echoing, making the script look cleaner to the end user.
Set the current directory to wherever this script is located.
Set the Startup folder's path as expected in Windows Vista or later.
If this folder exists, jump to the copying stage.
Set the Startup folder's path as expected in Windows 2000 or later.
If this folder exists, jump to the copying stage.
Report that the Startup folder can't be found.
Exit the batch script.
A label that can be jumped to.
Copy "MyApp" from the current folder (USB) to the Startup folder.
I don't want to take credit for Hand-E-Food's answer, but I figured out why his code didn't work and I can't reply to his answer, so here it is. Instead of using quotes around the %StartupFolder% variable in the Copy line, use them around the path for Set StartupFolder. Therefore, the code would be as follows.
#Echo Off
CD /D %~dp0
Set StartupFolder="%AppData%\Microsoft\Windows\Start Menu\Programs\Startup"
If Exist %StartupFolder% Goto :FoundStartup
Set StartupFolder="%UserProfile%\Start Menu\Programs\Startup"
If Exist %StartupFolder% Goto :FoundStartup
Echo Cannot find Startup folder.
Exit /B
:FoundStartup
Copy "MyApp" %StartupFolder%
The only reason I figured this out is because it wasn't doing anything for me either, so I tried removing the quotes around %StartupFolder% and that resulted in an error message that it couldn't find the folder, but at least I knew it was doing something at the end. Once I figured out that it was looking for the wrong folder because it thought the folder name stopped at the first space in its name, I simply added in the quotes and voila!
Try this (replace app.bat with whatever your actual app is called). This should work on Windows 2000 and up.
IF EXIST "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\*.*" COPY APP.BAT "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\"
IF EXIST "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\*.*" COPY APP.BAT "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\"

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

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

Resources