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.

2001.

Solve : Batch File Encryption.?

Answer»

I am sure when you read the title you thought this would be another "How do I encrypt my batch files?" thread. XP

I am not sure how to explain this, but I want to make a batch that pretty much does this;

Import text.
Change text.
Export text.

I do not fully understand the < and > commands quite yet, as I see no help for them in command prompt.
I know how to export something.

Echo Hi > C:\Test.txt

But I do not know how to use this to my advantage.

And I do not understand how to use the import currectly.
So...Lets say something along the lines of...

Make a text file that says Hi.
Import into my batch.
Change H to A
Change i to 9
Export
Now the txt says A9 instead of Hi.
Like,  somehow have the bat replace A's with B's, and B's with A's.  Or something like that.
If I could get how to make this, I could reverse it to decrypt the text as well.
But I am not exactly sure how to get this to work.
Of course,  I wouldnt use this as my primary way to Encrypt things. I am just trying to learn is all.
I already have a huge batch made up that will do this:

Work on startup, constantly close every application (Even taskmanager and Explorer) and ask for a password.  If the currect password is given, it will stop the process killing,  open explorer, and let you continue.
Just for fun and laughs really.






Also side question, how do I edit a txt file with cmd?  ASSUMING I know the line number, of course.
So lets say I wanted to change my password needed to continue my computer work;
The passwords are stored on line, 23, 28, and 45.
then go.
Xcopy Batch.bat Batch.txt
then edit batch.txt
Then use CALL to open up Batch2 (so Batch can be copied over). 
Then do:
Xcopy Batch.txt batch.bat
Then CALL again to go back to batch, DELETE batch.txt, then the password is changed.

I will use Third-Party programs if necessary.    (On either question)

RUNNING WindowsXP Media. SP2.Use a programming language eg Python or Perl, to do this.
Code: [Select]>>> print "hello".encode('rot13')
uryyb
the above generates rot13 of the word hello. Simple and just take few seconds. Of course, for full fledge encryption, use a well know algorithm such as AES or RSA using modules made for that such as PyCrypto. You can do similar things like this with Perl as well. Thanks for the reply.
But I want to make a batch file to Encrypt a text file, just to see if I can myself.
If I needed REAL encryption, or encryption that is pre-made,  I would have downloaded a different Encrypter like you said.

I want to make a batch that has a database (that I make of course)  that says like:
A=1
B=$
C=-
D=3 and so on and so on.

And and the same batch will replace, ABCD, with 1$-3.

Its just something I want to make myself.
Like my own little encryption system.

I just want to know if I can do it,  if so how?
Its for the pure fact if learning.  Like I said, if I wanted real encryption I could download something else like TrueCrypt or something, lol.the easiest way to do this type of "mapping" is by using a data structure called a dictionary or associative arrays.. a little example in Python
Code: [Select]>>> d={} # initialize associative array
>>> d["A"]="C"
>>> d["B"]="D"
>>> d["C"]="E"
>>> for character in ['A','B','C']:
...     print d[character]
...
C
D
E

cmd.exe doesn't support such data structures, so you would either go through character mapping one by one be using set and assignment each character with a  value and doing a lot of if/else checking , or completely dump batch and START to learn something more useful.Technically that isn't encryption, btw, it's actually called a cipher.

Not saying this to be a smartass, but rather because it might help refine your google searches on the subject Look at this:

set varname=%varname:A=!%
set varname=%varname:[email protected]%
set varname=%varname:C=#%

and so on and so fourth...XP Sorry ghost lol.   I learn whatever is entertaining for me.  Batch is VERY simple for the most part.
I mod games alot, going into it with a HEX editor,  trying to MEMORIZE things, etc.   
So going to batch to toy around for a while is simple enough that I can kinda relax on it for the most part and sometimes make something a little entertaining without having to put in too much thought.
I also know id need to make my own If/Else database of some kind.  I have no problem with that.  I acturally already thought I would have to.

BC:
Thanks,  I didnt even know that word existed lol,  maybe I can find something on google here in a sec after im done posting then.

Helpmeh:
I think I see what its doing there.
But how would I go about making batch load up C:\Test.txt (for example) to change the stuff inside it?
Like..

Load up Test.txt
Change number and letters.
Save Test.txtSo, you want something like this then?

echo off
setlocal enabledelayedexpansion
set filein=C:\test.txt
set fileout=C:\testout.txt
for /f "delims=" %%a in (%filein%) do (
     set origline=%%a
     rem Some characters require a ^ before them to prevent errors. I put it infront of all replacements
     rem just in case.
     set newline=!origline:a=^!
     set newline=!newline:b=^#!
     set newline=!newline:c=^$!
     rem ...
     echo !newline! >> !fileout!
)Perfect.
Exactly what I wanted. I didnt know you could use set commands with files.  XP Thanks again.
Real fast question though.
what does it mean when you use more then one % at a time? Quote from: Frozen2Dream on April 04, 2010, 04:34:53 PM

what does it mean when you use more then one % at a time?

Type FOR /? at the prompt.

Quote from: Salmon Trout on April 04, 2010, 05:01:17 PM
Type FOR /? at the prompt.
Please note, it will say %a, %i, etc. but that only applies to commands run from the command prompt, two % are for in batch files. Quote from: Helpmeh on April 04, 2010, 05:18:42 PM
Please note, it will say %a, %i, etc. but that only applies to commands run from the command prompt, two % are for in batch files.

It says:

Code: [Select]To use the FOR command in a batch program, specify %%variable instead of %variable.
2002.

Solve : A question about writing to text files.?

Answer»

Ok, just to let you know I am not the most experienced person with the command prompt so I do not know a lot about all the different commands however I have an irc bot written in msl, which is a scripting language for mirc. This means that I am not actually the one needing the data, it's the irc bot, so what I am wondering is...

If there is a way you can get all the OUTPUT of the command prompt to be written to a text file so that i can make the bot READ what it returns.

I am using the command prompt for is sending files to a ftp server, so the reason I need this is so that I can view any errors that are returned, and if the transfer is successful or not.

If you have an idea how this is POSSIBLE, any help would be greatly appreciated.

So to conclude what I need is:
A way of getting all the output from the command prompt into a text file. (by output, i mean everything that it returns to you)
for example:

Code: [Select]Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Andrew&GT;ftp
ftp> open ***
Connected to ***.
220---------- Welcome to *** [privsep] [TLS] ----------
220-You are user number 3 of 50 allowed.
220-Local time is now 19:00. Server port: **.
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.

etc.
You will need to make a script file containing all your FTP commands. If FTP is interactive, any prompts will be sent to the output file making it difficult for the user to see them.

Code: [Select]ftp -s:ftp.scr > ftp.console 2>1

ftp.scr is the name of the script file
ftp.console is the name of output log
2>1 re-routes the ERROR messages (STDERR) back to STDOUT for inclusion in the output log

Good luck.

2003.

Solve : Dos game to windows?

Answer»

I'm TRING to play and old game called "Z" from the bitmap brothers but its dos and i need to know how to make it work with windows. the site say To run the game you must extract the Z FOLDER contained in the archive to C:\Z OTHERWISE you have to change some settings manually. Also for the sound to work properly in the Zed game you have to run SETSOUND.EXE and select your CARD model. I did the following: Select and configure digital audio driver -> Creative Labs Sound Blaster or 100% compatible -> Attempt to configure manually.

At last, double click(run) Z.BAT and the game will start. Enjoy

2004.

Solve : How to fix time AT BOOT UP.?

Answer»

An old Laptop is missing the battery.
Runs fine while plugged in. Left without power for a few days and the time is way off. Really Way off.
How can i put a simple batch file the will reset the date if it is earlier than, say, March 15, 2010.  It would be OK to just SET it to March 15, 2010 and make a beeping noise ti let me know.
Maybe I could do this myself, but it would take me a week. But some you people does this sort of thing during lunch without letting your coffee get cold.
Pretty please!

PS I know about http://support.microsoft.com/kb/199030 but this is not an issue here, I just need a simple batch to fix the date and beep me on a old XP machine, not Vista or Windows 7.Spent some time trying to make a script work with this, but I GAVE up. VBScript and JScript make setting the date and time ridiculously hard. (and I couldn't get the WMI methods to work).

So I resorted to a VB6 program I tried the script first to avoid using an executable. oh well.

just a single module actually, you could probably make something similar with QuickBASIC...
Code: [Select]Option Explicit

Sub Main()
Dim latestdate As Date
Dim dateparts() As String

Dim gotyear As Integer, gotmonth As Integer, gotday As Integer


If Command$ <> "" Then
    dateparts = Split(Date, " ")
    If UBound(dateparts) >= 0 Then
        gotyear = Val(dateparts(0))
        If UBound(dateparts) >= 1 Then
            gotmonth = Val(dateparts(1))
            If UBound(dateparts) >= 2 Then
            gotday = Val(dateparts(2))
           
            End If
        End If
    End If
   
Else
    gotyear = 2010
    gotmonth = 3
    gotday = 1

End If
latestdate = DateSerial(gotyear, gotmonth, gotday)






If Now < latestdate Then
    Date = DateSerial(2010, 3, 1)
    Beep
    MsgBox "System Date has been reset to " & FormatDateTime(Now)
End If



End Sub

-the source files are included as well.





[recovering disk space - old attachment deleted by admin] Quote from: Geek-9pm on April 05, 2010, 05:10:05 PM

I just need a simple batch to fix the date and beep me on a old XP machine.

Sorry,  my recent batch  with net time /?  did work correctly.

Try this:

http://support.microsoft.com/kb/314090

Internet synchronization won't work unless the system time is within a few minutes of the time that the server gives back. As Geek has stated the time is way off when he REQUIRES this feature which makes it sorta useless. It will right eventlog entries THOUGH. that's useful.download GNU date , and then setting time/date is easy
set the time forward 2 minutes
Code: [Select]c:\test> gnu_date --set="+2 minutes"

set to APR 17 2010
Code: [Select]C:\test>gnu_date --set="20100417"
2005.

Solve : Timer Batch.?

Answer»

I want to make a batch file.

   Welcome. Today's time is "March 31, 2010, 07:24:23 PM"

It will change the time to two month earlier. To "Jan 31, 2010, 07:24:23 PM" or change it manualy.

   Change time to two month earlier or change it manualy? (T/M)
   >

If i put "t" it will change the time to two month earlier and "m" to change manualy.
If i put "t"

   Ok. Time is change to two month earlier.
   Change it back? (Y/N)
   >

If i put "Y" it will change it back to the time >"March 31, 2010, 07:24:23 PM"
"N" will just quite the window.

Or to change manualy.

   Ok. Change the time manualy. (mm-dd-yy)
   >

Now that is a timer batch.
but what is my batch?Sorry to disappoint you.
A time machine can not be made that way. Quote from: Geek-9pm on March 31, 2010, 07:49:24 PM

Sorry to disappoint you.
A time machine can not be made that way.
Well, just TELL me how to store the time.
If today is "March 31, 2010, 08:00:20 PM".
How to store the information.

Like this......
set/p "today=>"

But that you have to type in manualy.
set/p "today=>""March 31, 2010, 08:00:20 PM" Quote from: Geek-9pm on March 31, 2010, 07:49:24 PM
Sorry to disappoint you.
A time machine can not be made that way.
if he(BILL?)  just wants to change the system date to 2 months earlier, there are ways to do it. GNU date provides -s option to set system date. Similarly for vbscript the SetDateTime method of win32_operatingsystem class. the cmd.exe command line date function is another way, HOWEVER, you have to figure out the maths yourself if going by pure batch. Quote from: progmer on March 31, 2010, 08:06:38 PM
Well, just tell me how to store the time.
If today is "March 31, 2010, 08:00:20 PM".
How to store the information.

Like this......
set/p "today=>"

But that you have to type in manualy.
set/p "today=>""March 31, 2010, 08:00:20 PM"
Try running
date /t
and
time /t
at the command PROMPT and see what happens. Also look at %date% and %time%. Ahh-- it don't work for me! I tried to go back to February.
Would it not be easier to have a calendar on the wall?
Quote
d:\batch>date /?
Displays or sets the date.
DATE [/T | date]
Type DATE without parameters to display the current date setting and
a prompt for a new one.  Press ENTER to keep the same date.
If Command Extensions are enabled the DATE command supports
the /T switch which tells the command to just output the
current date, without prompting for a new date.
d:\batch>date
The current date is: Wed 03/31/2010
Enter the new date: (mm-dd-yy) 02/31/2010
The system cannot accept the date entered.
Enter the new date: (mm-dd-yy)
Quote from: Geek-9pm on March 31, 2010, 09:03:28 PM
Ahh-- it don't work for me! I tried to go back to February.
Would it not be easier to have a calendar on the wall?
ask greg the expert on date maths to help you02/31/2010
Now, why doesn't that work...hmm...better put on our thinking caps class. Quote
Similarly for vbscript the SetDateTime  method of win32_operatingsystem class.

eww..

sometimes I forget hwo much useful crap they stripped out of VB when they created VBS.

setting the date to two months prior in VB6 is as simple as:

date=dateserial(year(now),Month(now)-2,day(now))

Also: yes, it work for nearly any date. For example, dateserial(1998,2,35) gave me "3/7/1998" negative numbers work, also.

Anyway, dateserial() exists in VBScript, and you can use the Date command to change the date as well... or just use DateAdd(), which I complete forgot about while testing DateSerial:

Code: [Select]newdate = DateAdd("m",-2,Now)
Set oshell = CreateObject("WScript.Shell")
oShell.run "cmd /k date " & Cstr(newdate) & "&exit"
Quote from: BC_Programmer on April 01, 2010, 06:45:19 AM
date=dateserial(year(now),Month(now)-2,day(now))
a better variable name should be given instead of "date" since date is a valid keyword in vbscript
Quote from: ghostdog74 on April 01, 2010, 07:22:00 AM
a better variable name should be given instead of "date" since date is a valid keyword in vbscript


Quote
setting the date to two months prior in VB6 is as simple as:

Assigning a date in VB6< is as simple as assigning a date-type  variable to the "date" psuedo variable (which is actually a statement).

As you'll notice the latter code that is actually intended for VBScript does not use the name "date" for the variable and instead opts for "newdate".Ok.
Just tell me how to store the time.
Store it as %abc%

so when i type

echo "%abc%"

it will be

"April 01, 2010, 09:27:31 PM"

Thanks Quote from: progmer on April 01, 2010, 09:29:47 PM
Ok.
Just tell me how to store the time.
Store it as %abc%

so when i type

echo "%abc%"

it will be

"April 01, 2010, 09:27:31 PM"

Thanks
Look at this.

Echo %date% %time%
set abc=%date% %time%
echo %abc%
pause

It will repeat the same line twice. Well Thanks For Everyone's Help. Now The Batch Should Look Like This.

Code: [Select]echo off
set undot=%time%
set undod=%date%
goto 1
:restart
mshta vbscript:Execute("resizeTo 0,0:MsgBox ""System Refresh"",48,""System Refresh"":Close")
:1
cls
echo Welcome. Today's time is %time% %date%
echo.
echo You are about to change the time manualy. Please enter a time, HH-MM-SS. example: 23:59:59
set/p "sett=>"
echo.
echo.
echo You are now going to change the date manualy. Please enter a date, MM-DD-YY. example: 12-31-2010
set/p "setd=>"
echo.
echo.
:a
echo Confirm? (Y/N)
echo Time = %sett%
echo Date = %setd%
set/p "confirm=>"
if %confirm%==Y goto change
if %confirm%==y goto change
if %confirm%==N goto restart
if %confirm%==n goto restart
mshta vbscript:Execute("resizeTo 0,0:MsgBox ""Invalid. Y or N only."",64,""Invalid"":Close")
echo.
echo.
echo.
echo.
goto a
:change
time %sett%
date %setd%
:b
echo Do you want to undo? (Y/N)
set/p "undoing=>"
if %undoing%==Y goto undo
if %undoing%==y goto undo
if %undoing%==N goto exit
if %undoing%==n goto exit
mshta vbscript:Execute("resizeTo 0,0:MsgBox ""Invalid. Y or N only."",64,""Invalid"":Close")
echo.
echo.
goto b
:undo
time %undot%
date %undod%
mshta vbscript:Execute("resizeTo 0,0:MsgBox ""Time undo sucessfully."",64,""Undo"":Close")
:c
echo Do you want to restart?
set/p "rstart=>"
if %rstart%==Y goto restart
if %rstart%==y goto restart
if %rstart%==N goto exit
if %rstart%==n goto exit
mshta vbscript:Execute("resizeTo 0,0:MsgBox ""Invalid. Y or N only."",64,""Invalid"":Close")
echo.
echo.
goto c
:exit
mshta vbscript:Execute("resizeTo 0,0:MsgBox ""You have closed the timer batch."",0,""Timer Batch"":Close")
exit

