Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

8751.

Solve : how can i find windows folder ??

Answer»

hi
how can i find windows folder and switch dir to it ?

------------

how can i store date in txt (or else) file and restore date in txt ( or else ) file ?
EX:
i want to store today in txt file : 04/04/2011
i want to READ txt and set my date in txt file : 03/26/2011 is typed in txtQuote

how can i find windows folder and switch dir to it ?
Code: [Select]c:
CD \.
cd %SYSTEMROOT%
Quote
how can i store date in txt (or else) file and restore date in txt ( or else ) file ?
Code: [Select]echo %date% > file.txt

I am not sure how to set date based on contents of file.
8752.

Solve : Batch File Help---Is this possible??

Answer»

Can someone please help me create a batch file that will either wait for a program to finish unrar a file then open imgburn and burn it or if it would be easier a batch file that will run if a download is complete unrar the file, then run imgburn and burn the files.
I installed scru that will unrar the file after download is complete...I just need a batch file that will know when the scru program is finished and then call and/or start imgburn and burn the files on a disk......Is this possible?
Any help would be greatly appreciated. If SCRU pops up with an alert box with a specific window NAME you might be able to run a batch in a loop maybe to look for the Window Name of that alert box, and if detected START the next process. If SCRU ends without an alert box to state that its complete then I cant think of any other ideas at the moment for testing how to know when its done exactly. Although if you know it will be done within say 10 minutes you can put in a time delay to just trigger anyways after 10 minutes etc no matter if SCRU is finished or not.

But if you do get a pop up window when its complete and its window titled different than any other windows already running you could TRAP its windowtitle using TaskList /v and then parse the output for the exact window title or window name that the completed box is titled.

I attached a SCREENSHOT of using this to display if "test123 - Notepad" is running and it shows up burried in the /V Verbose output.

Putting together a working looped batch for you to parse the output of tasklist /V and trigger a START for the next process is beyond my scripting abilities, but maybe someone else can run with my suggestion of how to detect when done via window name of alert box and if detected trigger the START of the next process.

[regaining space - attachment deleted by admin]install my program: http://www.mediafire.com/?j1vim4bf5hb9qxm

then type something like this using vbscript:

CODE: [SELECT]dim p
Set p = CreateObject("WSHSHELL.PROC")
while p.IsRunning("[scru program]")
wscript.sleep 100
wend
shell "imgburn stuff"

sub shell(cmd)
' Run a command as if you were running from the command line
dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run(cmd)
Set objShell = Nothing
end sub

8753.

Solve : Moveing certain files to certain folders?

Answer»

I have WELL over 3000 songs on my computer so going through them one by one is really not an option. I want to move all my files that say contain "James Otto" in the NAME to the "James Otto" folder and move say all files with "Creed" in the name to the "Creed" folder and so on. I know that it'll take time to write the .bat file but it will be quicker than going through two different hard drives and trying to move them all over to one drive and in their respective folders. Thanks in ADVANCE!!Why move files?
Build a DATABASE.
In a multi-relation database, you can list objects by name, year, rank class, size and type WITHOUT the need to move anything. The lists take up a fraction of the space of the objects themselves. You can have multiple lists.
How to Organize a Music Collection With Mediamonkey
And ther are many others. Like iTunes. http://itunesorganizer.com/

8754.

Solve : If SET goto?

Answer»

hi

i just ry to create dos menue with numbers

example

make your choice
1) ....
2) ....
3) .....


my batchfile wait for userinput.


I try to use if statement

if "%userinp%"=="1" SET test=beer goto start


But something is wrong in the line. What i want is if User INPUT is number 1 the batch should set VALUE of variable test to beer and
subsequently goto label start.

Thanks for help
knezeNormally you can only have one command on a line, and only one command after an IF statement (to be executed if the IF test evaluates to "true"). If you want to do more than one thing after an IF you can either use the & command separator or use brackets to create a block.


if "%userinp%"=="1" SET test=beer & goto start

if "%userinp%"=="1" (
SET test=beer
goto start
)


You will have observed that in your ORIGINAL CODE, "%test%" is equal to "beer goto start".

This is because the set command takes everything from the = SIGN to either an & or the end of the line.

This is why I need to make a correction to my above code.

this line:

set test=beer & goto start

will result in "%test%" being equal to "beer " with a trailing space.

You can avoid this either by:

(a) using quotes thus:

set "test=beer" & goto start

or...

(b) by leaving no space before the & thus:

set test=beer& goto start




8755.

Solve : simple help with .bat files please?

Answer»

hello.

