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.

4851.

Solve : refresh a website with a .bat file?

Answer» IM NEW at this, but can anyone TELL me if it is possible to REFRESH a webpage with a bat file? (example...refresh a webpage every 10 sec for an hour....)

thanks much for your helpIt could be done, but would require more than batch to make it happen. Batch would only be used as timer and trigger for an exe. The exe would be a macro or program created to pass as F5 keystroke.

This can be done without batch by the way in its cleanest form, you can write or have someone write a short program to trigger the F5 key every 10 sec for 1hr.ok...just WONDERED if there was a way. Thanks for your help.
4852.

Solve : Check file for a certain word if exist do this?

Answer»

I am running a batch to check if a database EXIST if it does I need to exit the batch or if the database doesn't exist then to continue with the INSTALL what am I doing wrong here any help is much appreciated

Code: [Select]@ECHO OFF
net start MSSQLSERVER
net start SQLSERVERAGENT
osql -E -n -W 300 -o "c:\checkdbexist.txt" -i c:\checkdb.sql"
find "Database Exists" "c:\checkdbexist.txt"
IF ERRORLEVEL 0 GOTO :QUIT
:QUIT
exit
find "Database Does Not Exists" "c:\checkdbexist.txt"
IF ERRORLEVEL 0 GOTO :OK
:OK
pause
The IF statement in a batch FILE is not a a block structure.
It is a one LINE thing. The one line has to tell it to goto a blcok of code.Then you have to have some more GOTOs to define one or more blocks. You did not make the :QUIT part of a block. And you need to have a NOQUIT block and an a DONE point
May this is what you want.
IF ERRORLEVEL=0 GOTO QUIT
GOTO NOQUIT
:QUIT
blah blah blah THIS IS A BLOCK
GOTO DONE
:NOQUIT
blah blah blah THIS IS THE OTHER BLOCK
:DONE

Batch file programming has to be the worst thing ever invented! Code: [Select]@ECHO OFF
net start MSSQLSERVER
net start SQLSERVERAGENT
osql -E -n -w 300 -o "c:\checkdbexist.txt" -i c:\checkdb.sql"
find "Database Exists" "c:\checkdbexist.txt"
IF ERRORLEVEL 0 GOTO :QUIT

You will go here whatever the errorlevel <-----------------------------------------

:QUIT
exit

Therefore you will never get here <-----------------------------------------------

find "Database Does Not Exists" "c:\checkdbexist.txt"
IF ERRORLEVEL 0 GOTO

But even if you could <---------------------------------------
You will go here whatever the errorlevel <-----------------------------------------

:OK
pause

4853.

Solve : batch file to unrar one file from more archives to different folders?

Answer»

OK, now i GOT it working all the way to the unrar-ing... how can i add unrar.exe to the batch file? I installed unrar.exe (from winrar page) to program files, but i PROBABLY still need to add it to some library, or? woohoo got it working
thanx for the help.

the script looks like this:

Code: [Select]for /F "delims=." %%R in ('dir /b U:\Archive_200803*.rar') do (
MD "C:\test\%%~nR"
unrar X "U:\%%R" FolderB\File.bak
move FolderB\File.bak "C:\test\%%~nR"
rd FolderB
)
and i had to add the unrar.exe path to MyComputer settings (My Computer -> properties -> Advanced -> Environment Variables -> System variables / Path)Code: [Select]:: MD "C:\test\%%~nR"
for /F "delims=." %%R in ('dir /b U:\Archive_200803*.rar') do unrar e "U:\%%R" FolderB\File.bak "C:\test\%%~nR"
1st post

Since I just finished getting a batch script working to unrar password-encrypted RAR files,
I knew there was an easier way... even if this thread is old, it COULD help others.

The make directory MD is not necessary since original poster SAID it would exist.
As well, the previous code example was creating and destroying directories each time for each archive
that it found... makes everything slow and was not necessary... only needed before and after for loop.

For my example, you can extract the file directly without the tree structure by using "unrar e" instead
of "unrar x", and you can also specify the output directory as the last parameter.

Enjoy!

4854.

Solve : looping through files in a given directory?

Answer»

OS : Win XP pro
Problem : file concatenation using filename indexes

Some IDIOT CHOPPED up an mp3 file into 99 pieces of all LESS than 1 minute long chunks. filenames are track## where ## is ranging between 01 and 99. What I am trying to accomplish is:

for i=1 to 99 step 5
for j=i+1 to i+4
copy track(j)+track(j+1)+track(j+2)+track(j+3)+track(j+4) supertrack(j)
continue
continue

I know this code is neither basic nor DOS but I am not proficient in either of these, so goes my question. Is there anyway that I can accomplish this using the command window running under WinXP pro ? If not, what would be a good basic code and where can I get my hands on a copy (freeware) of basic interpreter ?

Thanks for all your help.


maybe try
type *.mp3 >>file.mp3Quote from: diablo416 on October 07, 2008, 09:47:07 PM


maybe try
type *.mp3 >>file.mp3

if only it were so easy. I do not WANT to put all files back together. I like to add 5 small parts to make larger part but still want to have the original file divided into 20 pieces instead of 100 pieces.

I uploaded one directory to my linux webhost where I happen to have shell access, and cobbled up a script in less than 30 minutes to accomplish that. Looking for a DOS/Command only solution to save me the trouble of UPLOADING and downloading files.
4855.

Solve : first time needing help with batch?

Answer»

Quote from: SALMON TROUT on August 28, 2009, 03:54:10 PM

You said that ALREADY.


For billrich.

He only added the star after wait. Quote from: Helpmeh on August 28, 2009, 03:52:04 PM
But dir /B *wait* will display ALL filenames CONTAINING wait in them.
that's per OP's requirement
4856.

Solve : DOS Batch File - Incrementing in Loops?

Answer»

Dias -

Thank you. I appreciate your COMMENT. However ....

Eventually my programs will be ported to UNIX and I need to be able to develop them in DOS so that I can port. Qbasic is a Microsoft Language, that does not exist in UNIX.

If I COULD rely on your expertise, to "think outside of the box", it would be appreciated. In other words, lets see if we can think in an innovative way to solve this.

Does anybody else on this forum have any ideas??

Thanks again.if this is going to be proted to unix, why not transfer the files into unix environment and MAKE use of unix utilities like integer arithmetic at the ksh prompt. What you are trying to do seems to be impossible in the pure dos environment unless you can find a dos COMMAND line calculator to give you increments.

qbasic, along with being from microsoft, is pretty benign language and very easy to comprehend. I believe there are even some free basic interpreters which can use the qbasic code with little to no modification. so learning it would not be so bad of an idea. If you have the basic understanding of programming languages, you are more than half way thru anyways.

good luck

4857.

Solve : Batchfile executing commands from a text file?

Answer»

Is it possible for a batch file to READ a text file and execute it's contents (all of them) in the same window?copy the text file into a batch file.
CALL the batch file
erase the temporary batch file.Quote from: Sky NINJA on October 02, 2008, 09:36:15 PM

in the same window
I need it to be in the same window. Is it possible?The steps I GAVE you will be in the same window.Oh, SORRY. Thank you.
4858.

Solve : find and replace batch file?..?

Answer»

Well I wanted to CREATE a batch file that would go through a text file and replace things. (aka convert)
For EXAMPLE, you find this in a text file:

D%o #$11
))>> $21
BUU

then you drop the text file on to the batch and it coverts it to this:

Lda #$11
Sta $21
Rts

so, is it possible? and what commands would i use?
A cross-assembler?

It's not the commands you need to worry about, it's putting them together in the right order.

Anyhow, we're always ready to help people with their projects, so let's see what you have already written.

If you actually want a complete batch file written for you, as a professional piece of work, my rates start at $50 per hour.


Quote from: Salmon Trout on August 23, 2009, 03:46:12 PM



If you actually want a complete batch file written for you, as a professional piece of work, my rates start at $50 per hour.



Either Salmon is joking or you should ignore him. We are all volunteers here meaning our help is 100% FREE$$$!Quote from: Helpmeh on August 23, 2009, 07:20:06 PM
Either Salmon is joking or you should ignore him. We are all volunteers here meaning our help is 100% FREE$$$!

I was being sarcastic; I have no intention of attempting to charge for any help I give on here (how would I collect?); I merely meant I would much rather see a project that someone has a problem with, and suggest a solution, than write a complex batch script from start to finish from a specification.


To the OP

You can read a text file line by line using FOR, you can split each line up with tokens and delimiters, and you can substitute one string in a line with another using the %string:abc=xyz% notation.
Quote from: Salmon Trout on August 24, 2009, 12:34:49 AM
I was being sarcastic; I have no intention of attempting to charge for any help I give on here (how would I collect?); I merely meant I would much rather see a project that someone has a problem with, and suggest a solution, than write a complex batch script from start to finish from a specification.

That seems more than fair to me too.I also would prefer that, but there are cases that

Person A tells Person B that he can do xyz with batch and learned it from here. Person B comes here and asks for a batchfile that can do as Person A mentioned.

And I've always learned by complete examples, picking them apart to figure them out, and ASK questions if I can't understand a piece of code. Fair enough, but I object to doing student's homework, or IT staff's PAID work, for them
Quote from: Salmon Trout on August 24, 2009, 05:05:05 AM
Fair enough, but I object to doing student's homework, or IT staff's paid work, for them

We're not allowed to help with homework (or is it They aren't allowed to ask questions regarding homework). Quote from: Helpmeh on August 24, 2009, 05:13:30 AM
We're not allowed to help with homework (or is it They aren't allowed to ask questions regarding homework).
we can help with homework, just not giving them FULL solution. Quote from: gh0std0g74 on August 28, 2009, 06:26:25 AM
we can help with homework, just not giving them FULL solution.
True. Pointing them in the right direction is allowed.
4859.

Solve : Path with a variable?

Answer»

I have made a BAT for launching :

"M:\Archivos de programa\Microsoft Office\Office10\WINWORD.EXE" /t "Y:\GABINETE\PROYECTOS\125.09\125.09.Proyecto.doc" /mmacro3

wproof.bat

The bat opens a word document and goes to a bookmark inside executing a macro associated to word.
The bat is launched from an excel cell by a HYPERLINK

But I need the expression "125.09" to be CONSIDERED a variable proposed in another excel cell.


I don't know if this is possible, so any additional consideration is welcome. First time I thought that the variable may be an environmental variable of windows xp system.
Or perhaps a variable in an ini file.
O simple a variable I can define with the excel cell content.
Or perhaps the bat may propose introduce the variable value with no problem and propose that value in the excel cell as a memory help of the expedient is opened.
"125.09" is the expedient reference.

So :

"%PROGRAMFILES%\Microsoft Office\Office10\WINWORD.EXE" /t "Y:\GABINETE\PROYECTOS\%xvar%\%xvar%.Proyecto.doc" /mmacro3


*******************
@ echo off
set xvar = %1


How can I do please ?


How can I propose the variable value in an excel cell ?

How can I define exactly the variable ?

BEST Regards








4860.

Solve : I have a wierd problem with a batch...?

Answer»

Hi,

I have a weird PROBLEM with my batch.

I am not looking in to programming batches. but when I made my text file (through VB) it give me the error attached. Ignore the second part, that is the one that works.

Thanks

Oaks99


[ATTACHMENT deleted by admin]post your code
DOS can understand and obey the "GOOD" bit which commences "start"

It is clearly telling you it does not understand 'squiggle squaggle squat" that PRECEDES your intended "start".

Somehow you have got some junk foriegn characters at the start of the command line.

Alan
p.s. you should use a proper text editor, of which WINDOWS notepad is the simplest/crudest.

Word processors and probably VB are NOTORIOUS for starting the file with junk,
e.g. commands for page formatting etc.

Alan

4861.

Solve : command in my batch file?

Answer»

ALAN_BR, after I MADE that assertion, I did some experiments and came to a SIMILAR conclusion. Also, I found these things out:

Quote

Zonealarm adds the line "Set tvdumpflags=10" to Win98SE autoexec.bat file..It's probably a variable for the tvDebug.log file which Zonealarm creates when it has a problem.

Quote
verflop.com ... may be connected with the KAK worm

I think the "batch file" in question may be the autoexec.bat of an infected Win98 system.