Good to know if there is any update for the batch. Just reply me. Quote from: progmer on March 31, 2010, 07:37:55 PM
Today's time is Tue 04/06/2010


It will change the time to two month earlier. To Tue 02/06/2010




C:\batch>type timer.vbs

Code: [Select]rem DateAdd(interval,number,date)

rem Parameter Description
rem interval Required. The interval you want to add
rem Can take the following values:

rem yyyy - Year
rem q - Quarter
rem m - Month
rem y - Day of year
rem d - Day
rem w - Weekday
rem ww - Week of year
rem h - Hour
rem n - Minute
rem s - Second

curDate=Now
WScript.echo "Current Date:" + Cstr(curDate)
newDate = dateAdd("m",-2,Now)
WScript.echo "date - 2 Month:" + Cstr(newDate)
newDate = dateAdd("m",1,Now)
WScript.echo "date + 1 Month:" + Cstr(newdate)

Output:

C:\batch>cscript  //nologo timer.vbs

Current Date:4/6/2010 6:59:12 PM
date - 2 Month:2/6/2010 6:59:12 PM
date + 1 Month:5/6/2010 6:59:12 PM

C:\batch>
2006.

Solve : How to make a DOS program take an input file?

Answer» HELLO,

I have a program in DOS that takes manual entries from the command prompt. The DOS program then writes the output to a notepad file called output.txt    I have over 17,000 entries I need to perform and would like to automate this TASK. I have the 17,000 entries in a notepad file called  input.txt    How do I feed this notepad file into the DOS program?  PROVIDE more details, post the SCRIPT that you are currently using.
From a Command Prompt enter:

Code: [Select]for /?
for more details.

Quote from: smiso24 on April 07, 2010, 08:39:02 AM
writes the output to a notepad file called output.txt   

C:\batch>type  smi.bat

Code: [Select]echo off
echo.  > output.txt
for /f "DELIMS=" %%a in (input.txt) do (
echo %%a
echo %%a >> output.txt

)
echo type output.txt
type output.txt  |  more
Output:

C:\batch> smi.bat
The DOS program then writes
The DOS program then writes
The DOS program then writes
The DOS program then writes
type output.txt

The DOS program then writes
The DOS program then writes
The DOS program then writes
The DOS program then writes


C:\batch> Quote from: smiso24 on April 07, 2010, 08:39:02 AM
writes the output to a notepad file called output.txt    I have over 17,000 entries I need to perform and would like to automate this task. I


C:\batch>type  simso.bat
Code: [Select]echo off

copy input.txt  output.txt

rem or

type input.txt  >  output.txt

rem for second run  type input.txt >>  output.txtC:\batch>
2007.

Solve : How to write a batch command for the following requirement?

Answer»

Hi,

I have to run a program from a location the following is my batch file code

ECHO off
echo Hello this is a test batch file
START D:\ORDSG\instances\instance1\bin>ltctctl.bat startall
pause

basically  I have to run ltctctl.bat program with the syntax as "ltctctl.bat startall" but when I run this batch file it opens the location
D:\ORDSG\instances\instance1\bin which contains the file ltctctl.bat instead of running the command "ltctctl.bat startall".

PLEASE SUGGEST

THANKS ,
Jay
Try this:
Code: [Select]echo off
echo Hello this is a test batch file
START "" D:\ORDSG\instances\instance1\bin\ltctctl.bat startall


Your path statement was incorrect.  You had the prompt instead of the patch.

type start /? from a cmd prompt and more info. Quote from: [email protected] on April 07, 2010, 06:25:06 AM

echo off
echo Hello this is a test batch file
START D:\ORDSG\instances\instance1\bin>ltctctl.bat startall

basically  I have to run ltctctl.bat program with the syntax as "ltctctl.bat startall"
Please suggest



C:\bin>type   ltctctl.bat
Code: [Select]rem C:\bin\ltctctl.bat startall
rem the above REQUIRES a command line argument

echo off
echo Hello this is a test batch file

rem C:\bin\ltctctl.bat %1

echo  ltctctl  %1
Output:

C:\bin>ltctctl.bat  startall

Hello this is a test batch file
 ltctctl  startall

C:\bin>Hi Thanks to all of you ..

I had actualy made a mistake in the command which Mr. Gregflowers rightly pointed.

Thanks,

2008.

Solve : Batch file for finding files on network shared drive?

Answer»

Hi, I'm new to the forums, but I would like to ask a question and hopefully get some help if I may;

I am trying to complie a batch file to find and then list a NUMBER of large files, lets say the 30 largest on a network shared drive at work. I use UNIX on a daily basis and the command I would use within UNIX is:

find . -size +9999999c  2> /dev/null -exec ls -l {} \; |sort -n +4 |tail -30

However, I realise that this may not work within DOS.

Can anyone help me because I've been searching round for a while and I've been able to find nothing at all. don't you know *nix tools have been ported to Win32? Download from here. (especially coreutils, findutils )No, I wasn't aware of that.. The only issue may be, that our laptops are so locked down by the admins that I may not be able to do much with anything on that list..!!As expected, I am unable to install anything from that page 

The lockdown on my machine here means I cannot write any values to the registry when attempting to install. So, if anyone does know of a way to answer my question using DOS commands in a batch file, I'd really, really appreciate it.

Thanks for the link though, this may help me with a similar issue at home!! Quote from: icage on April 08, 2010, 04:37:35 AM

As expected, I am unable to install anything from that page 

The lockdown on my machine here means I cannot write any values to the registry when attempting to install. So, if anyone does know of a way to answer my question using DOS commands in a batch file, I'd really, really appreciate it.

Thanks for the link though, this may help me with a similar issue at home!!
you can download from home, and save to thumb drive. (you can bring all the .exe installed into 1 thumb drive). also, only if your laptop's usb drive is not locked down by you admin as well Another big fat zero... I can't believe how petty the admins actually are, I've tried 3 USB drives in my work machine, none of them are showing up, so I CALLED our IT Support and I'm told they locked the USB ports down for "security reasons"

since your company has such as security policy, then there must be procedures when you need to use tools that are third party. Request permission from your boss to authorise the use of such tools (If its really for your work). Tell them these are tools that will increase your productivity. If its still a gone case, you will need to learn some DOS batching or vbscripting. Well, I did have a go at a batch file, but it's only slightly what I'd hoped for:

echo off
echo.
DIR Z: /A :RSA -D /P sortorder -S
pause

(I have the network drive mapped to Z: in my drives list)

This sort of works fine, but it lists the directories and then the files in no particular order, I'd prefer it not to list the directiories, but to interrogate them for large files and then print out a list of filenames starting with the largest file first.

Quote from: icage on April 08, 2010, 07:42:50 AM

This sort of works fine, but it lists the directories and then the files in no particular order, I'd prefer it not to list the directiories, but to interrogate them for large files and then print out a list of filenames starting with the largest file first.


well to remove the directories try the following:

DIR Z: /A -D /P sortorder -S

for more information type DIR /? Quote
find . -size +9999999c  2> /dev/null -exec ls -l {} \; |sort -n +4 |tail -30

Don't really understand the whole command, but your post text was helpful. This may do what you want:

Code: [Select]echo off
setlocal enabledelayedexpansion

if exist dirList.txt del dirList.txt
if exist sortedDirList del sortedDirList

for /f "tokens=* delims=" %%i in ('dir c:\windows\system32 /s /b') do (
  if %%~zi GEQ 9999999 echo %%~zi %%~dpni >> dirList.txt
)

sort /r dirlist.txt /o sortedDirList.txt

for /f "tokens=1-2" %%i in (sortedDirList.txt) do (
  echo %%i %%j
  set /a count+=1
  if !count! EQU 30 goto :eof
)

You can change c:\windows\system32 to any valid directory.

Good luck. 
Sidewinder, that's great, I just copied and pasted your code and then ran it as a batch file to test it, it worked brilliantly, however, if I try and replace c:\windows\system32 with the drive I need to CHECK, it doesn't seem to do anything at all...

I know the screen stays blank whether it's doing anything or not, but there is no text file created when I try and use iton my network drive..

I have tried \\share\folder and z:\share\folder (for share\folder - this is my networked drive).

Any ideas?I think you just have to be patient. I tested on a network directory (wireless) with 891 files. The script ran 25 minutes.

I inadvertently left out a few file extensions and there is a major logic error because NUMBERS in batch are treated as text and do not right align which will throw off the sort. I added logic to fix this but now you need to use the choice command for this work. Sorry for the inconvenience.

Code: [Select]echo off
setlocal enabledelayedexpansion

if exist dirList.txt del dirList.txt
if exist sortedDirList.txt del sortedDirList.txt

for /f "tokens=* delims=" %%i in ('dir c:\windows\system32 /s /b') do (
  call :ZeroFill %%~zi
  if %%~zi GEQ 9999999 echo !var! %%~dpnxi >> dirList.txt
)

sort /r dirList.txt /o sortedDirList.txt

for /f "tokens=* delims=" %%i in (sortedDirList.txt) do (
  echo %%i
  set /a count+=1
  if !count! EQU 30 goto :eof
)
goto :eof

:ZeroFill
  echo;;|choice /c=%1; set > p.bat
  set ct=0
  call p.bat

  for %%v in (%[%) do call set /a ct=%%ct%%+1

  set [=
  del p.bat > nul
 
  set /a pad=12 - %ct%
  if %pad% equ 11 set var=00000000000%1
  if %pad% equ 10 set var=0000000000%1
  if %pad% equ 9 set var=000000000%1
  if %pad% equ 8 set var=00000000%1
  if %pad% equ 7 set var=0000000%1
  if %pad% equ 6 set var=000000%1
  if %pad% equ 5 set var=00000%1
  if %pad% equ 4 set var=0000%1
  if %pad% equ 3 set var=000%1
  if %pad% equ 2 set var=00%1
  if %pad% equ 1 set var=0%1
  goto :eof

Good luck.
2009.

Solve : Checking tasklist?

Answer»

BC_programmer...you are correct...initially I thought it was the BATCH file I had to find...

But after making more enquiries I found it was a .exe file I should be looking for (long story)...

So saster your code does find a .exe so please post the explorer.exe code you tried...

All the best Neilas easy as I can do

Code: [SELECT]echo off
set "process=explorer.exe"
:begin
tasklist | find "%process%" >nul && (echo run) || (echo dont run)
ping localhost -n 3 >nul
goto begin
replace explorer.exe for other process

when you learn more you understand my first code, with the same function

Hopefully this will answer my questions...

Thanks for all the help...

Have a GOOD weekend...

NeilHi Saster...

Tried what you suggested and it worked well...
I've CHANGED it slightly to suit my needs (I've replaced the :-

ECHO OFF
Title Daemon Check
set "process=ADMIN.exe"
:begin
CLS
tasklist | find "%process%" >nul && (echo admin is running) || (goto :Restart)
ping localhost -n 5 >nul
goto begin
:Restart
call D:\Neil\PDMS_apps\Restart_Daemon.bat
goto begin

Is what I have okay or does it break programming rules ?

Cheers
Neil

2010.

Solve : ActiveFTP Data Connection??

Answer»

I'm trying to use a batch file to transfer files via FTP to my DriveHQ TRUE account, but when I send it, it takes a really long time...it says free accounts are SUBJECT to slower speeds, but it takes like 30 seconds to upload a 16 BYTE (yes, just 16 bytes) file.


When I reviewed what exactly happens when I upload, this is what I found which is interesting:
Code: [Select]ftp> put ftpsend
200 Port command successful.
421 Failed to create ActiveFTP DATA Connection. (Blocked by firewall?) Please use PassiveFTP, or download DriveHQ FileManager.
The 421 LINE is what is holding me up...I have no idea what PassiveFTP is and I can't use the FileManager, but it is taking a long time.


Is there some way I can enable "PassiveFTP" so it won't lag the script process so horrendously?


EDIT: I tried using Quote PASV as the first command after entering in my username and password, but it still brings up that stupid error message.some firewalls DISABLE PASV for FTP connections. EVEN if you use PASV with your FTP client, the firewall that stands between you and the other end must be able to recognise PASV mode. Check with the one that is in charge of the firewall. Quote from: ghostdog74 on April 09, 2010, 11:01:12 PM

some firewalls disable PASV for FTP connections. even if you use PASV with your FTP client, the firewall that stands between you and the other end must be able to recognise PASV mode. Check with the one that is in charge of the firewall.
Now, I did a quick look through the control panel and Windows Firewall is disabled...making me think that there is another firewall on the computer. I checked my taskbar icons (where one usually is for firewalls, etc.), nothing, unless ESET Nod32 Buisness edition has a built-in firewall, which I doubt. I checked Add or Remove Programs, nothing mentions any firewall.

I guess the board thinks deepfreeze and NOD32 (with an outdated signature because of deepfreeze) will be enough to secure their computers.


EDIT: I did a little bit of googling, and it appears that the FTP client from CMD.exe doesn't actually support PassiveFTP...
2011.

Solve : export local variable outside of setlocal?

Answer»

How can i export the varibles (set inside setlocal ) outside of setlocal .

for exmaple

setlocal
set var1=20
endlocal

set var2=%var1%

now here var2 should be set as enviorment varible that is FIXED till we are not close that window. Quote

How can i export the varibles (set inside setlocal ) outside of setlocal

Why would you want to? What are you trying to do that would require localizing the variable and then attempting global access?

The setlocal statement is purposely designed to localize the variables.

The normal SCOPE of a batch file variable is the duration of the session window (cmd/command). Setlocal reduces that scope until either an endlocal statement is encountered or the batch file ends, whichever comes first.

Is this related to this thread?

 

yes it is related to this thread.

so there is no way to access globally the local variable ?
Quote
so there is no way to access globally the local variable ?

There seems to be some confusion about a variable and it's value. While a setlocal variable will die with an endlocal or the end of the batch file, it's value can live on through the file system.

Code: [Select]echo off
setlocal
echo 20 > var1
endlocal
set /p var2=<var1
echo %var2%
del var1

Not for nothing, but in your last thread we eliminated the setlocal statement. What happened?

 actually there is many variables are going to set as enviorment variable if i remove set local
so i have to use set local without delayexpanssion only for that part of code and i want to use that DIR value out side of that setlocal.

Now the issue is that when i echo varibles inside batch file it prints correct value of that varibles but when i tried to echo from commant prompt it self it does not show any value to varible .
here i m talking about the varibles set outside of setlocal with the help fo DIR.

r u understand what i want to say.lets explain u with the example

i set DIR inside setlocal

use DIR and set TOP_DIR after endlocal

When echo DIR and TOP_DIR it prints correct value

now after runing that batch file i run one makefile in same window and use TOP_DIR in that but it doesnot work.Please post the code you used.

Quote
i set DIR inside setlocal

use DIR and set TOP_DIR after endlocal

Quote
When echo DIR and TOP_DIR it prints correct value

I'm interested to see this as it directly contradicts the purpose of setlocal.

 

Using command names as your variable names is not good practice. It can only lead to confusion. Code: [Select]SETLOCAL
set VOB_BASE_DIR=

for /f "tokens=* delims=\" %%P in ('cd') do (
set _mypath=%%P
)
set _array=%_mypath:\= %

for %%E in (%_array%) do (
if .%%E==. GOTO getout
  if %%E==test goto getout
  call set VOB_BASE_DIR=%%VOB_BASE_DIR%%\%%E
)
echo vob= %VOB_BASE_DIR%
ENDLOCAL
:getout
set VOB_BASE_DIR=%VOB_BASE_DIR:~1%

set TOP_DIR=%VOB_BASE_DIR%\\oscl
echo Set TOP_DIR to %TOP_DIR% ...

now after that i run makefile and it returns an error 
make:  makefile:  line 1:  Error -- Include file /makefile.mk, not found
and the first line of make is
Code: [Select]include $(TOP_DIR)/makefile.mk
after that i tried to echo TOP_DIR from command prompt so it prints: %TOP_DIR%
it does not show value.I hate to repeat myself, but why are you even using the setlocal and it's evil twin endlocal STATEMENTS? The whole point of the other thread was to not localize the variables so you would have global access.

Code: [Select]set VOB_BASE_DIR=

for /f "tokens=* delims=\" %%P in ('cd') do (
set _mypath=%%P
)
set _array=%_mypath:\= %