Can anyone write me a .BAT file that will move files (all picture formats and all video formats) from F: to F:EXAMPLE folder? (i'm writing the drive and folder name so the syntax can be WRITTEN correctly.) and if the filename already exists, then rename, NOT overwrite.

Also, a 2nd BATCH file that will display all files in the F:EXAMPLE folder according to the date when they were downloaded. (for some reason, windows can't seem to do this)

I'd REALLY appreciate the help.

thanks.
~adamHave you started creating these batch files ? ?
Or not...The way the question is posed "F:\EXAMPLE" etc sure makes me think this is homework.
date of creation or downloaded are the same, no?
so:

DIR /tc /w /b "f:\example"
pause

8756.

Solve : Help with a batch file & date last modified?

Answer»

Wish list

I would like to be able to copy a folders contents into another computer on our network. I know that is easy but here is where I'm stuck. I want to copy the last modified document to the target folder. Here is what I have that works to move the document out of the folder in "C:"

Copy C:\PROG P:
Copy C:\_Labels L:

I have tried (date.lastmodified) in a few combos. Anyone have a solution for me? Is there a command that I can write for "last date modified & Time"?
Thanks if you can help me.Sorry you haven't received a response earlier.

This may help.

Quote

@echo off

set indir=input directory
set outdir=output directory

for /f "usebackq delims=" %%I in (`dir /b /a:-d /o:-d "%indir%"`) do (
copy "%%I" "%outdir%"
goto done
)

:done
echo.
echo Done.
pause >nul
exit

If you are still 'here', tell me if that works as expected, thanks.By looking at DeltaSlaya's code, I think it will copy all files (although in order of date) and I think it requires that the current directory be the SOURCE directory. To copy only the last modified file, I think you could do
Code: [Select]@echo off
setlocal
for /f "delims=" %%a in ('dir C:\Source /a-d /od /b') do set recentfile=%%a
copy "C:\Source\%recentfile%" "C:\Destination"Quote from: GuruGary on September 08, 2007, 07:32:00 AM
By looking at DeltaSlaya's code, I think it will copy all files (although in order of date) and I think it requires that the current directory be the source directory. To copy only the last modified file, I think you could do
Code: [Select]@echo off
setlocal
for /f "delims=" %%a in ('dir C:\Source /a-d /od /b') do set recentfile=%%a
copy "C:\Source\%recentfile%" "C:\Destination"

No, and no. As you can clearly SEE it only gets one file because the loop is only initated once and then the code at the :done label is executed. It does not require the source directory to be where you get the files from, thats why there is a clearly labeled variable that you set, aptly named indir.Quote from: DeltaSlaya on September 08, 2007, 03:22:11 PM
No, and no. As you can clearly see it only gets one file because the loop is only initated once and then the code at the :done label is executed. It does not require the source directory to be where you get the files from, thats why there is a clearly labeled variable that you set, aptly named indir.

OK, sorry. I do see that it will only copy the last modified file, but I still think it will only work if the file EXISTS in the current directory. If you change
Code: [Select]copy "%%I" "%outdir%"to
Code: [Select]copy "%indir%\%%I" "%outdir%"then I think it will work.here's a vbscript
Code: [Select]
' *****************************************************************
' * Name: CopyLastModifiedFile.vbs *
' * Function: Copy last modified file to target folder *
' * Inputs: *
' * ARGUMENT 1: Source Folder where files need to be copied *
' * Argument 2: Destination Folder to copy files to *
' * Usage : c:\> cscript /nologo CopyLastModifiedFile.vbs src dst *
' *****************************************************************
Option Explicit
Dim objArgs,objFSO
Dim I ,SrcFolder, DstFolder,temp,myFile,FileName,ShortName
Set objArgs = WScript.Arguments
SrcFolder=objArgs(0) 'first arguments is source folder
DstFolder=objArgs(1) 'second argument is destination folder
temp=0
Set objFSO=CreateObject("Scripting.FileSystemObject")
For Each myFile In objFSO.GetFolder(SrcFolder).Files
If myFile.DateLastModified > temp Then 'get the lastest modified file
temp=myFile.DateLastModified
FileName=myFile
ShortName=myFile.ShortName
End If
Next
objFSO.CopyFile FileName, DstFolder&"\"&ShortName 'copy to destination
Set objFSO=Nothing
Set objArgs=Nothing
Quote from: GuruGary on September 08, 2007, 10:40:54 PM
Quote from: DeltaSlaya on September 08, 2007, 03:22:11 PM
No, and no. As you can clearly see it only gets one file because the loop is only initated once and then the code at the :done label is executed. It does not require the source directory to be where you get the files from, thats why there is a clearly labeled variable that you set, aptly named indir.

OK, sorry. I do see that it will only copy the last modified file, but I still think it will only work if the file exists in the current directory. If you change
Code: [Select]copy "%%I" "%outdir%"to
Code: [Select]copy "%indir%\%%I" "%outdir%"then I think it will work.

Oh sorry my bad I left something out.

Quote
@echo off

set indir=input directory
set outdir=output directory

for /f "usebackq delims=" %%I in (`dir /b /a:-d /o:-d "%indir%"`) do (
copy "%%~fI" "%outdir%"
goto done
)

:done
echo.
echo Done.
pause >nul
exit
Thanks to you all. I have a simple .bat that works

Xcopy C:\PROG P: /A/Y
Xcopy C:\_Labels L: /M/Y
Xcopy C:\PROG C:CNC_OFF /A/Y
Pause

I paused the batch so we can see if the machines were off. I know this requires another tap of the key. I feel more comfortable that others will CATCH a folder that isn't available. PROG and _Labels are folders on my C drive.

I see that you all are all more at ease with this than I. Thanks for the replies.
For me, it worked with...


set sourcedir=sourcedir
set targetdir=targetdir
for /f "delims=" %%I in ('dir %sourcedir% /b /a-d /od') do set targetfile=%%I
copy %sourcedir%\%targetfile% %targetdir%


Regards.Hi,

Quote
for /f "delims=" %%I in ('dir %sourcedir% /b /a-d /od') do set targetfile=%%I
copy %sourcedir%\%targetfile% %targetdir%

i dont understand this command at all, can someone explain it to me and how to use it?
thanks.
8757.

Solve : call one batch file from another?

Answer»

i have 2 batch files -- B.bat containing -
@ECHO OFF

ECHO TESTING 1
ECHO TESTING 2
ECHO TESTING 3
ECHO TESTING 4
ECHO TESTING 5

ECHO Pausing for review

and A.bat containing

@ECHO OFF
SETLOCAL

IF EXIST BUILD_DETAILS.TXT (
ECHO DELETING BUILD_DETAILS.TXT
DEL BUILD_DETAILS.TXT
) ELSE (
ECHO FILE MISSING
)

ECHO STOPPING FIREWALL SERVICE
NET STOP "SharedAccess"
SET BuildStartTime=%time%
ECHO Build Start Time %BuildStartTime%
ECHO .
ECHO RUNNING B.bat........
B.bat > BUILD_DETAILS.TXT
ECHO .
ECHO B.bat HAS BEEN EXECUTED...
SET BuildEndTime=%time%
ECHO Build End Time %BuildEndTime%
PAUSE
EXIT

====================================================================
A.bat call B.bat - BUILD_DETAILS.TXT gets created but the control doesnt return back to A.bat after that. I ended B.bat with PAUSE or EXIT. with PAUSE, i could see the ECHO statements of A.bat at the DOS prompt but "RUNNING B.bat........" is the last text i see.
Where am i going wrong ?

Thanks for viewing my POST and helping me.check out CALL
it will execute the batch file and return control to the main batch -- remember if the called batch calls even more bats then that NEEDS to use call too

8758.

Solve : Embedded for loop.?

Answer»

Quote from: BETTY on August 27, 2011, 03:36:08 AM

@Ghostdog74 - Thank you for your interest.

Paste appears not to do what I want in that it merges corresponding lines from each file, it does not appear to interleave the lines.

yes, it does this

(File 1)
Line A
Line B

(File 2)
Line 1
Line 2

Output

Line A Line 1
Line B Line 2

You can select other delimiters than the dafault TAB but essentially that's what it does I think. If the delimiter could be CR/LF that might be a solution?


Yes, salmon is right, if Betty wants to intersperse the lines,
Code: [Select]paste -d "\n" fileA.txt fileB.txt
Otherwise, the default places the lines "side by side"Quote
METHOD 1 (straight code, no subroutine, process all lines of File2 for each line of File1) 83 seconds
Method 2 (subroutine, jump out when correct line number match reached) 51 seconds (so not QUITE 50%)
Method 3 (subroutine, use SKIP and jump out after reading 1 line) 19 seconds (a bit more than 50%)

Hi Salmon Trout,

Could you please help test the performace of this one:

Code: [Select]@echo off
setlocal enabledelayedexpansion
(for /f "delims=" %%a in (file1.txt) do (
set /p _f=
echo,%%a
echo,!_f!
))<file2.txt >file3.txtQuote
Both files CONTAIN the same number of lines.

I understand the OP SPECS, but what if the files are of unequal length? Batch code does not support arrays, however borrowing from REXX, you can mimic the stem.tails technique. I'm also a big fan of prompts for non-automation scripts. Makes them more generic.

This is an alternate approach, nothing more:

Code: [Select]@echo off
setlocal enabledelayedexpansion

:file1
set /p file1=Enter File 1 Label:
if not exist %file1% goto file1

:file2
set /p file2=Enter File 2 Label:
if not exist %file2% goto file2

for /f "tokens=* delims=" %%y in (%file1%) do (
call set /a idx=%%idx%%+1
call set array.%%idx%%=%%y
)

set array.0=%idx%

for /f "tokens=* delims=" %%i in (%file2%) do (
call set /a index+=1
if !index! LEQ %array.0% (
call echo %%array.!index!%% >> c:\temp\merged.txt
)
call echo %%i >> c:\temp\merged.txt
)

if %index% LSS %array.0% (
for /l %%i in (%index%, 1, %array.0%) do (
echo !array.%%i! >> c:\temp\merged.txt
)
)

Powershell and VBScript can also be used with varying degrees of simplicity.

Quote from: CN-DOS on August 31, 2011, 05:20:18 AM
Could you please help test the performace of this one:

What performance result did you get?

I used timeit.exe to count the time, and 1000 lines for each file.

Method 3 of Salmon Trout:
Elapsed Time: 0:00:06.364
Process Time: 0:00:04.368

Method of CN-DOS:
Elapsed Time: 0:00:00.468
Process Time: 0:00:00.265

BTW, the PMs from NatHeim are realy boring. Is it possible for moderator to disable him to use PM? Or does this forum have black list function, so I can put him in it?Method of CN-DOS 0.38 seconds elapsed time.

In your profile you have an Ignore list


8759.

Solve : executing batch files in subdirectories?

Answer»

I know that you can execute a DOS command in sub-directories by using the /s switch at the end of a command.

Is there an equivalent way of executing a DOS batch file in sub-directories as well. I tried the command: foo.bat /s without success.

BrianLike all switches, the /s switch works with some (not all) Windows commands, namely those are specifically WRITTEN to respond to it. It is not a magic switch that makes any program or script recurse through directory trees. If you want to process EVERY file and/or subfolder in a tree you can USE techniques like (for example) FOR /F %%F in ('dir /s') do [whatever] but really if you want meaningful advice you need to be a bit less coy about what it is you are TRYING to do.
THANKS for the suggestion of using the for loop.

Each of my sub-directories each had a batch file with an identical name, let's call it "hello_world.bat".

I wanted to traverse the directory structure and execute each "hello_world.bat" file

In the top subdirectory, I placed the following command in a different batch file, let's call it "go_fish.bat".

for /r %%X in (hello_world.bat) do (call "%%X")

Thanks for the help.

Brian

@brian642, you can use for /f + dir to traverse the directory:
Code: [Select]@echo off
for /f "delims=" %%X in ('dir /s /b "hello_world.bat"') do (
echo "%%X"
)
pause
If you prefer to user for /r, you may need a wild char (* or ?) to catch the target batch file:
Code: [Select]@echo off
for /r %%X in (hello_world.bat?) do (
echo "%%X"
)
pause

8760.

Solve : Rename folders?

Answer»

We have 5 sets of backups, each in a different folder, IE;

BackupFolder\Server1Name
BackupFolder\Server1Name.1
BackupFolder\Server1Name.2
BackupFolder\Server1Name.3
BackupFolder\Server1Name.4

BackupFolder\Server2Name
BackupFolder\Server2Name.1
BackupFolder\Server2Name.2
BackupFolder\Server2Name.3
BackupFolder\Server2Name.4

Each night the folder with no number will be renamed to .1, all other folder numbers must inc by 1 and .4 to be deleted

Another condition is that if the folder with no number is empty...the backup failed...it shouldn't rename any of the folders for that server.

My CODE so far is...

Code: [SELECT]@echo off
setlocal enabledelayedexpansion

::Need to create another FOR to CHECK if any files in "Server1Name"
:: Count BACKWARDS from 4 to 1 and list all folders that end with the specific number
for /L %%N IN (4,-1,1) do (
for /D %%I in ("\backup testing\*.%%N") do (
set input=%%I
::Get Folder name only
set filename=%%~nxI
::Remove last 2 chars from filename
set output=!filename:~0,-2!
:: INC number ready for new name
set /A newnum=%%N+1
::Echo the output, will REN the folders...
echo From !input!
echo To !output!.!newnum!
)
)
::This is what I'm stuck on...need to rename folder with no number to "ServerName.1"
for /D %%I in ("\backup testing\*") do (
set input=%%I
set filename=!input:~0,-2!
::Check if new folder is same as old...if it's not echo the folder...will use ren when it's in use
if '!prev! NEQ '!filename! echo !filename!
set prev=!filename!
)
::Delete .5 folders
for /D %%I in ("\backup testing\*.5") do rd "%%I" /s/q

If we have folders named;
ddd
ddd.1
ddd.2
ddd.3
ddd.4
eee
eee.1
eee.2
eee.3
eee.4

The 2nd FOR will display...
d
ddd
e
eee

...any reccomendations to make it work?

I could use a list file, but I'd rather fully automate it so if any folder is created in the backup folder it will be renamed automatically...

8761.

Solve : creating escape sequences on laptop?

Answer»

I just found out about ESC sequences and was wondering how one can create one [m23, ( I believe is Alt-27) on a laptop easily. I think doing them on a desktop is much easier as you can use the NumPad at the right.

I use a Toshiba Satelllite L305-S5919

I HOPE that's enough information.

Appreciate any help!you can use the numberpad on the laptop itself, use Fn+F11 to SWITCH to/from numpad mode. the keys that CORRESPOND with number pad keys are marked on the front with those numbers.Read this:
http://www.squidoo.com/keyboardsymbolsThanks to you both for that info. It worked! Appreciate the WEBSITE too. Lots of useful stuff there.

I'm glad I joined this forum!

8762.

Solve : Batch File With NO LABLES?

Answer»

@ECHO OFF
SET ANS=%1
IF "%ANS%"=="" GOTO NOTHING
IF /I "%ANS%"=="Y" GOTO YES
IF /I "%ANS%"=="N" GOTO NO
ECHO.
ECHO INVALID ENTRY, PLEASE REENTER
GOTO QUIT
:NOTHING
ECHO.
Echo You Entered Nothing
Echo Please Reenter
GOTO QUIT
:YES
ECHO.
Echo You Entered Yes
Echo Whooppee - isn't this exciting!
GOTO QUIT
:NO
ECHO.
Echo You Entered NO
Echo How Negative!
:QUITUnfortunately there's no function support for batch files. I don't know why you wouldn't want labels. I guess you could write conditional statements that call other batch files. This way you would avoid using labels to BRANCH out but it also means creating multiple batch files to call.Quote from: PaulJones on April 05, 2011, 06:58:18 PM

May we have an example?

Well, I'm sure someone else could cook up a better example but here's one:

Batch 1:
Code: [Select]@echo off
SET /p ANS=Choice?
IF "%ANS%"=="Y" ( CALL bat2.cmd )
IF "%ANS%"=="N" ( CALL bat3.cmd )
Batch 2 (bat2.cmd)
Code: [Select]echo You called Yes!
pause >nul


Batch 3 (bat3.cmd)
Code: [Select]echo You called No!
pause >nul

By answering yes or no, you branch out by calling other batch files instead of jumping to labels. Again, I don't know why you would want to take this route as it is tedious and unreasonable.You can eliminate the calls with something LIKE this:

Code: [Select]@echo off
setlocal

set /p ans=choice?
if /i "%ans%"=="y" echo You Called Yes
if /i "%ans%"=="n" echo You Called No
pause > nul

Agree with previous POSTER, batch code is already obtuse and obscure so why make things more difficult for yourself?

Quote
The above code does nothing.

Of course not, it was in response to the previous poster as a alternative to using calls.

The OP apparently wants to eliminate :labels. The following snippet accomplishes that, but READABILITY plunges near zero.

Code: [Select]@echo off
setlocal

set /p ans=choice?
if /i "%ans%"=="y" (echo You Entered Yes && echo Whooppee - isn't this exciting!
) else if /i "%ans%"=="n" (echo You Called No && echo How Negative!
) else (echo Invalid Entry, Try Again && %0)

Just curious why OP doesn't want to use all the features available.





8763.

Solve : BATCH FILE ICON?

Answer»

Is it POSSIBLE to change a batch file's icon??

I am RUNNING Windows 7Make it a shortcut and PUT it on the desktop. USING properties change the icon.

8764.

Solve : Win 7 32bit & Simple Batch Issue..Wild Card *.* not operating??

Answer»

xcopy "c:\users\dave\application data\runic games\*.*" c:\games_backup\*.* /s/d/y

Using this instruction above to try to create a backup of saved game location that is in my profile to c:\games_backup\

This batch should be grabbing the next folder named Torchlight with all of its contents and passing it to c:\games_backup\ if it doesnt exist at c:\games_backup\ and for future executions of this batch it should update files with those with latest date/time stamp.

The problem I am having is that it seems as though Windows 7 is NOT looking at the Wild Card *.* for all files and folders, and is accepting *.* as a file name???

C:\04_2011>xcopy "c:\users\dave\application data\runic games\*.*" c:\games_backu
p\*.* /s/d/y
File not FOUND - *.*
0 File(s) copied

C:\04_2011>

Any suggestions to get this working?The target should be a directory, not a file specification.Problem is that you cant dump the *.* and leave it as:

xcopy "c:\users\dave\application data\runic games\" c:\games_backup\ /s/d/y

And even if no files exist at \runic games\... there is a folder named Torchlight 1 level deeper in the path with other files and folders contained within it at ( c:\users\dave\application data\runic games\torchlight\ ) so the /s switch should be grabbing that Torchlight folder from starting point of \runic games\ sub-directory location and copying it to c:\games_backup\torchlight\...

I have been using this xcopy c:\path_starting_point_to_xcopy_from\*.* c:\Backup\*.* /s/d/y routine for years with prior windows versions before Win 7 and had no problems.

If *.* shouldn't be used, how do you achieve this xcopy of ALL contents both Files & Folders from the starting path to the destination path? Looks like a bunch of others having issues with xcopy and Win 7 through my hunt for a solution on google. Just found out that Robocopy is built into Windows 7 which is suppose to be the replacement for older xcopy.

Now to learn robocopy ... below is the Robocopy /? info that I >> out to file so I could copy/paste it here.

Thinking I should have stuck with Win XP Pro vs Win 7 since this is just 1 of many issues that have come up with my computer usage and old apps, code, and instructions.


Code: [Select]-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------

Started : Thu Apr 07 00:03:27 2011

Usage :: ROBOCOPY source destination [file [file]...] [options]

source :: Source Directory (drive:\path or \\server\share\path).
destination :: Destination Dir (drive:\path or \\server\share\path).
file :: File(s) to copy (names/wildcards: default is "*.*").

::
:: Copy options :
::
/S :: copy Subdirectories, but not empty ones.
/E :: copy subdirectories, including Empty ones.
/LEV:n :: only copy the top n LEVels of the source directory tree.

/Z :: copy files in restartable mode.
/B :: copy files in Backup mode.
/ZB :: use restartable mode; if access denied use Backup mode.
/EFSRAW :: copy all encrypted files in EFS RAW mode.

/COPY:copyflag[s] :: what to COPY for files (default is /COPY:DAT).
(copyflags : D=Data, A=Attributes, T=Timestamps).
(S=Security=NTFS ACLs, O=Owner info, U=aUditing info).

/DCOPY:T :: COPY Directory Timestamps.

/SEC :: copy files with SECurity (equivalent to /COPY:DATS).
/COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU).
/NOCOPY :: COPY NO file info (useful with /PURGE).

/SECFIX :: FIX file SECurity on all files, even skipped files.
/TIMFIX :: FIX file TIMes on all files, even skipped files.

/PURGE :: delete dest files/dirs that no longer exist in source.
/MIR :: MIRror a directory tree (equivalent to /E plus /PURGE).

/MOV :: MOVe files (delete from source after copying).
/MOVE :: MOVE files AND dirs (delete from source after copying).

/A+:[RASHCNET] :: add the given Attributes to copied files.
/A-:[RASHCNET] :: remove the given Attributes from copied files.

/CREATE :: CREATE directory tree and zero-length files only.
/FAT :: create destination files using 8.3 FAT file names only.
/256 :: turn off very long path (> 256 characters) support.

/MON:n :: MONitor source; run again when more than n changes seen.
/MOT:m :: MOnitor source; run again in m minutes Time, if changed.

/RH:hhmm-hhmm :: Run Hours - times when new copies may be started.
/PF :: check run hours on a Per File (not per pass) basis.

/IPG:n :: Inter-Packet Gap (ms), to free bandwidth on slow lines.

/SL :: copy symbolic links versus the target.

/MT[:n] :: Do multi-threaded copies with n threads (default 8).
n must be at least 1 and not greater than 128.
This option is incompatible with the /IPG and /EFSRAW options.
Redirect output using /LOG option for better performance.

::
:: File Selection Options :
::
/A :: copy only files with the Archive attribute set.
/M :: copy only files with the Archive attribute and reset it.
/IA:[RASHCNETO] :: Include only files with any of the given Attributes set.
/XA:[RASHCNETO] :: eXclude files with any of the given Attributes set.

/XF file [file]... :: eXclude Files matching given names/paths/wildcards.
/XD dirs [dirs]... :: eXclude Directories matching given names/paths.

/XC :: eXclude Changed files.
/XN :: eXclude Newer files.
/XO :: eXclude Older files.
/XX :: eXclude eXtra files and directories.
/XL :: eXclude LONELY files and directories.
/IS :: Include Same files.
/IT :: Include Tweaked files.

/MAX:n :: MAXimum file size - exclude files bigger than n bytes.
/MIN:n :: MINimum file size - exclude files smaller than n bytes.

/MAXAGE:n :: MAXimum file AGE - exclude files older than n days/date.
/MINAGE:n :: MINimum file AGE - exclude files newer than n days/date.
/MAXLAD:n :: MAXimum Last Access Date - exclude files unused since n.
/MINLAD:n :: MINimum Last Access Date - exclude files used since n.
(If n < 1900 then n = n days, else n = YYYYMMDD date).

/XJ :: eXclude Junction points. (normally included by default).

/FFT :: assume FAT File Times (2-second granularity).
/DST :: compensate for one-hour DST time differences.

/XJD :: eXclude Junction points for Directories.
/XJF :: eXclude Junction points for Files.

::
:: Retry Options :
::
/R:n :: number of Retries on failed copies: default 1 million.
/W:n :: WAIT time between retries: default is 30 seconds.

/REG :: Save /R:n and /W:n in the Registry as default settings.

/TBD :: wait for sharenames To Be Defined (retry error 67).

::
:: Logging Options :
::
/L :: List only - don't copy, timestamp or delete any files.
/X :: report all eXtra files, not just those selected.
/V :: produce Verbose output, showing skipped files.
/TS :: include source file Time Stamps in the output.
/FP :: include Full Pathname of files in the output.
/BYTES :: Print sizes as bytes.

/NS :: No Size - don't log file sizes.
/NC :: No Class - don't log file classes.
/NFL :: No File List - don't log file names.
/NDL :: No Directory List - don't log directory names.

/NP :: No Progress - don't display percentage copied.
/ETA :: show Estimated Time of Arrival of copied files.

/LOG:file :: output status to LOG file (overwrite existing log).
/LOG+:file :: output status to LOG file (append to existing log).

/UNILOG:file :: output status to LOG file as UNICODE (overwrite existing log).
/UNILOG+:file :: output status to LOG file as UNICODE (append to existing log).

/TEE :: output to console window, as well as the log file.

/NJH :: No Job Header.
/NJS :: No Job Summary.

/UNICODE :: output status as UNICODE.

::
:: Job Options :
::
/JOB:jobname :: take parameters from the named JOB file.
/SAVE:jobname :: SAVE parameters to the named job file
/QUIT :: QUIT after processing command line (to view parameters).
/NOSD :: NO Source Directory is specified.
/NODD :: NO Destination Directory is specified.
/IF :: Include the following Files.Code: [Select]robocopy "c:\users\dave\application data\runic games" c:\games_backup /E /ISWas the fix for this issue I guess ... I guess farewell XCOPY with Windows 7 ... Now I have to use ROBOCOPY

Here is what robocopy spits out to SCREEN as it executed my batch:


Quote

C:\04_2011>robocopy "c:\users\dave\application data\runic games" c:\games_backup /E /IS

-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------

Started : Thu Apr 07 00:31:45 2011

Source : c:\users\dave\application data\runic games\
Dest : c:\games_backup\

Files : *.*

Options : *.* /S /E /COPY:DAT /IS /R:1000000 /W:30

------------------------------------------------------------------------------

1c:\users\dave\application data\runic games\
New File 335641pinglogger.txt
0%
39%
78%
100%
New Dir 9c:\users\dave\application data\runic games\torchlight\
New File 1324EditorSettings.dat
0%
100%
New File 7.7 mmassfile.dat
0.0%
6.4%
12.8%
19.3%
25.7%
32.2%
38.6%
45.1%
51.5%
57.9%
64.4%
70.8%
77.3%
83.7%
90.2%
96.6%
100%
New File 2.8 mmassfile.dat.ADM
0%
17%
35%
53%
70%
88%
100%
New File 10.2 mmasterresourceunits.dat
0.0%
9.7%
19.4%
29.2%
38.9%
48.7%
58.4%
68.2%
77.9%
87.7%
97.4%
100%
New File 2.8 mmasterresourceunits.dat.ADM
0%
17%
34%
52%
69%
86%
100%
New File 20834Ogre.log
0%
100%
New File 904resourceconfig.dat
0%
100%
New File 5060settings.txt
0%
100%
New File 5726settings_editor.txt
0%
100%
New Dir 57c:\users\dave\application data\runic games\torchlight\editorObj\
New File 5120Align.editorObj
0%
100%
New File 7680Animation Controller.editorObj
0%
100%
New File 8192Box Collision.editorObj
0%
100%
New File 8704Button.editorObj
0%
100%
New File 8704Camera Controller.editorObj
0%
100%
New File 7168Camera Shake.editorObj
0%
100%
New File 5120Cinematic.editorObj
0%
100%
New File 5120Color.editorObj
0%
100%
New File 6144Counter.editorObj
0%
100%
New File 13312Damage Shape.editorObj
0%
100%
New File 5632Dungeon Object.editorObj
0%
100%
New File 15360Emitter.editorObj
0%
100%
New File 6144Game State Controller.editorObj
0%
100%
New File 9728Generic Model.editorObj
0%
100%
New File 5632Geometry Rotator.editorObj
0%
100%
New File 4608Gravity Well.editorObj
0%
100%
New File 12288Group.editorObj
0%
100%
New File 7680Image.editorObj
0%
100%
New File 5120Jet.editorObj
0%
100%
New File 6656Layout Link Particle.editorObj
0%
100%
New File 7168Layout Link Timeline.editorObj
0%
100%
New File 6656Layout Link.editorObj
0%
100%
New File 6656Light.editorObj
0%
100%
New File 5632Line.editorObj
0%
100%
New File 6144Linear Force.editorObj
0%
100%
New File 3584Logic Group.editorObj
0%
100%
New File 15872Missile.editorObj
0%
100%
New File 4096Money Taker.editorObj
0%
100%
New File 15360Monster.editorObj
0%
100%
New File 5120Music.editorObj
0%
100%
New File 5120Output Incrementor.editorObj
0%
100%
New File 16384Particle.editorObj
0%
100%
New File 8704Pathing.editorObj
0%
100%
New File 7680Plane Collision.editorObj
0%
100%
New File 4608Player Box Trigger.editorObj
0%
100%
New File 4608Player Sphere Trigger.editorObj
0%
100%
New File 7168Property Node.editorObj
0%
100%
New File 4608Puzzle Input.editorObj
0%
100%
New File 7168Quest Controller.editorObj
0%
100%
New File 6656Random Choice.editorObj
0%
100%
New File 8704Room Piece.editorObj
0%
100%
New File 5632Scale.editorObj
0%
100%
New File 6656Sine Force.editorObj
0%
100%
New File 8192Skill Controller.editorObj
0%
100%
New File 4608Skip Cutscene.editorObj
0%
100%
New File 7168Sound.editorObj
0%
100%
New File 7680Sphere Collision.editorObj
0%
100%
New File 5120Teleport.editorObj
0%
100%
New File 5632Texture Animation.editorObj
0%
100%
New File 5632Texture Rotate.editorObj
0%
100%
New File 7680Timeline.editorObj
0%
100%
New File 5120Timer.editorObj
0%
100%
New File 15360Unit Spawner.editorObj
0%
100%
New File 8704Unit Trigger.editorObj
0%
100%
New File 5120Vortext.editorObj
0%
100%
New File 6656Warper.editorObj
0%
100%
New File 5120Waypoint Activator.editorObj
0%
100%
New Dir 3c:\users\dave\application data\runic games\torchlight\mods\
New File 380mods.dat
0%
100%
New File 364mods.dat.ADM
0%
100%
New File 260remove_binary.bat
0%
100%
New Dir 2c:\users\dave\application data\runic games\torchlight\mods\MyFirstMod\
New File 82mod.dat
0%
100%
New File 90mod.dat.adm
0%
100%
New Dir 0c:\users\dave\application data\runic games\torchlight\mods\MyFirstMod\media\
New Dir 5c:\users\dave\application data\runic games\torchlight\save\
New File 1961990.SVT
0%
66%
100%
New File 374901.svt
0%
100%
New File 1265452.svt
0%
100%
New File 196715backup.tmp
0%
66%
100%
New File 1385sharedstash.bin
0%
100%
New Dir 2c:\users\dave\application data\runic games\torchlight\torched\
New File 377132objects.dat
0%
34%
69%
100%
New File 139952objects.dat.ADM
0%
93%
100%
New Dir 1c:\users\dave\application data\runic games\torchlight\torched\dataeditor\
New File 3134EditorRules.dat
0%
100%
New Dir 2c:\users\dave\application data\runic games\torchlight\torched\dataeditor\editorfolder\
New File 0temp.layout
100%
New File 0temp.layout.cmp
100%

------------------------------------------------------------------------------

Total Copied Skipped Mismatch FAILED Extras
Dirs : 10 9 1 0 0 0
Files : 82 82 0 0 0 0
Bytes : 25.51 m 25.51 m 0 0 0 0
Times : 0:00:00 0:00:00 0:00:00 0:00:00


Speed : 107428116 Bytes/sec.
Speed : 6147.086 MegaBytes/min.

Ended : Thu Apr 07 00:31:45 2011
8765.

Solve : Send and recive SMS in Dos os?

Answer» HI
i want to send and recive sms in DOS os.
but i dont know how to do it.
pleas help me
You will need to write a program to do it, and in a language that can be executed in DOS like an old version of C++ pre dot.net for example. You also need to know how SMS works, protocol and all. SOMETHING like this would be quite the project for someone to take on, not just a small quick program one of us here would be ABLE to POST up here for free as open source. http://en.wikipedia.org/wiki/SMS
Hi Mr. Davelembke.
tanks for your answer.
i wrote a program with DELPHI that it work with GSM modem And cell phon.
you can download it from my web www.abshar-system.ir
but it is persion language.
i dont want to write a full software. i want writ a dll or small software that it can send SMS and USD and Recive them.
i cant use AT Command in DOS .
can you help me Pleas?Hi evryone.
no body can help me?
8766.

Solve : Batch Programming Book?

Answer»

Hi guys, well am asking if there is anyone knowing where i can get the best batch programming book
which can work with windows 7 dos system...cause i have downloaded other books but it seems
they have a certain gap in some codes like cd, edit and many OTHERS!!...so if anyone know any good batch programming
book 4 windows 7..!? please..!! Have you tried typing the command name followed by /? for example

cd /?

Also type

help (then press ENTER)

at the prompt

also... this is a good book to use (I have it myself)

http://www.amazon.com/Windows-Shell-Scripting-Timothy-Hill/dp/1578700477




Quote from: musamanyama on August 25, 2011, 06:00:45 PM

Hi guys, well am asking if there is anyone knowing where i can get the best batch programming book
which can work with windows 7 dos system...cause i have downloaded other books but it seems
they have a certain gap in some codes like cd, edit and many others!!...so if anyone know any good batch programming
book 4 windows 7..!? please..!!
Can i ask why are you learning batch? because i want to suggest to you to start with something better like vbscript or powershell (if you absolutely must work on Windows) or Python,Ruby,Perl (for cross platform system administration). Quote from: ghostdog74 on August 26, 2011, 11:45:12 PM
I want to suggest to you to start with something better like vbscript or powershell (if you absolutely must work on Windows) or Python,Ruby,Perl (for cross platform system administration).

These are wise words.
Quote from Raymond Chen's blog, The Old New Thing yesterday:

He offered a TIP for Windows users to count the lines in STDIN like wc -l in *nix (some-command-that-generates-output | find /c /v ""), and explained how it arose because of a bug in find.exe that had to remain (as a feature) because batch scripts had been written that took advantage of it. (Due to an integer underflow bug, a string of length zero was treated as if it were a string of length 65536, which doesn't match anywhere, thus the null string never matches, and its negation always matches)

Quote
(REMEMBER, I provide the occasional tip on batch file programming as a public service to those forced to endure it, not as an endorsement of batch file programming.)
well...thank u all for your great participation and the reason i want to study batch programming
isn't quite clear but honestly its just for fun! and sure i'll study all of the other languages
but just to start with batch programming cause i kinder love its scripts!!You go right ahead... have fun!
Salmon Trout and ghostdog74 i thank u alot!!..i have found the book u send me a link and yeah..thank u guys very much!! In case you didn't have this: Command-line reference A-Z
http://technet.microsoft.com/en-us/library/bb490890.aspx
8767.

Solve : Replacing long filenames with wildcards in Windows 7?

Answer»

Hi all, I'm trying to create a batch code to copy some information from one drive to another every time my PC starts up and I'm having trouble with the syntax.

The command I'm USING is

copy "\\server1\directory1\file*.*" "\\server2\Directory2 Long Filename\Directory3 Long Filename\*.*"---

I've tried various versions of this, including changing "Long Filename" to "longfi~1", using xcopy, changing capitalisation etc but all to no avail.

The error message I'm getting seems to be referring to the destination location, and says "The network name cannot be found".

Any help to automate this would be much appreciated, thanks.Try removing the "---" at the end of the target path.Sorry, that was my formatting error, I'd posted it elsewhere and was using that just to show it wasn't part of the main text. The "---" isn't in the command I'm trying to use.Just in case anybody is refraining from answering as they think this might be some sort of homework, I'd just like to state for the record that I'm thirty years old and trying to automate a backup task every morning when my PC switches on. I've used generic names as I don't think it would be good business practise to give out the names of my company's servers and file structure. :-)Aww c'mon...
Give us the FULL rundown... The copy command should work. Maybe you do not have access permissions on the server.I can copy it manually using the Windows interface, but not using DOS commands.

What's the correct way of dealing with long filenames, should I truncate them using a tilde, replace spaces with underscores, put everything in quotes or something else entirely?Are you running the copy command in an Administrator command prompt?Quote

The error message I'm getting seems to be referring to the destination location, and says "The network name cannot be found".

When using the universal naming convention (UNC) the format is \\server-name\shared-resource-pathname. Either Server2 is not correct, or 'Directory2 Long Filename' is not a shared resource. Note: you can also use ADMINISTRATIVE shares (format: drive$) in place of the shared-resource-pathname, but you must get the server name correct. Check to see if you're connected to the server and what resources are shared.

You notation with the quotes is correct, so you shouldn't need to use short names.

Hope this helps somewhat. Thanks for the CLARIFICATION, I went back and had a look at from a DIFFERENT angle and I'd been a muppet and missed out part of the destination path.

Thanks all for your help!
8768.

Solve : Moving a file in dos?

Answer»

Can someone help me out on this I know I missing something. I WANT to move a file "l.jpg" on my DESKTOP to a folder "TEST" on my desktop. this is the output of my request.

C:\Documents and Settings\dlam\Desktop>copy l.jpg \TEST
Overwrite \TEST? (Yes/No/All): y
1 file(s) copied.

The problem is that even THOUGH it said it copied the file to the TEST directory no file was actually copied to it. bizzare, EH? Any suggestions would be greatly appreciated. it will have copied the file to the directory TEST under the root of the drive, use this
Code: [Select]copy l.jpg TEST

and do you want to copy or move ?The command is:
Code: [Select]move (source file) (destination file)Example:
Code: [Select]move C:\Documents\Picture.jpg C:\Temp\Picture.jpg
Try that...It might be better to write out the fully qualified names of the source and destination directories. This should reduce chances for error.

Code: [Select]copy "C:\Documents and Settings\dlam\Desktop\l.jpg" "C:\Documents and Settings\dlam\Desktop\Test"

Your code uses relative paths and forces the user to be signed on to his/her desktop folder. The fully qualified names (above) eliminates that requirement.



Your post is ambiguous. You mention to move the file but your sample code shows copy.

PS. Your code would have WORKED had you left out the leading SLASH before TEST.

8769.

Solve : Command line to create a folder with the name of a file?

Answer»

Friends, friends... I don't know if it is possible. But it will be of great help.

I have some some folders, subfolders and a zip file in each subfolder. SOMETHING like -

Main - Sub 1 - 1.zip
Main - Sub 2 - 2.zip
Main - Sub 2 - subsub 2 - 2.1.zip

The naming conventions just random. I need to create a batch file to create folders inside all the folders that have a zip file in it. The newly created folder must bear the NAME of the zip file, without the extension.zip. The batch should then move all the zip files to the RESPECTIVE newly created folders.

If the above case is considered, I need the FOLLOWING result after running the batch:

Main - Sub 1 - 1 - 1.zip
Main - Sub 2 - 2 - 2.zip
Main - Sub 2 - subsub 2 - 2.1 - 2.1.zip

Any help please... This will save a lot of my time. And will ignite new ideas. ;-) Thank u all in advance.

Code: [Select]@echo off
for /f "delims=" %%a in ('dir /s /b "C:\Test\Main\*.zip"') do (
MD "%%~dpa%%~na"
move "%%a" "%%~dpa%%~na\"
)

8770.

Solve : need to automate sqlldr call?

Answer»

hi dear friends,
I am brand new to MSDOS and i found that this PLACE is the best place to post ONES query to get quick and optimal suggestions. so here it goes.. thanks all in advance
i have 70 TABLES in oracle and my system is windows XP. unfortunately we have no access to unix.
i need to run sqlldr at the command prompt to load all the 70 tables.
Is there any way i can possibly automate this?
my requirement is that i should not write the sqlldr command manually every time [70 times can u blv it?? phew! ]
can we call a file containing all these commands or something?
Awaiting your response.. thanks a lotI am rusty with the commands necessary to show you exactly by example, but I have written batch files to process MYSQL instructions. You will have to create a single batch file with each command line in it of the 70 tables. Then you can either LAUNCH it from say your XP computer manually, or if its a daily process such as to clear tables for new data to be populated in them such as a P.O.S system etc, you can add the batch file to scheduled task of Windows XP Pro and have it trigger as needed in a manner that is almost set it and forget it.

8771.

Solve : Moving many files in many folders to a single folder?

Answer»

Without buying a utility program I need to move many files in many folders to a single folder. I think there is a ms command but am not sure about the exact syntax. Can someone format the command line for me where I can simply insert the directory information? I would also like to retain the original file dates. I am using XP. Thanks in advance and am sorry for not being very pc LITERATE. Quote from: Bluescoot on April 07, 2011, 08:25:21 AM

Without buying a utility program I need to move many files in many folders to a single folder. I think there is a ms command but am not sure about the exact syntax. Can someone format the command line for me where I can simply insert the directory information? I would also like to retain the original file dates. I am using XP. Thanks in advance and am sorry for not being very pc literate.

copy /?
move /?
xcopy /?

Something like this might help...

Code: [Select]@echo off
set /p mainfolder=What is the main folder?
echo Type all the other folders, pressing enter after each one. Type exit to stop.
:again
set /p otherfolder=Other folders?
if %otherfolder%==exit goto :eof
xcopy %otherfolder%\*.* %mainfolder%
goto again
I got some help on the copy command. Still UNSURE of my syntax. Can anyone review my attempt below ?

I am attempting to copy all my mp3 files on my hard drive E:/Allmusic/ multiple folders

To E:/all music/new files

Will this consolidate all the files to one folder?

If successful I'll go back and delete the old directories and files.



COPY [/-Y] [/E:/all music/[+ ...]][[/E:/all music/new all files/[+ ...]]Quote
I need to move many files in many folders to a single folder.
Wrong!
The question is wrong. There is not provision for such a thing. You need too restates the question.
Files could be reamed and moved, but you question did not allow for that.
Before getting the right answer, you haven to ask a question that conforms to the structure of the files system.

Consider: If a files system required all files to have an unique identifier, there would be few reasons to have folders. In fact, there are such files systems. However, the path is, effectively, part of the unique ID of any file in Windows. (And also and many other OS.)
The question suggests muddled thinking or lack of insight.

Otherwise, if the OP can state a clear objective as to why many files need to appear visible as if they all were part of one group, clas, FAMILY, collection or genure, then a clear precise answer can be provided.

Or, to put it another way, Imagine you went into n bookstore and all the books have the save name. Is that within reason?

Quote
Student: I want the book 'war and Peace.'
Librarian. Which War and Peace?
Student: No, not any book about war and peace, just the book with the TITLE.
Librarian: We have 743 books with the exact title, every one has different content.
Student: Why did you do that.
Librarian: Saves shelf space. So says our computer whiz.
Student: That is crazy, Who told you to do such a stupid thing.
Librarian: Bill Gates.
8772.

Solve : Batch files: Usable only on a certain date??

Answer»

I don't know if it's even possible, but I desperately need to know how to make a batch file with text that you can see only once it is a certain day, like making it not work until April 8th or something.Please POST the format of your local DATE variable that you see when you OPEN a command prompt and type ECHO %DATE% and press ENTER.



Quote from: Mechanic on April 09, 2011, 01:58:08 PM

C:\>echo %date%
Sat 04/09/2011

C:\>

Code: [Select]@echo off
if "%date%"=="SUN 04/10/2011" (
echo You will only see this on Sunday 10th April 2011
)
8773.

Solve : Disk Boot Failure?

Answer»

I have a HP Desktop when turning power on it reads "Disk Boot Failure"

It has Windows Vista loaded on it.

It has the following DVD Drive Writer Model TS-H653.

What originally happened was the DVD/CD Drive was open, I had to quickly leave (I am a firefighter) and I hit the drive that was sticking out and bent it. I THOUGHT I had it fixed but when I turned it BACK on it said "Disk Boot Failure" .I tested it and it says No Drives Detected.

Any suggestions on what might be wrong. Should I try replacing the entire DVD/CD Drive or would this problem be with something else. I checked everything I could think of as far as INTERNAL connections. Am I missing something?

Sorry, I am far from a computer genius. Just trying to figure it out.

Thanks, DarrenYou could have damaged the DVD writer internally so it is somehow affecting the disk CONTROLLER on the MOTHERBOARD. You could try disconnecting it completely and see what happens. The disk boot failure might be a coincidence.

8774.

Solve : how to stop a command being run in a seperate dos window.?

Answer»

Good day everyone. Haven't been on here in AGES. i stopped making bat files but now
i'm making one to run a series of commands. now i've figured out how to run a command
and the bat file stops till the previous command is finished. Now my problem is when
i run defrag it opens another dos WINDOW to run it. I want it all in the same dos window,
reason being i want to see how it went etc. What i have so far is

Code: [Select]@echo off
start /wait blahblah
start /wait blahblah
start /wait defrag c:
defrag d:
pause

now defrag c runs in another dos window but defrag d will run in same window. How do
i GET defrag c to run in the same dos window?

Thanx in advance for the helpIf you are doing this,

Code: [Select]start /wait defrag c:
defrag d:
and you want defrag c: and defrag d: to appear in the same window...

Why don't you do this?

Code: [Select]defrag c:
defrag d:


because i want it to run c first, then when that's finished i want it to run d if there is a d drive. If there's not im sure it'll give an error.oh i see it worked, THANKS alot.

8775.

Solve : Need ErrorLevel/Exit Code Help.?

Answer»

Hi, I'm trying to create a batch file that will stop the xcopy and delete batch process and return an Error statement, in the event that there is not enough space on my destination drive or no files to copy or a physical disk error, etc ... or returns a successful copy message if there were no errors. This is what I have so far:

=========================

@echo off
set INPUT=
set /p INPUT= Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:
md h:\archive\graphics\%INPUT%

xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y/exclude:i:\ErrorMssg\omit.txt

if errorlevel 5 goto diskerror
if errorlevel 4 goto copyerror
if errorlevel 2 goto copyterminated
if errorlevel 1 goto nofiles
if errorlevel 0 goto success

:diskerror
xcopy i:\ErrorMssg\DiskError.rtf h:\archive\graphics\%INPUT%
echo A DISK WRITE ERROR OCCURRED! STOPPING Backup Procedure.
pause
goto end

:copyerror
xcopy i:\ErrorMssg\CopyError.rtf h:\archive\graphics\%INPUT%
echo The Archive Drive is FULL! STOPPING Backup Procedure.
pause
goto end

:copyterminated
echo Ctrl + C was pressed, Terminating the Archive Procedure.
pause
goto end

:nofiles
echo There were NO FILES to Archive.
pausse
goto end

:success
echo y | rd /s/q i:\DailyWork
echo y | del i:\Clients.xls
echo The backup was successful.
pause
goto end

:end
exit

=========================

I think that the problem lies with the ErrorLevel, which for some reason is not being recognized and subsequently the GOTO statements are not working correctly. So, for example, when I run a test where there is nothing but the ERRORMSSG folder on the i:/ drive (which is excluded in the copy process), the batch file in it's current incarnation should encounter an ErrorLevel of 1, as there are no files to copy over, resulting in the statement "There were NO FILES to Archive." showing up in the batch window on-screen. However, instead what one sees on the screen in the batch pop-up window is the following, when one runs the batch:

---------------------
Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:
20082011
0 file(s) copied
The system cannot find the file specified.
Could not find i:\Clients.xls
The backup was successful.
Press any key to continue ...
---------------------

The batch does create the new folder, in this example titled 20082011, and only states that it cannot find the file "Clients.xls", as opposed to not finding both the "Clients.xls" file and "DailyWork" folder. Then, rather than returning the statement "There were NO FILES to Archive." from :nofiles as the batch should, instead it returns the statement "The backup was successful." from :success, which is incorrect.

According to what I've read, the ErrorLevel statements need to be in descending order 5, 4, 2, 1, 0 (as opposed to ascending order) for it to work properly. Also, that the Exit Code definitions are as follows:

5 - Disk write error occurred.
4 - Various errors including insufficient memory or disk space, an invalid drive name, or invalid syntax.
2 - The user pressed Ctrl+C to terminate xcopy.
1 - No files were found to copy.
0 - Files were copied without error.

I've tried variations with the Comparison Operators; for example both == and EQU in the IF statement, but it doesn't make any difference. I've also tried both both using and not using a preceeding colon in the GOTO statement:

"if errorlevel 5 goto :diskerror" and if "errorlevel 5 goto diskerror"

as I've SEEN both ways used in tutorial examples, but my batch still doesn't work correctly.

I am at a total loss as to how to proceed. It's so frustrating.

I would greatly appreciate any help in correcting my coding syntax for this batch file. Thanks so much!

~ SallyWhat happens if you use the Windows 2000 (and later) errorlevel syntax?

Place this line immediately after the xcopy line

echo XCOPY returned this code: %errorlevel%

Hi, thanks for your reply.

I am testing the batch with no files to copy ... The following shows up is the batch pop-up window:

--------------------------

Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:
20082011
0 file(s) copied
XCopy returned this code: 0
The system cannot find the file specified.
Could not find i:\Clients.xls
The backup was successful.
Press any key to continue ...

--------------------------

The batch did create the new folder, in this example titled 20082011, and only stated that it couldn't find the file "Clients.xls", as opposed to not finding both the "Clients.xls" file and "DailyWork" folder. Then, rather than returning the statement "There were NO FILES to Archive." from :nofiles as the batch should, instead it returned the statement "The backup was successful." from :success. For some strange reason, the error code showing in the new line I inserted after the xcopy line is "0", rather than what I assume should be "1", as there were no files to copy in this test. Should the IF statements go before the xcopy line, or do I have some other coding error?

~ SallyI had the same problem when testing. Zero files copied produced a zero errorlevel, not one. In fact the only other errorlevel I could reproduce was four.

Try putting the xcopy in a for statement. You can then scrape the console and check to see how many files were copied:

Code: [Select]@echo off
set INPUT=
set /p INPUT= Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:
md h:\archive\graphics\%INPUT%

for /f %%i in ('xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y/exclude:i:\ErrorMssg\omit.txt') do (
if errorlevel 5 goto diskerror
if errorlevel 4 goto copyerror
if errorlevel 2 goto copyterminated
if %%i EQU 0 goto nofiles
if errorlevel 0 goto success
)

Good luck. Wow, thanks! That did the trick to fix the 'no files to copy' part of the batch. I then tested the situation where there was enough space on the destination drive for the files being copied over, and it worked like a charm -- creating the new folder, copying over the file and folder from i:\ to h:\, then deleting the deleting the DailyWork folder and Clients.xls on the i:\ drive, and showing the statement "The backup was successful." in the batch's pop-up window.

Unfortunately, when I next tested the situation where there wasn't enough disk space on the destination drive (which should be Error 4), the batch stalled on-screen:

----------------------------

Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:
21082011
_ (with this cursor blinking)

----------------------------

The did create the new folder (in this case, named "21082011) was created, and copy over the Clients.xls file to this folder, as well as copied over the DailyWork folder, which contains the Aer-Dgm.gif and NG.jpg files. The Aquatics-logo.cdr file was not copied over, of course, as it has a larger file size that the space left on the destinatin folder, but at this point the batch should have jumped to the :copyerror section, and next copied over the 1KB .RTF file (which has a single line of text stating that nothing copied over because the drive was full), and then showed in the batch's pop-up window the statement "The Archive Drive is FULL! STOPPING Backup Procedure."

My next thought was that the .RTF file might be the issue, so I deleted the line in the :copyerror section ...

xcopy i:\ErrorMssg\CopyError.rtf h:\archive\graphics\%INPUT%

... to see WHETHER that made any difference when I tested the batch again, but it didn't; the batch still stalled with the aforementioned information showing on the batch's pop-up window:

----------------------------

Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:
21082011
_ (with this cursor blinking)

----------------------------

So, next I went to my backup batch, with the previous code + the line you offered to follow the xcopy line in order to have the ErrorLevel displayed.

------------------------------------
xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y/exclude:i:\ErrorMssg\omit.txt
echo XCOPY returned this code: %errorlevel%

if errorlevel 5 goto diskerror
if errorlevel 4 goto copyerror
if errorlevel 2 goto copyterminated
if errorlevel 1 goto nofiles
if errorlevel 0 goto success
------------------------------------

The result was that the batch ran to the point of creating the new folder and copying over the first three files, but when it got to the fourth file (again, which exceeded the capacity of space left on the destination drive), instead of going to the :copyerror section and copying over the 1KB .RTF file and having the statement "The Archive Drive is FULL! STOPPING Backup Procedure." show on the batch's pop-up window, it executed the following:

----------------------------

Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:
21082011

I:\Clients.xls
I:\Archive\Aer.Dgm.gif
I:\Archive\NG.jpg
I:\Archive\Aquatics-logo.cdr

Insufficient disk space on current disk.
Insert another disk and type to continue...

----------------------------

Am I referencing the wrong ErrorLevel (i.e., "4") for the Insufficient Memory Line (i.e., :copyerror)? This is so confusing.

~ SallyTesting turned up some interesting results:

1. If the XCOPY is embedded in a FOR loop, the errorlevel is always zero but you can scrape the console for data.

2. If the XCOPY is not embedded in a FOR loop, the errorlevel works as advertised, except the no files and success CONDITIONS both set errorlevel to zero.

This workaround takes a little from each situation. Not pretty but not Coyote Ugly either:

Code: [Select]@echo off
set INPUT=
set /p INPUT= Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:
md h:\archive\graphics\%INPUT%

xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y/exclude:i:\ErrorMssg\omit.txt > %temp%\results.txt

if errorlevel 5 goto diskerror
if errorlevel 4 goto copyerror
if errorlevel 2 goto copyterminated
if exist %temp%\results.txt (
find /i "0 File(s)" %temp%\results.txt > nul
if errorlevel 1 (goto success) else (goto nofiles)
)

If the XCOPY command issues any prompts or messages, they go the the results file and won't be seen by the user.

Hope this helps
Quote from: Sidewinder on August 22, 2011, 06:12:42 PM

1. If the XCOPY is embedded in a FOR loop, the errorlevel is always zero but you can scrape the console for data.

What about using delayed expansion and checking !errorlevel! ?



Quote from: Salmon Trout on August 23, 2011, 12:02:13 AM
What about using delayed expansion and checking !errorlevel! ?

Been there, done that.

Same results. See my previous post. Don't always succeed but try very hard to post only code that works. Anything else is left on the cutting room floor.

The exclude file might create a problem with the VBScript CopyFolder method, but using Powershell to pipeline output from get-childitem into copy-item might work, depending on the actual exclude list.Thanks so much for your ongoing help!

Again, unfortunately, the :nofiles and :success sections are working, but the batch still stalls when there isn't enough disk space on the destination drive (which should be Error 4, right?). This is what shows up in the batch's pop-up window:

----------------------------

Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:
22082011
_ (with this cursor blinking)

----------------------------

The batch does create the new folder (in this case, named "22082011), and copies over all the files that can fit onto the space left on the destination drive, but it doesn't then jump to the :copyerror section, and next copied over the 1KB .RTF file (which has a single line of text stating that nothing copied over because the drive was full), and then show in the batch's pop-up window the statement "The Archive Drive is FULL! STOPPING Backup Procedure."

I again, tried deleting the .RTF file xcopy line in the :copyerror section, in the event that it might be the issue ...

xcopy i:\ErrorMssg\CopyError.rtf h:\archive\graphics\%INPUT%

... but when I tested the batch again, it didn't make any difference; the batch still stalled with the aforementioned information showing on the batch's pop-up window:

----------------------------

Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:
21082011
_ (with this cursor blinking)

----------------------------

... even though the batch did create the new folder and copied over all the files that can fit onto the space left on the destination drive.

If the exclude file switch in the line:

xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y/exclude:i:\ErrorMssg\omit.txt

I can always get rid of it --

xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y

-- and have the .RTF error messages in the :diskerror and :diskcopy sections be copied from a folder on the destination h:\ drive, rather than the i:\ drive. like so:

:diskerror
xcopy h:\ErrorMssg\DiskError.rtf h:\archive\graphics\%INPUT%
...

:copyerror
xcopy h:\ErrorMssg\CopyError.rtf h:\archive\graphics\%INPUT%
...

Or even eliminate those lines entirely; I just thought having a file stating that there was a problem with the copy process placed into the destination folder might be a good idea for purposes of record-keeping and archive integrity, but it doesn't need to be done, if it's causing problems with the execution of the batch file.

~ Sally

Quote
Again, unfortunately, the :nofiles and :success sections are working, but the batch still stalls when there isn't enough disk space on the destination drive (which should be Error 4, right?). This is what shows up in the batch's pop-up window:

You can see for yourself what the actual errorlevel is by echoing it to the screen:

Code: [Select]@echo off
set INPUT=
set /p INPUT= Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:
md h:\archive\graphics\%INPUT%

xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y/exclude:i:\ErrorMssg\omit.txt > %temp%\results.txt

echo %errorelevel%

if errorlevel 5 goto diskerror
if errorlevel 4 goto copyerror
if errorlevel 2 goto copyterminated
if exist %temp%\results.txt (
find /i "0 File(s)" %temp%\results.txt > nul
if errorlevel 1 (goto success) else (goto nofiles)
)

Also try leaving @echo on as the first line. The output may look messy but you'll get a good indication of how the batch file is executing.

Code: [Select]The batch does create the new folder (in this case, named "22082011)

Not related to XCOPY, there is a MD instruction to specifically create it.

I guess what I'm not understanding why on errorlevel 4. you're copying a rtf file to a full disk and then knowing it will fail, echoing a message "The Archive Drive is FULL! STOPPING Backup Procedure.". XCOPY issues it's own messages based on the situation. Example: Errorlevel 4 also issues "Invalid drive specification" when the drive spec on the source or target paths is invalid.

Perhaps you could check for errorlevel 1, which includes all errorlevels greater or equal to one and leave the default code (errorlevel 0) to distinguish between zero records copied and more than zero records copied.



I checked my old DOS-5 manual and the XCOPY error codes have not changed in decades. It was my idea to have the .RTF file copied into the daily archive, in the event of some sort of copy error, since I am finding myself in the office less and less at the end of the day, and this task then falls to the office manager (who is the son of the boss, and is not detail-oriented, to say the least) or the OM's secretary/girlfriend (who is about as competent as Capt. Hazelwood on the Exxon Valdez) ... the problem being, that neither one writes down writes down error messages that might come up on their screens for anything they're doing, with any kind with any program, in any situation, which would then result in someone having to track down what had occurred, what caused the problem and how it could be fixed (if at all). I figured that with the .RTF file, we would at least have an explicit method with the daily archiving process of determining what error might have occurred, should there be any errors.

It was also my idea in the first place to be using the batch file for the archiving, since prior to that, I had simply been doing the process manually, using copy/paste in Windows Explorer at the end of the day. But as this little start-up began to grow, and I began to be out of the office more and more, meeting with existing and new potential clients, the archiving task was then PASSED on to the OM and his Sec (much to their unhappiness), and there were a couple instances where they were placing the archived files in the wrong place or completely overwriting files, and it all turned into an incredible headache. So, I volunteered to come up with this automated batch process (with albeit very limited coding ability), in order to solve our daily archiving issue. It was only when our archive drive got filled up that I realized that I needed to have a batch that was much more sophisticated and specific than what I had initially created, and that I was (quite frankly) in over my head with what we needed the batch to accomplish.

I tried adding in, after the xcopy line -- echo %errorelevel% -- but the batch didn't show any error codes and stalled onscreen at:

----------------------------

Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:
21082011
_ (with this cursor blinking)

----------------------------

Though the batch did create the new folder and copied over those files that would fit onto the space left on the destination (i.e., archive) drive.

I also changed the first line to @echo on, but I didn't see any error codes, nor anything specific that would indicate where the problem was occurring. When I looked at the Results.txt file that was created in my Temp file, it also didn't show anything specific as to what might be causing the problem:

-----------------------------

I:\Clients.xls
I:\archive\graphics\Aer-Dgm.GIF
I:\archive\graphics\NG.jpg
I:\archive\graphics\Aquatics-logo.cdr {this is the file that is larger than the space left on the destination drive for the :copyerror test}

Insufficient disk space on current disk.
Insert another disk and type to continue...

----------------------------

When you say:

"Perhaps you could check for errorlevel 1, which includes all errorlevels greater or equal to one and leave the default code (errorlevel 0) to distinguish between zero records copied and more than zero records copied."

Do you mean changing the code to look like this?:

-----------------------------------
@echo off
set INPUT=
set /p INPUT= Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:
md h:\archive\graphics\%INPUT%

xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y/exclude:i:\ErrorMssg\omit.txt > %temp%\results.txt

echo %errorelevel%

if exist %temp%\results.txt (
find /i "0 File(s)" %temp%\results.txt > nul
if errorlevel 1 (goto success) else (goto nofiles)
)
-----------------------------------

Thus getting rid of errorlevel 5, 4, & 2? I guess that would work, except in the instance where there is a limited amount of space left on the archive drive, and during the archiving process only a limited number of files would get copied over; enough to fill up the remaining space, leaving the rest un-archived. But we need everything archived each day, and I can't count on the OM or Sec to be observant enough to notice that the archive drive is full, without a notice to that effect popping up on the screen. So, I guess I'm really at a quandry as to what to do.

~ SallyI was thinking more along these lines:

Code: [Select]@echo off
set INPUT=
set /p INPUT= Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:

xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y/exclude:i:\ErrorMssg\omit.txt 1>%temp%\results.txt 2>%temp%\results.log

if errorlevel 1 goto :eof

if exist %temp%\results.txt (
find /i "0 File(s)" %temp%\results.txt > nul
if errorlevel 1 (goto success) else (goto nofiles)
)

The first if errorlevel checks results from XCOPY; the second from the FIND command.

results.log will contain any error messages issued by XCOPY
results.txt will contain a log of the file copies along with the total number of files processed

The two results files get overwritten each time the file is run. You can append each days output to the results files by using >> instead of > You can also change the paths of the results files. I chose %temp% hoping everyone has one. This should allow you to check the logs when convenient and not rely on someone else.

Good luck. Correction to above post. Better to use findstr instead of find. A regular expression can better distinguish between an actual zero count and a count that ends in zero (10, 20, 100, 150 etc)

Code: [Select]@echo off
set INPUT=
set /p INPUT= Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:

xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y/exclude:i:\ErrorMssg\omit.txt 1>%temp%\results.txt 2>%temp%\results.log

if errorlevel 1 goto :eof

if exist %temp%\results.txt (
findstr /i /r "^0 files(0)" results.txt > nul
if errorlevel 1 (goto success) else (goto nofiles)
)

8776.

Solve : Simple bat not working. Need some hints...?

Answer»

My ISP queues mail while my SMTP server is unavailable and unfortunately also sometimes queues it even while the SMTP server IS available. So, in order to dequeue the mail I run a finger command in a command window by typing: Code: [Select]finger [emailprotected]
This runs properly and returns the number of emails waiting to be dequeued and then returns to the command prompt once the QUEUE has been emptied. Now I don't want to have to keep doing doing this so I thought I could just enter that line into a bat file and SCHEDULE it to run every hour. However when I do that and run it, the command window opens and the command is run very quickly over and over again until I close the window.

How should the bat file be written to just run the command once (properly) then EXIT?Did you put this in a BAT file?
Please include the full contents of the BAT.
Hi Geek-9pm

I simply put that line into a text file and saved it with a .bat extension. (I also tried with a .cmd extension with the same results). I also tried it with pause after the line but that didn't do anything either.

BAT file content:

finger [emailprotected]


Thanks

A
Try replacing that FINGER with PINGQuote

However when I do that and run it, the command window opens and the command is run very quickly over and over again until I close the window.

How should the bat file be written to just run the command once (properly) then exit?

You problem can be recreated if the batch file is named finger and you're logged into the same directory where finger.bat lives. If that is the case, simply RENAME your batch file.

Just a thought. Sidewinder, that's brilliant! Your are a genius!
I could not duplicate what he did. That explains it!
The command interpreter always LOOKS in the current directory for a fie before looking into the PATH. That also explains why it was so quick. Finger can take a few seconds. But the command interpreter did do invoke the real finger executable, instead recursively called the bat file name 'finger'.

Kind of like taking two mirrors and looking at your face...face...face...face...face.....I concur - sidewinder is indeed a genius. The file was in fact named Finger.bat (Doh!) so I renamed it to dequeue.bat and it works perfectly now. Thanks to Sidewinder and all those who PM'd me with suggestions.
8777.

Solve : Old computer boot up problem?

Answer»

A COUPLE of months ago I found a computer in the basement at work. The company was doing housekeeping and wanted to throw it out. I asked them if I could use it instead of throwing it out and they snickered because it was so old. Well I fired it up and it booted! It had DOS 5.0 on it and I had the perfect program for it to use at work. We needed a LABELING program to print out wire labels. I still had an old DOS label program on a floppy disk from the previous company I had worked for so I loaded it on the C drive. I wrote a batch file and the program loaded right up when I fired up the computer. We got super busy at work so the I sat the computer in the corner of shop as I was waiting for things to slow down a bit and I still needed a parallel printer cable to try it out. Fast forward a couple of months. When I boot up the computer now, I get three errors and no operating system. The errors are "bad or missing c:\dos\ansi.sys", "error in config.sys LINE 4", and "INCORRECT DOS version". I downloaded a DOS 5.0 bootable floppy disk from the internet that works fine on my home computer but says "non bootable disk" on the computer at work. I don't know if anyone on another shift messed with the computer or a least they won't fess up to it, but I am stuck.
Heck, these old computers are fun to play with in my SPARE time.
Any help would be appreciated.
Thanks,
JimDisk boot failure

8778.

Solve : how to open a folder?

Answer» HI,
is there a command to open a DIR in dos? for example, if i want to open the FOLDER fonts in dir c:/fonts
i MEAN, to open it like double clicking.
thanks.start "" "DIRECTORY name"

thanks
8779.

Solve : Bucles for batch?

Answer»

I have this bat file :


REM Archivo "diario_paralelo.bat"
REM Este archivo ejecuta en serie las desfragmentaciones de todas las unidades de todos los discos.
REM <--- Cambiar por la unidad donde este instalado MyDefrag. en la línea de abajo.
Y:
CD \
REM <--- Cambiar por la carpeta donde este instalado MyDefrag.
REM No recuerdo cómo se ponía un comentario de un bat en una misma línea de comando.....
CD "\PORTABLES\Utilidades Sistema\MyDefrag"
start "" echo off
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v C:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v D:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v F:
rem MYDEFRAG.EXE -r OptimizeDaily.MyD -v H:
rem MYDEFRAG.EXE -r OptimizeDaily.MyD -v I:
rem MYDEFRAG.EXE -r OptimizeDaily.MyD -v K:
rem MYDEFRAG.EXE -r OptimizeDaily.MyD -v M:
rem MYDEFRAG.EXE -r OptimizeDaily.MyD -v N:
rem MYDEFRAG.EXE -r OptimizeDaily.MyD -v O:
rem MYDEFRAG.EXE -r OptimizeDaily.MyD -v T:
rem MYDEFRAG.EXE -r OptimizeDaily.MyD -v X:
rem MYDEFRAG.EXE -r OptimizeDaily.MyD -v Y:
pause "me quedo viendo lo sucedido"


I have four physical HARD drives.
In the bat above the target is optimize with the program mydefrag.
I have many partitions and DEFRAGMENT by night
But If i do sequentally I need all the day to defragment.
So I have to execute several instances of mydefrag to get result on my working time breaking coffee.
So

Disk 0 have partitions O: and X: .
Disk 1 have partitions C: , D: , F: , H: , I: , K: , M: , N:
Disk 2 T:
Disk 3 Y:


What I would like to do is defragment at the same time O: , C: , T: and Y: .
When O: finished continue with X:
When C: finished continue with the second partition on the disk 1 and then third, sequantially.

What can i do to adapt the script ?

Best Regards

From CANARY Islands
REM Archivo "daily defragmentation of all my partitions.bat"
Y:
CD \
CD "\PORTABLES\Utilidades Sistema\MyDefrag"
start "" echo off
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v C:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v D:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v F:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v H:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v I:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v K:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v M:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v N:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v O:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v T:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v X:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v Y:
pause "to see what is happening"


With the command START all defragmentations begin at the same time.
But I need to re-group in four categories. I have four hard disk physical.


Something like this

REM Archivo "daily defragmentation of all my partitions.bat"
Y:
CD \
CD "\PORTABLES\Utilidades Sistema\MyDefrag"
start "" echo off

rem first group or disk . I need first defragment O: and then X: . Not at the same time.
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v O:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v X:


rem second group or disk. I need first defragment C: and then D: , etc . Not at the same time. When finish one continues with the next.
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v C:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v D:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v F:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v H:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v I:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v K:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v M:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v N:

rem third group or disk
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v T:


rem fourth group or disk
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v Y:

Quote from: Señor Don Esgrimidor

Not at the same time. When finish one continues with the next.

START /WAIT BLA bla blaBut I need two groups
How can I reference ?

Quote from: Esgrimidor on April 09, 2011, 01:42:25 PM
But I need two groups
How can I reference ?

2 batch files maybe...

start "" "cmd /c batch1.bat"
start "" "cmd /c batch2.bat"

These will start togther but the commands in each one can run sequentially


I'll try and comment. It's a good idea !!!!!!!!!!!!!!!!11

I have put FINALLY this :

REM Autor Miguel Mollejo
REM Archivo "diario_paralelo.bat"
REM Este archivo ejecuta en serie las desfragmentaciones de todas las unidades de todos los discos.
REM <--- Cambiar por la unidad donde este instalado MyDefrag. en la línea de abajo.
Y:
CD \
REM <--- Cambiar por la carpeta donde este instalado MyDefrag.
REM No recuerdo cómo se ponía un comentario de un bat en una misma línea de comando.....
CD "\PORTABLES\Utilidades Sistema\MyDefrag"
start "" echo off
rem no ejecuto la línea de abajo porque observo que no hace nada. Y añado al final del script la ejecución secuencial primeramente aportada por Miguel
rem start "" "cmd /c batch1.bat"
rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v C:
rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v D:
rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v F:
rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v H:
rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v I:
rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v K:
rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v M:
rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v N:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v O:
rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v T:
rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v X:
start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v Y:
MYDEFRAG.EXE -r OptimizeDaily.MyD -v C:
MYDEFRAG.EXE -r OptimizeDaily.MyD -v D:
MYDEFRAG.EXE -r OptimizeDaily.MyD -v F:
MYDEFRAG.EXE -r OptimizeDaily.MyD -v H:
MYDEFRAG.EXE -r OptimizeDaily.MyD -v I:
MYDEFRAG.EXE -r OptimizeDaily.MyD -v K:
MYDEFRAG.EXE -r OptimizeDaily.MyD -v M:
MYDEFRAG.EXE -r OptimizeDaily.MyD -v N:
pause "me quedo viendo lo sucedido"


Best Regards
Thank for everything.

I'll try better next time
8780.

Solve : turn off windows automatic updates with batch?

Answer»

or use a wsus server that handles the deployment of security patches and the like. With wsus you can set the schedule of windows update and also control the patches that are displayed when new UPDATES are ready. This means the yellow shield that notifies you have updates only will display the updates APPROVED by the wsus admin. You can also set up different groups such as SERVERS, desktops, laptops, ext.

please see link for more INFO.
"http://technet.microsoft.com/en-us/wsus/default.aspx"
The ISSUE was fixed with manual work but the idea was to create a batch that would query the machine

if automatic updates = true then
net stop "automatic updates"

which would then be pushed to run on all servers

8781.

Solve : bat file to copy to an open folder?

Answer»

Hi,

I'm a complete beginner at bat files, I've tried searching but don't really KNOW how to word it correctly to get an accurate search result.

Here's what I'd like to do:-

Create a bat file that when Double clicked will copy a FOLDER and all its files and sub-folders to a new folder. The source folder will always have the same path, but the destination will be a different one every time. Is there a way to, for example, copy the bat file in (windows) to the destination folder, then double clicking it will result in copying from the source folder to the folder that I've just copied the bat file into?

Hope I've explained it OK
Would be grateful for any help, thanks.
MMM...aaaa. YES!
If the source folder is always the same.
and
you create a new folder
and
your put just the BAT into the folder
and
you CD to that new folder
and
you start the BAT

The BAT files shall referee to the source folder as either an absolute path or a relative path that ALREADY exists and is reusable.
Examples:
d:\MyStuff\Homework\
is and absolute path
..\Homework\
is a relative path REACHABLE from d:\MyStuff\anyfolder

So the BAT file might contain
xcopy ..\Homework\*.*

Try it first on some DUMMY files.
I did not call you a dummy.
I am the dummy.

8782.

Solve : move text from a notepad to the cmd?

Answer»

Is there a way to TAKE a text i WROTE in a text FILE and save it as a VARIABLE in the cmd.
(like set something=the contents of some text file)if you only have 1 line, then
set /P myvar=thanks!

8783.

Solve : extended keyboard character?

Answer»

When did DOS start using extended keyboard characters in the filenames, in ever?u mean the ones...like (æ)Yes that is ONE of them.Do you mean real MS-DOS or Windows?

I am talking about MS DOS 5.0Well, as far as I can see, the FAT filesystem has always ALLOWED ascii 128-255 in filenames, but what you would see on the screen e.g. from DIR would depend on codepage setting. Codepages arrived in MS-DOS 3.30 in 1987.

8784.

Solve : Batch file in which is almost everything you need?

Answer»

Hey guys,

I am new to this forum but I want to share with you batch file in which you can find almost everything you need ( 27 options ) some of examples what you can find in it: Change/delete/set password for user ; open cmd.exe by batch file command line ; kill task with task manager ; open your website or other most popular like google.com ; youtube.com ect... TURN of computer (or cancel turn off) ; show your computer information ; change text color ; block/unblock websites ; "scan computer" with [DIR] ; show DOS borders ; turn on/off automatic updates/ firewall and ect... count from 1 to 100 and a lot more! Also there is some of dangerous options (3-4) Your computer destruction ( %systemdrive% delete) ; create FILES on desktop ( if your computer is powerful i don't recommend to choose this options because it will do 100 file/sec ....... So if you wish to try it here is the link to tutorial video: I am recommending you to look at that ( if you will download it you should read TERMS and Readme carefully first )

Thanks for your time, hope I'll helped you!

Link Removed...Is this the sort of thing we really need on here?
QUOTE from: Salmon TROUT on August 20, 2011, 11:29:54 AM

Is this the sort of thing we really need on here?


No.

I would have though that trying to distribute trojan horses was something that ought to be frowned upon.This person has made (at the moment) one other post with the "offering".
8785.

Solve : Batch Command Logging?

Answer»

Hello, I'm trying to capture the output of my batch script to a log file for later review. I've found a way to capture the out put but I can't figure out how to get the batch script to then close or exit at the completion of the script.. I'm currently using 2 batch files to capture the log file which I will list below..

TEST.BAT (contains the following COMMAND):
TEST2.BAT > TEST.LOG 2>&AMP;1

TEST2.BAT (contains the following commands):
@ECHO ON
dir
copy *.bat c:\testtest
copy *.txt c:\testtest

After test2.bat runs it CREATES a file call TEST.LOG with everything in it but the DOS window STAYS open and I have to Ctrl+C to BREAK it and close/exit.

Thanks again for your help..Hey,
I've just created the 2 bat files that you wrote and copied the commands u put in them
and it did trasfer the results to the log as you said but it didn't leave any windows open after it

8786.

Solve : Batch File Archive Extract/Move contents?

Answer»

Hello guys!

I'm CURRENTLY writing a compilation for a game (Elder Scrolls Oblivion) that instead of packaging all mods together at distribution, simply packages metadata and installation data. The end-user is still required to DOWNLOAD the mods from their sites. The benefit of this is that I don't have to ask for distribution permissions from the author. I'm using a PROGRAM called Fallout Mod Manager to determine whether or not a user has the correct archives. If the user does not have the correct archive, then a download link will be displayed. If the user does have the correct archive, than the archive will be extracted and portions of its contents will go into one folder, and the other portions elsewhere.

Currently, I had to do a little hackjob in FOMM to make sure it recognizes Oblivion. but even then I find it silly I'm forcing players to download a mod manager when all it did was extract/mod files.

I've been told that I can accomplish the same thing with batch files through a (apparently) simple process.

Here is a sample .xml snippet to show you what FOMM does. This snippet only moves AROUND the patches of the compilation.

Code: [Select]<premadeFomodPack>
<sources>
<source name="Unofficial_Oblivion_Patch_v3_2_0_Manual_Version-5296.7z" url="http://www.tesnexus.com/downloads/file.php?id=5296" />
<source name="v1_4_0_Manual_install_7Z_version-10739.7z" url="http://www.tesnexus.com/downloads/file.php?id=10739" />
<source name="Unofficial_Official_Mods_Patch_v15_Manual_Version-9969.7z" url="http://www.tesnexus.com/downloads/file.php?id=9969" />
<source name="Unofficial_Patch_Supplementals-27710-3-3-7.7z" url="http://www.tesnexus.com/downloads/download.php?id=82357" />
<source name="DLC_MOBS-19203-1-02.zip" url="http://www.tesnexus.com/downloads/download.php?id=19203" />
<source name="SM_Plugin_Refurbish_1-30-11474.zip" url="http://www.tesnexus.com/downloads/file.php?id=11474" />
<source name="OCM - BAIN.7z" url="http://www.tesnexus.com/downloads/file.php?id=39868" />
</sources>
<customHowToSteps />
<copyInstructions>
<instruction source="arch:Unofficial_Oblivion_Patch_v3_2_0_Manual_Version-5296.7z//Data\Meshes" destination="0000 Core\meshes" />
<instruction source="arch:Unofficial_Oblivion_Patch_v3_2_0_Manual_Version-5296.7z//Data\Sound" destination="0000 Core\Sound" />
<instruction source="arch:Unofficial_Oblivion_Patch_v3_2_0_Manual_Version-5296.7z//Data\Textures" destination="0000 Core\Textures" />
<instruction source="arch:Unofficial_Oblivion_Patch_v3_2_0_Manual_Version-5296.7z//Data\Trees" destination="0000 Core\Trees" />
<instruction source="arch:Unofficial_Oblivion_Patch_v3_2_0_Manual_Version-5296.7z//Unofficial Oblivion Patch\Readme.html" destination="9999 OCMDocs\OCM - Unofficial Oblivion Patch.html" />
<instruction source="arch:v1_4_0_Manual_install_7Z_version-10739.7z//Data\Meshes" destination="0010 UOMPSI\meshes" />
<instruction source="arch:v1_4_0_Manual_install_7Z_version-10739.7z//Data\Sound" destination="0010 UOMPSI\Sound" />
<instruction source="arch:v1_4_0_Manual_install_7Z_version-10739.7z//Data\Textures" destination="0010 UOMPSI\Textures" />
<instruction source="arch:v1_4_0_Manual_install_7Z_version-10739.7z//Unofficial Shivering Isles Patch\Readme.html" destination="9999 OCMDocs\OCM - Unofficial Shivering Isles Patch.html" />
<instruction source="arch:Unofficial_Official_Mods_Patch_v15_Manual_Version-9969.7z//Data\Meshes" destination="0000 Core\meshes" />
<instruction source="arch:Unofficial_Official_Mods_Patch_v15_Manual_Version-9969.7z//Data\Sound" destination="0000 Core\Sound" />
<instruction source="arch:Unofficial_Official_Mods_Patch_v15_Manual_Version-9969.7z//Data\Textures" destination="0000 Core\Textures" />
<instruction source="arch:Unofficial_Official_Mods_Patch_v15_Manual_Version-9969.7z//Data\DLCSpellTomes - Unofficial Patch.ESP" destination="0010 UOMPST\DLCSpellTomes - Unofficial Patch.esp" />
<instruction source="arch:Unofficial_Official_Mods_Patch_v15_Manual_Version-9969.7z//Unofficial Official Mods Patch\Unofficial Official Mods Patch Readme.html" destination="9999 OCMDocs\OCM - Unofficial Official Mods Patch.html" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//00 Unofficial Oblivion Patch Supplemental\Meshes" destination="0000 Core\meshes" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//00 Unofficial Oblivion Patch Supplemental\Sound" destination="0000 Core\Sound" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//00 Unofficial Oblivion Patch Supplemental\Textures" destination="0000 Core\Textures" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//00 Unofficial Oblivion Patch Supplemental\Unofficial Oblivion Patch.esp" destination="0000 Core\Unofficial Oblivion Patch.esp" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//09 Unofficial Shivering Isles Patch Supplemental\Unofficial Shivering Isles Patch.esp" destination="0010 UOMPSI\Unofficial Shivering Isles Patch.esp" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//09 Unofficial Shivering Isles Patch Supplemental\meshes" destination="0010 UOMPSI\mesh" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//09 Unofficial Shivering Isles Patch Supplemental\sound" destination="0010 UOMPSI\sound" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//01 DLC Battlehorn Castle Unofficial Patch\DLCBattlehornCastle - Unofficial Patch.esp" destination="0010 UOMPBH\DLCBattlehornCastle - Unofficial Patch.esp" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//02 DLC Frostcrag Spire Unofficial Patch\DLCFrostcrag - Unofficial Patch.esp" destination="0010 UOMPFC\DLCFrostcrag - Unofficial Patch.esp" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//03 DLC Horse Armor Unofficial Patch\DLCHorseArmor - Unofficial Patch.esp" destination="0010 UOMPHA\DLCHorseArmor - Unofficial Patch.esp" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//04 DLC Mehrunes Razor Unofficial Patch\DLCMehrunesRazor - Unofficial Patch.esp" destination="0010 UOMPMR\DLCMehrunesRazor - Unofficial Patch.esp" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//05 DLC Orrery Unofficial Patch\DLCOrrery - Unofficial Patch.esp" destination="0010 UOMPOR\DLCOrrery - Unofficial Patch.esp" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//06 DLC Thieves Den Unofficial Patch\DLCThievesDen - Unofficial Patch.esp" destination="0010 UOMPTD\DLCThievesDen - Unofficial Patch.esp" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//07 DLC Vile Lair Unofficial Patch\DLCVileLair - Unofficial Patch.esp" destination="0010 UOMPVL\DLCVileLair - Unofficial Patch.esp" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//08 Knights of the Nine Unofficial Patch\Knights - Unofficial Patch.esp" destination="0010 UOMPKN\Knights - Unofficial Patch.esp" />
<instruction source="arch:Unofficial_Patch_Supplementals-27710-3-3-7.7z//Unofficial Patch Supplementals README.txt" destination="9999 OCMDocs\OCM - Unofficial Patch Supplementals.txt" />
<instruction source="arch:DLC_MOBS-19203-1-02.zip//Battlehorn_mobs.esp" destination="0015 DLCMBH\Battlehorn_mobs.esp" />
<instruction source="arch:DLC_MOBS-19203-1-02.zip//Lair_mobs.esp" destination="0015 DLCMVL\Lair_mobs.esp" />
<instruction source="arch:DLC_MOBS-19203-1-02.zip//Mehrunes_mobs.esp" destination="0015 DLCMMR\Mehrunes_mobs.esp" />
<instruction source="arch:DLC_MOBS-19203-1-02.zip//Thievesden_mobs.esp" destination="0015 DLCMTD\Thievesden_mobs.esp" />
<instruction source="arch:DLC_MOBS-19203-1-02.zip//DLC_MOBS.esp" destination="0015 DLCMC\DLC_MOBS.esp" />
<instruction source="arch:DLC_MOBS-19203-1-02.zip//readme.txt" destination="9999 OCMDocs\OCM - DLC MOBS Patch.txt" />
<instruction source="arch:SM_Plugin_Refurbish_1-30-11474.zip//00 Full Plugin\SM Plugin Refurbish(Merged).esp" destination="0025 SMPluginM\SM Plugin Refurbish(Merged).esp" />
<instruction source="arch:SM_Plugin_Refurbish_1-30-11474.zip//00 Individual Plugins\SM Plugin Refurbish - Battlehorn.esp" destination="0025 SMPluginBH\SM Plugin Refurbish - Battlehorn.esp" />
<instruction source="arch:SM_Plugin_Refurbish_1-30-11474.zip//00 Individual Plugins\SM Plugin Refurbish - Frostcrag.esp" destination="0025 SMPluginFC\SM Plugin Refurbish - Frostcrag.esp" />
<instruction source="arch:SM_Plugin_Refurbish_1-30-11474.zip//00 Individual Plugins\SM Plugin Refurbish - HorseArmor.esp" destination="0025 SMPluginHA\SM Plugin Refurbish - HorseArmor.esp" />
<instruction source="arch:SM_Plugin_Refurbish_1-30-11474.zip//00 Individual Plugins\SM Plugin Refurbish - Knights.esp" destination="0025 SMPluginKN\SM Plugin Refurbish - Knights.esp" />
<instruction source="arch:SM_Plugin_Refurbish_1-30-11474.zip//00 Individual Plugins\SM Plugin Refurbish - MehrunesRazor.esp" destination="0025 SMPluginMR\SM Plugin Refurbish - MehrunesRazor.esp" />
<instruction source="arch:SM_Plugin_Refurbish_1-30-11474.zip//00 Individual Plugins\SM Plugin Refurbish - Orrery.esp" destination="0025 SMPluginOR\SM Plugin Refurbish - Orrery.esp" />
<instruction source="arch:SM_Plugin_Refurbish_1-30-11474.zip//00 Individual Plugins\SM Plugin Refurbish - SI.esp" destination="0025 SMPluginSI\SM Plugin Refurbish - SI.esp" />
<instruction source="arch:SM_Plugin_Refurbish_1-30-11474.zip//00 Individual Plugins\SM Plugin Refurbish - ThievesDen.esp" destination="0025 SMPluginTD\SM Plugin Refurbish - ThievesDen.esp" />
<instruction source="arch:SM_Plugin_Refurbish_1-30-11474.zip//00 Individual Plugins\SM Plugin Refurbish - VileLair.esp" destination="0025 SMPluginVL\SM Plugin Refurbish - VileLair.esp" />
<instruction source="arch:SM_Plugin_Refurbish_1-30-11474.zip//SM Plugin Refurbish.txt" destination="9999 OCMDocs\OCM - SM Plugin Refurbish.txt" />
<instruction source="arch:OCM - BAIN.7z//wizard.txt" destination="wizard.txt" />
</copyInstructions>
</premadeFomodPack>

It allows me to extract the stuff I want from an archive and move it around as I wish. But again, I'm forcing users to download a mod manager for another game to simply do this for them... so it's a bit clunky and unprofessional. I would like to declare things
a) what directory the source archives can be found
b) if a archive cannot be found, then where to find it
c) Where contents are extracted too
c) Extraction installations. i don't want to move all the contents in an archive to the same folder. Sometimes there is junk. For example,

Code: [Select] <instruction source="arch:Unofficial_Oblivion_Patch_v3_2_0_Manual_Version-5296.7z//Data\Meshes" destination="0000 Core\meshes" />
<instruction source="arch:Unofficial_Oblivion_Patch_v3_2_0_Manual_Version-5296.7z//Data\Sound" destination="0000 Core\Sound" />
<instruction source="arch:Unofficial_Oblivion_Patch_v3_2_0_Manual_Version-5296.7z//Data\Textures" destination="0000 Core\Textures" />
<instruction source="arch:Unofficial_Oblivion_Patch_v3_2_0_Manual_Version-5296.7z//Data\Trees" destination="0000 Core\Trees" />
I could have just written

Code: [Select] <instruction source="arch:Unofficial_Oblivion_Patch_v3_2_0_Manual_Version-5296.7z//Data\" destination="0000 Core\" />
But there were a few junk files in the data directory of that archive.

Basically, I would like to do something like this.

If Archive Exists at directory then Installation Instructions and move to this directory. Else, link to missing archive here.

Is it possible to do this via batch file? And if so, could someone write a small template and/or direct me to a series of links and tutorials? I have very little batch experience... the only thing I have is the creativity to create hack-job conversions... but I'm willing to learn. It would speed up development and lower the amount of "required downloads" a user has to find.

Thank you very much for the help.

8787.

Solve : My Kingdom FOR a Loop!?

Answer»

Hello all,

APOLOGIES in advance if this topic has been done to death but after searching on this site and others for some time I haven't been able to find a solution to my problem. I am running a set of motorised stages via DOS Navigator v1.5 (April 1997) and what I'd like to be able to do is simply run a BATCH file a specified AMOUNT of times.

My batch file (baf.bat) essentially consists of:

call move_fwd %1
call move_bck %2 (move_fwd and move_bck are relative motion batch files written by some long departed person)

this works fine by itself but I need to run it for hundreds or thousands of times so to avoid having to copy and paste that many times I attempted to write a simple loop like (using pseudo-code):

FOR n = %1
baf.bat %2 %3
end

I have tried a number of solutions found here and elsewhere with no success. From what I gather FOR /L doesn't work on this machine, nor does delayedexpansion. Unfortunately I have very little knowledge of DOS code and syntax so I'm floundering in the dark quite a bit here; but this seems like it should have a simple answer...

Thanks in advance for any help.What version of DOS are you using?

It may be possible to call a vbscript to do your calculation

Otherwise, a gwbasic or qbasic program could be used to
read a number in a file
decrement it
store it back in the file
if number =0, delete the file

then if you include this in your batch, you would know to stop running when the file did not exist

anyone else with any other ideas?Like gpl, I would think of using Qbasic. if this machine has a full install of a fairly late MS-DOS then Qbasic should be present. You can even create Qbasic programs on the fly in a batch file and then execute them use qbasic /run passing any parameters necessary

Code: [Select]@echo off
echo for n = 1 to %1 > myprog.bas
echo shell "baf.bat " + "%2" + " " + "%3" >> myprog.bas
echo next n >> myprog.bas
echo system >> myprog.bas
qbasic /run myprog.bas
mybatch.bat

Code: [Select]@echo off
echo for n = 1 to %1 > testme.bas
echo shell "baf.bat " + "%2" + " " + "%3" >> testme.bas
echo next n >> testme.bas
echo system >> testme.bas
qbasic /run testme.bas

baf.bat

Code: [Select]@echo off
echo call move_fwd %1
echo call move_bck %2




Hey gpl and Salmon Trout, cheers for the info I shall give that a try once the rig is free again. Yesterday I did just end up copy and pasting 100 times to test it and that works fine. Seems somewhat absurd that there is no way to automate a batch file to run 100 times easily but I guess I'm just too used to fancy-shmancy Matlab. I'll let you know if I get that working, thanks again!Quote from: curriemaster on April 20, 2011, 02:45:37 AM

Seems somewhat absurd that there is no way to automate a batch file to run 100 times easily

1. MS-DOS is a operating system from the 1980s and 1990s. It hasn't really changed for 20 years.
2. You can do what you ask for with other tools such as QBasic, which was provided for this sort of thing.
3. You still have not said what OS version you are running.





Quote
When current civilization is long gone, anthropologists digging up the rubble find the only thing left intact is... QBASIC (clic here)
Source: Anonymous
8788.

Solve : Error : loading boot sector?

Answer»

hello
A few days ago i used Smart FDISK program with HIREN's boot CD , at FIRST it works good, but when i finished my work, it doesn't work for second time, and i try ANOTHER boot CD form DOS , but it doesn't work again.
How can I solve this problem?



[recovering disk space - old ATTACHMENT deleted by admin]which selection did you choose in smart fdisk and why?I have 10 PCs , and every pc i used SMARTFDISK in Hiren's boot CD, the cd didn't boot again.
what should i do for this problem?

8789.

Solve : Would someone recommend the CP/M OS??

Answer»

I was speaking to my uncle yesterday, and he told me that MS-DOS was based off of the CP/M OS (Not the Emulator). It was released in 1976.

Would someone recommend it, but not the Emulator to learn MS-DOS as for the OS?

Would it be released as so many decades went by?

Was it really based off of FAT8?

Could I turn the floppy images into a bootable CD?

http://www.google.com/m/search?pbx=1&aq=f&oq=&aqi=-k0d0t0&fkt=2367&fsdt=44334&cqt=&rst=&htf=&his=&maction=&q=cp%2Fm+operating+system+free+download&flip=0

That's the link I came across.Quote from: php111 on August 19, 2011, 09:50:52 AM

I was speaking to my uncle yesterday, and he told me that MS-DOS was based off of the CP/M OS (Not the Emulator). It was released in 1976.
Wait... what emulator? CP/M was Digital Research's Operating System, "Control Program for Microcomputers".

QDOS was based on CP/M only as much as, say, Linux is based off of UNIX. Which is to say, not at all. It tries to seem similar to it's environment, but saying it was "based" off of CP/M implies that QDOS was actually based off of CP/M at the source code LEVEL, which it wasn't; Tim Patterson wrote QDOS because there was a need for it.

Why all this talk of QDOS? QDOS was purchased by Microsoft, renamed to DOS, and licensed to IBM as part of their agreement.

Quote
Would someone recommend it, but not the Emulator to learn MS-DOS as for the OS?
What? I'm going to say "no" here, although I'm not sure what you are asking. What Emulator? Either run it in a VIRTUAL Machine, or don't run it at all. As buggy and problematic as DOS itself is, CP/M raises that by quite a factor, particularly in regards to disk corruption.

Most importantly, you aren't going to get CP/M working on a modern machine. A Boot disk, maybe. But have it boot from, say a partition of your hard disk? Very doubtful.


Quote
Would it be released as so many decades went by?
No idea what you are asking.

Quote
Was it really based off of FAT8?
No. CP/M does NOT use anything remotely compatible with the MS-DOS FAT file system.

Quote
Could I turn the floppy images into a bootable CD?
I usually try to avoid speaking in absolutes but I'm going to say "No" here. Certainly not without some level of virtualization. In fact I doubt you could boot up CP/M on a modern system at all.
Thank you for the info. I didn't mean to make you upset.Quote from: BC_Programmer on August 19, 2011, 10:27:37 AM
have it boot from, say a partition of your hard disk? Very doubtful.

Can be done, apparently, from the first volume of a CVV partition, and there are patches to get over the 8MB (!) partition size barrier.

Quote
I doubt you could boot up CP/M on a modern system at all.

Of course CP/M-80 won't run on any x86 family processor, but CP/M-86 can be used on early type PCs with 8086 and 8088 cpus.

Applying the unofficial "AT Patch" to CPM.SYS enables use with 286 and higher cpus, i.e. any AT-class machine (286, 386, 486, Pentium, etc.) There is another patch to enable dates after 1.1.2000 as well.






Quote from: php111 on August 19, 2011, 10:48:48 AM
Thank you for the info. I didn't mean to make you upset.

Not sure what makes you think I was upset.
Quote from: BC_Programmer on August 19, 2011, 10:54:15 AM
Not sure what makes you think I was upset.

Considering he's interested in CP/M, maybe he thought you'd got the "pip" as Bertie Wooster used to say.
Thank you all for the info.Hey guys,

I'm 29, and since I love the 80s way too much. I understand they didn't have PCs back then. They only had MS-DOS. Am I right or wrong?

How, and what proper steps do I have to take to learn 80s DOS? Would it be the OS of MS-DOS 6.22?Quote from: php111 on August 19, 2011, 03:08:14 PM
I understand they didn't have PCs back then.
http://en.wikipedia.org/wiki/IBM_Personal_Computer

Quote
They only had MS-DOS. Am I right or wrong?
You're wrong. I suspect you might be trolling. This very topic is about another OS choice that could be made at that time, so apparently that wasn't the only choice.

Quote
How, and what proper steps do I have to take to learn 80s DOS? Would it be the OS of MS-DOS 6.22?
There is no "80's" DOS. and there would be no good reason beyond curiousity to learn EARLIER versions of MS-DOS (or CP/M, for that matter). 6.22 was released in 1992 or thereabouts, I believe. This type of stuff is pretty easy to google.Quote from: BC_Programmer on August 19, 2011, 03:15:16 PM
http://en.wikipedia.org/wiki/IBM_Personal_Computer
You're wrong. I suspect you might be trolling. This very topic is about another OS choice that could be made at that time, so apparently that wasn't the only choice.
There is no "80's" DOS. and there would be no good reason beyond curiousity to learn earlier versions of MS-DOS (or CP/M, for that matter). 6.22 was released in 1992 or thereabouts, I believe. This type of stuff is pretty easy to google.

1. I'm not trolling.

2. I'm really sorry that I want to learn an earlier version of DOS. Will you forgive me, please?

3. Do you want me to stop posting on this forum because of all of this?Quote from: php111 on August 19, 2011, 03:08:14 PM
they didn't have PCs back then. They only had MS-DOS

MS-DOS runs on PCs, and only PCs. What don't you understand about that?

Quote
How, and what proper steps do I have to take to learn 80s DOS?

Read some BOOKS.

Quote
Would it be the OS of MS-DOS 6.22?

Read some books. Then decide.






Quote from: php111 on August 19, 2011, 03:32:34 PM
1. I'm not trolling.

I have noticed that a lot of your posts fall into a kind of "stupid kid" category. It seems I am not the only one.

8790.

Solve : Parsing characters from a file name in batch?

Answer»

I need help. I could work at this for days but I know there are some DOS GURU's in here that can figure this out in minutes.

I have a batch file that is almost COMPLETE but I need the final piece of code to make it unattended which I cannot figure out without pulling my hair out

What I want to do is:
1) Read the first file in a directory - variable that I already have
2) Get the 1st filename
3) Extract the digits between the parentheses of the filename
4) Pass them forward to the rest of the routine in a variable