Quote from: Dias de VERANO on October 07, 2008, 03:41:23 PM
Quote
verflop.com ... may be connected with the KAK worm

I think the "batch file" in question may be the autoexec.bat of an infected Win98 system.

i think we should get broni or evil in this CONVERSATION to check this out.
4862.

Solve : Can I use FORFILES to remove folders of files??

Answer»

I have a backup script that places the backup file into a current DATE folder. I want to use a script to say truncate all folders that are earlier than 30 days from today's date

I do have a FORFILES script but it appears it is for files only. Is there a syntax to delete groups of folders based on the file system create date?

Thanks"FORFILES script" is not a specific description., but Google found :-
http://www.pcreview.co.uk/forums/thread-1466456.php

That was posted by someone who wished to avoid the default action of DELETING Folders as well as files - i.e. he did not like the default which you seem to require.

Regards
Alan
Ok then what DOS command would I use to delete folders with files after x given days...

if its possible, you can DOWNLOAD findutils (see my sig), and use the find command (different from Windows own find command)
Code: [Select]c:\test> find c:\test -type f -mtime +1 -delete

the above delete files more than 1 DAY old. adjust as needed.BAM01 gave me this..

Quote from: BAM01 on June 24, 2009, 01:53:34 PM

Haven't tried this yet but it's supposed to move files to a second folder if they are 365 days old

forfiles /p E:\path /m *.* /d -365 /c "cmd /c move @file e:\DELETE.FILES"




Will try it out.
C:\>rmdir /?
Removes (deletes) a directory.

RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path

/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
tree.

/Q QUIET mode, do not ask if ok to remove a directory tree with /S

C:\>Quote from: billrich on August 23, 2009, 08:26:50 AM
C:\>rmdir /?
Removes (deletes) a directory.
it just removes directory, but does not check for X days to delete. extra code is needed.
4863.

Solve : Question about FINDSTR command?

Answer»

When using the following code to check about the content of a text file (test.txt),
I get a blank screen and to quit by cntrl+C.

@echo off
findstr ^/ test.txt > nul
if %errorlevel%==0 (
echo Found!
) else (
echo No matches found
)
pause
exit

It works fine for ^\, ^| and ^?

Any idea about the problem?

Thanks,
Thomas Try:

Findstr /C:/ Test.txt > Nul

The others (\ ?) will probably work without being escaped, the pipe char will always have to be escaped.

Good luck.

Yes, it works perfect.

May I know the reaon to add c:/ ?

Thanks,
Thomas

In Findstr /C: is a switch and the following / is the string to be found as a literal. Don't CONFUSE the switch /C: with the partition C:\

Entered at the Command Prompt Findstr/? shows:
Quote

Searches for strings in files.

FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file]
[/C:string] [/G:file] [/D:dir list] [/A:color attributes] [/OFF[liNE]]
strings [[drive:][path]FILENAME[ ...]]

/B Matches pattern if at the beginning of a line.
/E Matches pattern if at the end of a line.
/L Uses search strings literally.
/R Uses search strings as regular expressions.
/S Searches for matching files in the current directory and all
subdirectories.
/I Specifies that the search is not to be case-sensitive.
/X Prints lines that match exactly.
/V Prints only lines that do not contain a match.
/N Prints the line number before each line that matches.
/M Prints only the filename if a file contains a match.
/O Prints CHARACTER offset before each matching line.
/P Skip files with non-printable characters.
/OFF[liNE] Do not skip files with offline attribute set.
/A:attr Specifies color attribute with TWO hex digits. See "color /?"
/F:file Reads file list from the specified file(/ stands for console).
/C:string Uses specified string as a literal search string.
/G:file Gets search strings from the specified file(/ stands for console).
/D:dir Search a semicolon delimited list of directories
strings Text to be searched for.
[drive:][path]filename
Specifies a file or files to search.

Use spaces to separate multiple search strings unless the argument is prefixed
with /C. For EXAMPLE, 'FINDSTR "hello there" x.y' searches for "hello" or
"there" in file x.y. 'FINDSTR /C:"hello there" x.y' searches for
"hello there" in file x.y.

Regular expression quick reference:
. Wildcard: any character
* Repeat: zero or more occurances of previous character or class
^ Line position: beginning of line
$ Line position: end of line
[class] Character class: any one character in set
[^class] Inverse class: any one character not in set
[x-y] Range: any characters within the specified range
\x Escape: literal use of metacharacter x
\<xyz Word position: beginning of word
xyz\> Word position: end of word

For full information on FINDSTR regular expressions refer to the online Command
Reference.

Hope this helps.Got it !! Thanks.
4864.

Solve : Batch file to log in a username and password?

Answer» GOOD day,

I'm new to this site and i'm a beginner with DOS batch files.

Here goes my question...

I mapped a DRIVE on which i installed a VIRTUAL machine (VPC).

I get tired of always starting the VPC then logging in etc... So i want to create a batch file to:
1. start the VPC
2. Login
3. Start other batch files in the VPC

Anyone know how to write the batch file to do this?

MANY thanks,

Chris I don't THINK it is possible to log yourself in with a batch file.
4865.

Solve : write ping and tracert to a txt file.?

Answer»

Hi! I need help with writing a BATCH file that would ping google.com every 5MINS, tracert google.com every 30mins, save the results to a txt file every 5 hours. if you could help me with this I would be GRATEFUL. You can use the windows scheduler to set off your tasks, logging the results is easy,

AnyCommand > FILENAME
puts the output of AnyCommand into filename, and
AnyCommand >> filename
does the same, but adds it on to the end of the file if it already holds info (> on its own recreates the file)

Graham

4866.

Solve : Batch file to copy files referenced in a text to a location?

Answer»

this should do it

Code: [Select]FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]

or, if usebackq option present:

FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ('string') DO command [command-parameters]
FOR /F ["options"] %variable IN (`command`) DO command [command-parameters]

filenameset is one or more file names. Each file is opened, read
and processed before going on to the next file in filenameset.
Processing consists of reading in the file, breaking it up into
individual lines of text and then parsing each line into zero or
more tokens. The body of the for loop is then called with the
variable value(s) set to the found token string(s). By default, /F
passes the first blank separated token from each line of each file.
Blank lines are skipped. You can override the default parsing
behavior by specifying the optional "options" parameter. This
is a quoted string which contains one or more keywords to specify
different parsing options. The keywords are:

eol=c - specifies an end of line comment character
(just one)
skip=n - specifies the number of lines to skip at the
beginning of the file.
delims=xxx - specifies a delimiter set. This replaces the
default delimiter set of space and tab.
tokens=x,y,m-n - specifies which tokens from each line are to
be passed to the for body for each iteration.
This will cause additional variable names to
be allocated. The m-n form is a range,
specifying the mth through the nth tokens. If
the last character in the tokens= string is an
asterisk, then an additional variable is
allocated and receives the REMAINING text on
the line after the last token parsed.
usebackq - specifies that the new semantics are in force,
where a back quoted string is executed as a
command and a single quoted string is a
literal string command and allows the use of
double quotes to quote file names in
filenameset.

Some examples might help:

FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k

would parse each line in myfile.txt, ignoring lines that begin with
a semicolon, passing the 2nd and 3rd token from each line to the for
body, with tokens delimited by commas and/or spaces. Notice the for
body statements reference %i to GET the 2nd token, %j to get the
3rd token, and %k to get all remaining tokens after the 3rd. For
file names that contain spaces, you need to quote the filenames with
double quotes. In order to use double quotes in this manner, you also
need to use the usebackq option, otherwise the double quotes will be
interpreted as defining a literal string to parse.

%i is explicitly declared in the for statement and the %j and %k
are implicitly declared via the tokens= option. You can specify up
to 26 tokens via the tokens= line, provided it does not cause an
attempt to declare a variable higher than the letter 'z' or 'Z'.
Remember, FOR variables are single-letter, case sensitive, global,
and you can't have more than 52 total active at any one time.

You can also use the FOR /F parsing logic on an immediate string, by
making the filenameset between the parenthesis a quoted string,
using single quote characters. It will be treated as a single line
of input from a file and parsed.

Finally, you can use the FOR /F command to parse the output of a
command. You do this by making the filenameset between the
parenthesis a back quoted string. It will be treated as a command
line, which is passed to a child CMD.EXE and the output is captured
into memory and parsed as if it was a file. So the following
example:

FOR /F "usebackq delims==" %i IN (`set`) DO @echo %i

would ENUMERATE the environment variable names in the current
environment.

In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:

%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string

The modifiers can be combined to get compound results:

%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
%~fsI - expands %I to a full path name with short names only
%~dp$PATH:I - searches the directories listed in the PATH
environment variable for %I and expands to the
drive letter and path of the first one found.
%~ftzaI - expands %I to a DIR like output line

In the above examples %I and PATH can be replaced by other valid
values. The %~ syntax is terminated by a valid FOR variable name.
Picking upper case variable names like %I makes it more readable and
avoids confusion with the modifiers, which are not case sensitive.Hey, many thanks for all this detail!

Sp.its just going to the command prompt and typing "for /?" Quote from: BatchFileBasics on August 26, 2009, 10:22:14 AM

its just going to the command prompt and typing "for /?"

It seems like magic to some people.
Quote from: Salmon Trout on August 26, 2009, 10:38:56 AM
It seems like magic to some people.


But it is magic!

BTW, I know I'm pushing my luck here however, is it possible SOMEHOW to find out the total duration of the copying procedure? i.e. the START and End time???Code: [Select]set time1=%time%
your process here
set time2=%time%
echo started %time1%
echo finished %time2%It basically starts copying and once all files are copied cmd closes so can't really see whether it reports the time taken for the process.

Any thoughts?

Many thanks in advance!

Edit: Done it! Added a pause statement at the end of the script and I can now confirm it works fine! Many thanks again.
4867.

Solve : Starting Two-worded files?

Answer»

Yea, I SAW that and tried start "Example.txt" and it didn't work. I'm just confused as to why start "" "Example Text.txt" WORKS. It appears to mean a new window with no title and then the FILE you want to open.

Once again thanks and SORRY for all the questions.Quote from: Svarog on October 01, 2008, 05:32:15 AM

Once again thanks and sorry for all the questions.

Hehe, no worries. We thrive on them.
4868.

Solve : if statement in *.ksh file?

Answer»

Hi,

i used following syntax in batch file (startup.bat):
Code: [Select]if not exist ($?VAR) set VAR=%cd%
Can anyone help me out how i can define it in startup.ksh file ?

THANKS in ADVANCE for help.Should i define like: Code: [Select]if [ ! -s $VAR ]; then
export VAR=$PWD
if

is this code block WORKS?Code: [Select]if [[ -z $VAR]]; then
export VAR=$PWD
fi

this solves the problem awww you solved it yourself!

See now this is what life teaches you, ''believe in yourself''

Way to go girl!!

4869.

Solve : email details?

Answer»

System model number? Is it located in a file too?Yeah i believe it also has to be queried using WMI. I can't find anything when i GOOGLE it and i did have this working about 3-4 years ago. I just can't find my documentation.Quote from: Helpmeh on August 26, 2009, 04:05:49 PM

By briefly looking at the code I can tell that it requires outlook. Is there a code to do the same thing without outlook?

CDO.


http://www.paulsadowski.com/WSH/cdo.htmYes it does require Outlook. This is not a big deal because the mail is only internal mail to the IT department. The email SIDE of it is working. Okay, i found the way to display the model of your computer. However, i can not seem to get it to work in the "for" command.

This is how to get the model (will not work on all machines, but works with DELL)
Code: [Select]wmic csproduct get NAME
and this is how i added it to the BAT:
Code: [Select]for /F %%a in ('wmic csproduct get name /value^|find "name"') do set namestring=%%a
for /F "tokens=1-2 delims==" %%b in ("%namestring%") do set name=%%c
This is the entire BAT thus far:
Code: [Select]@echo off
@Title "Verifying Computer Details"

for /f "tokens=2*" %%b in ('net USER "%Username%" /domain ^| find /i "Full Name"') do set DisplayName=%%c
for /F %%a in ('wmic bios GET SerialNumber /value^|find "SerialNumber"') do set sernumstring=%%a
for /F "tokens=1-3 delims==" %%b in ("%sernumstring%") do set sernum=%%c
for /F %%a in ('wmic bios GET name /value^|find "name"') do set namestring=%%a
for /F "tokens=1-2 delims==" %%b in ("%namestring%") do set name=%%c

