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.

751.

Solve : Help in an XCOPY script?

Answer»

I am running this code in a batch file every 2 minutes to copy from one server to another.  I need to copy specific files to a DESTINATION.  The script works fine, but the problem is that it copies over and over the ones it already did.  Is there a way to copy the files Im loking for, but exclude any that have all ready been copied?  The destination folder is a folder that another program "looks" in constantly.  when files land in this folder, the program takes them and then deletes them because they were processed.  My script copies the files again, and of course the program reprocesses them because it doesnt know they were done earlier in the day.  The source folder will have PDF's and XML's added all day long as patients are seen by the physician.  I hope this makes sense.  Here is what code I have, but i need it to only copy new files from the source:

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do cd s:\02\%%f
s:
for /D %%F in (*) do xcopy %%F\*.pdf \\MHCInterface\Heartlab /C /Y
for /D %%F in (*) do xcopy %%F\*.xml \\MHCInterface\Heartlab /C /Y
del \\MHCInterface\Heartlab\*.red.*

Thanks for any help you can offerI think Robocopy may be a better option for you.well the OS is winxp and server 2000.  Maybe I could do something with the archive bit in the xcopy script?  like turn off the archive if I copy it and have the script only copy new files with the bit set?  once copied undo the archive?Robocopy can monitor the source for changes so that is why I suggested that.

If you don't want to use robocopy the I think your other solution would be to make a log file of all the files that were copied. 

Instead of using the whacky way you were using the For /d option with two loops you could just use the for /f loop with the dir command and pipe it to the findstr command and use the inverse match option and the G option to use the log as the match. Basically telling findstr to find all files that you haven't copied yet.this sounds exactly what I need, but I have no clue how to even begin it.  Could you help me with the basics?  The structure is like this:

c:\Heartlab\1  <---for January
c:\Heartlab\1\01  <--- January 1st
c:\Heartlab\1\02\  <--- January 2nd
c:\Heartlab\1\03  <--- January 3rd....etc

then in each day there is a folder for each patient.  It is a random number to represent a new patient, so it could look like this:


c:\Heartlab\998821  <----patient #1
c:\Heartlab\1\015981  <----patient #2
c:\Heartlab\1\02\53721  <----patient #3
c:\Heartlab\1\03\54321  <----patient #4

In each patient folder is three files.  blah.xml  blah.pdf and blah.red.xml.  I only need the pdf and xml file copied (not the .red.xml) tp the servers listening folder \\mhcinterface\HeartlabI am confused as to why you would make the Month a single digit number and the day a two digit number.  Why aren't you leading with a Zero on both?sorry...i wrote that wrong...month and day are single digits.  not sure why I typed it that way. Quote from: mikedela on February 19, 2012, 06:10:31 PM

sorry...i wrote that wrong...month and day are single digits.  not sure why I typed it that way.
Just wondering because your original script shows a 02 for the month.
So when you echo the date variable from the command prompt and lets say it is Thursday February 9th, 2012 does it output like this
Thu 2/9/2012
Going to assume so because you are using a FOR Loop to PARSE the date apart.  I prefer to use the leading zeros in my Regional Settings.  Makes it easy to use the DATE variable in script with string parsing.  Plus if you are using the date to name files it makes it real easy to sort the file name by the date when it is 20120208_Myfile.doc.

Going to assume you screwed up this example as well.
Quote
c:\Heartlab\998821  <----patient #1
c:\Heartlab\1\015981  <----patient #2
c:\Heartlab\1\02\53721  <----patient #3
c:\Heartlab\1\03\54321  <----patient #4
I would assume that a patient should never be directly in the source directory or in a months directory. It should always be in the day directory of the month.ys your riht again.  I have so much on my plate, I confuse myself.  So all patients for the day go into that days folder.  for the feb 10th, they would go into 2\10\xxxx1, then next patient would 2\10\xxxx2 etc.  My script right now works perfect as it takes the day and copies every pdf and xml from the subfolders to the destination, then deletes the xxxxx.red.xml.  Its just that the script doesnt know if it copied the files already or not.  I dont know how to pipe into a file and then read it to see if its been copied.  Can you show me an easy example of a script that copies c:\mike\*.pdf to d:\Mike but only copies files it HASNT copied before?  The destination folder will not delete any txt documents, so we could parse into a txt and read from that.  I appreciate your help.  I have cracked my head on the wall with this one....im so frustrated and I know its so easy.I'm getting in on this thread, late in the game, so to SPEAK, but here's what I do.

In case of a hard drive crash or Windows boot failure, I don't want to loose any of my files from "My Documents" (MS Office) or "My Files" (Word Perfect) so I wrote a batch file, using XCOPY to copy only new or changed files to my assigned storage area on a separate hard drive.

With XCOPY you have a long list of switches that can be applied.
One switch, /M   copies a file and turns off the Archive bit so that file is NOT copied again, unless it's changed, which will reset the archive bit.

Even though I have several thousand files in my source directories, only a very few files get copied on each run of the batch file, keeping my backup time to just a few seconds.   Here is a SAMPLE line from my backup batch file:

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

I've printed out the entire list of XCOPY switches and I suggest that anyone wanting to use this command, do likewise.

If you run this command from a Command Prompt, you will get the switch list as a text file in your root directory, then you can pull it up in Notepad and print it out.

XCOPY /? > C:\xcopy.txt

I always prefer to use what MS gave us for free in every version of Windows, instead of installing more and more software.
Adding more and more programs every time you want to do something can CREATE a real 'Quagmire'.

XCOPY is just one DOS program that can save you a lot of time and effort once you learn how to use it.

I can send a batch file, using XCOPY to anyone in the world, who used any version of Windows and be assured it will run as intended.  Witness the batch files I've placed for download on my own web site.


Good Luck,
the Shadow B)
Good idea Shadow.  That will work perfectly.

Just so you know Robocopy is native to Vista and Windows 7.  XP just required that you download and install the Windows 2003 resource kit to use it.

Mike, make sure you use Xcopy's other option EXCLUDE so that you don't copy the .RED.XML file as well.
752.

Solve : help with script running in dos?

Answer»

hi there i am running a .ahk file with Autohotkeys .. when i go to run the script .. this is for Vista x64 .. it changes my \ to " .. so my folder would read

        (C:\Folder\Folder)  but in dos it is showing up as (C:"folder"folder) any help?Not sure what an autohotkey script has to do with dos or a batch file.when you execute the script .. it requires dos to runYou should post the script.
Quote from: phree on FEBRUARY 19, 2012, 11:17:59 AM

when you execute the script .. it requires dos to run
Do you mean your AHK script launches a btach file?AutoHotKey has a complex system of character replacement in parameter strings, in particular involving quotes and backslashes.

From the AutoHotKey documentation:

http://www.autohotkey.com/docs/commands/_EscapeChar.htm