for %%E in (%_array%) do (
if .%%E==. goto getout
  if %%E==test goto getout
  call set VOB_BASE_DIR=%%VOB_BASE_DIR%%\%%E
)
echo vob= %VOB_BASE_DIR%

:getout
set VOB_BASE_DIR=%VOB_BASE_DIR:~1%

set TOP_DIR=%VOB_BASE_DIR%\\oscl
echo Set TOP_DIR to %TOP_DIR% ...

Quote
When echo DIR and TOP_DIR it prints correct value

Quote
after that i tried to echo TOP_DIR from command prompt so it prints: %TOP_DIR%
it does not show value.


Assuming the syntax is correct, the makefile probably couldn't find a variable TOP_DIR

 

There are only 13 or so batch files commands. You don't need to use all of them in any single batch file.thanks

Finally I understand that I have not to use set local .
Solution:

rem === Export %params% from setlocal scope
for /f "delims=" %%i in ('echo %params%') do endlocal & set params=%%i
2012.

Solve : Need to run app in different window from window running the batch job Help!?

Answer»

I need to kick off an app that RUNS in a command WINDOW.  The app is a PROGRAM that listens for connections so I ALSO need the batch to move to the next command after it starts that app in a new window.....

2013.

Solve : Set/a arithmetic expressions.?

Answer»

Hey G.D. & S.T. The information both of you posted will no doubt come in handy, if not for me then perhaps for one or more of the 200+ READERS of this thread.   I regret that both of you ALLOWED your responses to become a personal slanging match rather than an exchange of technical knowhow of which you both seem to have more than enough to share.

I HOPE a mod will now LOCK this thread, which I regret starting, to stop the clash of personalities continuing.

Salutations to you both.

2014.

Solve : DOS/16M error [6] Insufficient memory to load program?

Answer»

Hardware: Acer Aspire 4720Z Laptop (Pentium Dual Core, 2GB RAM, 100GB Disk).
Platform: DOS 6.22, in Microsoft Virtual PC 2007, on Windows Vista Home Premium SP2.
Application: Informix-SQL 4.10.DD6 (DOS).
Settings: CONFIG.SYS (DEVICE=C:\DOS\HIMEM.SYS /TESTMEM:OFF /Q);
                AUTOEXEC.BAT (SET DOS16M=3)

Description:
1. After DOS 6.22 boot, 614K real mem. and 65MB extended mem. available.
2. All DOS and INFORMIX environment variables are properly set.
3. I have an app. written with protected-mode  INFORMIX-SQL 2.10.06E working,
    (see video-demo at www.frankcomputer.com).
4. I installed INFORMIX-SQL 4.10.DD6 (Protected Mode DOS).
5. The database engine (PSTARTSQL.EXE) size is 535K.
6. When I execute PSTARTSQL.EXE, I get "DOS/16M error [6] Insufficient memory to 
    load program"
7. I also tried removing all TSR's, including FSHARE.EXE, which allows me to share
    Windows Vista Drives and Folders with my DOS VM,
    (Examples: DOS Drive F: = Windows Vista Drive F: (USB Flash Drive);
                       DOS Drive C: = W.V. Drive C:, Dos Drive X: = W.V. Desktop-Folder\XFER)

DOS 6.22 has the MEMMAKER program which works well to create an install with the most amount of free memory, give it a try
MEMMAKER is used to move as many things it can to high memory... I have already done that, I have 614K real mem available + that's not the problem. My protected-mode
SQL engine, PSTARTSQL.EXE, is only 535K and its supposed to load into high mem and only use about 24K of real mem. Thanks anyway!I have been focusing on changing 'SET DOS16m=n' using the guide below, but no luck so far in getting INFORMIX-SQL v.4.10.DD6 (protected-mode DOS) to load/execute. (see intial post on this thread.)

1.2 Changing the Switch Mode Setting

     In almost all cases, DOS programs can detect the type of machine that
     is running and automatically choose an appropriate real- to protected-mode
     switch technique.  For the few cases in which this default setting does
     not work we provide the DOS16M DOS environment variable, which overrides
     the default setting.

     Change the switch mode settings by issuing the following command:

       set DOS16M=value

     Do not insert a space between DOS16M and the equal sign.  A space to the
     right of the equal sign is OPTIONAL.

     The table below lists the machines and the settings you would use with
     them.  Many settings have mnemonics, listed in the column "Alternate
     Name", that you can use instead of the number.  Settings that you must set
     with the DOS16M variable have the notation req'd in the first column.
     Settings you may use are marked option, and settings that will
     automatically be set are marked auto.
                                         
-------------------------------------------------------------------------------

+--------+---------------+--------+------------+-----------------------------------+
|           |                    |           |Alternate  |                                             |
|Status |Machine       |Setting|Name       |Comment                               |
+--------+---------------+--------+-=---------+------------------------------------+
|auto   |386/486 w/ DPMI|0      |None      |Set automatically if DPMI is active|
|req'd  |NEC 98-series  |1      |9801      |Must be set for NEC 98-series      |
|auto   |PS/2           |2      |None      |Set automatically for PS/2         |
|auto   |386/486        |3      |386, 80386|Set automatically for 386 or 486   |
|auto   |386            |INBOARD|None      |386 with Intel Inboard             |
|req'd  |Fujitsu FMR-70 |5      |None      |Must be set for Fujitsu FMR-70     |
|auto   |386/486 w/ VCPI|11     |None      |Set automatically if VCPI detected |
|req'd  |Hitachi B32    |14     |None      |Must be set for Hitachi B32        |
|req'd  |OKI if800      |15     |None      |Must be set for OKI if800          |
|option |IBM PS/55      |16     |None      |May be needed for some PS/55s      |
+-------+---------------+-------+----------+-----------------------------------+

     The following procedure shows you how to test the switch mode setting.

       1. If you have one of the machines listed below, set the DOS16M
         environment variable to the value shown for that machine and specify a
         range of extended memory.  For example, if your machine is an NEC
         98-series, set DOS16M=1 2M-4M.  See the section, "Fine Control of
         Memory Usage" later in this chapter for more information about setting
         the memory range.

            +--------------------+---------+
            | Machine            | Setting |
            +--------------------+---------+
            | NEC 98-series      | 1       |
            | Fujitsu FMR-60,-70 | 5       |
            | Hitachi B32        | 14      |
            | OKI if800          | 15      |
            +--------------------+---------+

         
         

         Before running DOS applications, check the switch mode setting by
         following this procedure:

       2. Run PMINFO and note the switch setting reported on the last line of
         the display.  (PMINFO, which reports on the protected-mode resources
         available to your programs, is described in more detail in the
         chapter, "Utilities".)

         If PMINFO runs, the setting is usable on your machine.

       3. If you changed the switch setting, add the new setting to your
         AUTOEXEC.BAT file.

     Note:  PMINFO will run successfully on X86 machines.  If your DOS
     application does not run, and PMINFO does, check the CPU type reported on
     the first line of the display.


     You are authorized (and encouraged) to distribute PMINFO to your
     customers.  You may also include a copy of this section in your
     documentation.

1.3 Fine Control of Memory Usage

     In addition to setting the switch mode as described above, the DOS16M
     environment variable enables you to specify which portion of extended
     memory DOS will use.  The variable also allows you to instruct DOS
     to search for extra memory and use it if it is present.

1.3.1 Specifying a Range of Extended Memory

     Normally, you don't need to specify a range of memory with the DOS16M
     variable.  You must use the variable, however, in the following cases:

       * You are running on a Fujitsu FMR-series, NEC 98-series, OKI
        if800-series or Hitachi B-series machine.

       * You have older programs that use extended memory but don't follow one
        of the standard disciplines.

       * You want to shell out of DOS to use another program that requires
        extended memory.

     If none of these conditions applies to you, you can skip this section.

     The general syntax is:

       set DOS16M= [switch_mode] [start_address [- end_address]] [:size]

     In the syntax shown above, start_address, end_address and size represent
     numbers, expressed in decimal or in hexadecimal (hex requires a 0x
     prefix).  The number may end with a K to indicate an address or size in
     kilobytes, or an M to indicate megabytes.  If no suffix is GIVEN, the
     address or size is assumed to be in kilobytes.  If both a size and a range
     are specified, the more restrictive interpretation is used.

     



     The most flexible strategy is to specify only a size.  However, if you are
     running with other software that does not follow a convention for
     indicating its use of extended memory, and these other programs start
     before DOS, you will need to calculate the range of memory used by the
     other programs and specify a range for DOS programs to use.

     DOS ignores specifications (or parts of specifications) that conflict
     with other information about extended memory use.  Below are some examples
     of memory usage control:

                                             

     set DOS16M= 1 2m-4m    Mode 1, for NEC 98-series machines, and use
                             extended memory between 2.0 and 4.0MB.

     set DOS16M= :1M         Use the last full megabyte of extended memory, or
                             as much as available limited to 1MB.

     set DOS16M= 2m         Use any extended memory available above 2MB.

     set DOS16M= 0 - 5m    Use any available extended memory from 0.0 (really
                             1.0) to 5.0MB.

     set DOS16M= :0          Use no extended memory.

     As a default condition DOS applications take all extended memory that
     is not otherwise in use.  Multiple DOS programs that execute
     simultaneously will share the reserved range of extended memory.  Any
     non-DOS programs started while DOS programs are executing will
     find that extended memory above the start of the DOS range is
     unavailable, so they may not be able to run.  This is very safe.  There
     will be a conflict only if the other program does not check the BIOS
     configuration call (Interrupt 15H function 88H, get extended memory size).

     To create a private pool of extended memory for your DOS application,
     use the PRIVATXM program, described in the chapter, "Utilities".

     The default memory allocation strategy is to use extended memory if
     available, and overflow into DOS (low) memory.

     In a VCPI or DPMI environment, the start_address and end_address arguments
     are not meaningful.  DOS memory under these protocols is not allocated
     according to specific addresses because VCPI and DPMI automatically
     prevent address conflicts between extended memory programs.  You can
     specify a size for memory managed by VCPI or DPMI, but DOS will not
     necessarily allocate this memory from the highest available extended
     memory address, as it does for memory managed under other protocols.

1.3.2 Using Extra Memory

     Some machines contain extra non-extended, non-conventional memory just
     below 16MB.  When DOS runs on a Compaq 386, it automatically uses this
     memory because the memory is allocated according to a certain protocol,
     which DOS follows.  Other machines have no protocol for allocating
     this memory.  To use the extra memory that may exist on these machines,
     set DOS16M with the + option.

       set DOS16M=+

     Setting the + option causes DOS to search for memory in the range from
     FA0000 to FFFFFF and determine whether the memory is usable.  DOS does
     this by writing into the extra memory and reading what it has written.  In
     some cases, this memory is mapped for DOS or BIOS usage, or for other
     system uses.  If DOS finds extra memory that is mapped this way, and
     is not marked read-only, it will write into that memory.  This will cause
     a crash, but won't have any other effect on your system.

1.4 Setting Runtime Options

     The DOS16M environment variable sets certain runtime options for all
     DOS programs running on the same system.

     To set the environment variable, the syntax is:

       set DOS16M=[switch_mode_setting]^options.

     Note:  Some command line editing TSRs, such as CED, use the caret (^) as a
     delimiter.  If you want to set DOS16M using the syntax above while one of
     these TSRs is resident, modify the TSR to use a different delimiter.

     These are the options:

     0x01       check A20 line -- This option forces DOS to wait until the
                A20 line is enabled before switching to protected mode.  When
                DOS switches to real mode, this option suspends your
                program's execution until the A20 line is disabled, unless an
                XMS manager (such as HIMEM.SYS) is active.  If an XMS manager
                is running, your program's execution is suspended until the A20
                line is restored to the state it had when the CPU was last in
                real mode.  Specify this option if you have a machine that runs
                DOS but is not truly AT-compatible.  For more information
                on the A20 line, see the section, "Controlling Address Line
                A20" in this chapter.

     0x02       prevent initialization of VCPI -- By default, DOS searches
                for a VCPI server and, if one is present, forces it on.  This
                option is useful if your application does not use EMS
                explicitly, is not a resident program, and may be used with
                386-based EMS simulator software.

     0x04       directly pass down keyboard status calls -- When this option is
                set, status requests are passed down immediately and
                unconditionally.  When disabled, pass-downs are limited so the
                8042 auxiliary processor does not become OVERLOADED by keyboard
                polling loops.

     0x10       restore only changed interrupts -- Normally, when a DOS
                program terminates, all interrupts are restored to the values
                they had at the time of program startup.  When you use this
                option, only the interrupts changed by the DOS program are
                restored.






     0x20   set new memory to 00 -- When DOS allocates a new segment or
                increases the size of a segment, the memory is zeroed.  This
                can help you find bugs having to do with uninitialized memory.
                You can also use it to provide a consistent working environment
                regardless of what programs were run earlier.  This option only
                affects segment allocations or expansions that are made through
                the DOS kernel (with DOS function 48H or 4AH).  This option
                does not affect memory allocated with a compiler's malloc
                function.

     0x40       set new memory to FF -- When DOS allocates a new segment or
                increases the size of a segment, the memory is set to 0xFF
                bytes.  This is helpful in making reproducible cases of bugs
                caused by using uninitialized memory.  This option only affects
                segment allocations or expansions that are made through the
                DOS kernel (with DOS function 48H or 4AH).  This option
                does not affect memory allocated with a compiler's malloc
                function.

     0x80       new selector rotation -- When DOS allocates a new selector,
                it usually looks for the first available (unused) selector in
                numerical order starting with the highest selector used when
                the program was loaded.  When this option is set, the new
                selector search begins after the last selector that was
                allocated.  This causes new selectors to rotate through the
                range.  Use this option to find references to stale selectors,
                i.e., segments that have been cancelled or freed.