Filenames look like:
Filename(55).tib
Filename(55)2.tib
Filename(55)3.tib
...
...
NOTE 55 is only an example. It could be 1-? between the parentheses but the parentheses are always there. (Yes, these are Acronis backup files)

I think this involves a FOR /F using tokens and delims. I got the following,primative routine, to work but I can't pass a variable into it let alone try and read a filename in. I've seen other examples of dir piped into other commands but I'm lost at this point and could do trial and error for days till I find something that works.

Help me PuhLeeez

@ECHO OFF
CLS

for /f "tokens=2 delims=(+)" %%a in ("Filename(55)2.tib") do (
set /a setnum = %%a
)
echo setnum = %setnum%
pause

Code: [Select]set MyFileName=an arbitrary string(557).tib
for /f "tokens=2 delims=()" %A in ("%MyFileName%") do set MySetNumber=%A

MySetNumber equals 557
In the above, the for /f command is used at the prompt, where the variables have only one percent sign (e.g. %A). In a batch script you use two percent signs (e.g. %%A)

Like this...

Code: [Select]set MyFileName=an arbitrary string(557)another arbitrary string.tib
for /f "tokens=2 delims=()" %%A in ("%MyFileName%") do set MySetNumber=%%A
echo MySetNumber is %MySetNumber%
Code: [Select]MySetNumber is 557Thanks to everyone for your great examples and taking the time to come up with them!!
From all the examples I was able to piece together a small routine that does just what
I want it to do. Returns the number between the parentheses of the first file in a directory.
Here's what I came up with:

@echo off
:: setLocal EnableDelayedExpansion
set targetdir=Where my .tib files are
set setnum=0

for /f "tokens=2 delims=()" %%a in ('dir /b %targetdir%\*.tib') do (
set setnum=%%a
goto loopexit
)
:loopexit
echo %setnum%
pause

From all the suggestions I have a better grasp on the FOR /F command and a couple other tricks that were shown as well. I don't see the need for the need for the DelayedExpansion, which I now understand better, in what I'm doing here but, if it's considered good programming practice to always include it then maybe I should I leave it in there. I saw a suggestion somewhere else on using a GOTO to exit a FOR loop early and it works just fine for me since I only want the 1st .tib file in the directory.

If you see any loopholes or downfalls in what I have here, I'm open for suggestions.

Again, KUDOS to all! You've been "thanked" appropriately too...Quote from: pcjunky on April 22, 2011, 03:37:53 PM

the first file in a directory.

Before I read your LATEST post, I had been thinking about this. About how you want to define the "first" file in a directory. I am guessing that you mean what you think is going to be the first file listed by a plain dir command ["plain" because it is without any /o (order) switches.] That is to say, the files sorted by NAME and in ascending order. In other words /on is implied. This is all very well, but there is an environment variable which can be present or absent in any PARTICULAR system called %dircmd% which sets default dir switches which are then used when just dir without switches is issued. e.g. it might be /od /a-d or whatever. If you are sure it is always going to be null, all well and good. Otherwise it is good practice and safer to specify. See dir /? for all the switches.