Quote
The default escape character for AutoIt v2 (.aut) scripts is backslash (\). [...] When a .aut script is auto-converted into a .ahk script, the backslash escape character (\) is globally replaced with the accent character (`).

I suspect that those characters shown as double quotes by the OP are really accent/backticks.

Without seeing the original script, (and maybe not even then) it will be very difficult (for me at least!) to offer much advice.

Thus I recommend:

1. A thorough and careful STUDY of the AutoHotkey documentation.

http://www.autohotkey.com/docs/

2. Having done that, (OTHERWISE stand by to be flamed!) ask in one of the AutoHotkey forums, such as this one...

http://www.autohotkey.com/forum/

In fact, that forum's "search" facility showed me quite a few promising looking TOPICS.
Quote from: Salmon Trout on February 19, 2012, 01:00:19 PM
http://www.autohotkey.com/forum/

In fact, that forum's "search" facility showed me quite a few promising looking topics.
What a novel idea. A support forum for a piece of software.
753.

Solve : How do I write a batch file to use WinRAR to archive?

Answer»

Hello everybody , I'm new here  I'm looking for the support of the board
Throughout this week I looking for a batch file which does auto my work
I want to when the UTORRENT FINISH download it will RUN a  batch file, this batch file can run winrar to archive torrent file finish download, and defaut folder for archive is : E:\archive when archive finish winrar will move those archive files to folder E:\linkup (because I USE funtion "folder monitoring" of Z-o-o-m to upload my file, it only work when winrar archive finish so I need move archive files to E:\linkup). Current I only can use winrar to auto archive to E:\archive when utorrents finish download and don't know how to move archive files to E:\linkup when winrar archive finish

This is command line I used to auto archive in utorrents:

"c:\program files\winrar\winrar.exe" a -m0 -v401m "%N" "%D"



And this is funtion "folder monitoring" of Z-o-o-m (soft for upload)



Before that I set defaut for archive:





So please help me


can anyone help me  Wasn't  really any need to bump your thread it was only the 2nd one down in the list.

754.

Solve : Searching for str of text in files and exportation?

Answer»

Greetings everyone,

Having a problem finding a way to search through multiple text files for certain strings of text and then exporting those lines of text to a new document in a decent readable format.  Other then opening each file and scrolling through approximently 800-900 lines in each document and copy\paste or rewrite the data in a new file.   I'll give an example just so that if what im trying to do is feasible or not.  Here is what the text files look like when opened.  would like to be able to search for any line that contain:    MSG, or TOOL.


%
 (BI01375)
 N2(MSG,65B04241-9 SN BI01375  1 )
 N3(MSG,04OCT01 MC095 WKW CAO)
 N7(MSG,15:30  Oct.  4, 2001 CHG#7   )
N9G40G90G80G17
 ( MATERIAL LENGTH =  7.610 )
N10G20
N20G10Y.0Z.0L2A.0P1U31.08X-1.54
N30G54
N40G90G0Y.0A.0U-1.55
N50Z19.
N60G1F475.U-1.19
N70M0
N80M45
N90G0U-1.55
N100U-2.3
N110M48
(MSG,LOAD 00000004,L 05.5500,D 00.3750,R 00.0600)
N120T4
N130M6
N140S18000M3
N150M8
N160M38
N170G90G0X1.71Y1.7095A-90.T2
N180G43Z11.55H4
N190( * * * * * * * * * * * * * * * * * * * * * * * * * * * )
N200(*****OPERATION    10*****                              )
N210( * * * * * * * * * * * * * * * * * * * * * * * * * * * )
N220(TOOL  4 =  .375 DIAMETER ENDMILL                       )
N230( * * * * * * * * * * * * * * * * * * * * * * * * * * * )
N240Y-.484A.0
N250G94
N260G1Z5.45F700.
N270X1.7075Y-.4565F150.
N280Y.1925
N290X1.6875Y.2125
N300Y-.484F250.
N310G0Z11.55
N320( * * * * * * * * * * * * * * * * * * * * * * * * * * * )
N330(*****OPERATION    20*****                              )
N340( * * * * * * * * * * * * * * * * * * * * * * * * * * * )
N350(TOOL  4 =  .375 DIAMETER ENDMILL                       )
N360( * * * * * * * * * * * * * * * * * * * * * * * * * * * )
N370A-180.
N380X1.71Y.484
N390G1Z6.8735F700.
N400X1.6875Y.4565F150.



Would like the out put into another text or word\excel to be somewhat in the following format

Filename.XXX
N2(MSG,65B04241-9 SN BI01375  1 )
 N3(MSG,04OCT01 MC095 WKW CAO)
 N7(MSG,15:30  Oct.  4, 2001 CHG#7   )
(MSG,LOAD 00000004,L 05.5500,D 00.3750,R 00.0600)
N220(TOOL  4 =  .375 DIAMETER ENDMILL                       )
N350(TOOL  4 =  .375 DIAMETER ENDMILL                       )

next file.XXX
N2(MSG,65B04241-9 SN BI01375  1 )
 N3(MSG,04OCT01 MC095 WKW CAO)
 N7(MSG,15:30  Oct.  4, 2001 CHG#7   )
(MSG,LOAD 00000004,L 05.5500,D 00.3750,R 00.0600)
N220(TOOL  4 =  .375 DIAMETER ENDMILL                       )
N350(TOOL  4 =  .375 DIAMETER ENDMILL                       )


UNFORTUNATELY we have about 5-600 files to go through with the same process.  Not all of the files have the .txt extension if that makes a difference.  I thought about using the findstr cmd but have no idea on what parameters to use or how to get it to export to a file in a readable format.  If someone has any help or advice i would greatly appreciate it.

Dan






Are the input files all in a single DIRECTORY or do they span multiple directories and sub directories?

If they are not in a single directory is their a source directory where the sub directories start?The files are all in one folder but spread out through out subfolders in that one folder.  i did find one CAVEAT, i need to exclude the text files with extensions of   .mg as these file do contain some of the strings that i am searching for but but not with the information that i need....

I greatly appreciate the help...


DanSo each input file will have a new output file in the same directory?
Could you give me an example of your input file names and how you want the new output file named?Some of the files that will be scanned are  65B04241-9.PPU; 65B17613-44.PPU; 11T5008-010-3.PPU; 11T5008-010-4.PPU.  I was HOPING the output could put into one file instead of one output file for each input file.

755.

Solve : Seeking help on DOS command (SET command)?

Answer»

Hi All,

I am here to seek for any help on the DOS command!

I have a text file which contains 100+ which looks like the following lines:

[Inv.txt]
Peter;STD:17/09/200718/09/2012214;NBD:17/09/200818/09/20100;POW:17/09/200818/09/20100
Paul;STD:18/07/200719/07/2012153;POW:18/07/200819/07/20100;NBD:18/07/200819/07/20100
Mary;NBD:25/12/201026/12/2012312;POW:25/12/201026/12/2012312
John;STD:17/09/200718/09/2012214;POW:17/09/200818/09/20100;NBD:17/09/200818/09/20100
Jerry;POW:23/10/201124/10/2012250;NBD:23/10/201124/10/2012250
Alex;NBD:21/04/201122/04/2013430;POW:21/04/201222/04/2013366;POW:21/04/201022/04/201265
Alice;STD:23/04/200424/04/20090;NBD:23/04/200424/04/20070;POW:23/04/200424/04/20070

On each line, I only interesting on some information which start with POW;
[Result.txt]
Peter;POW:17/09/200818/09/20100
Paul;POW:18/07/200819/07/20100
Mary;POW:25/12/201026/12/2012312
John;POW:17/09/200818/09/20100
Jerry;POW:23/10/201124/10/2012250
Alex;POW:21/04/201222/04/2013366;POW:21/04/201022/04/201265
Alice;POW:23/04/200424/04/20070

I try to run the code:
For /F "tokens=1-8 delims=;" %%a in (inv.txt) Do (
SET STR== %%a
ECHO %%b > tmp.tmp
FINDSTR "^P" tmp.tmp
IF !ERRORLEVEL! EQU 0 SET STR=%STR%;%%b

ECHO %%c > tmp.tmp
FINDSTR "^P" tmp.tmp
IF !ERRORLEVEL! EQU 0 SET STR=%STR%;%%c

ECHO %%d > tmp.tmp
FINDSTR "^P" tmp.tmp
IF !ERRORLEVEL! EQU 0 SET STR=%STR%;%%d

ECHO %%e > tmp.tmp
FINDSTR "^P" tmp.tmp
IF !ERRORLEVEL! EQU 0 SET STR=%STR%;%%e

ECHO %%f > tmp.tmp
FINDSTR "^P" tmp.tmp
IF !ERRORLEVEL! EQU 0 SET STR=%STR%;%%f

ECHO %%g > tmp.tmp
FINDSTR "^P" tmp.tmp
IF !ERRORLEVEL! EQU 0 SET STR=%STR%;%%g

ECHO %%h > tmp.tmp
FINDSTR "^P" tmp.tmp
IF !ERRORLEVEL! EQU 0 SET STR=%STR%;%%h

ECHO %STR% >>Result.txt
)


The result was not right (It only has the first valuable "Peter" in the result.txt)
 and I figure out the SET command is not working....
Your guidance will be appreciated. Thank you!So are you basically saying their will never be more than 8 tokens?  Meaning 8 fields separated by a semi colon?
Your basic problem right now is that the POW information is never the same token(FIELD).
So you basically have to test each Token to see if the first 3 characters equal POW.Kind of WONDERING why you are confused with the DelayedExpansion.
You are using it with the ERRORLEVEL but you don't use it with your STR variable.  You do realize that you need to do it with both.  You ALSO did not explicitly enable delayed expansion anywhere in your script.

You also don't have to write out the LOOP variable to a file first.  Just echo the variable and pipe the output to the FINDSTR command.
ECHO %%g |FINDSTR "^P" Quote

SET STR== %%a

Lose those double equals

You could really shorten things up by doing this.
Code: [Select]ECHO %%b |FINDSTR "^P" &&SET STR=!STR!;%%bAnother approach would be to not use the set command at all. Clear, concise and about as simple as it gets:

Code: [Select]echo off
setlocal

for /f "tokens=1-4 delims=;" %%i in ('findstr /i "pow" inv.txt') do (
  echo %%j | find /i "pow" > nul && echo %%i;%%j
  echo %%k | find /i "pow" > nul && echo %%i;%%k
  echo %%l | find /i "pow" > nul && echo %%i;%%l
)

Note: Alex has two POW parameters and is therefore listed twice.

Good luck. 


Quote from: Sidewinder on March 01, 2012, 01:03:51 PM
Another approach would be to not use the set command at all. Clear, concise and about as simple as it gets:

Code: [Select]echo off
setlocal

for /f "tokens=1-4 delims=;" %%i in ('findstr /i "pow" inv.txt') do (
  echo %%j | find /i "pow" > nul && echo %%i;%%j
  echo %%k | find /i "pow" > nul && echo %%i;%%k
  echo %%l | find /i "pow" > nul && echo %%i;%%l
)

Note: Alex has two POW parameters and is therefore listed twice.

Good luck. 
But this doesn't work for the way he wants his output. Quote
But this doesn't work for the way he wants his output.

Code: [Select]echo off
setlocal

if exist result.txt del result.txt

for /f "tokens=1-4 delims=;" %%i in ('findstr /i "pow" inv.txt') do (
  echo %%j | find /i "pow" > nul && echo %%i;%%j >> result.txt
  echo %%k | find /i "pow" > nul && echo %%i;%%k >> result.txt
  echo %%l | find /i "pow" > nul && echo %%i;%%l >> result.txt
)

 



Quote from: Squashman on March 01, 2012, 09:51:34 AM
You could really shorten things up by doing this.
Code: [Select]ECHO %%b |FINDSTR "^P" &&SET STR=!STR!;%%b

Thanks for this tip, it is sample but powerful!Hi Squashman & Sidewinder;

First of all, thanks for your advice!

May be I do not make my question clear enough..... I have a CSV file :
- contain 100+ lines which have multi tokens (so some times it contains the key word "POW" more than once!)
- the first token is an index so it must remind at the beginning of the line!
- wants to show each entries like
   index;POW:XXXXXXXX;POW:XXXXXXXX;POW..... <- if 2rd or 3th or 4th .....found!

I try to store/update the new token into the variable so it can ECHO the result at the same line.
Also rewrite the code and still the %STR% is not change the way I want

======================================================================
setlocal

if exist result.txt del result.txt
For /F "tokens=1-8 delims=;" %%a in (inv.txt) Do (
   ::Store the first token into the variable
   SET STR=%%a
   ::Test each token; if found start with "P" add it into %STR%
   ECHO %%b |FINDSTR "^P" &&SET STR=!STR!;%%b
   ECHO %%c |FINDSTR "^P" &&SET STR=!STR!;%%c
   ECHO %%d |FINDSTR "^P" &&SET STR=!STR!;%%d
   ECHO %%e |FINDSTR "^P" &&SET STR=!STR!;%%e
   ECHO %%f |FINDSTR "^P" &&SET STR=!STR!;%%f
   ECHO %%g |FINDSTR "^P" &&SET STR=!STR!;%%g
   ECHO %%h |FINDSTR "^P" &&SET STR=!STR!;%%h
   ::Output the string into the final result
   ECHO %STR% >> result.txt
)
===================================================
After run the batch; the result.txt only contains the index :-(
%Peter
%Paul
%Mary
%John
%Jerry
%Alex
%Alice

The STR will not update and seem the SET command is not working at all.....

Ok....after do some search on the delayedexpansion....all I need is add "Setlocal enabledelayedexpansion" at the beginning, and it work!  Quote from: qzero on March 01, 2012, 09:27:52 PM
all I need is add "Setlocal enabledelayedexpansion" at the beginning, and it work! 

Maybe. You need to change %STR% to !STR! everywhere inside the loop.

you missed one...

Quote
ECHO %STR% >> result.txt

Also (VERY IMPORTANT) - You must not use double-colons ( to start comments inside a loop. It will break the code. Double colons are broken labels. They are unofficial, undocumented, deprecated, not supported, bad, wrong, etc. (Yes I know they were OK to use in MS-DOS. This is not MS-DOS). Use REM.





Quote
- the first token is an index so it must remind at the beginning of the line!
- wants to show each entries like

I realize I'm not smarter then a fifth grader, but I can't seem to locate the index you WROTE about.

This second try is not nearly as elegant as my first but is more generic .It will scan each line for all keywords present, filtering out POW for processing.

Code: [Select]echo off
setlocal enabledelayedexpansion

for /f "tokens=1* delims=;" %%i in (inv.txt) do (
  set keyword=
  call :keywords %%j
  echo %%i!keyword!

goto :eof

:keywords
  if .%1==. goto :eof
  echo %1 | find /i "pow" > nul && set keyword=%keyword%;%1
  shift
  goto keywords

If you want to push the output into a file, add redirection to the echo STATEMENT in the for loop.

Hope this works for you.
756.

Solve : Ping Test Bat?

Answer»

Im tring to make a batch file that will run a ping test.  Basically, this is what I really have an Im going off memory

echo off

1 Preform a self Ping Test?
2 Enter a IP too Ping
3 Exit

if
Ping 127.0.0.1
else
ping


ExitWhat are you trying to accomplish here? You don't have this in any sort of Batch script language. Are you wanting a menu? What do you want the options to do?

From what I can gather, try this:

Code: [Select]echo off
:Menu
cls
echo 1 Perform a self Ping Test
echo 2 Enter a IP to Ping
echo 3 Exit
echo.
set /p ans=

if "%ans%"=="1" (
  ping 127.0.0.1
  pause
  goto Menu
)
if "%ans%"=="2" (
  set /p ip=IP:
  ping %ip%
  pause
  goto Menu
if "%ans%"=="3" (exit)
goto Menu
This program will REQUIRE that you press 3 to exit. It also will only do something with a 1 2 or 3, and will display the Menu again if it receives anything else. When asking for something, please be much more specific as to what you want, as that is more helpful in the long run.I wanted to be able to run a batch file that opened a batch file for network testing.  I wanted to have three options as indicated there to be selected.  I havent done anything with dos for a while so sorry if the code seems noobish.  If its anything other then 3 I wanted it to come back as not a vaild choice.    Quote from: Ryuk on January 11, 2012, 10:24:49 AM

I wanted to be able to run a batch file that opened a batch file for network testing.     

Is there a reason to have the batch call another batch? It would seem simpler overall to keep it all within the same file. Currently it pings the loopback address with option 1, pings an entered IP for option 2, and exits for option 3. If you would like to add more functionality to it, it shouldn't be problematic to have it all happen within the construct it is in now.

Quote from: Ryuk on January 11, 2012, 10:24:49 AM
If its anything other then 3 I wanted it to come back as not a vaild choice.

Easy enough. This goes in between the last two lines (notice they are the top and BOTTOM lines in this snippet):

Code: [Select]if "%ans%"=="3" (exit)
echo Invalid Entry
echo.
echo Please try again
pause
goto Menuummm.. No sorry, that was a grammer error on my part.  Quote from: Raven19528 on January 08, 2012, 05:43:50 PM
What are you trying to accomplish here? You don't have this in any sort of Batch script language. Are you wanting a menu? What do you want the options to do?

From what I can gather, try this:

Code: [Select]echo off
:Menu
cls
echo 1 Perform a self Ping Test
echo 2 Enter a IP to Ping
echo 3 Exit
echo.
set /p ans=

if "%ans%"=="1" (
  ping 127.0.0.1
  pause
  goto Menu
)
if "%ans%"=="2" (
  set /p ip=IP:
  ping %ip%
  pause
  goto Menu
if "%ans%"=="3" (exit)
goto Menu
This program will require that you press 3 to exit. It also will only do something with a 1 2 or 3, and will display the Menu again if it receives anything else. When asking for something, please be much more specific as to what you want, as that is more helpful in the long run.

sadly, it doesnt work.  I select each of the three options an it just exits Quote from: Ryuk on January 11, 2012, 11:34:01 AM
ummm.. No sorry, that was a grammer error on my part.


Quote from: Ryuk on January 21, 2012, 04:10:26 PM
sadly, it doesnt work.  I select each of the three options an it just exits
Maybe a spelling grammar error. Missing a closing parenthesis.I didnt build this, really I just wondered about how to get user input.  Also, what would of been wrong with my code Quote from: Ryuk on January 22, 2012, 10:06:05 AM
I didnt build this, really I just wondered about how to get user input.  Also, what would of been wrong with my code

The code you SAID at the top of the page wouldn't have worked because it isn't properly written, for example "1 Preform a self Ping Test?" would not have been displayed on screen and would have been interpreted as a command, rather than a comment. If you wanted the text to show you need to use the echo command (echo 1 Preform a self Ping Test?) as this tells Ms Dos that the following is not a command, but rather text to be printed on screen.
The user input as  said by Raven19528 is the "set /p ans=" part where it will set the variable "ans" to whatever the user inputs.

Hope this helped.I ment to SAY his code.  I can post mine but, I know it wont work an havent done anything with it since. Quote from: Squashman on January 21, 2012, 08:48:05 PM
Missing a closing parenthesis.

Yes I am, try this on the last few lines: Code: [Select]if "%ans%"=="2" (
  set /p ip=IP:
  ping %ip%
  pause
  goto Menu
)
if "%ans%"=="3" (exit)
goto Menu
Notice I missed that final closing parenthesis. Try it now and see what happens.I am able to select know.  The issue still remains where it wont allow to do a LOOP back or for entered ip'sYou need to show us the exact code you are using.Im just useing what was posted by Raven
757.

Solve : Reinstalling windows98?

Answer»

I have had to format my KIDS hard drive once again!!

Only this time when I went to reinstall windows98 my computer shows "type the name of command interpreter e.g. C:|WINDOWS\COMMAND.COM" followed by C>

I HATE to say it but I'm lost at what it would like to put in??  Can any one help?
The first concern should be what are those little darlings doing that is CAUSING frequent re-installs of W98??!!  When you fix that problem, ....!

When you went to re-install Win98, what exactly did you do prior to getting that message?  The command interpreter is the DOS environment and is the file COMMAND.com.  Do you have 2 or more Windows98 boot disks and possibly the one you used to start the install is missing that file?

A re-install of Windows98 can be done while running Windows, but this is often ineffective.  It should be done using the boot disk and you must boot up to that floppy.  And that floppy must have a command.com.

Are you doing a clean install?  This means that you are deleting the Windows folder and then doing the install.  A clean install is the only way to correct some problems that have to do with registry errors.  Your kids don't know how to run regedit I hope, because they could easily bring their system to the no can boot situation very quickly.  

Be aware that if you DELETE the Windows folder you are deleting all mail boxes and address book unless they have been moved out of the Windows folder.

How much memory do you have?  Processor speed?  Available disk space?  And they probably have Internet access?  Are they running a frequently updated anti-virus?  Are they running a firewall?  These are questions leading to finding out what is destroying the system!

When the boot process can't find command.com in the root of the A: floppy, then it wants you to tell the boot where the file is.  But you have no way to find out where command.com is.  Bring your Windows98se boot disk(s) to another system and make sure that there is a command.com.  This assumes you are booting to the A: floppy.  When booting to the C: partition, boot looks for command.com in the root of the C: partition which would be C:\COMMAND.COM.  But if Windows is busted, you need to be booting to the floppy.

You can try entering C:\Windows because under Windows98se, that's where the command.com is and it's also in c:\.

Good luck
Chris C.Thank you Chris,  and I'm not sure I would CALL them little darlings

It seems most of their troubles begins with msn and downloading too many skateboard videos and music, although the final straw yesterday was that the oldest decided to download a spyware program aswell as downloading an upgrade norton.  

After getting some sleep, I decided just to make another boot disk (incase the other was corrupt) and now things are working great!

Thank you for your help Maybe a copy of Norton Ghost or similar image-copy utility? Use this to make an image of the complete install to CD once you have it working baseline plus drivers and Windows Security Update/WindowsUpdate. Then you can boot to the first image-copy CDROM and it will let you wipe the HD and re-create the system from the CDs...

758.

Solve : Batch File to access a dbf file and get data from the last record?

Answer»

I need to WRITE a batch FILE that can access a .dbf file (???pclk.dbf) and get the date from the PL_Date field in this file where the pl_class='O*'.  I then want to use this as a parameter to run another batch file.  There will ALWAYS be at last 10 records with pl_class="O*".  I need the last occurrance of this.  The ???pclk.dbf file only has 3 fields PL_Date, PL_Route,PL_Class

The following is what I intend doing

Variable DayendDate
get last pl_date from ???pclk.dbf where pl_class="O*"
DayendDate= pl_date
beforend DayendDate

Please help with suggestions

I also want to use this date to check a directory for existing files with the NEXT date name and then copy a file to this directory with the date name and increment the extention by 1 every time. eg: if dayendDate=20120127 and 20120128.1 , 20120128.2 is found in directory want to copy backp.zip to 20120128.3 in that directory.


Variable ExtIncrm
ExtIncm=(FileOccurrance in SUB directory)
copy backup.zip to (DayEndDate).(ExtIncm+1)



Please Help!!!


759.

Solve : Simple for loop question?

Answer»

Hey all.  This one seems like it should be simple...  I have a SCRIPT containing

for %%x in (*.sql) do (
echo Working on file - %%x...
)

echo.

for %%X in (myDll1.dll myDll2.dll myDll3.dll) do (
echo Working on file - %%x...
)

set COM_LIST=(myDll1.dll myDll2.dll myDll3.dll)

echo.

for %%X in %COM_LIST% do (
echo Working on file - %%x...
)

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

This results in:

Working on file - mySql1.sql...
Working on file - mySql2.sql...

Working on file - %x...
Working on file - %x...
Working on file - %x...

Working on file - %x...
Working on file - %x...
Working on file - %x...

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

The first set of echo statements are correct but what is up with the second two?  I KNOW I have to be missing something simple but I am in a hurry and don't have time to run around in circles with this.

Thanks!
You are using %%X and %%x as For variables.   Yea, I just caught that right before you posted.  Thanks for your REPLY though...  Gotta watch the copy/paste stuff I guess...In FOR loops, the variable name is case sensitive, that is %%A to %%Z are not the same as %%a to %%z, so in your code the FOR variable is %%X but in the loop you are referencing %%x
Hey, thanks, Salmon Trout...  It was a simple oversight on my part and in my haste I PROBABLY posted that question prematurely.  I appreciate your INPUT, though. Quote

for %%X in %COM_LIST% do (
echo Working on file - %%x...
)

Also that should probably be

for %%X in (%COM_LIST%) do (
echo Working on file - %%X...
)
760.

Solve : Need batch file help?

Answer»

I want to make a BATCH file.
Example.
:1
echo Hello
PING 1.1.1.1 -n 1 -W 1>NUL
cls
echo         Hello
PING 1.1.1.1 -n 1 -w 60000 >NUL
cls
echo                  hello
goto 1

If any key pressed goto 33
:33
echo This is over.
pause
i want to be able to press any key in between the commands to goto a different command

Basically what i want it to do is keep doing commands but when i press SOMETHING at any time it will go to another command.Batch does not have a method of COLLECTING keypresses like you describe. You will need a proper PROGRAMMING language.

761.

Solve : Copy registry file to another computer and run it or...?

Answer»

Hey guys, I want to know if it is possible to copy a registry file from one machine to another(both with admin RIGHTS) and then run it afterwards. If not, then can you do the REG ADD command from one machine to another? Any response would be nice EVEN if you say I don't know, but thanks anyways.
PS: This post is OVER 9000!!! Quote

Hey guys, I want to know if it is possible to copy a registry file from one machine to another(both with admin rights) and then run it afterwards.

You can just use remote registry: http://www.techrepublic.com/article/remote-registry-administration-in-windows-xp-professional/5173421

You could copy it into the startup folder if it's shared.Thank you for giving me that link, it is not exactly what I am looking for. I would like to use the Command Prompt or a Batch file. Yes, I could copy it to the startup folder, but I would like to run it right away. I guess I was not specific enough, sorry about that. I don't really think that is possible unless you had VNC to that computer or something, the main reason is for security.

You could copy to the start-up folder and then do a remote restart.

shutdown /r -m \\xxx.xxx.xxx.xxx
Replace xxx.xxx.xxx.xxx with the IP address or computer name of the remote machine.Thank you for that response again! I did find an alternative though.
Code: [Select]echo off
color 0a
net view
echo.
set /p b=Type the computer name you are modifying:
echo.
set /p c=Type the homepage url you are changing:
cls
set /p d=Are you sure you want to change %b% homepage? [Y/N]:
if /i %d%==n goto a
cls
regini [-m %b%] REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MAIN" /V "START PAGE" /D "%c%" /F
pause >nul
goto a
762.

Solve : Check for AVG, if it's not there, then install?

Answer»

Trying to create a batch file that will do the following?

Check for file (c:\program files\avg\avg2012)
if there then exit

if not then popup message
user clicks on OK and another batch file is called. (\\192.0.1.100\apps\avg\avgsetup.bat)

 
We have AVG 2012 Business with Admin control. The new 2012 version has a wizard that created an install script. So what I want to do is look for the 2012 file and if its not there then to go ahead and install the program. I PLAN on using this same script for some other programs as well until I can get my system capable of using group policy correctly.So is that the exact path and name of the file? Because that looks LIKE a folder name to me. You seem to be confused about what batch files can do, specifically they can't popup messages with buttons on them. You would be betetr off using Visual Basic Script for that, but maybe that isn't AVAILABLE to you.

Those are.

A long time AGO I used a batch file in this same manner. That might have been the last time. I might have called up a vbs for the popup or maybe even a windows script file. I dont really remember. I'm game for anything that would work.Something like this might do the trick; you'll have to figure out running a batch from a network location, as I can't try that part out on this machine.

CODE: [Select]echo off
if exist "C:\Program Files\AVG\AVG2012" goto end
echo Wscript.echo MsgBox("Click OK to install AVG 2012", vbOKonly, "Message")>Myinput.vbs
cscript //nologo myinput.vbs
cmd /c \\192.0.1.100\apps\avg\avgsetup.bat
:end


I will give it a try. I only wish my memory still worked.

763.

Solve : syntax error?

Answer»

Hello,
I am having some trouble diagnosing a syntax error and was wondering if anyone could help.

I have narrowed it down to the line between the two pauses
Code: [Select]...
:ok4
set a=0
set b=0
cls
echo Enter Red 1's score (##)
set /p red1=
if "%red1:~0,1%" =="1" set a=1
if "%red1:~0,1%" =="2" set a=1
if "%red1:~0,1%" =="3" set a=1
if "%red1:~0,1%" =="4" set a=1
if "%red1:~0,1%" =="5" set a=1
if "%red1:~0,1%" =="6" set a=1
if "%red1:~0,1%" =="7" set a=1
if "%red1:~0,1%" =="8" set a=1
if "%red1:~0,1%" =="9" set a=1
if "%red1:~0,1%" =="0" set a=1
if "%red1:~1,1%" =="1" set b=1
if "%red1:~1,1%" =="2" set b=1
if "%red1:~1,1%" =="3" set b=1
if "%red1:~1,1%" =="4" set b=1
if "%red1:~1,1%" =="5" set b=1
if "%red1:~1,1%" =="6" set b=1
if "%red1:~1,1%" =="7" set b=1
if "%red1:~1,1%" =="8" set b=1
if "%red1:~1,1%" =="9" set b=1
if "%red1:~1,1%" =="0" set b=1
set /a c=%a%+%b%
if "%c%" =="2" goto ok5


:ok5
set a=0
set b=0
cls
echo Enter Red 2's score (##)
set /p red2=
pause
if "%red2:~0,1%” =="1" set a=1
pause
if "%red2:~0,1%” =="2" set a=1
if "%red2:~0,1%” =="3" set a=1
if "%red2:~0,1%” =="4" set a=1
if "%red2:~0,1%” =="5" set a=1
if "%red2:~0,1%” =="6" set a=1
if "%red2:~0,1%” =="7" set a=1
if "%red2:~0,1%” =="8" set a=1
if "%red2:~0,1%” =="9" set a=1
if "%red2:~0,1%” =="0" set a=1
if "%red2:~1,1%” =="1" set b=1
if "%red2:~1,1%” =="2" set b=1
if "%red2:~1,1%” =="3" set b=1
if "%red2:~1,1%” =="4" set b=1
if "%red2:~1,1%” =="5" set b=1
if "%red2:~1,1%” =="6" set b=1
if "%red2:~1,1%” =="7" set b=1
if "%red2:~1,1%” =="8" set b=1
if "%red2:~1,1%” =="9" set b=1
if "%red2:~1,1%” =="0" set b=1
set /a c=%a%+%b%
if "%c%" =="2" goto ok6
goto ok5
...

Thanks a ton!Isit not obvious?
Code: [Select]if "%red2:~0,1%” =="1" set a=1 Quote

D:\bat>if "%red2:~0,1%” =="1" set a=1
The syntax of the command is incorrect.
D:\bat>
Code: [Select]if "%red1:~0,1%" =="1" set a=1The above works fine. What are you trying to do?

My vision is very poor, but I can see the PROBLEM. Is this a quiz?
Quote from: Geek-9pm on March 13, 2012, 12:28:40 AM
Isit not obvious?
Code: [Select]if "%red2:~0,1%” =="1" set a=1 Code: [Select]if "%red1:~0,1%" =="1" set a=1The above works fine. What are you trying to do?

My vision is very poor, but I can see the problem. Is this a quiz?

What is difference in the two lines of code?As I said in the PM, you used EXTENDED ASCII code.
Quote from: Geek-9pm on March 13, 2012, 12:28:40 AM
Isit not obvious?
Code: [Select]if "%red2:~0,1%” =="1" set a=1 Code: [Select]if "%red1:~0,1%" =="1" set a=1The above works fine. What are you trying to do?

My vision is very poor, but I can see the problem. Is this a quiz?

I am writing a questionare to fill out a txt file in a certain format.
this line is to make sure that the imput for red2 =## and not a bunch of letters
and no, I'm on a FIRST robotics team, and my friend wanted this for his php server.

Quote from: Geek-9pm on March 13, 2012, 10:02:34 AM
As I said in the PM, you used extended ASCII code.

Not sure what you mean by this. Quote
Not sure what you mean by this.

One of the quotes chars is not the right one. In the first ASCII set there is only one; it looks like this: "
Most keyboards will not generate  chars beyond code 127. And such chars from 128 up has to come from the on-screen keyboard. Or some word process editors use the emended pair. They look like this:
 “ ”       
 I can force those codes by holing the alt key and hitting 223 or 224 on the numeric pad. (Hard to do on a laptop, takes 3 fingers.)   
This link below is for reference for all that wish to dig deeper into what 'extended ASCII' means in the jargon.
http://www.ascii-code.com/
Moral: don't use strange chars in a batch file.
if "%red2:~0,1%” =="1" set a=1
               ^
               |
     don't use smart quotes               

Quote from: Salmon Trout on March 13, 2012, 12:43:12 PM

if "%red2:~0,1%” =="1" set a=1
               ^
               |
     don't use smart quotes               



MIND = blown

thanks guys
764.

Solve : Commands will run in dos window, but not in bat file?

Answer»

I'm trying to execute a dos batch file with the following commands:

C:\hysplit4\exec\hyts_std
C:\hysplit4\exec\trajplot -iof12jun0923 -ojun12plot -v1 -l12 -m3 -a5
c:\hysplit4\exec\ascii2shp -d jun12plot lines < GIS_traj_ps_01.txt

The first line executes a meteorological model that develops a back trajectory or path of an air parcel.  It looks for an input file named CONTROL and uses its information to execute.  If it can't find the input file it defaults to asking for input via keyboard.

The second line takes the output file of the met model and creates a postscript graphic file of the trajectory and creates two additional output files (one of them GIS_traj_ps_01.txt) for conversion to an ESRI GIS shapefile.

The third line takes the file GIS_traj_ps_01.txt and converts the data into an ArcGIS shape file which can be imported into ArcGIS.  This system comes with a GUI which can handle one trajectory at a time, but to do an adequate analysis, I need to do several hundred.  Ideally, I would like to automate this process and loop through the process.  I have tried using Excel VBA's shell function for these and got nowhere.  The hyts_std executable could not find the CONTROL file and defaults to asking for keyboard input.

I can get all three commands to work properly when entered manually into a DOS window from the keyboard.  They can find the necessary input files and execute properly.  When I put them into a single bat file, however, they don't work.  I use the latest version of Windows XP at work and Windows Home Premium at home.  Any suggestions?  Many thanks in advance!

ErikG Quote from: ErikG on January 27, 2012, 02:00:04 PM

When I put them into a single bat file, however, they don't work.

Don't work? How? (In what way don't they work? With what symptoms/messages etc?)
I've only put them in batch files with the hyts_std executable by itself in one file and the trajplot and ascii2shp in the other batch file.

The hyts_std returns the default request for keyboard input.
The other two executables simply flash a dos window open and shut (to quickly to see anything written)Launch the batch file from the command prompt or put a pause in the script.

You need to be a little more clear on what you are doing. You need to show us the code that is in the batch file and its output.Timing may be an issue. An new task can start before the output file is closed from an earlier task.  If so, there NEEDS to be something that makes sure the file is ready for the next task.
You may wish to use a pipe.I suggest you put a pause statement after each command. When the program pauses, open another DOS command and check to see if the files you need have actually been created. Also there is a 'DELAY.COM' command I picked up someplace years ago. Probably Norton Utilities. It will wait for X number of seconds. I us it a lot of TIMES to wait for 2-5 seconds so files will have different time stamps. Maybe the time that is showed, but also the 1/10 of seconds. This way I can enter 'DIR /OD' and I an see exactly the order the fils were created. Hope this helped


Thanks very much for all the help!  I've got things working now. Quote from: ErikG on February 14, 2012, 04:11:31 PM
Thanks very much for all the help!  I've got things working now.
Would help all that find this thread later on if you would post your final solution.I needed to make sure that I was in the correct directory when running the file so I ADDED: cd c:\hysplit4\exec to the top of the three commands.
765.

Solve : Command prompt not clearing issue and have questions.?

Answer» HELLO everyone...it's been a while since my last visit. I am working on a project and I am having a bit of trouble. I have done quite a bit of reading on line but haven't found anything that works for me so far.

I am learning how to set up a flash drive so I can install Windows XP on it if ever I have any issues with my OEM installation disc. Currently I have the files from my Windows XP Home SP2 installation disc loaded to a folder on my C drive. I need to "Integrate" SP3 into my source file, which I have loaded to a folder on my C drive as well.

I'm having a problem clearing the command prompt so I can do the integration part. When I bring up the command prompt window...

C:\Documents and Settings\my name> is on the screen and I can't clear it. What am I doing wrong here? I keep trying CLR  but it doesn't work. I always get 'CLR' is not recognized as an internal or external command, operable program or batch file.

I read some HELP post here on this forum and tried the 'CLS' command I found and it only cleared the stuff about Microsoft Version, etc. at the very top of the window but always LEAVES...

C:\Documents and Settings\my name>

From her experience as a data processor at her job, my wife is telling me something is pointing to that above file but neither one of us can figure out the how's, why's, or what's to get a clean command prompt window.

Can anyone tell what is causing this issue? I'm willing to bet it has to do with some sort of setting but I don't EVEN have a clue how to correct it.

If there is anything anyone needs to know at my end please let me know and I'll get back to you ASAP.

Thanks,
GaryThe only way I know of doing this is with regedit.exe.
Open run>type regedit>hit enter>go to  HKEY_LOCAL_MACHINE>SOFTWARE>Microsoft>Command Processor
On the right side, double-click "Autorun" and type this in:   echo off&cls  Click Ok and you're done.
This is the only way I know to do it, I don't know if there are more ways...
-Nathansswell® Quote from: Nathansswell on March 12, 2012, 06:22:17 PM
The only way I know of doing this is with regedit.exe.
Open run>type regedit>hit enter>go to  HKEY_LOCAL_MACHINE>SOFTWARE>Microsoft>Command Processor
On the right side, double-click "Autorun" and type this in:   echo off&cls  Click Ok and you're done.
This is the only way I know to do it, I don't know if there are more ways...
-Nathansswell®


Ok I tried it and it WORKED. I have an empty command prompt screen now. 

What does that command actually do?

Should echo be on or off?

Being the first time trying this I don't know what to expect. Will everything work right?


Thanks Quote from: 69Z28 on March 12, 2012, 06:02:35 PM

I'm having a problem clearing the command prompt so I can do the integration part. When I bring up the command prompt window...

C:\Documents and Settings\my name> is on the screen and I can't clear it. What am I doing wrong here?

I read some help post here on this forum and tried the 'CLS' command I found and it only cleared the stuff about Microsoft Version, etc. at the very top of the window but always leaves...

C:\Documents and Settings\my name>


1. When opening a fresh command window a Microsoft message is displayed. To clear this the correct command is CLS.
2. When in an interactive session, the default prompt is the name and path of the logged-in folder, followed by the > character. Immediately to the right of that is a cursor, which may or may not be blinking.

What exactly do you mean that you are having trouble clearing the prompt? Why do you need to do this anyway? It is there to let you know the console is ready for a command to be entered.
766.

Solve : My batch file work on XP but not on Win7.?

Answer»

My script:

echo off
echo.
echo Please enter one of the listed options:
echo.
echo Select "S" or "s"to shut down.
echo
echo ****************************************************
echo.
echo Select "R" or "r"to restart.
echo
echo ****************************************************
echo.
echo Select "E" or "e"to exit this screen.
echo.
echo ****************************************************
echo.
set /p choice=Select choice and enter:
set choice=%choice:~0,1%
if /I "%choice%"=="S" goto SHUTDOWN
if /I "%choice%"=="R" goto restart
if /I "%choice%"=="E" exit

:shutdown
shutdown -s -t 10

:restart
shutdown -r -t 0

I save it as Run.bat

In WinXP it runs perfectly.

But in Win7, when i enter S for shut down, it runs shutdown (can see the warning that computer is shutting down in less than a minute) and follow by restart and it ended up restart.

Any idea?Possibly this may be because in Vista and later you need to be an administrator or a user who has been assigned the Shut down the system user right.

You don't need those labels. Why don't you just do this? (then you won't have the code falling through to the next label and you may be able to see any error messages)

Code: [Select]
set /p choice=Select choice and enter:
set choice=%choice:~0,1%
if /I "%choice%"=="S" shutdown -s -t 10
if /I "%choice%"=="R" shutdown -r -t 0
exit



But by running shutdown -s -t 10

from cmd works fine.See my edited post above
ok thanks.

Btw if i put it like this, it shuts down fine.

:restart
shutdown -r -t 0

:shutdown
shutdown -s -t 10
The reason for this is simple. The batch script triggers the shutdown process, but does not wait for it to complete. In XP you cannot start a second shutdown if one is already running, in Windows 7 the second one replaces the first if the delay has not expired.

Do you see why I suggested that you avoid using labels in this script? Of course you can put an EXIT command in the right place. Or SWITCH the restart and shutdown sections.

By the way, you have lines starting echo (no dot) which will trigger "echo is off" messages.


set /p choice=Select choice and enter:
set choice=%choice:~0,1%
if /I "%choice%"=="S" goto shutdown <------ If you select S these things happen:
if /I "%choice%"=="R" goto restart
if /I "%choice%"=="E" exit

:shutdown         <------ Execution is directed to this label
shutdown -s -t 10 <------ Shutdown -s process starts with 10 second delay
                  <------ Batch does not wait. Execution returns here.
:restart          <------ Execution falls through to this label
shutdown -r -t 0  <------ In XP this is barred, in Windows 7 a Shutdown -r process starts with no delay and restart is triggered.

This shows something you have to remember if you use goto with labels: you have to manage what happens after you have gone to the label and executed the command or COMMANDS after that label. Also you have to manage what happens if none of the IF tests are satisfied.

set /p animal="Type cat or dog "
if /i "%animal%"=="cat" goto cat
if /i "%animal%"=="dog" goto dog

if you TYPED anything other than cat or dog you will still get here
:cat
echo You typed cat

if you typed cat you will still get here
:dog
echo You typed dog


If you typed "fish" the batch will show

You typed cat
You typed dog

If you typed "cat" the batch will show

You typed cat
You typed dog

If you typed "dog" the batch will show

You typed dog

This shows how to manage (a) wrong input (B) correct input:


:loop
set /p animal="Type cat or dog "
if /i "%animal%"=="cat" goto cat
if /i "%animal%"=="dog" goto dog
echo Type cat or dog only!
goto loop

:cat
echo You typed cat
goto end

:dog
echo You typed dog

:end



767.

Solve : HOW TO TAKE COMPUTER NAME TO A TEXT FILE?

Answer» SIR,
how can i take the name of a local MACHINE to a text filein order to take the computer name to a variable
you need to use the command in autoexec.bat

eg:
set computername=edp

after booting win98 you can type the following command to get the computer name

echo %computername%

I got the solution only after WORKING with system at AROUND 3 hoursFor 2K/XP, all you'd have to do is:

echo %computername% >c:\name.txt

The name for this example ends up in the file C:\NAME.TXT
768.

Solve : Cant find what's going wrong with IF statements?

Answer»

Hey guys I'm back a second time with a new and exciting error ^^ *cry's deeply*. Anyway I think the IF statements are running even if the conditions are not met, but cant seem to track down exactly why or where I'm going wrong. The code is a little test for a combat phase in a small RPG game in the making in case anyone is interested . Now I know the code isn't all that efficient as it could be, but that's because I'm still  newish to batch files, so if there is any parts that could be made better just say . There is also a small problem when I target the second monster (%MonsterName2% goblin) it seems to take health off %MonsterName% instead of the second target like I wanted.
As I'm not sure what part is causing this and you will probably need the variables to re-create the error ill post all the  code I have so far.
Thanks in advanced!

The error:
after line Code: [Select]if /i %Target%==%MonsterName1% (
if %MonsterHealth1% LEQ 0 (
set MonsterName1=Dead
set MonsterHealth1=0
)
)I get:
        0 was unexpected at this time
        if       LEQ 0 (

Code: [Select]REM variables: -----------------------
set Agility=80
set Health=150
set Intellect=0
set Level=1
set MyVarName=Risen91
set Strength=150
set Xp=0
set Bot1Agility=30
set Bot1Health=130
set Bot1Intellect=250
set Bot1Level=1
set Bot1Name=Jessica
set Bot1Strength=50
set Bot1Xp=0
set Lvl2=100
set Lvl3=300
set Lvl4=600
set MonsterAgility=80
set MonsterHealth=150
set MonsterHealth1=150
set MonsterIntellect=0
set MonsterName=Rat
set MonsterName1=Goblin
set MonsterName2=-
set MonsterName3=-
set MonsterName4=-
set MonsterStrength=150
set /a MonsterLevel=%level%-1
set /a MonsterLevel1=%random%*3/32767+%MonsterLevel%
if %MonsterLevel1% Lss 1 (
set MonsterLevel1=1
)
cls
:MainMenu
REM Menu: --------------------
echo.
echo Fight
echo Spells
echo Inventory
echo Team
echo Run
echo.
echo.
Set /p menu=Choose a option:
if /i %menu%==Fight (
goto Fight
)
cls
echo Please choose a vailid option!
pause
cls
goto MainMenu
REM attack sub menu: -----------------------
:Fight
cls
echo.
echo Attack
echo Power Attack
echo.
set /p menu=Choose a option:
if /i %menu%==Attack (
goto Attack
)
REM Targeter: ---------------------
:Attack
cls
echo.
echo %MonsterName%
echo %MonsterHealth%
echo ------------------
echo %MonsterName1%
echo %MonsterHealth1%
echo ------------------
echo %MonsterName2%
echo %MonsterHealth2%
echo ------------------
echo %MonsterName3%
echo %MonsterHealth3%
echo ------------------
echo %MonsterName4%
echo %MonsterHealth4%
echo.
set /p Target=Choose a target to attack:
if /i %Target%==%MonsterName% (
goto Attack2
)
if /i %Target%==%MonsterName1% (
goto Attack2
)
if /i %Target%==%MonsterName2% (
goto Attack2
)
if /i %Target%==%MonsterName3% (
goto Attack2
)
if /i %Target%==%MonsterName4% (
goto Attack2
)
cls
echo Please choose a valid target!
pause
goto Attack
:loop
REM Damage: ------------------------
:Attack2
set /a hit=%random%%%10
set /a modifier=%random%%%2
if %modifier%==0 (
set mod=-
)
if %modifier%==1 (
set mod=+
)
set /a strnerf=%strength%/6
set /a dmg=%strnerf%%mod%%hit%
set /a critchance=%random%%%15
if %critchance%==0 (
set /a dmg=%dmg%+%dmg%
set critsay=1
) else (
set crit=0
set critsay=0
)
set /a miss=%random%%%15
if %miss%==0 (
set dmg=Attack Missed!
)
echo %dmg%
if %critsay%==1 (
echo Critical Hit!
)
if /i %Target%==%MonsterName% (
set /a MonsterHealth=%MonsterHealth%-%dmg%
echo %Target%s health=%MonsterHealth%
)
if /i %Target%==%MonsterName1% (
set /a MonsterHealth=%MonsterHealth1%-%dmg%
echo %Target%s health=%MonsterHealth1%
)
if /i %Target%==%MonsterName2% (
set /a MonsterHealth=%MonsterHealth2%-%dmg%
echo %Target%s health=%MonsterHealth2%
)
if /i %Target%==%MonsterName3% (
set /a MonsterHealth=%MonsterHealth3%-%dmg%
echo %Target%s health=%MonsterHealth3%
)
if /i %Target%==%MonsterName4% (
set /a MonsterHealth=%MonsterHealth4%-%dmg%
echo %Target%s health=%MonsterHealth4%
)

if /i %Target%==%MonsterName% (
if %MonsterHealth% LEQ 0 (
set MonsterName=Dead
set MonsterHealth=0
)
)
if /i %Target%==%MonsterName1% (
if %MonsterHealth1% LEQ 0 (
set MonsterName1=Dead
set MonsterHealth1=0
)
)
if /i %Target%==%MonsterName2% (
if %MonsterHealth2% LEQ 0 (
set MonsterName2=Dead
set MonsterHealth2=0
)
)
if /i %Target%==%MonsterName3% (
if %MonsterHealth3% LEQ 0 (
set MonsterName3=Dead
set MonsterHealth3=0
)
)
if /i %Target%==%MonsterName4% (
if %MonsterHealth4% LEQ 0 (
set MonsterName4=Dead
set MonsterHealth4=0
)
)

pause
PING 1.1.1.1 -n 1 -w 1000 >NUL
goto Attack
pause
exit
0 was unexpected at this time
        if       LEQ 0 (


See the blank? %MonsterHealth1% is expanding to nothing because it has no value, (investigate e.g. using echo) which breaks the IF line. The usual way to avoid this is to surround the comparison items with characters such as quotes.

if "%MonsterHealth1%" LEQ "0"


Hmm %MonsterHealth1% was defined in the variables listed at the top though? I cant see anything overwriting that value to blank :S

I cant remember how the error reporting works, but im pretty sure with echo off it only echo's the command if the line works. If that's the case then the next line %MonsterName2% has only been defined as - would this be whats causing it?Ah! *facepalm* your right I didn't define MonsterHealth2, 3 and 4 the quotations worked perfect thanks. Salmon Trout my Hero <3

All fixed now, turns out it was just me having a stupid moment and not adding in the right numbers (1,2,3,4) to the /set MonsterName in lines:
set /a MonsterHealth=%MonsterHealth3%-%dmg%
Thanks again!You have SPENT a lot of time on this. That is commendable. Surely you must also be good at some other programming language. Do you use Vb script?  Do you know Java?

The batch tool of DOS is very old and out of date. Microsoft has, for some time, been urging users to try something else.
What I am saying is this: that your energy and motivation would be more fruitful using anything other than pure batch. Compromise. Don't be a fanatic.

You cam incorporate a better language tool into simple batch files. The CScript.exe tool is a way of having Vb script power in a batch program.

Using the command-based script host (CScript.exe)

The link above provides very complete documentation of how to use the IF statement in the CScript language. With examples.

End of my rant. THANK you.
Thanks, I have done a small amount of Action Script in Flash but not much, and no this is the only language I know. This is only a fraction of the coding I have for the game, why this is just the basic attack sequence for combat, I haven't even got into Spells, advanced attacks, item drops, levels and statistics yet . I have got too far into this to change from batch files now, about 5-6 pages full of code like above hehe.
Although I see lots of people mentioning that batch is out of date I have not yet come across anything that I haven't been able to code, even if it is a less direct route.I am really interested in seeing the final product once completed. This really intrigues my interest Quote from: zeroburn on March 18, 2012, 01:56:37 AM

I am really interested in seeing the final product once completed. This really intrigues my interest

I'm afraid unless I have a team for this PROJECT, that it would take a very LONG time as at the moment I'm doing this in between university work. Appreciate your interest though and if I do ever get around to completing it ill be sure to send you a copy. I'm aiming for this to be a sort of Final fantasy/Diablo 2 game, text based of course .Have you tried a top-down approach?

Like this: Whenever you find some detail you can not handle, you just crate a 'stub' that fakes it. Later, you or someone else can fill in the details.

Kinda like an artist doing a sketch before he brings out the paint. Quote from: Geek-9pm on March 18, 2012, 02:06:52 PM
Have you tried a top-down approach?

Like this: Whenever you find some detail you can not handle, you just crate a 'stub' that fakes it. Later, you or someone else can fill in the details.

Kinda like an artist doing a sketch before he brings out the paint.

Hmm I'm not sure if I would like doing things that way, first off I'm a bit of a perfectionist when it comes to stuff like this and secondly I would have to fix the code at 1 time or another so it seems like I would be just giving myself more work to do, by not only having to scan through the code for 'stub' parts but writing them as well as the correct code later. I can see the reasoning behind that way of doing it though and I'm sure it would have its benefits at some point. Quote from: Risen91 on March 18, 2012, 02:29:16 PM
I'm a bit of a perfectionist when it comes to stuff like this

If you are a perfectionist, why are you writing a batch game? Unless it's an obsessive hobby thing, like making a model of the Taj Mahal out of matchsticks.

Beware. Somebody asked the Duke Of Wellington how he kept beating Napoleon's army, supposedly the best trained and most technically advanced force in Europe at the time. He compared his method of planning and executing a campaign with Napoleon's. He answered something like this: "Compare a miltary plan to a horses harness. Napoleon typical plan is like a very fine hand tooled leather harness, all the pieces very beautifully and precisely made, all fitting together perfectly. It all works well until something snaps and then it is useless. My typical plan is like one made out of assorted bits of string. If a bit breaks I just tie a knot and carry on".
Salmon Trout, great come back! 
Candidate for post of the month.mind = blown
And I started writing this batch game ages back to learn, since then its really just about I already have the code, know it well enough and am having fun with it and I think that's the most important thing, don't want to be learning a language I don't like much (E.g. Actionscript) even if batch is very outdated.The general idea now in computer programming is incremental refinement and crated packages.They call it by various names.

The concept is no avoid looking at a print out that covers the walls of two rooms. The main part of the code describes the logic of the program. Various packages do the hard work and are hidden from view. Until you want to see them.

Just an OBSERVATION.
For further reading:
http://c2.com/cgi/wiki?StructuredProgramming

Quote
"Structured programming" is programming that links control flow blocks (a function, an if statement's block, etc.) to the scopes of variables. A variable declared inside such a block is invisible outside it.
Structured Programming is a foundation of ModularProgramming and ObjectOrientedProgramming, as it's assumed that individual methods are structured (i.e., coded with only #1 to #3 above). (Of course, plenty of people write garbage in ObjectOrientedProgrammingLanguages.) (Yes, but it's structured garbage!) (Not necessarily, but it's encapsulated within the object.)

Three cheers for structured garbage!  you lost me at incremental refinement sorry Just been working on my script and come across something I'm struggling to get working right. basically I need a monster to have a random attack sequence, the variable names are %MonsterName% %Monstername1% and so forth up to 4 (giving a total of 5 in the group)  ill show you what I have been tinkering around with at the moment to see if I can spur any ideas (not that you need them )

Code: [Select]set /a modifier=%random%%%5
if %modifier%==0 (
set MonSeq=""
)
set MonSeq1=%MonsterName%%modifier%
)
:resetmon1
set /a modifier=%random%%%5
set MonSeq2=%MonsterName%%modifier%
if MonSeq2=%MonSeq% (
goto resetmon1
)
if MonSeq2=%MonSeq1% (
goto resetmon1
)
I was going to have it basically "Re-randomising" every time that %MonsterName% number was taken. This seems a really slow and process sapping way of doing it though, I need all 5 in a set order (don't matter if its pre-set or randomises it after the combat script where last monster has taken its hit) any ideas?

Edit: quick change to that script to make it more understandable
769.

Solve : Stuck on batch file creation for user input?

Answer»

I'm trying to make a MS-DOS batch file automatically update the firmware on up to 12 HBA cards. (The site has a closet full of HBA's that need updating and this would speed up the process) I've SUCCESSFULLY completed the part to select which model to upgrade, but it's been too long to remember how to set up the part where the user inputs how many cards are in the system.

In the command line of DOSLPCFG download n=1 i=zd282a4.all The n= is where the card number would be so it would run n=1, then loop to n=2, etc until it reaches the user defined number of cards. Initially I created a var called %HBANUM% and I found the portion of the script regarding this on line, but I am missing something or this is not what I need. Where the (??) is where I need something to specify the input range (Currently in=1 is hardcoded so I COULD work on the portion dealing with card type selection which I am fully aware MAY also be done incorrectly for this type of batch file.)

The CONFIRM section simply runs a command to list the HBA's after everything is complete to confirm all cards are at the same firmware level. This part works fine.


Any assistance would be appreciated, even if just pointing me in the right direction. I can't learn anything if it's all done for me.

Thanks
Joe

REM *****HBA firmware upgrade batch file *****


:BEGIN
cls
echo.
echo.
echo                     EMULEX HBA FIRMWARE UPGRADE UTILITY
echo.
echo        This utility will upgrade the firmware on the Emulex LPE11000
echo           (single port) and LPE11002 (Dual port) PCI-E HBA cards
echo.
echo                 You can upgrade up to 12 HBA's at one time.
echo.
echo              All HBA's MUST be the same type (single or dual)
echo.
echo     Otherwise the upgrade will fail on the cards not specified to be
echo                                 upgraded.
echo.
echo  Select HBA Type:
echo.   
echo  1=LPE11000 (Single Port)
echo  2=LPE11002 (Dual Port)

strings HBATYPE = ASK Model of card to upgrade:

IF %HBATYPE%== 1  GOTO LPE11000
IF %HBATYPE%== 2  GOTO LPE11002
IF %HBATYPE%== "" GOTO ERROR

REM var HBANUM =  ASK How many HBA's are installed?:
REM echo off
REM set HBANUM=0

REM:start
REM if %HBANUM%==  (??) goto CONFIRM
REM echo %HBANUM%
REM set /HBANUM +=1
REM goto start

REM:end


:LPE11000
DOSLPCFG download n=1 i=zd282a4.all

 
:LPE11002
DOSLPCFG download n=1 i=zf282a4.all
pause


:ERROR
echo Invalid entry. Try again
GOTO BEGIN

:CONFIRM
cls
echo.
DOSLPCFG listhba
echo.
echo              Confirm firmware version in all above listed HBA's

:END Code: [Select]:LPE11000
DOSLPCFG download n=1 i=zd282a4.all

:LPE11002
DOSLPCFG download n=1 i=zf282a4.all
pause
you do realize this will run both LPE11000 and Code: [Select] LPE11002 if you HBATYPE=1? you need a GOTO after Code: [Select]DOSLPCFG download n=1 i=izd282a4.all (I think, though I've never run across this command)


Code: [Select]REM if %HBANUM% GTR 2 goto CONFIRM
REM echo %HBANUM%
REM set /a HBANUM +=1
edited
Code: [Select] set /HBANUM +=1 to
Code: [Select] set /a HBANUM +=1you forgot the /a part to make it an equation


edited
Code: [Select] if %HBANUM%== (??) to
Code: [Select]if %HBANUM% GTR 2of you could also use
Code: [Select]if "%HBANUM%" =="3"but this is less accurate.


Code: [Select]strings HBATYPE = ASK Model of card to upgrade:did you mean set /p HBATYPE =Model of cards to upgrade: ?
'strings' came up as an error when I tried it in cmd.

Hoped this helped!

770.

Solve : Windows Setup batch file?

Answer»

When I set up a new computer, I use both batch files and registry scripts to either add to, subtract from or modify things in Windows and in its registry.

Without getting too DETAILED, I have tried to run a .reg script at the end of a batch file and find that the .reg script never runs, even if I preface it with 'Call'. 

Is this even possible?  Likewise combining a VBScript and a batch file together.  Possible?

thanks in advance,
  Quote

Without getting too detailed, I have tried to run a .reg script at the end of a batch file and find that the .reg script never runs, even if I preface it with 'Call'.

Actually getting too detailed is exactly what's called for here.Please show us the code so we can all understand what is going on.

Quote
Is this even possible?  Likewise combining a VBScript and a batch file together.  Possible?

If you don't supply the parent PROCESS (ie: regedit for .reg files or cscript for .vbs files) then the file association is used.

A VBScript can run a batch file via the Run method. A batch file can run a VBScript the same as any other NT command. If you mean combining both languages in a single file, YES it can be done by writing one of those god-awful hybrid scripts

 Thank you.

Ok, a typical batch file + registry script would go something like this:

Echo off
cls
del /F /S /W "C:\temp\*.*"
Rem Put more lines here to CLEAN out more junk.

GrantAdminFullControl.reg


It's just that simple.
I can run a .exe file, or a .com file, or even another .bat file on that last line and they all run OK,
but NOT a .reg file. 
So I guess I'm asking if anyone knows why it won't run and if there is anything I can do to MAKE it run?

If not, it ain't no big deal.  I can always do what I've been doing for years, first running all my batch files, then run my registry scripts and then run my VBScripts. 

Thanks again,
The Shadow 

PS:  I came here, to this forum, because I've received some great help here in the past.I can't duplicate your problem. Nothing seems particularly wrong but it may be the .reg association is not set. Did you get any runtime errors?

You might try this:

Code: [Select]Echo off
cls
del /F /S /W "C:\temp\*.*"
Rem Put more lines here to clean out more junk.

cscript //nologo myVBScript.vbs
regedit GrantAdminFullControl.reg

The call statement is only valid for calling batch files and determines whether the called file returns control to the caller or not. Other executable files should always return control to the caller.

With any luck, this may help.

Quote from: Sidewinder on March 18, 2012, 12:50:56 PM
The call statement is only valid for calling batch files and determines whether the called file returns control to the caller or not. Other executable files should always return control to the caller.

You can use the call command for any file that is either executable or has an association.



Whew!  It's been a long day, after a night of St Patrick's Day FESTIVITIES, but with way more Googling than I really wanted to do, I finally just did a search for "Batch File Commands".

When I learned DOS and batch file programming back in the early 80's, there were not so many batch file commands available.

I was both surprised and pleased to find the "Start" command.
All I had to do is precede the name of my registry script with the command "Start" like this:

Rem  The following line runs the registry script RegTweaks.reg
START RegTweaks.reg


There are, of course, a bunch of switches that can be used by that command, but they are not necessary for my purpose.

As was mentioned, "Call" is primarily for running one batch file from within another batch file.

Thank you all again, for your efforts.
The Shadow
771.

Solve : For /f Tokens?

Answer»

I was reading through one of the questions posted here, and geek's response to it, and it got me thinking. He said you can read at most 52 (he also said it could be 62 or more) variables from a file. Through my really quick and dirty research, I discovered that the number is actually 69 (both alphabet cases, numberic, and 7 mysterious variables). However, I found that the maximum number of tokens you can USE in one for command is 31 (trial and error, any more and the command refuses to run but doesn't give an error).
The code I tested with
Code: [Select]echo off
mode con cols=200
setlocal enabledelayedexpansion
for /l %%A in (10,10,620) do set var=!var!%%A
echo %var% > test.txt
for /f "tokens=1-31" %%0 in (test.txt) do echo %%0 %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 %%A %%B %%C %%D %%E %%F %%G %%H %%I %%J %%K %%L %%M %%N %%O %%P %%Q %%R %%S %%T %%U %%V %%W %%X %%Y %%Z %%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o %%p %%q %%r %%s %%t %%u %%v %%w %%x %%y %%z
pause
As you can see if you run it, the variables 0-9 and A-N expand (10-100 and 180-310, respectively), but there is a 7-variable gap between 9 and A. Does anyone have an idea what would be in that 7-variable gap? It's not numbers >=10.Weird how I can't edit. Oh well. I just discovered something relevant while explaining this to another user on a different forum. There's also a 6-variable gap in the rollover between Z and a. So it works out like this:
0-9 >>> x 7 >>> A-Z >>> x 7 >>> a-z

There could also be something after z, but I have no way of testing this. So, instead of 69 variables, we're dealing with something greater or equal to 75. Quote from: Helpmeh on March 18, 2012, 12:06:26 AM

There could also be something after z, but I have no way of testing this.

You do have a way to check the "gaps". You have the prompt. You can do it manually or you could write something such as a vbscript that goes through the whole ascii table and CREATES, and shells out to, a command line like below, recording which ones work and which don't. (There are threads in the Google Groups archive of alt.msdos.batch.nt which touch on this topic)

C:\>for %{ in (*.txt) do echo %{
01.txt
1-sfc-problems.txt
1-sfcdetails.txt
1.txt
2.txt
3.txt
hello.txt

C:\>for %| in (*.txt) do echo %|
% was unexpected at this time.

C:\>for %~ in (*.txt) do echo %~
01.txt
1-sfc-problems.txt
1-sfcdetails.txt
1.txt
2.txt
3.txt
hello.txt


You have two issues here, I think:

First, what characters can be used as FOR metavariables (answer: practically every printable character which does not have a special meaning [e.g. % ! < > etc])

Quote
there is a 7-variable gap between 9 and A. Does anyone have an idea what would be in that 7-variable gap? It's not numbers >=10.

You will see the answer to this when you look at an ASCII chart.

Second the maximum number of tokens possible in a FOR construct; clearly this requires an unbroken consecutive run of valid variable characters and this has been well established to be from ASCII 63 '?' to ASCII 93 ']'



Quote from: Salmon Trout on March 18, 2012, 01:54:17 AM
what characters can be used as FOR metavariables (answer: practically every printable character which does not have a special meaning [e.g. % ! < > etc])

You will see the answer to this when you look at an ASCII chart.

I tested 1 to 255 and these failed, so, at a first glance, maybe you could use some non-printables, although you might have to use tricks to get them in a script.

ASCII   9
ASCII  10
ASCII  11
ASCII  12
ASCII  13
ASCII  32
ASCII  34 "
ASCII  37 %
ASCII  38 &
ASCII  44 ,
ASCII  59 ;
ASCII  60 <
ASCII  61 =
ASCII  62 >
ASCII  94 ^
ASCII 124 |
ASCII 160 á


You can do this

for /f "tokens=1-2" %} in ("a b") do echo %} %~

but not above ASCII 127 (the first token works, not the later ones)

but this works (☺ is ASCII 1 and ☻ is ASCII 2) (you type them by holding down ALT and typing the number on the keypad)

for /f "tokens=1-2" %☺ in ("a b") do echo %☺ %☻


This that I wrote above obviously only applies to one loop; by nesting you can get more simultaneously existing FOR variables.

Quote from: Me
the maximum number of tokens possible in a FOR construct; clearly this requires an unbroken consecutive run of valid variable characters and this has been well established to be from ASCII 63 '?' to ASCII 93 ']'

Quote from: Helpmeh
we're dealing with something greater or equal to 75.

I managed 81 so far, and I believe I could squeeze a few more out.

The essential point is that the command interpreter sees the variable character as an ASCII code, and it is quite happy, with the exceptions already noted, to deal with the codes that aren't letters of the alphabet or numbers, including ones that don't correspond to keys on the keyboard. I imagine that when they wrote the documentation they deliberately kept it simple and only mentioned A-Z and a-z and that's where the figure of 52 comes from.

echo off
set String1="v1 v2 V3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 v18 v19 v20 v21 v22 v23 v24 v25 v26 v27 v28 v29 v30 v31"
set String2="v32 v33 v34 v35 v36 v37 v38 v39 v40 v41 v42 v43 v44 v45 v46 v47 v48 v49 v50 v51 v52 v53 v54 v55 v56 v57 v58 v59 v60"
Set String3="v61 v62 v63 v64 v65 v66 v67 v68 v69 v70 v71 v72 v73"
Set String4="v74 v75 v76 v77 v78 v79 v80 v81"
FOR /F "tokens=1-31" %%? in (%String1%) do (
        FOR /F "tokens=1-29" %%_ in (%String2%) do (
                FOR /F "tokens=1-14" %%- in (%String3%) do (
                        REM ASCII 1 to 8 [Won't display in CH]
                        FOR /F "tokens=1-8" %% in (%String4%) do (
                                Echo %%? %% %%A %%B %%C %%D %%E %%F %%G %%H %%I %%J %%K %%L %%M %%N %%O %%P %%Q %%R %%S %%T %%U %%V %%W %%X %%Y %%Z %%[ %%\ %%]
                                Echo %%_ %%` %%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o %%p %%q %%r %%s %%t %%u %%v %%w %%x %%y %%z %%{
                                Echo %%- %%. %%/ %%0 %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 %%:
                                Echo %% %% %% %% %% %% %% %%
                                )
               
                        )
                )
        )