echo Full Name.........%displayname% >>"U:\IT\Details.txt"
echo Username..........%username% >>"U:\IT\Details.txt"
echo Computer Name.....%computername% >>"U:\IT\Details.txt"
echo Serial Number.....%sernum% >>"U:\IT\Details.txt"
echo Model Number......%name% >>"U:\IT\Details.txt"

call "%~dp0\Email.vbs"

call "u:\delete.bat"

echo on
Thank you for the assistance everyone! I hope some of this TOPIC is helping someone out!
4870.

Solve : RENAME DIRECTORY USING CLIPBOARD DATA?

Answer»
Hii everyone.

i hav seen all ur questions n answers.. all r very good answers.

now i need a HELP from u frnds.

i want to rename a folder from clipboard DATA.

suppose example. i copied a text "1-ABC123456", i want to create a folder with that name. 1-ABC123456.dir

(everytime name changes, so when i copy and run any batch program, it should create a folder with that text which i hav copied)

Thanks in advance frnds.

hope i get results soon

byebye


I'm having a difficult time visualizing what you want to do.

Batch code cannot interact with the clipboard which is a Windows component. Actually you'll need Internet Explorer to copy data to or paste data from the clipboard.

Quote
(everytime name changes, so when i copy and run any batch program, it should create a folder with that text which i hav copied)

How does 1-ABC123456 get on the clipboard? Is 1-ABC123456 a string? Does it represent text from a file? If it's simply a string, you can persist data in batch by using the environment space or the file system.

Need more details to be helpful.

Thanks for your reply..

but am really sorry.

1-ABC123456 is not any string nor anything. i just gave an example of folder name.

actually i have a list in online ...
1-ABC53452
1-ABC54567
1-ABC87452
1-ABC95457
1-ABC98665
1-ABC78934
1-ABC89034
1-ABC67893
....
....
...

(it goes approximately 1000 or above names i think)

so i have to create folders with each of the name from the above list. (above all are folder names not any special characters nor any string nor any codes.)

Create a folder in my desktop with a name from the above list.

for example if u take any name from the above list. 1-ABC53452 is a name,
with this name i have to create folder.

(and onemore thing we cant download all names at a time. each name comes one by one)

=> copy a name from online ..
=> and create a folder in LOCAL DRIVE with new name.
thats how GOING on.

i just wanna to know ...is there any shortcut by running any batch program

pls let me know.. if u still cant get it.

i will try to explain more detaeiledif this page online is plain with just that names you can use wget to download copy of site to a disk and then use for command
4871.

Solve : REMOTE DEKTOP BATCH FILE?

Answer»

Dear Friends

I would like to write a windows bath file for the following

to open remote desktop connection (mstsc)
provide computer name " computername"
provide user name " user name"
provide user password " password"
provide domain name "domain name"

to start the programme
program path and file name "d:\notepad.txt"
start in folder "d:\ "

Please help me out

I want to CONTROL my remote user to access only a particular programme not
any other folder or even desktop
also tel me if there is any easiest alternative method


thanks in advance


RAMESH shettySo you want to make a batch file start remotely on another computer and save a text file with information about the User and Computer?Quote from: Carbon Dudeoxide on October 06, 2008, 06:00:10 AM

So you want to make a batch file start remotely on another computer and save a text file with information about the User and Computer?

You can't be too SKETCHY on this one. You need to login with the other user's Username and Password just to access the remote desktop.Thanks friends

I have created dos batch file , which creates temperory rdp connection and runs rdp which is WORKING fine

but I am not sure WETHER it will work in all os's, It is working fine in win xp

thanks
ramesh shettyWe will have to see the code.

Also, since we are talking about batch files, I'm moving this to the MS DOS Section.
4872.

Solve : write long file names with pkunzip?

Answer»

Hi,

I'm trying to write a batch file to unzip filenames that are longer than the 8.3 DOS naming convention. For example I want to unzip a file LIKE Very_Long_Filename.txt in zipfile.ZIP to a new DIRECTORY.

I want to preserve the filename as Very_Long_Filename.txt and not get Very_lon.txt with DOS 8.3 naming convention. Is there a way to do this with PKUNZIP?

Are there other unzip utilities out there with a command line interface that can execute a DOS batch file? Any help would be greatly appreciated.What OS are you using?
http://en.wikipedia.org/wiki/Long_filename

Quote from: rgalecki on August 24, 2009, 07:58:40 AM

Hi,

I'm trying to write a batch file to unzip filenames that are longer than the 8.3 DOS naming convention. For example I want to unzip a file like Very_Long_Filename.txt in zipfile.zip to a new directory.

I want to preserve the filename as Very_Long_Filename.txt and not get Very_lon.txt with DOS 8.3 naming convention. Is there a way to do this with PKUNZIP?

Are there other unzip utilities out there with a command line interface that can execute a DOS batch file? Any help would be greatly appreciated.

I believe that PKUnzip cannot do what you want. I've used it for years, and either just get used to the truncated file names, or simply don't use PKUnzip when I have long file names to deal with.


Check out 7-zip .
http://www.7-zip.org/download.html
There is a command line version, and a GUI version.
( I keep a copy of the command line version in my utils directory, in the path)


I just tried the command line version here, and it handled long file names just fine.
Both zipping and unzipping.
7-zip does other formats besides PKZip compatible, so if you want to work with plain old PKZip type files, be sure to get the command line switches correct.

Also, check out Zip and Unzip:
http://www.info-zip.org/
It almost does not matter what operating system you have... there is a version of Zip and Unzip for it.

All are free.

This is baffling me SLIGHTLY:

Quote
Are there other unzip utilities out there with a command line interface that can execute a DOS batch file?

Does he mean "that can be called from a DOS batch file?"

And does he really mean "DOS"?

Thank you all for your replies. I found another utility: pkzip v2.5 from pkware. That one works just fine.
4873.

Solve : Batch file : replacing text part in files with FOR command?

Answer»

Hello,

I have a TexRep software from No Nonsense Software. I can make my changes singly.
I'ld like to make my changes automatically. It means, there are several .htm files in a folder and NEED to change TEXT PARTS in this files. How can I do it with FOR command in a batch file?
e.g:
texrep *.htm "texttofind" "replacewith"

Sorry if it is an resolved issue but I couldn't find.
Thanks,
CsabaText files cannot be updated in place with batch code. This little snippet produces output files with a chg extension.

Code: [Select]@echo off
setlocal enabledelayedexpansion

set /p search=Search String=
set /p replace=Replace With=

for %%v in (*.htm) do (
for /f "tokens=*" %%a in (%%v) do (
set newline=%%a
set newline=!newline:%search%=%replace%!
echo !newline! >> %%~nv.chg
)
)

If not run from the htm directory, you may have to add paths to the code.

Good luck. Quote from: Sidewinder

Text files cannot be updated in place with batch code.

You can PRODUCE a new file which contains the CHANGED text, delete the original file, then rename the new file with the original name.
4874.

Solve : Another question?

Answer»

I'm a newbie and need some help from you, the experts

I am in need of a batch file that can help me to automatically change the attribution of a specific file in a specific location and then delete it. In my case, the file name is autorun.inf (with attribution System, hidden, read-only on it) located in an USB STORAGE device.

I started my batch file by using notepad with the content like this:
Code: [Select]attrib autorun.inf -s -h -r
del autorun.inf
My problem is that I can only execute the batch file in the root directory of my USB storage device to delete the file autorun.inf. Can you help me to improve the batch file so that I can run it in any PC (other location than my USB storage device) and get the file autorun.inf deleted.

All things are done in the built-in MS.DOS of Microsoft windows XP (SP 2)

P.S: the autorun.inf I mention above can be exploited to automatically run virus files upon navigating to the USB storage device from My Computer. I think that by deleting autorun.inf, I can no longer suffer this. But, like everyone, I want the batch tool easy to use just by the double-clicking of the mouse.

Thanks for all your help!So bored to wait for a reply, I get myself out this way:

Code: [Select]@ECHO OFF
ECHO Please Enter your removable drive letter
SET /P CHOICE="Letter: "
ATTRIB %CHOICE%:\autorun.inf -s -h -r
DEL %CHOICE%:\autorun.inf
EXIT

I'll appreciate if someone help me to rebuild this batch file with the same purpose but user do not need to enter anything. You should not hijack other people's threads. Start a new one.
Quote from: Dias de verano on OCTOBER 02, 2008, 10:22:55 AM

You should not hijack other people's threads. Start a new one.

Yes, agreed.Split.Thanks! I'm new here and so shy to post a new one! Sorry

Nice day! Dias de verano ^^!
4875.

Solve : display file name and label name in batchfile?

Answer»

Is there a way to returning the name of the current label that is running in a batchfile onscreen (or to a log). And is it possible to have a batchfile write it's own name to a logfile? This would save on hardcoding.

Code: [Select]:Test1
ECHO program = %currentfile % >> c:\temp\mylog.txt
ECHO Label = %currentlabel % >> c:\temp\mylog.txt
if exist "C:\debt\bills.xls" (goto Test2) Else (goto End)
goto Test2

:Test2
ECHO program = %currentfile % >> c:\temp\mylog.txt
ECHO Label = %currentlabel % >> c:\temp\mylog.txt
Ren "C:\debt\bills.xls" "pay.xls"

:End
Thank you
dramklukkelIf you have not used Shift, then %0 refers to the batch name :
>Logfile.txt Echo %0

or for the full path
>Logfile.txt Echo %~f0

There is no simple way of IDENTIFYING the current label - however most good editors would allow you to create a macro that locates each label then uses that value to create the next line that echos it to the logfile. C:\>type batchname.bat
Code: [Select]@echo off
set optionone=%1
echo optionone = %optionone%

set batchname=%0

echo batchname = %batchname%
Output:

C:\>batchname.bat Joe
optionone = Joe
batchname = batchname.bat
C:\>

_____________________________


C:\>type batchname.bat
Code: [Select]@echo off
set optionone=%1
echo optionone = %optionone% > mylog.txt

set batchname=%0

echo batchname = %batchname% >> mylog.txt

echo My log.txt :
echo.

type mylog.txt
Output:

C:\> batchname.bat Joe
My log.txt :
optionone = Joe
batchname = batchname.bat
C:\>You could do it by assigning a variable for the current label.
Code: [Select]@echo off
:Test1
Set lbl=Test1
ECHO program = %~f0% >> c:\temp\mylog.txt
ECHO Label = %lbl% >> c:\temp\mylog.txt
if exist "C:\debt\bills.xls" (goto Test2) Else (goto End)
goto Test2

:Test2
Set lbl=Test2
ECHO program = %~f0% >> c:\temp\mylog.txt
ECHO Label = %lbl% >> c:\temp\mylog.txt
Ren "C:\debt\bills.xls" "pay.xls"

:End
for batch name use %0
for label name i dont know what you meanQuote from: smeezekitty on August 25, 2009, 01:24:47 AM

for batch name use %0
for label name i dont know what you mean


C:\>label
Volume in drive C: is Free
Volume Serial Number is F4A3-D6B3
Volume label (ENTER for none)?
Delete current volume label (Y/N)? ^C
C:\>

( I have used computers since 1968 and have never had need for the label information. )Quote from: gpl on August 24, 2009, 05:23:28 AM
If you have not used Shift, then %0 refers to the batch name :
Used Shift? You mean like the Shift Key on the keyboard? What does it do?

Quote from: gpl on August 24, 2009, 05:23:28 AM
good editors would allow you to create a macro that locates each label
YEAH yeah, rub it in.

Thank you gpl.
dramklukkelQuote from: dramklukkel on August 26, 2009, 12:52:09 AM
Used Shift? You mean like the Shift Key on the keyboard? What does it do?

The SHIFT command in a batch file, which shifts the parameters %1 %2 %3 ETC down by one each time it is used. So %1 becomes %0 and %2 becomes %1 and so on.

%0 is normally the command line used to start the batch (i.e. its name and sometimes its drive letter path as well DEPENDING on how it is invoked) but if SHIFT is used then it is lost because it is replaced by the contents of %1 %2 %3 etc (if there are any) or a blank (if there are not)
Quote from: billrich on August 25, 2009, 12:09:19 PM
( I have used computers since 1968 and have never had need for the label information. )