1.5 Controlling Address Line 20

     This section explains how DOS uses address line 20 (A20) and describes
     the related DOS16M environment variable settings.  It is unlikely that you
     will need to use these settings.

     Because the 8086 and 8088 chips have a 20-bit address spaces, their
     highest addressable memory location is one byte below 1MB.  If you specify
     an address at 1MB or over, which would require a twenty-first bit to set,
     the address WRAPS back to zero.  Some parts of DOS depend on this wrap, so
     on the 286 and 386, the twenty-first address bit is disabled.  To address
     extended memory, DOS enables the twenty-first address bit (the A20
     line).  The A20 line must be enabled for the CPU to run in protected mode,
     but it may be either enabled or disabled in real mode.

     By default, when DOS returns to real mode, it disables the A20 line.
     Some software depends on the line being enabled.  DOS recognizes the
     most common software in this class, the XMS managers (such as HIMEM.SYS),
     and enables the A20 line when it returns to real mode if an XMS manager is
     present.  For other software that requires the A20 line to be enabled, use
     the A20 option.  The A20 option makes DOS/4GW restore the A20 line to the
     setting it had when DOS switched to protected mode.  Set the
     environment variable as follows:

       set DOS16M= A20






     To specify more than one option on the command line, separate the options
     with spaces.

     The DOS16M variable also lets you to specify the length of the delay
     between a DOS instruction to change the status of the A20 line and the
     next DOS operation.  By default, this delay is 1 loop instruction when
     DOS is running on a 386 machine.  In some cases, you may need to
     specify a longer delay for a machine that will run DOS but is not
     truly AT-compatible.  To change the delay, set DOS16M to the desired
     number of loop instructions, preceded by a comma:

       set DOS16M=,loops

2015.

Solve : Newbie needs help! (batch file)?

Answer»

I'm in the process of LEARNING DOS.

In its simplest form, i need to:
1. If there's a file that exists, i need to check it if it exists, if it does i need to rename it with a .txt extension and place it into a directory. then WRITE a note in log file.

2. if there isn't a file that doesn't exist, i need to create a directory. then write it in a log

3. i need to copy only modified files from one directory to another


If anyone can help it would be very much appreciated.

thanksdoes this make sense?