Output:

v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 v18 v19 v20 v21 v22 v23 v24 v25 v26 v27 v28 v29 v30 v31
v32 v33 v34 v35 v36 v37 v38 v39 v40 v41 v42 v43 v44 v45 v46 v47 v48 v49 v50 v51 v52 v53 v54 v55 v56 v57 v58 v59 v60
v61 v62 v63 v64 v65 v66 v67 v68 v69 v70 v71 v72 v73
v74 v75 v76 v77 v78 v79 v80 v81
Quote from: Helpmeh on March 18, 2012, 12:06:26 AM
Weird how I can't edit.

You get 1 hour from the time of posting, I believe.
Quote
FOR /F "tokens=1-14" %%- in (%String3%) do (

The above works, but for the sake of accuracy this should be

FOR /F "tokens=1-13" %%- in (%String3%) do (
772.

Solve : Simple Batch File Help!?

Answer»

Hi..   I've created 2 simple batch files that start and stop "windows audio" service  (as I often need to stop/start it when I'm working with MUSIC and using different drivers)

So far im just using net start/stop "windows audio"

However I was wondering if I could ACHIEVE the same THING just using 1 batch file that uses a conditional statement that effectively turns in on and off i.e

//=============================
If (Windows Audio Service = running)

     net stop "Windows Audio"

Else{
    net start "Windows Audio"
}
//=============================

Is it possible to create a batch file that acts as a switch to turn the service on and off?
Any help is much appreciated.  Code: [Select]echo off
set status=not running
sc query type= service | FIND "AudioSrv" > nul && set status=running
echo The Windows Audio Service is %status%.
if "%status%"=="running" (
net stop "Windows Audio"
) else (
net start "Windows Audio"
)
pause

Output:

Code: [Select]C:\Batch\Test>SwitchWindowsAudioService.bat
The Windows Audio Service is running.
The Windows Audio service is stopping.
The Windows Audio service was stopped successfully.

Press any key to CONTINUE . . .

[64]C:\Batch\Test>SwitchWindowsAudioService.bat
The Windows Audio Service is not running.
The Windows Audio service is starting.
The Windows Audio service was started successfully.

Press any key to continue . . .

[64]C:\Batch\Test>

Quote from: Salmon Trout on March 17, 2012, 02:32:17 AM

Code: [Select]echo off
set status=not running
sc query type= service | find "AudioSrv" > nul && set status=running
echo The Windows Audio Service is %status%.
if "%status%"=="running" (
   net stop "Windows Audio"
) else (
   net start "Windows Audio"
)
pause

Output:

Code: [Select]C:\Batch\Test>SwitchWindowsAudioService.bat
The Windows Audio Service is running.
The Windows Audio service is stopping.
The Windows Audio service was stopped successfully.

Press any key to continue . . .

[64]C:\Batch\Test>SwitchWindowsAudioService.bat
The Windows Audio Service is not running.
The Windows Audio service is starting.
The Windows Audio service was started successfully.

Press any key to continue . . .

[64]C:\Batch\Test>

Fantastic!  Thank you very much for the speedy response, you have made things a lot easier and cleaner for me.
773.

Solve : Getting input from a user in a batch file?

Answer»

I'm writing a simple XCOPY batch file and I want the user to input a directory name.  I've seen this done quite some time ago (pre Win 95) but just can't remember how it was done.  The input would have to RESIDE in a variable within the program.

Anyone got an idea?  THANKS in advance,

Paul.
I always used one of the many batch enhancers in the old bare DOS days.  Nowadays, I use AutoIt http://www.autoitscript.com/autoit3/ for this kind of task.  For a bunch of old-style DOS utilities, try http://garbo.uwasa.fi/pc/ Quote

I always used one of the many batch enhancers in the old bare DOS days.  Nowadays, I use AutoIt http://www.autoitscript.com/autoit3/ for this kind of task.  For a bunch of old-style DOS utilities, try http://garbo.uwasa.fi/pc/


Many thanks, John.  I think it was the ask utility that I had seen used before.  I'll CHECK out the autoit tools too - I hadn't HEARD of this before.

Paul.
774.

Solve : Suppress file name extensions -- MS DOS?

Answer»

Hi,

I have a directory in which i will get one zip file every day. It can be any type of the zip file and I don't know the name of the file (i.e., the file name varies every day). But i will know what type of the zip file it is (for ex, *.zip, *.bz2, *.7Z ETC).

on getting this zip file, I have to load the name of this zip file into a separate file and i have to create a new directory with this name (with no extension).

I have used one simple command "dir /B *.zip > dir_file.txt". But this is giving the file name with extensions. IF any one gives me any addition to this command it will solve my problem.

Or you can give me ENTIRE new command to do this task. Can ANYONE help me how to do this in DOS?I am presuming that you don't really mean "MS-DOS" but rather Windows NT family command language (Windows 2000 and later).

At the prompt:

for %A in (*.zip) do echo %~nA > dir_file.txt

In a batch file:

for %%A in (*.zip) do echo %%~nA > dir_file.txt

Hi Salmon,

Your presumption is right.  i meant that only.
and your logic is also USEFUL for me. Thanks for the help.

775.

Solve : Telxon running Dos 3.21?

Answer»

Hello.  My company is using Telxon PTC-710s running Dos 3.21 with a proprietary clipper ORDER entry program.  

Anyway, one of our users wants the volume increased, so that when she scans an item, she can HEAR the little click beep sound.  

I know its possible to change the speaker volume on this thing... we were able to do it in a previous version of the software... I was just wondering if there was a DOS command that could do this POSSIBLY, or if it was purely a clipper function.  Unfortunately, the person who wrote this software left a few years ago, so I'm left trying to support these things not knowing anything  

Thanks for your help.

FredThe PC Speaker offers no support of volume control in DOS and minimal (PCSpeaker WAV Player) in Windows. Get small 3 or 4 cell audio amplifiers that you can get away with running on the system 5v bus (or 12v bus if they're 8 cell amps) and connect them to the PC speaker output and add a volume control. You can EITHER get these as little add-on amps for Walkman/Discman portable players, or as IC projects from Radio Shark or similar ELECTRONICS stores.

776.

Solve : Concatenate two variables?

Answer»

Hi,
    I have a variable predefined, let's call it Apples.  I want to move all files with this as the prefix followed by _TEST followed by anything and then .zip to a differnt DIRECTORY i.e.

IF EXIST %Apples%_TEST*.zip MOVE %Apples%_TEST*.zip .\Zipped

It's not WORKING, how do I do this?

Thanks.

Raymondyou may find the answer here>http://home7.inet.tele.dk/batfiles/Thanks, since you sound confident of where to find it, wanna give me a TIP as to what to search for on the webpage?  I.e. "variable"?

Thanks.Looks like you need to put the filespecs in quotes.

IF EXIST "%Apples%_TEST*.zip" MOVE "%Apples%_TEST*.zip" .\Zipped

This will force recognition of long file NAMES.

777.

Solve : Extending DOS beyond the 640K limit?

Answer»

[glb]PLEASE HELP !!!![/glb]

I am trying to put a TCP/IP stack on a DOS 6.22 PC. at the moment it uses NetBEUI.

If I change the network card to use TCP/IP then I run out of memory, so what I am looking for is a program that will let me use the other 63MB that are available on the P3 1Ghz PC.

Any help would be much appreciated.

Many thanks
Bigfooters
Unless you're using a CGA or Hercules card, your main program RAM is limitted to 640K.

You can move stuff out of there. First, get acquainted with MSD, the Microsoft System Diagnostics tool, included with DOS 6 and later. It includes a decent memory viewer.

You can use devicehigh in config.sys and loadhigh or lh in autoexec.bat to move things from the 0 to 640K RAM range.

config.sys example:

device-c:\dos\himem.sys /v
dos=high,umb
device=emm386.exe noems

files=25
buffers=24
stacks=9,256
fcbs=10,6
lastdrive=z

devicehigh=c:\dos\setver.exe
devicehigh=c:\cdrom\oakcdrom.sys /d:cd01
devicehigh=c:\network\smc4dos.sys /dev:eth0
devicehigh=c:\network\win3tcp.sys /eth0
devicehigh=c:\audio\sndcard.sys /a:220 /m:330 /i:5 /j:201


Sample autoexec.bat:

echo off
path ;
c:\fprot\bootscan /root /autofix
lh c:\video\et4kdos.com
lh c:\fprot\rscan
lh c:\mouse\mouse.com
lh c:\cdrom\mscdex.exe /d:cd01 /m:12
set netpath=c:\network\temp
lh c:\network\winsock.com
set blaster=a:220 m:330 i:5 j:201 t:4
lh c:\audio\arack.com /blaster
path c:\dos;c:\windows;c:\;c:\fprot;c:\network;
prompt $p$g
if exist c:\temp\nul: deltree c:\temp
md c:\temp
set temp=c:\temp
ver


These samples may not contain your driver versions. If you use something based on these, use MSD to verify that most or all of your resident files are loaded out of your 640K workspace.

You can then use MEMMAKER to gain even higher EFFICIENCY by fine-tuning the BOOT sequence to put as many of your files high as possible. LOAD order is significant.

I include the trick of not setting unnecessary environment variables (I even ditch the default PATH) until they are needed. Each resident program includes a copy of the then-current environment when it loads. Shaving off the environment saves space. This file set also clears the TEMP directory automatically on startup.I am trying to get TCP/IP working on a dos 6.33 boot floppy disk. It keeps saying that I am out of memory. Is there a way of not loading DNR, as these is where I have the problem.

Many thanks for any help in ADVANCE

BigfootersDNR? Unfamiliar. In the sample files, the network card, sound card, and video card drivers are loaded 'high' to get them out of the lower 640K RAM.

You may want to use a router to provide DHCP, DNS, and NAT services to your system and firmware firewall services to discourage hackers and malware.

778.

Solve : Way to Tell if Parameters exist or not??

Answer»

Hello All,

I'm trying to create a batch FILE that accepts a parameter
but if the parameter does not exist I want
to echo to the user that they need to provide the
parameter.. Otherwise I want to use the parameter.

Is there a WAY to know if the user has entered a parameter.  

I've tried %1==NUL, %1=="" and NOT EXIST %1 all
to no eval...  
I'm pretty SURE you can do this, but OBVIOUSLY I just don't know how.

Any assistance greatly APPRECIATED.

ThanksIf you use the form:

IF X%1 == X GOTO NOPARM

... it will take the branch if there is no parameter present.

Thanks a bunch..

779.

Solve : How to separate a long command to two lines?

Answer»

Hi,

I have a very long command in a batch file, but I don't want to type it in one line. How can I separate it as two lines but still get executed as one command?

Thanks,
sg  :-/Use (hold down the ctrl key and press j) at the point where you want to line to break. Then continue typing the command where you left off. This tells DOS that what follows on the next line is part of the same command. If type the command in a DOS window, you will see that the cursor returns to the home position, but without the normal prompt.I am using Windows XP PRO and I was not ABLE to make the ctrl+j work.  Is there a anternative method for entering long command lines?  What is the MAXIMUM LENGTH of a command line?

Thanks in advance.Hi,

It seems doesn't work. The second line is ALWAYS executed as another command. Please note this is not a dos command.

Thanks.The command line maximum length is a little short of 256 characters, including the prompt, and if you just type in your string it should automatically line feed when you reach the end of the 80 character line. You should be able to fill 3 lines with text (240 characters) before DOS truncates the string when you push ENTER.

CTRL J is not a valid character in a batch string.

780.

Solve : Maintaining a prompt window open?

Answer» HI all.

Is it possible to maintain a prompt window opened after executing some COMMANDS from a batch file? I just want to EXEC ipconfig and then keep the window open so I can copy de ip address.

Thanks for the helpOpen command from the "Run" box, then type ipconfig. It stays open until you close it.That's what i USUALLY do...

I want to run the command from a .bat... i'm lazy

Thanks for the HELP anywayIPCONFIG /ALL
PAUSE
Thanks!!!  

That's exactly what i wanted!
781.

Solve : Answer in Batch -NET USE?

Answer»

Any IDEAS on SENDING a blank answer for a username in a batch file? Is there a command to send the answer as "enter"?

Windows XP.

Here is a LINE from the batch file:
net use F: \\Telserv\H  \username:testuser  \password:(There is no password)How about :

echo.|net use F: \\Telserv\H  \username:testuser  \password
Thanks for trying, but it still GIVES me the syntax help screen when I run it. I need to somehow fill that password field with "enter." It works manually so there must be a way to do it with code.Okay thanks JOHN. You led me to it. Here it is...
net use G: \\Telserv\D  
testuser
Echo.    

Basically answering the prompts rather than putting them in with answers. Appreciate your help.

We'll count this as a win.

782.

Solve : Internet Relay Chat on DOS?

Answer»

There is a way to start an IRC chat on DOS with the PERSONS IP ADDRESS.  Would anyone happen to know the command text?

If so can you please E-mail them to me at [email protected] or just MESSAGE my AIM at Cousin Gnome. Thank you

783.

Solve : file renaming?

Answer»

Hi, i want to know how i can rename alot of files without giving the previous name, here is what i want to do:

there is a folder called "mp3", and the user must PUT 50 .mp3 files in it, and a batch file must name the 1, 2, 3... 50, but i don't know what the names of  the .mp3 files, can this be DONE with a batch file?

thx in advancewhat like guns*ROSES track one.....you may find software out there to do this ....batch files to me old HAT...why waste time messing with them...when a readymade soultion can be FOUND..are we still playing with  the amiga...1200..or mac 7180 or i3862 bad, i was going to put all that in one simple batch file
but i think im going to serach for some software that does that, or the user must go and rename all those files  http://www.collectorz.com/mp3/THX!

784.

Solve : Partition and format...help...?

Answer»

I need to write a batch file that partitions and then FORMATS my drives with out any user INTERACTION when I start up the COMPUTER....

I'm a newbie at this, so bare with me...This is what I got so far...

I'm GOING to put this into my autoexec.bat file on the boot floppy:

fdisk 1/pri: 1000
fdisk 1/ext: 2000
fdisk 1/log: 300
format C: /y
Format D: /y
Format E: /y


Could SOMEONE help me and tell me if that would be the most efficent way of doing it or is there a better, or easier way...It has to be without any user interaction though...http://home7.inet.tele.dk/batfiles/

785.

Solve : shortcut keys - help!!!!!?

Answer»

I am using an international KEYBOARD and am having a hard time remembering my English, much less which keys are referred to with "CTRL+BREAK" Can someone please HELP me. I WOULD appreciate it very much! Ctrl is the control key, usually two of them below the shift keys.  Break is on the Pause key, upper right on my keyboard.  Ctrl-Brk would be holding Ctrl and pressing the Break key.
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q301583 and this>http://support.microsoft.com/default.aspx?scid=kb;en-us;q126449

786.

Solve : Creating a blank file?

Answer»

I am looking for a way to create a blank file in dos using a batch file.

What I mean is there is an existing file called FileA.dbf and I want to delete the existing file and replace it with a new file called FileA.dbf, but with nothing in it.  I thought of using edit FileA.dbf, but is there a SWITCH to close the edit WINDOW?

Thanks for any insight you might have on this.
here is a solution that you might find helpful, i'll assume that you're working with text files but in my experience, it WORKS with other file formats a well


create a blank txt file called "test.txt"

create a batch file with this line in it
"type test.txt > FileA.txt"

every TIME this batch file is run, it overwrites FileA with the contents of test.txt which happens to be blank.Well, it's easy to get close, this CREATES a file with a space and a C/R-L/F pair.

echo. >file.txt
Thanks for the help.  Both work great.

787.

Solve : alonso109?

Answer» some BODY how I can SHUTDOWN a service (process) from windows 2000 with a batch FILE?

Thank you for your TIME and help.


Try PSKILL from http://www.sysinternals.com/ntw2k/freeware/pstools.shtmlThanks a lot !!
788.

Solve : bios guardian?

Answer» SOMEBODY HELP ! When I go into my bios,I keep GETTING a page says that I can't change any bios settings until I disable the bios guardian. How do I disable it ? Thanks.what mobo is this...i GUESS you are trying to flash your bios...
789.

Solve : writing batch file?

Answer»

Hi all,

I want to write a batch file, my requirement is like this,
it should 1st ping the REMOTE machine, if its reachable
then only it'll make the ftp connection with the same machine & do some opreation.
If it fails to ping then STOP executing the rest of the batch script & send a MAIL about the lost of connectivity.

Thanks in advance!
EARLY RESPONSE will be highly appreciated

790.

Solve : windows dosnt start?

Answer» OK i have an old 92 gateway with wut i think is the old version of ms dos n E ways..i was deleting some stuff on it and i think i deleted the wrong thing it was "microsoft publisher" and after i deleted all the files it asked me to restart so i did. when i did windows didnt start so i used my boot disk and it didnt help at all windows still didnt start so i came on this site and i looked for some things and i tryed them like the undelete thng it says that it was a bad command or something like that and so i tryed the GUI=1 thing and it went to te windows 98 loading screen but then it just gos back to the boot disk thing( when i took it out and restarted the comp it dosnt do a thing) it gose to an options screen with the safe mode on it and it says to use the command prompt option and use "scanreg" so i did and it dosent do n e thing and if i use safe mode or normal it gose to the windows 98 loading screen for about 5 mins then it gose back into the ms dos with a message "invalid media type drive C: abort retry,fail" every time. i want to ERASE every thing on my computer and reinstall windows with a fresh start but i dont know how and i dont know if im using the undelete thing right. if u can will u plz help out a guy in needok win98 boot disk load it restart-pc on the a:\ cd windows enter this will take you to c:\>type this command scanreg/restore and chose the last good cab file...try it.i have a dell with HOME xp on it...whenever i turn it on it loads microsoft and restarts..i will put the xp disc in and like he said it willl take me to a safe mode screen and i TRIED all options for it but it didnt work
it stopped working when we downloaded some windows updates and it sed to restart for them to work
help me
every time i try and do something like ur suggestion it always says "invalid media type reading drive C" dose this mean i dont have drive C? plz help
791.

Solve : Getting out of MS-DOS Mode???

Answer»

Okay I dont know if this belongs here or not, but here it is. I have Windows 95 or 98, I dont know which one. But I restarted me computer in MS-DOS Mode, and now I cant get out! Someone said to type exit and press enter, I did, but it just restarts and comes back up in MS-DOS. Anyone know whats going on here? 

Hi,

When PC is restarting press the F8 key constantly as it boots up - before it says "starting windows". This will GIVE you a choice of modes to boot into. Select either safe mode if you still have a problem, or normal mode if you want to get back to normal.

Remember, before you do the crime, think about the time.

Oscar  I dont really know what you mean about a crime?but thanks, ill TRY it.No, it only let me log in under safe mode, there were all these other options but I dont know what they are. I tried normal, and it took me right back?Just for laughs, type WIN at the DOS prompt and see if it fires up Windows.

If so, I suspect that the MSDOS.SYS file has GUI=0 instead of GUI=1 in it, change that and the SYSTEM will run as before.  I believe MSCONFIG will allow you to change this parameter, but I don't have a W98 system to CHECK...
When I do that it says that I am currently running in MS-DOS mode, and if I want to run in normal to press enter. Well I did, and it just restarts again and it is still in MS-DOS mode. I don't know whats going on. Am I going to have to take it to a shop and pay a ridicules amout of money?At the DOS prompt type scanreg /restore. A list of items should appear. Use the arrow keys on the keyboard to MOVE the highlighted item. Select the one with the oldest date and press enter.If you are in a root MSDOS shell in Win9x, typing WIN at the dos prompt will start Windows.

If you have a DOS shell session open in Windows (applies to the emulator in NT/XP as well as a DOS session in Win9x), you type EXIT to close the DOS shell and return to Windows.I tried typing WIN and Exit, it just re-starts the computer and brings MS-DOS mode back up.Are you 100% sure that windows is installed?  Type "dir c:" at the command prompt.

792.

Solve : .bat send file?

Answer»

How can i send a file with .bat to other comp moast easy copy test.txt \\standby\c\test.txt

This command just copied the TEST.TXT file from my local machine's current directory to my machine named STANDBY, the shared drive C, and named it test.txt there too.

Just like a local copy with network path as the destination.but cant you just send it like e-mail to ip? :-/how can i copy 2 txt's in to one? with  batch?and how can i USE choice?? How about you state your PROBLEM FULLY and in complete sentences.  It's pretty hard to offer a solution without knowing what the real problem is.   Quote

how can i copy 2 txt's in to one? with  batch?

copy file1+file2
Can be run from the command line or a batch file
Quote
and how can i use choice??

Choicei've got lots of problems, choise doesnt seem to work on xp, and "can not FIND file C:\text.txt+C:\text2.txt"How can i send a file with .bat to other comp moast easy?
- i would recommend ftp or if you're on a network, put it on a share drive(either one can be done throught batch files

how can i copy 2 txt's in to one? with  batch?
-easy, create a batch file and put this command in it
"type test.txt >> test2.txt"
every time the batch file is run,  the contents of test.txt are added to test2.txt



793.

Solve : removing partition(s) with FDisk?

Answer»

I am running windows 3.1 and more by (bad) LUCK than by good MANAGEMENT, my hard drive was partitioned.

If I remove a Extended partition and Logical DOS Drive will I still retain my Primary and all the info and OS there?

Display Partion Information screen shows:
                C:  1  A  PRI  DOS   FAT 16 43%       and:
                     2      EXT  DOS               43% .

Total disk space is 4777 Mbytes.

Or will all Hard drive info be wiped out?

I have no need for any partitions and I plan on installing windows 95.Removing the extended partion won't affect the primary partition.

794.

Solve : Logon batch script trouble?

Answer»

Hey all

I'm creating a logon script for a small NETWORK of about 30 PCs, some Windows 98SE, some XP Pro. The login script currently synchronises the computers clock with the server, and maps some standard network drives.

However, for certain usernames I want to map some extra drives. In the script I'm USING the putinenv utility to get the username and then performing an if to check the username, like this:

Code: [Select]\\Server\netlogon\putinenv L /l

if "%username%"=="testuser" goto mapextra

This works fine on the 98 MACHINES as the putinenv utility returns the username in lower case - so my test works fine. However on the XP machines, the username environment variable is KEPT in the case that the user entered at the login screen, which could be TESTUSER, TestUser, TEstuSEr etc etc.

This causes the if to fail, as it is not an exact match - is there any way to ignore case in the if, or to force the XP username environment variable into small case? Or any other ways around this?

THANKS in advance

Andy W

795.

Solve : how to automate saving file with batch??

Answer»

Can any body please help? does any body have  batch file which can automate the saving of a file to a SERVER .It will need to run every night at a set time?  http://www.iopus.com/guides/batch.htmKirbyFooty distributes a freeware WINDOWS cron utility KirbyAlarm which will do this - and will even do it when the machine next STARTS up if it was off when the backup would normally be done. You can have KirbyAlarm EITHER copy the file directly to the backup location or access a batch file to do it.

Otherwise, you will need an MSDOS utility that emulates UNIX cron to act as a timer and START the batch file.should be fairly easy, you can use windows task scheduler to do this or the AT command to set it on a timer.

796.

Solve : Batch file hangs if I don't specify output file?

Answer»

I have a batch file which runs from a JAVA UI. The batch file calls various commands. I get to a certain point and run the FOLLOWING command (a DB2 command):

asnclp -f %IWDA_DIR%\tmp\rep.sql >> %IWDA_DIR%\log\rep.log

This runs fine, however, I want to REMOVE the >> $IWDA_DIR\log\rep.log part since this command outputs plain text passwords.  When I remove that part, giving:

asnclp -f %IWDA_DIR%\tmp\rep.sql

The batch file just hangs at this point.  When I KILL the JAVA UI which is calling this batch file, it finishes.  Any idea why specify the output makes the DIFFERENCE and how I can OVERCOME this problem?
www-306.ibm.com/software/data/dpropr/db2cp.pdf -

797.

Solve : format the hard drive??

Answer»

I'm unable to format my hard drive. A MSG comes up saying that my volume NEEDS to be DISMOUNTED first, but when I try...it's unable to LOCK the drive. Is there a command I can use to fix this???You can't format the boot drive while you're running off of it!  Boot from a FLOPPY, then you can format the hard disk, if that's what you're trying to do.

798.

Solve : backup 1x per day with XCOPY?

Answer»

Hi there...

I use XCOPY to do a backup of certain files every time my PC loads up automatically.

Is there a command I can add within my editor for XCOPY to do the backup only once per day (by checking last date executed), so that it checks if a backup has already been installed on that date / day?You would need to recreate a file in the backup directory (like flag.dat) every time you actually back up, and check the date of that file with a batch SCRIPT that runs the backup. An if-then loop checks the flag.dat creation date against the current date, and if they don't match it does the backup copy, then deletes flag.dat and creates a new flag.dat to update the date mark. Otherwise it skips the backup.Sounds like he is running the command from autoexec.bat. The easy way would be to create a seperate batch file to run the command and then use task scheduler to run the batch file at a predetermined time.'Task Scheduler' is lame. If your machine is not on when the event is scheduled, it won't execute.

A better cron utility is Kirby Alarm. This will check itself on startup and do things that were scheduled since the previous shutdown, and seems to be LESS of a resource hog than Task Scheduler. Freeware at www.kirbyfooty.com, I think that link is right.Since this is the DOS forum, if he's really running DOS, neither of these solutions will do the trick.  There are tons of old MS-DOS utilities that will allow you to check the DATES, the trick nowadays will probably be finding them.  Most of these utilities are 10 years or more old, and getting a little dusty.  For instance, here's the help screens from a little utility I've used for years, note it has several date manipulation features.


GET Version 2.6a  -   BATch File Enhancer   -   Copyright 1994 Bob Stephan
 Syntax:  GET command argument(s) /switches     More Instructions: GET.DOC
Purpose          Command Argument(s) Switches Environment ErrorLevel Extended
---------        ------- ----------- ---[/]-- --(GET=)--- --(Exit)-- --[E]---
         --------- STRING Handling and Screen I/O Commands --------
Echo             EC   "prompt"            AN   --         --          --
Get character    C[E]["prompt"][chars]    All  ASCII Char ASCII code No Echo
aNswer yes or no N[E]["prompt"][seconds]  All  ASCII Char ASCII code No Echo
Get string       S[E]["prompt"][pattern]  All  String     Length     No Echo
Put string (Zap) Z[E]["string/prompt"]    All  String     Length     StdInput
In String        #[E] "string" ['arg']    MVWX Position in string    Extract
Moving Text      T[E] "filespec" [chars]  All  ASCII Char ASCII code No Echo
Key waiting      I[E]["prompt"]           All  --Character Waiting-- Get Char
Keyboard bUffer  U[E]["chars"][num][/Wnum]MVW  [E]Locks   Length     Caps/Num
            For UE: 16=Scroll Lock, 32=Num Lock, 64=Caps Lock
'Rithmetic       R ["+-*/!="] num [/Wnum] MVWA Result     Result
Blank Screen     B[E] [New attribute]     MV   --Old attribute--     HexAttr
Video mode/bordr V[E] [New mode/color]    MV   --Old mode/color--    VGA Border
Date and Time    H[E] ["prompt"] code     All  String    Value      CatSum
 codes: 1=DoW 2=DoM 4=Mon 8=Yr 16=Hr 32=Min 64=Sec 128=odd/even 256=100ths
         --------- Disk and File Commands --------
File size[date/E]F[E] filespec[/Wdiv/X/A] MVXWA Bytes/Hex Kilobytes  Kb/10
    /W date/time codes for /E: 2=DoM 4=Mon 8=Yr 16=Hr 32=Min
Disk free space  K[E] [drive] [/Wdiv]     MVW  Kilobytes  Kb/10      Kb/100
Disk capacity    Q[E] [drive] [/Wdiv]     MVW  Kilobytes  Kb/10      Kb/100
Volume label     L[E] ["label"][drive]    MVUL Label      1=yes,0=no Match
Current dir      Y[E] [drive for Y]       MVL  Directory Level/Drive Drive:A=0
         --------- Memory and System Commands --------
Environment left E[E]                     MVX  Bytes left Bytes left Bytes/10
Memory free      M[E]                     MV   Kilobytes  Kilobytes  Kb/10
EXEC    X[E] "d:\path\program.ext" 'args' MV   Exit[Path] Exit[Drive] GETsPath
Break Flag       BR[New flag 1=on, 0=off] MV       Old flag           --
Printer(PRN)     P[E]  [test]             MVX  1=yes,0=no 1=yes,0=no Initialize
DOS Version      D[E]                     MV   Major Vers MajorMinor MinorEnv
DESQview Version DV                       MV   Major Vers MajorMinor  --
4DOS Version     4                        MV   Major Vers MajorMinor  --
Windows          4E                       MV   1=yes,0=no 1=yes,0=no  --
Coprocessor/CPU  7[E]                     MV   1=yes,0=no 1=yes,0=no CPU Type
ANSI.SYS/Model   A[E]                     MV   1=yes,0=no 1=yes,0=no PC Model
Warm/Cold Boot   W[E] ["prompt"][arg]     All  If arg:1=warm, 0=cold ColdBoot
Surrogates: }=Carriage Return, ~=Escape, Alt-255=Space/Blank.
SWITCHES: /C Ctrl-Break, /U /L case, /M Master Env, /E Enhanced keys
 /X eXtra feature, /H Hex output, /W[num] numerical value, /N No CR
 /B flush key Buffer, /TL/TR/T Trim Left/Right/Both, /Vvar=, /V- No var
 /A[nnn] Attribute ["prompt"], All bytes [F], ASCII [R]
 /S Silence, /R Return Code in Environment
See GET.DOC for additional features and BATch programming instructions.
Unregistered version, registration REQUIRED for commercial use.Thanks guys, you were all on the right track...
The best solution was 'Kirby Alarm', because I did originally intend for Task Scheduler to do just what I wanted, but an internal error regarding account information not beeing set of some sort stopped it from being able to execute (exact error: 0x80090016: key not available) ... so that freeware tool should do the trick.

I was actually using W2k, but for batch files one uses MS-DOS commands, thats what I meant.If you're running under Windows, one of my favorite script tools is AutoIt http://www.autoitscript.com/autoit3/, it's a slick utility that'll allow you to do all sorts of automation tasks.I' look for a command that can assist me in complete what I already have. It is to also place copies in four other location and here is a example of the locations these files has to copied to:

E:\xcopy Z:\staging  Z:\backup Z:\localrelease Y:\Localrelease Y:\backup F:\CA F:\TX F:\MD


echo %DATE% FILE COPY START > %3_xcopy.log
xcopy /d /e /v /c /f /h /y %1 %2 >> %3_xcopy.log
echo %DATE% FILE COPY STOP  >> %3_xcopy.log


echo ----------------- >> archive.log

echo %DATE% >> archive.log
tail -1 %3_xcopy.log >> archive.log
start notepad %3_xcopy.log
start notepad archive.logshorty, see the reference to AutoIt I posted previously.

799.

Solve : Finding text and inserting variable?

Answer»

I have pgp installed and wanted to make a batch file to execute on a directory automatically. Hourly the scripts are being sent with a new file name every hour. I have tried using the c:\* and every other wildcard, but just keep on getting error MESSAGES in pgp with file does not EXISTS. EX: synatx of a good filename c:\test.pgp. How do I get around this. Ultimately I want a script to run hourly that would decrypt the whole directory looking for .pgp FILES. Would I execute a script to look for all files with a .pgp filename, save the filename then put in some static text with the variable filename .pgp. How do I go about doing this.

http://www.experts-exchange.com/Security/Q_20917079.htmlThe LINK is right on. Dont know if the responses are worth paying for a subscription.

800.

Solve : Starting Out?

Answer» HI I am 13 and have started using cmd prompt I was just wondering if anyone has any tips on writing .bat FILES that open programs. Any help would be much appreciated as I do not no much about using COMMAND prompt. Thanks.Opening a file from a batch file is as simple as putting the name of the file in the batch file.  For instance:


NOTEPAD.EXE C:\TEST.TXT

... will invoke notepad and open the file C:\TEST.TXT
A copy of the DOS 6.22 HELP.* and QBASIC.* files in your DOS or Windows\Command directory will give you access to a better HELP function than the /? one in DOS 7.x for Winn9x. WinNT/2K and XP trimmed down the AVAILABLE commands too much in the emulator...

There are still good 'tutorials' for batch file programming on the Web, use a search tool.