Thanks for your reply Billrich,

The 'LABEL' in this case is not the drive label, but he label where GOTO refers to.
Returning the name of that label helps you debugging. When reading a log you can see what route the program has followed, what labels it has passed/skipped, or sometimes if it has crashed.

In my example the labels were called :Test1, :Test2 and :End.

You are right about the drive label. I can find no use for it except for easy reading.

grt
dramklukkel.Thanks you all for your valuable input.
I appreciate it.

grt, dramklukkelQuote from: oldun on August 25, 2009, 01:22:05 AM
You could do it by assigning a variable for the current label.
Code: [Select]@echo off
:Test1
Set lbl=Test1
ECHO program = %~f0% >> c:\temp\mylog.txt
ECHO Label = %lbl% >> c:\temp\mylog.txt

I see, but this means I have to assign every single label. That way I might as well hardcode it and skip the variable.

Code: [Select]@echo off
:Test1
ECHO Label = Test1 >> c:\temp\mylog.txt

Wich is basically what I was doing allready. My intention was to not having to write out every label. Thus not risking errors while typing or failers after renaming labels. Rather I'd have a single line that I can copy over and over, without having to think about it.
Oh dear, I'm spoiled.

greetings,
Dramklukkel.
Quote
That way I might as well hardcode it and skip the variable.

Even better code it so you don't use gotos & labels. It is possible, and I see you already understand this...

if [test] (something1) else (something2).

Extend it to...

if [test] (
something1
something2
) else (
something3
something4
)

4876.

Solve : Xcopy - certain file extensions only .pdf?

Answer»

I've set up the xcopy command in a batch so i can schedule it to run overnight - I'm useless with DOS so I just set up a basic xcopy as all I NEED is to move files from one folder to another (see below).

@echo off
xcopy Y:\mi\WebPublishing\Students \\Gi-studnet\nexus\Timetables /y

It works brilliantly but all i want to move is the .pdf timetables only and not everything else that is generated with them - what am i missing and where should it be entered.

thanks for the help guysI like your coding style, simple, concise, to the point.

This will copy all the pdf files:

Code: [Select]@echo off
xcopy Y:\mi\WebPublishing\Students\*.pdf \\Gi-studnet\nexus\Timetables /y

Quote

It works brilliantly but all i want to move is the .pdf timetables

Are all pdf files timetables? If not, is there a way to distinguish a pdf timetabe from other pdf files. You may have to narrow the wildcard search.

Cheers sidewinder, I thought (more hoped) it would be something simple like my coding!!

I've tested it on a random sample but it didn't work, I tried it without the *.pdf and it copied all the files from 1 folder to another no problem. The pdf files are all named either s1234 or p12345 if this helps (1234 etc being a random 4/5 digit number)

All timetables are the only pdf's in the folders

cheers for the help I knew i'd need it.Quote
I've tested it on a random sample but it didn't work

How didn't it work? Error messages? Incorrect results? When you ran it without the *.pdf filter were any pdf files copied?

The *.pdf indicates to the machine you only want pdf files. If nothing was copied, I can only think that there are no pdf files in Y:\mi\WebPublishing\Students.

Is this code part of a larger group of code?



No error messages - when I ran it without the *.pdf it copied everything in the folder!! This is where I'm having trouble it should all run smoothly but it refuses for some reason to pick up the pdf's!!

An example of what's listed in the folder is:

d20index 4KB HTML Document
shrink 1KB GIF Image
p13629 11KB Adobe Acrobat Document (this being the timetables)

I don't need all the html etc just the pdf's.

There is no larger code is like you stated at the begining very simple/concise!!

CURIOUSER and curiouser!

I don't mean to sound condescending, but does that p13629 file actually have a pdf extension? Will you post a directory listing of that directory? I'm looking to see the file extension not the file type.

Quote
This is where I'm having trouble it should all run smoothly

You're absolutely right. This is pretty simple stuff.



in xcopy if copying a file from one directory to another where the file does not already exist, it will prompt the user for input: press F if object is file and D if directory, its frustrating

Run your batch and tap the F key a few times, it will copy one .pdf for each F if my guess is correct.

You can output your command to a log file to see the prompts sent to your batch when troubleshooting.

example: XCOPY /F "\\servername\c$\temp\*.pdf " "\\servername\d\mydir\" >> log.txt 2>&1Hi

All DOS commands respond to the /? option. Always worth a go

XCOPY /? lists a tremendous range, including :-
/L to tell you what it would have done - can save the embarrassment of copying C:\Windows\... to a floppy disc etc !!!
/I which may overcome any ambiguity over whether the destination is a file or a Directory.

Regards
Alan
Although NOT new to DOS, I'm new to this particular forum and I'm reading it with great interest. Thank you guys for a great forum.

Now my question:
In the above posts I see the XCopy line with double backslashes in it ( \\ ).

What's that all about? I'm used to using more precise path statements.

By the way, I save many hours every week by doing things with batch files rather than trying some other method. I use a batch file in my Startup folder to remove as many temp (garbage) files as I can that were generated the day before.

But I've never used that double backslash.

Help?

The Shadow Hey Shadow,

Check out the lower part of this link for some explanations.
http://en.wikipedia.org/wiki/Path_(computing)

hope that helps
NTWell, today I guess I'm batting a big fat Zero,
because that link told me nothing about double backslashes.

A quick explanation would have sufficed.

Oh well, I'm sorry I asked a question in someone else's thread.

My bad!

Hey Shadow

The double backslash just indicates the directory on a different server/pc; if you're copying local to local then you dont need them. XCOPY is most useful from one machine to another, otherwise just use COPY.

I'm a little new to this forum as well, at least as far as posting so maybe I ADD a step in there that wasn't asked for. Sorry for the confusion.Hey, the confusion was all mine.

I do remember \\ being used to express a folder on a Server or other PC on a network, but I didn't see how that applied to this thread.

I don't do networking, so that really eluded me, till you explained it.

Again, my apologies, and thanks for the clarification.

I really appreciate yous guys!

Quote from: r0mad on September 26, 2008, 02:55:25 PM
in xcopy if copying a file from one directory to another where the file does not already exist, it will prompt the user for input: press F if object is file and D if directory, its frustrating

Run your batch and tap the F key a few times, it will copy one .pdf for each F if my guess is correct.

Hi r0mad, I had the same problem until I found the "/I" switch, which has the effect that "If destination does not exist and copying more than one file, assumes that destination must be a directory".

Here's my code suggestion below. It uses relative paths instead opf absolute paths, and assumes you want to copy pdf files in the 'targetDirectory" and it's subdirectories to a temporary location.

Code: [Select]xcopy .\targetDirectory\*.pdf .\myTempDir /S /F /-Y /I
Hope this helps.
With the myriad and various switches available to XCOPY, you can do almost anything you want to with it.

I keep "My Documents" backed up to my second HD with this simple one-line batch file which I run manually, every few days. I could also put that backup batch file in my startup folder for a free backup every time I reboot my PC.

xcopy "C:\Documents and Settings\MyUserName\My Documents\*.*" "D:\My Documents\" /s /y /H /R /D

I use similar batch files to back up all my email files and other select folders.

I've been using xcopy now for more years than I really want to admit to, and I'm constantly finding new uses for it.

Here's a list of the xcopy switches:
************************************************
Copies files and directory trees.

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.
*****************************************

So you see, with that long list of switches, xcopy can and does do many different chores. For me xcopy replaces at least a half dozen programs and is much easier to set up and use.

I hope this all helps someone.......somewhere.

Cheers Mates!
the Shadow
4877.

Solve : Batch file - Filenames when using wildcards?

Answer»

Can it be done, when sending multiple files to a command using a wildcard, such as in...
Code: [Select] FOR %%X IN (*.txt) DO COMMANDthat each filename sent to the command can be somehow got/captured as it is passed along?

I would like to save each filename to a variable as the file is sent to the command, then, when the next file is sent, replace the variable with the next filename.

An example:

File #1 of 10 gets sent to the command, I need to know that filename so i can do something like the following:
Code: [Select]...DO COMMAND [string manipulation of filename for File #1]
Hope that makes sense, let me know.

Thanks for the help. try this

set c=0
for %%X IN (*.TXT do (
call set c=%%c%%+1
call set c.%%c%%=%%X
)



that would set all filenames into variables , c.0 + 1
example:
%c.1%
%c.2%
%c.3%
Thanks for the quick reply diablo416.

I think that might be close to what I need, but instead of each filename getting its own variable, I need just one. One variable that KEEPS getting replaced as each new file is sent to the command.

Thanks again.

for %%X IN (*.TXT do (
SET VARIABLE=%%x
command
)
@ Dias DE verano
Thank you, that was remarkably SIMPLE. I had actually tried it before but believed it not to work, as I had not looked at the output carefully. Perhaps it still may not work fully with what I need to do.

Here is the source of my confusion:
Code: [Select]FOR %%X IN (*.TXT) DO (
SET test=%%x
command [command parameter in which I call variable(test)]
)I call the variable(test) like so, %test% , however this does not work.
Additionally, variables I set outside of this specific FOR command, work fine, however it should be noted these have hard set values, UNLIKE variable(test) with its value of %%X.

So, the question is, how do I call variable(test) in my command's parameters?

Thanks for the help.Google for the topic "delayed expansion".
Thanks Dias de verano, I got it WORKING now.

-edit-

I just read the previous thread I had started, where you explicitly warned me about this, my bad.

4878.

Solve : Win/Batch: How to extract string from a quoted string?

Answer»

Hello again,

Now I am going to perform checking of users' input about the file(test.txt)
and gives ADVISE for user inputs.

Again the test.txt consists of 3 lines:
IP username= password=
ATTACH NODE
!

Users are required to change the content and here is an example:-
IP 10.1.1.1 username=abcd password=00000
ATTACH Node "Test"
!

However, if user forgot to input the required field, that is
if the file content still consists of < character, it will display
message that advise user to input the corresponding field

such as:
- for , it will display a message to
tell user to input IP address.

- for username=, it will display a message to
tell user to input username.

- for password= it will display a message to
tell user to input password.

- for ATTACH Node , it will display a message to
tell user to input node_name

I think I have to use FOR function but which token and delimiter
do I need to used?
Also please teach me how to test for the present of character
< and >


Thanks,
ThomasAs checked out from other screens, I found
the solution as shown. Just want to share
with OTHERS for interest. Please FEEL free
to comment.

==========================================
@ECHO OFF
REM
FINDSTR ^< test.txt > nul
IF %errorlevel%==0 GOTO syntaxERR
REM
FINDSTR ^> test.txt > nul
IF %errorlevel%==0 GOTO syntaxERR
REM
:syntaxERR
ECHO ****************** syntaxERR ***********************
ECHO.
ECHO Some parameter^(s^) in test.txt cannot parse!
ECHO.
ECHO Please check the content of test.txt.
goto end
REM
REM
FOR /f "tokens=3*" %%a IN (test.txt) DO SET sysname=%%a %%b
REM
FINDSTR IP test.txt > temp_line1.txt
FOR /f "tokens=2,4,6 delims== " %%c IN (temp_line1.txt) DO (
SET ip=%%c
SET user=%%d
SET PASS=%%e )
IF EXIST "temp_line1.txt". (DEL/q "temp_line1.txt" > nul.)
REM
ECHO.
ECHO Current settings in test.txt: -
ECHO.
ECHO IP %ip%
ECHO username=%user%
ECHO password=%pass%
ECHO ATTACH Node %sysname%
ECHO.
ECHO Please verify
REM
:end
pause
exit
================================================

4879.

Solve : rename folder?

Answer»

I want to RENAME a folder to the folder name plus today's date. I have a general idea of how to do this but I can't get the syntax correct.
example:
gem.train changes to gem.train_today's dateCode: [Select]ren gem.train gem.train_%date%
EDIT:

what you see when you type in cmd echo %date% ??echo %date%
Tue 09/23/2008

batchfile.bat
ren gem.train gem.train_Tue 09/23/2008
The syntax of the comand is incorrectshould work now
Code: [Select]ren gem.train "gem.train_%date%"ren c:\gem.train "gem.train_%date%"
The system cannot find the path specified.You need to strip the '/' characters out of the date first

Code: [Select]ren c:\gem.train "gem.train_%date:/=%"
Its always handy to stick an ECHO in front of the command while you are trying it out, so you can see what it will be trying to do, then when the command line looks ok, remove the echo and away you go
GrahamThat's it. Thanks allHi Grammie85. Glad to see you found a solution, & sorry I came to the party late. For further variety, try PLAYING around with the code below. (I modified it from code I found on the web). Cheers! (Of course, it assumes the necessary files & folders are in place already, and it renames the orginals WITHOUT further MODIFYING them).


Code: [Select]REM --> Renames a File or Folder with a TIMESTAMP. Keeps Folder Contents Intact.
REM ---------------------------------------
echo off
set hh=%time:~0,2%
if "%time:~0,1%"==" " set hh=0%hh:~1,1%
set yyyy-mm-dd__hh.mm.ss=%date:~10,4%-%date:~4,2%-%date:~7,2%__%hh%.%time:~3,2%.%time:~6,2%---%date:~-0,3%
set myDate01=%date:~10,4%-%date:~4,2%-%date:~7,2%
set myDate02=%date:~10,4%-%date:~4,2%-%date:~7,2%__%hh%.%time:~3,2%.%time:~6,2%
echo on

move tempZip.zip LogArchive%yyyy-mm-dd__hh.mm.ss%.zip
move tempFile.txt tempFile%yyyy-mm-dd__hh.mm.ss%.txt
move tempFolder tempFolder%yyyy-mm-dd__hh.mm.ss%
move testFile01.txt testFile01%myDate01%.txt
move testFile02.txt testFile02%myDate02%.txt

4880.

Solve : xcopy help?

Answer»

he code i have is this

@ECHO OFF
cls
xcopy "%userprofile%\desktop\DdotBat v1.5.lnk" "%userprofile%\appdata\roaming\microsoft\windows\startmenu/programs"

pause


the batch FILE SAY 1 file copied but it is not there any help please
Quote from: DKSNOWDON on AUGUST 25, 2009, 09:54:54 AM

@ECHO OFF
cls
xcopy "%userprofile%\desktop\DdotBat v1.5.lnk" "%userprofile%\appdata\roaming\microsoft\windows\startmenu/programs"

pause
what BFB is TRYING to say is the slash is the wrong direction
4881.

Solve : bat file help?

Answer»

Hi guys need some help over in this problem. I want to execute a series of commands as follows

Basically i need to execute these 3 commands from the command prompt.
1)console.exe>answer.txt (execute this command and OUTPUT to answer.txt)
2)are you a computer (string used to ask a question for the chat bot to REPLY)
3) /exit (exit the program)
when I do these 3 commands from the command prompt, It works out and the output(answers.txt) contains my answer.

