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.

4801.

Solve : Display special char in env variable??

Answer»

Win2k Sp.4 - Cmd.exe

Code: [Select]@echo off
cls
set a=

set a=%1
echo %a%
This code works if %1 is say -10 or +10 but if %1 is =10 the "=" is not displayed. I assume this is because the char needs to be escaped in the Echo statement but how to do that

Thanks.
Quote from: Hedonist

I assume this is because the char needs to be escaped in the Echo

When you assume....

It's no good trying to escape the vanished character in the batch, because cmd.exe has already stripped it off. You could protect it by wrapping the whole parameter in quotes and then using the ~ variable modifier in the batch to take them off.

Showme.bat

Code: [Select]@echo off
set parameter=%~1
echo parameter is %parameter%

Output of Showme.bat

Code: [Select]S:\Test\Batch>showme "=1"
parameter is =1
The ~ variable modifier strips any surrounding quotes (if present) from a loop variable or from a passed parameter.

It is documented in the help for FOR, so type FOR /? for details.

THis method doesn't work with all problem characters, for EXAMPLE &.



Thank you Dias.

In a reply on post #68095 you escaped all of the ( and ) characters Quote
echo Yesterdate = (Date^(^)- 1^)>yesterday.vbs
echo Yyyy = DatePart^("YYYY", Yesterdate^)>>yesterday.vbs
echo Mm = DatePart^("M" , Yesterdate^)>>yesterday.vbs
echo Dd = DatePart^("D" , Yesterdate^)>>yesterday.vbs

Is there a SPECIAL reason for doing this?The batch file in question works fine without those carets, as I have just now discovered. There are other situations where you do need to escape parentheses so I have GOT in the habit of doing so. If a parenthesis doesn't need ESCAPING, it does no harm to escape it, whereas a parenthesis that should be escaped, but isn't, causes an error.

In the code below, the regular expression passed to SED contains parentheses, and because the command invoking SED is inside the parentheses of a FOR command, they need escaping to stop cmd.exe borking.

