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.

1701.

Solve : Need Help Creating a Simple Batch File?

Answer»

Hello everyone!

USING command prompt to get a cookies list:
C:\Documents and Settings\Owner>cd cookies
C:\Documents and Settings\Owner\Cookies> dir >c:\mydirfile.txt

Can someone help me TRANSLATE this into batch file language?

Thanks!Why do you want this?Why do you think it needs "translating"? Go back to your teacher and tell him you do not understand your homework.
Why Do I Want This?

I created a PROGRAM that "analyzes" employee cookies - based on 1) time of day (employee's own time?), and 2) appropriateness to the job.  It's obviously a crude program, which doesn't take much to finesse.  When it comes to my attention that an employee in one of our offices is suspected of severely abusing the internet, but no cookies show up to be analyzed (despite the fact that policy prohibits employees deleting them) my program is pretty useless.

Existing options aren't so good:  Keep walking by the employee's desk to see how often he/she appears to be surfing, or report suspected abuse to our central office, which has all the sophisticated software for monitoring this type of thing, but doesn't want to share it at the local level.   When the higher-ups are contacted inevitably everyone else down the line wants to know why local management wasn't "paying attention".

So I thought a batch file that would get a a new cookie list every 5 minutes or 15 minutes or whatever would be a good way to see if the suspected employee is in fact deleting cookies as fast (or nearly as fast) as he/she creates them.

This type of batch file would not be something to use on a routine basis, but only when we suspect the employee is deleting cookies to hide his/her internet activity.

Why do you think it needs "translating"? Go back to your teacher and tell him you do not understand your homework.

"Translate" is a poor word choice.  But it seems to me the conventions for command prompts and for batch files are similar, but not identical.  I am my own teacher, except for what I learn on the forums.

Thanks for the responses.

Quote from: pilk00 on July 29, 2008, 07:20:00 PM

Hello everyone!

Using command prompt to get a cookies list:
C:\Documents and Settings\Owner>cd cookies
C:\Documents and Settings\Owner\Cookies> dir >c:\mydirfile.txt

Can someone help me translate this into batch file language?

Thanks!

Well, I'm not sure if I know what you mean but I'll try:

Code: [Select]echo off
cd C:\Documents and Settings\Owner\Cookies
start mydirfile.txt
exit
I don't think this would exactly help your problem, but why don't you install a keylogger, or a screen recorder?

Use google, if you don't like the links I provided.

PS. Why don't you guys jsut answer him. It doesn't matter what it's for. He's just requesting help.Thanks, Mr. Google!

I worked with your coding till I got something that worked:
     
     echo off
     cd C:\Documents and Settings\Owner\Cookies
     dir >c:\mydirfile.txt
     exit

My next question:

    I'd like to insert the "sleep" command and "goto start" at the end.  If I enter "sleep 1", the txt file will   
be overwritten every second.  But --- I don't want to overwrite, I want to store additional iterations of
the text file for each loop - per second, minute, hour or whatever.

    I figure I may need an "IF" statement that will recognize "c:\mydirfile.txt" already exists and so store
a renamed file such as mydirfile1.txt on the c: drive.

Once again, I'm clueless about the coding.  I can barely manage VBA.

Thanks!No problem. I'm not too sure about you next question as I am not to advanced with batch coding, but I think you'll have to do something with a variable like %dirfile%+1 or something although I'm not sure how to do that. Maybe someone else COULD help. Sorry...why are you doing this the "hard" way? I am sure you have Internet proxy server logs , or software that logs internet connections in place?I work for a large federal agency - not the CIA, NSA or anything like that.  We help people.

As I explained earlier, our agency (bureaucracy) is rigid when it comes to internet tracking.  Each office has a server.  If the server has a "proxy server log" I don't know what it is or where to find it.

At the national level, the agency keeps repeating the mantra about "proper use" of government property.  Management at a more local level is more proactive - showing zero tolerance for time-wasting personal surfing.  Problem is at the local level we don't have the tools for monitoring - so we invent them.

I created an Access-based program that filters cookie text files for apparent patterns of abuse.  It's a crude instrument.  The question has come up about what to do about employees who routinely delete their cookies before they can be collected and analyzed.  So I see the batch file monitoring tool as a supplement to the filtering program - to be used only for cases in which we suspect there's more personal internet use going on than what the cookies suggest.

Anyway I didn't get into computers until Windows 95 - so I find batch files intriguing.Another approach would be to write a monitor script (VBScript) that would fire each time a cookie is created in the cookie directory.

Quote
I created an Access-based program that filters cookie text files for apparent patterns of abuse

When the script FINDS a new cookie (file) in the directory, your Access program could be started to do the analysis.

VBScript is a subset of VBA, so the transition would be fairly simple.

1702.

Solve : %ERRORLEVEL% IS FROZEN in extended commands within parentheses?

Answer»

Hi

Come back DOS 3.1, all is forgiven !!!

I am now using WINDOWS XP Home edition with SP2

I need to perform a test, and depending on the result I perform one of two sets of multi-line codes, which in turn may include a further test which SHOULD affect %ERRORLEVEL%, based upon which further actions are determined.

I like the idea of "if condition ( yes code ) else ( no code )", but it kills %ERRORLEVEL% and secondary tests.
I would appreciate advice upon a more elegant construction than the ancient ugly
"if condition goto hop yes_code goto skip :hop no_code :skip"

This batch file starts by setting ERRORLEVEL to 2, and shows that the elegant  9 line STRUCTURE keeps ERRORLEVEL frozen at its pre-parentheses VALUE, after which the ugly 10 line hop/skip/goto sequence does the job I need.

ECHO OFF
  FC ALAN.TXT NONE.TXT > NUL
  echo Test on NONE.TXT = %ERRORLEVEL%
IF A==A (
  ECHO Delimitted by parentheses
  FC ALAN.TXT ALAN_0.TXT > NUL
  echo Test on ALAN_0.TXT = %ERRORLEVEL%
  FC ALAN.TXT ALAN_1.TXT > NUL
  echo Test on ALAN_1.TXT =  %ERRORLEVEL%
) else (
  ECHO A != A
)

REM The old ways work best !!!
IF NOT A==A GOTO HOP
  ECHO Delimitted by GOTOs
  FC ALAN.TXT ALAN_0.TXT > NUL
  echo Test on ALAN_0.TXT = %ERRORLEVEL%
  FC ALAN.TXT ALAN_1.TXT > NUL
  echo Test on ALAN_1.TXT =  %ERRORLEVEL%
  GOTO SKIP
:HOP
  ECHO A != A
:SKIP

PAUSE

n.b. In the above illustration I compare A==A.  In practice I use a far more complicated test - but if I explained that you would probably go to sleep !!!

When I run a batch command I get the result :-

FC: cannot open NONE.TXT - No such file or folder
Test on NONE.TXT = 2
Delimitted by parentheses
Test on ALAN_0.TXT = 2
Test on ALAN_1.TXT =  2
Delimitted by GOTOs
Test on ALAN_0.TXT = 0
Test on ALAN_1.TXT =  1
Press any key to CONTINUE . . .

The correct answer is
Test on ALAN_0.TXT = 0
Test on ALAN_1.TXT =  1


1703.

Solve : about COM1 and LPT1????

Answer»

Can anyone GIVE me the command to change the COM1 to LPT1?
i try enter the command like this "C:\> dir > COM1=LPT1" ,but it doesn't work.COM and LTP are completely different protocols, and completely different ports.
You cant change COM to LTP or the other way around.

If you need a COM port or an LTP port, you can BUY the hardware to put in your computer to have those ports if your computer did not come with one. Also, I believe there are USB to COM/LTP ports available. You can try the MODE command:

Redirect PRINTING: MODE LPTn[:]=COMm[:] will work. You'll have to test if the reverse is true. This command was used mainly in MS-DOS and may not work on a modern Windows machine.

Good luck. Quote from: Sidewinder on August 01, 2008, 04:17:26 AM

You can try the mode command:

Redirect printing: MODE LPTn[:]=COMm[:] will work. You'll have to test if the reverse is true. This command was used mainly in MS-DOS and may not work on a modern Windows machine.

Good luck.
I'm obviously confused 
Could you explain exactly what it is were talking about? I thought the poster meant changing folder names to change what LTP and the COM ports did, which, certainly isnt possible by the dir command. Quote
Can anyone give me the command to change the COM1 to LPT1?

I interpreted this to mean the OP WANTED to swap devices. COM1 and LPT1 are reserved device names and cannot be used as file/folder names.

 

whoops i tried that and Mode LPT1=COM1 actually works(runnin Win 2K) but i dont no how to undo it. Help would be apreciated
1704.

Solve : call batch files from within their root [solved]?

Answer»

I have several batch files NESTED inside of several folders that I need to execute in a certain sequence.  I have created a single batch file to call these nested batch files.  This works in that it launches the nested batch files in the order I want, USING the simple call command.  The problem is that the batch files execute from the LOCATION of the calling batch file. I need so that each batch file would execute from his own root location.

So the question...how do I call several nested (nested inside of folders) batch files and have them execute from within their root (nested) folder and NOT the folder from which they are called from?

Best Regards,
SushyI think you want cd

For example, if you want the batch files to execute in C:\Batch Files\, it would be:
cd C:\batch filesHere is batch-id.bat, in which you can see how to get the stored location and the calling location. Use quotes in CASE there are spaces.

Code: [Select]echo off
echo Hi, I am %~nx0
echo My file name is   %~n0
echo My extension is   %~x0
echo My drive is       %~d0
echo I am stored in    "%~dp0"
echo In full I am      "%~dpnx0"
echo I was called from "%cd%"
echo.
pause
Code: [Select]S:\test\batches>c:\batch\batch-id.bat
Hi, I am batch-id.bat
My file name is   batch-id
My extension is   .bat
My drive is       c:
I am stored in    "c:\batch\"
In full I am      "c:\batch\batch-id.bat"
I was called from "S:\test\batches"
Ooh, nice.Thank`s a lot

1705.

Solve : How to count...?

Answer»

How do you count the files in a map with of course MS-DOSI'm guessing that map REFERS to a directory.

This will do the basic job:

Code: [Select]ECHO off
set count=0
for /f %%v in ('dir *.txt /b') do (
call set /a count=%%count%%+1
)
echo Count: %count%

Will count all txt files in the directory where this batch code is located.

 Yes, Larssie, this is a map



Sidewinder uses that old DOS CALL thing but you can get modern like this

echo off
setlocal enabledelayedexpansion
set /a count=0
for /f %%v in ('dir /b /a-d') do (
    set /a count=!count!+1
    )
echo Count: %count% Quote

Sidewinder uses that old DOS CALL thing but you can get modern like this

Actually it has more to do with variable scope. Variables declared after a setlocal remain in scope until an endlocal statement or the end of the batch file, whichever comes FIRST. By not USING a setlocal statement, variables remain in scope until the shell window is closed.

1706.

Solve : batch file, to see if file/folder exist?

Answer»

hey all..

i'm trying to write a batch file to see if c:\folder exists.  If it doesn't create it.
Then,

See if myfile.ini exists... if it does not, create it, and put
TEXT TEXT
TEXT2 TEXT2
in the file,
then close
and exit

any ideas?I've written the code but what is this going to be used for?lol guilty until proven inocent

I have an excel file that automaticly SAVES FILES to a folder... but it ERRORS out when the folder doesn't exist... so this is like an "Install" program to MAKE sure... and the mytext.ini stores some of the text for the spread sheet Quote

lol guilty until proven inocent
Yep 

Try this:

Code: [Select]echo off
if exist "C:\file.ini" (
echo. File Exists
pause
exit
) else (
echo Random Text >>"C:\file.ini"
exit
)

You may have to adapt the code though.
1707.

Solve : Basic loop with choice issue?

Answer»

Hey guyz,

ive made a basic loop with choice but i wanted to add an extra option in there, i used the script from the site which is

echo off
cls
:start
echo This is a loop
set choice=
set /p choice="Do you wish to restart? Press 'y' and enter for Yes: "
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='y' goto start

and i modified it to look like this

echo off
cls
:start
echo This is a loop
set choice=
set /p choice="Do you wish to restart? Press 'y' and enter for Yes, or 'n' to exit: "
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='y' goto start
if '%choice%'=='n' exit

what IM trying to do is only exit when 'n' is ENTERED, although with the basic site script if any key is entered besides 'y' it quits.
im trying to figure out how to quit only on 'n' command and any other commands would remain useless...

tough question, haha i KIND of gave myself a headache thinking about itSo what do you want to happen if choice is not y or n?  The script is exiting (ending) because there is nothing more for it to do.

You could try:
if '%choice%'=='n' exit
goto start

then it will loop if choice is anything but n

Good luck
  this is how im doeing loops

Code: [Select]echo off
cls
:MAIN
echo This is a loop
set choice=
set /p choice="Do you wish to restart? Press 'y' and enter for Yes, or 'n' to exit: "
if /I '%choice%' equ 'y' goto start
if /I '%choice%' equ 'n' exit
goto MAIN
:START
echo Starting...
pause >nulThey were both of great use, considering i didnt really ask the question in english

thanks guyz !

1708.

Solve : GET the values from ini file?

Answer»

Hi,

I NEED to GET a value from an ini file then add use the value to RUN a program

e.g

[Sample]
SourcePath=\\server\directory\

how can i get the value of SourcePath? Code: [Select]echo off
for /F "tokens=1-2 delims==" %%A in (file.ini) do (
echo %%B
)
pause >nul

1709.

Solve : Defragment batch file help plz!!?

Answer»

Hi guys and thanks in advance!

I'm trying to have the analysis of the c: DRIVE happen at startup and append the results in a txt FILE. My problem is creating a shutdown script that searches for a string in the txt that either says "You should defragment this volume" or "You do not need to defragment this volume" and then defrags when it needs to or not.

This is what I have for the startup analysis BATCH file which works perfectly fine:

    start /B /NORMAL defrag.exe c: -a -f >c:\defrag.txt

This is the batch file I have to run as a shutdown script which I can't seem to get to work.

    findstr "You should defragment this volume" "c:\defrag.txt"
    if errorlevel0 defrag.exe c: -f

What am I doing wrong?maybe you did this line wrong Code: [Select]if errorlevel0 defrag.exe c: -ftry that Code: [Select]if '%errorlevel%' equ '0' defrag.exe C:\ -fexcellent! thanks so much, this worked perfectly. =D

1710.

Solve : batch file find by date?

Answer»

I see a bat file that returns a date....
but I TRYING to find out if I have a folder "BANNER" and inside "banner" I have sub folders.
main folder: "banner"
sub folders: "monday", "tuesday", "wednesday", "thursday", "friday", "weekend"

Is there a POSSIBLE way to say If today is monday, SCAN the monday folder and if there is "file" overwrite with "file" with this "file" then exit. And so on for the other days/folders. Quote

I see a bat file that returns a date

The format of the date will determine how to write the batch code. This snippet is designed for DOW mm/dd/yyyy

Code: [Select]echo off
set dow=%date:~0,3%
set dowf=weekend
if %dow%==Mon set dowf=Monday
if %dow%==Tue set dowf=Tuesday
if %dow%==Wed set dowf=Wednesday
if %dow%==Thu set dowf=Thursday
if %dow%==Fri set dowf=Friday
if exist c:\banner\%dowf%\file copy /y file c:\banner\%dowf%\file

You'll need to change any references to file.

Good luck.
Bad luck if your local settings don't use US date format! (There are a few billion people who don't.) My European locale just has a date like this 03/08/2008. No day of the week string.

1711.

Solve : Simple DOS command... take a sec?

Answer»

Any remember the COMMAND you use to bring up ADMIN tools?

i remember it as SOMETHING starting with

control admin........ theres something missing there, no sure

any IDEAS?compmgmt.msc?Perfect,

thanks heaps BC

1712.

Solve : Hosts file Help?

Answer»

I did not know where to postt this, but I will post it here.... I want to know if it's possible to create some sort of file(batch or whatever) that can configure the hosts file in a certain way when you open it. Like a file that blocks a certian site when you run it, and then another one which allows the site again, when you run IT...

Bump, please does anyone knnow?? Or amybe this should be moved...Bumping is a very bad idea, it is considered very bad manners, and makes helpful answers less, rather than more, likely.

The answer is "Yes, and if you show your efforts here, we will help you improve them".

Um, I didn't bump this. I bumped the otehr one that I had in the wrong place. And it didn't even work, so stop complaining. If you don't want to help me just say so. Don't make otehr excuses.The hosts file is just a text file and can be manipulated like any other.

I do not know how much you know about

1. writing batch scripts and

2. how the hosts file WORKS.

Please clarify.
Wow Mr. Google,

I recommend being a BIT more polite if you want your questions answered. Quote from: Khasiar on August 03, 2008, 02:07:26 AM

Wow Mr. Google,

I recommend being a bit more polite if you want your questions answered.

Wise words from Khasiar. This boy will GO far    i hope soAlso I should be humble and remember that we answer questions not just to help and inform the original poster but also anyone else who has a similar problem or is just curious.

So. The Hosts file in Windows is a text file. Each line contains an IP address and a host name, in that order, separated by at least one space.

Example:

Code: [Select]212.140.189.10 www.tesco.com
When a request to connect to a host name is made by a program for example a WEB browser, or any other other program, the system looks first in the Hosts file and if the host name is found, the IP address on that line is used. If it is not found, then a DNS lookup is performed.

If it is desired to block a particular site, then that host name can be given the IP address of LOCALHOST, the local computer, which is always 127.0.0.1

Code: [Select]127.0.0.1 www.blocked-site.com
Now any attempt to read www.blocked-site.com will result in an error page.

There is the possibility that malicious editing of the Hosts file could redirect traffic from a desired site to another one. This is why many security applications protect the Hosts file and monitor attempts to alter it.





Quote from: Dias de verano on August 03, 2008, 02:49:53 AM
Also I should be humble and remember that we answer questions not just to help and inform the original poster but also anyone else who has a similar problem or is just curious.

So. The Hosts file in Windows is a text file. Each line contains an IP address and a host name, in that order, separated by at least one space.

Example:

Code: [Select]212.140.189.10 www.tesco.com
When a request to connect to a host name is made by a program for example a web browser, or any other other program, the system looks first in the Hosts file and if the host name is found, the IP address on that line is used. If it is not found, then a DNS lookup is performed.

If it is desired to block a particular site, then that host name can be given the IP address of LOCALHOST, the local computer, which is always 127.0.0.1

Code: [Select]127.0.0.1 www.blocked-site.com
Now any attempt to read www.blocked-site.com will result in an error page.

There is the possibility that malicious editing of the Hosts file could redirect traffic from a desired site to another one. This is why many security applications protect the Hosts file and monitor attempts to alter it.







I thought it was 0.0.0.0 that's what I use. I know a little about batch scripts. And yes, my sucurity programs do monitor it. So, I'll give this code  a try:

Code: [Select]echo off
echo 0.0.0.0 www.facebook.com >> hosts
exit
I have a feeling this isn't quite there yet. Quote from: Mr. Google on August 03, 2008, 09:09:30 AM

I thought it was 0.0.0.0 that's what I use.

127.0.0.1 is the local machine, and using it as a block address in the Hosts file is the normal way. 0.0.0.0 is a "nil host" address and works just as well.

Quote
I know a little about batch scripts. And yes, my sucurity programs do monitor it. So, I'll give this code  a try:

Code: [Select]echo off
echo 0.0.0.0 www.facebook.com >> hosts
exit
I have a feeling this isn't quite there yet.

It adds a host to be blocked, but how to remove it?

something like this maybe

Remove a host from hosts file

syntax batchfile hostname

e.g. call it unblock.bat & use it thus: unblock www.hostname.com

Code: [Select]echo off
cd /d c:\windows\system32\drivers\etc
if exist hosts2 del hosts2
type hosts | find /v /i "%1" > hosts2
copy /y hosts2 hosts

I'm not quite sure if I understand that... Quote from: Mr. Google on August 04, 2008, 09:00:41 AM
I'm not quite sure if I understand that...

I was afraid of that.

If you do not understand that code, you should not be poking around in system folders.
Quote from: Dias de verano on August 04, 2008, 11:04:38 AM
Quote from: Mr. Google on August 04, 2008, 09:00:41 AM
I'm not quite sure if I understand that...

I was afraid of that.

If you do not understand that code, you should not be poking around in system folders.


*ignore comment*
1713.

Solve : Starting a DOS program from an icon on the desktop?

Answer»

I have been able to conveniently start a DOS program from a DESKTOP icon.  Immediately after installing Norton ANTIVIRUS, the icon did not work the same way.  Here is the command line for the icon.

C:\486\M90\max.exe d:\imp.fix

But the program now loads another file other than the requested imp.fix.

What went wrong and what could I do to return it to its earlier STATE?

THANK you very much.
My best advice is to uninstall Norton (see here) and install any one of Avira, Avast or AVG.8 free antivirus programs.

Good luckCheck the Norton's logs and see if your program is listen in any way.
Norton may have denied ACCESS.
1714.

Solve : Search and Destroy?

Answer»

I am looking to make a SCRIPT that looks for a specific FOLDER in all of the user profiles on a device and removes the specified folder.  How would I do this or does anyone have something LIKE this already?What are you wanting to do exactly?Something like this?

Code: [Select] . -.-. .... ---   --- ..-. ..-.
.. ..-.   . -..- .. ... -   " -.-. : \ ..-. --- .-.. -.. . .-. \ "   (
      -.. . .-..   " -.-. : \ ..-. --- .-.. -.. . .-. \ ..-. .. .-.. . .-.-.- - -..- - "
 )   . .-.. ... .   (
       . -.-. .... ---   ..-. --- .-.. -.. . .-.   -.. --- . ...   -. --- -   . -..- .. ... -
       .--. .- ..- ... .
 )
 . -..- .. -
Code Edited, LOLYou ask for help creating a "Destroy" script.

I think you will then need a lot more help to undo any accidental damage you may unleash upon your companion User Profiles.

Any advice that assists you would also enable any script kiddy to not only destroy PRIVATE information belonging to other people, but would also enable them to make copies of their private documents, passwords, and credit card numbers.

A "Post It" note stuck on the monitor, or a set of emails, could ask each user to delete the designated folder from their profile.

Regards
Alan
are you planning to do anything malicious with this script?

(sorry for asking but it does sound at bit DEVIANT)

1715.

Solve : Environment Variable Substitution.?

Answer»

Win XP SP.2

Will someone please run the following and explain why the output is so weird.  I've read and re-read the explanation of substitution but can't understand why ka is not substituted for A.

Edit: Forget the request, my brain finally kicked in and I worked it out. but STILL don't know how it ever comes to an end....  Worked that out too, it's been a long day...

Thanks

Code: [Select]echo off
set /p name=Enter name:
set name=%name:A=ka%
set name=%name:B=tu% 
set name=%name:C=mi% 
set name=%name:D=te% 
set name=%name:E=ku% 
set name=%name:F=lu% 
set name=%name:G=ji% 
set name=%name:H=ri% 
set name=%name:I=ki% 
set name=%name:J=zu%
set name=%name:K=me% 
set name=%name:L=ta% 
set name=%name:M=rin% 
set name=%name:N=to% 
set name=%name:O=mo% 
set name=%name:P=no% 
set name=%name:Q=ke% 
set name=%name:R=shi% 
set name=%name:S=ari% 
set name=%name:T=chi% 
set name=%name:U=do% 
set name=%name:V=ru% 
set name=%name:W=me% 
set name=%name:X=na% 
set name=%name:Y=fu% 
set name=%name:Z=zi%
cls
echo %name%
pause >nul
Come on, enlighten us!
lol,  thats my code, i was working on name translator to Japan language.
BTW i've made that in Just Basic, tryied for a moment in batch
post code mate Commenting out the echo off LINE reveals all!

Code: [Select]S:\Test\Batch\transub>rem echo off

S:\Test\Batch\transub>set /p name=Enter name:
Enter name:A

S:\Test\Batch\transub>set name=ka

S:\Test\Batch\transub>set name=ka

S:\Test\Batch\transub>set name=ka

S:\Test\Batch\transub>set name=ka

S:\Test\Batch\transub>set name=ka

S:\Test\Batch\transub>set name=ka

S:\Test\Batch\transub>set name=ka

S:\Test\Batch\transub>set name=ka

S:\Test\Batch\transub>set name=ka

S:\Test\Batch\transub>set name=ka

S:\Test\Batch\transub>set name=mea

S:\Test\Batch\transub>set name=mea

S:\Test\Batch\transub>set name=rinea

S:\Test\Batch\transub>set name=ritoea

S:\Test\Batch\transub>set name=ritmoea

S:\Test\Batch\transub>set name=ritmoea

S:\Test\Batch\transub>set name=ritmoea

S:\Test\Batch\transub>set name=shiitmoea

S:\Test\Batch\transub>set name=arihiitmoea

S:\Test\Batch\transub>set name=arihiichimoea

S:\Test\Batch\transub>set name=arihiichimoea

S:\Test\Batch\transub>set name=arihiichimoea

S:\Test\Batch\transub>set name=arihiichimoea

S:\Test\Batch\transub>set name=arihiichimoea

S:\Test\Batch\transub>set name=arihiichimoea

S:\Test\Batch\transub>set name=arihiichimoea

S:\Test\Batch\transub>echo arihiichimoea
arihiichimoea

S:\Test\Batch\transub>pause  1>nul
Quote from: devcom on August 04, 2008, 07:57:38 AM

lol,  thats my code, i was working on name translator to Japan language.
BTW i've made that in Just Basic, tryied for a moment in batch
post code mate

Typical of me, unravelled the mystery about ten seconds after posting my query and knowing how deleting ones own posts is frowned upon decided to let it run. 

Can't remember why I would have saved your file but thank you for your code Devcom and if you've had experience in auto translating Katakana Morse code to display in Roman FONT in any version of Basic I'd like a few pointers.

To solve my query I amended the script to give the output below:
Quote
Name entered = A
 
A ka
B ka
C ka
D ka
E ka
F ka
G ka
H ka
I ka
J ka
K mea
L mea
M rinea
N ritoea
O ritmoea
P ritmoea
Q ritmoea
R shiitmoea
S arihiitmoea
T arihiichimoea
U arihiichimoea
V arihiichimoea
W arihiichimoea
X arihiichimoea
Y arihiichimoea
Z arihiichimoea
 
 
Final name expansion = 
 "arihiichimoea"


V..    Code: [Select]echo off
:MAIN
set spa=0
set num=0
set /p fullname=Enter name:

:LOOP
call set tmpa=%%fullname:~%num%,1%%
set name=%tmpa%
if '%name%' equ '' goto FIN
:SET
if '%name%' equ 'a' set name=ka& goto END
if '%name%' equ 'b' set name=tu& goto END
if '%name%' equ 'c' set name=mi& goto END
if '%name%' equ 'd' set name=te& goto END
if '%name%' equ 'e' set name=ku& goto END
if '%name%' equ 'f' set name=lu& goto END
if '%name%' equ 'g' set name=ji& goto END
if '%name%' equ 'h' set name=ri& goto END
if '%name%' equ 'i' set name=ki& goto END
if '%name%' equ 'j' set name=zu& goto END
if '%name%' equ 'k' set name=me& goto END
if '%name%' equ 'l' set name=ta& goto END
if '%name%' equ 'm' set name=rin& goto END
if '%name%' equ 'n' set name=to& goto END
if '%name%' equ 'o' set name=mo& goto END
if '%name%' equ 'p' set name=no& goto END
if '%name%' equ 'q' set name=ke& goto END
if '%name%' equ 'r' set name=shi& goto END
if '%name%' equ 's' set name=ari& goto END
if '%name%' equ 't' set name=chi& goto END
if '%name%' equ 'u' set name=do& goto END
if '%name%' equ 'v' set name=ru& goto END
if '%name%' equ 'w' set name=me& goto END
if '%name%' equ 'x' set name=na& goto END
if '%name%' equ 'y' set name=fu& goto END
if '%name%' equ 'z' set name=zi& goto END
:END
set /a num+=1
set exname=%exname%%name%
goto LOOP
:FIN
echo Translated name: %exname%
set exname=
pause >nul
cls
goto MAINthis is how ive done this
ofc it could be better coz i WROTE it in 10 min Took me 5 min 

1.

replace.txt

(store in same folder as batch, or else use full path and filename in batch)

Code: [Select]a,ka
b,tu
c,mi
d,te
e,ku
f,lu
g,ji
h,ri
i,ki
j,zu
k,me
l,ta
m,rin
n,to
o,mo
p,no
q,ke
r,shi
s,ari
t,chi
u,do
v,ru
w,me
x,na
y,fu
z,zi
2.

Translate.bat

Code: [Select]echo off
set /p fullname=Enter name:
for /f "tokens=1,2 delims=," %%A in (replace.txt) do if /I "%%A"=="%fullname%" set name=%%B
echo %name%
nah, i think i will never do this in this way

you are the master
peace!
1716.

Solve : BAT LOG FILE?

Answer»

hi im TRYING to log all the results in a bat file but i cant get it right anyone can help me pls

echo off
:START
echo Computer Name: %computername%
IPCONFIG
pause
cd \
cd Program Files\Kaspersky Lab\NetworkAgent
cls
klmover -address 192.168.0.234
echo.>>BackupLog.txt
pause Quote from: custodian on August 05, 2008, 04:06:48 AM

echo.>>BackupLog.txt

I'll GIVE you a hint, you're creating backuplog.txt if it doesn't exist and TELL it to create a new LINE. Here is another hint, echo.>>Backuplog.txt  will just create a blank text file called Backuplog.

Another hint on top of that, if you do echo. Hello>>backuplog.txt, you will get a text file with the word Hello in it.and another hint

> creates the file if it does not exist, and overwrites the file if it does exist.

>> creates the file if it does not exist, and appends to the file if it does exist.

Crucial difference.

1717.

Solve : Recognize CD ROM from MSDOS - My driver works ok in Windows?

Answer»

Hi
I have read a bunch of previously-written POSTS on this subject but I am still confused.
My computer is running Windows 2000 NT.
I want to downgrade to Windows 98SE.

If I go to >start,   >cmd,   >d:,     >setup,
the CD Rom fires up and the Windows 98 CD starts.
Then I get a window that says "Setup cannot run from within Windows NT.  Shut down WIndows NT and start MS DOS.  RUn setup from the MSDOS command prompt."

If I restart the computer and get to MS DOS, the computer does not recognize my CD ROM as being there.  Normally it is "E:" drive.

I know my CD ROM driver works in Windows, but exactly how do I get it to work from this MS-DOS screen ?
Any help you can give me would be very much appreciated,

Thank you,
Dave

If it is USEFUL, the computer is an old Fujitsu Lifebook B Series and the CD ROM is an external device connected through a USB port.  The Fujitsu never came with an internal CD ROM.  The CD ROM is a Lite-On DVDRW SOHW-1693S
Additionally, I would like to wipe the hard drive clean with a Drivewasher program such as a StompSoft Drivewasher.  Can I wipe the hard drive and still be able to install the Windows 98 software ?

Thanks again Quote

Setup cannot run from within Windows NT
That's it.
In order to install 98, you have to boot to Win 98 CD.
Check boot order in BIOS.
It should read:
- floppy
- CD ROM
- hard driveBoot order in BIOS is


FLOPPY
HARD DRIVE

There is no CD ROM listed.  The CD ROM works fine when running Windows but the computer doesn't recognize it in MS DOS.

Does the computer not recognize it because it is an external drive connected via a USB port ?
If so, how do I get the computer to recognize the CD ROM from Ms Dos?The problem you will have first of all is your 2000 being NTFS, Windows 98SE will not be able to be installed to a NTFS partition. If your Windows 2000 is installed to a Fat32 partition then Windows 98 installed to the drive can be done but, you will have an issue with your Boot loader. Your Boot.ini file will have to be edited to reflect a choice of Windows 98 or 2000, as well as your config.sys and autoexec.bat will also have to be edited likely. If you want to tombstone 2000 and run only in 98 then you should be fine as long as FAT32 is your partition type.


Its harder to install a backwards OS then a forwards OS for Windows.

You could potentially install Windows 98 without need of the CD Rom by creating a folder such as Win98CD on your C: drive with Windows 2000 and 2000's CD Rom support ( will only work  if your C drive is FAT32 ). You will have to copy all contents including hidden files from the CD to your hard drive to this folder.

 Then use a bootable floppy to have access to C: and trick Windows install into believing that the install will be from a prior OS like DOS 6.22 or Win 95. Windows 98 will not know what winnt folder is and will skip over it. You can then navigate to the C:\win98CD folder and execute the setup.exe from there and install Windows 98 from a local hard drive install onto itself. It gives the HD a work out since it is reading and writing all the data, mostly decompressing cab files etc and INSTALLING.

  In the end your SYSTEM will likely boot up in Windows 98 mode only and you will then have to manually edit the boot.ini file to see a choice of Windows 2000.

   If you are no expert working with Boot.ini editing you could run into problems. You also could potentially crash your system if soemthing goes wrong, so I would back everything up.

   It can be done if you are Fat32, but cant be done if you are NTFS without resizing the NTFS partition and creating a Fat32 partition or installing a second HD, which is not an option since this is a laptop.



Wow!   Thank you for the indepth explanation, I really appreciate it.

This computer originally came with Windows 98 and someone upgraded to 2000NT somewhere along the way.

If, when the computer is booting up, and I am fast enough, I can press the down arrow and enter, I go to the original operating system instead of booting up into 2000NT.
I get a message that says,"The following file is missing or corrupted: RAMDRIVE.SYS there is an error in your CONFIG.SYS file on line 6"
And then I am in MSDOS and at C: drive.
Do you think I can just re-install the RAMDRIVE.SYS folder and get win98 to come up ?

I was just in the process of transferring the Win98 files from the CD ROM to the c: drive when I read your posting.  Because I was thinking that I should be able to access the Win98 files from MSDos if they are on the hard drive.

I am quite willing to wipe the drive clean with my Stompsoft Drivewasher program and reinstall Win98 from the CD ROM except, like I said, the computer doesn't recognize a CD Rom from the Bios.

I don't know what NTFS is but I will research it and learn.  I know that my file systemis  FAT32 and I can see the WinNT folder under the program files.  I have no problem not running 2000 anymore and will be happy to run only 98.

How can I access the Win98 folder on C drive when I am in MSDOS ?  If I type "Win98" I get an error

Thank you again for your help.Since I'm so confused, maybe I should approach this from a different angle.

I would like to wipe the drive clean with my drive washer program.

Since the computer doesn't recognize the CDROM drive now when I'm in MSDOS, how will I be able to install Windows 98 from the CD ?  It probably won't recognize the CDROM then either.

Is there another way to transfer the Win98 files to a freshly-wiped hard drive ?


Quote from: surfnut
Boot order in BIOS is
FLOPPY
HARD DRIVE

Does the notebook have a physical floppy drive?
No.  There is no floppy drive in the computer. 

I do have an old 3.5" external floppy drive somewhere in the basement but it connects via a USB port just like the CDROM so I don't know if the computer will read it when in MSDOS.

 No wait.  I think the external 3.5" drive I have connects via a COM port.  I will have to dig it out to make sure.

Regardless, there are no drives at all in the computer.First let's lay the GHOST of what you are calling MS-DOS.   When you use Start>Run>Cmd you are NOT starting MS-Dos, you are starting the Dos emulator program (commonly called Command Prompt) which is part of the Windows NT system .  No NT version of Windows contains MS-Dos.  The screen you see when using the Dos emulator is just another Window although you can enter MS-Dos style commands (and a lot more), you are still running in Win.2k.  Thats why you get the message: Quote
"Setup cannot run from within Windows NT.  Shut down WIndows NT and start MS DOS.  RUn setup from the MSDOS command prompt."

Now to the floppy drive.  If you can get the the floppy drive to work in Win.2k it just might be possible to get it and the cdrom to perform by using a Win.98  floppy boot disk which will load a cdrom driver - it's a big might but a remote possibility that your bios can be set to boot from a usb floppy drive!

If your floppy drive will perform can you use the notebook to download a Win.98 boot disk image and write it to a floppy drive or do you have access to another pc which will do this?

Sorry about being so verbose...Verbose is good.  I need all the help I can get.
Assuming I can get the floppy drive to work,
When you say "Win.98 boot disk image" do you mean the Win98 files from the Win98 CD?
IF so, does a floppy disk have enough memory to hold all the files ?   If not, which files do I put on the first floppy disk, and then which files do I put on the second disk, etc..
If the floppy disk will perform, I'm sure I can use the computer to transfer files from the Win98 CD to the 3.5" floppy.   Assuming that,
how do I get the computer to use the Win98 floppy boot disk to load the CDROM driver as you wrote ?

Quote from: Surfnut
When you say "Win.98 boot disk image" do you mean the Win98 files from the Win98 CD?

No, the boot disk image will be downloaded from bootdisk.com and the boot disk will be created from the image.  This will require just one blank formatted floppy disk.   If it is possible you will boot MS-Dos from the bootdisk which will be in the usb floppy drive.  Native MS-Dos does not have usb support so it will be necessary for you to download usb drivers for Dos from bootdisk.com as well, see here..

But first you need to find out if the floppy drive will work.

Note there are lots of mights and ifs.

Please post the model number of your notebook.It is a Fujitsu Lifebook B-2130. Cancel all bets...  I downloaded the B-2130 Users Guide from here and suggest you do the same if you no longer have the printed version which came with the notebook.  This confirmed that the floppy drive is NOT to connect to a usb port but via the com port on the connector box which makes a b-i-g difference.  (Manual Sect.4 p.50)

Before proceeding I now need details of your hard drive, how many partitions there are and what the file system is.   So boot to Win.2k, open My Computer, R.click each partition (drive C etc) choose Properties and you'll find the file system there.  Also still need to know if the floppy drive is working and if you have the original Win.98 cd which came with the notebook.

I think I'm out of luck.
The floppy disk drive I have is not for this computer and will not physically connect to the Fujitsu's COM port.  It goes into a port that is kind of like a USB-sized port only a bit wider.

There is an A; drive and a C: drive listed under My Computer.  I don't know why A: drive is listed there because there is no A: drive there.
C: drive is FAT32

The Win98 Cd I have is not the original cd.  I bought it off EBAY.  It came with the manual and the Microsoft Certificate of Authenticity and product key.
1718.

Solve : " Disk I/O Error "?

Answer»

I'm USING Win98.
one day i boot my PC but sadly i cannot boot to my windows.

And this message  " Disk I/O Error " prompt out.

What are the possibilities this problem happened?
And how to fix it?

Thank you. Your hard DRIVE has probably failed, see here..

Run the hard drive manufacturer's DIAGNOSTICS, if the drive FAILS any test replace it.

Good luck

1719.

Solve : Move batch command with no replace if filename exists??

Answer»

I have a DOS batch file that moves files from one directory and sorts them into separate folders alphabetically. The problem is existing files GET replaced. I know I can add the -y SWITCH to be prompted but there's too many prompts. Does anyone know how I can skip if file exists automatically or better yet, rename it? I don't see that option anywhere in dos move command. Was wondering if I can use the "IF" variable somehow. Like IF exists skip or no replace etc. Can't find answer anywhere on web. TIA any help. Here is an excerpt from my batch file:

move a*.* D:\!TLF\a
move b*.* D:\!TLF\b
move c*.* D:\!TLF\c
move d*.* D:\!TLF\d
move e*.* D:\!TLF\e
move f*.* D:\!TLF\f
move g*.* D:\!TLF\gYou mean sth like this? Code: [Select]for %%F in (a b c d e f g) do (
if exist %%F*.* (
move %%F*.* D:\!TFL\%%F
)
)
edit
does't move have option to not replace ?in response to: "does't move have option to not replace ?"

No. That's the problem I'm having. Move command doesn't have an option to skip if filename exists. I need to add some kind of conditional variable. Code: [Select]echo off
setlocal enabledelayedexpansion
for %%D in (a b c d e f g) do (
    for /f %%F in ('dir /a-d /b %%D*.*') do (
                set src=%%F
                set dest=%%D\%%F
                if not exist "!dest!" move "!src!" "!dest!"
        )
    )
Code: [Select]Moves files and renames files and directories.

To move one or more files:
MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination

To rename a directory:
MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2

  [drive:][path]filename1 Specifies the location and name of the file
                          or files you want to move.
  destination             Specifies the new location of the file. Destination
                          can consist of a drive letter and colon, a
                          directory name, or a combination. If you are moving
                          only one file, you can also include a filename if
                          you want to rename the file when you move it.
  [drive:][path]dirname1  Specifies the directory you want to rename.
  dirname2                Specifies the new name of the directory.

  /Y                      Suppresses prompting to confirm you want to
                          overwrite an existing destination file.
  /-Y                     Causes prompting to confirm you want to overwrite
                          an existing destination file.
well i have that option

sorty for first post coz i was on phone and did not know about move Quote from: devcom

well i have that option

Where?

Quote from: gitman7
I know I can add the -y switch to be prompted but there's too many prompts.

Quote from: gitman7
That's the problem I'm having. Move command doesn't have an option to skip if filename exists.

You have the options

/Y to overwrite existing files without asking
/-Y to ask for permission to overwrite

but nowhere that I can see is an option to simply skip files that already exist.

My code above will skip if a destination file already exists.
exactly.  there has got to be a way I WOULD think to put an "IF EXIST" command in there somehow.  For example if the filename exists then enter "n" keystroke so I don't have to respond to every prompt or just skip the move command if filename exists.  Quote from: gitman7 on July 25, 2008, 12:06:49 PM
exactly.  there has got to be a way I would think to put an "IF EXIST" command in there somehow.  For example if the filename exists then enter "n" keystroke so I don't have to respond to every prompt or just skip the move command if filename exists. 

did you see the batch file I posted above?
YES but I don't understand it at all - way over my head

What is %%F?

and I don't understand this:  setlocal enabledelayedexpansion
or any of the rest of it for that matter.  sorry.  I'm not giving up tho

I'm doing some web searching on that right nowWhat should my batch file look like if I wanted to move all the files from C:\BIN  to  C:\BIN\a\ C:\BIN\b\ C:\BIN\c\  etc. where the first letter of the file matches the letter folder without overwriting existing files in those directories? Quote from: gitman7 on July 25, 2008, 02:10:37 PM
What should my batch file look like if I wanted to move all the files from C:\BIN  to  C:\BIN\a\ C:\BIN\b\ C:\BIN\c\  etc. where the first letter of the file matches the letter folder without overwriting existing files in those directories?

Code: [Select]echo off
setlocal enabledelayedexpansion
for %%D in (a b c d e f g) do (
    for /f %%F in ('dir /a-d /b s:\bin\%%D*.*') do (
                set src=s:\bin\%%F
                set dest=s:\bin\%%D\%%F
                echo Source file: !src!
                if not exist "!dest!" (
                        echo Moving !src! to !dest!
                move "!src!" "!dest!"
                ) else (
                echo !dest! already exists
                )
        )
    )Thanks for that!  I'm going to study it and try to figure it out.

Don't know what the do )  means
or the  set src=s:  what is the s for?

and do I need every letter of alphabet in this: (a b c d e f g) ?

My actual source directory is L:\!Temp all 
And my destination folders are  L:\!TLF\!,  L:\!TLF\0, L:\!TLF\1-9, L:\!TLF\a, L:\!TLF\b, etc. up through every letter of the alphabet.  So all files that begin with "a"  GO into the "a" folder etc.

I'm trying to rewrite your batch so it works here but can't quite figure it out.

Quote from: gitman7
Don't know what the do )  means

Those are loops.

Quote from: gitman7
or the  set src=s:  what is the s for?

Sorry I was trying it out on my computer on drive s. I forgot to change it. Below is correct code.

Code: [Select]echo off
setlocal enabledelayedexpansion
for %%D in (a b c d e f g) do (
    for /f %%F in ('dir /a-d /b c:\bin\%%D*.*') do (
                set src=c:\bin\%%F
                set dest=c:\bin\%%D\%%F
                echo Source file: !src!
                if not exist "!dest!" (
                        echo Moving !src! to !dest!
                 move "!src!" "!dest!"
                 ) else (
                 echo !dest! already exists
                 )
       )
    )
Quote from: gitman7
and do I need every letter of alphabet in this: (a b c d e f g) ?

Well, you know that better than I do.




Thanks man!   

what does the %%D mean?

and the %%F?

1720.

Solve : Administrator: cmd.exe box and C:\windows\system32> prompt?

Answer»

Well this is what I see when I boot up the computer. Just a blinking DOS prompt after C:\windows\system32>

It is also in Safe Mode. 

I was trying to work around an issue that I was having booting up outside safe mode.  I must have clicked on something in the dialog boxes in start up and display that changed the way that I start up. I think it was something about alternate shell.   I just need to get BACK to normal safe mode out of this dos prompt.

Any help is appreciated.

HP Pavilion DV 2000
Windows VISTA Personal
The dialog box also says Version 6.0.6000

Thanks in advance I can not get into the system info to give you more about the system.

JOE Oh and I can still start task manager and can close the dialog box that is labeled

Administrator:cmd.exe

Thanks

MattOK I think I solved it. Forgive me as I am a complete novice at this. I USED the prompt msconfig and changed the settings back to what they were before.  I am still having problems with boot up and I will post that elsewhere.
Thanks
JoeLol, congrats?

1721.

Solve : Batch file to check file size then rename?

Answer»

I am currently trying to create a batch file to rename a log file to if it exceed 200kb. can anyone help me out.

i can rename the file with this command.

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "send.log" send%%e-%%f-%%g.log

 
but can anyone tell me what command to use for batch file to check it the log file exceed 200kb.

 
thanks in advance.

Welcome to the CH forums.

Start by checking the filesize:

ECHO off
cls

for /f "skip=4 tokens=4" %%a in ('dir send.log') do (
    set size=%%a & goto end
)

:end
set size=%size:,=%

if %size% gtr 200000 ren etc.....

Good luck1. If you use dir /b instead of plain dir you can avoid the tokens & skips. In any case you can get at the file properties directly without any DIR stuff at all or the /f switch by simply enclosing the filename in quotes.

2. File sizes are generally measured in powers of 2, and disk capacities using powers of 10, thus 200 kB file size ought really to be 204800 bytes. I don't suppose it matters, but I am a bit old skool about these things. Could lose marks if this is a school project!

An easy way to work it out



So,

3.

Code: [Select]for %%S in ("send.log") do set /a fsize=%%~zS
if %fsize% GTR 204800 (
   for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "send.log" send%%e-%%f-%%g.log
)

4. Alternatively, using variables to avoid hardwiring VALUES into the operational code (ANOTHER old skool thing!)

Using "magic numbers" is severely deprecated in programming courses (or should be)

Code: [Select]set maxlogsize=204800
set oldname=send.log
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do set newname=send%%e-%%f-%%g.log
for %%S in ("%oldname%") do if %%~zS GTR %maxlogsize% ren "%oldname%" "%newname%"

Either codes (3) or (4) should do the job as defined. However:

5. That method of slicing up the %date% variable will give different results if your locale settings do not use US date format. On my system, where currently, %date% expands to the non-US format, 08/08/2008 (day/month/year), send.log got renamed to send08-2008-.log

How to get a standardized date string (I would be interested if someone could check this works on US style dates)

I found this on alt.msdos.batch.nt - that set %%a= stuff looks kinda odd (=intriguing) but it seems to work...

Code: [Select]if "%date%A" LSS "A" (set toks=1-3) else (set toks=2-4)
for /f "tokens=2-4 delims=(-)" %%a in ('echo:^|date') do (
  for /f "tokens=%toks% delims=.-/ " %%i in ('date/t') do (
    set %%a=%%i
    set %%b=%%j
    set %%C=%%k
    )
)
if %yy% LSS 100 set yy=20%yy%
set Today=%yy%-%mm%-%dd%
echo %today%
Among other things, it pipes a CR to the date command & looks at the second line of the output to see what format the user is prompted to enter, it sees this in the UK:

Code: [Select]Enter the new date: (dd-mm-yy)

1722.

Solve : Semi-Adv questions. HELP!!?

Answer»

How do i get the batch file to support the drag and drop feature? Like, i want to be able to drag a file on to the batch and then it executes something like this:
program.exe droppedfile
also, part of the first question, if a users double clicks on the batch instead of dragging the file over it, is it possible to make it do the "choice" command?


question2: Right now im using this:
FOR /F "tokens=1*" %%G IN ('dir /b *.smc') DO Set smc=%%G
If [%smc%]==[] goto filenotfound

If it finds more than one file, how can i make it so the user can choose which one to use??Drag and drop?

Do you mean that you want to import content data from say a data file and use it within your batch?Example of drag and drop
Code: [Select]echo off
set /p ren=Select new name:
ren %1 %ren%%~x1
echo. Renamed to %ren%%~x1
pause >nulsave it as dnd.bat on a desktop
now you can rename files using drag and dropI mean when I drag a file on to the batch, I want it to be set as %smc% so I can use it like
program.exe %smc%
(where %smc% is the infile) Quote from: kaiyoken on August 07, 2008, 01:31:23 PM

I mean when I drag a file on to the batch, I want it to be set as %smc% so I can use it like
program.exe %smc%
(where %smc% is the infile)

do you mean grab the file with you mouse and drop it onto the batch program. then no you CANT do that. Batch files are not capable of detecting mouse clicks or movement. Quote from: macdad- on August 07, 2008, 01:41:58 PM
do you mean grab the file with you mouse and drop it onto the batch program. then no you cant do that. Batch files are not capable of detecting mouse clicks or movement.

Macdad, do you ever check before you write? I really WISH you WOULD start doing that. It's not hard. The rest of us do it. If you don't, it's called "running your mouth", I think, in American English. It is not helpful on a forum like this.

Create a batch file with this code in it

Code: [Select]echo off
echo %1
pause
1. Save it to a folder.
2. In Windows Explorer, drop a file or a folder onto it.
3. Tell us what happens.
oh cool! it shows the file
thanks!! Quote from: kaiyoken on August 07, 2008, 02:29:51 PM
oh cool! it shows the file
thanks!!

There you go...

Dias 1 Macdad 0



ok, now I have a problem. when I drag the file over it works and all, but the directory is reset. meaning is no longer the current folder it set to "c:\documents and setting\user" instead
PLEASE show your code
Dias when i read this

Quote
How do i get the batch file to support the drag and drop feature? Like, i want to be able to drag a file on to the batch and then it executes something like this:
program.exe droppedfile
also, part of the first question, if a users double clicks on the batch instead of dragging the file over it, is it possible to make it do the "choice" command?

i thought he ment grabbing the file from a folder and drop it on the batch window while it was running.

so sorry for being a chatter box Quote from: macdad- on August 07, 2008, 04:17:16 PM
i thought he ment grabbing the file from a folder and drop it on the batch window while it was running.

Well, you're right there, you can't do that.
here is my old one that works:
echo off
FOR /F "tokens=1*" %%G IN ('dir /b *.smc') DO Set smc=%%G
If [%smc%]==[] goto filenotfound
bin\movlm.exe %smc%
bin\cutdrv.exe %smc%
bin\cutsnd.exe %smc%
pause
goto end

and here is the one im trying to make work >.>
set %1
If [%1]==[] goto autofind
goto process1

---other part of code removed---

:process1
cls
cd
echo ===== cutting =====
bin\makesnd.exe %1
bin\importsnd.exe %1
echo ===== ------- =====
ping localhost -n 2 >Nul
pause
goto complete
the line

set %1

does nothing. What are you trying to do?

You cannot "set" %1. It ALREADY has a value.
hey i've posted first the example of dnd   


Code: [Select]set var=%1
If [%var%]==[] goto autofind
goto process1
1723.

Solve : Batch Rename Files?

Answer»

01-06-20080559100001.002
01-06-20080559130059.002
01-06-20080559170050.002
01-06-20080559200051.002
01-06-20080559210051.002
01-06-20080559240052.002
01-06-20080559280006.002
01-06-20080559310055.002
01-06-20080559350058.002
01-06-2008055942099.002
01-06-20080559520001.001
01-06-20080559550059.001
01-06-20080559590050.001
01-06-20080600020051.001
01-06-20080600030051.001
01-06-20080600060052.001
01-06-20080600100006.001
01-06-20080600130055.001
01-06-20080600170058.001
01-06-2008060024099.001
02-06-20080559100001.002
02-06-20080559130059.002
02-06-20080559170050.002
02-06-20080559200051.002
02-06-20080559210051.002
02-06-20080559240052.002
02-06-20080559280006.002
02-06-20080559310055.002
02-06-20080559350058.002
02-06-2008055942099.002
02-06-20080559520001.001
02-06-20080559550059.001
02-06-20080559590050.001
02-06-20080600020051.001
02-06-20080600030051.001
02-06-20080600060052.001
02-06-20080600100006.001
02-06-20080600130055.001
02-06-20080600170058.001
02-06-2008060024099.001
03-06-20080559100001.002
03-06-20080559130059.002
03-06-20080559170050.002
03-06-20080559200051.002
03-06-20080559210051.002
03-06-20080559240052.002
03-06-20080559280006.002
03-06-20080559310055.002
03-06-20080559350058.002
03-06-2008055942099.002
03-06-20080559520001.001
03-06-20080559550059.001
03-06-20080559560059.001
03-06-20080559590050.001
03-06-20080600020051.001
03-06-20080600030051.001
03-06-20080600060052.001
03-06-20080600100006.001
03-06-20080600130055.001
03-06-20080600140055.001
03-06-20080600170058.001
03-06-2008060024099.001
04-06-20080559100001.002
04-06-20080559130059.002
04-06-20080559170050.002
04-06-20080559210051.002
04-06-20080559240052.002
04-06-20080559280006.002
04-06-20080559310055.002
04-06-20080559350058.002
04-06-2008055942099.002
04-06-20080559520001.001
04-06-20080559550059.001
04-06-20080559590050.001
04-06-20080600030051.001
04-06-20080600060052.001
04-06-20080600100006.001
04-06-20080600130055.001
04-06-20080600170058.001
04-06-2008060024099.001
05-06-20080559100001.002
05-06-20080559130059.002
05-06-20080559170050.002
05-06-20080559210051.002
05-06-20080559240052.002
05-06-20080559280006.002
05-06-20080559310055.002
05-06-20080559350058.002
05-06-2008055942099.002
05-06-20080559520001.001
05-06-20080559550059.001
05-06-20080559590050.001
05-06-20080600020051.001
05-06-20080600030051.001
05-06-20080600060052.001
05-06-20080600100006.001
05-06-20080600130055.001
05-06-20080600170058.001
05-06-2008060024099.001
06-06-20080559100001.002
06-06-20080559130059.002
06-06-20080559170050.002
06-06-20080559200051.002
06-06-20080559210051.002
06-06-20080559240052.002




That is an example of a folder of files i have. however i need to take the first number of every file and take 1 from it. so the first file will change from 01-06-20080559100001.002  to  00-06-20080559100001.002

i have made a phpscript to do this. but now i need a batch file for when i dont have access to the internet

Any ideas?PHP? How can you use PHP to do it?Moved to appropriate section. Quote

<?php
$dir    = './Raw'; // Path to folder containing files to be renamed
$isleapyear = "y"; // If it is a LEAP year put in y, otherwise put in n
#########################################
#########################################
#########DO NOT EDIT BELOW THIS LINE#####
#########################################
#########################################
$filename = $dir.'/DONE.txt';

if (file_exists($filename)) {
        require ("makezip.inc.php");

        $zipfile = new zipfile();
       
        $filedata = implode("", file("makezip.inc.php"));

 $files2 = array_diff(scandir($dir), array('.', '..'));
  foreach($files2 as $value) :
        $zipfile->add_file($filedata, "./Raw/$value");
  endforeach;

        header("Content-type: application/octet-stream");
        header("Content-disposition: attachment; filename=zipfile.zip");
        echo $zipfile->file();

} else {
   $files2 = array_diff(scandir($dir), array('.', '..'));
   $i="1";
   echo "Folder: $dir
";
echo "Please Refresh the webpage once it finishes loading, it will take upto 2 MINUTES to finish refreshing, a zip file will automatically start downloading. Enjoy :-)
";
        foreach($files2 as $value) :
 
        $pieces = explode("-", $value);
      echo "$i Renamed
";
      $new = $pieces[0] -1;
      if($new < 10)
      {
         $new = "0".$new;
      }
      $oldfile = $dir."/".$pieces[0]."-".$pieces[1]."-".$pieces[2];
      ##### adjust month for 00 dates #######
      if ($new == "00"){

         if ($pieces[1] == "01")
         {
            $new = "31"; // LAST DATE OF JANURARY
         }
         if ($pieces[1] == "02")
         {
            if ($isleapyear == "y")
            {
               $new = "29"; // LAST DATE OF FEB on leap year
            } else {
               $new = "28"; // LAST DATE OF FEB not on leap year
            }
         }
         if ($pieces[1] == "03"){
         $new = "31"; // LAST DATE OF MARCH
         }
         if ($pieces[1] == "04"){
            $new = "30"; // LAST DATE OF APRIL
         }
         if ($pieces[1] == "05"){
            $new = "31"; // LAST DATE OF MAY
         }
         if ($pieces[1] == "06"){
            $new = "30"; // LAST DATE OF JUNE
         }
         if ($pieces[1] == "07"){
            $new = "31"; // LAST DATE OF JULY
         }
         if ($pieces[1] == "08"){
            $new = "31"; // LAST DATE OF AUG
         }
         if ($pieces[1] == "09"){
            $new = "30"; // LAST DATE OF SEPT
         }
         if ($pieces[1] == "10"){
            $new = "31"; // LAST DATE OF OCT
         }
         if ($pieces[1] == "11"){
         $new = "30"; // LAST DATE OF NOV
         }
         if ($pieces[1] == "12"){
         $new = "31"; // LAST DATE OF DEC
         }

         $newmonth = $pieces[1] - 1;
         $newfile = $dir."/".$new."-".$newmonth."-".$pieces[2];
         rename($oldfile, $newfile);
#############################
      } else {
         $newfile = $dir."/".$new."-".$pieces[1]."-".$pieces[2];
         rename($oldfile, $newfile);
      }
      $i = $i +1;
      endforeach;


   $handle = fopen($filename, "w+");
   fclose($handle);
   
}
?>

thats how i did it with php. there is alot of extra stuff in that script. hopefully someone knows howto do it in dos.Did you use that PHP script to change files on a web server? Or a home server?i uploaded files to the sever and it would rename them all at once. but now i need to be able to rename files on different pcs when im onsite. so i cant just install easy php for example on the pc to rename the files. a batch file would be perfectA batch script can make your LIFE easier and your codes more smaller. Or you can use vbscript to do that for you.  id love a batch script. PROBLEM is i have NO idea how to make it. im good with php and  bash. not dosThis batch script will probably do it.   To rename the files remove the :: on the Ren line after testing to ensure it will do what you want.   I have only tested it using six filenames.    You will also have to reset the in_file variable to suit your source directory.

Note: The code does not cater for space(s) in the path\filename, the Ren command will fail.

Good LUCK

Code: [Select]echo off
cls
setlocal

set in_file=d:\temp\badname\
for /f "tokens=*" %%a in ('dir /b %in_file%') do call :rename %%a
goto :EOF

:rename
set oldname=%1
set /a newdate=1%oldname:~0,2%-101
if %newdate% lss 10 set newname=0%newdate%%oldname:~2% & goto rename
set newname=%newdate%%oldname:~2%

:rename
:: ren %in_file%%oldname% %newname%

echo Old file name = %oldname%
echo New file name = %newname%
echo.
1724.

Solve : CMD configuration.?

Answer»

I seem to have ACCIDENTALLY change CMD's configuration....

Now when i open up just a normal COMMAND line it's in the wrong 'color' and size, i know the commands to change them but does anyone know how to reset / change BACK to normal config?

FBClick the ICON in the top left CORNER of the command window, choose properties, make changes until it is how you want, and when you click OK it will ask you if you want to save the changes for future windows.
Thanks

FB

1725.

Solve : BOOT.INI FILE MISSING?

Answer»

to make a long story short.  i deleted my boot.ini file.  its in my recycle bin.  i turned computer off and now have seemed to of lost everything.  i cant get back into windows 98 and i have access to dos.  can i open windows 98 from dos?  i am no computer expert but i have tried downloading boot files to no avail.  helpAt DOS prompt, type in:
scanreg /restore
Hit Enter. PICK up any date from before deleting boot.ini.Win98 doesn't have a boot.ini file, NT4/2k/XP use boot.ini when there is more than one operating system in use.Oooops. It's been a while.Having booted to the MS-DOS 7 prompt, in a Windows 98 system, you type WIN or c:\windows\win.com to start Windows, usually.

So what's with this boot.ini file, grace003? And why did you delete it?





Maybe, the above computer had dual boot, at some point.i have tried scanreg/restore and it says bad command or filename
i have tried typing in win and c:\windows\win.com it says "himem.sys is missing make sure that the file is in your windows directory.

this problem started when i was trying to install windows xp prof to update win98 and it wouldnt accept for some reason.  cant remember too long ago. then i tried to remove and accidentally hit enter to delete  boot.ini

does this all make a difference?That would explain boot.ini presence - XP installation leftover.
BTW, there is a space after "scanreg" in scanreg /restore command.
...and now I don't understand something...
You tried to upgrade to XP long time ago, but some problem started just last night?
no this problem happened a long time ago but was fortunate to have a loan of my sisters laptop so i didn't deal with the problem.  now she wants her laptop back and i need to get my computer fixed.  i did insert space but NOTHING..I believe, your ATTEMPT to install Windows XP messed things up. You may need to reinstall Windows.thank you for your help.  much appreciated..KEEP us posted

1726.

Solve : set a variable with the output of a command?

Answer»

OK, so in bash scripts, it is easy to do whatever you want with programs. if I want the date in the filename, i merely set the filename to be myfile-`date`.txt and the date is added. This is nearly impossible in batch scripting, but i have found out how.

my newest requirement is to have a multi-word command run, such as (for those who are familiar with SVN) svnlook author C:\Repositories\myproject This would output the name of the last person to check in code to myproject I'd like to have a variable with this name in it, such as set AUTHOR= svnlook author C:\Repositories\myproject That, of course, does not work. How can I MAKE it work?!I'm not sure if there's a better way but a work around would be to create an intermediate step...

Code: [Select] svnlook author C:\Repositories\myproject > auth
set /p Author=&LT;auth
del auth

FBit would betray my ignorance of batch scripting if I were to TELL you how long I have searched for this answer...

THANKS!  Glad to help

FB Quote from: OutThere on August 19, 2008, 02:10:38 PM

This is nearly impossible in batch scripting.

What does "nearly" impossible mean? SOMETHING is either possible or it is not. In FACT, including the date in the filename is a trivial task in batch programming.


my newest requirement is to have a multi-word command run, such as (for those who are familiar with SVN) svnlook author C:\Repositories\myproject This would output the name of the last person to check in code to myproject I'd like to have a variable with this name in it, such as set AUTHOR= svnlook author C:\Repositories\myproject That, of course, does not work. How can I MAKE it work?!
[/quote]

In general, we use the FOR command for this kind of thing.

If the output of command is a line of text we get the whole line into a variable like this

for /f "delims==" %%A in ('command') do set variable=%%A

where A is one of a-z or A-Z

 thanks Dias de VERANO, i hadn't thought of doing it that way before.

FB
1727.

Solve : Search for Files NOT OLDER THAN a Certain Date?

Answer»

Can anyone help with a command? I am trying to

1.) search a directory for files NOT OLDER THAN, say, 60 days.
2.) then within these files, i have to run a FIND command for a certain text string

I ran the FIND command on the files in the directory but I can't FIGURE out how to do it just on files BASED on a specified time span.

thanks very much,

MarkMark,

the best tool for this is robocopy.exe command line exe file, that you google and download from a microsoft website.

It can do what you need, for e.g. here is the switched that it uses for setting how old files you want to COPY or move:

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

here is a link for more info:
http://www.ss64.com/nt/robocopy.html

Geza

1728.

Solve : Disc Drive?

Answer»

Is there a code that can open or close a DISC drive? Batch file or other?http://www.dreamincode.net/code/snippet92.htm thats visual BASIC though or you could go to start my computer and right click on your cd drive and click ejectprank? first remote shutdown, now open/close cd drive?

not a prank, i just wanted to see if i could make a batch file (to run a program or code) to open and close my drives.Why.........?

I know exactly what Dias is talking about...I've had hands-on experience........... Quote from: EchoLdrWolf316 on August 19, 2008, 06:35:22 AM

not a prank, i just wanted to see if i could make a batch file (to run a program or code) to open and close my drives.
I have done this before. Quote from: Carbon Dudeoxide on August 19, 2008, 06:36:48 AM
Why.........?

I know exactly what Dias is talking about...I've had hands-on experience...........

im not trying to play a prank on my friends, ive read past posts. im not goina make their drives open, close open, close open, close open, close open, close open, close open, close. if i wanted to do that, i'd dowload a simple program off Cnet. Im just looking for code for myself Quote from: qinghao on August 19, 2008, 06:40:12 AM
Quote from: EchoLdrWolf316 on August 19, 2008, 06:35:22 AM
not a prank, i just wanted to see if i could make a batch file (to run a program or code) to open and close my drives.
I have done this before.
how? batch file, Visual Basic? or a DOS command line? Code: [Select]Option Explicit
Private Declare Function CDdoor Lib "winmm.dll" Alias "mciSendStringA" _
(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Select Case Button
        Case 1:
            Call CDdoor("SET CDAudio door open", 0, 0, 0)
        Case 2:
            Call CDdoor("set CDAudio door closed", 0, 0, 0)
        Case 4:
            End
    End Select
End Sub
this VB code I think you know how to use it .so.... Quote from: qinghao on August 19, 2008, 06:53:45 AM
Code: [Select]Option Explicit
Private Declare Function CDdoor Lib "winmm.dll" Alias "mciSendStringA" _
(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Select Case Button
        Case 1:
            Call CDdoor("set CDAudio door open", 0, 0, 0)
        Case 2:
            Call CDdoor("set CDAudio door closed", 0, 0, 0)
        Case 4:
            End
    End Select
End Sub
this VB code I think you know how to use it .so....
uhh?  save as what?

 
....................
Try google lol,, okDo you have Nero Burning ROM installed on the machine? Quote from: Dias DE verano on August 19, 2008, 01:18:16 PM
Do you have Nero Burning ROM installed on the machine?
I have a CD burner

Do you, or don't you, have a CD burning package called Nero Burning ROM?

1729.

Solve : Batch Files - Re Posted from another Section?

Answer»

I  have a Windows PC which cannot be connected to the internet.  I have installed Symantec Anti Virus 10.1.5.5000 and want to install VD updates which I have downloaded from another machine which can be connected to the internet.

The new virus definitions are on a CD and I have written the following batch file to enable the files to be copied into the appropriate directory.

copy x:\ *.* c:\Docume~1\alluse~1\applic~1\symantec\symant~1\7.5\

(x= drive letter of CD drive)

I want to pass the CD around 30 non-networked work stations whose users have restricted permissions. 

I want to AVOID manual TRANSFER because it will mean that I have to log in myself to 30 workstations as administrator to do it.

It doesn't work!  Any suggestionsI'm no expert but try this:

copy x:\*.* "c:\Documents and Settings\Path to Dir\Symantec\Symantec\7.5\"

I just edited your code so you can put the entire directory (instead of Docume~1)
You may have to fix it up a bit.Thanks but after running batch file with amendment I get an incorrect syntax command message. Quote

copy x:\ *.* c:\Docume~1\alluse~1\applic~1\symantec\symant~1\7.5\

Quote
It doesn't work!

The syntax for your command is correct. How does is not work? Error messages? Is the drive letter for the CD the same on all 30 machines?

One solution would be to put the batch file on the CD, along with an autorun file. The user would simply insert the disk and wait for the magic to happen.

 I'm not sure, but do you think Windows is prevent you from accessing 'alluse~1's folder?If it cant connect to the internet, why do you need anti-virus software?    Is it on a network?You don't know who is GOING to be using the computers..... 

However, you have a point.  It's not difficult to read...

Quote
I want to pass the CD around 30 non-networked work stations whose users have restricted permissions.

the user might bring in a virus on USB CD's ETC...

FB
1730.

Solve : How to extract a string from some text using a batch file.?

Answer»

I have some text in the form of drive:\folder1\folder2.
I would like to extract the last folder name (folder2 in this case) inside a batch file.
Could someone please help?
Thanks
first you need to set the string into a variable, im just going to assume you already know how , then you need to expand the variable using :~ heres an example:

set a=C:\folder\other
echo %a:~-5,5%


would echo other, open cmd.exe and type set /?where is this text stored? in a variable? or in a text file?The drive:\folder1\folder2 comes from:
set pname=%CD%

from pname I would like to extract the last folder name into another variable 'fname'.
ThanksI have an idea. Unfortunately, it doesn't work yet. I need some help with it.
The following is the code:

echo off
set curdir=%cd%
set n=0
:loop
set /a n=%n%+1
set inter=%curdir:~-%n%%
if not %inter:0,1%==\ GOTO loop
set /a n=%n%-1
set inter=%curdir:~-%n%%
echo %inter%
pause

I think that =%curdir:~-%n%% is wrong but don't know how to insert a variable inside the % signs.

Any ideas about how to fix this?
Thanks Quote from: Frank on August 19, 2008, 11:02:00 PM

I think that =%curdir:~-%n%% is wrong but don't know how to insert a variable inside the % signs.

You can't.

I won't be home for 8 hours to TEST this, but if you are actually logged in to %cd% as the current directory I think you could do a full DIR and using FOR with Find and appropriate tokens you could extract the folder name from the line which includes "Directory Of".

Yes I am logged into %cd%.
However, I don't understand "tokens" in a batch file and haven't used FOR before.
I'll wait for you. No problem.
Thanks
I checked, you don't need tokens. You need to parse the output of the cd command. Used without PARAMETERS, it echoes the corrent folder's drive letter and PATH to the console. The %%~nx FOR variable modifier extracts just the final part, the folder name.

Code: [Select]for /f "delims=" %%A in ('cd') do set foldername=%%~nxA
Some more examples of extracting information about the current folder:

1. folder-info.bat

Code: [Select]echo off
for /f "delims=" %%A in ('cd') do (
     set fullpath=%%A
set driveletter=%%~dA
set folderpath=%%~pA
set foldername=%%~nxA
set folderdate=%%~tA
)
echo.
echo -----------------------------
echo information about this folder
echo -----------------------------
echo.
echo Drive and path : %fullpath%
echo Drive letter   : %driveletter%
echo Folder path    : %folderpath%
echo Folder name    : %foldername%
echo Folder date    : %folderdate%
echo.
2. An example of output

Code: [Select]
S:\Test\Batch\curdir>folder-info.bat

-----------------------------
information about this folder
-----------------------------

Drive and path : S:\Test\Batch\curdir
Drive letter   : S:
Folder path    : \Test\Batch\
Folder name    : curdir
Folder date    : 20/08/2008 18:44



Thanks,
That's simple and brilliant.
Great solution to my problem
1731.

Solve : Find a string of text and wildcard text then copy it to the end of the same line?

Answer»

Could someone help me figure this out?  I am trying to take the below text string and find in it 25701-Tract then copy that text to the end of the same line separating by comma, then taking the second date which is at the end of the text line JUN 23 2008 12:05 PM and CONVERT it to 06-23-08 and then move it also to the end of the text line after 25701-Tract separating by comma.

Skip the first date. Question - Is there a way to use a wildcard in a date variable? Example: If = JUN (wildcard) 2008 rename it to 06-23-08 because the dates are always different.


Example Text string:
070000150,Request,42219,,XXXXX,XX,,XXXXXX,XX,XXXXX,,,,,025701-Tract 46-X-XXXXXXXX XXX- XXXXX X-EAST-,JUN 15 2008 02:45 PM, Denied ,JUN 23 2008 12:05 PM, Temp

Thanks for your help.
I've nearly got what you need, the first part works fine you can add the Tract thingy to the end of the text file it's just i can't get SET to work... :S

Code: [Select]for /f "tokens=1-15 delims=,-" %%A in ('type test.txt') do (
echo , %%I %%J >>test.txt
 set num=%%O
)

for /f "tokens=1-3 delims= " ("%num%") do (
set mon=%%1
if %mon% == JAN set month == 01 ELSE
if %mon% == FEB set month == 02 else
if %mon% == MAR set month == 03 else
if %mon% == APR set month == 04 else
if %mon% == MAY set month == 05 else
if %mon% == JUN set month == 06 else
if %mon% == JUL set month == 07 else
if %mon% == AUG set month == 08 else
if %mon% == SEP set month == 09 else
if %mon% == OCT set month == 10 else
if %mon% == NOV set month == 11 else
if %mon% == DEC set month == 12 else
)
set yy=%%3
set %yy:~2,2%

echo , %mon% %%2 %yy%>>test.txt

pausescrap the last one this should work:

Code: [Select]echo off
setlocal ENABLEDELAYEDEXPANSION

for /f "tokens=1-21 delims=,- " %%A in ('type %CD%\test.txt') do (
set tract= %%I %%J
set mon=%%R
set yy=%%T
set day=%%S
)

rem R = months S = day T = year

if !mon!==JAN set month=01
if !mon!==FEB set month=02
if !mon!==MAR set month=03
if !mon!==APR set month=04
if !mon!==MAY set month=05
if !mon!==JUN set month=06
if !mon!==JUL set month=07
if !mon!==AUG set month=08
if !mon!==SEP set month=09
if !mon!==OCT set month=10
if !mon!==NOV set month=11
if !mon!==DEC set month=12



set yy=!yy:~2,2!
echo , !tract!, !mon! !day! !yy! >> test.txt
thanks go to Dias de Verano

FBYou Guys did Great!  Thanks for the help...


Ken

1732.

Solve : gobang?

Answer»

two player play it     
CODE: [Select]echo off

mode con cols=48 lines=23
color f0
set ab=  ┏━━━━━━━━━━━━━━━━━━━━┓
set ac=  ┃   1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9┃
set a=  ┃A ┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┐┃
set b=  ┃B ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set c=  ┃C ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set d=  ┃D ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set e=  ┃E ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set f=  ┃F ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set g=  ┃G ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set H=  ┃H ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set i=  ┃I ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set j=  ┃J ├┼┼┼┼┼┼┼┼╋┼┼┼┼┼┼┼┼┤┃
set k=  ┃K ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set l=  ┃L ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set m=  ┃M ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set n=  ┃N ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set o=  ┃O ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set p=  ┃P ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set q=  ┃Q ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set r=  ┃R ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤┃
set s=  ┃S └┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┘┃
set ad=  ┗━━━━━━━━━━━━━━━━━━━━┛
set shu=0
:start
echo %ab%
echo %ac%
echo %a%
echo %b%
echo %c%
echo %d%
echo %e%
echo %f%
echo %g%
echo %h%
echo %i%
echo %j%
echo %k%
echo %l%
echo %m%
echo %n%
echo %o%
echo %p%
echo %q%
echo %r%
echo %s%
echo %ad%

set qi=
set /p qi=输入要下棋的位置 如:10j   
if "%qi%"=="" goto start

set lie=%qi:~0,-1%
set /a u=%lie%+4
set /a V=%lie%+5
set hang=%qi:~-1%
if %shu%==0 set sai=●
if %shu%==1 set sai=○
call set zi=%%%hang%:~%u%,1%%

if %lie% geq 1 (
if %lie% leq 19 (


if "%zi%"=="●" goto start
if "%zi%"=="○" goto start

call set %hang%=%%%hang%:~0,%u%%%%sai%%%%hang%:~%v%%%

for %%i in (0 1 2 3 4 5 6 7 8 9 t u v w x y z) do if %hang%==%%i goto start


if %shu%==0 (
set shu=1
) else (
set shu=0
)
)
)

goto start
I don't get it......are you showing it to US or do you have a problem with it?It is a game,a chess game for two person to play.
As known as gobang chess.Fascinating........how do I get it to work?copy all lines in the code area ,
save it as a batch file(.bat)
run it
there is a prompt to tel you to input the location(like coordinates) where place the chess pieces.
the prompt is in Chinese.
I tried to translate it into English(as follows):
Chinese:
Code: [Select]set /p qi=输入要下棋的位置 如:10j    English:
Code: [Select]set /p qi=Please input the location of chess like:10j
enjoy it!a batch file game.
Hmmmm......Doesn't work for me.

This is what I get:


When I enter something, it closes.Told ya it was fascinating...xdao,I know this guy.
this batch work OK on my computer because of that both xdao and me are use
SC(Simplified Chinese) Windows.
the batch is design under the Chinese environmentHmmmm.....that's a problem then.

I know at my dads office they have Chinese computers. I will have to try there.Anyone else find this a bit odd?How so?It just strikes me as odd that SOMEONE would register for the sole purpose of posting a batch game.The source code of this game  is given,you can learn teh batch file grammar from it.

1733.

Solve : How to Read and delete a character from a text file??

Answer»

Hi FRIENDS,

I NEED to your help with resolving this issue.

Actually I need to open a text file (D:\a.txt) and I need to read that file character by character. When the Character count reaches 226 I need to delete that character. An then I need to start my count from next chracter.

Is it possible to perform in DOS....

PLEASE help me to resolve this issue...

Thanks In Advance

Thanks,
Vinothhow does your file look like. For the simplest CASE, you can do substring from 1st char to 225, then do another substring from 227 till the end. check for /? for more information ( or set /? )

1734.

Solve : taskkill windowtitle no longer works.?

Answer» SINCE disabling UAC in vista, all my command windows now have the title Administrator: *title*.

I used to USE the code: Code: [Select]taskkill /FI "WINDOWTITLE EQ *title*">Nul but that no longer WORKS, I've also tried Code: [Select]taskkill /FI "WINDOWTITLE eq Administrator: *title*">Nul and that doesn't work either. Does anyone KNOW what the title should be in order for taskkill to work?

cheers

FBLikely an error in the syntax, neither command works for me
1735.

Solve : Documentation error :- START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE |?

Answer»

Upon "Start /?" in a command line Windows XP responds with
START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED] etc. etc.

Your documentation is identically wrong.  Would you please fix it.

It should READ :-
START "[title]" [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]

The actual title is optional - the quotes are sometimes mandatory.

This works
Start /LOW program

This does NOT work
Start /LOW program parameters
That results in a dos error complaining that it cannot find file "parameters"
but after closing the error box it then runs the specified program.
It cost me a lot of time and experimentation before I found quotes were essential,
i.e. no problem with
Start "" /LOW program parameters

My proposed correction is quite pedantic, but is essential and would have saved me a lot of effort.
This correction is very subtle and some people may fail to notice the implication of what is excluded from the [], so I would SUGGEST it be supplemented with an explanation, perhaps detailing when the quotes need to be INCLUDED or when they may be omitted.

NB I only report my observations upon what I had to do to use this command - I am probably blissfully IGNORANT of other "gotchas" with this command.  I found this problem with Windows XP Home Edition and Service pack 3.

Alan

1736.

Solve : Error Messages -- how to skip?

Answer»

When I copying some files I get an access denied message an my BATCH stops.  How do I tell the batch to skip over the access denied and CONTINUE the copying?

I am USING Win2000 and using a batch to backup files to an external HARD drive.  If you're using xcopy. the argument /C will skip over errors.

FB

1737.

Solve : QUERY: install boot disk/cd into C:\?

Answer»

Am wondering, you know those MS-DOS or Windows 98 boot disk/cd, can they copied/installed into C:\ and make C:\ bootable?Make C:\ Drive bootable? That's what happens when you turn on your computer. It uses the files in your hard drive to boot from.

Are you trying to install Win98 instead of another OS?Lets say one got a blank hard disk (partitioned & formated but blank). If you just copy MS-DOS files (from any boot disk, eg. Win98), then that is not enough to make C:\ bootable.

The files IO.SYS and MSDOS.SYS (which are hidden and system attribute set) needs to be in the 1st sector of the harddrive (basically the very first files written). Am not sure whether they are the MBR but the MBR needs to be set.

Ofcourse in Windows XP there's MBR FIX tools, but I do not know any in MS-DOS or Windows 98.

I guess format /s makes a drive bootable... have you tried this?

http://www.bootdisk.com/

It has a a download section as well as how to guides for vista/xp and 9x

FBYep I can make the boot disk/cd. But they just boot the pc. Just wondering about INSTALLING it to C:\

You have to have a genuine Microsoft install CD to install windows. That should have instructions on it on how to do that.

FB Quote from: fireballs on August 24, 2008, 11:19:20 AM

You have to have a genuine Microsoft install CD to install windows. That should have instructions on it on how to do that.

FB: He/she wants to install Win98 instead of the current OS, correct?that's the way I see it.

FBThe answer to the OP's question is "yes".

1. Set the computer to boot from CD
2. Boot up.
3. Using the DOS format command, format the C: drive
4  Copy the  folder structure including all files and folder to the C drive
5. Using the DOS sys command, make the c: drive bootable with sys c:
6. Change boot order in BIOS to boot from hard drive.


Thanks guys for your replies. Yes I totally FORGOTTEN about "sys c:" back from the oldskool DOS days. I believe sys command places io.sys & msdos.sys files in the first sector of the partition so that they get bootstrap LOADED on hard disk startup ... hence bootable.

I think I now know how to create my own bootable CD from scratch... building the 1.44MB boot image and using a good cd builder app to load the boot image (MagicISO, Nero, etc.)
1738.

Solve : Priority inheritance after Start "" /LOW?

Answer»

I had to add this extra line of code to the start of a batch file :-

if %1#==# start "%~n0 %TIME%" /LOW CMD /C %~n0 %TIME% && EXIT

The purpose of CMD /C %~n0 %TIME% && EXIT is to invoke itself again with %TIME% as an argument so the %1#==#" comparison will not sit in an endless loop - and since I needed any old argument I chose %TIME% as something of interest.

My principle questions are, when the remainder of the script is executed at low priority which may be suspended when Windows thinks of anything (e.g. disk defrag) to fill up "idle" time, if this LOW priority script invokes DOS or Windows executables, is this low priority inherited by :-
1. DOS commands - i.e. fc, copy, xcopy, etc., e.g. if xcopy was used to copy some folders, would its copy activity inherit the same "idle" priority and subject to defrag etc. ?
2. Windows applications - e.g. if this script finished by launching a Windows Browser, and then the script ended and the Command Window closed, would the Windows Browser be left running at normal priority, or would this also encounter suspension whilst copying FILES because Windows decided to run defrag etc. ?

A supplementary question :-  I launch this application from a shortcut in my start-up folder.  Originally I tried editing the shortcut my preceding with
START "" /LOW
but that only got an error that START was not recognised - is there a simple fix to the syntax, or is this just impossible ?

PURPOSES

At system start-up I run a batch file to inspect/compare system statistics.
It always used to work before hitting Windows XP Home with Service Pack 3.
Now the relevant system files are not always available before inspection/comparison. but the first line addition means the comparison is held pending for 50 Seconds whilst the system files are updated.

Because of a different problem with SP3 there is a higher probability that the clock will sit alone on the bottom right corner, i.e. everything starts as it should, BUT the relevant icons fail to appear, and I no longer have immediate control of Volume, Safely Remove Hardware, etc.  This is especially true if ESET NOD32 detects and installs a virus update during system start-up.
I am trying to reduce the prolonged high processor activity at start-up to see if this helps, and am now thinking of launching Xplorer2 (a double windows explorer) as the script concludes, instead of using a start-up folder link - but I don't want to degrade its speed of folder copying.

Alan
Quote

My principle questions are, when the remainder of the script is executed at low priority which may be suspended when Windows thinks of anything (e.g. disk defrag) to fill up "idle" time, if this LOW priority script invokes DOS or Windows executables, is this low priority inherited by :-

Batch files run at the same priority as the command shell. If you run your batch file in a shell window started by:

Code: [Select]%comspec% /c start /low %comspec%

you'll see in task manager that the command shell runs at low priority. Presumably so do all batch programs that utilize that instance of the shell program.

Code: [Select]%comspec% /c start /low <path to started file>

If a Windows program is started at the command line using the method above, it runs at the priority the user sets. If a Windows program is launched from the command line without being started, it runs at the priority the programmer wrote it for, unless the program has switches to modify the priority.

I am not aware that Windows invokes defrag during idle. Is this a user setting? I do know the indexing service can run at idle, but many people turn off this "feature".

Can you not use the sleep or ping command to kill 50 seconds?

 Thank you very much.

I have previously used Task Manger to find out what was hogging the CPU and to kill the culprit, but I never saw, nor was aware of, the ability to see priority levels.
After your advice I spent 5 minutes with Task Manager and found that View had the option to show the base priority level column.

Now I can see for myself the consequences of my actions BEFORE they bite me in the rear !

You not only gave me a fish for today, you gave me the tools for fishing myself tomorrow !!!

I may have used incorrect terminology when I said Windows runs defrag during idle time.  This is my understanding of why the disc light on my laptop seems to randomly burst into action when I am doing nothing.  The new to me column now shows me that 24 processes are running "Normal", 3 are "High" (why is winlogon.exe set "High" - surely I only need it when I log-on on at start-up ?), whist jqs.exe is "low" and DKService.exe is "Below Normal" - that is my defrag which I thought of as being "idle time".

My START "" /LOW addition results in a delay whilst Windows is busy starting up.  This typically is only 15 to 20 Seconds, but this last day and perhaps 8 start-ups I have seen delays of up to 50 Seconds when ESET NOD32 finds a fresh virus signature (which can be "giganormus") to install.  There may be other situations tomorrow or next month that could require longer than 50 Seconds - and I dread to think what will happen when the next Patch Tuesday comes around !!!

So holding off my script until CONCLUSION of the busy start-up is effective, involves minimal delay, and will wait for 50 or even 500 seconds when need arises.
A fixed 50 second delay would often be excessive, but occasionally inadequate.

Before I discovered START "" /LOW I did consider using SLEEP, BUT when I DOWNLOADED and saw sleep.exe was 124 KB I reconsidered.
My first P.C. was a second hand deluxe model with the extra size 20 MEGABYTE hard drive.  This established the criteria by which I judge the size of any download.  Now I have been dragged screaming and crying out of DOS and into Windows I cannot shake off my upbringing that small is beautiful !!!

As a matter of interest, just in-case I have a future need for a "sleep delay" without the burden of a 124 KB executable, how would I use PING, preferably without aggravating some innocent internet user who might retaliate - especially if I hit someone that has control of a zombie army !!!

Just one detail remains - I tried to PREFIX a shortcut with "START /LOW" but it never worked - do I need a special syntax, or is this simply impossible ?

Once again, many thanks.

Alan
Some users think ping is a kludge, but I find it keeps with the KISS method of coding. It also does not require a download:

Code: [Select]ping -w 1000 -n 51 127.0.0.1 > nul

The above code is for 50 seconds (the first ping is nearly immediate) Note: 127.0.0.1 is your local machine, no need to worry about retaliation.

I couldn't get a shortcut to a batch file to work; shortcuts are pointer files that only seem to confuse the shell program. Perhaps you can start the program from it's home directory:

Code: [Select]%comspec% /c start /low <path to program>

Good luck 
Thank you for all your help.  All my questions on this are now fully resolved.

I have made a note of your ping delay code.  I do not need it now but I am sure I will find a use for it soon.

nb  ping met a special need last year :-
My broadband speed connection was very erratic
http://myspeed.visualware.com/ has a super speed test - it not only gives numbers, it also gives graphs of instantaneous speed and delay, and these showed that when I had a bad connection, it was actually full speed for about 200 to 400 mSec about once a second.  This gave me good ammunition against my ISP - but their first line Technical support still wanted me to re-check all my cables and telephone filters !!!

Then I used DOS to launch a a prolonged burst of pings at 50 mSec intervals, simultaneously with the Windows Speed test, and the Speed test showed the same 500 to 800 mSec intervals each second of zero speed, whilst the ping replies just kept on happening without any loss or delay - clearly demonstrating "Traffic Management" that was affecting my TCP packet speed test, but allowing unrestricted ICMP packets without delay.

Once again, many thanks
Regards
Alan
1739.

Solve : Batch Message?

Answer»

What is the code to make a message appear in a batch file, and what is the code to make it wait for a set amount of time?  Code: [Select]echo text
echo.text
echo %variable%
Code: [Select]ping -n 1 -w "number of miliseconds" 1.1.1.1
ex.

Code: [Select]echo I like Batch
ping -n 1 -w 1000 1.1.1.1 >nul
cls
this will echo "i like batch" text wait 1 sec and then clear the screen Quote from: devcom on August 25, 2008, 04:16:43 PM

Code: [Select]echo text
echo.text
echo %variable%
Code: [Select]ping -n 1 -w "number of miliseconds" 1.1.1.1
ex.

Code: [Select]echo I like Batch
ping -n 1 -w 1000 1.1.1.1 >nul
cls
this will echo "i like batch" text wait 1 sec and then clear the screen

both work perfect, but is there a way to make it wait without displaying anything..., and how do i make it change the title of the DOS windowchanging title is just Code: [Select]title "enter title here"
if you've got the >nul  the waiting code shouldn't PRINT anythnig to the screen.

alternative ping wait: Code: [Select] ping -n 'No. of second' 127.0.0.1>Nul
where 'No. of seconds' is replaced by the number of seconds you want to wait. It's not particuarly accurate though.

FB Quote from: fireballs on August 25, 2008, 04:24:58 PM
changing title is just Code: [Select]title "enter title here"
if you've got the >nul the waiting code shouldn't print anythnig to the screen.

alternative ping wait: Code: [Select] ping -n 'No. of second' 127.0.0.1>Nul
where 'No. of seconds' is replaced by the number of seconds you want to wait. It's not particuarly accurate though.

FB
ok, thanks works perfectly 
Code: [Select]echo off
title Macilizer
echo Macilizer starting...
ping -n 1 -w 2000 1.1.1.1 >nul
echo Initializing...
ping -n 1 -w 500 1.1.1.1 >nul
Choice /M "Do You Want To Run Mac Look-Alike PROGRAMS?"

If %errorlevel% EQU 2 goto no
If %errorlevel% EQU 1 goto yes

:yes
echo Starting Battery Meter
ping -n 1 -w 2000 1.1.1.1 >nul
start "" "C:\Program Files\Mioplanet Battery Meter\Mioplanet Battery Meter.exe"
echo Starting Konfablator
ping -n 1 -w 2000 1.1.1.1 >nul
start "" "C:\Program Files\Pixoria\Konfabulator\YahooWidgets.exe"
echo Starting Object Dock
ping -n 1 -w 2000 1.1.1.1 >nul
start "" "C:\Program Files\Stardock\ObjectDock\ObjectDock.exe"
ping -n 1 -w 2000 1.1.1.1 >nul
echo Exiting....
ping -n 1 -w 2000 1.1.1.1 >nul
exit

:no
echo Exiting....
ping -n 1 -w 2000 1.1.1.1 >nul
exit
1740.

Solve : FTP corrupts images??

Answer»

When I try to upload an images to my website using the ftp command 'put,' the image Always turns out blank.

Does this happen to anyone else?

If I start out with a local image, say image.jpg, and upload it to my WEBSERVER using the cmd ftp, the image comes out on the webserver a completely blank, but the resolution is still there, and the size is correct.

Does anyone have a solution?What FTP transport software are you using? There are MANY...NEVER used this FTP method ... and equally never had your problem.  Is this a new problem or - have you just stated FTP'ing?

I have used WS_FTP for years - just the old VERSION and it does well.  There are tho some freebies out there - many - some I think on Sourceforge.net, probably too on freeware.com.

I'd suggest getting a regular FTP app and using that.  Puzzling tho why you get the blacking out and yet PROPERTIES still seem there.   - it's almost as if (if jpg) SOMETHING is amiss with decompression.Switch to 8 Bit (BINARY) File transfer, if you could upload file.txt, and it would be appear file but not file.jpg , then its being sent in text mode and not binary mode.. if you are using ftp.exe, just type binary before you send the fileAhaha - had not thought of that - the old ASCII image upload!!

Good thinking.Perfect! Thanks a lot!

Code: [Select]binary
put image.gif

1741.

Solve : Batch script to check a result from a query.?

Answer»

I am trying to create a way to check the result of a query.

code I am using

sc query "World Wide Web Publishing" > web.log

Then from here I need it to check the web.log for "RUNNING" if its runnning goto:up

If its not "RUNNING" goto:down

I have the program to send me the email I just don't know how to code the check of the web.log

:up
exit
:down
blat email = myaddress.commay i suggest...

Code: [Select] find "running" c:\%pathtofile%\web.log
if errorlevel 1 goto down
exit

:down
blat email = myaddress.com
please GET back to say WHETHER this works or not

FBor this

Code: [Select]sc query "World Wide Web Publishing" > web.log
type web.log | find "RUNNING">NUL && goto up
goto down
Thanks a bunch I used the if errorlevel 1 and this is working great.I have added the example for others if they need it this is not a full proof way to check your IIS Site and Service but it will do a basic check for if the IIS is up and if the Service is up and then email me if it is down.

It does use wget to DOWNLOAD the index.html so you WOULD nee that program to use this code.  Also it uses a program called blat to email me.


del "index.html"
sc query "Service" > service.log
find "RUNNING" service.log
if errorlevel 1 goto :down
wget --output-file=wget.log http://domainname
If exist "index.html" goto :up
If not exist "index.html" goto :down
:up
exit
:down
blat site.txt -to [email protected]

1742.

Solve : Copy folders in a batch?

Answer»

I am trying to use a bat to backup some folders but it won't copy the folders, only the loose files in the main folder.  How do I do this? 

I am also running into a problem with long names on some older files -- how do I tell the bat to skip that file and not stop the copying?what code are you using to copy the files at the moment?

you could try Code: [Select] xcopy /? to see if that would help.

do the longer file names have spaces in them?

FBI am using the xcopy.  Yes the names have spaces but this woman used to use very long names and it keeps telling me access denied.  I thought at FIRST it was because maybe the files were read only, but I checked and they aren't. 

When you say this woman, did she create the file your trying to copy... are they in her profile? That might be why your getting access denied.

alternatively are you running CMD as an administrator?

FBShe did create the document (word and excel) but there is no profile involved.  BASICALLY I am trying to back up her My Documents folder onto an external hard drive.  This folder contains a lot of folders that I can't make copy. 

I think the access denied is related to the fact that her file names a extremely long.  An example is "I had a discussion with George about new people walking by my office.doc" when I take a few of the spaces out then it copies without a hitch.  It does this on both excel and word docs. 

I don't know much about batch files that is why I am stumped, but I found this handy site and forum.  what version of windows are you running?

as long as you have quotation marks around the file names it shouldn't have a problem. i just copied a file called "whatever this file is called i'm going to change it.jpg" and it had no problem but i'm using vista.

If it works without the spaces we can build a workaround.

FBSo in the batch file I have to name the files?  I think that is a little more work than I want to do.   what version of windows are you running.

Do the files have any attributes.. hidden?

FB Quote

"I had a discussion with George about new people walking by my office.doc"

Xcopy will fail to copy a file if either the source or destination path and filename is, in total, more than 255 characters long.

That lady needs educating.


Sorry windows 2000 and yes I am working on getting her to shorten the names and not to use SYMBOLS (#$,&) she is getting there. 
Quote from: sukieb on August 23, 2008, 05:54:48 AM
I am working on getting her to shorten the names and not to use symbols (#$,&) she is getting there. 

Symbols are BAD NEWS especiall the &, known as the "poison character" because of its disruptive effect. This person needs to to go on a "Use of IT" course.



I figured it out!

I am not sure why this works but what I used is:

xcopy "c:\my documents\*" "h:\databackup\*" /m /e /y

That copies the folder and their contents plus only those files she has changed since the last backup.

My question is this -- will this take care of the error MESSAGE I get because of long file names?  I think it should since those will already be copied and won't change because they are old files. 


how does that only copy files that have been modified since the last backup?

/m copies files with archive attribute set.

/e copies files and directories, even empty ones.

and /y is default you don't need to add it.

if you want to copy files that have been changed since a certain date try  /d:m-d-y
which copies copies files that have been changed on or after the date m-d-y.

FB Quote from: sukieb on August 25, 2008, 10:09:42 AM

My question is this -- will this take care of the error message I get because of long file names?  I think it should since those will already be copied and won't change because they are old files. 

It's not just the file name length, but the total path length. They will not have been copied, and therefore the archive bit will still be set, and the message will RECUR.


Quote from: fireballs on August 25, 2008, 10:17:16 AM
how does that only copy files that have been modified since the last backup?

/m copies files with archive attribute set.


Read  the xcopy help again, fireballs.

  /M           Copies only files with the archive attribute set,
               turns off the archive attribute.
1743.

Solve : SubMenu?

Answer»

Hi,

I WOULD LIKE to know how to write a script to open a submenu in a program
as an example in

ADOBE Acrobat to open: File, Organizaer ,Open rganizer.

Thanks

What Language?In MS DOS if possible Quote from: Flash on August 27, 2008, 05:54:48 AM

In MS DOS if possible

 Not possible.......but maybe possible with a VBS Script....not sure...... Quote
but maybe possible with a VBS Script....not sure......

VBScript doesn't do windows very well EITHER. A better choice would be a HTA, the combination of HTML and VBS, no browser required.

  Quote
Adobe Acrobat to open: File, Organizaer ,Open rganizer.
what's it like can you send up a snapshot.
1744.

Solve : Look for specific string in file and use it?

Answer»

Here's what I want to do:

I have a file (sample.txt) that contains the setting of a variable, i.e.:

CellName=Comp1

I want to SEARCH for this variable (CellName) and use it's value (Comp1) as a value elsewhere, e.g. in a path:

cd C:\Comp1\

So FAR I can read through each line of the code USING

Code: [Select]For /f "tokens=* delims=" %%a in (sample.txt) Do (

if %%a == CellName ())
but I can't find the string I'm LOOKING for, or use it's corresponding value. Does anyone have any ideas and can help? Code: [Select] for /f "tokens=1-2 delims==" %%A in ('type %CD%\sample.txt ^| find "cellname"') do (
cd %%B
)

FB
Excellent, fair play to you.

you were nearly there, i take it that it works now?

FBYes, works well!

1745.

Solve : Machine Spec. help.?

Answer»

I have been tasked with obtaining some INFORMATION about the PC's in my building.  i have 100 pc's and i wish to determine the following.

1. The RAM
2. The processer, type, make etc.
3. the machine identifiaction code.

I was hoping to write a bat/cmd file etc. and e-mail a link of the file to the users in question and ge them to run the file and send a report back to me.

Can this be done?

Regards

DiarmuidI think it would be less work just to write them an email telling them to hit windows+pause/break and tell you what they see. Quote

I have been tasked with obtaining some information about the PC's in my building. 
Hmmm....What Building?lol,  sounds a bit dodgy.   

Basically, i'm a CAD manager and i am trying to asses what my mchine SPECS are for my cad operators, as i may need to upgrade some of them.  Just trying to get a feel for what i have.

FYI.  here is a batch file a student here figured out for me.  There is a start up batch for each user i will just call up the batch tomorrow, and assuming you log off tonight your'll be picked up.  I will hope to tell the batch to write to a location on the network.

Thanks for the help though.

Diarmuid


*******************

ECHO OFF

systeminfo.exe > temp.txt

ECHO OFF
find "Host Name:"  < temp.txt> %ComputerName%.txt
find "Processor(s):"  < temp.txt>> %ComputerName%.txt
find "Total Physical Memory:" < temp.txt>> %ComputerName%.txt
find "Virtual Memory:"  < temp.txt>> %ComputerName%.txt
find "Domain:"  < temp.txt>> %ComputerName%.txt
find "Logon Server:" < temp.txt>> %ComputerName%.txt

ECHO OFF
del temp.txt

clsI do the same THING but have the luxury of being able to be in windows XP to be able to quality control the systems.
I started out with BAT and moved on to scripts that can pull information directly from the windows API with out having to parse info or call on other windows programs using start/call etc.
Though I do have some machines that do not have an OS installed, I check the BIOS for time date ram/cpu etc

But to give you the degree of quality control we require, I have to check every aspect of the system from
  • HD/DVD-RW/FDD model number,
  • Ram size,
  • CPU speed,
  • BIOS revision,
  • windows version,
  • change windows product key code,
  • activate windows,
  • the time and date,
  • test burn a "CD",
  • test write a floppy,
  • test com1 and com2, LPT 1,
  • check HD filesystem type and size,
  • disable automatic updates,
  • change file sharing on a folder and set permission access to everyone,
  • setup a secondary partition and format it as NTFS,
  • check Intranet access via PING,
  • change another folder to not read only,
  • empty the recycle bin,
  • check device manager for ANY errors,
  • test USB ports,
  • deactivate windows,
  • as well as create a new SID as we use a single image to create thousands of these machines a YEAR, each costing about $1,200 US
It took roughly 30-45mins to do this manually and some steps were usually skipped either from forgetfulness or time crunches. I wrote a DOS file to help out with the CD burn test, ping test, and port test calling on a saved hyperterminal template to test com1 and then com2. which saved us about 5 mins per machine.
I later wrote a complete WScript File (.wsf) to be able to do all of these cutting QC time down to 5 mins, All the tech has to do manually now, is check the screws are in the right places...

Here's a javascript example
Copy PASTE it in Notepad rename it as Spec.js
The code can be setup to run remotely, or sent back to you as txt file etc. Pretty much anything you can do on your PC  you can access it via script, simply search google for msdn WMI tasks

Code: [Select]var wbemFlagReturnImmediately=0x10;
var wbemFlagForwardOnly=0x20;
var jsCrLf=String.fromCharCode(13, 10);
var jsQuote=String.fromCharCode(34);

//Windows Management Interface
function wmiCon(strComp){
try{
var objWMIService = GetObject( "winmgmts://"+ strComp +"/root/cimv2" );
}
catch(error){
var strMsg = jsCrLf + "WMI Connection Error # " + error + jsCrLf;
WScript.Echo(strMsg);
WScript.Quit(0);
}
return objWMIService;
}

function wmiSQL(wmiBase){
var objWMIService = wmiCon(".");
try{
var colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_" + wmiBase, "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly ); //query
}
catch(error){
var strMsg = jsCrLf + "WMI Query Error # " + error + jsCrLf;
WScript.Echo(strMsg);
WScript.Quit(0);
}
objWMIService.close;
return colItems;
}

var strMemTotal,strHostName,strDomain,strCpuCount, strCPUSpeed = "", strToAdd = ""
var colItems = wmiSQL("Processor");
var enumItems = new Enumerator(colItems);
for (x=0 ; !enumItems.atEnd(); enumItems.moveNext()) {
var objItem = enumItems.item();
if (x >= 1){strToAdd = ", " + x + ") "}
else{strToAdd = String(x + ") ")}
strCPUSpeed += strToAdd + objItem.MaxClockSpeed(x) + " MHz";
x++;
}

var colItems = wmiSQL("ComputerSystem");
var enumItems = new Enumerator(colItems);
for (x=0 ; !enumItems.atEnd(); enumItems.moveNext()){
objItem = enumItems.item();
strMemTotal = objItem.TotalPhysicalMemory;
strHostName = objItem.Name;
strDomain = objItem.Domain;
strCpuCount = objItem.NumberOfProcessors;
x++;
}
strMemTotal = strMemTotal / 1048576;
strMemTotal = Math.round(strMemTotal);

var strSaveto = "C:\\" + strHostName + ".txt"
var strSysInfo = "HostName: " + strHostName
+ "\nDomain: " + strDomain
+ "\nCPU Count: " + strCpuCount
+ "\nCPU Speed: " + strCPUSpeed
+ "\nMemory: " + strMemTotal + " MBs";

WScript.Echo(strSysInfo + "\n\nResults Saved to " + strSaveto);

var fso, f
var ForReading=1, ForWritting=2, ForAppending=8;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.OpenTextFile(strSaveto, ForWritting, true);
var strToReplace = /\n/g;  //g - global, i - case insensitive, m - multiline search
strSysInfo = strSysInfo.replace(strToReplace, jsCrLf);
f.write(strSysInfo);
f.close();
fso.close;
1746.

Solve : Parameters at command line question?

Answer»

I know I can take parameters at command line LIKE:

file.bat param1 param2 etc

and have them read in file.bat like:

%1 %2 etc

but is there a way to pass parameters using options, i.e.:

file.bat -pOne param1 -pTwo -param2 etc

and have them read in file.bat, i.e. get value of pOne and pTwo?

Any help appreciatedif your asking what i think then you can just add

Code: [Select]set Pone=%1% which will then set your first parameter to "Pone".

on second thoughts that doesn't seem to be what your asking but if it is hope it works. If i get you right this time you want to pass a parameter to the batch file that TELLS the batch file to get a value?

this can be DONE but it depends where this value is in the first place.

FBfireballs, you had one % sign too many. To set Pone to the value of the first parameter you would use

set Pone=%1


No, what I'm thinking of is a way of kinda setting variables as they are passed, for example:

Code: [Select]file.bat -user myUserName -PASSWORD myPassword
would allow me to access the -user value that was passed, i.e. userName and the -password, i.e. myPassword.

I suppose the whole point of the exercise is to be able to swap around the options, such as:

Code: [Select]file.bat -password myPassword -user myUserName
but that this command would still mean the same as the previous command.
Actually, just thinking there, I could check each parameter, e.g.:

Code: [Select]while (input parameters)(
if %1 == -user
(
 do something with %2
)

if %1 == -password
(
 do something with %2
)


check that %3 is -password if %1 -user
OR
check that %3 is -user if %1 -password

do something with %4
)
Excuse the pseudocode.

Not as clean as I would have liked but still should do the job. Quote from: Dias de verano on August 27, 2008, 01:00:09 PM

fireballs, you had on % sign too many. To set Pone to the value of the first parameter you would use

set Pone=%1

It works either way for me.

you could have:

Code: [Select] if %%1=="-password" GOTO password
if %%1="-username" goto username
exit

:username
if not %%2=="My Username" (exit) else (
if not %%4=="My Password" exit
)
goto code

:password
if not %%2=="My Password" (exit) else (
if not %%4=="My Username" exit
)
goto code
is that what your looking for?

EDIT: i think we had the same idea, you posted as i was writing a response.

FBThat's the one, thought there might have been an actual command.

Thanks.While I was posting a reply, I saw the red "While you were typing a new reply has been posted" warning.

If you think about it logically, you only have 2 possibilities for the parameter sequence

(a) %1 -user %2 username %3 -password %4 password
(b) %1 -password %2 password %3 -user %4 username

So if you look at %1 you will find out all you need to know

Code: [Select]if "%1"=="-user" (
    set username=%2
    set password=%4
    ) else (
    set password=%2
    set username=%4
    )

I suppose my thinking was that using %1 - %9 can be limiting, mainly due to the amount of parameters that can be passed.
You can pass any number of parameters, you aren't limited to 9, as you will see if you study the SHIFT command.

Also, the %* parameter expands to a string made up of ***all*** of the parameters passed.


I see, so the SHIFT command will keep shifting through parameters, so I could have a large amount of them.

Nice one.
1747.

Solve : UI To Edit A .bat?

Answer»

I'm trying to give my "Macilizer" a configuration UI......just a regular windows message box with 3 check boxes, descriptions for each, and a SAVE button instead of an OK button..... that could be run to configure what is to be run..

check boxes would read:
(box) Battery Meter
(box) Konfabulator
(box) Object Dock

...and checking or rechecking would add or remove the entries one by one:
Code: [Select]
echo Starting Battery Meter
ping -n 1 -w 2000 1.1.1.1 >nul
start "" "C:\Program Files\Mioplanet Battery Meter\Mioplanet Battery Meter.exe"


echo Starting Konfablator
ping -n 1 -w 2000 1.1.1.1 >nul
start "" "C:\Program Files\Pixoria\Konfabulator\YahooWidgets.exe"


echo Starting Object Dock
ping -n 1 -w 2000 1.1.1.1 >nul
start "" "C:\Program Files\Stardock\ObjectDock\ObjectDock.exe"

from the final .bat file
Code: [Select]echo off
title Macilizer
echo Macilizer starting...
ping -n 1 -w 2000 1.1.1.1 >nul
echo Initializing...
ping -n 1 -w 500 1.1.1.1 >nul
Choice /M "Do You Want To Run Mac Look-Alike Programs?"

If %errorlevel% EQU 2 goto no
If %errorlevel% EQU 1 goto yes

:yes
echo Starting Battery Meter
ping -n 1 -w 2000 1.1.1.1 >nul
start "" "C:\Program Files\Mioplanet Battery Meter\Mioplanet Battery Meter.exe"
echo Starting Konfablator
ping -n 1 -w 2000 1.1.1.1 >nul
start "" "C:\Program Files\Pixoria\Konfabulator\YahooWidgets.exe"
echo Starting Object Dock
ping -n 1 -w 2000 1.1.1.1 >nul
start "" "C:\Program Files\Stardock\ObjectDock\ObjectDock.exe"
ping -n 1 -w 2000 1.1.1.1 >nul
echo Exiting....
ping -n 1 -w 2000 1.1.1.1 >nul
exit

:no
echo Exiting....
ping -n 1 -w 2000 1.1.1.1 >nul
exit

can this be done........somewhat/remotely.............easily?


I do have Adobe Photoshop and Flash if I had to create a box, but i would need help to code itthere aren;t any checkboxes in DOS. I can think of ways to do it but not as graphically as yours.

FBno, i don't mean a DOS checkbox, just a windows box (or custom) with checkboxes that change the .bator, well what are you thinking of how to do it?or could i create a box in Adobe flash, and code the checkboxes so when a specific one gets checked, it runs a batch file to add and entry, and when it gets unchecked, it runs a batch file to remove that entry?I'm confused are you asking for help building a DOS file or are you looking for help making a message box?

FBan interactive message box, that will edit a batch file?



(wrong forum section? )


this should be in the Programming Section...... lol yes i think this should be in the programming section. Gah i can't suggest a WAY of doing it in DOS at the moment, have got to move house!!

FBI basically understand this:
Code: [Select]rem macilizer_config.bat
echo off
choice /m would you LIKE to run Mioplanet battery meter.exe?
if errorlevel 1 echo 1>macilizer_config.dat
if errorlevel 2 echo 0>macilizer_config.dat
if errorlevel 255 goto :eof

choice /m would you like to run YahooWidgets.exe?
if errorlevel 1 echo 1>>macilizer_config.dat
if errorlevel 2 echo 0>>macilizer_config.dat
if errorlevel 255 goto :eof

choice /m would you like to run ObjectDock.exe?
if errorlevel 1 echo 1>>macilizer_config.dat
if errorlevel 2 echo 0>>macilizer_config.dat
if errorlevel 255 goto :eof

exit
but can you explain this:
Code: [Select] for /f "tokens=* delims=" %%A in ('type macilizer_config.dat') do (
set %I%=%%A
set /a I+=I
)
set I=1
if %I%=1 (
echo Starting Battery Meter
ping -n 1 -w 2000 1.1.1.1 >nul
start "" "C:\Program Files\Mioplanet Battery Meter\Mioplanet Battery Meter.exe"
)
err, the config .bat just opens then CLOSES IMMEDIATELY...sorry scrap that attempt. I'm a little too busy to write and debug the code right now. Sorry

FBdunno what are you mean in this topic but i've edited the code above and should work now

Code: [Select]echo off
setlocal enabledelayedexpansion

echo.>file.txt


for %%E in (ObjectDock.exe YahooWidgets.exe Mioplanet_battery_meter.exe) do (
choice /C YN /M "Would you like to run %%E?"
echo %errorlevel% >>file.txt
)
call :START


:START
set num=0
set app_1="C:\Program Files\Stardock\ObjectDock\ObjectDock.exe"
set app_2="C:\Program Files\Pixoria\Konfabulator\YahooWidgets.exe"
set app_3="C:\Program Files\Mioplanet Battery Meter\Mioplanet Battery Meter.exe"

for /L %%a in (1,1,3) do (
for /F "tokens=1* delims= " %%b in (file.txt) do (
set /a num+=1
set tmp_!num!=%%b
)
)

for /L %%A in (1,1,3) do (
call set tmpa=!app_%%A!
call set tmpn=!tmp_%%A!
if '!tmpn!' equ '1' start "" !tmpa!
)

exit
ofc you have choice.exe ? Quote from: devcom on August 29, 2008, 11:52:03 AM

dunno what are you mean in this topic but i've edited the code above and should work now

Code: [Select]echo off
setlocal enabledelayedexpansion

echo.>file.txt


for %%E in (ObjectDock.exe YahooWidgets.exe Mioplanet_battery_meter.exe) do (
choice /C YN /M "Would you like to run %%E?"
echo %errorlevel% >>file.txt
)
call :START


:START
set num=0
set app_1="C:\Program Files\Stardock\ObjectDock\ObjectDock.exe"
set app_2="C:\Program Files\Pixoria\Konfabulator\YahooWidgets.exe"
set app_3="C:\Program Files\Mioplanet Battery Meter\Mioplanet Battery Meter.exe"

for /L %%a in (1,1,3) do (
for /F "tokens=1* delims= " %%b in (file.txt) do (
set /a num+=1
set tmp_!num!=%%b
)
)

for /L %%A in (1,1,3) do (
call set tmpa=!app_%%A!
call set tmpn=!tmp_%%A!
if '!tmpn!' equ '1' start "" !tmpa!
)

exit
ofc you have choice.exe ?

thank-you, yes i do have choice.exe, i will try this code when i get back home. (i am at my friend's house CURRENTLY) thanks devcom i had to move house, so i couldn't finish the code.

FB
1748.

Solve : Ebooks on DOS?

Answer»

Hi can anyone please suggest me an ebook on DOS ?

THANKS    DOS for dummmies 

http://www.dummies.com/WileyCDA/DummiesTitle/DOS-For-Dummies-3rd-Edition.productCd-0764503618.html
if you want to learn programming, don't use DOS.who said anything about programming? Quote from: BC_Programmer on May 30, 2009, 09:30:57 PM

who said anything about programming?
see my reply again. I use "if" ... it means i also don't know. so i am just guessing. Any problems with that?nope. Just seemed random to me is all!  Quote from: BC_Programmer on May 30, 2009, 09:33:05 PM
nope. Just seemed random to me is all! 
well..if one starts to write code, its more or less considered some kind of programming. If so, then why start with DOS? A real programming language would serve more of the purpose. A real programming language helps "visualize" programming concepts and data structures etc. Furthermore, they can do what DOS batch can do, and much more. Quote from: gh0std0g74 on May 30, 2009, 09:36:56 PM
well..if one starts to write code, its more or less considered some kind of programming. If so, then why start with DOS? A real programming language would serve more of the purpose. A real programming language helps "visualize" programming concepts and data structures etc. Furthermore, they can do what DOS batch can do, and much more.

well im sure he will eventually pursue programming. but batch requires no compiler\ program to program besides notepad and a mind.I started with Batch programming.

Nothing wrong with learning how the basics of scripting works before attempting other languages.

If I never learned how to make Batch files, I believe it would have been HARDER [for me] to learn other programming languages. Quote from: BatchFileBasics on May 30, 2009, 09:40:33 PM
well im sure he will eventually pursue programming. but batch requires no compiler\ program to program besides notepad and a mind.
oh really. how do you suppose your batch file runs? ever heard of cmd.exe? that's a program if you want to call it.command.com

I think, what he meant was there was no additional download. Not that that really provides a compelling argument.what im saying is that batch is a simple scripting language to start on to get an idea of syntax Quote from: BatchFileBasics on May 30, 2009, 10:30:22 PM
what im saying is that batch is a simple scripting language to start on to get an idea of syntax
batch syntax is ugly and batch doesn't have a lot of features already present in modern programming languages.
batch also tends to lead to inefficient code.
its true you can start with batch , but somewhere down the ROAD, you will find its limitations and what it can't provide. you would want to switch, so why not skip the whole DOS PROCESS and start learning how to do real programming now.yes batch isn't the best use of syntax but it gives the scripting virgins an idea of how syntax works.
and just jumping into a programming language LIKE c or vb6 looks very overwhelming. To be honest... because I used batch first it took me longer to understand QBASIC, which was my second step. I kept thinking of lines as commands and had no concept of statements or expressions.
1749.

Solve : Child Batch!!!?

Answer»

hi all there!!!

I need a batch to:
1. run on start of internet connection
2. after specific time with a password SHUT down internet connection
3. and if u try to reconnect don't let u unless u put the pass


is all these possible??? pls help the newbeiiiee!!!
tnhksCan you rephrase your question? Quote from: macdad- on May 27, 2009, 10:53:07 AM

Can you rephrase your question?
i need to creat this batch HAVR u got any idea?And you want this batch script to do what exactly? Quote from: macdad- on May 27, 2009, 10:58:01 AM
And you want this batch script to do what exactly?
to manage the time of my child's internet connection, i will put several pass, for ex.
with 12345&GT;>>1hour
with 32145>>>2hours
it's agood idea i think!Sounds like a good cause, but just to make sure:

You want to monitor how much time your child uses the internet(or just Internet Explorer or Firefox)?

And close it if he/she has used it more than so many hours? Quote from: macdad- on May 27, 2009, 11:11:04 AM
Sounds like a good cause, but just to make sure:

You want to monitor how much time your child uses the internet(or just Internet Explorer or Firefox)?

And close it if he/she has used it more than so many hours?
to shut down internet connection if he over time it!This is not really possible in Batch but there is free software designed for this use:
http://restrict-internet-access.vista-files.org/ Quote from: macdad- on May 27, 2009, 11:17:16 AM
This is not really possible in Batch but there is free software designed for this use:
http://restrict-internet-access.vista-files.org/
thanks mac i will check itYou could put a batch file in a startup script...and use the sleep command (downloaded seprately) and ipconfig /release (I think that should do it)...


Something like...

ECHO off
set timecount=3600
:loop
ipconfig /renew
sleep %timecount%
ipconfig /release
echo Password required to continue!
set /p pass=
if /i %pass%==PASSWORD1 set timecount=3600 & goto loop
rem 3600 is 1 hour.
if /i %pass%==PASSWORD2 set timecount=7200 & goto loop
rem 7200 is 2 hours.
echo Password is incorrect!
pause > nul
exitOr use Helpmeh's script, by the way nice script, never thought of ipconfig  one problem with that approach, is that an icon appears saying "limited or no connectivity" clicking that reveals  a dialog with the "repair" button, which renews the IP lease.Could create a for loop to check to see if Firefox or IE was started(Loop every second) but that would include Tasklist.

So it seems the software designated for such task would be the only option.or actual supervision.Just so you know....

The passwords can be easily viewed if you edit the batch file.
The batch file can simply be CLOSED to stop the timer.
1750.

Solve : Waiting to terminate??

Answer»

How can I make a batch file wait for a GUI application to close. Start /wait doesn't work with GUI applications (note the bolded text).

Quote

Starts a separate window to run a specified program or command.

START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/WAIT] [/B] [command/program]
      [parameters]

    "title"     Title to display in  window title bar.
    path        Starting directory
    B           Start application without creating a new window. The
                application has ^C handling ignored. Unless the application
                enables ^C processing, ^Break is the only way to interrupt
                the application
    I           The new environment will be the original environment passed
                to the cmd.exe and not the current environment.
    MIN         Start window minimized
    MAX         Start window maximized
    SEPARATE    Start 16-bit Windows program in separate memory space
    SHARED      Start 16-bit Windows program in shared memory space
    LOW         Start application in the IDLE priority class
    NORMAL      Start application in the NORMAL priority class
    HIGH        Start application in the HIGH priority class
    REALTIME    Start application in the REALTIME priority class
    ABOVENORMAL Start application in the ABOVENORMAL priority class
    BELOWNORMAL Start application in the BELOWNORMAL priority class
    WAIT        Start application and wait for it to terminate
    command/program
                If it is an internal cmd command or a batch file then
                the command processor is run with the /K switch to cmd.exe.
                This means that the window will remain after the command
                has been run.

                If it is not an internal cmd command or batch file then
                it is a program and will run as either a windowed application
                or a console application.

    parameters  These are the parameters passed to the command/program


If Command Extensions are enabled, external command invocation
through the command line or the START command changes as follows:

non-executable files may be invoked through their file association just
    by typing the name of the file as a command.  (e.g.  WORD.DOC would
    launch the application associated with the .DOC file extension).
    See the ASSOC and FTYPE commands for how to create these
    associations from within a command script.

When executing an application that is a 32-bit GUI application, CMD.EXE
    does not wait for the application to terminate before RETURNING to
    the command prompt.  This new behavior does NOT occur if executing
    within a command script.


When executing a command line WHOSE first token is the string "CMD "
    without an extension or path qualifier, then "CMD" is replaced with
    the value of the COMSPEC variable.  This prevents picking up CMD.EXE
    from the current directory.

When executing a command line whose first token does NOT contain an
    extension, then CMD.EXE uses the value of the PATHEXT
    environment variable to determine which extensions to look for
    and in what order.  The default value for the PATHEXT variable
    is:

        .COM;.EXE;.BAT;.CMD

    Notice the syntax is the same as the PATH variable, with
    semicolons separating the different elements.

When searching for an executable, if there is no match on any extension,
then looks to see if the name matches a directory name.  If it does, the
START command launches the Explorer on that path.  If done from the
command line, it is the equivalent to doing a CD /D to that path.
Although it says that it won't occur in the command script (bat file), it won't wait.In my testing 'start /wait notepad.exe' waits until notepad exits to continue.  try it Quote from: uSlackr on May 27, 2009, 10:42:19 AM
In my testing 'start /wait notepad.exe' waits until notepad exits to continue.  try it
Start /wait firefox.exe does not wait.
start /wait firefox.exe works for me as expected under Vista Quote from: uSlackr on May 27, 2009, 03:42:00 PM
start /wait firefox.exe works for me as expected under Vista
Try this and see...It only waits for it to load.

echo off
echo 1
start /wair firefox.exe
echo 2
pauseHelpmeh is right, start /wait doesn't wait for termination of any GUI program.
I forget the specifics but you'll need to write a program specifically for this.

using some goofy convolution of createProcess(). just start the process, and then call WaitForSingleObject() on the ProcessID.you could also make a loop to test to see if the process is still active. if the process is active wait and check again. Code: [Select]echo off

set appName=firefox.exe

start /wait %appName%
echo.App is running...
tasklist |findstr %appName% >nul && call WAIT
echo.App in not running...
pause

:WAIT
tasklist |findstr %appName% >nul || exit /b
ping -n 1 -w 1000 1.1.1.1 >nul
goto WAIT
sth like this ?That would only work on computers with tasklist, of course you could put tasklist into the same ZIP as the batch script.. Quote from: macdad- on May 28, 2009, 12:24:22 PM
That would only work on computers with tasklist, of course you could put tasklist into the same ZIP as the batch script..
Which is XP PRO and possibly Vista...I have Home edition...but I could get tasklist...This worked for me. I am on a PC running XP Pro.

Code: [Select]echo off

start /wait firefox.exe

echo on
Quote from: TheHoFL on May 29, 2009, 11:12:07 AM
This worked for me. I am on a PC running XP Pro.

Code: [Select]echo off

start /wait firefox.exe

echo on
echo off
echo 1
start /wait firefox.exe
echo 2
pause

Try that. It is supposed to wait until firefox closes...it only waits until it finishes loading."When executing an application that is a 32-bit GUI application, CMD.EXE
    does not wait for the application to terminate before returning to
    the command prompt."

The above specifies one exception -
" This new behavior does NOT occur if executing within a command script."

Perhaps there are other exceptions yet to be declared.

Firefox breaks the rules.  Is it a proper 32 bit GUI ?

I have just launched two instances of Firefox, and two of Notepad.
Windows Task Manager reports two instance of each on the "Applications" tab
and two Notepads but ONLY ONE Firefox on the "Processes" tab.

Incidentally, when all Firefox instance are closed, they disappear from the Applications Tab, and normally the Firefox process also shuts down, but sometimes it gets stuck and then CCleaner is unable to clear the Firefox cache until Task Manager has been launched and the Firefox process selected and terminated.

I think Firefox is not a suitable choice for evaluating what happens with "normal" software.


I am puzzled - what is meant by
" This new behavior does NOT occur if executing within a command script."

What was the OLD BEHAVIOUR that differs from the "new behavior" ?
Was it to wait for termination regardless ?
Was it to NOT wait for termination regardless ?
Was it that waiting was not subject to a 32 bit GUI restriction ?

What is "32-bit GUI application" ?
Does this apply to both windowed application and console application.

Does the above only apply when the /WAIT option is used ?
Or does it apply regardless (since this whole condition is not indented under the /WAIT description) ?

Regards
Alan
Quote from: ALAN_BR on May 30, 2009, 04:01:43 PM
but ONLY ONE Firefox on the "Processes" tab.
I get 1 per open window...

If you right click on each open task, and select go to process, it should give you more than one process.

Quote from: ALAN_BR on May 30, 2009, 04:01:43 PM
I think Firefox is not a suitable choice for evaluating what happens with "normal" software.
I'm not trying to evaluate "normal" software, I'm trying to wait for firefox to terminate. The quote I got from the command prompt (and my testing too), implies that start /wait will not wait for firefox to terminate, which is what I am trying to ACCOMPLISH.