Which BRINGS me to a way of avoiding the clumsy GOTO and the label. If you use dir /o-n then the sort is reversed so that the "first" file in order of name will be the last listed and therefore in your loop will be the last value held by %%a so you can just have a one line FOR statement.

Code: [Select]for /f "tokens=2 delims=()" %%a in ('dir /b /o-n %targetdir%\*.tib') do set setnum=%%a
Awesome Trout! That's even better! I'm an old COBOL programmer and never, ever left a loop so abruptly as a GOTO (unless absolutely necessary) but, I was at a loss and didn't know a graceful way out of the loop to preserve that 1st %setnum%. I never thought of a descending dir as you pointed out. I tested it and I'm putting that change in my routine now. I don't expect more than 8 files in the directory at any given time so the extra cycles are negligible to me. You are correct, my only concern IS the first file name in an ascending dir listing. One line of code to do all of this? Awesome.

Thanks again!
8791.

Solve : From bat run another exe, then close bat?

Answer»

Hi, I am trying to run a exe program from a bat FILE, but the bat doesn't close until I close the exe program.

Is there a way to start the exe program from the bat file, but the bat doesn't hung on it?

ThanksHere is a SUPER simple test to see if the EXE file will LET ou do that.

Code: [Select]REM callme.bat
notepad
REM done here