@echo off
setlocal enabledelayedexpansion
for /f %%i in (qd.txt) do for /f %%J in ( ' echo %%i ^| sed -e
s/.*\x22\^(.*\^)\x22.*/\1/ ' ) do set yfn=%%j



Thanks again. I understand the need for escaping character(s) in the For command, just couldn't get to grips with escaping ( and ) in the Echo command.

4802.

Solve : error 53 & 6118?

Answer»

Hi on a small 3 machine network (2 winxp pro, 1 msdos 6) in a remote office the primary xp2 PC power supplied FAIL. Upon delivering the new PC with the same name and workgroup I'm unable to connect to the share created on the xp from the dos pc.
From the net config I can confirm the workgroup name though when I attempt to map the share net use x: \\pcname\sharename I receive an error 53 the computer name specified in the net path can not be located. When I attempt net view I get returned error 6118 The LIST of servers for this workgroup is not available.
Any help would be appreciated.XP Firewall blocking?

Quote

xp2 PC power supplied fail. Upon delivering the new PC with the same name and workgroup I'm unable to connect to the share created on the xp from the dos pc.

Disable firewall if safe to do so and test with firewall disabled.Thanks Dave, XP Firewall is disabled. set netbios\tcpip, changed from default, created an lmhost file, confirmed net\system.ini workgroup
Hi, This issue has become a MUTE point, looking further in the issues finding a variety of other pieces of equipment failures potenially related to power, surge? lightning? Time the remote office updated, the last 486.
Thanks for the consideration.
4803.

Solve : edit to yesterday's date?

Answer»

Hi there,
The following code copy some files from one location to another and put them in TODAYS named folder.
Instead of creating today's date, i want to make it yesterday's date.
Here is the code:

Code: [Select]@echo off
setlocal

for /F "tokens=1-6 delims=/:." %%T in ("%date:~4%.%time: =0%") do set timestamp=%%V%%U%%T-%%W.%%X

xcopy "C:\Documents and Settings\user\Desktop\allbackups" "C:\Documents and Settings\user\My Documents\TrainingLog\%timestamp%\" /C /H /R /Y /Z
Thanks in advance


This code (courtesy scripting guru Dias de Verano) will produce yesterday's date. You may have to alter the script to suit your date format.

Code: [Select]@echo off
echo wscript.echo ^(Date^(^)- 1^)>yesterday.vbs
for /f %%a in ('cscript //nologo yesterday.vbs') do set ydate1=%%a
del yesterday.vbs

set ydate1=%ydate1:/=%

set m=%ydate1:~0,2%
set d=%ydate1:~2,2%
set y=%ydate1:~4,4%
set ydate2=%y%%m%%d%
echo yesterday was %ydate2%

Good luck.Quote from: Dusty on October 10, 2008, 03:13:54 AM

You may have to alter the script to suit your date format.

New! Improved! You won't have to alter this, it is independent of date format settings. You can fool around with the variables to make different strings as you can see in the 3 examples at the bottom.

Code: [Select]@echo off
echo Yesterdate = (Date^(^)- 1^)>yesterday.vbs
echo Yyyy = DatePart^("YYYY", Yesterdate^)>>yesterday.vbs
echo Mm = DatePart^("M" , Yesterdate^)>>yesterday.vbs
echo Dd = DatePart^("D" , Yesterdate^)>>yesterday.vbs
echo Wscript.Echo Yyyy^&" "^&Mm^&" "^&Dd>>yesterday.vbs

FOR /F "tokens=1,2,3 delims= " %%A in ('cscript //nologo yesterday.vbs') do (
set /a Year=%%A
set /a Month=%%B
set /a Day=%%C
)

if %Month% LSS 10 set Month=0%Month%
if %Day% LSS 10 set Day=0%Day%

REM Examples
echo (1)
echo.
echo Yesterday was:
echo.
echo Year : %Year%
echo Month : %Month%
echo Day : %Day%
echo.
echo (2)
echo.
echo %Day%/%Month%/%Year%
echo.
echo (3)
echo.
echo %Year%%Month%%Day%
echo.
Output today Friday 10/10/2008:

Code: [Select](1)

Yesterday was:

Year : 2008
Month : 10
Day : 09

(2)

09/10/2008

(3)

20081009Ahhh Dias...

Quote
O Lord my God, When I in awesome wonder,
Consider all the scripts Thy Hands have made;
I see the stars, I hear the rolling thunder,
Thy power throughout the internet displayed.

Then sings my soul, My Saviour God, to THEE,
How great Thou art, How great Thou art.
Then sings my soul, My Saviour God, to Thee,
How great Thou art, How great Thou art!

Although it is -- of course -- immensely flattering to be likened to God, modesty insists that I must decline such a comparison.

By the way, if you want to just keep Yesterday.vbs somewhere and call it when you need it, rather than create it from a batch script, it looks like this

Code: [Select]Yesterdate = (Date()- 1)
Yyyy = DatePart("YYYY", Yesterdate)
Mm = DatePart("M" , Yesterdate)
Dd = DatePart("D" , Yesterdate)
Wd = DatePart("W" , Yesterdate)
Wscript.Echo Yyyy&" "&Mm&" "&DdThank you for that but your elevated status is hereby revoked 'cos I couldn't get your New! Improved! version to perform.

I think this line:Quote
FOR /F "tokens=1,2,3 delims= " %%A in ('yesterday.vbs //nologo') do (

should be: Quote
FOR /F "tokens=1,2,3 delims= " %%A in ('cscript //nologo yesterday.vbs') do (



You are right - It depends on which of the two scripting hosts is the default on your system, cscript or wscript. On mine it is cscript, so I can just do...

Code: [Select]scriptname.vbs //nologo
...or even (assuming the script file has the .vbs extension)...

Code: [Select]scriptname //nologo
...from a batch WITHOUT having to specifically mention cscript.exe, but I forgot that on systems where the other host is the default it would have to use your line, so it is better (more UNIVERSAL) to do it that way, so I have edited the script above.

Incidentally, if you get bored with adding //nologo every time, you can make cscript save it as a per-user preference by using it just once with the //S switch when you run a script (any script, it applies to all scripts run with cscript by that user after that, until you change it back again by using //S with //logo)

Before (Windows default):

Code: [Select]S:\Test\Batch\Yesterday>yesterday
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

2008 10 10 6
Set //nologo as user's cscript default:

Code: [Select]S:\Test\Batch\Yesterday>cscript //nologo //s yesterday.vbs
Command line options are saved.
2008 10 10 6
After:

Code: [Select]S:\Test\Batch\Yesterday>yesterday
2008 10 10 6

To change it back again:

Code: [Select]S:\Test\Batch\Yesterday>cscript //logo //s yesterday.vbs
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

Command line options are saved.
2008 10 10 6
Back the way we were...

Code: [Select]S:\Test\Batch\Yesterday>yesterday
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

2008 10 10 6
4804.

Solve : Set second line of a file as a variable.?

Answer»

Just as I IMAGINED what WENT wrong.
Good WORK, and THANKS again.

4805.

Solve : Usb Security?

Answer»
Right now try to make usb security software like my pendrive vol is "Volume Serial Number is 2404-3726" if the

vol no. "2404-3726" match then it open other wise it can't open so no one can load virus in my system it is possible in DOS

or any other language pls help me.
What? Do you have any code already?

I'm not sure how to dismount the flashdrive and only re-mount it when the correct password is entered.

This is my "code":

Pseudo dismount %~d
Set /P volinp=Volume Number:
If "%volinp%"=="volume number here" pseudo mount %~d

No no not like this we not enter the number like passwords but it match internali if vol no. match then it open other wise eject.

or possible in other langage pls help ...So your saying something like this pseudo-code?

On USB.INSERT If USB.VOLUME EQU VOLUMENUMBR THEN (exit) ELSE (USB.EJECT=true)
yes3 words. Not in BATCH.

So in which language is this 3 word is haveQuote from: Deadly D on September 08, 2009, 09:38:04 PM

So in which language is this 3 word is have
http://www.cprogramming.com/smeezekitty- offer a demonstration.ok then
Code: [Select]#include <iostream.h> //some COMPILERS use iostream some iostream.h
#include <Stdio.h>
#include <stdlib.h>
#include <string.h>
#define _S "<proper serril number here>"
int main(){
int i;
char line[60];
char ser[30];
system ("dir X:\*.pes >_temp.tmp"); //change X to the proper drive letter
FILE *f = fopen("_temp.tmp", "r");
fgets(line, 0xFFF, f);
fgets(line, 0xFFF, f);
//fgets(line, 0xFFF, f) //NEEDED?
while(line[25+i]){ser[i]=line[25+i]; i++;} //change 25 to the OFFSET of the seril number (25 should be ok)
ser[i]=0;
fclose(f);
system("del _temp.tmp");
cout<<"Number of volume:" <<ser <<endl;
if(strncmp(ser, _S, strlen(_S)) == 0){cout<<"OK!\n";} else {/*eject code here*/}
return 0;
}


Thanks for replay @[emailprotected] but can possible to find serial no of pen drive and match.maybe BC_programmer (my buddy i argue with) can help
4806.

Solve : Do Loop??

Answer»

I am trying to perform a function that will send out an email and retry the function until it passes my condition. It has been a few years since I have used batch commands and I am in need of some help. Here is what I have so far:

:START

(I have other criteria here that will run what I need)


if %errorlevel% GTR 0 goto fail

:fail
C:\Email.bat [emailprotected] "Execution Failed" "The scheduled JOB failed to execute"

goto startand whats EXACTLY wrong with that ?You do not have a for loop which contains "DO" You have A GOTO loop. Goto start needs to be directly after the test condition. The order of test and and Goto start that you have allows :fail to execute regardless of the test condition.

Quote

:start

(I have other criteria here that will run what I need)


if %errorlevel% GTR 0 goto fail

:fail
c:\Email.bat [emailprotected] "Execution Failed" "The scheduled job failed to execute"

goto start

C:\&GT;cat gostart.bat
Code: [Select]@echo off

:start

echo Enter errorleve

set /p errorlevel=



if %errorlevel% GTR 0 goto fail

goto start

:fail
REM c:\Email.bat [emailprotected]

echo "Execution Failed" "The scheduled job failed to execute"

goto start
C:\> gostart.bat
Output:

Enter errorleve
-10
Enter errorleve
0
Enter errorleve
66
"Execution Failed" "The scheduled job failed to execute"
Enter errorleve
2
"Execution Failed" "The scheduled job failed to execute"
Enter errorleve
-7
Enter errorleve
4807.

Solve : Kill an application started through a Novell Client running in Windows XP?

Answer»

Dear all,

How do I kill an application running in Windows XP, that was started through a Novell Client net, using a batch file?
The command Taskkill /f / im [image name] doesn't work.

Thanks for your helptaskkill /f /im imagename


k first off , /F and /IM are both written beside the slash

taskkill /F /IM Imagename.exe

if you cant taskkill with the image name, type tasklist Notice under the PID column the PID NUMBER and use this example, 1000 is the example pid number


TASKKILL /F /FI "PID ge 1000"

I suspect that Windows can only see the Novell client and not the task running inside the Novell environment. This would be similar to the Windows command shell where Windows can see the shell program but not individual programs running within the shell. You MAY have to kill your program from within the Novell environment.


Hi guys!

Thank you for helping me to solve my problem.
Both hints were very helpfull.
The taskkill /f /im wasn't working because XP and MS DOS "see" different things.
XP "sees" the "real name" of the application as SHOWN on the XP Task Manager box.
MS DOS, on the other hand, "sees" the same application but with a general application name "ntvdm.exe".
The tasklist command ENABLED me to FIGURE out this difference and get the actual image name of the application "seen" by MS DOS: ntvdm.exe.
With the right im the taskkill /f /im command worked perfectly and properly.
Thank you very much.

4808.

Solve : Copy contents of file1,file2 into file3?

Answer»

Sir,
I want to add contents of file1.txt , file2.txt and file3.txt into file4.txt
File1.txt & File3.txt has DATA BUT file2.txt has no data i,e. that is blank
1. When I type COPY FILE1.TXT + FILE3.TXT FILE4.TXT
I find exact result and file4.txt receives all data of file1.txt and file3.txt
BUT
2. When I type COPY FILE1.TXT + FILE2.TXT + FILE3.TXT FILE4.TXT
I find NO result and file4.txt receives NOTHING i,e. all data of file1.txt and file3.txt
is not copied in file4.txt

My PROBLEM : I have to include also those files which have no data because there are several files and these are to be copies in a single file through batch file.
How can I get correct result by adding files having data and having no data

Your' sincerely
Lohanione WAY, would be to create temporary files to merge the results of multiple copy commands.


Code: [SELECT]copy file1.txt+file2.txt tempout.tmp
for %%P in (<list of remaining files>) do
(
copy tempout.tmp+%%P tempout2.tmp
erase tempout.tmp
ren tempout2.tmp tempout
)
redirect > and append >> will also work.

C:\>type file1.txt > file4.txt

C:\>type file2.txt file3.txt >> file4.txt

4809.

Solve : Help from DOS Expert?

Answer»

I am facing probelm in applying the following DOS Commands.

Please help me with EXAMPLES that I can use with my Windows XP OS.

backup

graphics

print

format

xcopy

restore

chkdsk

command

diskcopy

rmdir

ren

ATTRIB

append

Please EXPLAIN me each command with applicable examples.

Thanks

Ashfaq KarachiWelcome to the CH forums.

At the command prompt enter the command followed by /? to view the command syntax. e.g. attrib/?

You can also find all commands listed here.. Most have examples.

Backup info can be FOUND on this MS site.

4810.

Solve : available diskspace?

Answer»

Hi,
is there a COMMAND in MS DOS that retrieves the available space of a disk drive?

This value I want to use in a batch file (login script).

Thank you for tipps.the closest thing i can find is the DIR command.

see it hereCode: [Select]for /f "tokens=1-3 delims= " %%F in ('dir /-c ^| find "bytes free"') do SET DRIVESPACE=%%H
This will retrieve the string, but you cannot use any value over 4 GB as a NUMERICAL variable because NT command interpreter is limited to 32 bits of precision.

4811.

Solve : Fdisk - problems with extended dos partition?

Answer»

It all started with windows vista trying to UPDATE 3 updates and could only complete 2 and the third was trying but kept restarting and saying the same thing. Had a feeling it was something to do with clashing with avg. Anyway had enough of trying to get it to load windows and had nothing but trouble from vista not showing pages over the internet and not compatible with things, so decided to change back to windows XP, but because of this extended dos partition it has not allowed it. I have been through the wars with this laptop, believe me this is the last resort before i smash it to smitherines lol.

Trying to delete an extended partition, it is a fixed disk drive. It is the only thing left to delete. It says 'no logical drives defined' and 'all logical drives DELETED in the extended dos drive'. I have tried to delete from 1-4 of the options in fdisk. I cannot format and i think it is due to this, as when i GOT the computer it had dvd direct 3 on it and a long story but this has brought me to this predicament. Can anyone help me? It would be very much appreciatedHave you tried to recreate the primary partition and delete the extended partition ? ?
Could this be a hidden Recovery partition ? ?Quote from: patio on September 08, 2009, 09:10:03 AM

Have you tried to recreate the primary partition and delete the extended partition ? ?
Could this be a hidden Recovery partition ? ?

Yes it may well be a hidden recovery partition, but because of this i don't SEEM to be able to format the drive. I have created a partition and tried to delete it but it does not seem to MOVE and when i have loaded up windows vista and xp they won't install, it comes up errors cannot copy this file etc. has 4% of Usage on it and i'm not certain but it had media direct 3 on it, which is a program that lets you play dvd's. I don't know if that has any significance.
4812.

Solve : ö in path in batch file?

Answer»

I NEED to make a batch command which enters the date and time in a file. The actual batch file contains:

Code: [Select]date/t >"E:\Maraddata\Tingö\puc.txt"
time/t >>"E:\Maraddata\Tingö\puc.txt"
But using the ö, MS-Dos don't recognize it. Anybody who can help me o create this text file with date and time in this "Tingö" folder???


Note that the command is running at a server with Win2003 installed.
cmd.exe recognizes the ö charachter
the PROBLEM is your using quotations

This works..
date/t >E:\Maraddata\Tingö\puc.txt
time/t >>E:\Maraddata\Tingö\puc.txt




This Doesnt..
date/t >"E:\Maraddata\Tingö\puc.txt"
time/t >>"E:\Maraddata\Tingö\puc.txt


I expect you didn't try it in a batch file. Because it doesn't work...

Executing the batch file, the results:

Code: [Select]E:\Maraddata\Tingö>date/t >E:\Maraddata\Ting÷\puc.txt
The system cannot find the path specified.

E:\Maraddata\Tingö>time/t >>E:\Maraddata\Ting÷\puc.txt
The system cannot find the path specified.
Please note the ÷ INSTEAD of the ö

I see what you mean, ok .. i played around with it for a while and this is what i CAME up with

@echo off
cd\
if not exist %systemdrive%\maraddata mkdir %systemdrive%\maraddata
cd %systemdrive%\maraddata
for /f "tokens=1*" %%a in ('dir /a:d ting* /b') do cd %%a
date/t >.\puc.txt
time/t >>.\puc.txt
if the tingö folder exists it will work, otherwise create it manually first from the lineThank you!

But...

When I execute the batch file from the command line, no problem.
But if the batch-file is executed by another process (a mail-client software program), i get the following: (I removed the @echo off)


Code: [Select]C:\Documents and Settings\Administrator>cd\

C:\>cd E:\Maraddata

C:\>for /f "tokens=1*" %%a in ('dir /a:d ting* /b') do cd %%a
File not found

C:\>date/t 1>.\toc.txt

C:\>time/t 1>>.\toc.txt
?and Tingö folder existsthe folder wasnt found because the folder didnt change, try this instead



cd\maraddata
for /f "tokens=1*" %%a in ('dir /a:d ting* /b') do cd %%a
date/t >.\puc.txt
time/t >>.\puc.txt


Still not succeeded.

I can change the folder WITHIN the C-drive. But I failed to switch over to my E-drive
oh, sorry i didnt realize E: wasnt your systemdrive,

HEres another way

E:
cd\maraddata\ting?
date/t>.\puc.txt
time/t>>.\puc.txt
Right! Thanks, it works!no problem and welcome to the forums

4813.

Solve : Running 2 programs simultaneously in a batch file?

Answer»

How do I execute a video clip (GIF) and a sound clip (AMR) SIMULTANEOUSLY in a batch file? Is it POSSIBLE? It is possible to run both in Windows at the same time.You can run them both, but you can't start them at the same time together.

Code: [Select]start videoclip.gif
start soundclip.amrThanx Macdad, MUCH APPRECIATED.

4814.

Solve : XP/DOS Dual boot?

Answer»

Hi all,

I am trying to create a Windows XP/DOS dual boot machine. So far, I have done the following:

1. Windows XP was ALREADY installed, so I created a new PRIMARY FAT partition using Partition Magic

2. I installed DOS 7.10 onto the new partition

3. I edited the boot.ini file in Windows, and it now reads:

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect
multi(0)disk(0)rdisk(0)partition(2)\DOS71="MS-DOS" /noexecute=optin /fastdetect

When I boot up and select the MS-DOS OPTION, I get the following error message:

"Windows could not start because the following file is missing or corrupt:
\system32\hal.dll.
Please re-install a copy of the above file."


Any ideas??

Cheers

Nick




If I recall correctly, DOS has to be installed in the first physical partition. As long as you have Partition Magic, you can FREE some space before the XP partition and create your DOS partition there.

Good luck. I see, I have DOS installed in a partition after XP. I'll start again...

4815.

Solve : using XCOPY when directory has a space in name?

Answer»

I got the "START" command to work when the APP name has a space in it, but now having the same problem with XCOPY. The DIRECTORY I want to copy has a space in it (Ham Radio) and the command fails. The same fix USED for START doesn't seem to apply to XCOPY.
Trying to set up a batch file that will copy this dir and sub-dirs to another drive (XCOPY C:\Ham Radio D:\Ham Radio)

Thanks in advance!
Doc
If you are USING DOS/Batch programs with a space in a path then you need to put "" around the path e.g. Code: [Select] Xcopy /s "c:\ham radio" "D:\Ham radio"
also the '/s' switch copies all subfolders including empty ones.

FBThanks! I don't think I tried that COMBINATION of quotes. Will give it a shot when I get home thisafternoon!

That did it!

Thanks again!

4816.

Solve : Batch w/ wildcard using external data from text file?

Answer»

I'm trying to figure out a means to copy a single file from one location on to multiple workstations, but because the workstation names might change I want to put the names in a text file for the batch to take to plunk into the command.

Something like

:start
get computername starting with line 1 from text file
:process
xcopy C:\filename.txt \\%computername%\folder
get next computername from text file
if last computername goto end
goto process
:end

(robocopy might WORK better for this instead of xcopy)

In the text file will have one column like:

abc
abb
acc
etc...

Any sort of pointers would help greatly. Something along these lines perhaps?

Code: [Select]for /f "delims==" %%A in (file.txt) do (
xcopy c:\filename.txt \\%%A\folder
)

This FOR loop reads each line in turn from a text file called file.txt and substitutes that line for the computername in the xcopy command which is then executed
That SEEMS to work. Thanks!

I tested this for another task, to rename a folder on muliple workstations and did it for one and worked like a charm. I'll do the file copy next once I get this task done...

Now I just need to figure out 'upon ERROR' goto next computer in case the pc is down and somehow report the missing computer.Quote from: Relig on September 04, 2009, 04:59:17 PM

Now I just need to figure out 'upon error' goto next computer in case the pc is down and somehow report the missing computer.

what you could try and do is ping each computer and use the errorlevel to tell if the system is on or not. if the system is off then echo the computer name into a text file on the host (the system the batch is running on).
4817.

Solve : move command using batch file help?

Answer»

Hello all, I am a beginner using MS-dos so i might not know all the exact terms used to describe my problem.

I am working on a batch file to move large amounts of files, the issue I am having is that dos picks up a syntax error when it reaches a document or folder name that has spaces in it such as (C:\WINDOWS\Connection Wizard) the space in between connection and wizard would set off this error

My QUESTION is if there is anyway around this?

Thank you.

my second post, reply # 2, has updates to my situation.well what you could do is use the /s sysntax:

Code: [Select]XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
[/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
[/EXCLUDE:file1[+FILE2][+file3]...]

source Specifies the file(s) to copy.
destination Specifies the location and/or name of new files.
/A Copies only files with the archive attribute set,
doesn't change the attribute.
/M Copies only files with the archive attribute set,
turns off the archive attribute.
/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string
should be in a separate line in the files. When any of the
strings match any part of the absolute path of the file to be
copied, that file will be excluded from being copied. For
example, specifying a string like \obj\ or .obj will exclude
all files underneath the directory obj or all files with the
.obj extension respectively.
/P Prompts you before creating each destination file.
/S Copies directories and subdirectories except empty ones.
/E Copies directories and subdirectories, including empty ones.
Same as /S /E. May be used to modify /T.
/V VERIFIES each new file.
/W Prompts you to press a key before copying.
/C Continues copying even if errors occur.
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.
/Q Does not display file names while copying.
/F Displays full source and destination file names while copying.
/L Displays files that would be copied.
/G Allows the copying of encrypted files to destination that does
not support encryption.
/H Copies hidden and system files also.
/R Overwrites read-only files.
/T Creates directory structure, but does not copy files. Does not
include empty directories or subdirectories. /T /E includes
empty directories and subdirectories.
/U Copies only files that already exist in destination.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/N Copies using the generated short names.
/O Copies file ownership and ACL information.
/X Copies file audit settings (implies /O).
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
/Z Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.
but you may run into the error:
Code: [Select]Cannot PERFORM a cyclic copy
0 File(s) copied
and to fix. create a new folder:
c:\files_to_copy

then in your batch file:
Code: [Select]xcopy /s c:\windows\files\*.* c:\files_to_copy\*.*thank you that seems like alot though just to make dos ignore that there are spaces within a folder or file name.
sorry that I did not post these up last night, I did not have access to these from my home computer, but these are actual codes im using for this batch file then running in dos and they do not seem anything near to what you wrote.
this code actually worked but not sure why
move G:\Adam-Invoice\Invoice.doc G:\FileStructure\QWI Manual\QWI 5- Purchasing\

this one did not work because it had a space in the folder name
move G:\Adam-Invoice\Cardinal Cogen-Invoice.doc G:\FileStructure\QWI Manual\QWI 5- Purchasing\

same as above
move G:\BETZ\GE Water Service Reports\Reports 2003\Cardinal Towers 1-9-03.doc G:\FileStructure\QWI Manual\QWI 6- Facility Operation\6.1 Facility Operations Standard\Reports\2003\Tower\

Just wondering if there is something more simple then the previous reply, or if there is some sort of compiler that i could use to make dos compatible with spaces within a file name.
thank you well what i was putting was:
Code: [Select]xcopy /s c:\windows\files\*.* c:\files_to_copy\*.*sorry I did not understand it at first but got it now. Thank you for all of your helpDOS does not understand spaces.

You NEED quotes.

e.g.
C:\Documents and Settings\Dad>DIR C:\Documents and Settings\Dad
The system cannot find the file specified.

add the quotes and you get
C:\Documents and Settings\Dad>DIR "C:\Documents and Settings\Dad"
Volume in drive C is ACER
Volume Serial Number is EC16-8702

Directory of C:\Documents and Settings\Dad

20/05/2003 18:31 2,682 launApp.log
06/06/2009 19:14 My Documents
12/06/2009 16:40 7,602,176 ntuser.bak
13/06/2009 11:58 6,815,744 ntuser.dat

Regards
Alan

4818.

Solve : Question about using batchfiles in Windows XP?

Answer»

Quote

when will you LEARN never give your stuff away
especially to the church

text - binary - hex

http://home2.paulschou.net/tools/xlate/Quote from: BatchFileBasics on September 07, 2009, 10:08:05 AM
text - binary - hex

http://home2.paulschou.net/tools/xlate/
I ALWAYS use that site for converting binary, hex, decimal etc. yea, it came in handy when my friend needed me to "decode" binary he got in a message

anyways.

i wonder where lufkincy isQuote
HEY bc_prog can you decode this:
Hey kitty, can you give a ONE LINE command that will decode what you just sent to BC ?
Well, maybe three or four lines.
4819.

Solve : processing arguments in batch file?

Answer»

processing ARGUMENTS in batch file

Hi all,
I'm playing with this a bit now and I have come up with this so far!


::Script that processes arguments
::If you don't have Notepad++ or something like that this could be really hard to read through
::
@ECHO OFF
:: Make variables local and clear unwanted variables
SETLOCAL
:: Create variables that comments out parts in script
SET ##=::
SET ###=
:: Save the script filename value to variable
SET SCRIPTNAME=%~nx0
SET HELP=
SET PRINTVAR=
:: Set default value for %COMMAND%
SET COMMAND=test_Robocopy
SET NETUSE=
SET logfile=
SET eMail=
GOTO :MAIN

:LOOPARGS
%##% :LOOPARGS START
IF NOT "%1"=="" ( SET x=%1 ) ELSE (( SET HELP=:HELP)&(GOTO :EOF))
IF "%1"=="debug" ( SET PRINTVAR=:PRINTVAR & SET ##=ECHO .)
IF "%x:~0,6%"=="email:" ( IF DEFINED eMail (SET eMail=%x:~6%,%eMail%) ELSE (SET eMail=%x:~6%) )
IF "%X:~0,8%"=="logfile:" SET logfile=%x:~8% & SET ROBOLOGFILE=/LOG:%logfile%
IF "%x:~0,7%"=="source:" SET SOURCE=%x:~7%
IF "%x:~0,5%"=="dest:" SET DESTINATION=%x:~5%
IF "%x:~0,9%"=="source_u:" SET SOURCE_U=/USER:%x:~9% & SET NETUSE=:NETUSE
IF "%x:~0,9%"=="source_p:" SET SOURCE_P=%x:~9% & SET NETUSE=:NETUSE
IF "%x:~0,7%"=="dest_u:" SET DESTINATION_U=/USER:%x:~7% & SET NETUSE=:NETUSE
IF "%x:~0,7%"=="dest_p:" SET DESTINATION_P=%x:~7% & SET NETUSE=:NETUSE
IF "%x:~0,8%"=="command:" SET COMMAND=%x:~8%
IF "%1"=="/help" SET HELP=:HELP
IF "%1"=="help" SET HELP=:HELP
IF "%1"=="/?" SET HELP=:HELP
IF "%1"=="--help" SET HELP=:HELP
IF NOT "%2"=="" SHIFT & GOTO :LOOPARGS
%##% :LOOPARGS END
GOTO :EOF

:NETUSE
%##%:NETUSE START
:: Check if Source is network path
IF "%SOURCE:~0,2%"=="\\" NET USE %SOURCE% %SOURCE_U% %SOURCE_P% || IF DEFINED logfile ECHO connecting to %SOURCE% faild>>%logfile%
:: Check if Destination is network path
IF "%DESTINATION:~0,2%"=="\\" NET USE %DESTINATION% %DESTINATION_U% %DESTINATION_P% || IF DEFINED logfile ECHO connecting to %DESTINATION% faild >>%logfile%
%##%:NETUSE END
GOTO :EOF

:eMail
%##%:eMail START
ECHO Sending email to %eMail%
%##%:eMail END
GOTO :EOF

:PRINTVAR
%##%:PRINTVAR START
IF DEFINED eMail ECHO email:%eMail%
IF DEFINED logfile ECHO logfile:%logfile%
IF DEFINED SOURCE ECHO source:%SOURCE%
IF DEFINED DESTINATION ECHO dest:%DESTINATION%
IF DEFINED SOURCE_U ECHO source_u:%SOURCE_U%
IF DEFINED DESTINATION_U ECHO dest_u:%DESTINATION_U%
IF DEFINED SOURCE_P ECHO source_p:%SOURCE_P%
IF DEFINED DESTINATION_P ECHO dest_p:%DESTINATION_P%
IF DEFINED COMMAND ECHO command:%COMMAND%
%##%:PRINTVAR END
GOTO :EOF

:HELP
%##%:HELP START
ECHO.Processes arguments in batch-script
ECHO.%SCRIPTNAME% [arguments]
ECHO.email:[email:[emailprotected]] [email:[emailprotected] email:[emailprotected]]
ECHO.Includes emailaddress to report to. You can have more than one
ECHO.logfile:[logfile:%temp%\%~n0.log]
ECHO.Includes logfile to print to
ECHO.source:[source:\\computername\share] [%temp%\tempfolder1]
ECHO.Files to work with
ECHO.dest:[dest:\\computername\share] [%temp%\tempfolder2]
ECHO.Destination to put files in
ECHO.source_u:[source_u:admin]
ECHO.Username for remote share
ECHO.source_p:[source_p:adminpassword]
ECHO.Password for remote share
ECHO.dest_u:[dest_u:admin]
ECHO.Username for remote share
ECHO.dest_p:[dest_p:adminpassword]
ECHO.Password for remote share
ECHO.command:[command:echo] [command:robocopy]
ECHO.The command you WANT! does the following: "command" "source" "destination" "/LOG:logfile"
ECHO.Default is test_Robocopy
ECHO.debug[debug]
ECHO.Prints out variables and locations in script
SET ###=::
%##%:HELP END
GOTO :EOF

:MAIN
%##%:MAIN START
:: Call :LOOPARGS procedure and process arguments
CALL :LOOPARGS %*
:: If source or destination neads password call procedure :NETUSE
IF DEFINED NETUSE CALL %NETUSE%
:: If argument "printvar" was GIVEN call procedure :PRINTVAR
IF DEFINED PRINTVAR CALL %PRINTVAR%
:: If help is needed call procedure :HELP
IF DEFINED HELP CALL %HELP%
:: Execute command in new environment replace "CMD /C" with "START" to start separate shell
%###% CMD /C "%COMMAND% %SOURCE% %DESTINATION% >>%LOGFILE%"
:: If any email address was given then call procedure :eMail
IF DEFINED eMail CALL :eMail

%##%:MAIN END. THIS IS THE END OF %SCRIPTNAME%
:: Erase local variables and exit
ENDLOCAL



4820.

Solve : Checking for SQL backups?

Answer»

Hi All

I have been asked come up with a way of automating check on sql 2000 backups.

I have the following so far...


cls
set DDate=%date:~0,2%
set MDate=%date:~3,2%
set YDate=%date:~6,4%
set backuppath=D:\SQL Server\Backup
set bkup=_backup_
set bkuptime=2230
set a=""

d:
cd\
cd D:\Notifications
:loop

echo 20 second intervals
echo Waiting for backup file last file check was at %time:~0,8%

for /f %%a in (livedbs.txt) do if EXIST "%backuppath%\%%a\%%a%bkup%%YDate%%MDate%%DDate%%bkuptime%.bak" goto cont
echo %%ERRORLEVEL%%
for /f %%a in (livedbs.txt) do echo %date% %time:~0,8% - %%a not backed up >> D:\Notifications\backuplog.txt

ping localhost -n 20 -W 10000 > nul

cls

goto loop

:cont
for /f %%a in (livedbs.txt) do echo %date% %time:~0,8% - %%a backedup email sent >> D:\Notifications\backuplog.txt

And works.... well sort of, if only one of the databases listed in the livedb.txt is true it bombs out stating that all database have backed up.

in otherwords its not looping to check all are ok.

How can i make this script work or do i need another approach?XCOPY /M will probably do all the work for you without a script.

It will copy all the files whose Archive BIT is set, and also clear that bit so it will not copy it again.

There may be something special about SQL, but normally it is expected that if a file is updated with different information, the Archive bit will be set as the NEW information is written, and then any backup archiving SYSTEM such as XCOPY will know that the old backup is out of date.

Use "XCOPY /?" to see the relevant help file with many other useful option switches.

Regards
Alan

4821.

Solve : How to list all the partitions in the system ??

Answer»

I want a command to list all the partitions in the system, so it tells me in a small list what partitions are, with their labels.
Like:
c: My Disk
d: Vista

Is there something like that inside DOS ? actually I want this to use it with Windows 7 PE cmd shell, not real DOS.Have a LOOK at this: http://tinyurl.com/kpd4oh

Don't think it SHOWS labels but it might help a bit
http://support.microsoft.com/kb/309000

Quote

How to use Disk Management
To START Disk Management:
Log on as administrator or as a member of the Administrators group.
Click Start, click Run, type compmgmt.msc, and then click OK.
In the console tree, click Disk Management. The Disk Management window appears. Your disks and volumes appear in a graphical view and list view. To customize how you view your disks and volumes in the upper and lower panes of the window, point to Top or Bottom on the View menu, and then click the view that you want to use.
not even close to what the op wants bill...Quote from: BatchFileBasics on September 06, 2009, 10:54:04 AM
not even close to what the op wants bill...

You are right. I will erase my post. Your answer is much better.

Thanks for the help.if you noticed, i didn't post an answer because its just about

Quote from: camerongray on September 06, 2009, 09:13:43 AM
Have a look at this: http://tinyurl.com/kpd4oh

Don't think it shows labels but it might help a bit

Code: [Select]C:\Documents and Settings\Owner>diskpart

Microsoft DiskPart version 5.1.3565

Copyright (C) 1999-2003 Microsoft Corporation.
On computer: CHRIS-COMPUTER

DISKPART> list volume

Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 D DVD-ROM 0 B
Volume 1 F DVD-ROM 0 B
Volume 2 C Hard Drive NTFS Partition 74 GB Healthy System
Volume 3 G Removeable 0 B
Volume 4 H Removeable 0 B
Volume 5 I Removeable 0 B
Volume 6 K Removeable 0 B

DISKPART>It will show Volume labels if they are assigned...Quote from: BatchFileBasics on September 06, 2009, 01:50:42 PM
if you noticed, i didn't post an answer because its just about

Code: [Select]C:\Documents and Settings\Owner>diskpart

Microsoft DiskPart version 5.1.3565

Copyright (C) 1999-2003 Microsoft Corporation.
On computer: CHRIS-COMPUTER

DISKPART> list volume

Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 D DVD-ROM 0 B
Volume 1 F DVD-ROM 0 B
Volume 2 C Hard Drive NTFS Partition 74 GB Healthy System
Volume 3 G Removeable 0 B
Volume 4 H Removeable 0 B
Volume 5 I Removeable 0 B
Volume 6 K Removeable 0 B

DISKPART>

WORKED, the diskpart is already included with the Windows 7 PE and it worked the very good way
thaaaankkks
4822.

Solve : How can FOR see Hidden files :- FOR %%A IN (*.XYZ) DO my_test %%A?

Answer»

I require "my_test" to process EVERY file with the extension XYZ.
Unfortunately some of them have the HIDE attribute set, and are not seen by FOR.

I can firstly do "ATTRIB -H" so that everything is visible,
but afterwards I would LIKE all attributes to be restored as they were,
i.e. only hiding the files which were previously hidden.

Several times I have driven myself to brain-fade by reading the extensive documentation upon FOR.
Every time a understand a little more, and then decide the reminder is tomorrow's MIGRAINE ! !

I would appreciate advice upon any of the special features and option switches that would help me,
or a "SUPER_FOR" command,
or perhaps a short and simple vb-script I could use that would find all files and invoke my_test.cmd upon each.

Regards
Alan
use attrib -h and get those hidden files to a new file...
after processing, read that new file line by line and attrib+h back Thanks, but I already stated I could use attrib -h.
I really need to use a suitable FOR option switch, or a vb-script.

I am exploring the habitat of system files;
the Windows version of the ancient mariners maps "where dragons be". ! !

File "permissions" can impose various restrictions,
and I suspect that I may be able to see the existence of some files,
but NOT make a copy (e.g. files like pagefile.sys)

Any change to any file may RESULT in System Restore intercepting and putting a copy in Restore.
When I ALLOWED Disc Cleanup to perform its default "compress old files",
Windows File Protection demanded my Windows Installation C.D. and would accept no excuses.
I really do not want to make Windows angry with me ! !

Regards
Alan

what about:

Code: [Select]for /f "tokens=*" %%A in ('dir *.XYZ /b /a') do my_test %%A
BC_Programmer

Thank you very much - Perfect Solution.

N.B. I have used DOS V3.32 onwards.
I have always used DIR * /A:-D to see all files regardless of attributes.
I was surprised by your use of /A.

I have now inspected DIR /? and can see that [:] is optional,
so /A:-D is the same as /AD
I can also see that no specific attribute needs to be included.
I was not aware this was optional.
I am surprised to observe that I can see all directories and files regardless of attributes with /A
Back to SCHOOL for me ! !

FOR /F %%A IN ('COMMAND') is something I had problems with some months ago.
I was never sure whether I should be using forward quotes or back quotes,
i.e. keyboard top left or just left of #

When I viewed FOR /? I saw
Quote

FOR /F ["options"] %VARIABLE IN ('command') DO command [command-parameters]
or, if usebackq option present:
FOR /F ["options"] %variable IN (`command`) DO command [command-parameters]
and I assumed the "usebackq option present" was something pre-existing, either by an option switch when launching CMD.EXE or by a registry hack.

I now realise, after scrolling down a page, it is not a pre-existing thing, but a special modifier within the optional options.

Time for my aspirins ! !

Thank you for your solution, which has led me into a less incomplete understanding of DIR and FOR.

Regards
Alan
4823.

Solve : Combining files?

Answer»

I know that two files can be combined or added with:
copy /b file.001 + file/002 outputfile

This is o/k for a couple of file. I have 99 files file.001 to file.099 to COMBINE. Is there a way place the above command in a loop to add them all together?
Thanksyou can do it the hard way. use wildcards
Code: [Select]copy file.0* newfile
copy file.1* anothernewfile
then combine the 2 new files togther again.Sometimes things turn out simple.
My files are about 5Mb each and the total of 99 files turned out to be only 1K, Something is not RIGHT. I tried:
copy /b file.0* newfile

This gives the correct size. I am not sure what the /b switch does, but I hope the file contents is correct.
ThanksQuote from: Frank on June 11, 2009, 05:34:27 AM

Sometimes things turn out simple.
My files are about 5Mb each and the total of 99 files turned out to be only 1K, Something is not right. I tried:
copy /b file.0* newfile

This gives the correct size. I am not sure what the /b switch does, but I hope the file contents is correct.
Thanks
check copy /? for what /b does. also, you can make small files and test them out. then you can see what the final file looks like. That's a good idea. I'll do that.
ThanksCOPY assumes text files, and will terminate at Control Z and anything ELSE which is not a normally printable character.

COPY /B is a BINARY copy, which duplicates every character regardless of whether it is printable.

COPY /B file.0* newfile
That will work, and is a great way to use up empty disc space.
It may however disappoint you, newfile will CONTAIN copies of files in the sequence that they are given by Windows.
If you want the contents of file.001 to be followed by file.002 etc etc you need to control the sequence.

Regards
Alan
@OP, if you can afford to install GNU tools (see my sig), common way to do it in *nix can now be done also on Windows
Code: [Select]c:\test> cat file.0* >> newfile.txt
4824.

Solve : dos command to strip leading zeros?

Answer»

i have files and i want them renames as such:
p000001.gif -> p1.gif
p000002.gif -> p2.gif
p000003.gif -> p3.gif
p000004.gif -> p4.gif
p000005.gif -> p5.gif
p000006.gif -> p6.gif
p000007.gif -> p7.gif
p000008.gif -> p8.gif
p000009.gif -> p9.gif
p000010.gif -> p10.gif
does anybody have a batch file or dos command (better) to do it?
Code: [Select]Set objFS=CreateObject("Scripting.FileSystemObject")
strFolder = "c:\test"
Set objFolder = objFS.GetFolder(strFolder)
For Each strFile In objFolder.Files
If objFS.GetExtensionName(strFile) = "gif" Then
strFileName = strFile.Name
strNum = Mid(strFileName,2,6)
strNum = strip(strNum)
strNewFileName = Mid(strFileName,1,1) & strNum & Mid(strFileName,8)
strFile.Name strNewFileName
End If
Next

Function strip(str)
s=""
For i=1 To LEN(str)
If Mid(str,i,1) <> "0" Then
s=s&Mid(str,i)
Exit For
End If
Next
strip=s
End Function

Code: [Select]c:\test> cscript /nologo myscript.vbs
didnt work ::
it didnt change anything
oh wait i didnt notice it the first time:
there was an error message
Microsoft VBScript runtime error object does no
support this property or method: 'strFile.Name'the problem area is
Code: [Select] strFile.Name strNewFileName i will leave it to you to find out. Hint: an OPERATOR is missingi tried = but it didnt work
i DONT LIKE vb or vb script so i dont know
never mind i got it -- there was a conflicting file in thereHere is a site that has lots of string manipulation for DOS.
http://www.dostips.com/DtTipsStringManipulation.php

From that site an example to replace a word in a LINE of text.
Code: [Select]set str=teh cat in teh hat
echo.%str%
set str=%str:teh=the%
echo.%str%
DOS Script Ouput
Quote

teh cat in teh hat
the cat in the hat

If you can understand that, then you can get rid of leading zeros by recursion. Or iteration.







Quote from: Geek-9pm on September 06, 2009, 07:43:31 PM
Here is a site that has lots of string manipulation for DOS.
http://www.dostips.com/DtTipsStringManipulation.php

From that site an example to replace a word in a line of text.
Code: [Select]set str=teh cat in teh hat
echo.%str%
set str=%str:teh=the%
echo.%str%
DOS Script Ouput
If you can understand that, then you can get rid of leading zeros by recursion. Or iteration.

thats neat






http://www.robvanderwoude.com/battech_leadingzero.php

Code: [Select]:Loop
IF "%Var:~0,1%"=="0" (
SET Var=%Var:~1%
GOTO Loop
)
4825.

Solve : Need a help for writing a batch script !!!?

Answer»

hi,
firstly am NEW into this batch scripting and am basically a UNIX guy !! (please dont hate me for this)

now have got a task of writing my first batch FILE ! well the problem am facing is as mentioned below !

i want to write a line as shown below into one file through a batch file

ECHO <stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ ARGUMENTS" value="-messagelog stdout -rulesfile &quot;\${resource_name}\&quot;"/> > test.xml

but am facing error when i run the above statement in my batch file as shown below !

The syntax of the command is incorrect.

i tried giving double quotes and single quotes in the echo statement as above , but then didnt work out ! i tried to figure out (still figuring out) on various online tutorials , but then no use, i see only a simple line being echoed into a file , no were i COULD find a explanation to echo a complaex line as above into a file.

your help in this REGARD would be highly appreciated ! < and > have special meaning in batch scripting. Use the caret to show where those CHARACTERS are not to be treated as special chars.

Quote

ECHO ^<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ ARGUMENTS" value="-messagelog stdout -rulesfile &quot;\${resource_name}\&quot;"/^> > test.xml

Then check the test.xml file to ensure the format is correct.

Good luck.

Edit: & Welcome to the CH forums.BINGO !!!! Thanks a lot Dusty !!
4826.

Solve : what is "setlocal enabledelayedexpansion"?

Answer»

I have been browsing TOPICS and all, and i USUALLY COME ACROSS

@echo off
setlocal enabledelayedexpansion
code
code
code

what does setlocal do?
i just don't really understandshouldn't you use google first?

4827.

Solve : Comparing extenions and executing.?

Answer»

So with my batch file, you are able to drag two files into it. But, I manually have to decide which file is which
( echo If you asm is first, type 1. If it is second, type 2.
echo.
echo %1
echo %2
echo.
echo ------------------
set choice=
set /p choice=
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto one
if '%choice%'=='2' goto two
echo "%choice%" is not valid please try again )

I was wondering if there was a way to compare extensions and execute accordingly.
example:
( if [%1]==[*.asm] go to one
)

please note that the above example does not work
The extension part of a file name, if present, including the dot, is extracted USING the ~xV variable modifier thus... (V=variable, in this case it is %~x1)

if [%~x1]==[.asm] go to one

If %1 = S:\test\batch\extest\tryme.bat, then...

~d1 drive letter and colon S:
~p1 path and folder \test\batch\extest\
~n1 name part of filename tryme
~x1 extension .bat

You can join them:

e.g. ~dpnx1 is S:\test\batch\extest\tryme.bat

These MODIFIERS also apply to FOR loop variables e.g. %%~nA

type FOR /? at prompt for FULL help

Im a bit baffled. I think.. So from my understanding, i use one of those variables with a numeral?

so to see if %1 is an asm file, I'd do this:
( if [%~x1]==[.asm] goto one
)
and to see if %2 is a smc file, I'd do this?:
( if [%~X2]==[.smc] goto two
)That is correct, but what are the red parentheses for?
to show code >.
Code: [Select]if [%~x1]==[.asm] goto one

4828.

Solve : chatting with CMD?

Answer»

hey guys
I'm trying to make a little CMD fun thing
I'm gonna add bunch of words and so it can reply to the user
OK

for ex, what command do i use for IF the user said blah or something, EX:
Code: [Select]IF hello=hello mate
IF what it is your name=Ashely, whats yours?
(ok right here, i need to put something that what ever the user says, it would reply back: cool name)
so u get the idea?
all those commands are wrong, i know, its what i need help with
i was looking hours for the right command to use, FIRST i thought choice, but then 1%
idk, helpp?

BTW please just don't reply: check the IF /? command
put this as an EXAMPLE:
Code: [Select]IF hello=hello mate
IF what it is your name=Ashely, whats yours?
(ok right here, i need to put something that what ever the user says, it would reply back: cool name)
out it in the right codes, and I'll get the right idea
thanks
how about...

Code: [Select] @echo off
echo What is your name?
set /p name=
echo welcome %name% cool name...

FBQuote from: fireballs on August 16, 2008, 05:17:00 AM

how about...

Code: [Select] @echo off
echo What is your name?
set /p name=
echo welcome %name% cool name...

FB
thanks, but thats only part of it
i need the user to start talking

so if they said Hi:
Hello
USER: What is your name?:
Ashely, and u?
set /p name=
echo %name% cool name...
echo so %name% hows ur day?
IF bad GOTO bad
IF good goto good

:bad
echo why?
(what ever they said here, it will reply Im sorry)


The PROBLEM with IF is that the user has an unlimited range of RESPONSES, choice might be better like so...

Code: [Select]Choice /N /C "GBA" /M "How was your day? Good? (G) Bad? (B) Alright? (A)"
if errorlevel 2 goto Label1
if errorlevel 3 goto Label2
if errorlevel 4 goto Label3
rem code here...

FBQuote from: fireballs on August 16, 2008, 05:30:43 AM
The problem with IF is that the user has an unlimited range of responses, choice might be better like so...

Code: [Select]Choice /N /C "GBA" /M "How was your day? Good? (G) Bad? (B) Alright? (A)"
if errorlevel 2 goto Label1
if errorlevel 3 goto Label2
if errorlevel 4 goto Label3
rem code here...

FB
ok, so far i got this:
Code: [Select]title Chat with CMD
@echo OFF
cls

echo Hello mate, what is your name?
echo What is your name?
set /p name=
echo welcome %name% cool name...
Choice /N /C "GBA" /M "How was your day? Good? (G) Bad? (B) Alright? (A)"
if errorlevel 2 goto Label1
if errorlevel 3 goto Label2
if errorlevel 4 goto Label3

:Label1
cls
echo why awesome?

:Label2
cls
echo why badd?

:Label3
cls
echo alright?
echo sounds like something is going on

pausebut it doesn't work at the choice, something wrong?what do you mean doesn't work? i might have gotten the errorlevels wrong try debugging...

Code: [Select]choice...blah blah

echo %errorlevel%sorry for some reason i skipped a number it should just be...

Code: [Select]choice...
if errorlevel 1 goto good
if errorlevel 2 goto bad
if errorlevel 3 goto alriteQuote from: fireballs on August 16, 2008, 05:55:55 AM
sorry for some reason i skipped a number it should just be...

Code: [Select]choice...
if errorlevel 1 goto good
if errorlevel 2 goto bad
if errorlevel 3 goto alrite
soo this:
Quote
title Chat with CMD
@echo OFF
cls

echo Hello mate, what is your name?
echo What is your name?
set /p name=
echo welcome %name% cool name...
Choice /N /C "GBA" /M "How was your day? Good? (G) Bad? (B) Alright? (A)"


if errorlevel 1 goto good
if errorlevel 2 goto bad
if errorlevel 3 goto alrite
:1
cls
echo why awesome?

:2
cls
echo why badd?

:3
cls
echo alright?
echo sounds like something is going on

pause

it suddently closes ok this works:Quote
title Chat with CMD
@echo OFF
cls

echo Hello mate, what is your name?
echo What is your name?
set /p name=
echo welcome %name% cool name...
pause
cls
ECHO so hows your day?
ECHO.
ECHO 1. Good
ECHO 2. Alright
ECHO 3. BAD
set choice=
set /p choice=
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto :1
if '%choice%'=='2' goto :3
if '%choice%'=='3' goto :2
ECHO "%choice%" is not valid please try again
:1
cls
echo why awesome?

:2
cls
echo why badd?

:3
cls
echo alright?
echo sounds like something is going on

pause
he is probably using XP and you Vista.
XP doesnt have choice.exe but Vista does thats the problem i think
4829.

Solve : Forcing wait-to-finish for each command in batch files?

Answer»

When running a batch file, each command does not seem to wait until a previous command has finished.

For example: Given the following code snippet, the test to see if DEST.DOC exists must not run until after the COPY command has completed.

Code: [Select]COPY /Y SOURCE.DOC DEST.DOC
IF EXIST DEST.DOC (
ECHO DEST.DOC EXISTS
) ELSE (
ECHO DEST.DOC DOES NOT EXIST
How can I program the batch file commands to wait-until-complete?

Thanks

-Mikeyou could always just set up a test kinda of like what you have but if the file dose not exist then you can goto the top and wait for a few seconds then try again.

example:

Code: [Select]
COPY /Y SOURCE.DOC DEST.DOC

:loop

ping -n 1 -w 3000 1.1.1.1 &GT; nul

IF EXIST DEST.DOC (
ECHO DEST.DOC EXISTS
) ELSE (
GOTO loop
)
Thanks wbrost,

Yes, I thought about doing something like what you suggest.

However, I've USED an option or something in the past WOULD instruct DOS not to proceed until the current command has completed.
I just can't remember what that option was.
It was something like placing a ; or something like this at the end of the command line.

Any one remember what this is?

Thanks

-MikeQuote from: Soniq2 on May 20, 2009, 01:06:48 PM

Thanks wbrost,

Yes, I thought about doing something like what you suggest.

However, I've used an option or something in the past would instruct DOS not to proceed until the current command has completed.
I just can't remember what that option was.
It was something like placing a ; or something like this at the end of the command line.

Any one remember what this is?

Thanks

-Mike
Start /wait commandORprogram

Will wait for the command or program to terminate before continuing. I'm not 100% sure that it works for commands, it should though.Hi everyone...

I'm a complete newbie to DOS...so please be gentle with technical terms...

I use PDMS at work and DOS/bat files set everything up...

The problem is I have a .bat file that fires up a simple PDMS .mac file...
The .mac creates a text file....
Then the idea was the original .bat would RENAME/MOVE this text file...

What I suspect is happening is that the .mac is creating the text file but my .bat file is carrying on and as there is no text file to RENAME/MOVE it's finishing...

Is there a way to say to DOS check/keep checking that C:\text.txt has been fully built and ready to be renamed...

I tried to use the suggestion on this post, see below :-

C:\AVEVA\pdms11.6.SP1\pdms.bat TTY SEA SYSTEM/XXXXXX /TEST/DESIGN $m/c:\PDMS\Run_Dice.mac

:loop

ping -n 1 -w 3000 1.1.1.1 > nul

if exist C:\AVEVA\pdms11.6.SP1\pdmsuser\dice.txt (

echo DOCUMENT exists

rename C:\AVEVA\pdms11.6.SP1\pdmsuser\dice.txt KUPE-DICE-CHECK.txt

MOVE C:\AVEVA\pdms11.6.SP1\pdmsuser\KUPE-DICE-CHECK.txt C:\PDMS\Results\Dice

) else (

echo document doesn't exist

go to loop

)

Cheers
NeilTry "calling" the first batch file.
Code: [Select]CALL C:\AVEVA\pdms11.6.SP1\pdms.bat TTY SEA SYSTEM/XXXXXX /TEST/DESIGN $m/c:\PDMS\Run_Dice.mac
Cheers That worked great....the code is now continueing...

The problem now is the code is continueing as I wanted...but by the time the code goes back to the .bat :-

if exist C:\AVEVA\pdms11.6.SP1\pdmsuser\dice.txt (
echo Document exists
rename C:\AVEVA\pdms11.6.SP1\pdmsuser\dice.txt KUPE-DICE-CHECK.txt

The file is in existance...but it's still been compiled...so cannot be coppied yet...

Is there a way to check the compiling is finished before it continues to the rename/move ?

Cheers
Neil

you could check to see if the process is still active using tasklist.

Code: [Select]tasklist /FI "imagename eq firefox.exe"

change firefox.exe to the name of what you are looking for. If you need to know run the process and watch task manager.Hi...thanks for the reply...not sure if I've included it into my code correctly...

But you are correct...when the adm.exe completes running then I want to carry on to the rest of the .bat code...

See below how I've used it....please TELL me if it's correct...as it doesn't seem to be making any difference...

-- --------

CALL C:\AVEVA\pdms11.6.SP1\pdms.bat TTY SEA SYSTEM/XXXXXX /TEST/DESIGN $m/c:\PDMS\Run_Dic.mac

tasklist /F1 "imaginename eq adm.exe"

rename C:\AVEVA\pdms11.6.SP1\pdmsuser\dice.txt KUPE-DICE-CHECK.txt

MOVE C:\AVEVA\pdms11.6.SP1\pdmsuser\KUPE-DICE-CHECK.txt C:\PDMS\Results\Dice

-- --------

Cheers
NeilQuote from: NEILD on September 04, 2009, 12:34:03 PM

tasklist /F1 "imaginename eq adm.exe"


first thing I see is that the command is /FI not /F1
second is the image name is incorrect it should be "imagename eq adm.exe"

I will work on this and see if I can come up with something. There might be some one that already has an example for you to use. ok this will check and see if the process is still active and if not then stop for 15 seconds and try again.

Code: [Select]@ECHO OFF

:loop
CLS

set errorlevel=

tasklist /fi "imagename eq adm.exe" | find /i "adm.exe"> NUL

if /i %errorlevel% GTR 0 goto yes

ECHO adm is working!
PING -n 1 -w 15000 1.1.1.1 > nul
GOTO loop

:yes
ECHO.
ECHO.
ECHO adm is finished
pause
wbrost thanks so much for helping me with this...

I've added your changes to my .bat

-- -------------
CALL C:\AVEVA\pdms11.6.SP1\pdms.bat TTY SEA SYSTEM/XXXXXX /TEST/DESIGN $m/c:\PDMS\Run_Dic.mac

@ECHO OFF

:loop
CLS

set errorlevel=

DEL C:\AVEVA\pdms11.6.SP1\pdmsuser\temp.txt ..................$$$$ coding stops at this point $$$$............

tasklist /fi "imagename eq adm.exe" l find /i "adm.exe"> NUL

DEL C:\AVEVA\pdms11.6.SP1\pdmsuser\temp1.txt

if /i %errorlevel% GTR 0 goto yes

DEL C:\AVEVA\pdms11.6.SP1\pdmsuser\temp2.txt

ECHO adm is working!
DEL C:\AVEVA\pdms11.6.SP1\pdmsuser\temp3.txt
PING -n 1 -w 15000 1.1.1.1 > nul

GOTO loop

:yes
ECHO.
ECHO.
ECHO adm is finished

rename C:\AVEVA\pdms11.6.SP1\pdmsuser\dice.txt KUPE-DICE-CHECK.txt

MOVE C:\AVEVA\pdms11.6.SP1\pdmsuser\KUPE-DICE-CHECK.txt C:\PDMS\Results\Dice
-- ------------------------------------------------------
It doesn't seem to completing the full code...it stops part way thgrough...

Before I tell you the problem can I confirm that this symbol in the centre is the one on the backslash key on the keyboard...not sure of it's name:-
exe" | find

I created some dummy files and added delete code...to see how far the code got...

The code made it to and past :-
set errorlevel=

It stopped at this line :-
tasklist /fi "imagename eq adm.exe" | find /i "adm.exe"> NUL

Have I made another typo ?

Cheers
Neil
I got it working by modifying one line :-

Old
tasklist /fi "imagename eq adm.exe" l find /i "adm.exe"> NUL

New
tasklist /fi "imagename eq adm.exe" goto goto loop

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

So it now looks like this :-

@ECHO OFF

:loop
CLS
ECHO adm is working!
PING -n 1 -w 15000 1.1.1.1 > nul
errorlevel=

tasklist /fi "imagename eq adm.exe" goto goto loop

if /i %errorlevel% GTR 0 goto yes

:yes
ECHO.
ECHO.
ECHO adm is finished


FOR /F "TOKENS=1-4 DELIMS=/ " %%i in ('date /t') DO (SET DATE=%%i-%%j-%%k)
rename C:\AVEVA\pdms11.6.SP1\pdmsuser\dice.txt KUPE-DICE-CHECK-%DATE%.txt
MOVE C:\AVEVA\pdms11.6.SP1\pdmsuser\KUPE-DICE-CHECK-%DATE%.txt C:\PDMS\Results\Dice

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

Thanks for the help...
Neil
4830.

Solve : How to rename file in sequence when file name already exists??

Answer»

The below works fine providing that desktop6.ndkOLD1 do not already exist, how can I have it to rename the file in sequence so that it will TRY first desktop6.ndkOLD1 then desktop6.ndkOLD2 etc.


Code: [Select]C:
cd\Documents and Settings\%username%\Local Settings\Application Data\Lotus\Notes\Data
Rename desktop6.ndk desktop6.ndkOLD1
Heres a script doing what you need, first it changes the directory
then , it sets variable cn to zero , then it starts a new SECTION and for array
in the array it processes all , *.NDKOL?? Files witch is the same thing as *.ndkOLD2 , *.ndkOLD3 , ECT .. it then calls set and adds 1 to the variable CN if the file name .NDKOLD3 already EXISTS , it loops back to the top and adds another 1 to the variable.. and does this untill CN hits a number that doesnt exist yet.. once it finds the next file that doesnt exist , it uses IF /F and LSS , so if desktop6.ndk is LESS then desktop6.NDKOLD4 OR desktop6.NDKOLD%CN% , it will rename the file to Desktop6.NDKOLD%CN% or Desktop6.NDKOLD5 (WHATEVER comes next)


@echo off
cd\Documents and Settings\%username%\Local Settings\Application Data\Lotus\Notes\Data
set cn=0
:TOP
for /f "tokens=1*" %%a in ('dir /a *.ndkOL?? /b') do (
call set /a cn=%%cn%%+1
if exist desktop6.ndkOLD%cn% Goto Top
if /i desktop6.ndk LSS %%a rename desktop6.ndk desktop6.ndkOLD%cn%
)
:END
Thanks Diablo416, just the thing I needed.

4831.

Solve : Restricting some of the websites...??

Answer»

Hello to all,

Is there any way I can block some of the websites by using any batch file or script. I want to restrict some of the websites. I'm using Windows Xp Service PACK 2 & my IE version is 6.0. I'm not joined to any domain. Or is there is any other way I can restrict the some of the websites so that users can't be allowed to use them.
Have a Nice Day, Bye.

Find your hosts file, if you use XP.. save the following as hosts.cmd

@ECHO OFF
@Set H=C:\windows\system32\drivers\etc\hosts
@ECHO %1 %2>>%H%
@CLS


and at the line, the SYNTAX would be
hosts.cmd 0.0.0.0 www.google.com


0.0.0.0 is the default for the localhost, its the equivilant of 127.0.0.1
So you could also type hosts.cmd 127.0.0.1 www.google.com

your hosts file, has the ability to block any remote host on your machine , when you open it in a NOTEPAD, you will see probably something like this..

# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, COMMENTS (such as these) may be INSERTED on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
0.0.0.0 free-viruscan.com
0.0.0.0 www.free-viruscan.com

0.0.0.0 dpnet.com
0.0.0.0 www.dpnet.com
0.0.0.0 gal.dpnet.com
0.0.0.0 www.gal.dpnet.com
0.0.0.0 deploy.akamaitechnologies.com
0.0.0.0 akamaitechnologies.com
0.0.0.0 a96-6-120-43.deploy.akamaitechnologies.com
0.0.0.0 www.live.com
0.0.0.0 www.google.com

4832.

Solve : Copying straight to cd?

Answer»

Is it possible to copy a file straight to a cd via BATCH, as in without another program? If the cd has drive-letter-access, e.g. in Windows packet writing, then yes.
Ohh. I heard a while back that you had to burn the files to the cd. What are you wanting to do? If you want to create a data cd that anybody can put in a CD drive and read, you have to burn the disk, but if you just want to use a CD or DVD disk as a giant floppy, then you can just copy the files from the command prompt, if you have DLA enabled. if you are talking about real MS-DOS, that is another STORY altogether.


I am trying to copy quite a few files scattered around my computer to cds. No, this is not actual MS-DOS, that's OLDER than me!Well, CD burning apps like Nero, Roxio ETC have a GUI where you can drag and drop files from Windows Explorer until the disk capacity is reached.But is it possible to have a batch file just copy them onto a disk? Like

@echo off
Copy file1 D:\folder
Copy file2 D:\folder
Etc.

Without downloading any other programs like nero. do you have DLA?
i am thinking its not possable
but you probubly could find a free CONSOLE based burner app
on sourceforge.net

4833.

Solve : commands after batch file that pings not working?

Answer»

Quote from: Two-eyes on September 05, 2009, 07:43:56 AM

@helpmeh: was that an insult?...no wait...don't wanna know...

Is there a way to CLOSE a THREAD, pls?

Two-eyes

No that wasn't an insult at all. Mods can close threads, but there is no need here.
the 6 e-mails saying: a REPLY has been posted on the TOPIC. but now i see a little checkbox down help...let's uncheck it and hope

Two-eyes

Just forget bout itQuote from: Two-eyes on September 05, 2009, 07:52:54 AM
Just forget bout it

Gladly

4834.

Solve : Starting from .bat with spaces in filename?

Answer»

How can I start an application from a batch FILE when the NAME of the app INCLUDES spaces - for example, to start "run me.exe".
If I enclose the command line in quotes the application will start, but the batch file hangs at that point and won't continue until I close the app I just started.
I can't rename the application, as it is called from other programs.

Thanks in advance!
Doc
If it is necessary to use quotes for the file name, you must include quotes for the title field:

Code: [Select]start "" "run me.exe"

Good luck.
It worked PERFECTLY! Thanks!!

4835.

Solve : Folder backup using timestamp?

Answer»

I have created a .bat or .cmd file (actually is there any difference?) which (scheduled daily) enables me to copy 5 files to a folder located on a NAS box, for backup purposes. However, with each new backup the existing folder (and its contents) are gone. How can I avoid that by appending the currently backed up folder with (say) a time stamp?

Basically here's what I am trying to accomplish:

First Day
COPY path\...\file1 \\NAS\...\FolderName_timestampA\file1
..
...
....
COPY path\...\file5 \\NAS\...\FolderName_timestampA\file5


Second Day
COPY path\...\file1 \\NAS\...\FolderName_timestampB\file1
..
...
....
COPY path\...\file5 \\NAS\...\FolderName_timestampB\file5

etc ...


The way I see this HAPPEN is by first creating on the NAS box a folder with the current day and time and ONLY THEN starting a simple copy or xcopy backup from the destination to the newly created folder with the timestamp.

Creating the folders with the current time stamp is marginally out of my abilities.

Doing the copy or xcopy backup, OK this is trivial.

But...

how do I send these 5 files to a different folder every day is totally out of my league.

And the ULTIMATE challenge is how to PACKAGE all this in one .bat or .cmd file.

I am greatly thankful for any of your answers.

Sincerely,

Xwris OnomaTry this
Code: [Select]@Echo Off
Set d=%date%
REM IF THE DATE SEPARATOR IS NOT A "/", THE NEXT LINE CAN BE DELETED
Set d=%d:/=%
XCopy D:\rootpath\path1\path2\filename.ext \\server\share\folder_%d%\
very nice simple way, but it still shows the day abbreviated.
try this

Code: [Select]@echo off
for /f "tokens=2-4 delims=/- " %%a in ('date /t') do set DT=%%a%%b%%c
XCopy D:\rootpath\path1\path2\filename.ext \\server\share\folder_%dt%\Quote from: BatchFileBasics on September 04, 2009, 08:24:24 PM

very nice simple way, but it still shows the day abbreviated.
try this

Code: [Select]@echo off
for /f "tokens=2-4 delims=/- " %%a in ('date /t') do set dt=%%a%%b%%c
XCopy D:\rootpath\path1\path2\filename.ext \\server\share\folder_%dt%\

I also USE token for dated filenaming.
but I use rename to change name to my desired naming.

this is good and simple.
thanks for sharing it.
4836.

Solve : How Do I Execute Same Command in Current Directory's Children Directories??

Answer»

For any given directory, all I WANT to do is go into each of its immediate child directories and execute the same command.

I originally was thinking about taking the command of "dir /AD /B /X" and store it into a txt file, but after that, I'm not really sure what I can do. I need to go into each child directory since the OUTPUT of the command I want to do creates files that populate whatever the current directory is.

Is there a quick fix to this?

This is my pseudo-code:

Code: [Select]FOR %%d in (dir /AD /B /X) DO (

cd %%d
REM excecute command here
cd ..My other idea was this:

dir /AD /B /X > dir.txt

FOR %%d in (dir.txt) DO (
cd %%d
REM excecute command here
cd ..
)
I just FOUND out the /X is useless when trying to store the old MS-DOS 8.3 filename LIMITATION since when I redirect to a txt file, it opts to use the longer filename convention.

I'll have to figure out how to wrap directories with quotes.Okay even though I got no help, I perused through the forum and looked in some other people's scenarios which vaguely had some similar needs as mine. I THINK this is my solution.... I have to wait since I can't run the bat file until my current process ends on my server. But here is what I think will do the trick:

Code: [Select]FOR /F "delims==" %%d in ('dir /AD /B /X') DO (

cd "%%d"

cd

REM insert executable command here

cd ..

)

4837.

Solve : Need help creating a batch file with .wvx extension?

Answer» Background
I have a number of WMV files on my website's server and Im creating two sets of links to them. One for instant viewing and the other for downloading it.
Creating the download link is easy since its just a link with the full path name (webserver/path/filename.wmv).
For the streaming link, I have a "director file" with a .wvx extension which is simply a text file with a short script in it that tells the client PC to execute windows media player to play said wmv file.

The *.wvx text file has the following string in it:



http://YourWebServer/Path/YourFile.wmv" />




The Task
I would like to create a BATCH file that can create a *.wvx file for each of the *.wmv files on the drive.
The newly created wvx should have the same name as the wmv file (just different extensions) and also inside the *.wvx should reference to the wmv file on the server.
I hope this makes sense.

My attempt
for %%a IN (*.wmv) do echo " http://Mywebserver/path/%%~na.wmv"/> " > %%~na.wvx

I've come up with this string and it does everything for the most parts, but it list the entire string on one line but as you can see in the above example, the string is suppose to be on 5 lines. or the link doesn't work. I know bearly anything about batch files commands so any help will be welcomed
@echo off
For /f "delims=." %%a in ('dir /b /s PATHTOFILES*.wmv') do (
Echo %%a
Echo ^ > %%a.wvx
echo ^ >> %%a.wvx
echo ^ >> %%a.wvx
echo ^ >> %%a.wvx
echo ^ >> %%a.wvx
)

That should work. I haven't tested it though. If I understand what you want, it is not worthwhile doing it in batch. This kind of job could be DONE in some kind of HTML page with some code for either doing a down load or STARTING a stream. I tried your code Helpmeh, but it didn't work, it didn't even create a .wvx file
I substituted ('dir /b /s PATHTOFILES*.wmv') for ('*.wmv') since I placed the batch file in the same directory as the wmv files. But no avail.

I'm not familar with any HTML code for creating a metafile for wmv files Geek-9pm, but i'm listening natedj,

Does anyone know what you are talking about or what you are trying to do?I though I was clear in the topic but in a nutshell.

I need to create a text file to point to a WMV file on my website.
(why? .... because linking to it offer a download option in some browers and not actually playing/streaming the file)

I've be creating these files manualy
i.e. create one, do a "save as", change the file name (thats inside of the string) to the newly target file and so on

This is the text file string that is in each .wvx file




http://YourWebServer/Path/YourFile.wmv" />



I then save this text file with a .wvx extension.


Why do I want a batch file for this ... I have a ton of wmv files that need wvx files to point to them.

Where id i get the idea from?
http://www.microsoft.com/windows/windowsmedia/howto/articles/webserver.aspx#webserver_topic3

Code: [Select]Set objFS=CreateObject("Scripting.FileSystemObject")
strFolder = "c:\test"
Set objFolder = objFS.GetFolder(strFolder)
For Each strFile In objFolder.Files
If objFS.GetExtensionName(strFile) = "wmv" Then
strBaseName = objFS.GetBaseName(strFile)
strFileName = Replace(strFile.Name," ","%20")
WScript.Echo strFileName, strBaseName
strNewFileName = strBaseName & ".wvx"
Set objOut = objFS.CreateTextFile(strNewFileName,True)
objOut.WriteLine("<ASX VERSION=""3.0"">")
objOut.WriteLine(" ENTRY")
objOut.WriteLine("<REF HREF=""http://YourWebServer/Path/" & strFileName & """" & "/>")
objOut.Close
End If
Next


output
Code: [Select]c:\test> cscript /nologo myscript.vbs
I have read over the reference you gave. That looks cool.
You can also use Flash player, but that is another story.

The issue is your web site does not support real time streaming of video, so the thing from Microsoft with help WMA do a better job and avoid a broken stream.

So you want to create the HTML stuff automatically on you PC and then load the files to your site.

OK. Now I get it. I used to do that sort of thin when I have a number of sites that I want to have ALMOST the same code on each site but just a few changes from an list. And I did it with a batch file and then uploaded the changed files to my sites. I I did that with batch also. So yea, you can do that.

You can do that with a FOR loop. Some of the others here will tell you how to use FOR to substitute the text in a number of files.

I am a FOR loop flunky, so I would just create a batch files that would pass a list of names to another batch file to process the text. I had to INCORPORATE a program into the batch that would do the actual text substitution. Never could understand how FOR does that, just easier for me to write a program that opens a file, substitute from a list and writes a new copy of the file to a directory.
The vbs thing is what you could use, but I used QBASIC, more primitive, but does the job.
4838.

Solve : unhide hidden folders...?

Answer»

can someone guide me how to unhide hidden folders in my flash drive??

the hiddens folders are:

"virus 123"
"virus loves"

i tried to =>"ATTRIB -h e:\virus 123"
it won't work..!
its=>"Parameter format not correct - "

Hi,

Please post your problem Here.

ThankyouQuote from: and1_bluemen

can someone guide me how to unhide hidden folders in my flash drive??

Try:

Attrib -h "e:\virus 123"

Peculiar name for a FOLDER...I was gonna say the same Dusty...maybe you don't want to unhide those and simply format that flash drive...attrib -s -hQuote
"virus 123"
"virus loves"

something seems fishy.....TNX! Dusty .... it works!
4839.

Solve : checking if file names contain spaces?

Answer»

As the title READS, I would like to be able to see if a file name contains spaces, or if the path contains spaces.

for example:

SUPER Adventure.smc has a space in it, therefore i want it to go to SOMEWHERE else. Or if it is possible i would like it to be renamed.

C:\Bob Claton\pop rocks\ has two spaces in it, so i want it to go to somewhere else.

i hope im clear.Setting the delims as spaces, use FOR to PARSE the filename into 2 tokens. If the first token is EQUAL to the whole filename, there weren´t any spaces in it.

4840.

Solve : Change file names?

Answer»

I have 1000 files of different names, I want to CHANGE their names using a BATCH file to this way
s_0000,
s_0001,
.
.
.
s_0999, with any extension

Note that all files in a folder called x and I want all files with the new names in a new folder called y

I did that code, but it changed the first file name only and the counter Z DOSE not increase

@echo off
set DIR=X
set OUT=Y

set Z=000
for %%E in (%DIR%/*.*) do (
XCOPY %Dir%\%%E*.* %OUT%\s_%Z%.*
set /a Z=Z+1
)
pause
@ECHO OFF
set c=0
set ifi=FOR,/F;"Tokens=1,2,3,4,5*",%%A;in,
CLS;&%ifi%('dir /B'),do (
call set /a c=%%c%%+1
call rename %%A s_%%c%%
)



this will rename all files in the current folder, to s_1 , s_2

4841.

Solve : batch file program?

Answer»

How to show current date WITHOUT prompting the user to enter NEW dateTry using date /t

THis keeps COMING up. Why does everybody SUGGEST date /t ? what´s wrong with echo %date% ?

4842.

Solve : finding current folder in and setting it?

Answer»

As the topic reads, i need to find the folder that batch is CURRENTLY in. Then i need to set it to something like %opath%

the current folder is already set to CD , %CD%There is a DIFFERENCE between the "current folder", which is usually taken to mean the currently logged in folder, which is %cd%, and the folder where the batch file is ACTUALLY located, which is %~dp0 and which is not necessarily the same as the current folder.

For example consider a batch file containing these lines called test.bat which is stored in the folder d:\batch

echo 1...%cd%
echo 2...%~dp0

I open a command PROMPT and type cd c:\

Now c:\ is the current folder but if i type this

d:\batch\test.bat

I will see this output

1...C:\
2...D:\batch\test

That's exactly what I needed Dias de verano! Thanks

4843.

Solve : Renaming multiple files at once?

Answer»

I would like to rename a large amount of files at once. For EXAMPLE:

I would like to rename all the files beginning with 4REF to 4REF_SL

Old Name New Name
ex: 4REF0001.jpg 4REF_SL0001.jpg
4REF0002.jpg 4REF_SL0002.jpg

I tried using an * but it does not work.... help!

Using WILDCARDS with the ren command can produce some SURPRISING results, and not NECESSARILY good ones. Based on your naming convention, this may help:

Code: [Select]@echo off
setlocal enabledelayedexpansion
for %%v in (*.jpg) do (
set fname=%%v
set ref=!fname:~0,4!
set num=!fname:~4,4!
ren %%v !ref!_SL!num!.jpg
)

You may need to USE a path pointer to the jpg files.

Good luck.

4844.

Solve : SOLVED -- Trouble with script run from Scheduled Tasks?

Answer»

Hi all,

Have a batch script whose intention is to delete files based on the passing of time.

There are two files associated with the script; the script itself and a parameter file.
The problem I'm having is that when the script is run as a scheduled task, it successfully deletes all files on the LOCAL file system. However there are additional entries in the parameter file that refer to a mapped drive (mapped network storage area device). It is not performing the necessary deletion's from this device.

On the flip side, if I logon and execute the same scheduled task or execute the script manually, all applicable files in those locations contained in the parameter file are deleted successfully.

The scheduled task is run under my own UID - and the results have me stumped as I have ADMINISTRATOR priv's.

OS: Windows 2003

Batch Script:
Code: [Select]:: ----------------------------------------------------------------------------------------------------------
:: --
:: -- Script : Delete_Old_Files.bat
:: --
:: -- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
:: --
:: -- Purpose :
:: --
:: -- To delete old/unwanted files from the local and potential member servers.
:: -- The script uses delete_old_files.txt for input to identify files for deletion.
:: --
:: ----------------------------------------------------------------------------------------------------------

@echo off

if not "%1"=="" goto %1

for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set DayOfWeek=%%i
set Day=%%j
set Month=%%k
set Year=%%l
set Date=%%l-%%k-%%j
)

for /F %%i in ('time /t') do (
set CurTime=%%i
)

set SleepTime=10
set OutputLog=%~dp0Logs\%~n0-%Date%.log

@echo. >> %OutputLog%
@echo ------------------------------------------------------------------------------ >> %OutputLog%
@echo ------------------------------------------------------------------------------ >> %OutputLog%
@echo Start of batch job %0 on %Date% at %CurTime% >> %OutputLog%
@echo ------------------------------------------------------------------------------ >> %OutputLog%
@echo ------------------------------------------------------------------------------ >> %OutputLog%
@echo. >> %OutputLog%

set Directories=%~dpn0.txt
set Recursive=TRUE

for /F "tokens=1,2,3,4 delims=;" %%i in (%Directories%) do (
set Dir=%%i
set Age=%%j
set Files=%%k
set Recursive=%%l
call %0 deletefiles
)

goto FinishRun

:deletefiles
set RFlag=
if %Recursive%==TRUE set RFlag=/S

forfiles /P %Dir% /D -%Age% %RFlag% /M %Files% /C "cmd /c @echo Deleting @path as it is older than %Age% days >> %OutputLog%"
@echo forfiles /P %Dir% /D -%Age% %RFlag% /M %Files% /C "cmd /c del /F @path >> %OutputLog%" >> %OutputLog%
forfiles /P %Dir% /D -%Age% %RFlag% /M %Files% /C "cmd /c del /F @path >> %OutputLog%"
@echo.
@echo *** Sleep for %SleepTime% seconds ***
@echo. >> %OutputLog%
@echo *** Sleep for %SleepTime% seconds *** >> %OutputLog%
sleep %SleepTime%

goto :EOF

:FinishRun

for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set DayOfWeek=%%i
set Day=%%j
set Month=%%k
set Year=%%l
set Date=%%l-%%k-%%j
)

for /F %%m in ('time /t') do (
set CurTime=%%m
)

@echo. >> %OutputLog%
@echo ------------------------------------------------------------------------------ >> %OutputLog%
@echo ------------------------------------------------------------------------------ >> %OutputLog%
@echo Finish of batch job %0 on %Date% at %CurTime% >> %OutputLog%
@echo ------------------------------------------------------------------------------ >> %OutputLog%
@echo ------------------------------------------------------------------------------ >> %OutputLog%
@echo. >> %OutputLog%


goto :EOF
Parameter File:
C:\batchjobs\logs ;31 ;*.log ;TRUE
C:\batchjobs\logs ;31 ;*.zip ;TRUE
C:\batchjobs\logs ;7 ;*.bkf ;TRUE
S:\BKUP-DAILY ;8 ;*.bkf ;TRUE
S:\BKUP-SYSSTATE ;2 ;*.bkf ;TRUE
S:\BKUP-WEEKLY ;21 ;*.bkf ;TRUE

Sample of the logging file.
The first run was via the Scheduled Task, the second run was when I logged in.

Code: [Select]
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Start of batch job C:\Batchjobs\Delete_Old_Files.bat on 2008-09-24 at 00:30
------------------------------------------------------------------------------
------------------------------------------------------------------------------

Deleting "C:\batchjobs\logs\MYOB-Newsletter_COPY-08-24-Sun.log" as it is older than 31 days
Deleting "C:\batchjobs\logs\DALA_Backups-2008-08-24.log" as it is older than 31 days
Deleting "C:\batchjobs\logs\Delete_old_files-2008-08-24.log" as it is older than 31 days
forfiles /P C:\batchjobs\logs /D -31 /S /M *.log /C "cmd /c del /F @path >> C:\Batchjobs\Logs\Delete_Old_Files-2008-09-24.log"

*** Sleep for 10 seconds ***
Deleting "C:\batchjobs\logs\DALA_Backups-2008-08-24.zip" as it is older than 31 days
forfiles /P C:\batchjobs\logs /D -31 /S /M *.zip /C "cmd /c del /F @path >> C:\Batchjobs\Logs\Delete_Old_Files-2008-09-24.log"

*** Sleep for 10 seconds ***
forfiles /P C:\batchjobs\logs /D -7 /S /M *.bkf /C "cmd /c del /F @path >> C:\Batchjobs\Logs\Delete_Old_Files-2008-09-24.log"

*** Sleep for 10 seconds ***
forfiles /P S:\BKUP-DAILY /D -8 /S /M *.bkf /C "cmd /c del /F @path >> C:\Batchjobs\Logs\Delete_Old_Files-2008-09-24.log"

*** Sleep for 10 seconds ***
forfiles /P S:\BKUP-SYSSTATE /D -2 /S /M *.bkf /C "cmd /c del /F @path >> C:\Batchjobs\Logs\Delete_Old_Files-2008-09-24.log"

*** Sleep for 10 seconds ***
forfiles /P S:\BKUP-WEEKLY /D -21 /S /M *.bkf /C "cmd /c del /F @path >> C:\Batchjobs\Logs\Delete_Old_Files-2008-09-24.log"

*** Sleep for 10 seconds ***

------------------------------------------------------------------------------
------------------------------------------------------------------------------
Finish of batch job C:\Batchjobs\Delete_Old_Files.bat on 2008-09-24 at 00:31
------------------------------------------------------------------------------
------------------------------------------------------------------------------

[emailprotected]
[emailprotected] [emailprotected]
MailSubject=Delete_Old_Files on DALA-FS - 2008-09-24 (Wed) / 00:31
MailBody=Delete_Old_Files on DALA-FS for 2008-09-24 (Wed) has completed.
sendmail.vbs -f [emailprotected] -t [emailprotected] [emailprotected] -s "Delete_Old_Files on DALA-FS - 2008-09-24 (Wed) / 00:31" -b "Delete_Old_Files on DALA-FS for 2008-09-24 (Wed) has completed." -a C:\Batchjobs\Logs\Delete_Old_Files-2008-09-24.log

------------------------------------------------------------------------------
------------------------------------------------------------------------------
Start of batch job C:\Batchjobs\Delete_Old_Files.bat on 2008-09-24 at 00:38
------------------------------------------------------------------------------
------------------------------------------------------------------------------

forfiles /P C:\batchjobs\logs /D -31 /S /M *.log /C "cmd /c del /F @path >> C:\Batchjobs\Logs\Delete_Old_Files-2008-09-24.log"

*** Sleep for 10 seconds ***
forfiles /P C:\batchjobs\logs /D -31 /S /M *.zip /C "cmd /c del /F @path >> C:\Batchjobs\Logs\Delete_Old_Files-2008-09-24.log"

*** Sleep for 10 seconds ***
forfiles /P C:\batchjobs\logs /D -7 /S /M *.bkf /C "cmd /c del /F @path >> C:\Batchjobs\Logs\Delete_Old_Files-2008-09-24.log"

*** Sleep for 10 seconds ***
Deleting "S:\BKUP-DAILY\DALA_Backups-2008-09-16-C-Drive.bkf" as it is older than 8 days
Deleting "S:\BKUP-DAILY\DALA_Backups-2008-09-16-D-Drive.bkf" as it is older than 8 days
forfiles /P S:\BKUP-DAILY /D -8 /S /M *.bkf /C "cmd /c del /F @path >> C:\Batchjobs\Logs\Delete_Old_Files-2008-09-24.log"

*** Sleep for 10 seconds ***
Deleting "S:\BKUP-SYSSTATE\Systemstate-2008-09-20.bkf" as it is older than 2 days
Deleting "S:\BKUP-SYSSTATE\Systemstate-2008-09-21.bkf" as it is older than 2 days
forfiles /P S:\BKUP-SYSSTATE /D -2 /S /M *.bkf /C "cmd /c del /F @path >> C:\Batchjobs\Logs\Delete_Old_Files-2008-09-24.log"

*** Sleep for 10 seconds ***
Deleting "S:\BKUP-WEEKLY\DALA_Backups-2008-09-01-C-Drive.bkf" as it is older than 21 days
Deleting "S:\BKUP-WEEKLY\DALA_Backups-2008-09-01-D-Drive.bkf" as it is older than 21 days
forfiles /P S:\BKUP-WEEKLY /D -21 /S /M *.bkf /C "cmd /c del /F @path >> C:\Batchjobs\Logs\Delete_Old_Files-2008-09-24.log"

*** Sleep for 10 seconds ***

------------------------------------------------------------------------------
------------------------------------------------------------------------------
Finish of batch job C:\Batchjobs\Delete_Old_Files.bat on 2008-09-24 at 00:41
------------------------------------------------------------------------------
------------------------------------------------------------------------------

[emailprotected]
[emailprotected] [emailprotected]
MailSubject=Delete_Old_Files on DALA-FS - 2008-09-24 (Wed) / 00:41
MailBody=Delete_Old_Files on DALA-FS for 2008-09-24 (Wed) has completed.
sendmail.vbs -f [emailprotected] -t [emailprotected] [emailprotected] -s "Delete_Old_Files on DALA-FS - 2008-09-24 (Wed) / 00:41" -b "Delete_Old_Files on DALA-FS for 2008-09-24 (Wed) has completed." -a C:\Batchjobs\Logs\Delete_Old_Files-2008-09-24.log

Any ASSISTANCE would be really appreciated as this has got me absolutely stumped.

Cheers,
CameronQuote

On the flip side, if I logon and execute the same scheduled task or execute the script manually, all applicable files in those locations contained in the parameter file are deleted successfully.

It appears the the drive is only mapped when you are logged on and then only if the drive was made persistent. How and when is the drive mapped?

Can you MOVE mapping the drive to your batch file? If you need to make temporary mappings for your file and you don't want to screw up any system settings, it's possible to map multiple drive letters to the same network drive.

Good luck and glad to see you back Cameron. Many thanks for the reply & welcome back SIdewinder; has been a while.

Taking on board your suggestion is the likely way to go - had skipped over the idea a few days ago.

Will look into the use of pushd/popd and see how I go.
Problem solved, so for anyone interested read on .....

The use of pushd & popd as I'd thought was a go-er was not the way forward.
Had issues with how pushd truncated USB network storage device paths.

Instead used the 'subst' command.
Placement is majorly important due to the 'call' statement - the 'subst' statements must be executed within the 'call' statement (in the same shell).

This is how it was resolved ....
Code: [Select]set Directories=%~dpn0.txt
set Recursive=TRUE

for /F "tokens=1,2,3,4 delims=;" %%i in (%Directories%) do (
set Dir=%%i
set Age=%%j
set Files=%%k
set Recursive=%%l

call %0 deletefiles

)

goto FinishRun

:deletefiles

SUBST X: %Dir%

set RFlag=
if %Recursive%==TRUE set RFlag=/S

forfiles /P X: /D -%Age% %RFlag% /M %Files% /C "cmd /c @echo Deleting @path as it is older than %Age% days >> %OutputLog%"
@echo forfiles /P X:(%Dir%) /D -%Age% %RFlag% /M %Files% /C "cmd /c del /F @path >> %OutputLog%" >> %OutputLog%
forfiles /P X: /D -%Age% %RFlag% /M %Files% /C "cmd /c del /F @path >> %OutputLog%"

SUBST X: /D

@echo.
@echo *** Sleep for %SleepTime% seconds ***
@echo.
@echo. >> %OutputLog%
@echo *** Sleep for %SleepTime% seconds *** >> %OutputLog%
@echo. >> %OutputLog%
sleep %SleepTime%

goto :EOF
The Parameter file also changed to be explicit in its detail ...
C:\batchjobs\logs ;31 ;*.txt ;TRUE
C:\batchjobs\logs ;31 ;*.log ;TRUE
C:\batchjobs\logs ;31 ;*.zip ;TRUE
C:\batchjobs\logs ;7 ;*.bkf ;TRUE
\\192.168.0.115\Backup\BKUP\BKUP-DAILY ;8 ;*.bkf ;TRUE
\\192.168.0.115\Backup\BKUP\BKUP-SYSSTATE ;2 ;*.bkf ;TRUE
\\192.168.0.115\Backup\BKUP\BKUP-WEEKLY ;21 ;*.bkf ;TRUE

Hope this is all of some HELP for anyone else too.

Cheers,
Cameron

4845.

Solve : Convert date from MM/DD/YYYY into YYYYMMDD format?

Answer»

Hello all,

My requirement is to get the date of a specific folder and to delete the same if the folder creation date is more than some 2 weeks.

can any one help me in this.

thanks in advance.Batch code does not do date/time arithmetic very well. I have snippets in my closet going back to 1983, but not one of them does aging in batch code.

How about a nice VBScript solution?

Let us KNOW. spshanth

I wish you luck,
but I fear you will get a lot more experience than you want !!!

Created in 2003 I have C:\Windows.
This is MUCH MORE than 2 weeks old.

If I applied the RULE of deleting a folder when it was two weeks old, it would save 4.7 GB of disc space, but I would not be able to do much with all that extra space but no operating system.

The date of a folder does NOT indicate its most recent contents;
it just possibly corresponds to the most recent file dates at the "root" of this folder,
but ignores any more recent dates of folders and subsequent files it may contain.

Whatever the rules (if any) may be, they PROBABLY depend upon whether you are looking at "Created" or "Modified".
There are no rules for "ACCESSED". If you use Windows Explorer to look in an obscure region you have not looked at for some time, you may see an ancient "Accessed" date. This is meaningless. If you reboot the computer you will now see it was accessed 5 minutes ago. Accessed does not MEAN the contents were read or written.
The "Accessed" date changes if Windows Explorer shows that file exists,
but it will NOT change if you use the "DOS" command "DIR".

File dates are interesting, and quite useful, but I would not depend upon them to control what gets deleted.

Regards
Alan
thanks for the response.

But i have to do this in a DOS batch script only and cannot use VBS here

is there any other way to handle this situation oter than using the date manipualtion logic??

Thnaks.Quote

Convert date from MM/DD/YYYY into YYYYMMDD format

Code: [Select]@echo off
set dt=mm/dd/yyyy
set newdate=%dt:~6,4%%dt:~0,2%%dt:~3,2%
echo %newdate%

It becomes problematical when using arithmetic on dates. Everything is fine if both dates are in the same month. The real fun begins when you "borrow" days from the previous month.



I can't sell a VBS script to anyone today. thanks sidewinder...
4846.

Solve : Turning command prompt while on log on screen?

Answer»

Quote from: Salmon Trout on August 31, 2009, 12:45:31 AM

Threatening me would be a very bad mistake.


lolBut can he do anything about it?you poor UNINFORMED Dense as Plumbum fools.

A contrexing is what you could GET.

but I doubt time would be wasted on such an endeavor.Hehehehe

Endeavor. That's a pokemon move. Quote from: Helpmeh on SEPTEMBER 02, 2009, 08:48:51 PM
Hehehehe

Endeavor. That's a pokemon move.

err yeah... it's also a word.Quote from: BC_Programmer on September 02, 2009, 08:56:49 PM
err yeah... it's also a word.
proof: http://www.thefreedictionary.com/endeavorNow that the original content was removed and any relevance that this post had to DOS is gone should this get moved to "Off topic" Quote from: mroilfield on September 02, 2009, 11:58:25 PM
Now that the original content was removed and any relevance that this post had to DOS is gone should this get moved to "Off topic"
yesOr we just LEAVE this topic alone so we can STOP bumping it. Topic Closed.

patio.
4847.

Solve : 4 Questions (2 Answered) Tough to Solve...??

Answer» HELLO to all,

As I have four questions (2 solved) which are mentioned below:

1.) I'm using a batch file & it is in Startup folder. It runs every time
when I log in. I'm using three commands in it. Every time its shows Ok mesage when a command is executed successfully, so I want to disable the "Ok"mesage, I have used "@ECHO OFF" after every command but it doesn't work. Commands are netsh firewall & netsh interface ip so when they are executed, Ok mesage is appeared, I want to disable the mesage or it should not be appeared.
And I also want to ask that Can that blank window be minimized automatically and runs in small window above the clock or in any side so that whenever it runs user can not notify that a batch file is running.?

Ans) If we do not want to see any messages OR To get rid of the screen output use redirection and redirect the output
to NULL use this method:
netsh firewall ... ... 1>nul 2>nul
for example ...
"netsh interface ip set address name= "Local Area Connection" static 10.0.0.1 255.0.0.0 10.0.0.50 0 1>nul"
Then the OK mesage will not be appeared.

& when we run a batch file, blank window appears, If we want that window to be minimized then instead of running the batch file directly, run it like so:
start /min "" cmd.exe /c d:\Tools\test.bat
where d is the drive in which batch file exist.

2.) My second question is that, I want to send a mesage at a particular time, for example at 10.00pm or After one hour of login. The syntax of SENDING mesage is Msg * Hello.

Ans) We can use SCHEDULED tasks located in Start --> All Programs --> Accessories --> System Tools --> Scheduled Tasks. Add the Batch File and you can set up when you want it to run.


3.) Can we send the mesage in any colorful window, & Can we change the color of the window (in which mesage appears) or can we change the title of the window when it appears. ?

4.) Can we enable or disable lan or any Local area Connection by any command or by batch file?
1. What is are the commands?

2. Scheduled tasks?

3. To change the color of the command prompt window, type color /? and press Enter. To change the title, the command is title TITLE HERE

4. Why?1. Ah sorry, I seem to have missed that. I don't think there is a way to get rid of the OK message. To start a batch file minimized, use start /min file.bat.

2. Scheduled tasks is located in Start --> All Programs --> Accessories --> System Tools --> Scheduled Tasks. Add the Batch File and you can set up when you want it to run.

3. There is no way to change that.

4. Still, why? Sounds devious to me....Hello Dear,

My 3rd question, "Changing title and color of mesage box" Dear I'm not sure but I think its possible but I'm unable to use that command, Below I'm POSTING the syntax of it from a website so may be you can help me about it.


http://www.pitrinec.com/bar_help/pg_hlp_cmd_msg.htm
--------------------------------------------------------------------------------

Shows message window.


Command Tree: Message \ Show Message
.
Syntax: (Xpos, Ypos, "MessageText", "Title", OKButton)
Xpos
X-coordinate of the message window position.

Ypos
Y-coordinate of the message window position.

MessageText
Text you want to display in the message window.

Title
Title of the message window.

OKButton
Can be one of these values:
0 - OK button is not shown. The command must be used to close the message window.
1 - OK button is shown in the message window.

.
.
Example: <#> This macro will display message window
<#>
(100,100,"This is a message
to notify user just
about anything....","Message",1)

--------------------------------------------------------------------------------
I'm posting link of another site, In that it shows that msgbox is the command of batch file but it doesn't run in cmd.

http://www.jpsoft.com/help/index.htm?msgbox.htm
http://www.jpsoft.com/help/index.htm?window.htm

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

4th Question, I'm using a computer which is shared, so I want some of the users not to use lan. I will put the batch file on the startup folder so that it will automatically disables the lan. I hope you understand now.

Any way dear, Thanks very much for helping me so much. I will be waiting for your reply. Take Care. Have a Nice DAY.
4848.

Solve : printing in dos to file (filename.txt ASCII) yields a portait output?

Answer»

Can anyone TELL me HOE to change the dos print command to yield a landscape output?

thanks
tomHERE are some similar entries through which you can read to see if any of the information helps.Or you could use the Tao ExDOS 2009 LITE product to solve all your printing PROBLEMS from DOS.
It allows complete manipulation of the printed document, among many other features.

http://www.taocs.co.il

4849.

Solve : Batch file erase, don't have a clue?

Answer»

On my wife's computer (DELL Latitude) running Windows XP SP2, when I make an autoexec.bat file and place in the root directory after rebooting, the file has been erased. I have gone through this procedure several times and it always gets erased after booting. This is a really simple .bat file that only sets the path. Any ideas?
Please help,
DougOn an XP machine, the autoexec.bat file has been replaced by the autoexec.nt file which should be in the system32 directory. The autoexec.nt file is used to initialize the Windows DOS environment not Windows.

Not to be obvious, but are you saving the file correctly?

Have you checked what, if any, jobs are running from the startup folder? Many other jobs are started from the registry. The msconfig utility can help you see them. Perhaps one of them is the culprit.

If you still have problems, it might be wise to trot over to the Viruses and Spyware board and let the experts check it out.

Good luck. Bewareofdoug - Welcome to the CH forums.

Autoexec.bat is parsed when windows is loaded but the only statements which are executed are SET and Path, all OTHERS are ignored.

The following quote is from this wiki:
Quote

The AUTOEXEC.BAT file may often be found on Windows NT, in the root directory of the boot drive. Windows only considers the "SET" and "PATH" statements which it contains, in order to define environment variables global to all users.

And another from this site:
Quote
Windows XP searches the startup files and processes the environment variable settings in the following order:

* Autoexec.bat files
* System Variables
* User Variables

Here's a long odds reason why you "lose" the file -- if you are using Notepad to create the file, Notepad will append the suffix .TXT to the file when it is SAVED therefore Autoexec.bat will not be found. When saving with Notepad enclose the the filename/suffix to save in " ' e.g. "autoexec.bat"

Good luckThanks for the tips.

I am editing the file from the dos prompt edit command.
I have already created the autoexec.bat.txt file using notepad so that I can just delete the .txt part and run the .bat from prompt.

Thanks for the tip about the .nt file. I don't know MUCH about the windows enviroment, just an old dos guy that does a lot of stuff in Dbase.

The funny THING is that I use an autoexec.bat file on a different computer and don't have the erase problem.

Thanks again,
Doug
4850.

Solve : Changing Files names in a sequentail order?

Answer»

I have 1000 files of different names, I want to change their names using a batch file to this way
s_0000,
s_0001,
.
.
.
s_0999, with any exteension

Note that all files in a folder called x and I want all files with the new names in a new folder called y

I did that code, but it changed the first file name only and the counter Z dose not increase

@echo off
SET DIR=X
set OUT=Y

set Z=000
for %%E in (%DIR%/*.*) do (
XCOPY %Dir%\%%E*.* %OUT%\s_%Z%.*
set /a Z=Z+1
)
pause
Google for "DELAYED EXPANSION", or search this forum.