Code: [Select]If exist "c:\temp\MyPlace\*.*" (
rename *.* *.FIL >> m.log
) else (
md c:\temp\MyPlace >> m.log

xcopy m:\*.* c:\temp\MyPlace\*.* /d /y1.
echo off
if exist FILENAME (
     ren FILENAME FILENAME.TXT
     Copy FILENAME.TXT DIRECTORY
     Echo File found. > log.txt
)
2. If there isn't a file that doesn't exist? So, you have a list of files that need to exist? Ok.

echo off
set list=put the path to where the REQUIRED file names are in. Eg. Files.txt
setlocal enabledelayedexpansion
for /f "delims=" %%a in (%list%) do (
     Set /a COUNTER+=1
)
for /f "delims=" %%b in (%list%) do (
     If exist %%a (
          ren %%a %%a.txt
          Copy %%a.txt DIRECTORY
          echo File found > log.txt
          Set /a counter2+=1
     )
)
If %counter% neq %counter2% (
     Echo Not all files found. >log.txt
     Md DIRECTORY
)
    
3. Look at XCOPY /? at the command PROMPT. Also, try looking through the forum. You will probably find something to your requirements.  thanks for this!

for #2.
it's more like if FILENAME or DIRECTORY don't exist, create the directory (and the file) and write in a log file.

2016.

Solve : Parsing multiple IPs on multihomed machine - in batch?

Answer»

Hi there,

I wrote batch which enumerate all network interfaces on machine and list them on screen. I need list all IP addresses and netmasks assigned to particular interfaces. There are few ways, how to pull those INFORMATION from system:

1: ipconfig
2: netsh in ip SH AD [iface_name]
3: REG QUERY "HKLM\SYSTEM\ControlSet001\services\%GUID%\Parameters\Tcpip" /s | find "IPADDRESS"

Disadvantages of listed methods:

1: seems not to be easy detect, what IP is assigned to what iface
2: in w2k does not show dynamically assigned IPs
3: not possible in w2k. MULTIPLE IPs per interface is listed on one line separated by backslash, possible troubles with parsing.

what is you recomendation?? Do you have any other idea??

[email protected]


2017.

Solve : Management of the press from the keyboard?

Answer»

Hello! I from Russia.
Allow to ask a question please.
I quote from the textbook:
There are the combinations of keys processed in special way:
... PrtScr (or Shift PrtScr) - the press on the printer of a copy of the contained screen in DOS...

On the computer it is established MS DOS 6.22. The printer is absent, but there is a question.
When I start FILE Print.exe, it is visible that the system is ready to work. The system requests page which should be unpacked.
At attempt to take advantage of the function described above, the system does not react. I think, that if to connect the printer - too NOTHING will occur.
Any files of system need to be edited?
There can be this function is an external command and consequently the additional program is necessary?
I ask to answer please with an official language as I badly know English.
Under command-line based operating systems such as MS-DOS, the PrtScrn key causes the contents of the current text mode screen memory buffer to be copied to the standard printer port, usually LPT1. In a GUI operating system such as Windows, a bitmage image of the screen is copied to the clipboard.


Whether the system should report at use of this function?
Or she SENDS the image on LPT on-default? Quote from: Bazaroff on APRIL 21, 2010, 01:13:06 PM

Whether the system should report at use of this function?
Or she sends the image on LPT on-default?

If printer is connected and switched on and has paper it will immediately print 25 or 43 or 50 lines of text (the text screen contents)Thank you very much. I Will search for the corresponding printer.The computer will freeze until the printing is finished.
2018.

Solve : Save file with current DateTimestamp?

Answer»

I'm using batch file to run Visual Studio load test. For this I'm using MSTest command's /testcontainer and /resultsfile METHODS. I want to save file with unique name by appending datetimestamp to output file specified in /resultsfile method. How can I do so?

Here is the snippet of code from batch file



Code:
Code: [Select]MSTest /testcontainer:"C:\Test.loadtest" /resultsfile:"C:\TestResults.trx"
I want file to be saved like: TestResult_04-12-2010-09_09_09.trx Quote from: goru09 on April 12, 2010, 08:31:27 AM

I'm using batch file to run Visual Studio load test. For this I'm using MSTest command's /testcontainer and /resultsfile methods. I want to save file with unique name by appending datetimestamp to output file specified in /resultsfile method. How can I do so?

Here is the snippet of code from batch file



Code:
Code: [Select]MSTest /testcontainer:"C:\Test.loadtest" /resultsfile:"C:\TestResults.trx"
I want file to be saved like: TestResult_04-12-2010-09_09_09.trx

download GNU coreutils, then try this

Code: [Select]echo off
for /F %%a in ('gnu_date.exe +%%m-%%d-%%Y-%%H_%%M_%%S') do (  set timestamp=%%a )
set filename=c:\TestResults-%timestamp%.trx
MSTest /testcontainer:"C:\Test.loadtest" /resultsfile:%filename%


or, just

Code: [Select]MSTest /testcontainer:"C:\Test.loadtest" /resultsfile:"C:\TestResults%date%-%time%.trx"
ghostdog74  and BC_Programmer, received MSTest syntax error in both ways.if the date and/or time variables contain poison characters you have to remove or replace these before trying to use them in a file name.This may be helpful:

Code: [Select]echo off
for /f "tokens=2-7 delims=./: " %%i in ("%date% %time%") do (
  set mm=%%i
  set dd=%%J
  set yyyy=%%k
  set hh=%%l
  set mn=%%m
  set ss=%%n
)
MSTest /testcontainer:"C:\Test.loadtest" /resultsfile:TestResults_%mm%-%dd%-%yyyy%-%hh%_%mn%_%ss%.trx

If your date format is not mm/dd/yyyy, you'll need to reconfigure the set statements.

  Quote from: goru09 on April 12, 2010, 11:37:42 AM
ghostdog74  and BC_Programmer, received MSTest syntax error in both ways.
Then check your DOCUMENTATION on MSTest for the correct syntax.Thanks Sidewinder!
2019.

Solve : Difference between .cmd and .bat?

Answer»

Hi everyone,

Can someone TELL me the difference between .cmd and .bat

I'm asking as I have both on my computer...

I'm creating a master .bat (Mon.bat) that will :-
1. Call the .cmd file (which paths system drives)
2. Copies some files
3. Calls another .bat that STARTS a program

-- --------------------------------------------------------
Mong.bat

J:\cae_prog\pdms\v11.6\ECSArea\PDMS\pathing\Mon_Network.cmd
ping localhost -n 10 >nul
ECHO OFF
COPY J:\cae_prog\pdms\v11.6\Area\PDMS\bat\Copy_bats\mon_evars.bat C:\cae_prog\pdms\v11.6\CadCentre
ECHO mong_evars copied
COPY J:\cae_prog\pdms\v11.6\Area\PDMS\bat\Copy_bats\mon_pdms.bat C:\cae_prog\pdms\v11.6\CadCentre
ECHO mong_pdms copied

CALL C:\cae_prog\pdms\v11.6\CadCentre\mon_pdms.bat

-- --------------------------------------------------------
Mon_Network.cmd

echo off
color 1f

echo.
echo ---------------------------------------------
echo Connecting to Mon PDMS Server ... Please wait ...
echo ---------------------------------------------
echo.

echo Map Network Drive Z:

echo on

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

My problem is...the .cmd executes okay...
but it stops there...the files aren't copied and the bat isn't executed either...

So can anyone tell me why my .bat isn't executing ?

Cheers
Neil Quote

-- --------------------------------------------------------
Mong.bat

J:\cae_prog\pdms\v11.6\ECSArea\PDMS\pathing\Mon_Network.cmd
ping localhost -n 10 >nul
ECHO OFF
COPY J:\cae_prog\pdms\v11.6\Area\PDMS\bat\Copy_bats\mon_evars.bat C:\cae_prog\pdms\v11.6\CadCentre
ECHO mong_evars copied
COPY J:\cae_prog\pdms\v11.6\Area\PDMS\bat\Copy_bats\mon_pdms.bat C:\cae_prog\pdms\v11.6\CadCentre
ECHO mong_pdms copied

CALL C:\cae_prog\pdms\v11.6\CadCentre\mon_pdms.bat

Batch/Command files need to be called to have control passed back to the caller. You have it right in the last line of your file.

Quote
-- --------------------------------------------------------
Mong.bat

CALL J:\cae_prog\pdms\v11.6\ECSArea\PDMS\pathing\Mon_Network.cmd
ping localhost -n 10 >nul
ECHO OFF
COPY J:\cae_prog\pdms\v11.6\Area\PDMS\bat\Copy_bats\mon_evars.bat C:\cae_prog\pdms\v11.6\CadCentre
ECHO mong_evars copied
COPY J:\cae_prog\pdms\v11.6\Area\PDMS\bat\Copy_bats\mon_pdms.bat C:\cae_prog\pdms\v11.6\CadCentre
ECHO mong_pdms copied

CALL C:\cae_prog\pdms\v11.6\CadCentre\mon_pdms.bat

Quote
Can someone tell me the difference between .cmd and .bat

As far as I know there are none. CMD files came along with WinNT. Both are text files which are executed within an interpreter.

 Thanks Sidewinder...you've saved me again...

Cheers
Neil Quote from: Sidewinder on APRIL 20, 2010, 08:09:03 AM

As far as I know there are none. CMD files came along with WinNT. Both are text files which are executed within an interpreter.


Scripts to be interpreted by command.com (the old MS-DOS command interpreter) need to have the .bat extension. Scripts to be interpreted by cmd.exe can have either the .bat or the .cmd extension. Put another way, a .bat script can be interpreted by either command.com or cmd.exe, whereas a .cmd file can only be RUN with cmd.exe. If both .bat and .cmd versions of a script (test.bat, test.cmd) are in the same folder and you run the script without the extension (test), by default the .bat version of the script will run, even on 64-bit Windows 7. The order of execution is controlled by the PATHEXT environment variable.

Didn't the REXX interpreter included with PC-DOS USE the cmd extension? Quote from: BC_Programmer on April 20, 2010, 02:24:28 PM
Didn't the REXX interpreter included with PC-DOS use the cmd extension?

Yes, indeed.
2020.

Solve : Batch file to check files exist?

Answer»

I have a batch file that checks if our image & DR files have been transferred to our DR server.

This file is faily long and I'm wanting to either reduce the amount of line or make it easier to edit...main section is as follows;

This checks for 7zip files...
Code: [Select]echo -------------------------------------------------------------->> %logfile%
set FINDSTR=%DRIVELETTER%:\SERVER1\e\backup\FILE.7z
if not exist %FINDSTR% (
echo ***ERROR*** - %FINDSTR%>> %logfile%
) ELSE (
echo Located - %FINDSTR%>> %logfile%
)

This check for modified date on image files...
Code: [Select]set FINDSTR="%DRIVELETTER%:\SERVER1\e\Image files\FILE8.tib"
dir %FINDSTR% | %SystemRoot%\system32\find "%DATESTR%/%MONTHSTR%/%YEARSTR%" >nul
if %ERRORLEVEL%==1 echo Error with SERVER1 TIB files, does not exist or incorrect file date>> %logfile%

This repeats for each database & image file and currently is just over 500 lines and will be around 900 when complete by doing it this way.

What I'd prefer to do is create a sub routine that can be called to execute the actual checks, then go back and change FINDSTR to the next file to be checked then jump to the sub routine again...then do the same for the image files.

Code: [Select]set FINDSTR
goto CheckRoutine
set FINDSTR
goto CheckRoutine
.
.
goto end
:CheckRoutine
blah blah
RESUME BACK IN MAIN CODE
:end
Any help would be appreciatedYou don't need a subroutine, you need a loop.

Hard coding the 7z files in the batch file is counterproductive. Each file is processed the same, so why not code their names in a text file (FileList.txt); one name per line and read each label prior to testing it's existence?

The tib files are more problematic. You're just checking the date but you need to feed the loop from a directory list.

Perhaps this will help or at least get you started.

Code: [Select]echo off
set logfile=logfile.log
for /f "tokens=* delims=" %%i in (FileList.txt) do (
  if exist "%%i" (echo Located - %%i >> %logfile%) else (echo ***ERROR*** - %%i >> %logfile%)
)

for /f "tokens=* delims=*" %%i in ('dir /s /b "%DRIVELETTER%:\SERVER1\e\Image files\*.tib"') do (
  dir %%i ^| find "%DATESTR%/%MONTHSTR%/%YEARSTR%" > nul
  if errorlevel 1 echo Error with SERVER1 TIB files, does not exist or incorrect file date >> %logfile%
)

Good luck.  So...
Code: [Select]for /f "tokens=* delims=" %%i in (FileList.txt)...will import a line at a time into the loop.

I'll test it and let you know how I get on.

Thanks for the responseThanks, that worked..but I have 2 issues

I can't pass a parameter between list file and the batch file.

dr1-zip.txt contains the FOLLOWING lines...
Code: [Select]\server1\e\backup\db\database1_
\server1\e\backup\db\database2_
\server2\e\backup\db\database1_
\server2\e\backup\db\database2_

I need to create an import file for 7z & tib files...we also have BAK files...so that's 3 import file per DR server making it 9 files in total.

Code: [Select]for /f "tokens=* delims=*" %%i in (dr1-zip.txt) do (
if exist %DRIVELETTER%:%%i%CHECKSTR%*.7z (
echo Located - "\\dr1%%i%CHECKSTR%*.7z" >> %logfile%
) else (
echo ***ERROR*** - \\dr1%%i%CHECKSTR%*.7z >> %logfile%
)
)
for /f "tokens=* delims=*" %%i in (dr1-tib.txt) do (
dir %DRIVELETTER%:%%i*.tib ^| find "%DATESTR%/%MONTHSTR%/%YEARSTR%" > nul
if %ERRORLEVEL%==0 (
echo Located - "\\dr1%%i" TIB files >> %logfile%
) else (
echo ***ERROR*** - "\\dr1%%i", does not exist or incorrect file date >> %logfile%
)
)
I'd then have to create FOR loop for BAK files, then do it all again on 2 other DR SERVERS.

But I'd prefer the following for the list file...
Code: [Select]\server1\e\backup\db\database1_%CHECKSTR%*.7z
\server1\e\backup\db\database2_%CHECKSTR%*.7z
\server2\e\backup\db\database1_%CHECKSTR%*.7z
\server2\e\backup\db\database2_%CHECKSTR%*.7z
Code: [Select]for /f "tokens=* delims=*" %%i in (dr1-zip.txt) do (
if exist %DRIVELETTER%:%%i (
echo Located - "\\dr1%%i" >> %logfile%
) else (
echo ***ERROR*** - \\dr1%%i >> %logfile%
)
)
Pass %CHECKSTR% back to my batch file - %CHECKSTR% = date to check for, defined earlier in the batch file.
Second issue is, can I parse the last 3 chars of %%i and create a if,else loop?

Code: [Select]for /f "tokens=* delims=*" %%i in (dr1-zip.txt) do (
  if LAST3CHARS==.7z (
    if exist %DRIVELETTER%:%%i (
      echo Located - "\\dr1%%i" >> %logfile%
    ) else (
      echo ***ERROR*** - \\dr1%%i >> %logfile%
    )
) else if LAST3CHARS==tib (
  dir %DRIVELETTER%:%%i*.tib ^| find "%DATESTR%/%MONTHSTR%/%YEARSTR%" > nul
  if %ERRORLEVEL%==0 (
    echo Located - "\\dr1%%i" TIB files >> %logfile%
  ) else (
    echo ***ERROR*** - "\\dr1%%i", does not exist or incorrect file date >> %logfile%
  )
)
Quote

I can't pass a parameter between list file and the batch file. Pass %CHECKSTR% back to my batch file - %CHECKSTR% = date to check for, defined earlier in the batch file.

You're right. The text file has no knowledge of what goes on in the batch file. This might work with delayed expansion. If not, there might be other ways, but this seems the simplest.

Code: [Select]\server1\e\backup\db\database1_!CHECKSTR!*.7z
\server1\e\backup\db\database2_!CHECKSTR!*.7z
\server2\e\backup\db\database1_!CHECKSTR!*.7z
\server2\e\backup\db\database2_!CHECKSTR!*.7z


Also, add a setlocal enabledelayedexpansion line to the beginning of your batch file.

Quote
Second issue is, can I parse the last 3 chars of %%i and create a if,else loop?

You can use the notation %%~xi to isolate the extension of the file. Note: %%~xi includes the dot.

I couldn't test the code on this machine,  so I wish you luck. 

FYI: The if/else construct is not a loop, the for instruction as written is. Keep in mind, batch code is not a programming language, it's a command language. You might want to check out VBScript which was installed with your OS. It's a lightweight scripting language which has more functionality than batch language.I don't think I have the FOR command correct...

Code: [Select]for /f "tokens=* delims=" %%i in (zip.txt) do (
    for /F %%a in ("%%i") do (
      set FILETYPE=%%~xI
      echo %FILETYPE%
   )
)
FILETYPE contains no value...My first reply to you was this basic framework:

Quote
echo off
for /f "tokens=* delims=" %%i in (FileList.txt) do (
  if exist "%%i" (echo Located - %%i >> %logfile%) else (echo ***ERROR*** - %%i >> %logfile%)
)

for /f "tokens=* delims=*" %%i in ('dir /s /b "%DRIVELETTER%:\SERVER1\e\Image files\*.tib"') do (
  dir %%i ^| find "%DATESTR%/%MONTHSTR%/%YEARSTR%" > nul
  if errorlevel 1 echo Error with SERVER1 TIB files, does not exist or incorrect file date >> %logfile%
)

You then posted back that it worked, but claimed there were some issues. Fair enough, but how it went from my original post to this convoluted mess, I'll never know.

Quote
for /f "tokens=* delims=*" %%i in (dr1-zip.txt) do (
  if LAST3CHARS==.7z (
    if exist %DRIVELETTER%:%%i (
      echo Located - "\\dr1%%i" >> %logfile%
    ) else (
      echo ***ERROR*** - \\dr1%%i >> %logfile%
    )
) else if LAST3CHARS==tib (
  dir %DRIVELETTER%:%%i*.tib ^| find "%DATESTR%/%MONTHSTR%/%YEARSTR%" > nul
  if %ERRORLEVEL%==0 (
    echo Located - "\\dr1%%i" TIB files >> %logfile%
  ) else (
    echo ***ERROR*** - "\\dr1%%i", does not exist or incorrect file date >> %logfile%
  )
)
I suggested some changes to the input file. Did they work? If not, this issue should be resolved before moving on.

Next you posted this nested for loop, which for the life of me can't figure out why it's needed or what context you're using it in.

Quote
for /f "tokens=* delims=" %%i in (zip.txt) do (
    for /F %%a in ("%%i") do (
      set FILETYPE=%%~xI
      echo %FILETYPE%
   )
)

I would SUGGEST getting back to basics. Create a for loop for the 7z files and get it working. Add a second for loop for the tib files and get that working. Then you can add a third for loop for the bak files. If later you find DUPLICATE code for two of the file extensions, you can work at combining/streamlining the logic. It's easier to debug code as you develop it, rather than writing all the code and debugging from line 1. Above all, keep it simple.

 

Using the !CHECKSTR! worked fine...thanks for that pointer.

There are file types of tib, bak, 7z and DAT that need to be checked to make sure they have been succesfully copied to the server.

The 7z & bak files contain the date of the backup within the file name, so I can check if the correct date is there and that works great.

Only way to check tib & dat files is to get the modified date from the file, check this is the date we expect.

We have 3 servers, maybe more to come...with 4 file types, that's 12 list files to maintain so I wanted to check the ext of the filename and execute the checking commands based of filetype...that's what I added the extra FOR inside the first one.
2021.

Solve : batch to copy and not replace existing files?

Answer»

Hi all,

I am aware that there is no switch to do this so i was thinking of another way of doing it.

i was thinking of creating a text file with a list of files in the directory in source and destination, then comparing the two, finding any DIFFERENCE then copy the files singley.

so far i have

echo off

DIR /S /b c:\a\* >> a.TXT             
DIR /S /b c:\b\* >> b.txt

this creates files a.txt and b.txt with a list of file NAMES files in each folder. i would then need to compare the two, CREATE a 3rd .txt file which contains the path of everything that is in dir a and not in b, then copy from dir a everything in the 3rd .txt file to dir b...

hope this makes sense. im sort of disappointed that microsoft would not include a switch for this, there are many USES for it.

Any help would be great.

Thank you.
normally, you would go for xcopy. type xcopy /? and see how its used.xcopy has more functions within but none to say no to all

2022.

Solve : MS-DOS and VMWARE?

Answer»

I have a Pawnshop Management System developed with Informix-SQL 2.10 perfectly running
under a DOS 6.22 virtual hard drive (MICROSOFT Virtual PC 2007) on Windows Vista Home
Premium SP2.

The (2GB) BIGDOS partition, including the MBR (Master BOOT Record) is encapsulated inside
one Windows Vista .vhd file (102MB). Backup copies to a flash drive are done in less than 15
seconds.

With DOS FSHARE.EXE, I can share Windows Vista Drives/Devices/Folders from WITHIN the
DOS virtual machine and vice-versa!

Examples:

LASTDRIVE=Z:

DOS Drive F: = Windows Vista Drive F:(USB Flash Drive).
DOS Drive L: = W.V. Parallel Printer (LPT1:)
DOS Drive P: = W.V. USB HP-LaserJet Printer.
DOS Drive S: = W.V. Drive C:
DOS Drive X: = W.V. C:\Users\Root\Desktop\Xfer

(See video-demo at: www.frankcomputer.com).

2023.

Solve : Having problem with %%?

Answer»

Hi i want to make a batch file (timer creater.bat) as shown:
Code: [Select]echo off
echo echo off >timer.bat
echo MSG * today is %date% %time% >>timer.bat
echo exit >>timer.bat
Well this is hard to explain, I want to CREATE a new batch file that is timer.bat
and i want the command %date% in my new batch but not the information about the %date% like 04/19/2010 monday.
Know what i mean? 
So my new batch (timer.bat) will look like this:
Code: [Select]echo off
msg * today is %date% %time%
exit
But not this:
Code: [Select]echo off
msg * today is 04/19/2010 Mon 11:20:32.68
exit
Make sense?
If yes, please help!Try this:
Code: [Select]echo off

(
echo echo off
echo msg * today is %%date%% %%time%%
echo exit
)>timer.bat

Note the doubling of %% so that they are treated as LITERALS.

Quote from: T.C. on April 18, 2010, 09:56:14 PM

Try this:
Code: [Select]echo off

(
echo echo off
echo msg * today is %%date%% %%time%%
echo exit
)>timer.bat


Note the doubling of %% so that they are treated as literals.


Well THANKS It WORK Great!
2024.

Solve : Command-Line Downloader?

Answer»

I'm looking for a substitute for WGET (which is extremely slow [taking over 30 secs to download something ~19kb])...it doesn't need ALL the FEATURES, it just needs to work from command-line, and accept wildcards.

I REALLY don't know why WGET is so slow, even though the download is complete and the file exists, it is still working away at SOMETHING (I tried setting the quota to 1, so it should only look for one file).curl or aria2c MAYBE?

But can you describe the problem you are having with wget a bit more fully?


I am trying to download a webpage and look at the source and display certain values in the source. WGET just seems to go unresponsive...or at least doing something not required to bring the file to my computer.

The actual WGET command looks like this:
     wget http://services.runescape.com/m=itemdb_rs/*/viewitem.ws?obj=%%a (%%a being a number already known to exist)


When I got the output, this is what it is:

--17:53:25--  http://services.runescape.com:80/m=itemdb_rs/%2A/viewitem.ws?obj=532
           => `[email protected]=532'
Connecting to services.runescape.com:80... CONNECTED!
HTTP request sent, awaiting response... 200 OK
Length: 18,622 [text/html]

    0K -> .......... ........ << This is where it freezes for about 20+ seconds

This is the debug output:
DEBUG output created by Wget 1.5.3.1 on Windows.

parseurl ("http://services.runescape.com/m=itemdb_rs/*/viewitem.ws?obj=1436") -> host services.runescape.com -> opath m=itemdb_rs/*/viewitem.ws?obj=1436 -> dir m=itemdb_rs/* -> file viewitem.ws?obj=1436 -> ndir m=itemdb_rs/*
--17:57:15--  http://services.runescape.com:80/m=itemdb_rs/%2A/viewitem.ws?obj=1436
           => `[email protected]=1436'
Connecting to services.runescape.com:80... Created fd 1908.
connected!
---request begin---
GET /m=itemdb_rs/%2A/viewitem.ws?obj=1436 HTTP/1.0

User-Agent: Wget/1.5.3.1

Host: services.runescape.com:80

Accept: */*



---request end---
HTTP request sent, awaiting response... HTTP/1.1 200 OK
Date: Sun, 18-Apr-2010 21:57:17 GMT
Server: JAGeX/3.1
Content-type: text/html; charset=ISO-8859-1
Cache-control: no-cache
Pragma: no-cache
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Set-Cookie: settings=wwGlrZHF5gKN6D3mDdihco3oPeYN2KFybL9hUUFqOvk; version=1; path=/; domain=.runescape.com; Expires=Wed, 17-Apr-2013 21:57:17 GMT; Max-Age=94608000
Connection: Close
Content-length: 18649


Length: 18,649 [text/html]

    0K -> .......... ........

So, I really don't know why this isn't working. I'll try curl and arai2c soon.I tried curl and it works PERFECTLY! Thanks ST!

2025.

Solve : Starting and Stopping Windows services with Batch code?

Answer»

I am trying to stop a few windows services using some batch code, but I keep getting an error code.

System error 1060 has occurred. The specific service does not exist as an installed service.

Here is the code I am using...

Code: [Select]echo off
cls
CD C:\progra~1\Raxco\Perfec~1\
call PerfectDisk.exe
NET STOP PDAgent.exe
NET STOP PDEngine.exe

When PerfectDisk.exe is started, both services, PDAgent.exe and PDEngine.exe are started. But when I close PerfectDisk.exe the other two services do not close.

Any help would be appreciated.

Thanks

I'm certainly no batch expert, but are "PDAgent.exe" and " PDEngine.exe" the service names, or the filenames?  As far as I am aware you must use the service name, as shown in services.msc, to use the NET STOP/START ETC commands.
If this doesn't help, I'm sure someone knowing a little more will be along shortly Ahh yes. I need to remove the ".exe" as the service names are PDAgent and PDEngine.

Thus:

Code: [Select]echo off
cls
CD C:\progra~1\Raxco\Perfec~1\
call PerfectDisk.exe
NET STOP PDAgent
NET STOP PDEngine

They now close, but only AFER I manually close PerfectDisk.exe. Shouldn't the program end after the call command moves on to the next command? Or is there a better way to end PerfectDisk.exe? Is there batch language to terminate PerfectDisk.exe? I think I used it at one time.

Good to hear that is now working.
As for your other questions, I'm not sure, I've not used the call command so I'm not certain what the behaviour should be but I think it should wait until the program it called is closed until it moves on, as you described.  I know you could use the "taskkill /im PerfectDisk.exe" command to kill the process, but it seems like there should be a better way than that.
Maybe you could try using the run command, or just the filename?
I'm guessing more than anything, I'll admit that ... QUOTE from: iONik on April 18, 2010, 11:55:12 AM

I need to remove the ".exe" as the service names are PDAgent and PDEngine.

Correct. ALSO I always use quotes around the service name.

Quote
Or is there a better way to end PerfectDisk.exe?

A better way to start it, you mean. The CALL command is for starting one batch file from another and returning after completion.

Code: [Select]C:\>call /?
Calls one batch program from another.
[...]

For .exe (program) files you need to use the START command. In your situation where you want to wait for the program to finish, use the /WAIT switch. In addition START needs a title string (which is required, and which can be blank).

Code: [Select]echo off
cls
CD C:\progra~1\Raxco\Perfec~1\
start /WAIT "" "PerfectDisk.exe"
NET STOP "PDAgent"
NET STOP "PDEngine"
Ahh Yes. You are right, Salmon TROUT. It's been a long time since I used batch code.

I did try the code you suggested, but PerfectDisk.exe did not quit after I "X'd" out of the program. But this was because the settings in the program was set to minimize to system tray. So your code works perfectly!

Thanks
2026.

Solve : rename a file?

Answer»

how do you CHANGE the extention when you don't know the file NAME
the reason i don't know the file name is because it is suplied by the %1 parameter Quote from: mat123 on April 18, 2010, 07:29:31 AM

how do you change the extention when you don't know the file name
the reason i don't know the file name is because it is suplied by the %1 parameter

If %1 is the complete filename then %~x1 is the extension


%1      "c:\my path\my PROGRAM.exe"
%~d1    c:
%~p1    \my path\
%~n1    my program
%~x1    .exe
%~dpnx1 c:\my path\my program.exe


thank you salmon trout
2027.

Solve : trying to save pics using DOS?

Answer»

i'm trying to help my son who managed to get his pc infected with the virus "xp antimalware 2010". after i googled this virus on my pc, i found a procedure to REMOVE it. The fix was a registry change. I tried it and now windows WONT start. I can get to a dos prompt and i did a dir and it shows his directories including his docs. At this point i would like to save his pics before doing a win xp reinstall. 1. could i copy his pics to a flash drive? 2. if so, how would i go about installing the flash drive(usb) without windows, using dos? 3. or is there a better way anyone can suggest?  Thanks in advance for any help.first off never modify your registry
put the flash drive in and try
D:\
E:\
etc all the way to Z:\when you find the flash drive letter Code: [Select]Copy C:\pics\*.* where C:\pics is where the pictures are stored and X:\ is the drive letter for the flash drive
Wait. I think he said DOS 3.3 which does not read NTFS.
Does the OP have another PC?no his windows gui turned off he is call ing whats left dosyes, i have a laptopIs this Win98?

I apologize. It's win XPSlave Drive Tutorial

You don't have DOS...sounds like safe mode command prompt perhaps? Some more INFO from the OP would be helpful

2028.

Solve : MS-DOS imeadiatly closes...?

Answer»

I was trying to play a demo that uses MS-DOS. Originally it worked fine, the DOS prompt would appear and give me the game's options, but when I would try and load the game, I got an error when I got to the gameplay part, it would say "an installable virtual DEVICE failed DLL initialization", so I had to delete and remake the "VirtualDeviceDrivers" key to stop the error.

Here is my current problem, every time I try to run the demo's .exe, the prompt comes up for literally a split second and closes. What can be done?

ADDITIONAL information

-Normal Command prompt STILL works fine

-The demo was for Dark Forces

-Could I have done something wrong with my fixing of the VirtualDeviceDrivers? I did everything I was told, THOUGH I could have gotten the directory wrong. Here it is.

My Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\VirtualDeviceDrivers

2029.

Solve : FTP rar file corruption?

Answer»

Hi all - I have written a batch file that uses the rar command to archive a folder with a bunch of files in it.

This file then needs to be sent to my ftp server.

I can successfully connect to my ftp server and 'put' files on it with no PROBLEMS...

However, the PROBLEM comes when I try to upload a .rar file. The file sends to my ftp server and seems to have no problems, but when I pull it off and try to extract it it tells me the following:

!   C:\Users\Christopher\Desktop\wrar393.rar: CRC failed in wrar393.exe. The file is CORRUPT
!   C:\Users\Christopher\Desktop\wrar393.rar: Unexpected end of archive

This is just a test archive I made (archived the wrar.exe file and sent it as a .rar file)

So the problem here is definitely within the dos FTP client because when I use FileZilla, it woks perfectly fine.
If i upload the file through ms-dos and download it through ms-dos it gives me the error
If i upload the file through filezilla and download it through ms-dos it gives me the error.
If i upload the file through ms-dos and download it through filezilla it gives me the error
If i upload the file with filezilla and download with filezilla it does not give me error

So it seems as SOON as it passes through ms-dos's FTP it is corrupting it. (or something is happening)

I have tried this on both Windows 7 and Win XP and same issues on both as well as crossing over (download/uploading on the different machines)


I'm USING this within the command prompt:
ftp
open XXXXX.com
userXXXXXXXname
passXXXXXXXword

lcd C:\Setup_Files
cd qbooksbackup
put qbooksbackup.rar
(It then proceeds to finish and say a certain byte size was transferred in a number of seconds, etc.)

Any Help Please!

Thank you so much in advance!

- Chris
use binary mode for your ftp transfer. Sounds like you may need to force the ftp transfer to happen in binary mode

http://www.nsftools.com/tips/MSFTP.htm

ftp
open XXXXX.com
userXXXXXXXname
passXXXXXXXword

lcd C:\Setup_Files
cd qbooksbackup
binary
put qbooksbackup.rarWorks Perfect


Thank you guys so much for the help!

- Chris

2030.

Solve : START with affinity option on windows XP?

Answer»

I know that at least in Windows Vista the START command has an affinity option to start a process with a specific processor affinity mask. For example:
START "Title" /affinity 1 cmd.exe

That option is not available for me on Windows XP Home SP3. Which is a shame because I only need it on XP (to start NTVDM). Any way to make this work?

Since NTVDM is a system file I don't want to change it with imagecfg or the like.In the upper right you see a searcdh box for this forum. Type in "NTVDM" WITHOUT the quotes and find lots of threads about  that.
Also:
Troubleshooting MS-DOS-Based Programs in Windows
Actually you'll find no threads at all about how to set the affinity of the NTVDM process. Or MUCH about affinity masks for that matter. Nor does the MS article you linked explain that.
If you need to know why I want to do that you can read this article.

Anyway, I found a utility to set the affinity of a process on the web that does the job. So problem solved.Thanks for sharing the links with us.
Sorry we could not help here. Now we have some info about ""affinity option".

Could you give an SIMPLE example of how ""affinity option" is a useful tool for XP?
We would like that for our database here at CH. Quote from: Geek-9pm on April 16, 2010, 10:18:21 AM

Could you give an simple example of how ""affinity option" is a useful tool for XP?
We would like that for our database here at CH.

The links pretty well illustrate that. Quote
The links pretty well illustrate that.
Yep. You are right. I had no idea of what all that was about until I read the first link over very carefully. There are people out there doing serious work with 16 bit programs. A modern high-performance PC can actually hang a process using the NTDVM.

If anybody has strange random program hangs using NTDVM, read the links given by Kolya. A real world case of a problem and a solution using Windows tools and third party stuff.

And MS is aware of the issue, says the link. This will NOT  very likely be fixed in XP because it is near end-of-life. Quote from: Geek-9pm on April 16, 2010, 11:05:26 PM
And MS is aware of the issue, says the link. This will NOT  very likely be fixed in XP because it is near end-of-life.

Consider that the "real world" example used a relatively ancient version of FoxPro... FoxPro is still being released as part of modern versions of Visual Studio. (I think) Quote from: BC_Programmer on April 16, 2010, 11:07:19 PM
Consider that the "real world" example used a relatively ancient version of FoxPro... FoxPro is still being released as part of modern versions of Visual Studio. (I think)
Now you HIT a nerve.
MS has all but killed FoxPro.
We could start a whole new thread about "Why MS hates FocPro."
Or something like that. Quote from: Geek-9pm on April 16, 2010, 11:32:03 PM
Now you hit a nerve.
MS has all but killed FoxPro.
We could start a whole new thread about "Why MS hates FocPro."
Or something like that.

what are you talking about?

http://msdn.microsoft.com/en-us/vfoxpro/default.aspx

A Service pack was released this month for it. It's not part of Visual studio anymore, though. It certainly outlived VB-COM.Thanks for the link. Good information.
Still, after reading that, and some related links, IMO MS hates FoxPro.

Or, to put it another way.
If Microsoft were a parent.
And FoxPpro was a 16 year old daughter.
The Child Protection Service would find the parent  ...
guilty of mental and emotional trauma to the child.The parrot isn't for NOTHING, eh? Quote from: Geek-9pm on April 17, 2010, 12:47:25 PM
If Microsoft were a parent.
And FoxPpro was a 16 year old daughter.
The Child Protection Service would find the parent  ...
guilty of mental and emotional trauma to the child.

You do write nonsense sometimes, Geek-9PM.
2031.

Solve : HELP...F2 to Run Setup OR F12 to Boot from Network??????

Answer»

The power cable from my COMPUTER DISCONNECTED turning off the computer.  When I powered back up the computer goes to DOS and asks if I want to
F2 to Run Setup
OR
F12 to Boot from Network
I've never seen this before and I'm afraid I'll make the wrong choice.
What does this mean and which do I choose?  Is this a big deal?  Will I loose my data?
HELP!!
Thanks!!click F2 it is more than likely just letting you know WINDOWS was not shut down correctly. 

let us know if this does not fix you issue. Quote from: wbrost on April 16, 2010, 05:48:58 PM

click F2 it is more than likely just letting you know windows was not shut down correctly. 

  SOUNDS more like a BIOS message to me.

The type you might get if the hard drive is unbootable.
2032.

Solve : STARTING A BAT FILE FROM A PARENT BAT FILE?

Answer»

I'm stumped with this. I have a parent BAT file and within it I'm starting a SECOND
BAT file. My objective is to have it run in the background while the parent GETS on
with concurrent work. I don't want to have to wait for the second BAT to finish.

I've tried   -  parent BAT   and within it -  'start jobx.BAT'.  When I open the parent a cmd window starts and then a second window displays because of the start cmd.
My problem is the second BAT doesn't really run. The window displays and just seems to be waiting for something, perhaps for something to run.

I've also tried 'start /B jobx.bat' and the job just doesn't run i.e. what it is designed to do doesn't get DONE

I didn't think the concept of starting something and having it run in the background would be this difficult. Obviously I've missed something here.

When I change the start to 'call jobx.bat it' performs as designed but the parent will wait for it to complete which is not my objective. 

Hopefully someone may have SEEN this ISSUE and has a solution.
Try this:

start "" cmd /c "C:\Documents and Settings\user\My Documents\batchfile.bat"

2033.

Solve : editting through DOS?

Answer»

my comp operates with an xp  but the DOS  CANT edit a file.  yet it can perform other COMMANDS .please helpGIYBF

Google Is Your Best Friend

You dont have a text editor then google for it, the WORDPERFECT Office editor has been RELEASED as FREEWARE (I believe), simtelnet has a lot of small editors, Im sure I used to have one called TEDDoes Edit.com not open from the command line?

2034.

Solve : DOS 6.22 in MS-Virtual PC 2007 shares Windows Vista Drives/Devices/Folders.?

Answer»

I have a Pawnshop Management System developed with Informix-SQL 2.10 perfectly running
under a DOS 6.22 virtual hard drive (Microsoft Virtual PC 2007) on Windows Vista Home
Premium SP2.

The (2GB) BIGDOS partition, including the MBR (Master Boot Record) is encapsulated inside
one Windows Vista .vhd file (102MB). Backup copies to a flash drive are done in less than 15
seconds.

With DOS FSHARE.EXE, I can share Windows Vista Drives/Devices/Folders from within the
DOS virtual machine and vice-versa!

Examples:

LASTDRIVE=Z:

DOS Drive F: = Windows Vista Drive F:(USB Flash Drive).
DOS Drive L: = W.V. Parallel Printer (LPT1:)
DOS Drive P: = W.V. USB HP-LaserJet Printer.
DOS Drive S: = W.V. Drive C:
DOS Drive X: = W.V. C:\Users\Root\Desktop\Xfer

See video-demo at: www.frankcomputer.com).

*CAVEAT: However, trying to UPGRADE to INFORMIX v.4.10 is causing me DOS16M problem,
but it's just a matter of time before I fix it, hopefully with help from someone who has had
similar difficulties with DOS16M.


I never used DOS 6.22 but I used DOS 6 and WFWG 3.11 (with a NETWORK) to share FILES.

2035.

Solve : Label a Flash Drive using DOS?

Answer»

I need to LABEL a flash drive USING a MS-DOS COMMAND, but it needs to be in this format:

last_first

Is there a character limit?Nevermind--I answered my own question, but for those who might look this one up in the future the answer is YES. I was only allowed 11 characters.

Label [Drive:]XXXXXX_XXXX

2036.

Solve : Control not passed back to calling Batch program?

Answer»

Hi, I have a DOS batch program which calls another application to perform a backup.  When the other application is finished control is not passed back to the batch program which called it - leaving the rest of the required batch processing uncompleted.  Please helpWhy don't you post what you have so that somebody can look at it for you.
(Our CRYSTAL balls were recalled DUE to some defect or other...)Sorry - below is the batch the problem line is:
     D:\Apps\Progress\10B\bin\probkup online figtree D:\Backup\CustCare\figtree.bak
It does not return control to the batch.


echo off
REM ********************************************************
REM This program performs the Figtree Online backup
REM ********************************************************

set src-dir=D:\Backup
set db-dir=D:\Figtree\data\db\CustomerCare
set backup-dir=D:\Backup\CustCare
set run-dir=D:\Figtree\data\db\CustomerCare
set dlc=D:\Apps\Progress\10B

cd %run-dir%
D:\Apps\Progress\10B\bin\probkup online figtree D:\Backup\CustCare\figtree.bak

REM ********************************************************
REM Get the date and reformat it so it can be used as a
REM directory name
REM ********************************************************

for /f "tokens=1,2" %%U in ('date/t') do set d=%%v
set datestr=%d:~0,2%-%d:~3,2%-%d:~6,4%                             
mkdir %backup-dir%\%datestr%
move %backup-dir%\figtree.bak  %backup-dir%\%datestr%
exit
Try using call or start /wait. Eg.
Call Batchfile.bat
Start /wait "" D:\Stuff\program.exeThanks Helpmeh - used the Call statement and everything works fine.

2037.

Solve : I really need some advice from people that know about this :)?

Answer»

Hi,
  I just registered here and am glad to have found this forum. I have a Dell Studio computer, almost a year old (desktop) and yesterday for the first time, the computer got a VIRUS. Since I have an online business and need my computer, and the geek squad couldn't come for a week, I called a local computer repairman. He removed everything from the computer, backed up documents, pictures, ETC, on my external hard drive, put everything back...Well, during the course of the very long visit, I mentioned how I didn't like Vista as much as I did Windows XP, so he put Windows XP (I think it's a bootleg copy) on my computer. Anyway, my husband and daughter are upset now because the computer is not connected to either of our printers (the Epson Stylus Photo 820 or the Dell V305w wireless). I called the computer tech, he told me to go to epson.com, download the info, etc, I called Epson, had a woman walk me through downloading the driver for our printer, and when we tried to run it to set the computer up we get the following message:

"The system file is not suitable for running MS-DOS and Microsoft Windows Applications, click close to terminate the program"

Do I need to reinstall Vista? Should I? The man also removed our wireless Linksys by Cisco and supposedly hooked the wireless up another way, my husband (who knows less than techie computer stuff than me lol) wants to know if we can just stick the wireless card back into the front of the computer where it was...and of course, if we need to get Vista back. By the way, I lost all of my Outlook information, which is very upsetting too...Any help and advice is greatly appreciated, thank you so much in advance.

Katy1977Can anyone help me with this please? Thanks so much. 

Katy1977If you change the subject title to something related to your problem rather than "I need help" you will probably get a better response.ASAP you need to talk to your local Better Business Bureau,  the Chamber of commerce and the District attorney.
http://www.bbb.org/

They should give you advice as to how to deal with the 'computer tech' who tore into you computer. If he does not put your system back the way it was, TAKE him to small claims court. I am not joking.

Meanwhile, you can get back online at you local library or college campus.  Also, you can pick up a refurbished computer with a one year warranty and a certified Windows XP install for about $190 plus shipping.

To see more, Google refurbished Desktop
 You can use your old monitor. A NEW Wireless card is about $20 at you local WallMart.

The Epsom printer came with a install CD that will automatically do the printer installation. Quote

take him to small claims court

Quote
Also, you can pick up a refurbished computer with a one year warranty and a certified Windows XP install for about $190 plus shipping.

  Don't go sue people or waste money on a new computer. I am sure the tech just forgot to install some drivers.

What is the exact file you are running when you recieve the error message? I know it is the driver, but what's the file name? Quote from: Linux711 on April 14, 2010, 12:57:17 PM
Don't go sue people or waste money on a new computer. I am sure the tech just forgot to install some drivers.

Would you be so forgiving if the surgeon "forgot" to "install" your new kidney?
2038.

Solve : Format Command--Need help?

Answer»

What is the MSDOS command to format a disk with the following PARAMETERS:

MAKE it bootable (legacy)
full format &AMP;
name it PCOS
Drive letter is B:

Would the following be CORRECT? FORMAT B: /S /V:PCOSCorrect.  You get an "A".Thank you for your immediate response. I'm working on a project so I might have more questions. Again thank you!!From command PROMPT type format /?
Any ones that are still available in WinXP are there for you.

2039.

Solve : Logical OR operator?

Answer»

This is what I'm trying to do:
Code: [Select]IF "%win_version%"=="xp" | "%win_version%"=="2000" | "%win_version%"=="2003" | "%win_version%"=="nt" (ECHO Hurray!)

It works when I only have one condition (IF "%win_version%"=="xp" ) but I need to check for a few more and if either is true, do something. You need different if statements.
If "%var%"=="XP" echo hooray
if "%var%"=="2000" echo hooray
...Here is a workaround
Code: [Select]set bool=0
IF "%win_version%"=="xp" set /a bool+=1
IF "%win_version%"=="2000" set /a bool+=1
IF "%win_version%"=="2003" set /a bool+=1
IF "%win_version%"=="nt" set /a bool+=1
IF %bool% GTR 0 (
    ECHO Hurray!
    ECHO Suitable version
    )
Ah, so there isn't a logical OR.

Thank you for your help, that workaround looks promising. QUOTE from: Kolya on April 13, 2010, 04:10:53 PM

Ah, so there isn't a logical OR.
Or as an alternative, you can learn a different language that has better support for such things and more, EG Python
Code: [Select]>>> versions=("xp","2000","2003","nt","here","you","can","add","more","different","checks","etc","etc","etc")
>>> if win_version in versions:  print "hurray, suitable version"
     

Quote from: ghostdog74 on April 13, 2010, 05:54:39 PM
you can learn a different language

What a surprise! I wasn't expecting that!  Quote from: Salmon Trout on April 14, 2010, 12:00:02 AM
What a surprise! I wasn't expecting that! 
Salmon...!I'm fairly certain Ghostdog is now mentioning alternatives such as python, grep, SED, etc. just because he knows it annoys ST, heh.

And hey! here's the BEST part about the python approach! it's cross-platform! now you can check what version of windows you have installed on Ubuntu!    Quote from: BC_Programmer on April 14, 2010, 06:21:29 AM
I'm fairly certain Ghostdog is now mentioning alternatives such as python, grep, sed, etc. just because he knows it annoys ST, heh.
no, i am not. I have been suggesting alternatives long time ago using vbscript, Perl , Python etc. and no, remember, my posts are never meant for anyone else but the OP. They are 100% for the OP to solve his problem. Whether one is "annoyed" or not, I don't care.

Quote
And hey! here's the best part about the python approach! it's cross-platform! now you can check what version of windows you have installed on Ubuntu!   
i am assuming you are joking.
2040.

Solve : How to install windows on an empty hard drive??

Answer»

I just had a virus that killed everything in my Hardrive.
I formated it. Now, it is EMPTY. How do I re-install it now?
It is plugged in the form of a external Harddrive.
But, if I drive the windows CD in the other computer.. it is going to install itself on the other computer, not the the ONE I want..

HELP!!Please make it clear what happened.
You have two computers.
One BECAME infected and you removed the Hard-drive. You put the hard drive into another machine and formatted it.
Is that right?
If so, now you put the hard drive back into the machine that had been infected. START the machine with the XP CD in the CD-ROM reader. When you see the message you can press any key to start the installation.
Boot to the OS cd and the install process will begin. Quote from: Geek-9pm on April 10, 2010, 07:43:03 PM

Please make it clear what happened.
You have two computers.
One became infected and you removed the Hard-drive. You put the hard drive into another machine and formatted it.
Is that right?
If so, now you put the hard drive back into the machine that had been infected. Start the machine with the XP CD in the CD-ROM reader. When you see the message you can press any key to start the installation.


Okay. I'll explain from the start.
I have two computer at home. One of 'em got a virus.
I had to formate it. So, I put the Hard Drive *the one with the virus* in a Case for internal hard drive.
Plugged it to another computer. And I formated it. 
Now, it is empty.

I have the CDs to install windows. But, I put the CDs into the CD-drive of my computer (that works)
Windows will only install itself on the computer that works, not the empty Hard Drive...

So, how to I install... a new exploitation system... on a empty hard Drive? Quote from: Allan on April 11, 2010, 04:49:32 AM
Boot to the OS cd and the install process will begin.
Windows must install on a internal drive.
You can not install it on a hard drive in a box outside the computer on a USB.
Well, you could, but if you knew how to do that you would not have come here,
The empty hard drive has to be inside the PC and plugged into the normal interface cables. Quote from: Geek-9pm on April 11, 2010, 08:58:56 PM
Well, you could, but if you knew how to do that you would not have come here,
The empty hard drive has to be inside the PC and plugged into the normal interface cables.

And, would you agree to help me out?
By, you know, just explaining how? Since Windows OS's since WinME were designed this WAY for copyright reasons i'm afraid we can't assist with that... Quote from: patio on April 12, 2010, 03:52:14 PM
Since Windows OS's since WinME were designed this way for copyright reasons i'm afraid we can't assist with that...

Is there a way I can re-install it then?? Quote from: LeJer on April 13, 2010, 03:09:51 PM
Is there a way I can re-install it then??

Put it back into the computer it came from. You were already told this.
step 1. put the formated hard drive into the original computer
step 2. put the instalation disk into that computer
step 3. turn on the computer and it will ask if you want to start the instalation
step 4. click yes
step 5. tada
2041.

Solve : Networking DOS with XP?

Answer»

I have an old DOS 6.22 computer with a 3com Etherlink III network card. I want to network the computer so I can access the shares on my XP machines. I installed the microsoft network client 3.0 for DOS program. In one of the ini files I had to disable DHCP (never use it) and assign the computer an IP. When I REBOOTED, it tells me that I need to type a username and password. This is the part that is confusing me. My network does not have any domain servers, its just a simple windows XP workgroup. All I want to do is be able to access the network shares on the XP comp. I tried just leaving both USER and pass blank, but when I try to ping I can't access ANYTHING on the network.can you ping web sitesSorry it took so long for the reply.

Quote

can you ping web sites
No, it just says "the name can not be resolved".

I found that the only thing I can ping SUCCESSFULLY is the router. But at least now I know the card isn't broken. So does anyone have any ideas?I just noticed that it can only ping the router if all the computers on the network are off. After I turned on this comp, it wasn't able to ping the router anymore.

Correction:

when I ping a site, it says "the node google.com can not be resolved."do you have dial up. Quote
do you have dial up.

no
2042.

Solve : Batch File That Accepts Two Input Parameter To Copy A File?

Answer»

we have a scheduler called TIDAL Enterprise Scheduler a software that we use to schedule a job. the scheduler RUNS a windows copy command to copy a file however the job failed when it does not find a file. to avoid this a batch file is a workaround to check if the file EXIST and if not return a friendly message that tells the file is not found.

i am attempting to write a batch file that will accepts two input parameters. the first parameter is to tell what files is to be copied, and the second parameter is to tell where the files are to be copied.

basically here is what i have so far:

Code: [Select]echo off
rem parameter settings
set pInputFile=%1%
set pOutputFile=%2%
set vDate=%date%

rem DISPLAY system info
ver
echo Current SYSDATE date: %vDate%

rem display the source folder listing
echo Source folder listing
echo.
cd %~p1
dir %~p1

echo.
echo looking for the file %pInputFile%
echo.

for %%a in (%pInputFile%) do (
if EXIST %%a (echo %%a was found) ELSE (echo %~nx1 missing))

when i run the batch file with this command:
Code: [Select]check_file.bat "e:\apps\ias\travelvouchertst\in\*FPCSFADZ_*.ENC" "e:\apps\ias\travelvouchertst\out"

i got this output:
Code: [Select]Microsoft Windows [Version 5.2.3790]
Current sysdate date: Mon 04/12/2010
Source folder listing

 Volume in drive E is Data
 Volume Serial Number is 02EC-D431

 Directory of E:\APPS\IAS\travelvouchertst\in

04/02/2010  12:05 PM    <DIR>          .
04/02/2010  12:05 PM    <DIR>          ..
04/08/2010  11:50 AM           883,908 1FPCSFADZ_sample01.ENC
03/23/2010  12:00 PM           155,832 1FPCSFAEA_sample01.ENC
04/08/2010  11:50 AM         1,008,522 2FPCSFADZ_sample02.ENC
04/08/2010  11:50 AM           860,688 3FPCSFADZ_sample03.ENC
04/08/2010  11:50 AM           873,330 4FPCSFADZ_sample04.ENC
03/23/2010  03:21 PM                 0 ExpenseAnywhereTempFile.null
03/23/2010  04:15 PM         1,008,522 FPCSFADZ_20100323_051747.ENC
03/24/2010  05:20 AM           860,688 FPCSFADZ_20100324_051835.ENC
03/25/2010  04:18 AM           873,330 FPCSFADZ_20100325_041614.ENC
03/26/2010  05:25 AM           883,908 FPCSFADZ_20100326_052315.ENC
03/23/2010  12:00 PM           155,832 FPCSFAEA_20100323_091554.ENC
              11 File(s)      7,564,560 bytes
               2 Dir(s)   9,253,732,352 bytes free

looking for the file "e:\apps\ias\travelvouchertst\in\*FPCSFADZ_*.ENC"

1FPCSFADZ_sample01.ENC missing


Completed at 4/12/2010 11:36 AM

the files are existing and if i try to replace this line of code:
Code: [Select]for %%a in (%pInputFile%) do (
with this actual file it works:
Code: [Select]for %%a in (*FPCSFADZ_*.ENC) do (

Code: [Select]Microsoft Windows [Version 5.2.3790]
Current sysdate date: Mon 04/12/2010
Source folder listing

 Volume in drive E is Data
 Volume Serial Number is 02EC-D431

 Directory of E:\APPS\IAS\travelvouchertst\in

04/02/2010  12:05 PM    <DIR>          .
04/02/2010  12:05 PM    <DIR>          ..
04/08/2010  11:50 AM           883,908 1FPCSFADZ_sample01.ENC
03/23/2010  12:00 PM           155,832 1FPCSFAEA_sample01.ENC
04/08/2010  11:50 AM         1,008,522 2FPCSFADZ_sample02.ENC
04/08/2010  11:50 AM           860,688 3FPCSFADZ_sample03.ENC
04/08/2010  11:50 AM           873,330 4FPCSFADZ_sample04.ENC
03/23/2010  03:21 PM                 0 ExpenseAnywhereTempFile.null
03/23/2010  04:15 PM         1,008,522 FPCSFADZ_20100323_051747.ENC
03/24/2010  05:20 AM           860,688 FPCSFADZ_20100324_051835.ENC
03/25/2010  04:18 AM           873,330 FPCSFADZ_20100325_041614.ENC
03/26/2010  05:25 AM           883,908 FPCSFADZ_20100326_052315.ENC
03/23/2010  12:00 PM           155,832 FPCSFAEA_20100323_091554.ENC
              11 File(s)      7,564,560 bytes
               2 Dir(s)   9,253,732,352 bytes free

looking for the file "e:\apps\ias\travelvouchertst\in\*FPCSFADZ_*.ENC"

1FPCSFADZ_sample01.ENC was found
2FPCSFADZ_sample02.ENC was found
3FPCSFADZ_sample03.ENC was found
4FPCSFADZ_sample04.ENC was found
FPCSFADZ_20100323_051747.ENC was found
FPCSFADZ_20100324_051835.ENC was found
FPCSFADZ_20100325_041614.ENC was found
FPCSFADZ_20100326_052315.ENC was found


Completed at 4/12/2010 11:42 AM

why can't i use a parameter to do a loop? please advise.

thanks,
warrenFrom the looks of it, these two parameters are coming from the command line:

Quote

set pInputFile=%1%
set pOutputFile=%2%

If so, try using:

Code: [Select]set pInputFile=%1
set pOutputFile=%2

 

Quote
set pInputFile=%1%
set pOutputFile=%2%

to clarify

passed parameters have only one % sign, before the number

right... %1 %2 %3 etc

wrong... %1% %2% %3% etc
you should use ~ for possible quotes

Code: [Select]set "pInputFile=%~1"
set "pOutputFile=%~2"

thank you all that works when i removed the extra % from the parameter and make it like this below:
Code: [Select]set "pInputFile=%~1"
set "pOutputFile=%~2"

there is another thing that's going on with the batch file. when the file is not found it didn't go thru ELSE. please advise.
Try the following:

Code: [Select]if EXIST %%a (echo %%a was found) ELSE echo %~nx1 missing
2043.

Solve : Protected Mode DOS/16M error [6] Insufficient memory to load program.?

Answer»

Hardware: Acer Aspire 4720Z Laptop (Pentium Dual Core, 2GB RAM, 100GB Disk).
Platform: DOS 6.22, in Microsoft Virtual PC 2007, on Windows Vista Home Premium SP2.
Application: INFORMIX-SQL 4.10.DD6 (DOS).
Settings: CONFIG.SYS (DEVICE=C:\DOS\HIMEM.SYS /TESTMEM:OFF /Q);
                AUTOEXEC.BAT (SET DOS16M=3)

Description:
1. After DOS 6.22 boot, 614K real mem. and 65MB extended mem. available.
2. All DOS and INFORMIX environment variables are properly set.
3. I have an app. written with protected-mode  INFORMIX-SQL 2.10.06E working,
    (see video-demo at www.frankcomputer.com).
4. I installed INFORMIX-SQL 4.10.DD6 (Protected Mode DOS).
5. The database engine (PSTARTSQL.EXE) size is 535K.
6. When I execute PSTARTSQL.EXE, I get "DOS/16M error [6] INSUFFICIENT memory to 
    load program". This engine is supposed to load into extended memory, not in real.
7. I tried all DOS16M switch settings according to Rational Systems documentation,
    removing all TSR's, including FSHARE.EXE, which allows me to share
    Windows Vista drives, devices and folders with my DOS Virtual Machine,
    (Examples:  DOS Drive F: = Windows Vista Drive F: (USB Flash Drive);
                       DOS Drive C: = W.V. Drive C:,
                       DOS Drive T: = W.V. C:\Users\Root\Transfer,
                       DOS Drive L: = W.V. Parallel Port (LPT1:),
                       DOS Drive U: = W.V. USB001,
                       DOS Drive X: = W.V. Mapped Network Drive X: to Linux Server. 

      LAST DRIVE=Z:

2044.

Solve : "The system file is not suitable for running MS-DOS..." Please help me with this?

Answer»

Hi,

Please excuse the duplicate post, I was told to change the subject of the thread and that I would probably get a better response. I wasn't sure how to edit my first post, so here it is again with a different subject line:
 

I just registered here and am glad to have found this forum. I have a Dell Studio computer, almost a year old (desktop) and YESTERDAY for the first time, the computer got a virus. Since I have an online business and need my computer, and the geek squad couldn't come for a week, I called a local computer repairman. He removed everything from the computer, backed up documents, pictures, ETC, on my external hard drive, put everything back...Well, during the course of the very long visit, I mentioned how I didn't like Vista as much as I did Windows XP, so he put Windows XP (I think it's a bootleg copy) on my computer. Anyway, my husband and daughter are upset now because the computer is not connected to either of our printers (the Epson Stylus Photo 820 or the Dell V305w wireless). I called the computer tech, he told me to go to epson.com, download the info, etc, I called Epson, had a woman walk me through downloading the driver for our printer, and when we tried to run it to set the computer up we get the following message:

"The system file is not suitable for running MS-DOS and Microsoft Windows Applications, click close to terminate the program"

Do I need to reinstall Vista? Should I? The man also removed our wireless Linksys by Cisco and supposedly hooked the wireless up another WAY, my husband (who knows less than techie computer stuff than me lol) wants to know if we can just stick the wireless card back into the front of the computer where it was...and of course, if we need to get Vista back. By the way, I lost all of my Outlook information, which is very upsetting too...Any help and advice is greatly appreciated, thank you so much in advance.

Katy1977I'm not an expert, but it sounds like you downloaded the wrong file.

When you go to Epson.com, go to their "Drivers and Support" page. Enter your model number for your printer, and then download the driver for it. Make sure you are downloading the driver for Windows XP.

If you have the right file and are still getting that error message, check out this article:
http://support.microsoft.com/kb/324767

Good luck!Thanks so much, but I tried this and I don't seem to have the Autoexec.nt file, is there a way I can download this? or could it be misplaced on my computer? Thanks again for any help.

Katy1977From what I've read, and please correct me if I'm wrong, I will need to put a Windows cd into the computer, I need to know if I can use a Windows XP home cd since I have Windows XP pro or if it doesn't matter, or, should I just go back to Vista? I'm so frustrated, and want to get my printers working, any help is greatly appreciated, thanks.

Katy1977

A number of users have reported problems with an error similar to the following when installing or running some GMI products:

C:\WINDOWS\SYSTEM32\AUTOEXEC.NT. The system file is not suitable for running MS-DOS and Microsoft Windows applications. Choose 'Close to terminate the application.

This is a BUG created by Microsoft with certain Windows 2000 and Windows XP hotfixes, and with certain versions of Windows xp Service Pack 2. The upgrade process removes the autoexec.nt file necessary for running any 16-bit program (including some of our installers) in Windows NT-based systems..

Microsoft documents the problem and a somewhat cumbersome fix (requiring you to have your Windows 2000 or Windows XP installation CD in a knowledge base article:

http://support.microsoft.com/default.aspx?scid=kb;en-us;324767
I was able to copy the Autoexec.nt file from my laptop and e-mail it to my PC, then I copied it into the windows repair and windows system 32 files. The computer was able to communicate with the printer for the first time since this began, but when I downloaded the Epson driver I now get this error message:

The Win16 Subsytem was unable to enter Protected Mode, DOSX.EXE must be in your Autoexec.nt and present in your PATH

Microsoft offers the following resolution, which I don't understand at all,



Make sure that the line, "device=%SystemRoot%\system32\himem.sys," exists in the CONFIG.NT file.

Make sure that the line, "lh %SystemRoot%\system32\dosx.exe," exists in the AUTOEXEC.NT file.

Expand HIMEM.SYS, DOSX.EXE, or both from the Windows NT setup disks or CD- ROM disc if either or both are missing from the SYSTEM32 directory.

For more information on DOSX.EXE, query on the following keywords in the Microsoft Knowledge Base:

WOW and 16-BIT
            

so am asking that someone please explain what my next step is, thanks so much and have a great day!

Katy1977

BTW, The computer repair man came again yesterday, said the printer was broken, of course it's not, still works, (copied from my laptop) I have gotten more help from this place than this "computer repairman"...It's me again lol, I just saw this at the bottom of the windows page with the resolution:

APPLIES TO
Microsoft Windows 2000 Server
Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Professional Edition
Microsoft Windows NT Advanced Server 3.1
Microsoft Windows NT Server 3.51

My OS is Windows XP Pro, so now what do I do??? Thanks so much any help is greatly appreciated!

Katy1977Huh?

http://support.microsoft.com/default.aspx?scid=kb;en-us;324767

Quote

APPLIES TO

    * Microsoft Windows XP Professional
    * Microsoft Windows XP Home Edition
I was referring to the information below when I said it didn't apply to Windows XP

Make sure that the line, "device=%SystemRoot%\system32\himem.sys," exists in the CONFIG.NT file.

Make sure that the line, "lh %SystemRoot%\system32\dosx.exe," exists in the AUTOEXEC.NT file.

Expand HIMEM.SYS, DOSX.EXE, or both from the Windows NT setup disks or CD- ROM disc if either or both are missing from the SYSTEM32 directory.

For more information on DOSX.EXE, query on the following keywords in the Microsoft Knowledge Base:


   WOW and 16-BIT
            

Back to the top

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

APPLIES TO
Microsoft Windows 2000 Server
Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Professional Edition
Microsoft Windows NT Advanced Server 3.1
Microsoft Windows NT Server 3.51
Back to the top


Katy1977I now found this from someone who had the same issue:

I solved the problem by copying the following files from another
XP Home Edition computer that did not have the problem to the
following locations

c:\windows:
_default.pif

c:\windows\system32:
config.nt
autoexec.nt
dosx.exe
cmd.exe
command.com

What ever was screwed up, got replaced with a good one.


My question is, if I try this, can I cause more harm than good? I was able to copy and paste the autoexec.nt file from my laptop to my desktop, but I didn't have that file in my computer.

I do have the other files in my computer and want to know if I copy and paste them from my laptop are they automatically replaced? Is this advisable? Maybe the printer will work then. I"m looking forward to hearing back from some of you as to what to do, thanks so much.

Katy1977I actually copied the file on my laptop from a Windows XP home version, and my desktop has Windows Pro, so I'm wondering if this is why the printer still isn't printing...Also, I'd really appreciate any help on the last few posts I've posted, thanks so much and have a great day everyone.

Katy1977have you ever considered taking it back to the tech who screwed it up in the first place? with a bootleg copy of XP? Quote from: BC_Programmer on April 13, 2010, 03:56:09 PM
have you ever considered taking it back to the tech who screwed it up in the first place? <And> with a bootleg copy of XP?

I actually had the computer tech (I'm using that term very loosely) come back on Saturday and he couldn't fix it, all he did was try to download the drivers from the Epson site which I had tried already unsuccessfully. Believe it or not, his answer was that the printer broke! Ten minutes later he mentioned that he sells computers, my husband and I were both annoyed and wanted to laugh at the same time, I cut my LOSSES with him and would rather figure this thing out myself, of course, with the help of the real experts that are on this forum.

Faith
2045.

Solve : how to execute cmd on local machine instead on Remote Machine?

Answer»

Here's my situation. 

I am creating a batch file that would auto restart computers and logins.  The issue I am getting here is if the batch file is executed through remote procedures (remote machines), my batch file to auto login does not work.  I would GET an error stating remote procedures failed.  If I run my batch files locally on the machine, it has no problem restarting and logging in.

So my question is how do I execute a remote command that would run my batch file locally on a particular machine?

Example: my computer is Computer A.  Computer B is a test machine.
I WANT to execute a command from Computer A to run a batch file that is located on Computer B.  But I want to run the batch file locally on Computer B. 

OH I have tried "CALL" and our DOS version don't support "rexecd". Hi,

For this kind of tasks I use psexec from pstools.
I actually saw the psexec but I can't install anything on most of the computers I am working on.  Any other ideas?There 's nothing to install but only an exe to copy to your PC.
Nothing is needed but a valid account on the remote PC.

From your PC, the command to execute The_batch.cmd on a remote PC would be something like :

psexec \\"remote computer or ip address" - u "valid account on remote" -p "valid password on remote" -c (this option is optional and copies The_Batch.cmd on the remote PC) "The_batch.cmd"

Regards.

yeah, I know it's just copying files over but where I work they are pretty picky on what's on your computer.  Let's just say I would not risk it.

After some DIGGING around found that I could use Task Scheduler.  The only down side to this is user will have to wait for 2-5 minutes for Scheduler to activate it.  I tried doing it  (command "at") without time but it keeps telling me my parameters are wrong.  At least it's a solution.

If you guys know how to admit time for the "at" command that would be great.This doesn't sound right to me.....

You can google the AT command.

yeah, I have google the "at" command.  I tried it the way it was mentioned but my computer for some reason still requires a time.  Is it different for MS-
DOS version?

2046.

Solve : Extract info from Dir?

Answer»

Win XP H.

I'm trying to write a batch file to extract some details from a DIR listing.  So FAR I've got:

Quote

echo off
cls

for /f "Tokens=* skip=4" %%a in ('dir c:\*.*') do (
    set line=%%a
    echo !line:~0,14!


)
which works quite well but the last two lines of the listing contain the FILES and directory info which I don't want.  The info extracted from those lines is
Quote
195 File(s)
29 Dir(s) 11,

Is there any way of getting the for loop to ignore the final two lines.  Obviously the contents of the lines will change when another folder is listed.

ThanksUse the /b SWITCH with dir , the bare formatSince you are only setting one variable you dont need to use an array.. and with /b switch you dont need to skip any lines


for /f "tokens=*" %%a in ('dir c:\*') do set line=%%aThe idea is to be able to extract information from the Dir listing.  That information could be any combination of the information produced by Dir, last access date, created date, last written date, file size, filename etc.  using the /b switch suppresses everything but the file/folder name so how could I extract say the file/folder name and creation date if /b is used??? Quote from: Woodman on December 10, 2008, 12:06:27 AM
The idea is to be able to extract information from the Dir listing.  That information could be any combination of the information produced by Dir, last access date, created date, last written date, file size, filename etc.  using the /b switch suppresses everything but the file/folder name so how could I extract say the file/folder name and creation date if /b is used???

You can still get the file info with dir /b. Type for /? at the prompt and read the part about variable modifiers.


Quote from: diablo416 on December 09, 2008, 11:52:11 PM
Since you are only setting one variable you dont need to use an array..

What array? Since when did cmd have arrays? Quote from: Dias de verano on December 10, 2008, 12:15:17 AM
Quote from: diablo416 on December 09, 2008, 11:52:11 PM
Since you are only setting one variable you dont need to use an array..

What array? Since when did cmd have arrays?

don't be so sure, maybe diablo416 knows something you don't.

heh. yeah....


When did we start helping Megaman 2 Robot masters anyway? Quote from: Dias de verano on December 10, 2008, 12:13:42 AM
You can still get the file info with dir /b. Type for /? at the prompt and read the part about variable modifiers.

Right on the mark thank you.  I found everything I need except a syntax to return file ownership details.  Do you know of one?  I tried o and q without success.

This would be a case of knowing your data up close and personal. You can send the directory list through the pipe, excluding lines which have either an open parenthesis or a close parenthesis. Other characters could be used and you could include characters as well.

Code: [Select]echo off
cls
setlocal enabledelayedexpansion
for /f "skip=4 tokens=1-6" %%a in ('dir /q /a:-d c:\*.* ^| find /i /v "(" ^| find /i /v ")"') do (
    echo Owner: %%e File: %%f
)

To access the other columns in the dir list, you'll need to reference the other variables defined by the tokens parameter.

Quote
Quote from: Dias de verano on Today at 02:15:17 AM
Quote from: diablo416 on Today at 01:52:11 AM
Since you are only setting one variable you dont need to use an array..

What array? Since when did cmd have arrays?

don't be so sure, maybe diablo416 knows something you don't. <snicker>

Personally I have always thought of batch language as a trip down the rabbit hole, so who better to consult than the White Knight about arrays in batch code:

Code: [Select]set month=12
for /f "tokens=%month%" %%i in ("January February March April May June July August September October November December") do (
        set month=%%i
)
echo %month%

Hmmmm, his logic could be backwards, but since he is talking backwards, he got it right!

Quote from: Sidewinder on December 10, 2008, 05:00:52 AM
Personally I have always thought of batch language as a trip down the rabbit hole, so who better to consult than the White Knight about arrays in batch code:

Code: [Select]set month=12
for /f "tokens=%month%" %%i in ("January February March April May June July August September October November December") do (
        set month=%%i
)
echo %month%

Hmmmm, his logic could be backwards, but since he is talking backwards, he got it right!


That's a pseudo-array. Quote from: Dias de verano on December 10, 2008, 11:42:13 AM
Quote from: Sidewinder on December 10, 2008, 05:00:52 AM
Personally I have always thought of batch language as a trip down the rabbit hole, so who better to consult than the White Knight about arrays in batch code:

Code: [Select]set month=12
for /f "tokens=%month%" %%i in ("January February March April May June July August September October November December") do (
        set month=%%i
)
echo %month%

Hmmmm, his logic could be backwards, but since he is talking backwards, he got it right!


That's a pseudo-array.

Exactly; I see no subscripts anywhere.Good grief! Tough crowd.

Quote
That's a pseudo-array.

What is a pseudo-array?

Quote
Exactly; I see no subscripts anywhere.

I was under the impression that the month variable acted as an index into the array. However the White Knight suggested the following snippet for all the index lovers out there:

Code: [Select]echo off
setlocal enabledelayedexpansion

: Make Array
for /l %%y in (1, 3, 68) do (
  call set /a idx=%%idx%%+1
  call set array.%%idx%%=%%y
)

: Read Array
for /l %%i in (1,2,11) do (
  for /f  %%x in ("!array.%%i!") do (
    echo Array Index: %%i  Value: %%x
  )
)

 Thank you Sidewinder - the code in your reply #8 is a great learning experience and of course works splendidly.

The other comments in various replies about arrays, pseudo-arrays, White Knight et al are way above my level of knowledge.  I cannot find that an array as shown in your reply #11 has anything to do with extracting Dir details but I'll keep LOOKING (or did my thread just get hijacked?).

Thanks to all for the input, much appreciated. Quote from: Sidewinder on December 10, 2008, 06:28:23 PM

I was under the impression that the month variable acted as an index into the array. However the White Knight suggested the following snippet for all the index lovers out there:



any attempt to use arrays in batch is a pseudo array. the definition of an array holds that they all have the same name, and are accessed via noncongruous subscripts. In your examples, each variable has a name that is simply formed from the index it refers to, there is no way to reference the array as a whole.

for example, if you were to list environment variables after creating a "array" as you've described it, it will show all the "elements" of the "array".


Although I must contend that it is a good workaround that offers array-like access methods.


A similar thing occured with javascript, java doesn't have intrinsic support for arrays. The original solutions were pretty similar to that which you've created. Anyway, the entire problem dissapeared when JavaScript became an ECMAscript, and the standard (i believe) imposed the creation of an "Array" object.

Arrays are something that can be simulated, but unless the language specification actually mentions it, you can assume that you can't create anything that can be called an array in formal terms. (VB docs mention array a lot... same with C and a lot of other languages (javascript notwithstanding, lol), but the docs for command line extensions and so forth? Don't think so.)

What you've done is analogous to creating a file that contains other files, and calling it a file system. While you can access the files, you cannot do so using standard file system methods, just as you can do array-like things with your creation here, but cannot access it using standard array-access methods as supported by numerous array-featuring languages (javascript notwithstanding).

And finally, I must mention that it is a clever way of adding the ability to work with sets of data, assuming environment space isn't at a premium, of course.
2047.

Solve : Makeing a batch exicute a text?

Answer»

hello im a bit new to batch files. OK is there any way to make it so that after i make the batch open notepad it enters a text into the notepad.
i did do a lot of searching to see if anyone has posted about this but no luck on my end
thank you for your help.
You can make the text first and then make Notepad open it

Code: [Select]echo Title>sample.txt
echo Next line>>sample.txt
echo Last line>>sample.txt
Notepad sample.txt
right i UNDERSTAND that. but is there any way to first open the notepad.exe then have the batch create a line in the notepad. like
  Code: [Select]echo off
start notepad.exe
(now some way to enter a code that adds text to the notepad)
Quote

right i understand that. but is there any way to first open the notepad.exe then have the batch create a line in the notepad. like

No. Notepad is a WINDOWS application. You'll need to use a language that can grab a handle to a window.

VBScript sample:
Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad"
WScript.Sleep 100
WshShell.AppActivate "Untitled - Notepad"
WScript.Sleep 100
WshShell.SendKeys "This is line 1"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 500
WshShell.SendKeys "This is line 2"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 500
WshShell.SendKeys "This is line 3"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 2500

Save script with a VBS EXTENSION and run from the command line as wscript scriptname.vbs

Good luck.
2048.

Solve : Checksum test using batch?

Answer»

I was wondering if someone might be able to show me a way to perform a Checksum test between two files a KNOWN good and a questionable ONE USING a batch? There is file compare that can be run, but is that the same as a checksum or does it only look at name and size, where a checksum will detect a variant between say Test.txt of 4k in size and another Test.txt of 4k in size with altered contents but taking up same name and storage space.

Thanks!COMP /?fc will tell you if 2 files are identical or not.

type fc /? at the prompt to see syntax

2049.

Solve : How to Use Multiple Extentions?

Answer»

Is it possible to list multiple extentions to match in a single command, or do I need to USE multiple commands in a batch FILE, &AMP;& operator?  For example something like:

dir /S (*.log | *.txt)

which would list all "*.log" or "*.txt" files, or for example something like "del *log | *.txt"?Use a semicolon and a space to separate the file masks

e.g. to find all log and txt files in this and sub folders:

Code: [SELECT]dir /s *.log; *.txt
and to delete all log and txt files:

for /f "delims==" %%F in ('dir /b /s *.log; *.txt') do del "%%F"

2050.

Solve : Dos 6.22 on HP ze4500 does not fill screen.?

Answer»

Hi,
Perhaps someone else has run into this problem...I have Dos 6.22 and Wfw 3.11 installed on a HP ze4500. I was ABLE to change the Wfw driver so I could use the full screen...but Dos still has a BLACK unusable border around the command line, very hard to use. Is this a Vesa ISSUE, config.sys, autoexe.bat?
Any help WOULD be greatly appreciated and thank you for your participation.