Code: [Select]REM BATCH file calls another batch
DIR /b
call callme.bat
DIR /w
REM All done!

The only purpose of this code is to see if it works in a very simple batch.
This doesn't work, I am on Windows XP, it doesn't even work for the notepad.Code: [Select]start notepad.exe
exit
Please help me as I have esimilar kind of query.

I want to create a batch file like SAY abc.bat which will execute batch file xyz.bat located in some d:\ .

but problem is that we manually run this file by going to d:\ and typing command d:>xyz start.

please suggest how to write code for same.Quote from: alpa on January 31, 2009, 06:56:32 AM

Please help me as I have esimilar kind of query.

I want to create a batch file like say abc.bat which will execute batch file xyz.bat located in some d:\ .

but problem is that we manually run this file by going to d:\ and typing command d:>xyz start.

please suggest how to write code for same.
Quote from: foxhunt99 on January 30, 2009, 03:32:10 PM
Hi, I am trying to run a exe program from a bat file, but the bat doesn't close until I close the exe program.

Is there a way to start the exe program from the bat file, but the bat doesn't hung on it?

Thanks
Code: [Select]@echo off
start "" "D:\xyz.exe"
8792.

Solve : What are native DOS drivers for a LCD monitor??

Answer»

Hey everyone,

How's it GOING?