But when I write these 3 commands to a bat file as follows

console.exe>answer.txt
are you a computer
/exit
exit

It only executes the 1st part of the bat file which is

console.exe>answer.txt

Just want to ask where have I gone wrong in the bat file scripting?
Any feedback is welcomed thanks.can you explain what console.exe does? , in a batch file writing are you a computer would be a error, you need to echo the WORDS in.. unless console.exe waits for input and thats the purpose of the /exit command?Console.exe is an executable which chats with you when u ask it a question. Thus the are you a computer is the question part.You must follow set batch file language, line for line, and
the second line is NOT a batch file command,
neither is line three.

You really need to study batch file command structure.
There are many good tutorials on the INTERNET, on how to write batch files.

Cheers mate!

4882.

Solve : How to stop the execution of group of batch files when an if condition failed?

Answer»

I have a 6 batch files(sample1.bat, sample2.bat, sample3.bat, sample4.bat, sample5.bat, sample6.bat) which will be EXECUTED one after the other. I have an if condition in the 3rd batch file(sample3.bat).

If this IF condition failed I want to block the execution of remaining batch files (sample4.bat, sample5.bat, sample6.bat)

Please help.. THANKS in advanceWell. If the batch files are executing the next one then just do this:

If something equ something (your commands) ELSE (exit)Quote from: simhadri1985 on August 25, 2009, 04:15:34 AM

I have a 6 batch files(sample1.bat, sample2.bat, sample3.bat, sample4.bat, sample5.bat, sample6.bat) which will be executed one after the other. I have an if condition in the 3rd batch file(sample3.bat).

If this IF condition failed I want to block the execution of remaining batch files (sample4.bat, sample5.bat, sample6.bat)

Please help.. Thanks in advance

Why are they all SEPARATE? Why cannot the CODE be in one file?
4883.

Solve : RENAME FILES IN ONE DIRECTORY USING A BATCH FILE?

Answer»

A bit of a differnet twist to my filename rename issue in a batch file.

I basically was attempting to append a - and a numeric value beginning with 1 to
each file in a directory. My aim was to increase the variable containing a numeric value for each file found and append it to the filename.. e.g. filex-1, filey-2, filez-3.

I tried the following but ended up with the same value of 0 in the variable. Not sure why the variable was not being adjusted..

Hopefully someone can spot where I've gone wrong in the code...

mycode

setlocal enabledelayedexpansion

SET filenum=0


cd D:\TEST

for %%A in (*.txt) do (
@echo on
set /A filenum=%filenum%+1
set oldname=%%A
set newname=%%~nA-%filenum%.txt
rem echo "oldname"
rem echo "newname"

ren "!oldname!" "!newname!"
rem pause
)Quote from: BRIANH

Not sure why the variable was not being adjusted..

Because %filenum% should have been !filenum!
I suspect we're getting close..however the result is not what I had targeted...

The updated file names all have the same variable value..

e.g. filex-1, file-y-1, filez-1

I'm trying to get ---- filex-1, filey-2, filez-3.

My fault in not being able to articulate clearly what I wanted...

The for loop now is coded as:

for %%A in (*.txt) do (
@echo on
set /A filenum=%filenum%+1
set oldname=%%A
set newname=%%~nA-!filenum!.txt
rem echo "oldname"
rem echo "newname"

ren "!oldname!" "!newname!"
rem pause
)You only changed the second %filenum% when you should have changed both.
Terrific !!!! I have exactly what I want...

thanks fo much !!!

One of the issues I have with some of the code is that I don't fully understand how some of the sublties really work... e.g. the significance of the !variable! VERSUS
%variable% within the SCOPE of the FOR statement.. I assume !variable! indicates that the new value of the variable is to be used each time through the loop as opposed to the %variable% which appears to use only the initial value of the variable set during the first loop ... again, just guessing... I've attempted to find some information on this and haven't had much luck...the HELP of the FOR statement does not explain this well....The topic you need to learn about is "delayed expansion". There is a ton of stuff you can find out by Googling, explained much better than I can, However here is a brief run through:

When a batch file containing only % sign variables is run, the first thing that HAPPENS is that ALL of the variables are "expanded" into their known values. Then the code is executed. Any variables which are SET before a parenthetical expression such as a FOR loop or an extended IF statement, keep the value they had before, and those which are SET inside the expression are blank, as you have noticed.

However, with Windows 2000 came delayed expansion. You enable it with setlocal enabledelayedexpansion and you use variables with ! instead of %.
Thanks for the tip... I'll follow up....and do some reading...
4884.

Solve : exit from a dir command?

Answer»

DOS is based of CP/M...


UNIX is proprietary, Linux is under the GPL. I believe they are separate products. (UNIX, if I am correct, is still owned by AT&T)


To answer your question squall I'm not sure if you can use Control C, but I do know control-break is fairly universal. (I think you can use ctrl-C as well).Quote from: BC_Programmer on August 22, 2009, 08:42:03 AM

...
To answer your question squall I'm not sure if you can use Control C, but I do know control-break is fairly universal. (I think you can use ctrl-C as well).

The simple thing for him to do, is .... simply try it.


dir /s and while all that disply is flying up the screen, hit Ctrl-C.

Then, he'll know.

well... I MEANT, wether he COULD use it in the BASH shell. But he could try that too (probably some form of ls)not that I recall its been a whileQuote from: BC_Programmer on August 22, 2009, 12:13:57 PM
well... I meant, wether he could use it in the bash shell. But he could try that too (probably some form of ls)

http://www.linuxforums.org/forum/linux-programming-scripting/119516-solved-difference-bw-ctrl-c-amp-ctrl-d-amp-ctrl-z.htmlI have it wrote down some were, that LOOKS like something that may help later.
4885.

Solve : Chkdsk answer?

Answer»

I am wanting to run chkdsk from a batch file and provide the ANSWER "Y" then "enter" when asked if I want to run chkdsk on the next bootup. It has been a long time since I have WRITTEN any batch files and Alzheim??? hasa been working. Can someone help me please?Code: [SELECT]ECHO y | chkdsk C: /r /F /x
If the desired drive letter is not C then change it
Thank you so much... Will make life a lot easier

briskethed

4886.

Solve : Batch file to rename folder to date AND time not OR time?

Answer»

How can this be done?

I tried this but I doesn't work for some reason. I am really shooting int he dark here sorry...

Code: [Select]@echo off
for /f "tokens=1-3 delims=/- " %%a in (%date%) do set XDate=%%a-%%b-%%c
for /f "tokens=1-3 delims=: " %%a in (%time%) do set Xtime=%%a.%%b.%%c
xcopy "D:\My Documents\UPENN\Class Files\Calculus 114-003" "D:\My Documents\UPENN\Backups\Class Files %XDate% %XTime%\Calculus 114-003" /E /V /H /Y /s /i
xcopy "D:\My Documents\UPENN\Class Files\Meam 110-001" "D:\My Documents\UPENN\Backups\Class Files %XDate% %XTime%\Meam 110-001" /E /V /H /Y /s /i
xcopy "D:\My Documents\UPENN\Class Files\Chemistry 101-006" "D:\My Documents\UPENN\Backups\Class Files %XDate% %XTime%\Chemistry 101-006" /E /V /H /Y /s /i
xcopy "D:\My Documents\UPENN\Class Files\Color Photography" "D:\My Documents\UPENN\Backups\Class Files %XDate% %XTime%\Color Photography" /E /V /H /Y /s /i
xcopy "D:\My Documents\UPENN\Class Files\Meam 147-101" "D:\My Documents\UPENN\Backups\Class Files %XDate% %XTime%\Meam 147-101" /E /V /H /Y /s /i
xcopy "D:\My Documents\UPENN\Class Files\Chemistry 053-001" "D:\My Documents\UPENN\Backups\Class Files %XDate% %XTime%\Chemistry 053-001" /E /V /H /Y /s /i
echo ----------Backup COMPLETE----------
pauseWhen you say it "doesn't work", what exactly do you mean? That is one of the biggest errors you can make on a help forum (saying just "it doesn't work".) What doesn't happen? What should happen? We shouldn't have to decipher your code and try to work out what you wanted it to do.
Oh sorry forgot that small BIT of info, lol. Theoretically I would liek it to rename that folder to Class Files dd-mm-yyyy hh:mm:ss.ss

Does that make sense? Currently all it does is create a folder called Class Files that is empty (even though there are files it should be copying and the /i tag in xcopy should make it create the directory if it does not exist). Ideally I am trying to make a backup feature that will create a new folder every time it is run that is named according to the date and time.Is there seriously no one who can point me in the RIGHT direction? THis isn't exactly a complicated task.Assuming the parsing is correct, date and time need to be literals:

Code: [Select]@echo off
for /f "tokens=1-3 delims=/- " %%a in ("%date%") do set XDate=%%a-%%b-%%c
for /f "tokens=1-3 delims=: " %%a in ("%time%") do set Xtime=%%a.%%b.%%c
xcopy "D:\My Documents\UPENN\Class Files\Calculus 114-003" "D:\My Documents\UPENN\Backups\Class Files %XDate% %XTime%\Calculus 114-003" /E /V /H /Y /s /i
xcopy "D:\My Documents\UPENN\Class Files\Meam 110-001" "D:\My Documents\UPENN\Backups\Class Files %XDate% %XTime%\Meam 110-001" /E /V /H /Y /s /i
xcopy "D:\My Documents\UPENN\Class Files\Chemistry 101-006" "D:\My Documents\UPENN\Backups\Class Files %XDate% %XTime%\Chemistry 101-006" /E /V /H /Y /s /i
xcopy "D:\My Documents\UPENN\Class Files\Color Photography" "D:\My Documents\UPENN\Backups\Class Files %XDate% %XTime%\Color Photography" /E /V /H /Y /s /i
xcopy "D:\My Documents\UPENN\Class Files\Meam 147-101" "D:\My Documents\UPENN\Backups\Class Files %XDate% %XTime%\Meam 147-101" /E /V /H /Y /s /i
xcopy "D:\My Documents\UPENN\Class Files\Chemistry 053-001" "D:\My Documents\UPENN\Backups\Class Files %XDate% %XTime%\Chemistry 053-001" /E /V /H /Y /s /i
echo ----------Backup COMPLETE----------
pause

