Search found 3544 matches

by aGerman
09 Feb 2010 04:07
Forum: DOS Batch Forum
Topic: On Exit Do Command
Replies: 18
Views: 6938

Re: On Exit Do Command

My question was geared if you would need it for something special. Batch is a very primordial class. It is based on good old DOS and has a lot of limitations. Batch doesn't have any event handler. That means you can't figure out - which key is pressed - which mouse button is pushd - where the mause ...
by aGerman
08 Feb 2010 16:49
Forum: DOS Batch Forum
Topic: On Exit Do Command
Replies: 18
Views: 6938

Re: On Exit Do Command

No, you can't.
Also you can't disable Ctrl+C.

Why do you need it?

Regards
aGerman
by aGerman
08 Feb 2010 14:58
Forum: DOS Batch Forum
Topic: Find specific files from a directory and copy to a newfolder
Replies: 2
Views: 2040

Re: Find specific files from a directory and copy to a newfolder

lifeh2o Try if this will work for you. @echo off &setlocal set /a n=0 set /a m=0 for /f "delims=" %%a in ('dir /a-d /b /s "c:\*.log" "c:\*quiz*.htm"') do call :sub "%%a" goto :eof :sub if /i "%~x1"==".log" ( set /a n+=1 call set i=%%n%...
by aGerman
08 Feb 2010 05:24
Forum: DOS Batch Forum
Topic: On Exit Do Command
Replies: 18
Views: 6938

Re: On Exit Do Command

BAT Beginner

There is no command for such intention.
Batches are interpreted line by line. If you close the window this interpretation is interrupted and nothing else will go on.

Regards
aGerman
by aGerman
07 Feb 2010 18:26
Forum: DOS Batch Forum
Topic: Redirection Echo Output into .txt file
Replies: 3
Views: 2826

Re: Redirection Echo Output into .txt file

Chunter I don't know the given specifications, but if you have to process the data later you will get a problem if you can't find a data record in a single line. What ever. If you want to write it as a block you could do it like that :: [...] echo Total sales has been calculated as %total% echo Com...
by aGerman
07 Feb 2010 16:37
Forum: DOS Batch Forum
Topic: Redirection Echo Output into .txt file
Replies: 3
Views: 2826

Re: Redirection Echo Output into .txt file

Chunter You can't redirect the values to a file and to your screen using the same command, but you could write two command lines. e.g. echo Total sales has been calculated as %total% >>commlog.txt echo Total sales has been calculated as %total% But I think that's not exactly what you need. IMHO it ...
by aGerman
04 Feb 2010 09:09
Forum: DOS Batch Forum
Topic: Reverse command prompt action
Replies: 2
Views: 2032

Re: Reverse command prompt action

Peterr

Additional to !k's reply - the default line should be

Code: Select all

127.0.0.1       localhost


Regards
aGerman
by aGerman
03 Feb 2010 15:12
Forum: DOS Batch Forum
Topic: Create a batch to loop through files, run command & move
Replies: 3
Views: 3452

Re: Create a batch to loop through files, run command & move

Threep Your entire Batch is just one FOR loop written as a block. For your command line interpreter it looks like a single command line. Note that the expansion of variables occurs only one time during the run time of a command line. Thats why you can't see any changes of the %errorlevel% variable....
by aGerman
03 Feb 2010 07:39
Forum: DOS Batch Forum
Topic: How to check for installed softwares in a system
Replies: 5
Views: 2671

Re: How to check for installed softwares in a system

krisamigo sxekjb is right, this is also a possible solution. The first you have to do is allways searching for a meaningful key in the registry. Use any registry editor (e.g. regedit.exe). If you want to use the function of my url: @echo off &setlocal call :IsRegKey "HKLM\SOFTWARE\Adobe\Ac...
by aGerman
02 Feb 2010 14:15
Forum: DOS Batch Forum
Topic: How to check for installed softwares in a system
Replies: 5
Views: 2671

Re: How to check for installed softwares in a system

krisamigo There are different approaches. If it is a registered software you could have a look to your registry (HKEY_LOCAL_MACHINE\SOFTWARE) to figure out if a software is installed. See also http://www.dostips.com/DtCodeCmdLib.php#Function.IsRegKey . Otherwise you could look for a special exe fil...
by aGerman
02 Feb 2010 11:27
Forum: DOS Batch Forum
Topic: How to change all files to zero-byte?
Replies: 2
Views: 1682

Re: How to change all files to zero-byte?

auaa no idea what those could be good for Take a FOR loop and overwrite each file with 0 byte. @echo off &setlocal set "folder=C:\anywhere" pushd "%folder%"||goto :eof for %%a in (*) do ( type nul>"%%a" ) popd Every found file will be a blank file, also links! Rega...
by aGerman
01 Feb 2010 15:09
Forum: DOS Batch Forum
Topic: Batch for restart a services
Replies: 3
Views: 2388

Re: Batch for restart a services

avery_larry You are right. I misunderstood that kyosa asked for a service. net start | find /i "name of the service" >nul 2>nul || net start "name of the service" Will only try to start the service if it isn't running. Not that this method WOULD match partial service names. Exam...
by aGerman
01 Feb 2010 14:48
Forum: DOS Batch Forum
Topic: compare files and echo message
Replies: 7
Views: 3630

Re: compare files and echo message

pink I'm not sure about, but maybe you could use something like that. @echo off &setlocal for /f "delims=" %%a in ("T:\data\test.dat") do ( for /f "delims=" %%b in ("T:\arch\test.dat") do ( if "%%~ta"=="%%~tb" ( if "%%~za"==&...
by aGerman
01 Feb 2010 09:27
Forum: DOS Batch Forum
Topic: Redirecting both stdout and stderr to a single file... how?!
Replies: 2
Views: 2593

Re: Redirecting both stdout and stderr to a single file... how?!

PJonDevelopment

The solution is simple.

Code: Select all

call myOtherFile.bat>logFile.log 2>&1


Regards
aGerman
by aGerman
01 Feb 2010 03:30
Forum: DOS Batch Forum
Topic: Batch for restart a services
Replies: 3
Views: 2388

Re: Batch for restart a services

kyosa You could use TASKLIST and FINDSTR to test if a process is running. Notepad as an example: @echo off &setlocal set "process=notepad.exe" set "fullname=%SystemRoot%\notepad.exe" :loop tasklist|findstr /i /b /l /c:"%process%">nul||start "" "%full...