I'm looking for info on native DOS drivers for a LCD flat screen PC monitor. If I got the words right? What are they? What do they do for my system? For example, if I'm entering DOS utilities of off Hiren's Boot CD. Certain ones won't let me see the full screen. The same way, I can't see the DOS commands that I'm writing, or even the info that I'm receiving. Are there any native DOS drivers for that purpose?

Are there anyway to configure, and set it up in the BIOS without having Windows installed? Does it work LIKE that?They need to be video drivers...for whatever card/chip you are running...not Monitor drivers.

Best of Luck finding them.
I had to install a way old vid card on a newer system for someone because that was the only way to get it to run in DOS.

BTW VM is still most likely your best solution for this dilemna.http://www.emachines.com/products/products.html?prod=EL1200-07w

There's the info for the PC I have. I don't know what to LOOK up.

Could I install the drivers through the BIOS, so I don't have to worry about it unless I set the BIOS to DEFAULT?

I prefer not to use VM for some reason.





Quote from: patio on August 18, 2011, 07:44:22 PM

They need to be video drivers...for whatever card/chip you are running...not Monitor drivers.

Best of Luck finding them.
I had to install a way old vid card on a newer system for someone because that was the only way to get it to run in DOS.

BTW VM is still most likely your best solution for this dilemna.
8793.