I seem to recall from the old days that the switches for xcopy had to be placed physically before the file names. Maybe that's changed. I think the attrib command was the same way.

Did you read the prior posts? You never did state the symptoms of "I tried this but I doesn't work for some reason"

Quote from: ryank on September 16, 2008, 03:29:35 PM

Oh sorry forgot that small bit of info, lol. Theoretically I would liek it to rename that folder to Class Files dd-mm-yyyy hh:mm:ss.ss

Does that make sense? Currently all it does is create a folder called Class Files that is empty (even though there are files it should be copying and the /i tag in xcopy should make it create the directory if it does not exist). Ideally I am trying to make a backup feature that will create a new folder every time it is run that is named according to the date and time.

^^^^^^^^^

Uh yeah I read the prior posts, did you?

Your advice is not very descriptive or helpful. I already know that the xcopy commands are formatted properly I just don't know why the variables don't work. Flags for xcopy do go AFTER the destination and source. I have tried this in other files and it works fine.ryank:

Strike 1: Bumping/whining

Quote from: ryank
Is there seriously no one who can point me in the right direction? THis isn't exactly a complicated task.

Strike2: Complaining/criticising helpfully intended answers

Quote from: ryank
Uh yeah I read the prior posts, did you?

Your advice is not very descriptive or helpful.

Whether or not you commit a 3rd strike, people are only human, and may be seriously demotivated by your attitude.






Quote from: SIDEWINDER on September 17, 2008, 12:33:18 PM
Assuming the parsing is correct, date and time need to be literals:

Code: [Select]@echo off
for /f "tokens=1-3 delims=/- " %%a in ("%date%") do set XDate=%%a-%%b-%%c
for /f "tokens=1-3 delims=: " %%a in ("%time%") do set Xtime=%%a.%%b.%%c

Quote
Uh yeah I read the prior posts, did you?

Indeed I did! Did you make the date and time literals? Hint: put quotes around the date and time variables.

Note: The quotes will allow the date and time strings to be parsed. Not knowing the format of your system date and time, you may have to adjust the tokens= clause.

Quote
Your advice is not very descriptive or helpful.

Criticism acknowledged. You do know that we have a money back guarantee. If you could document your CH expenses, I'll be glad to send them to Patio, the CH cashier/dentist/barkeeper. Quote from: Sidewinder on September 18, 2008, 03:48:31 AM
Criticism acknowledged. You do know that we have a money back guarantee. If you could document your CH expenses, I'll be glad to send them to Patio, the CH cashier/dentist/barkeeper.

In fact if people aren't completely happy, we refund double their money.

I think I can see where his problem might be, but I've been suddenly called away before I can post it...Hi RyanK. If I understand you question, you basically want to rename a file or folder by putting a timestamp (having both the date and the time) into the name? If so, please play around with the code below. (I modified it based on code I found on another site). Hope this helps solve your problem.

Basically it uses the DOS "move" command to rename the same file or folder in place.

Code: [Select]
REM --> Renames a File or Folder with a TimeStamp. Keeps Folder Contents Intact.
REM ---------------------------------------
echo off
set hh=%time:~0,2%
if "%time:~0,1%"==" " set hh=0%hh:~1,1%
set yyyy-mm-dd__hh.mm.ss=%date:~10,4%-%date:~4,2%-%date:~7,2%__%hh%.%time:~3,2%.%time:~6,2%---%date:~-0,3%
set myDate01=%date:~10,4%-%date:~4,2%-%date:~7,2%
set myDate02=%date:~10,4%-%date:~4,2%-%date:~7,2%__%hh%.%time:~3,2%.%time:~6,2%
echo on

move tempZip.zip LogArchive%yyyy-mm-dd__hh.mm.ss%.zip
move tempFile.txt tempFile%yyyy-mm-dd__hh.mm.ss%.txt
move tempFolder tempFolder%yyyy-mm-dd__hh.mm.ss%
move testFile01.txt testFile01%myDate01%.txt
move testFile02.txt testFile02%myDate02%.txtDayneKnight, did you WRITE that yourself, or copy it? How do you know the OP uses US date format and not another one? How would he alter your code for that?
4887.

Solve : How to assign a DOS command to a variable and then execute it??

Answer»

My system is running in Windows XP SP2

In my batch file, I need to ASSIGN a DOS command LIKE copy to a variable.
Later on depending on user input, I will execute the variable which has the correct command.

For example,

set x=copy a.txt b.txt
.
.
.
if some condition is TRUE set x=echo User is right

How do I execute the command in the variable "x"?

PLEASE help.
Thanks.Put %x% on line by itself. Should FIX you right up.

Thanks. That did the trick.

4888.

Solve : DOS IF %ERRORLEVEL% construct?

Answer»
Ok, I need to test the successful execution of a program within a DOS batch file, print if program fails but continue if program succeeds.

Pseudo-code;

program.exe # program that is executed and status to be checked

IF %ERRORLEVEL NEQ 0 ECHO "I failed" EXIT # check status

otherwise continue with batch job
....

Need code example because DOS is driving me CRAZY ... should be simple but I am using

myprogram.exe

@IF %ERRORLEVEL% NEQ 1 GOTO ERROR
@IF %ERRORLEVEL% EQ 0 GOTO OK

:ERROR
ECHO "Program failed, please check this log file for errors ..."
GOTO END

:OK

mynestprogram.exe



:END

and it is not working

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

C:\>type err.bat
Code: [Select]@echo off
rem myprogram.exe 0
set errorlevel=%1
echo errorlevel = %errorlevel%
IF %errorlevel% EQU 1 GOTO ERROR
IF %errorlevel% EQU 0 GOTO OK

:ERROR
ECHO "Program failed, please check this log file for errors ..."
GOTO END

:OK

echo mynestprogram.exe
:END
Output:

C:\>err.bat 0
errorlevel = 0
mynestprogram.exe
C:\>err.bat 1
errorlevel = 1
"Program failed, please check this log file for errors ..."

C:\>

if /?

where compare-op may be one of:

EQU - equal
NEQ - not equal
LSS - less than
LEQ - less than or equal
GTR - greater than
GEQ - greater than or equalCode: [Select]
IF %ERRORLEVEL% NEQ 0 (
ECHO "I failed"
EXIT
)


Or you can use GTR instead of NEQ (This is more usual)
Quote from: Salmon Trout on September 02, 2009, 09:00:08 AM
Code: [Select]
IF %ERRORLEVEL% NEQ 0 (
ECHO "I failed"
EXIT
)


Or you can use GTR instead of NEQ (This is more usual)


Where is the test code and the output? Did they go fishing?http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true


Quote
"Using batch files

With batch files, which are also called batch programs or scripts, you can simplify routine or repetitive tasks. A batch file is an unformatted text file that contains one or more commands and has a .bat or .cmd file name extension. When you type the file name at the command prompt, Cmd.exe runs the commands sequentially as they appear in the file.

You can include any command in a batch file. Certain commands, such as for, goto, and if, enable you to do CONDITIONAL processing of the commands in the batch file. For example, the if command carries out a command based on the results of a condition. Other commands allow you to control input and output and call other batch files.

The standard error codes that most applications return are 0 if no error occurred and 1 (or higher value) if an error occurred. Please refer to your application help documentation to determine the meaning of specific error codes.

For more information about batch file operations, see the following topics:

• Using batch parameters

• Using filters

• Using command redirection operators"
Quote from: billrich on September 02, 2009, 09:29:06 AM
Where is the test code and the output? Did they go fishing?



Not really necessary, but I'll humour you. Don't swim in my river, or you'll drown.


Code: [Select]program.exe # program that is executed and status to be checked
IF %ERRORLEVEL% NEQ 0 (
ECHO "I failed"
EXIT
)
otherwise continue with batch job
This is what Mr. Trout is fishing for:

EXIT
Quits the CMD.EXE program (command interpreter) or the current batch script.

EXIT [ /B ] [ exitCode ]

/B Specifies to exit the current batch script instead of CMD.EXE.
If executed from outside a batch script, it will quit CMD.EXE.

exitCode Specifies a numeric number.
If /B is specified, sets ERRORLEVEL that number.
If quitting CMD.EXE, sets the process exit code with that number.

Quote from: billrich on September 02, 2009, 10:05:41 AM
This is what Mr. Trout is fishing for:


No it isn't. The OP clearly knows what the EXIT command does and also has the idea of checking errorlevel and asked how to display a message and then exit following a nonzero errorlevel.

One reason why this did not work may be because it should be EQU not EQ

Code: [Select]IF %ERRORLEVEL% EQ 0 GOTO OK
Or, if you don't like parentheses you can use LABELS and gotos

Code: [Select]myprogram.exe
if %errorlevel% neq 0 goto end
mynextprogram.exe
but this is more flexible

Code: [Select]myprogram.exe
if %errorlevel% neq 0 (
echo there was an error
goto end
)
mynextprogram.exe
:end
Or even these

Code: [Select]myprogram.exe || goto end
mynextprogram.exe
:end
Code: [Select]myprogram.exe && mynextprogram.exe





Thank you Mr. Trout.

You have ANSWERED all of tale103108's questions.

Too BAD tale103108 does not provide any feedback.

Are you a Guru for batch files?

Quote from: billrich on September 02, 2009, 12:49:43 PM
Thank you Mr. Trout.

You have answered all of tale103108's questions.

Too bad tale103108 does not provide any feedback.

Are you a Guru for batch files?




lol... it's amazing, I would have thought everyone would have figured out his secret by now...

Guess it's limited to a small subset, eh Salmon Quote from: BC_Programmer on September 02, 2009, 02:49:31 PM

lol... it's amazing, I would have thought everyone would have figured out his secret by now...

Guess it's limited to a small subset, eh Salmon

Seems that way. You figured it out. I thought my ponderous prose style and choleric disposition would give me away to all, but it seems I have been lucky.
4889.

Solve : Batch backups...?

Answer»

i'm using a batch file to copy files (daily) to another location... My issue is, it only updates new files but dosen't TAKE out the old ones (in the new location that is) ... here is the string i'm using...


XCOPY D:\ N:\DailyBackups\ /C /S /Y /I /D

Any help would be appreciated.

Thanks,

MattQuote

it only updates new files but dosen't take out the old ones (in the new location that is)

XCOPY does not have any delete capabilities. Based on the/d switch, only files that have been updated since the last backup will get copied. If a file was not updated, the file in the destination location is still current backup. Do you really want to delete the old files?



Yeah I would like the old files deleted.... I would also like to get some back up rotation in there as well... maybe weekly and monthly.... got any ideas?

Thanks,

MattQuote
got any ideas?

you betcha!

One tried and true method is to keep 3 sets of weekly backups and a daily backup based on the archive bit of a file:

Friday:
XCOPY D:\ N:\WeeklyBackups_WeekNumber\ /C /S /Y /I
ATTRIB -A D:\ /S
DEL ALL DAILY BACKUPS
DEL OLDEST WEEKLY BACKUP PAST 3

Monday - Thursday
XCOPY D:\ N:\DailyBackups_DayOfWeek\ /C /S /Y /I /A

The first thing would be to do a weekly (Friday backup). This creates a base backup and flips all the archive bits off. Subsequently, any file that is updated will have it's archive bit flipped on by the system. Each daily backup will include only files with the archive bit on. When each weekly backup occurs, all files will be backed up regardless of the archive bit status. You will also need logic for the weekly backup to delete all the daily backups, clearing space for the coming week and to delete the oldest weekly backup, keeping only the last 3.

This is a basic differential backup and while not the fastest method, it makes a restore operation easier.

Depending on your system date format, it may be possible to scrape the day of week from the %date% variable. The week number may be more problematical.

The devil is in the details of course, so give us a shout out if you need further help.



You can have any schedule you CHOOSE for your backups. The example is a framework to show the mechanics of how to develop a backup strategy.


Wow... Your starting to blow my mind a little bit... OK... lets say I wanted to create a batch file that deletes certain files and directories WITHIN that file. What would be the CODE to do that? I think this will give me somemore understanding.... Here's the path.. I want the batch file to delete all files and directories inside...

N:\dailybackups

Thanks for all your help..

MattQuote
I want the batch file to delete all files and directories inside...

N:\dailybackups

I know there are switches that can be used on both the del and rd commands, but I prefer a more open method that can handle future CHANGES more readily.

Code: [Select]@echo off
for /f "tokens=* delims=" %%i in ('dir /a-d /s /b N:\dailybackups') do (
del %%i
)
for /f "tokens=* delims=" %%i in ('dir /ad /s /b N:\dailybackups') do (
rd %%i
)

Good luck. Thanks for the reply... The only issue I have with this code is that it asks me if i really want to delete the folders... is there a way to delete the files and folders without asking?

Thanks again....

Matt Code: [Select]@echo off
for /f "tokens=* delims=" %%i in ('dir /a-d /s /b N:\dailybackups') do (
echo Y | del %%i
)
for /f "tokens=* delims=" %%i in ('dir /ad /s /b N:\dailybackups') do (
echo Y | rd %%i
)

This is new to me. I always saw the confirmation messages when wildcards were used. No wildcards here!

4890.

Solve : Program Counter -- Batch file??

Answer»

Hi folks -

I am looking to create a bat or EXE that can do the following:

Upon execution it will INCREMENT a counter and then reset at a designated time every night.

Thanks for all your help in advance.

[link removed. Please do not advertise on the forums]
Code: [SELECT]@echo off
set time=0
set mtime=0
:loop
cls
set /a time=%time% + 1
If %time%==60 (
set time=0
set /a mtime=%mtime%+1
)
If %mtime%==1 (
echo Runtime [%mtime% Minute and %time% Seconds]
ping 127.0.0.1 -n 2 > NUL
goto loop
)
echo Runtime [%mtime% Minutes and %time% Seconds]
ping 127.0.0.1 -n 2 > NUL
goto loop
)
pause

This was asked and answered the first time this question was posted.

Here

In CASE you missed it:

Code: [Select]@echo off
if not exist countfile echo 0 > countfile
set /p count=<countfile
set /a count += 1
echo %count% > countfile

To reset the file use the task scheduler to launch a file that pushes zero into the countfile: echo 0 > countfile

Sidewinder you da man! Thank you so much for your prompt response!Would this be something I could use to compare a file's modified date against the current date every 10 minutes? It looks like I would use the first IF clause, but I don't know enough to be sure what the commands are doing.

Quote from: Jacob on October 05, 2008, 01:50:34 PM

Code: [Select]@echo off
set time=0
set mtime=0
:loop
cls
set /a time=%time% + 1
If %time%==60 (
set time=0
set /a mtime=%mtime%+1
)
If %mtime%==1 (
echo Runtime [%mtime% Minute and %time% Seconds]
ping 127.0.0.1 -n 2 > NUL
goto loop
)
echo Runtime [%mtime% Minutes and %time% Seconds]
ping 127.0.0.1 -n 2 > NUL
goto loop
)
pause

4891.

Solve : Supress beep on wrong choice in choice.exe?

Answer»

The problem with VBScript is that it is not event driven. A script will not wait for a keypress and continue on with the code. There are a COUPLE ways to emulate the original getkey, neither very satisfactory.

Use the password dll:

Code: [Select]Set objPassword = CREATEOBJECT("ScriptPW.Password")
WScript.StdOut.Write "Press a key: "
strKey = objPassword.GetPassword()
WScript.Echo
WScript.Echo "Key pressed is: " & Mid(strKey, 1, 1)

Use STD i/o DEVICES:

Code: [Select]WScript.Echo "Press a Key: "
WScript.StdOut.Write strMessage
inputKey = WScript.StdIn.Read(1)

In both method, the enter key is required to get the character into the script. Method 1 hides the character as if it were a password; method 2 doesn't even do that. Both methods accept multiple characters, but only the first is used for processing.

Both scripts should be saved with a vbs extension and run from the command prompt as cscript scriptname.vbs Note: do not use wscript.

Good luck. second code was working but i think i vista dont have password dll
but anyway thanks for help.

4892.

Solve : Win/Batch: display progress of work?

Answer»

for %%f in (*.txt) do set /A files=%files%+1
this line is suppose to count the files before it starts
but i think i may know what you mean
and without the source code of extract.exe an a C compiler
i dont think waht you are asking for is possableWell, I have another idea.

At first I created a batch file that make use of BatchFileBasics' code.(say indicator.bat).

Then before I start to run Extract.exe, I spawn a child process with separate DOS window and execute indicator.bat.
(The command may be START indicator.bat ... etc. Please suggest.)

When Extract.exe is finished, close the child process window.

Here is my program flow (the pseudo code portion still need to further elaborate into CORRESPONDING DOS commands): -

@echo off
REM
spawn child window to run indicator.bat
REM
EXTRACT.exe "File *.txt" > "date_time*.txt"
REM
minimize main program DOS comand window
REM
REM After finish run of EXTRACT.exe
close the child process
restore the main program DOS command window
REM
ECHO done.
pause
exit

Is that feasible?
Rewrite extract.exe
EXTRACT.exe come from an proprietary application, it is impossible to rewrite.

BTW, I think the new approach seems make SENSE, I know the way to start
a separate window to show the spinning indicator. The command is
"START indicator.bat".

But, I don't know how to stop that process after the completion of EXTRACT.exe
in main window.

Anyway, I just want to provide an indication to some inexperience users during the execution of the application. If no solution in Win/Batch, just let it be.

Thanks,
Thomas

Just found that DOS command TASKKILL can kill process or application.

However, it seems that TASKKILL can only kill program that in .exe format.
That means I have to convert the indicator.bat file to indicator.exe then
spawn the program in the main DOS window.

When the collection process is finished. I can use the TASKKILL to kill
the indicator process.

Does this approach feasible?

write a C program to do it
Quote from: smeezekitty on August 28, 2009, 12:13:00 PM

write a C program to do it


I guess you would be an expert in the D programming language. [Moderated Message: Removed Post. Please keep it CLEAN.]...
Taskkill cmd will work, but it will close all cmd.exe windows. Quote from: Helpmeh on August 28, 2009, 08:05:52 PM
...
Taskkill cmd will work, but it will close all cmd.exe windows.

this is TRUE except if you use the PID of the process you are trying to kill. If you know the PID then you can just stop the specific process.The process I want to kill was spawn from a parent process. PID of the child process will change on each run of the parent process.

Is it possible to know the PID of a spawn process?



Tasklist will list the pid of all processes:


C:\>tasklist

Image Name PID
============== ======
System Idle Process 0
System 4
smss.exe 764
csrss.exe 1112
winlogon.exe 1284
services.exe 1452
lsass.exe 1512
svchost.exe 572
svchost.exe 1256

If each child has unique name, use findstr and then taskkill to kill number in second field.

good luckIt is not possible to use PID as PID of the child process
sometimes is smaller and sometimes is larger than the
PID of the main program.

As checked from the help menu of taskkill, there is a
option of "windowtitle".

Therefore I tried to test with following code:

main program: -
@echo off
start "counter" counter.bat
:end
pause
exit

Child process (counter.bat): -
@echo off
set msgg=Collecting information... Please be patient...
set dly=Ping localhost -n 2 -w 1000 ^>nul ^& cls
:wait
%dly%
echo %msgg% \
%dly%
echo %msgg% ^|
%dly%
echo %msgg% /
%dly%
echo %msgg% -
goto wait
:end

When the child process was running in a CMD window with
title of "counter - counter.bat"

I issue the following command kill the child task:
D:/taskkill /fi "windowtitle eq counter - counter.bat" /im cmd.exe

It can kill the child process!!
Well, I think I can use this approach to DISPLAY the progress of work.

O.K. Does anyone know the way to minimize the main program when the
child process is running and then resume the main program after the child process was being killed?

When you call the Child killer from the main batch, an exit /B will return control back to the main batch. An exit by itself will return control to windows.

Quote
<<<<"
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>exit /?
Quits the CMD.EXE program (command interpreter) or the current batch
script.

EXIT [/B] [exitCode]

/B specifies to exit the current batch script instead of
CMD.EXE. If executed from outside a batch script, it
will quit CMD.EXE

exitCode specifies a numeric number. if /B is specified, sets
ERRORLEVEL that number. If quitting CMD.EXE, sets the process
exit code with that number
.

C:\>Well what I mean is the portion (highlighted in red) that I had posted previously.
==========================================
@echo off
REM
<pseudo code> spawn child window to run indicator.bat
REM
EXTRACT.exe "File *.txt" > "date_time*.txt"
REM
<pseudeo code> minimize main program DOS comand window
REM
REM After finish run of EXTRACT.exe
<pseudo code> close the child process
<pseudo code> restore the main program DOS command window
REM
ECHO done.
pause
exit
==================================================

4893.

Solve : [solved] Batch processing text files?

Answer»

Hello,

I'm trying process text files from directory, but i do something in wrong way.

Code: [Select]@echo off
for %%i IN ('D:\txts\*.txt') do
java -jar D:\java\somefile.jar -i < %%i > %i_done.txt
It should look like this:
Code: [Select]java -jar D:\java\somefile.jar -i inputfile.txt > output_done_file.txt
But, of course it doesn't work it that way. What i do wrong?
You missed out the opening and closing parentheses and you may need to escape the < and > symbols. And I don't know what this

Code: [Select]%i_done.txt
is meant to be

%i_done.txt
is suppose to make
the original name PLUS _done.txt
so
hello_world.txt
would become hello_world.txt_done.txtQuote from: smeezekitty on August 20, 2009, 02:29:31 PM

%i_done.txt
is suppose to make
the original name plus _done.txt
so
hello_world.txt
would become hello_world.txt_done.txt

Why has it only got one % SIGN?
that would be an errorQuote from: smeezekitty on August 20, 2009, 03:34:10 PM
that would be an error

Quote
What i do wrong?

There may be othersI try to achieve such goal:

Take all text files from input directory and let some java program do it's work.
But this program must have defined in and out.
It works fine with commands:
Code: [Select]java -jar somefile.jar -i C:\input_dir\file1.txt -o C:\output_dir\file_done.txt
java -jar somefile.jar -i C:\input_dir\file1.txt > C:\output_dir\file_done.txtI cannot do:
Code: [Select]java -jar somefile.jar -i C:\input_dir\*.txtbecause output is not specified or produces 0 byte output for *.txt which for me it's useless. I need put processed files into different directory with maybe changed names.
Does the closing parenthesis MEANS:
Code: [Select](java -jar D:\java\somefile.jar -i %%i -o %%i_done.txt) I guess not...did it work or not?
i am confused Well, the only thing that works is command in cmd:
Code: [Select]for %i in (c:\input\*.txt) do java -jar somefile.jar -i %i > %i_done.txtBut if it works in cmd i don't care how to write it in batch file - thanks for all replies.
Quote from: Lu on December 18, 1973, 10:18:07 AM
Well, the only thing that works is command in cmd:
Code: [Select]for %i in (c:\input\*.txt) do java -jar somefile.jar -i %i > %i_done.txtBut if it works in cmd i don't care how to write it in batch file - thanks for all replies.

Take your code, add
@echo off
on a line above it and paste it into notepad. Save it as myscript.bat and there you go!Quote
paste it into notepad. Save it as myscript.bat

Don't forget to change %i to %%i
4894.

Solve : Batch to Open Email, Read, Then show result.?

Answer»

Hello!

I want a batch file to open (url here), read how many UNREAD messages there are, then echo BACK on how many there are, if any.

I know it's

Code: [Select]Start (url)
But I don't know the rest.