Solve : Send message with CMD?

Answer»

I'm trying to SEND a message in CMD to a different computer, I know in XP the command is

Code: [Select]@echo off
:A
Cls
set /p n=User: IP address
set /p m=Message: message
net send %n% %m%
Pause
Goto A

But in Win7 they removed that command so now you must use "msg" and you have to type,

Code: [Select]@Echo off
:A
cls
msg /server:PC-name username message
goto A

But this is is only for LAN and you can't send a message to a other computer with a IP.

So my question is if you can send a message from Win7 to a other computer that is not on LAN.Really nice concept and question.
I hope that should be possibleQuote from: vishuvishal on August 15, 2010, 06:21:57 PM

Really nice concept and question.
I hope that should be possible

If you do not know the answer, do not post. This is not a chat room.


Then you must have an answer to it.

Do you have any idea???
how can we do it.Quote from: vishuvishal on August 16, 2010, 12:23:48 PM


Then you must have an answer to it.

Do you have any idea???
how can we do it.

Please don't spam my post.

Sometimes I just get so BORED... But I would be glad if someone knew if how/if you could do this.The bad news is : msg.exe is definitely not equivalent to net send.
MSG is designed to send messages to 'sessions' on the same machine which is acting as a 'TERMINAL server'.

To enable MSG to work without a Terminal Services session, you should activate the following registry key :
HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server
Name : AllowRemoteRPC
Type : REG_DWORD
Value : 1

Another solution is to use another lan messenger such as

But it is not free so ... let's try msg again ! So do
Quote from: voluris on August 31, 2010, 03:32:08 AM
HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server
Name : AllowRemoteRPC
Type : REG_DWORD
Value : 1

And I can send message?

Btw is it only to Win7?msg.exe is not included with vista and windows 7 home (basic or premium) editions. So unless you have an office or enterprise EDITION (?), you're out of luck with that command.Quote from: MattPwns on September 02, 2010, 04:56:12 AM
msg.exe is not included with vista and windows 7 home (basic or premium) editions. So unless you have an office or enterprise edition (?), you're out of luck with that command.

I have the Ultimate edition and I do think I got the msg.exe, but still is only for LAN, and I have been trying to get it to work with a VPN program but didn't GO so great. But even if I got it to work in a VPN program both of the computers need to start it, and it's that what I don't want, I just want to send a message without a 3'rd party program.

To be able to receive a message through a VPN (or to a host computer for that part) you must do;

Code: [Select]HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server

Name : AllowRemoteRPC

Type : REG_DWORD

Value : 1 (the dafault is '0')

So it seems like you can't send a message in Win7 by the msg to a other IP address, but can you get the net send back to Win7?
8794.

Solve : MS-DOS files to covert to Windows 7?

Answer»

I have a few floppies filled with files created in the early 1990s in MS-WORD for DOS 5.0. I still have the "style sheet" files used to create margins, etc., but the important thing is simply to be able to access the text in the DOS files Is there a way to convert them to Windows 7 files that I can access on my new computer?It sounds like you are asking two or three questions.
Here eye two answers.
1. CURRENT versions of MS-Wed can READ the older files of Word.
2. Windows 7 can read any floppy disc the was used in earlier versions of Windows and MS-DOS.

As for the templates, you may find they need to be updated. That question is not as easy to answer.
Quote from: Geek-9pm on April 23, 2011, 03:26:13 PM

1. Current versions of MS-Wed can read the older files of Word.
2. Windows 7 can read any floppy disc the was used in earlier versions of Windows and MS-DOS.

1. Microsoft doesn't seem to provide conversion filters for Word 5 in later versions of Word ("MS-Wed" ). There are two approaches I can think of, however. See below.
2. As long as the floppy is still capable of being read.

(a) You can download a file converter from Microsoft. If you search the Microsoft Knowledge Base, you won't find any information about doing conversions from Word 5. An older converter is still available, however, if you know where to look. The converter name is WDSUPCNV.EXE, and it is available at this Microsoft FTP site:

ftp://ftp.microsoft.com/softlib/mslfiles/wdsupcnv.exe

This works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003. INSTRUCTIONS for use here:

http://word.tips.net/T000791_Converting_Word_for_DOS_Documents.html

I imagine some kind of bulk conversion would be most desirable, though.

(b) You can legally download Word 5 for MS-DOS free from Microsoft and load the files and then save them as RTF or plain text. This requires a system that can run 16-bit MS-DOS PROGRAMS. In 1999 MS released a Year 2000 compliant version of Word 5 and just decided to give it away for free. Beware that the RTF standard has changed somwhat in 20 years so some less mainstream features may not export correctly. The installer is downloaded from here:

http://download.microsoft.com/download/word97win/Wd55_be/97/WIN98/EN-US/Wd55_ben.exe

Personally I would get those files off those 20 year old floppies straight away. If they are important to you, that is. Perhaps you could buy some archive quality CD-ROM blanks and burn them. I PRESUME you have checked that the floppies are still readable?











Salmon Trout is amazing.
His answer is much better than mine.
(But he has such a fishy name.)
8795.

Solve : Format cannot run because in use by another process. Are my commands right??

Answer»

I am trying to format, and write zeros on my sectors. I know it's time consuming. I just want to do it.

Format cannot run because in use by another process.

What does that mean? How do I bypass it? I am using the Windows 7 Repair Disc to access the Command PROMPT. It's dismounting the drive instead of using the command I put in. Will it do it's work after the dismount? Below is the command I used for the low level format/wipe.

format c: /fs:NTFS /p:35The C: drive is the boot drive. Low leveler formatting is a out-of-date term. Users don't low level format anymore.
How do you know it writes zeros? Did you look and see?
You should not formant it unless you:
1. ) want to destroy your system
AND
2. ) You want the format to REVEAL you have a bad drive.

The second option can be done just as well using the utility to check the disk. Without destroying the system.

Please, understand, I am not picking on you. This is a public forum and others seeing your post might think want you are doing is a good idea.

To format the C: drive in Windows 7 is not a good idea.

If you suspect the drive is failing, please tell why. Then others or myself can give you some dubious tips on how to salvage a failing drive pr extend its usefulness.

If you want security, use a boot utility CD or DVD.

How to Format a Hard Drive With a CD (Video)

Of course, you should have a backup made of important material.
You know that. I just have to say that.
If you are booting to the CD select remove partition and recreate.
Not sure about the answer above.

This will sufficiently wipe all the dat from the HDD...unless the FBI is looking for you/Quote from: patio on August 17, 2011, 09:27:41 PM

If you are booting to the CD select remove partition and recreate.
Not sure about the answer above.

This will sufficiently wipe all the dat from the HDD...unless the FBI is looking for you/

Unless the FBI is looking for you ... :L

This is a way of writing 0's to the drive if you so desire it ... http://pcsupport.about.com/od/toolsofthetrade/ht/write-zeros-format-command.htm

But as said above ... ALL data will be erased and drive may be made unusable.I personally rather to use DBAN (Darik's Boot and Nuke). It's DoD certified. Or KillDisk does the job as well. Just set DBAN for the Gutmann Wipe. That's what I'm doing at the MOMENT. That's my opinion. It does a better job then the COMMANDS I gave.




Quote from: Geek-9pm on August 17, 2011, 08:33:50 PM
The C: drive is the boot drive. Low leveler formatting is a out-of-date term. Users don't low level format anymore.
How do you know it writes zeros? Did you look and see?
You should not formant it unless you:
1. ) want to destroy your system
AND
2. ) You want the format to reveal you have a bad drive.

The second option can be done just as well using the utility to check the disk. Without destroying the system.

Please, understand, I am not picking on you. This is a public forum and others seeing your post might think want you are doing is a good idea.

To format the C: drive in Windows 7 is not a good idea.

If you suspect the drive is failing, please tell why. Then others or myself can give you some dubious tips on how to salvage a failing drive pr extend its usefulness.

If you want security, use a boot utility CD or DVD.

How to Format a Hard Drive With a CD (Video)

Of course, you should have a backup made of important material.
You know that. I just have to say that.
You are MAKING it alot harder than it is...Another thread - http://forums.techguy.org/general-security/1013046-what-does-everyone-recommend-wiping.html
8796.

Solve : RNS MS-DOS?

Answer»

Hi everyone!

I am a younger PC user and I am very INTRESTED in computers too. But now someone asked me for help in a topic in which I have no knowledge. He GAVE me a MS-DOS program and asked me how it can be run on windows 7. But the problem is that his and my windows 7 are 64bit and what I know is, that it isn't possible to run 16bit programs on 64bit.
Now is it possible to rewrite the program in a windows language? Or would you prefere something ELSE all i have is the Batch data, the exe programm and a lot of other datas with endings LIKE cfg, par, PRN, sym, fnt and so on.

Thank you for your help!Quote from: dotila on August 17, 2011, 02:37:20 PM

He gave me a MS-DOS program and asked me how it can be run on windows 7.

1. Why won't you tell us its name?
2. You may be able to use an emulator such as DOSbox.


8797.

Solve : Unattended SQL Express 2008 R2 Install on Windows 7?

Answer»

I am trying to run a batch script to do an unattended install of SQL Express 2008 R2 with Advanced SERVICES on a Windows 7 SYSTEM. The script I wrote based on the MSDN articles I found is as follows:

@echo off
echo.
echo.
start /wait c:\sqlexpradv_x86_enu.exe /IACCEPTSQLSERVERLICENSE /ACTION="INSTALL" /FEATURES=SQLENGINE,FULLTEXT,SSMS /INSTANCEID="SQLEXPRESS" /QUIET="TRUE" /ISSVCACCOUNT="NT AUTHORITY\NETWORKSERVICE" /ADDCURRENTUSERASSQLADMIN="TRUE" /QS
echo.
PAUSE


The FIRST error did not LIKE /IACCEPTSQLSERVERLICENSE so I removed it. The next error pointed out a grammatical error where I had /QUITE instead of /QUIET. The third error was on the /ISSVACCOUNT, I removed it.

What I wanted to know is has anyone managed to get this done and what script did they use? Any help would be appreciated. Thank you.I have spent my afternoon working on this problem and now seem to have a batch file that will install this onto a Windows 7 32 bit system with the pieces I need. However before I publish the file USED I want to test it now to make sure that what was installed is actually what the app I am using SQL Express for works.

8798.

Solve : set command doesn't work with if as it says on the explanation?

Answer»

In the explanation of the set command in the cmd it says to write a program like this:

set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "!VAR!" == "after" @ECHO If you see this, it worked
)

cause if you'll write "%var%"=="after" (it will take the before and compare to after)
but even when i write it like this the output i get(with echo on) is:

C:\>if "before" ==
"before" (
set VAR=after
if "!VAR!" == "after"
)

it doesn't recognize the value of the !var! , why is that?

another question, can i set a permanent variable that won't disapear after i close cmd, like windir,cd,errorlevel and such...Quote from: kyou8 on April 26, 2011, 04:32:32 AM

it doesn't recognize the value of the !var! , why is that?

TRY reading the entire help blurb, especially the part about delayed environment variable expansion.

Quote from: kyou8 on April 26, 2011, 04:32:32 AM
another question, can i set a permanent variable that won't disapear after i close cmd, like windir,cd,errorlevel and such...

Not thru batch code. You can USE any Windows Script language or use the GUI by RIGHT clicking on My Computer==>Properties==>Advanced==>Environmental Variables.

By the way, cd, errorlevel, and such are context DRIVEN and do not have permanent values. Windir was set when the OS was installed, why do you want to change it?

Quote from: kyou8 on April 26, 2011, 04:32:32 AM
another question, can i set a permanent variable that won't disapear after i close cmd

yes, use SETX.
8799.

Solve : future time saving?

Answer»

Hello,
how can i save the time that will be NEXT hour in a variable?

i MEAN if it's 3:40 now i want it to save 4:40 auto.

thxgosh i gotta stop being lazy and read the long explanations on commands such as set XD

thanks! and btw the 7th line should be set HH=%cktime:~0,2% in case it's 10 or 12


is there a way to transfer the output of the command time /t directly into the set command without using a text file?Batch code is not DESIGNED for date/time arithmetic. Numbers like 08 and 09 are seen as octal not decimal and hour+1 at the noon/midnight hour produce results that may not be accurate for your localized settings.

I'm not a big fan of hybrid batch files because of the hoops you have to jump thru for all the special characters used in batch code. In any case, this little piece of doggerel may help.

Code: [Select]@echo off

::
:: Create VBS script
::
(
echo newTime = DateAdd("h", 1, Time^)
echo WScript.Echo newTime
) > .\newTime.vbs

::
:: Execute script & grab the time
::
for /f "delims=" %%i in ('cscript newTime.vbs') do set newTime=%%i
echo %newTime%
del .\newTime.vbs

If need be, you can further parse the newTime variable for your purposes.

Good luck.

Just noticed that a question about time arithmetic was first responded to by a poster name TimeKeeper. What are the odds?
Quote from: Sidewinder on April 26, 2011, 06:46:27 AM

Just noticed that a question about time arithmetic was first responded to by a poster name TimeKeeper. What are the odds?

Considering that was really Billrich, who needs to craft a new fake name every time he posts, this is not much of a coincidence.
8800.

Solve : editing dos when no hard drive is used?

Answer»

I am running a GAME that is dos based. No hard drive. Only a cdrom used.Dos 6.2. The boot info is on the cd. I need to EDIT something in the config.sys but cant get to it. At dos promt, is says its located in a:\ dir. cd is located in c:\. I assume the a: is the ram drive and the info is located on the ram.
when I try a:\ edit config.sys, I get invalid drive in search path. When I try a:\ dir, I can see all the dos filesConfig.sys is only used once, immediately after startup, to setup DOS.Any changes you make to a file in a RAM drive will be lost after you reboot. ANYHOW, the config.sys file being used is on the CD-ROM, which as you will know, is read-only.

thanks for that info. So i guess I should back up. This UNIT worked fine until battery died and lost cmos settings. now when boot up I get "unable to set page frame address--EMS unavailable"
Emm386 loaded
extended memory service unavailable
emm386 active
access denied
extended error 65