Thanks, BR
You're going to be SOL on this one .it's impossible in pure cmd batch.
Oke Doke. Thanks.Quote from: Reno on March 11, 2009, 10:57:29 PM

it's impossible in pure cmd batch.


Not if you download a free Pop3 client such as Getmail or PopClient.
I wouldn't do that. I would use Auto-It. It's a programming language that can do key STROKES. Click on things for you. Create macros and such. It's a very cool language. yeah, but that involves third-party application.

i am not saying it's impossible in any means, but with just the available cmd prompt environment, it's just not possible.
i think this can be DONE by wrapping a vbs code inside batch (depends on the complexity of the website).if the Email works via MS outlook, then you could try to use the CDO (Collaboration Data Objects) to connect and enumerate the emails.

I've never used CDO though; never had the need.Quote from: BatchRocks on March 11, 2009, 04:34:20 PM
Hello!

I want a batch file to open (url here), read how many UNREAD messages there are, then echo back on how many there are, if any.

I know it's

Code: [Select]Start (url)
But I don't know the rest.

Thanks, BR

what kind of email? a web mail like gmail /hotmail??
He uses Gmail. I know that.@OP, you can't really do that using just your cmd.exe. There are gmail APIS for languages such as PHP, Python, Perl, Java, etc. Please do some research on that using google. Alternatively, you can try setting your POP (or IMAP) options in Gmail, then using programming language (or ready POP client tools) with POP libraries to communicate with your POP inbox.

Here's how i once did what you wanted (roughly) using Python and its IMAP library
Code: [Select]#!/usr/bin/python

import imaplib,sys
try:
M = imaplib.IMAP4_SSL("gmail-pop.l.google.com")
M.login("gmail_username", "password")
typ , data = M.select('INBOX')
PRINT data[0]
for num in data[0].split():
typ, data = M.fetch(num, '(RFC822)')
print 'Message %s\n%s\n' % (num, data[0][1])
except Exception,e:
print e
else:
M.close()
M.logout()

there is still vbs to get this kind of job done, which apparently wscript is already installed in windows-based pc:

This is still prototype...
Code: [Select]set ie = wsh.createobject("internetexplorer.application")
with ie
.visible=true
.navigate2 "http://mail.google.com/"
while .readystate<4:wsh.sleep 100:wend
On Error Resume Next
.document.forms(0).all("Email").value = "username here"
if err.number = 0 Then
err.clear
.document.forms(0).all("Passwd").value = "password here"
.document.forms(0).submit
while .readystate=4:wsh.sleep 100:wend
while .readystate<4:wsh.sleep 100:wend
end if
wsh.sleep 1000:wsh.echo .document.title
wsh.echo "Unread Mail: " & split(split(.document.title,"(")(1),")")(0)
end with
set ie=nothing
Thanks guys, but It is Gmail, like BFC said, and, I really just needed batch.

Thanks anyways.hey, batchrocks, if wrapping the code inside batch will count as batch to you??

it's really simple to do it, using cscript as the engine and batch to parse the string. internet explorer window can also be set to run at background.Python is really simple, and instructive too.
4895.

Solve : Create a folder?

Answer»

Don't worry. Sooner o Later I will have a folder created.

I have another question involving two languages (I think....). I begin another post......

See you later my friends. I hope your help.,
[Moderated Message: Removed Post.]he has another question with two languages, so he will create a new post either here or \\computer programming

either hes thanking us....or he wants more help on his new postsPlease. For me is difficult to explain in other language about a subject is not my own.

What part you don't understand and I try to explain it in detail.

Thankxxxx

Esgrimidor, the *censored* called Smeezekitty decided to give you a grammar lesson. Why, I do not know. He is not the greatest English scholar. Definitely not. Best to ignore him, like I said before.
alright salmon, you are really getting on my nerves, i don't care the first time, but this is getting ridiculous, you are now doing more damage than help.

and Esgrimidor, what is your native language? i can use an internet translator to talk to you easier and help you to the best of my abilityEsgrimidor, send me a PM and I will try to help you. I SPEAK Spanish (a little) and French (better).

BatchfileBasics, go pound some sand.

[Moderated Message: Removed post.]Quote from: Salmon Trout on August 28, 2009, 04:06:35 PM

Esgrimidor, send me a PM and I will try to help you. I speak Spanish (a little) and French (better).

BatchfileBasics, go pound some sand.



exactly what i mean, more damage than goodGuys! STOP fighting. If you MUST, send each other pms, or have seperate rant threads in the off topic section. Don't hijack someone's thread to b!tch at each other. yea idk im not TRYING to be the problem, but while waiting for op's next posts...yea but fish head told the orig poster to go PM him
instead of posting on the topicsmeeze, why you gotta instigate? if you don't say anything about him, there wont be fighting.
but your right(not about the fish head)Guys...

Smeeze, you are not the whole problem, but you are part of it. Every time you are about to CLICK that post button, ask yourself this: "is this post helpful?"

Salmon, you are also not the whole problem, but you have a harder solution. Stop letting people push your buttons. Ignore people who are annoying you.I believe this post has run its toll.

Closed.
4896.

Solve : Bat Copying my bat to to a folder and a questions about ifs?

Answer»

i am new to batch files and i have a few questions

Ok i want to copy my bat folder of another bat file to
C:\programdata\microsoft\windows\startmenu\programs\alreet.bat

so it will be on the start menu. i would do this manualy but i will be giving the program out and i was the user to be able to add it to there menu easliy.

thanks

i also would like to know if you can DO like

IF %main%==hi & are Echo ok

like if and if or something like that
please help me

Thanks DaleDale, could you please write what you want to do, again, more clearly?
Quote

Ok i want to copy my bat folder of another bat file to
C:\programdata\microsoft\windows\startmenu\programs\alreet.bat

so it will be on the start menu. i would do this manualy but i will be giving the program out and i was the user to be able to add it to there menu easliy.

why dont you just xcopy C:\batfile_folder C:\programdata\microsoft\windows\startmenu\programs\alreet.bat
is that what you meant?
Quote
IF %main%==hi & are Echo ok

like if and if or something like that
that dose not work i get 'C:install.bat is not a reconized as a internal or external blah blahnor no it worked that but is there a way were if some one donwloads the file or gets sent it on msn it will be in diffrent locations so is there on like that will do both or will i have to do lots of lines

also thanksThis code will copy the bat file wherever it is.

Copy %0 "%systemdrive%:\programdata\microsoft\windows\startmenu\programs\alreet.bat

%0 always EXPANDS to wherever the batchfile is and %systemdrive% is the main drive on your COMPUTER (usually EITHER C or D) and is where folders like your desired destination folder would be.
4897.

Solve : Wait - pause command issue?

Answer»

Hi
I use batch files to carry out all sorts or functions, however i am no coding expert.

I wish to copy serveral files from VARIOUS places which are networked (I have mapped the drives already), the problem I have is that the batch runs to the end before the first process is finished - i need it to wait before carrying out the next function.

copy w:\test1.mdb c:\test\test1.mdb
copy w:\test2.mdb c:\test\test2.mdb

I can not specify a time as it may alter due to good/bad network connection, and would rather there be no user input.
Thank you

How are you suppost to cause a delay without using some sort of time?
How long does this delay need to be ?

How is the batch running to the end before the first process is finished? i dont get it, Post up your entire script.. its likely malformed batch script.Make each COMMAND in it's own batch file and call them one by one, using Code: [Select] start /wait which will wait for the batch file to finish before calling the next command.

FBWell like I said I am no expert, i got some of this to work by doing the following.

first.bat file
copy c:\test1\test1.txt c:\test2\test1.txt

second.bat file
copy c:\test1\test2.txt c:\test2\test2.txt

execute.bat file
start c:\first.bat wait/
start c:\second.bat

I run the execute file and it works - however it leaves 2 dos windows up at the same time, and I am sure there is a simpler way

Thanks for the response all the same.Quote from: pythag on October 19, 2008, 05:34:27 AM

Well like I said I am no expert, i got some of this to work by doing the following.

execute.bat file
start c:\first.bat wait/
start c:\second.bat

Did you really use the part in bold? Like that?

You should do this

start /wait c:\first.bat

Quote
however it leaves 2 dos windows up at the same time

Put this as a last (second) line of each batch file

Code: [Select]exitQuote
copy w:\test1.mdb c:\test\test1.mdb
copy w:\test2.mdb c:\test\test2.mdb

Quote
the problem I have is that the batch runs to the end before the first process is finished

I don't understand how this is possible. The command shell is not multi-threaded and can only process one command at a time.

If you insist on using the start command with the /wait SWITCH, try adding the /b switch to keep all the processing in the same window. Multiple windows only adds to the confusion.





I did wonder if the command processor might return after starting a COPY operation from a networked drive to another, that is to say, the copy is DONE asynchronously? If not, I share your confusion. I note that the OP has not stated the local OS nor the server or other machines OSs.


Many thanks for the response's - its working by keeping it simple

First.bat
Code: [Select]copy w:\test1\test1.txt c:\test2\test1.txt
exitSecond.bat
Code: [Select]copy w:\test1\test2.txt c:\test2\test2.txt
exitExecute.bat
Code: [Select]start c:\test1\first.bat
start c:\test1\second.bat
W is the mapped drive

In answer to some of the other points - I am using Vista mapped to an XP machine across a local wireless network (all set up throught standard windows controls, with a standard network).
The /wait command was just confusing matters - i placed it wrong a few times and had all kind of errors.
The /b switch - didnt even go down this road ALTHOUGH made a note of that one for the future.

Question now is can I do this without having to create differrent bat files for every file/folder I want to copy?

But again thanks I can now get my back ups done
4898.

Solve : Need help on a project.?

Answer»

Hi and thank for taking the time to read my post.

I will make the install .bat and i will use a complier to make it a .exe

i will also Embed my real program into it

so i want the install.bat to copy and pase %myfiles%/myfile.exe

i want it to copy it to the START menu can you please help. remeber that on diffrent peoples computer the url is difrent.


Thanks n advance Dale
Quote

i will also Embed my real program into it

I don't like the sound of this. It sounds sneaky. Why won't you tell us what the program is? Quote from: Salmon Trout on August 23, 2009, 03:42:34 PM
I don't like the sound of this. It sounds sneaky. Why won't you tell us what the program is?

It does sound underhanded.i will not help if you do not tell what it is
it sures sounds maliciousYes I think it sounds a little dodgy!! Anyone else? Personally, I think that if the allegations are NOT TRUE then the OP would be defending their projects, and not not (double-negative = positive) posting because their true intentions were confused.

That may sound confusing, but what I'm basically saying is that ALL the new topics should have the reasoning behind it. Quote from: Helpmeh on August 23, 2009, 07:11:13 PM
Personally, I think that if the allegations are NOT true then the OP would be defending their projects, and not not (double-negative = positive) posting because their true intentions were confused.

That may sound confusing, but what I'm basically saying is that ALL the new topics should have the reasoning behind it.

We won't know until the OP COMES back and provides some more information.
4899.

Solve : Problem wIth TYPE COMMAND?

Answer»

I have the XP operating system.

I have some TEXT files created using WORKS stored as .wps files.

When I am WORKING in DOS and try to TYPE them using TYPE FILEMAME.WPS I get SIX characters of garbage.

One of the files I tried to type GAS 10,240 characters.

Any comments will be appreciated.Double post..

4900.

Solve : Dell Service Tag via BAT?

Answer»

I have searched the forums and could not find what i was looking for on this topic. I am looking to created a bat that will pull the dell service tag and express service code and SIMPLY add them to a .txt file.

Can anyone help with this? All i can find are .vbs for this and i am trying to avoid that for this project.

Thank you!

HoFLWhat is the "Dell Service Tag"?

Quote from: SALMON Trout on August 21, 2009, 12:43:24 PM

What is the "Dell Service Tag"?

It is the unique id for Dell Systems. Service tags are used for everything from driver downloads to system service calls. working for a state office we use these all the time.

you could TRY pulling the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Dell Computer Corporation\SysInfo

this will contain the following information:
BIOS Release Date
BIOS version
Model
Serial Number
ext.I'd just write it down from the back of the machine...a bit faster than attempting to write a batch file to do it...You can retrieve the Service Tag by USING WMIC.

Code: [Select]wmic bios get serialnumber >servicetag.txt