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.

8151.

Solve : looking for some 3rd Party MS-DOS encryption apps..???

Answer»

anyone know of any 3rd party encryption apps that WORK LIKE cipher.exe does through cmd to encrypt ENTIRE folder contents but with DIFFERENT encryption types though...??TRY Here...

8152.

Solve : Backup Batch File?

Answer»

I am new to making batch files. What I want to do is make a backup batch file.

1.) I want it to copy:
C:\DOCUMENTS and Settings\[User]\My Documents

2.) Zip the files

3.) Archive them by DATE onto the "D:\Backup" (seperate hard drive) folder

I want to be able to do this EVERY day for a backup.

Please help me.Well than you also want to make SURE that if the file is already copied that it isn't copied again. (am I wright?)

JONAS That is correct

8153.

Solve : Need help with copy?

Answer»

Greetings all. This is my first post here. I was unable to find an ANSWER in previous posts. I basically do not know anything about DOS, but I have managed, by extensive trial and error, to create a batch file, Install.bat, to copy an Access database from a share drive to my local desktop as follows:

COPY /Y \\106.102.5.44\fttpva_shared\FTTP.adp "c:\documents and settings\all users\desktop" /v

The only way I could get it to work is by putting "" AROUND the destination. It works fine, and I can immediately open the file by clicking on it once it is intalled. I also have another batch file, decompile.bat, to decompile and open FTTP.adp as follows:

c:windows /decompile c:\documents and settings\all users\
start/max fttp.adp

If the FTTP.adp file is installed on my desktop by opening the share drive and RIGHT clicking and pasting it on my desktop decompile.bat works fine and opens the file. When FTTP.adp is installed via my Install.bat, however, I get the error message:

"Windows can not find 'fttp.adp'. Make sure you typed the name correctly then try again, blah, blah, blah."

If I go into explorer the file is right there as it should be in c:\documents and settings\all users\desktop, so why can't windows find it?Am I missing SOMETHING? I am using XP service pack 2, but some of my users have older computers. My goal is to create a simple batch file that will overwrite their local copy of our database frontend if they already have it, or install it if they do not, then open it. I want to get away from having to email it out everytime I have to make an update to it. It seems like I am missing something so simple. Any ideas? Thank you in advance.I am new to this too but quotes around the file name would seem useful. I THINK the blanks between documents and settings are throwing it
good luckThanks for the quick reply. I thought that also and already tried, but it does not work, or explain why decompile.bat works when I copy and paste the file on my desktop but not when installed with install.bat. I have been searching for dos copy on google all morning, and I can not see any reason why my decompile.bat does not work.Well the paths are totally different. Try changing the...

Code: [Select]c:\documents and settings\all users\start\max fttp.adp
to...

Code: [Select]C:\documents and settings\all users\desktop\fttp.adp
If it still doesn't work post back.

8154.

Solve : How to run more RELATED commands with the same variable read from a text file??

Answer»

Hello!

I have a dilemma of that I need to run commands that depend on the result of the previous one. How do you do that with a FOR loop?

If I'd rephrase this question, it would say: How can you run more than one command with a word picked from a text file?

For example I have a text file "computers.txt" that has the LIST of all active computers like this:

cp001
cp002
cp005
cp022
etc.

Then I want the batch file to pick the first computer name, then do these or any multiple commands with the same computer name:

a) if not exist "\\%computer%\c$\program files\eudora\nicknames\sample.txt" copy whateverfilename.txt "\\%computer%\c$\program files\eudora\nicknames\"

b) echo %computer%>>resultlog.txt

...then go and pick the next computer name from the file computers.txt and run the same commands again until it finished reading the last name from the text file.

Geza

for /f "delims==" %%A in (computers.txt) do (
set computer=%%A
if not exist "\\%computer%\c$\program files\eudora\nicknames\sample.txt" (
copy whateverfilename.txt "\\%computer%\c$\program files\eudora\nicknames\"
REM put this here to log only when a file needed copying
echo %computer%>>resultlog.txt
)
REM or here to log every computer on the list regardless
echo %computer%>>resultlog.txt
)


did you want the echo to resultlog.txt whether or not sample.txt is copied?





Contrex,

You just made my day!!

Who would have THOUGHT of, that the solution is using parenthesis??
I didn't.

(I expected some kind of multiple For/Next loops, that I learned in Algol, more than 30 years ago.)

I've been using batch files in my work (network administrator) in the past 15 years but I could never figure out the solution to this problem, (For /? was no help in this matter) so when I needed to run a batch file for the same result, I used excel and notepad to create a batch file with as many lines as many I needed and used "find/replace" all - heavily and used IF and GOTO like crazy.

No, I don't need conditional %errorlevel% reporting, but Thank You for offering it to me, the batch file example mentioned in my question was there just for the sake of an example.

I will have an another question though, but I won't clutter this thread with it, because it is a different subject, I will start a new one a bit later.

Thanks a bunch again for the solution!!!

Geza
I found this command on a page of a similar question:

<
REM For loop example to pull each entire line from another file
REM Note that each line is executed independantly from all others

for /f "tokens=*" %%a in (file.txt) do CMD /C %%a
>

where the only difference is in between the quotes:

"tokens=*" and "delims=="

What is the difference? Or, what is the meaning of the 2nd "=" after "delims="?

Can you recommend me a good book or maybe a website where I can learn more about this stuff in this dept?

Thanks,
Geza

------------------------------------------------------------------------
delims=xxx - specifies a delimiter set. This replaces the
default delimiter set of space and tab.
tokens=x,y,m-n - specifies which tokens from each line are to
be passed to the for body for each iteration.
This will cause additional variable names to
be allocated. The m-n form is a range,
specifying the mth through the nth tokens. If
the last character in the tokens= string is an
asterisk, then an additional variable is
allocated and receives the remaining text on
the line after the last token parsed.
------------------------------------------------------------------------Hi guys I'm a girl from 75 I use to play Janitor Joe a lot but now I tried to play it after I founded free on the net however is running way to fast I can't get it to work. what do I need to do any IDEA?75? LE soixante-quinze (Paris)? Alors, chérie, il faut que tu commences ton propre fil...Quote from: Geza on July 28, 2007, 12:15:23 PM

"tokens=* delims=="

What is the difference? Or, what is the meaning of the 2nd "=" after "delims="?

As far as I can see, "tokens=*" means "no token separators", ie parse the whole line,

If the last character in the tokens= string is an asterisk, then an additional variable is allocated and receives the remaining text on the line after the last token parsed. (IE if the asterisk is the first and last character then there is no last token, and the whole text of the line is passed to the first variable)

... and "delims==" is equivalent to "delims=", ie "token delimiters are the start and end of the line",

so this options block:

"tokens=* delims=="

is a kind of dummy placeholder meaning "process the whole line and don't split it".

examples...

Quote
@echo off
echo data set="eggs bacon tomatoes"
echo.
echo "delims="
for /f "delims=" %%A in ("eggs bacon tomatoes") do (
echo variable A=%%A
)
echo.
echo "delims=="
for /f "delims==" %%A in ("eggs bacon tomatoes") do (
echo variable A=%%A
)
echo.
echo "delims=*"
for /f "delims=*" %%A in ("eggs bacon tomatoes") do (
echo variable A=%%A
)
echo.
echo "delims= "
for /f "delims= " %%A in ("eggs bacon tomatoes") do (
echo variable A=%%A
)
echo.
echo "tokens=1,2,3 delims= "
for /f "tokens=1,2,3 delims= " %%A in ("eggs bacon tomatoes") do (
echo variable A=%%A
echo variable B=%%B
echo variable C=%%C
)
echo.
echo data set="eggs,bacon,tomatoes"
echo.
echo "tokens=1,2,3 delims=,"
for /f "tokens=1,2,3 delims=," %%A in ("eggs,bacon,tomatoes") do (
echo variable A=%%A
echo variable B=%%B
echo variable C=%%C
)
echo.

echo data set="eggs,bacon,tomatoes,sausages,fried Velveeta,corn pone,kippers"
echo.
echo "tokens=1,2,3,4* delims=,"
for /f "tokens=1,2,3,4* delims=," %%A in ("eggs,bacon,tomatoes,sausages,fried Velveeta,corn pone,kippers") do (
echo variable A=%%A
echo variable B=%%B
echo variable C=%%C
echo variable D=%%D

echo.
echo extra variable called into being by asterisk at end of "tokens=" string
echo variable E=%%E
)


output...

Quote
data set="eggs bacon tomatoes"

"delims="
variable A=eggs bacon tomatoes

"delims=="
variable A=eggs bacon tomatoes

"delims=*"
variable A=eggs bacon tomatoes

"delims= "
variable A=eggs

"tokens=1,2,3 delims= "
variable A=eggs
variable B=bacon
variable C=tomatoes

data set="eggs,bacon,tomatoes"

"tokens=1,2,3 delims=,"
variable A=eggs
variable B=bacon
variable C=tomatoes

data set="eggs,bacon,tomatoes,sausages,fried Velveeta,corn pone,kippers"

"tokens=1,2,3,4* delims=,"
variable A=eggs
variable B=bacon
variable C=tomatoes
variable D=sausages

extra variable called into being by asterisk at end of "tokens=" string
variable E=fried Velveeta,corn pone,kippers

Quote
Can you recommend me a good book or maybe a website where I can learn more about this stuff in this dept?

You could type "FOR loop tutorial" into Google. This one is pretty good.

http://www.student.oulu.fi/~vtatila/batch_tutorial.html#forContrex,

Last night I noticed, that the "new reply notification" messages from this website were caught by my spam filter, that's why I didn't notice your reply until now.

Thanks a lot for explaining to me basically the difference between the terms "tokens" and "delims" and how can you use any of them for indicating "take the whole line in a text file".

Also, thanks for the link to Veli-Pekka's tutorial page on using "For", it is a GREAT page for learning DOS scripting!

Geza
8155.

Solve : How to Write a Batch file that Closes an Application or File?

Answer»

Hello all,

I am trying to WRITE a batch file that WOULD close access 2003. HOPEFULLY a specific mdb file but if not I will close the wole APPLICATION. Any help is greatly appreciated.
tasklist | findstr program.exe && taskkill /im program.exe

Replace program.exe with the running NAME of Access 2003.

8156.

Solve : Pinging ??

Answer»

is it possible PING an specific ip and if the ip gives answer then RUN a specific command something

ping 192.162.1.52 if return GOTO weei
exit
:weei
echo it works!
pauseQuote

...and if the ip gives answer

Ping ALWAYS gives a response so try and be more specific next time. It would also help us if you mentioned your OS.

Code: [Select]@echo off
ping -N 1 192.162.1.52 | find /i "reply from" > nul
if not errorlevel 1 echo it works

Good luck. 8-)
8157.

Solve : How to make a batch file wait??

Answer»

Hi !

This is my FIRST message in this forum. Good day to all.

I want to monitor a file. When the file changes, I want to be informed.
There are folder watching programs for this, but I should write my own.
I want a batch file to check a file PERIODICALLY. In case of any changes, I want it to trigger a command. For example opening the changed LOG.TXT file.

I did it with the following batch file.
FC.EXE is a file of XP. It compares and finds out the differences between two files. And there is SLEEP.EXE from old dos versions.

This batch file does the following :
1 - Compares two files. When there is a difference, it opens the changed file.
2 - When the user reads and closes the log.txt file, sleep.exe waits 120 seconds
3 - 1 and 2 repeats.

@echo off
:START
FC c:\log.txt e:\log.txt
IF ERRORLEVEL 1 goto DIFFERENT
GOTO END
:DIFFERENT
e:\log.txt
:END
sleep 120
goto START

The only problem is that : the CPU usage is 100 % when the sleep command runs.

Is there a way, to make a batch file wait for a while and then run again without making the CPU %100 busy.

If I knew Visual Basic coding, It would be easy to do this.

Thank you all for your help,

OsmanYou could try:

Code: [Select]ping -n 121 localhost >NUL
If 121 doesn't give a reasonable time you could try tweaking it a bit.Dear DeltaSlaya,

Thank you very much. You've solved my problem. That's what I want.

OsmanNo problem!

Thats a common way to resolve such an issue without USING additional files, and as I'm aware it doesn't use any considerable amount of CPU time.

If you have any other batch file queries don't hesitate to ASK on this forum again.

8158.

Solve : How to escape | < > in a batch file.?

Answer»

Hey, I was just wondering how, when entering a value into a batch file you can automatically 'escape' out the characters that usually make the program close. "| < >".

I've tried set x=%x:^|=^^^|% though it doesn't work.

For example, how would I make this code work?

Quote

@echo off

set /p in=Input "|":
echo %in%>dump.txt

If the input was "|", how would I make it so "|" and only "|" is outputted to the file. No quotation marks either, I think they work?Escape the variable as if it were the character it would expand to.

Quote

@echo off
set /p in=Input "|":
echo ^%in% > show.txt
type show.txt
pause


Quote

Input "|":|
|
Press any KEY to continue . . .


Yea, I probably didn't phrase the question properly.

What if the variable included "< > |" anywhere inside it, eg "dksk>>|", for example.

How would you enable that to be used by an if, echo or other command, without causing an error and EXITING?Quite honestly, DeltaSlaya, this is where I say to myself, "here be the limitations of command LINE" and DIG out QBasic. Life is too short.

Ok, so it's just not possible? I thought that ":str1=str2" could work, I'm guessing it can't, and I haven't got it to work with it either.You did know you can make a batch file create and execute a Qbasic program?

echo FOR J=1 TO 10 > dome.bas
echo PRINT J >> dome.bas
echo NEXT J >> dome.bas
qbasic /run dome.bas

Thus you could for example get a string input and get it into a file by passing the string to a QBasic program to do the file creation and writing. You'd have to be sure QB was present on the system, which up to Win ME, you were.





@OP,
if QBasic is not present on the system (which newer windows OS doesn't come with it), then the next best thing after DOS is vbscript (considering native requirement). Quote from: ghostdog74 on AUGUST 07, 2007, 05:51:48 AM
@OP,
if QBasic is not present on the system (which newer windows OS doesn't come with it), then the next best thing after DOS is vbscript (considering native requirement).

Now, how did I know you were going to write that?

Next best? Vbscript is way better than QBasic.
8159.

Solve : save ping results?

Answer»

Hello all, I am looking for a way to SAVE the machines names that actually reply BACK on my PING command BAT file that I run.

Right now I am using the command below but must SEARCH through the txt file to find the machines that are alive because it saves everything.

ping -1 machine name 1>>results.txt

thanks
Just logging the successful pings...

ping -1 machine name && echo machine name >>results.txt
Thanks Contrex, I will give it a shot tomorrow.

SchmoWorks like a charm...thanks again Contrex

8160.

Solve : MSDOS is all thats left please help?

Answer»

The hard drive has it's own ribbon.

Now if you use the ribbon cable you have for the 2 cdrom type drives it has a double plugin for 2 drives.

Have you tried the hard drive and 1 of the cdroms only hooked to the motherboard IDE outlet where the hard drive is now working
off and tried it like that?i think i found the config.sys on the ME BOOT disk:

rem DEVICE=HIMEM.SYS /testmem:off
FILES=30
BUFFERS=20

DEVICE=cd1.SYS /D:tomato

rem DEVICE=cd1.SYS /D:tomato /P:1f0,14
rem DEVICE=cd1.SYS /D:tomato /P:170,15
rem DEVICE=cd1.SYS /D:tomato /P:170,10
rem DEVICE=cd1.SYS /D:tomato /P:1e8,12
rem DEVICE=cd1.SYS /D:tomato /P:1e8,11
rem DEVICE=cd1.SYS /D:tomato /P:168,10
rem DEVICE=cd1.SYS /D:tomato /P:168,9

LASTDRIVE=ZQuote

The hard drive has it's own ribbon.

Now if you use the ribbon cable you have for the 2 cdrom type drives it has a double plugin for 2 drives.

Have you tried the hard drive and 1 of the cdroms only hooked to the motherboard IDE outlet where the hard drive is now working
off and tried it like that?

no, im a little confused by this as the cdrom is at the top, and the hard drive is not within reach of the plug to connect them together. but i will try this i have nothing to loose. thanksQuote
The hard drive has it's own ribbon.

Now if you use the ribbon cable you have for the 2 cdrom type drives it has a double plugin for 2 drives.

Have you tried the hard drive and 1 of the cdroms only hooked to the motherboard IDE outlet where the hard drive is now working
off and tried it like that?

THIS WORKED!!!! i couldnt plug the hard drive and cdrom together but i did unplug the bottom adapti drive and booted up with the cdrom showing as R:..... i am so happy thank you dusty, and willy and everyone who helped... you are gonna be mad at me, but now i cant find my install cd
Well done Geogia - success at last.

We don't get mad we just get even. Very good to HEAR of a satisfactory outcome.

Good luck i am so happy... unfortunately the ME operating system i had is an upgrade, so therefore i cannot upgrade without putting 98 in first... so i DONT at this point have an operating system to install.. (it was in the old cdrom i had to take apart to get it out ....anyway, all that came with the computor originally is the factory restore disk which doesnt work... so i still dont have an operating system, but at least i know now i can load one in... you are so great... thank you thank you thank you.

do you know where i can download and burn one? if i am the orginal owner is there somewhere where i would have access to this

again many thanks and good wishes to everyone who helped.. especially willy thanks for the patienceYou cannot legally download a Microsoft operating system. If all you have is a ME upgrade, you will need an older qualifying product. You don't have to install the older one first, just have the CD available when installing.

So you are back where you started from. You need to install Windows.Im way ahead of where i started from, now i have a cdrom drive which i didnt before this all started.. i made the mistake of uninstalling the operating system with a disabled cdrom. i assumed the new one would work... it seems the adapti burner or second cd is bad, which i can live without so its all good.

dont want to do anything illegal, wasnt looking to, i just wondered if i could get it somewhere using my serial numbers and product key or SOMETHING. the computor did not come with operating system cd's just a RECOVERY cd which i have but it doesnt work. a friend let me borrow a geniune windows ME cd, but it appears to be an upgrade which needs 98 installed first.... or a valid product key for 98 im not sure how that works..

in any event i feel im way ahead of where i was. i was ready to throw the tower in the trash.Quote


so i still dont have an operating system, but at least i know now i can load one in...

Now the question is: Where are some places to get a good deal on a legitimate Windows install disk.

We're talking about versions prior to WindowsXP.
The first thing that pops to mind is eBay.
But that takes some patience, and willingness to measure and accept risk. That's up to you.

If you feel you need some advice on places to look, you might want to start another thread as that is quite a bit different topic and will get the proper attention that way.
You might want to ask what to expect to pay too.


8161.

Solve : HOW TO SEND MESSAGE (PING) IN LAN USING DOS?

Answer» PLEASE give syntax to send a message for one COMPUTER to another computer in a local area network using DOS.Are you talking about real DOS or the cmd in 2000/XP?The last person to post here that actually had DOS was February of last year...Yeah okay, point taken PATIO.

But another QUESTION then...
Your subject says ping but it sounds like you want to send a message?
If you want to ping a computer the syntax is ping and the computer name or IP.

I'm a bit unsure about posting out the syntax for sending messages since I know some people will use these to annoy others.
Fortunately the message sending ability has been disabled in XP service pack 2.
But I'll wait with the command for sending msgs till the OP has GIVEN a reasonable explanation for wanting this.
8162.

Solve : recovery of my ecer commputer?

Answer»

put in my recovery disk for my acer aspire t100 COMPUTER says cannot RUN on windows nt PLEASE boot your system into dos then run gdisk. tried booting all orders didnt work :( tried GOING to run cmd run gdisk not recognized internal or external command need help thank youHave you tried booting the computer with the CD in the drive?thanks for your reply gx1 man tried rebooty with disk in cd drive , didnt work i think i need the right command in dos, recovery cd says in dos type in command rdisk so i go to run cmd which i think im in dos? then type in rdisk says rdisk is not a recognized internal or external command operable program are batched file dont understand why acel would give you a recovery cd disk that wont work in its preloaded windowsYour next STOP would be to contact Acer.

8163.

Solve : Changing to the next device in the boot sequence via DOS?

Answer»

Once booted into DOS from a USB Flash disk, is it possible to exit DOS and have the loader switch control to the NEXT device in the boot sequence (from USB to CD-ROM or Hard disk)? Thanks.No.
The boot order is determined by the BIOS...WAY before DOS loads...Just to clarify, I don't mean DOS finding the boot order in BIOS, I just mean DOS BOOTING to another device. So I couldn't have DOS CHECK for an MBR on the CD drive (after loading drivers for it), then on the hard disk, and booting into one of those devices if an MBR is found?It is the BIOS that boots a device, so no, there's no way to get DOS to do what you want.

8164.

Solve : Make a .txt file form .bat?

Answer»

Hey everyone, i need help with something.
I made this batch THING with a list of commands like 'TYPE 1 to do watever'
I was wondering if there is any way to make a .txt file with text in it, for example:
'type 5 to save the readme for this file on the desktop'.

Thanks in advance.Why not just PRINT out the batch file?Have it echo the readme, but add ">> %userprofile%\Desktop" to the end (assuming you use XP). Like this:

ECHO Readme >> %userprofile%\Desktop
ECHO.
ECHO This file is designed to >> %userprofile%\Desktop

etc...How do you print something through a .bat file?

Either use the print or the type or the echo command DEPENDING where you want the output and where the input is.

Use the help switch /? with either command for more details. With type and echo you can redirect the output to the device of your choice.

8-)

8165.

Solve : How to Check if a Certain Process is already Running..???

Answer»

is there any code to check if a process is already running from a certain location..??

i need a code like:

IF C:\SYSTEM\SMSS.EXE IS ALREADY RUNNING GOTO END
:END
CLS


tasklist | findstr program.exe && goto end
:end
cls

That checks if program is running, but I'm not ure if that is precisly what you want.is it not possible to check if a process is already running from a specific location..??

If not is there any code that can prevent this same bat-exe from being ran more than once at a time
so if this bat-exe FILE is already running and the same bat-exe gets executed again while the first ONE is running, than this newly executed bat-exe ends itself.


I just need to MAKE my batch file that im compiling into an .EXE so that its only able to be ran in one instance of itself,
and if ANOTHER instance of it tries to be ran at the same time, it wont let it..
is this possible at all with batch or ms-dos..??anybody know of anything that might WORK at all..I think that DeltaSlayer and contrex have addressed this (i.e. running from a certain location) in your other thread (here)

8166.

Solve : Multi-Line file to Variable ...?

Answer»

Hello all,

Am trying to GET the contents of a file into a variable.
FILE CONTAINS: (but could be anything)
[highlight]sql-job-1.sql
sql-job-2.sql
sql-job-3.sql[/highlight]

Need to get it into a Variable like ... [highlight]sql-job-1.sql,sql-job-2.sql,sql-job-3.sql[/highlight] ... if possible.

The purpuse is to include the list from the file into the body of an email ....
set MailBody=The %Product% Instance `%Instance%` has performed one or more SQL updates/query's against the database `%SQLDatabase%`. Please refer to the individual logfiles for each of the following ... [highlight]%SQLLOGLIST%[/highlight] with regards to their success.

Hope I've provided enough of an explaination.
Note: DOS batch script indicdently uses SETLOCAL ENABLEDELAYEDEXPANSION .
Many THANKS in advance.
This might help:

CODE: [Select]@echo off
setlocal enabledelayedexpansion
set str=
for /f %%i in ([highlight]input.txt[/highlight]) do set str=!str! %%i,
echo %str%

The HIGHLIGHTED portion is a arbitrary file name.

Good luck. 8-)

Many thanks Sidewinder - figured you'd be the one to respond.
I'd actually had everything ~but~ the preceeding 'set str=', thinking it was not necessary - why, oh why.
The script I've written for work has been an eye opener (using `setlocal enabledelayedexpansion`) and have had to remember at what level of the script the executing code is to determine which operators (% / !) (if that's what you call them) to use.

Again, many thanks.The set str= is defensive coding. You never know what user environment variables have been defined previously.

Glad it it WORKED for you. Stop by any time. 8-)

8167.

Solve : read and write batch file include log file?

Answer»

is that posible to have a BATCH file that read and WRITE a storage device(hdd or Compact flash) in looping and generate a log file?

thanksYes, most likely.

What exactly do you want to do? What do you mean by read and write? Please elaborate and I'll write something simple for you, until someone more advanced intervenes.oh.thanks.
well, i have a compact flash card,
so i need a program to test it, read and write test looping(or i can SET a counter for it),
and a log file, just in case the test failed.@echo off
set /a x=0
set /a e=0
if not exist D:\ (
echo D: Not present.
pause >nul
exit
)

for /l %%I in (1,1,1000) do (
if exist "%temp%\GRNBELT.BIN" del "%temp%\GRNBELT.BIN"
RD /s /q D:\
for /l %%I in (1,1,10000) do (
set x=%random%
>>"%temp%\GRNBELT.BIN" echo %x%
>>"C:\GRNBELT.BIN" echo %x%
)
FC /b "%temp%\GRNBELT.BIN" "C:\GRNBELT.BIN"
if %errorlevel%==1 set /a e+=1
)

echo %e% Errors.
echo.
pause

--------------------
someone write this to me, D: is my compact flash card to be write,
C: is USB flash drive(DOS).
but i get the error, it cannot be run

8168.

Solve : Windows is very stubborn?

Answer» I need help with windows xp dos. I used a floppy to boot to dos and recieve a a prompt how do i CHANE this to get to the c prompt? I'm tring to remove windows xp and install windows 98 instead. There is no other op sys on the hd and i can't boot from install disk for 98Hi Mike - Welcome to the CH forums.

You cannot use a Dos bootdisk to delete Win.XP if your hdd is formatted NTFS, Dos will simply not recognize NTFS. You can use the Delpart utility from here to delete the NTFS PARTITIONS or you could use your XP cd to delete partitions and reformat Fat32 in preparation for INSTALLING Win.98

Good luck
8169.

Solve : Need Help in combining two Excell files?

Answer»

Hello All,

Please help me to get out of this.

Iam trying to add the contents of one excell sheet to another.

Iam USING Copy command at cmd prompt and it says copying success.

But when i really check the same by going to Excell it shows file as corrupted.

What i need is to add two excell sheets A1.xls and B1.xls to C1.xls.

Thanks in advance
Raj

Try doing this within Excel using a series of copy/paste operations. Excel FILES use a proprietary structure. The best the batch copy command can do is physically copy the files but not merge the logical structure of an Excel workbook.

8-)Thanks for timely reply,

But my problem is like this we are recieveing these two excell sheets from some other company as a report.

And we need to combine the same for our accounting department people.

Currently iam mergeing them manaully where as my boss wants it to be done using some script.

Help is greatly appreciated

RajTry recording a macro in Excel. This will at least eliminate some of the drudgery of this task.

"DOS" is text based so you could export each of the incoming xls files as csv files. Now your "DOS" copy command will WORK (copy A+B C) and then import the resulting file back into Excel.

A VBScript would work ALSO but you really haven't given us ENOUGH information about the incoming workbooks or the resulting workbook.

Good luck. 8-)

8170.

Solve : START %~d0\ IF THIS FILE IS BEING RAN FROM THE ROOT OF ANY DRIVE?

Answer»

START %~d0\ IF THIS FILE IS BEING RAN FROM THE ROOT OF ANY DRIVE

HOW CAN I MAKE THIS POSSIBLE - WHATS THE CODECould you PLEASE make sense?I need for this batch file to check if its being ran from the root of any drive Ex: C:\batch.bat or D:\batch.bat
and if it is then this code START %~d0\ will open that root drive of where its being ran from in a new explorer window..Quote

@echo off

if "%~0"=="%~d0\%~nx0" (goto yes) ELSE goto no

:yes
START %~d0\
pause

:no
echo Not in root.
pause

Probably a better way...Quote
Probably a better way...

Probably...

code saved as F:\fpath.cmd:

Quote

@echo off
echo Deltaslaya's code:
echo if "%~0"=="%~d0\%~nx0" (goto yes) else goto no
echo.
echo my code:
set rootfolder=%~d0\
set thisfolder=%~dp0
echo if "%thisfolder%"=="%rootfolder%" then whatever


Quote

F:\>fpath
Deltaslaya's code:
if "fpath"=="F:\fpath.cmd" (goto yes) else goto no

my code:
if "F:\"=="F:\" then whatever




Quote from: contrex on August 07, 2007, 02:10:27 PM
Quote
Probably a better way...

Probably...

code saved as F:\fpath.cmd:

Quote

@echo off
echo Deltaslaya's code:
echo if "%~0"=="%~d0\%~nx0" (goto yes) else goto no
echo.
echo my code:
set rootfolder=%~d0\
set thisfolder=%~dp0
echo if "%thisfolder%"=="%rootfolder%" then whatever


Quote

F:\>fpath
Deltaslaya's code:
if "fpath"=="F:\fpath.cmd" (goto yes) else goto no

my code:
if "F:\"=="F:\" then whatever






How did my code do: " "fpath"=="F:\fpath.cmd" " Quote from: DeltaSlaya on August 07, 2007, 02:17:13 PM
How did my code do: " "fpath"=="F:\fpath.cmd" "

Like this...

Variable modifiers (V=variable)

Edited from FOR /?

%~fV - expands %V to a FULLY qualified path name
%~dV - expands %V to a drive letter only (and colon) EG D:
%~pV - expands %V to a path only
%~nV - expands %V to a file name only
%~xV - expands %V to a file extension only
%~sV - expanded path contains short names only
%~aV - expands %V to file attributes of file
%~tV - expands %V to date/time of file
%~zV - expands %V to size of file

modifiers can be combined to get compound results:

%~dpV - expands %V to a drive letter and path only
%~nxV - expands %V to a file name and extension only
%~fsV - expands %V to a full path name with short names only

Your code:

if "%~0"=="%~d0\%~nx0" (goto yes) else goto no
^ ^ ^
| | |
filename drive filename and extension
| | |
fpath F: \ fpath.cmd


How come when I run the code:

Quote
if "%~0"=="%~d0\%~nx0" (goto yes) else goto no

:yes
START %~d0\
pause

:no
echo Not in root.
pause

From the C:\ directory the output is:

Quote
C:\>if "C:\Test.bat" == "C:\Test.bat" (goto yes ) else goto no

C:\>START C:\

C:\>pause
Press any key to continue . . .

how odd. Will investigate.

Whether I call it fpath.cmd or test.bat It works the same.

My OS is XP Professional SP2, is yours different?

I am running under cmd.exe

Quote

C:\>fpath
Deltaslaya's code:
if "fpath"=="C:\fpath.cmd" (goto yes) else goto no
my code:
if "C:\"=="C:\" then whatever

C:\>test.bat
Deltaslaya's code:
if "test.bat"=="C:\test.bat" (goto yes) else goto no
my code:
if "C:\"=="C:\" then whatever


This is what it does under XP command.com

Quote

C:\>command
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.

C:\>fpath
Deltaslaya's code:
if "FPATH"=="C:\fpath.cmd" (goto yes) else goto no
my code:
if "C:\"=="C:\" then whatever




I know why, %~0 just shows how the batch file was initially started. If you open it in explorer it gives the file path, if you open it in a prompt it gives the line that started it.So the batch file would have to be written so it works regardless of how it was started.
Well mine doesn't work if it is started from the command prompt by just its name, ie. fpath.

Because then %~0 would expand to fpath.

I suppose in a way it's like %cmdcmdline%, the line that initiated command prompt. ...system32\cmd.exe

Though if it is started by typing "cmd" %cmdcmdline returns "cmd":

Quote
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.

C:\Users\DeltaSlaya>echo %cmdcmdline%
"C:\Windows\system32\cmd.exe"

C:\Users\DeltaSlaya>cmd
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.

C:\Users\DeltaSlaya>echo %cmdcmdline%
cmd

C:\Users\DeltaSlaya>
8171.

Solve : Automated Backup Batch File?

Answer»

I am pretty NEW to batch scripting. I would like to make a batch file to backup certain directories, to another location. Also, i would like to CREATE an output log with the details of the backup and whether it was successful or not. Finally, i would like this log to have a time stamp (begin and end, if possible a time stamp for each line entry. Below is what i have so far. THANK you.



@echo off
Q:
:Make
mkdir Logs
IF EXIST Logs GOTO LOG
CD\Logs
IF EXIST Logs\BackupLog.txt GOTO LOG

:CREATE
ECHO BACKUP LOG > Logs\BackupLog.txt
ECHO. >> Logs\BackupLog.txt

:CREATE
ECHO BACKUP LOG > Logs\BackupLog.txt
ECHO. >> Logs\BackupLog.txt

:LOG
ECHO File Backup has started: >> \Logs\BackupLog.txt
ECHO. |DATE| FIND "Current" >> \Logs\BackupLog.txt
ECHO. |TIME| FIND "Current" >> \Logs\BackupLog.txt

ECHO. >> Logs\BackupLog.txt
ECHO File Backup was stopped: >> \Logs\BackupLog.txt
ECHO. |DATE| FIND "Current" >> \Logs\BackupLog.txt
ECHO. |TIME| FIND "Current" >> \Logs\BackupLog.txt
ECHO --------------------- >> \Logs\BackupLog.txt
ECHO. >> \Logs\BackupLog.txt


mkdir Batches
IF EXIST Batches GOTO Backup
mkdir Rules
IF EXIST Rules GOTO Backup
mkdir Signatures
IF EXIST Signature GOTO Backup
mkdir Templates
IF EXIST Templates GOTO Backup
:Backup
ECHO BACKUP IN PROGRESS
xcopy "C:\Documents and Settings\paduanoj\Desktop\Batches" "Q:\Batches" /s /e /k /i
xcopy "C:\Documents and Settings\paduanoj\My Documents\Outlook\Backup.Outlook\Rules"

"Q:\Rules" /s /e /k /i
xcopy "C:\Documents and Settings\paduanoj\My Documents\Outlook\Templates" "Q:\Templates" /s

/e /k /i
xcopy "C:\Documents and Settings\paduanoj\My Documents\Signatures" "Q:\Signatures" /s /e /k

/i


IF ERRORLEVEL 1 GOTO end_on_error



goto end

:end_on_error
@echo off
ECHO Error During Backup
pause

goto end

:endHi There,

all the features, that you NEED can be acomplished by USING robocopy.exe .

You can google on it, I think, you can download it from Microsoft.

It does excellent logging (if you want it), time stamp of starting, ending, time it took to run it, etc.

Check it out, you will be amazed how powerfull this XP/Win2000/W2k3 Command line utility tool, that happens to be a 32 bit executable, so it is also super fast.

Geza

thank you. I will check it out. Although my main goal was to get experience with creating batch files. Thank you again.

8172.

Solve : Need Help Please?

Answer»

I run a moparscape server (see www.moparscape.org) and i need a batch file that restarts my server every 30mins can anyone help me please?
This is the normal run server that i have and i have to restart it by myself:

Code: [SELECT]@echo off
title Server
java -Xmx1024m -CP .;./jython.jar;./MySql/mysql-connector-java-3.0.17-ga-bin.jar server
Thanks,
Onyxhow about using the windows task scheduler?Where is it lol and how do i use it?The task scheduler is LOCATED in Start-->All Programs-->Accessories-->System Tools-->SCHEDULED Tasks.
To use it you have to drag the item onto the screen, RIGHT click on it, goto properties and set the time for it to start.
Hope that helps.

8173.

Solve : Batch File help please?

Answer»

Need a batch FILE to print an excel file to a SPECIFIC network printer with an IP address. PLEASE help
:-? :-?

8174.

Solve : Browse for installation directory !?

Answer»

I wanna make browse script in batch file working on win xp !
Something like ...
Code: [SELECT]Enter directory !!!
(user write this) X:\Games\
Press Y for Yes to countinue or N to CHOOSE other directory !then dir for installation is = to x:\games\ and installation begins !
Im new in this type of scripting and gimme example please ... other part of the script for "choosing" and ect. is done !
This MAY help you out:

Code: [Select]@echo off
:loop
set /p dir=Enter directory:
echo %dir%
set /p ans=Press Y for Yes to countinue or N to choose other directory !
if .%ans%==.Y goto next
if .%ans%==.y goto next
goto loop
:next

rest of your code GOES here

8-)Starting with echo off !
Code: [Select]@echo off
Thats work if its alone in BAT file !
Code: [Select]:start
echo --------------------------------------------------------------------
ECHO 1. Install in current directory !
ECHO 2. Browse !
ECHO 3. Exit !
echo --------------------------------------------------------------------
set /p choice=
set choice=What is your choise ?
if '%choice%'=='1' goto install
if '%choice%'=='2' goto loop
if '%choice%'=='3' goto exit
ECHO "%choice%" ERROR ... TRY 1 , 2 or 3 !
ECHO.
goto start
:install
@UHARC.exe x -pwproject project.uha
goto exit
Thats work if its alone too !
Code: [Select]:loop
echo Browse for install dir ... NOTE !!!
echo --------------------------------------------------------------------
echo If the path you want to use doesn't exist
echo the program will be installed in current dir
echo and the folder will be automaticaly created !
echo --------------------------------------------------------------------
set /p dir=Where to install:
echo %dir%
set /p ans=Press Y(Yes) to install or N(NO) to choose other dir !
if .%ans%==.y goto next
if .%ans%==.Y goto next
if .%ans%==.n goto loop
if .%ans%==.N goto loop
goto loop
:next
@UHARC.exe x -t%dir% -pwproject project.uha
@pause
Exit comand is here !
Code: [Select]:exit
@EXIT
Where do i wrong ?

Quote

UHARC comands
-t directory
example: -tproject
and -pw password
example: -pwproject
x=extract

When i merge this two scripts i recieve error !
"(choose... 1, 2, or 3) = 1 is was unexpected at this time."
I dont know where is the error , all seems to be correct but dont work !

P.S. Thank you for the help ... when your script is alone in the bat file works great !You never mentioned why the merged script failed to run, but you may have some luck with this:

Code: [Select]@echo off
:start
echo --------------------------------------------------------------------
ECHO 1. Install in current directory !
ECHO 2. Browse !
ECHO 3. Exit !
echo --------------------------------------------------------------------
set /p choice=What is your choice ?
if '%choice%'=='1' goto install
if '%choice%'=='2' goto loop
if '%choice%'=='3' goto exit
ECHO "%choice%" ERROR ... TRY 1 , 2 or 3 !
ECHO.
goto start

:install
@UHARC.exe x -pwproject project.uha
goto exit

:loop
echo Browse for install dir ... NOTE !!!
echo --------------------------------------------------------------------
echo If the path you want to use doesn't exist
echo the program will be installed in current dir
echo and the folder will be automaticaly created !
echo --------------------------------------------------------------------
set /p dir=Where to install:
echo %dir%
set /p ans=Press Y(Yes) to install or N(NO) to choose other dir !
if .%ans%==.y goto next
if .%ans%==.Y goto next
goto loop

:next
@UHARC.exe x -t%dir% -pwproject project.uha
:exit
8-)
8175.

Solve : Old 386 again?

Answer»

I have the old 386 running again thanks to help from this forum so I am back at the well again. I have copied and moved a large portion of my data but I have a set of 6 backup floppies that I would like to restore. It's been since '92 so it obviously can't be too important, but my old employer would like some of his old DRAWINGS if I can find them. The problem is I forgot to record the directory info that they were backed up from so I don't know what directory to restore to. Is there some way to restore to a default or \* directory to save me on this or should I just write them off? I'm running DOS 3.?
Steve
What backup program did you use? If it was a DOS backup you need to use that for sure. What are the file extensions on the disks?The Backup/Restore utilities were changed with each version of DOS so you may need to have the same version of DOS that was used to backup the files. That said, something like this may work:

restore a:\*.* c:\restore /s

With any luck, the restore will build the directory tree from the backups under the c:\restore directory.

Good luck. 8-)

Typing restore /? at the COMMAND prompt will give you all the valid switches.Still no luck with the tough restore...
I have restored and retrieved all of my old data with the exception of the 6 backup discs that I don't know the original directory for. I have tried your suggestion as well as creating directories with names that I may have used in the past and trying to restore to them with no luck. Without the correct directory for a target the PC just says to put in the next disc without actually restoring anything.
I am running DOS 3.30 on the same PC that the backups were done on so the operating system is the same. The only info of any use that I get when I attempt to restore is the date of the backup and the sequential order of the discs.
The discs contain 2 files:
Backup.001 and Control.001, the extension number follows the sequence they were done in. Backup.* is consistent @ 353Kb until the last disc and control.* is 1Kb on all.
Is the directory information I am looking for in Control.001 somewhere and is it possible for a non-code literate rookie like me going to be able to locate it? As I said before the data has been in mothballs for years but this has become more of a personal challenge to try to solve (with much help from this forum) than anything else.
The files on the discs are AutoCAD.DWG files.
SteveI seem to recall that some versions of DOS required the last disk to be inserted first. You may want to try that.Did you, by any chance, create a log file of the backups at the time they were made? The log file should contain the necessary paths. If you did not create a log file, your only option may be to find the backup/restore programs from FreeDos. The FreeDos restore will allow you to specify ANY directory as the base directory for restoring the files.DONE!
I tried FREEDOS.org and found some info that SOUNDED like it would be helpful but I ran into some access problems with the site after I tried to get back on to check some documentation. I am not sure if their program supports backup/restore yet but at this point it doesn’t really matter. I got tired of trying to get back on and kept searching for another option. I located this link searching for “DOS 3.3 restore” http://a2.swlibero.org/a2763.htm
Chapter 642. The valuable DOS Freeware page
Restaur (7) - Replacement for Dos Restore, I downloaded restaur1.0 as a single file and was able to easily install it and restore my files to the directory of my choice. As I ran it I was able to SEE the directory the files were originally backed up from and was able to match the data on the control.001 file from the backup disc to the original folder. I had looked at control.001 in Wordpad before but I was looking for some type of DWG folder when the info on the discs was actually LOTUS. It is pretty obvious now but since I was looking for something else I missed it. All of this for data I have no use for, but it was an interesting experiment.
This is the DOS 3.30 control.001 file viewed in notepad of another backup I did as a test: ‹BACKUP ÿFACAD10\DWGS ÿÿÿÿ"ACAD.DWG ™ ™ ©Y "ESSCH.DWG k ™ k n½{ "ESSN.DWG ¨ §| ¨ S˜w "MOM.DWG - O? - !‚a "ACAD.BAK # |¥ # ¡\ "ESSCH.BAK `U Ÿª `U c¹^ "ESSN.BAK `Ö ÿÿ `Ö 9|\ "COLUMBIA.DWG 5€ _Ö 5€ º*_
ACAD20\DWGS is the folder the files were backed up from and the files themselves are pretty easy to identify. A simple note on the floppy would have saved a lot of work.
Thanks for the input to help me get this resolved. I may keep the old PC around just for fun now…
Steve
Glad to see everything worked out for you. Might be fun to create some REAL dos batch files and do a little programming in the old GwBasic.

8176.

Solve : I'm not crazy?

Answer» HI there,

Using Google I have been trying to create a simple batch program. I'm not a programer and I know I'm not crazy either. But I think what I'm trying to accomplish can't be impossible - it's just beyond my abilities. So I'm asking for help - before I go crazy and throw myself off a bridge.

I've spent the past 5 hours trying to make a batch file that will copy a .jpg to another directory and give it a new name. That part is EASY. There are variables though. The original .jpgs are pictures of people using numbers as the name. What I need is to have the picture copied to another folder with the ability to enter the persons proper name. Wait! It gets more complicated - People, for some silly reason, sometimes have more than a first and a last name. *censored* I was able to write seperate batch files for two, three and even four names and they work. But what I really want is to do it all from one batch script, select the number of names I need (2, 3, or 4), enter the original .jpg file, then enter the proper names, PRESS enter and end up back at the 'select how many names' option.

Here's what I've got so far:

:BEGIN
@echo off
set choice=
set /p choice=Enter the number of names for the pictured user to continue...
if '%choice%'=='2' GOTO COPY2
if '%choice%'=='3' GOTO COPY3
if '%choice%'=='4' GOTO COPY4

:COPY2
CLS

set /p choice=Enter picture number:
if '%choice%'=='%5.jpg' set choice=%5

set /p choice=Enter first name:
if '%choice%'=='%6' set choice=%6

set /p choice=Enter last name:
if '%choice%'=='%7' set choice=%7

CLS
COPY %5 "C:\Den\Destination\%6 %7.jpg"

etc. for the 3 names, and 4 names options.

Now, the above doesnt work. It asks the questions and looks the way I want, but it won't copy the picture. It says it can't find the picture. I have no clue why, but I'm hoping someone out there does and can tell me how to fix it, please.

TIA
Regards,
"Insane in Waterloo"KISS should be every coder's anthem.

%5, %6, %7 (actually %0-%9) are command line parameters. Unless you passed them on the command line when you ran your file, they have no value whatsoever.

The set /p statement takes everything input at the prompt literally. Whether someone's name is Cher or John Doe, or Edgar Allan Poe the variable takes on the value of every character typed up to the return key. In your case there is no reason to know whether someone has 1, 2 or 3 names, the variable will contain Cher, or John Doe or Edgar Allan Poe and if they are the Artist Formerly Known As Prince, well, that will all be in the variable too.

8-)Based on the reply I have modified it thustly:

:BEGIN
@echo off
set /p choice=Enter badge number:
if '%choice%'=='%1' set choice=%1

set /p choice=Enter user name:
if '%choice%'=='%2' set choice=%2

COPY %1 "C:\Den\Destination\%2.jpg"

GOTO BEGIN


Here's how I understand the above -

The first set /p choice is to ask me what the file I'm looking for is called. For example I enter 564658.jpg which will be REPRESENTED as the variable %1

The second set /p choice is to provide the new name of the file. For example I enter Jean Luc Picard which is represented as the variable %2

The final command is to copy %1 to the new folder and rename it %2 and go back to start the cycle again.

I know this is obvious to people except me but this doesnt work. Anyone care to help???
Well, it's simpler but think short story instead of NOVEL:

Code: [Select]:BEGIN
@echo off
set /p badge=Enter badge number:
set /p user=Enter user name:
COPY %badge% "C:\Den\Destination\%user%.jpg"
GOTO BEGIN

The %0-%9 variables have special meaning in batch files and cannot be used in the context you were using them.

8-)That'll work.. Thanks for making my life simple again.
8177.

Solve : Get month in cmd?

Answer»

Hey everyone

You know if you TYPE 'echo %date%' in the COMMAND prompt, it shows the date like:
Fri 02/23/2007

Is there any way for it to show the current month like from a batch file or something
Any help would be greatly appreciated Have no idea what OS you have, but this will work on some versions of Windows.

Code: [Select]set mm=%date:~4,2%
echo %mm%

8-)Hey thanks Sidewinder, I can use that.
Using xp btwQuote

Hey everyone


Is there any way for it to show the current month like from a batch file or something
Any help would be greatly appreciated


There is a free utility program that does a LOT of date and MATH functions.

Fdate
http://www.ferg.org/fdate/index.html

As far as I know, it works not only with MS-DOS, but with all versions of Windows command line.

It is well documented, but be prepared to SPEND a few minutes reading. It has a multitude of functions, so to get the one you want, and the format you want, you have to wade through all the other STUFF.
As with most anything, once you get the hang of it though, it is very easy to use.

I hope this helps.


8178.

Solve : Hiding Batch file DOS area??

Answer»

Hi all,

Is there a way to hide the running batch DOS box that pops up when you run the .bat file?

thanks,

LucasThis sounds sinister. Nah, I just want a PROGRAM to run after a sleep cycle with an addition of not letting the user see the box. They will prolly close the box and kill the process when it auto opens. Work related. We have Microsoft COMMUNICATOR at work, and when the user logs in to the pc, it needs to run, but the user opens MS Outlook simultaneously, and sometimes the MS Communicator freezes Outlook. Long story...You could try starting the batch file with the MINIMIZE switch:

start /min batch.bat

Note: Job will not OPEN a window but will be in the task bar.

8-)Thanks, THATS a good solution.

8179.

Solve : .me file?

Answer»

how to CREATE .me file to use in dos?
i have a .me file, but i can't edit it.
What is it your are trying to accomplish? More details on what and where it is. Is this a README file?yes.i s readme file...the INSTRUCTION is inside.
but how can i edit it,BACAUSE i download it and want to use for my own program.
or how can i create a new .me file?
does save it as .me file will make it?What if you open it with notepad?

8180.

Solve : Reading text file in Windows 95?

Answer»

Hello,

I want to read some lines from a text file and then execute a dos command for each of the line read using BAT file in Windows 95. I COULD accomplish this in Windows XP with the "for /f" command but I can't execute this in WIN 95 as command extensions is not enabled.

So could you'll please let me know how to enable command extensions in win 95 if its possible or suggest an alternative solution for my batch file.

Thanks.I don't seem to recall any command extensions in Win95. Depending on which version you have, VBScript may not even be an option. REXX is a great scripting language, easy to learn, is open source and of course free.

Good luck. 8-)

PS. Some version of BASIC or BASICA may even be installed with Win95.Thanks for the reply...but i really can't install anything on this windows 95 desktop.

So could any one suggest how i could loop and read some lines from a text file and then execute a dos command for each of the line read using bat file in Windows 95.

8181.

Solve : ADD DATE TO FOLDER NAME?

Answer»

This probably sounds like a bit of an odd question but I am looking to add the date to a folder name with a batch file. The reason for this is so that I can have it set to a schedule to run every day. The over all TASK is to put the date onto a folder name and then the program recreates the previous folder and fills it and then the next day at the same time this script runs again and everyone is HAPPY. The problem I am having is when I use the SET %DATE% command and try add its results to the folder is tells me that the MON or TUE or what ever the day is not a valid function. Is there another way to write this? Any help would be great.

If more information is needed please ask.

Thanks.
perhaps you could show us the batch code you have been using?
Sorry I decided to change accounts to keep some things consistent but the code is shown below:


SET %DATE%

rename \\PCNAME\D$\TEST\ \\PCNAME\TEST%DATE%\

I know this looks very BASIC but I am still learning the scripting world. Thanks for the help.
try here---> http://talk.bmc.com/blogs/blog-gentle/anne-gentle/dos-timestamp-tipsThank You very much gumbaz. That got me the date and time variable. Unfortunately I am unable to rename the file with that variable. I have tried with the URL path & Mapping a network drive with no success. I have tried using the xcopy, REN, and other commands to try to change the name with the variable with no success. Any ideas?Quote


SET %DATE%


I'm not sure what that line is meant to do. LOSE it! To set a variable, you don't use percent signs. To read it you do. For example

set food=eggs
echo %food%

Also if you want to read the value of %date%, you should not be trying to set it.

Use quotes around any file, folder or path containing spaces.

Quote

rename "\\PCNAME\D$\TEST" "\\PCNAME\TEST%DATE%"



I was missing the "" . Stupid mistake. The entire script looks like so:


REM Create sub directory CALLED \yymmdd_hhmmss

REM where yymmdd_hhmmss is a date_time stamp like 030902_134200

set hh=%time:~0,2%

REM Since there is no leading zero for times before 10 am, have to put in

REM a zero when this is run before 10 am.

if "%time:~0,1%"==" " set hh=0%hh:~1,1%

set yymmdd_hhmmss=%date:~12,2%%date:~4,2%%date:~7,2%_%hh%%time:~3,2%%time:~6,2%

MOVE "\\PCNAME\D$\TEST" "\\PCNAME\D$\TEST%yymmdd_hhmmss%"


Thanks for the help Guys/Girls

--I have alot of learning to do--
8182.

Solve : I want to Download/Copy?

Answer»

i want to download/copy a file from my server is that possible it is an HTTP:// adress based on port 80
i just want to RUN a command that DOWNLOADS a TEXTFILE. please helpif your server has FTP or SSH ENABLED, you can also use them to transfer your file
if only HTTP is enabled, you can use tools like wget to get your text file.
Wget

8183.

Solve : SETTING A VARIABLE THROUGHOUT ENTIRE CODE..???

Answer»

THIS IS MY CODE:

Code: [Select]SET DRIVE=D
IF NOT EXIST %DRIVE%:\ GOTO %DRIVE%-SKIP
START CALC
:%DRIVE%-SKIP

BUT THIS IS WHAT I GET AS RESULTS IN A CMD WINDOW:

Code: [Select]MICROSOFT Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\VM-WARE>"C:\Documents and Settings\VM-WARE\Desktop\1.BAT"

C:\Documents and Settings\VM-WARE>SET DRIVE=D

C:\Documents and Settings\VM-WARE>IF NOT EXIST D:\ GOTO D-SKIP
The system cannot find the batch label specified - D-SKIP

C:\Documents and Settings\VM-WARE>

SO HOW CAN I MAKE IT SEE THE :%DRIVE%-SKIP BY STILL KEEPING THE %DRIVE% VARIABLE..??Gumbaz, is there a caps lock key on your KEYBOARD?

You cannot make a label out of a variable. It cannot be done. Batch language does not support self-modifying code! Nice try though



8184.

Solve : Legacy program will not print from DOS?

Answer»

Hello All,

I have a challenge that you might be able to help me with. I have an older DOS/dBASE program that will not PRINT anywhere other than LPT1.

So I followed the instructions here:
http://geekswithblogs.net/dtotzke/articles/26204.aspx

Now I can print from the command line, but I still get the same error from the DBASE program. I was thinking that since both DOS and dBASE are looking to LPT1 that if I could get it to work for DOS the dBASE program would follow. But it seems like I am wrong. I was wondering if anyone would be able to point me in the right direction for this.

Thanks!What version of windows is this?

If XP you have to realize that the command line isn't DOS. It just HAPPENS to look a little like DOS. Every DOS based program that you execute in XP runs in a VIRTUAL DOS machine. Unfortunately not all programs runs correctly in this virtual machine.

I'm sorry I don't have a solution here, but just thought I'd share what I think might be the root of the problem.Deerpark - thanks for the reply!

The legacy program was written in dBASE 5 for DOS. THOUGH the print setup in the program just uses the default DOS printer settings. Which from what I understand defaults to LPT1. I am aware that the command line and DOS are not the same, but I was hoping that the emulation was close enough. Aparently not. The method I had posted previously will work on the second laptop I am working on, though it actually has a parallel port.

So far is seems like my only option is to use DOSPRN. Which is bad because that will allow text changes (centering, shrinking, etc.)

That is, unless I can find a computer manufacturer that will make laptops with parallel ports. Why not just save the job to a file and then use another app to print it? ?Read the comments on the article you mentioned. I have not tried it, but I like the fake printer idea.Thanks everyone for the input!

I did find out if the actual physical port was present, that the net use method was the way to go. But the computers we will be using will not have that port. ALSO, DOSPRN isn't a bad solution, which we will hopefully be using.

8185.

Solve : pre-defined variables?

Answer» OKAY WELL i have had this question and I have been working around it. How do i make a pre-difined variable? like so I can type %1% and it will show what %1% is because i type %1%=Hello or somethingI have no idea what your question is, but here goes:


Quote
set variable=string

Code: [Select]C:\Users\DeltaSlaya>set I=string

C:\Users\DeltaSlaya>echo %I%
string

C:\Users\DeltaSlaya>set I
I=string

C:\Users\DeltaSlaya>

I know thats PROBABLY not what you want but I didn't understand your question. If it's about setting variables type "set/?" in a command prompt.yeah that was pretty much it. thanxQuote from: gamerx365 on AUGUST 09, 2007, 03:04:13 PM
yeah that was pretty much it. thanx
8186.

Solve : Running Python Script with batch?

Answer»

I have downloaded the Python script from Google that generates a sitemap, and I'd like to automate the process with a batch file. However, my batching skills are limited to echo and ping.

BASICALLY, I need to create a batch file that changes the directory to and then runs the command "python sitemap_gen.py --config=config.xml"

All of this is doable in the command prompt, but it takes quite a few keystrokes. How do I do this?

-rockA batch file is basically one or more COMMANDS that run at the command line. So you enter the same commands that you would do from the command prompt. The batch file you want is probably something like:
Code: [Select]@echo off
cd \directory
python sitemap_gen.py --config=config.xmltried that and it didn't seem to work.

The file I had going was very similar to what you've posted, but I changed it just in case.

The results, however, are identical:
The black command prompt window opens, but nothing happens and it closes again. I've checked the sitemap.xml file to see when it was created and it hasn't changed since I did it manually a few hours ago.

Is there some WAY to see what the batch file is doing behind the scenes?

(leave echo on? It still didn't work.)

Code: [Select]@echo off
cd d:\tom\web\site\htdocs\scripts\map\
python sitemap_gen.py --config=config.xml
dunno what's wrong.Are you running this from C: or from D:? I assume PYTHON is in your path? And that sitemap_gen.py is in d:\tom\web\site\htdocs\scripts\map?
You can try this in case it is a drive letter issue:
Code: [Select]@echo off
cd /d d:\tom\web\site\htdocs\scripts\map
python sitemap_gen.py --config=config.xmlI'm running the script from C:, although I could put it in D: and just make an accessible shortcut. My windows/software HD is C:, my data HD is D:

However, they are both on the same Physical drive.

That didn't work. I MAY just scrap this and put up with the couple lines of typing every time. It's not like I NEED a new sitemap every time I add a file, but it'd be nice.

Thanks for the help, if you have any more ideas, I'm open.....

-rockTo see what is going on before the command prompt closes, try this:
Code: [Select]@echo off
cd /d d:\tom\web\site\htdocs\scripts\map
python sitemap_gen.py --config=config.xml
pauseLet us know what you get.sorry about the gigantic bump, but I thought I'd let people know that I got this to work

here's the .bat file
Code: [Select]@echo
E:
cd e:\python25
python d:\tom\web\site\htdocs\scripts\map\sitemap_gen.py --config=d:\tom\web\site\htdocs\scripts\map\config.xml

That's it. Runs without errors. I must've been a real batching n00b back then .

thanks for your help

-rock

8187.

Solve : netsh command static ip assign?

Answer»

Hi Iam trying with this and cant make it to work??
------
SET /P IP= IPADRESS:
SET /P MASK= SUBNET:
SET /P GW= GATEWAY:
NETSH interface ip set address "Local Area Connection" static %IP% %MASK% %GW%
-----
Why??
reg/spesse :-/What values are entered for ipaddress, subnet, and gateway? Are they valid? What error messages did you get? This is the kind of information we need to troubleshoot problems...we shouldn't have to drag it out of you.

You can get full details from netsh interface ip set address /?

Good luck. 8-)Sorry... I got this
The syntax supplied for this command is not valid. Check help for the correct sy
ntax.

and I typing like this
IPADRESS? 192.168.32.10
SubNet? 255.255.255.0
Gateway? 192.18.32.1

And the syntax is OK I think??? SET /P IP IPADRESS? %IP% ??
As in my SCRIPT???The set statements seem to be fine. I found this help for the netsh command, which is where I suspect the problem is:

Quote

Remarks: Used to change the IP address configuration mode from either DHCP to
static mode or static mode to DHCP. Adds IP addresses on an
interface with static IP address or adds default gateways.

Examples:

set address name="Local Area Connection" source=dhcp
set address local static 10.0.0.9 255.0.0.0 10.0.0.1 1
Source: Microsoft Help Command

Good luck. 8-)Tanx I solved it by my self..
The right syntax and execute command should look like this
*********
SET /P IP= IPADRESS?
SET /P MASK= SUBNET?
SET /p GW= GATEWAY?
netsh interface ip set address name="Local Area Connection" source=static %IP% %MASK% %GW% 1

*********

obvious this only works if you don't have changed your Nic name...

To put it back to DHCP
****
netsh interface ip set address "Local Area Connection" dhcp

****

And for vbs like this.

***********
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE AND index=9")

IP = InputBox("Type In New IP Adress eg. 10.11.12.13", "", "Type Here")
SUBN = InputBox("Type In New Sub Net Mask eg. 255.255.255.0", "", "Type Here")
GW = InputBox("Type In New Gateway eg. 10.11.12.1", "", "Type Here")
DNS = InputBox("Type In New DNS eg. 10.11.12.3", "", "Type Here")

strIPAddress = Array(IP)
strSubnetMask = Array(SUBN)
strGateway = Array(GW)
strGatewayMetric = Array(1)

For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
If errEnable = 0 Then
WScript.Echo "The IP address has been changed."
Else
WScript.Echo "The IP address could not be changed."
END If
Next

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

But I have trouble to make it generic "index 9" that is my Nic on this computer.
I am no good @ vbs but i am getting there, i will try to list all my Nic and make a choice
eg. 1 =lan ,2 =Wifi, 3=Blue tooth etc... and den run the script.
I will post the solution if I can make it to work..
:-/
reg/spesseOne nice things about functions is that they return a value which you can use to your advantage:

Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE AND index=" [highlight]& GetIndex()[/highlight])

IP = InputBox("Type In New IP Adress eg. 10.11.12.13", "", "Type Here")
SUBN = InputBox("Type In New Sub Net Mask eg. 255.255.255.0", "", "Type Here")
GW = InputBox("Type In New Gateway eg. 10.11.12.1", "", "Type Here")
DNS = InputBox("Type In New DNS eg. 10.11.12.3", "", "Type Here")

strIPAddress = Array(IP)
strSubnetMask = Array(SUBN)
strGateway = Array(GW)
strGatewayMetric = Array(1)

For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
If errEnable = 0 Then
WScript.Echo "The IP address has been changed."
Else
WScript.Echo "The IP address could not be changed."
End If
Next

Function getIndex()
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

cnt = 0
For Each Adapter In colNetAdapters
cnt = cnt + 1
strMenu = strMenu & cnt & ". " & Adapter.description & vbCrLf
Next

getIndex = InputBox(strMenu, "Choose The Adapter")
If CINT(getIndex) > cnt Then getIndex()
End Function

This should prompt the user by giving a menu of adapters from which the user can choose by number. Nice script by the way.

Note: You might want to do more error trapping so the user input is not too ridiculous.
yeah
8188.

Solve : Scanner Bat?

Answer»

hi all,
I need help with a Scanner bat. You see, my friend has a laptop that got broken from a virus and now HES at the YMCA (he LIVES across the street from it) and he makes BATS so no ONE else can enjoy the computer.
So i made a bat and sent it to my self in the email. The bat i sent to my self in the email will create my scanner bat.The bat is suppose to scan the the computers server hard drive for bat files that are listed in a txt.
Heres the txt file
"FIREFOX is mine.bat"
and etc.
it will have to delete them.
Thanks in advance!!!!What

8189.

Solve : can v replac multiple files(sameName) under a dir??

Answer»

Hi All,

Is it possible to replace some files with same names under a directory by some ms dos command..

I will explain the scenario in details

There is directory which has many sub diretcories. And all these subdirectories contain a file with common name.Likeways there are around 1000 files with the common name
But we dont know the directory structure in which this file is contained.
Now my requirement is to replace this common files with a new file.
Is it possible to do this?

Directory structure will look somewhat like this

Dir1

|
Dir1 Dir2 Dir3 Dir4 ....
| |
Sub1 sub2 sub3 sub4
Commonfie |
sub1
|
commonfile

Now i need to replace the common files coming under parent directory with a new file..

Is it possible to do this?

If my question is not clear,please get back to me

Regards
Fathima
You could try RUNNING a directory list of this common file with the /s and /b switches. REDIRECT the list to a file. This will produce a list of where the common file lives and where you will copy the new common file

Open up the file in an editor and using some basic search/replace you should be ABLE to create a batch file where each line is a copy command of the the new common file to the destination produced by the dir list.

Sample dir list:
Code: [Select]C:\dir1\sub1\commonfile.txt
c:\dir2\sub3\sub2\commonfile.txt

Batch file after search/replace in editor:
Code: [Select]copy c:\newcommonfile.txt c:\dir1\sub1\commonfile.txt
copy c:\newcommonfile.txt c:\dir2\sub3\sub2\commonfile.txt

By saving the edited code as a batch file, it can do the work for you.

Note: the code SNIPPETS are examples only; your data will be different.

8-)

8190.

Solve : Call another batch file?

Answer»

How do I write a runall.bat batch file to RUN cmd1.bat after FINISH, it will run CMD2.bat , after it finish running cmd2 then will cmd3.bat and quit . i am using windowsxp

C:\log\runall.bat

C:\log\A\cmd1.bat

C:\log\B\cmd2.bat

C:\log\C\cmd3.bat


easy
c:\log\runall.bat -----

call C:\log\A\cmd1.bat

call C:\log\B\cmd2.bat

call C:\log\C\cmd3.bat



Graham

8191.

Solve : I just want to share something useful i made ;)?

Answer»

[highlight]@ECHO off
mode 15 , 2
set /a xx=0
set /a gg=0
:num
set /a xx=%xx% + 1
if "%xx%"=="255" msg * ip serching is done you found %gg% ipnumbers.
echo pinging @ %xx%
ping -n 1 -w 500 192.168.1.%xx%|find /i "reply from" >NUL
if not errorlevel 1 goto uu
cls
goto num

:uu
msg * ip found at 192.168.1.%xx%
set /a gg=%gg% + 1
goto num[/highlight]

it pings all the ip's in ure networkYa so what does it mean in English? What does ping your IP mean?It's quite useful.Quote

Ya so what does it mean in English? What does ping your IP mean?

Ping-A UTILITY that forwards DATA packets to check the quality of a link or verify the connection of a MACHINE to the Internet.

8-)fffreakOOOOOOOOOOOkay! thank-ya!
8192.

Solve : how to print from a batch file?

Answer»

how to print an EXCEL from a batch file?
any help will be greatly appreciated!! If you want to print the file from the desktop, type:

@echo off
print "%userprofile%\desktop\name.xls"
cls
echo. Your file is being printed
pause
exit

Another very simple way is to copy cmd.exe from C:\WINDOWS\System32\ to wherever your excel file is. Then open that COMMAND prompt and just type:

print name.xls

hope this works

-------------------
CARBON DUDEOXIDEThe print command works with text files only. Excel workbooks have a proprietary structure with character SEQUENCES that will make most printers run AMOK.

You could write a standalone script, an Excel macro, or use the File==&GT;Print sequence in Excel.

Note: the standalone script could be called from a batch file :-?; using the Excel menus would be done within the Excel application; a macro would be able to use either a batch file or run manually within Excel.

8-)

8193.

Solve : empty file?

Answer»

How do i create a new empty file in DOS?
The equivalent of touch in Unix?

ThanksAt the DOS prompt type copy con yourfilename.txt
Pres ctrl+z
DOS should respond with something like "1 file COPIED"
The file will be placed in the current directory.Well ACTUALLY i was hoping for something more automatic that I could use in a batch file. SUGGESTIONS?

Thankscopy nul yourfilename.txt
you dont need the ^Z

GrahamQuote from: SHAMMER on August 07, 2007, 10:03:02 AM

Well actually i was hoping for something more automatic that I could use in a batch file. Suggestions?


See this thread.

Quote
cd\>filename

Works for me...echo. > filenameThat won't MAKE a blank file, that will make a file with a blank line in it.

either:

type nul>filename
OR
cd\>filename

create zero-byte files.
8194.

Solve : bat problem..think %username% isn't getting complete name...?

Answer»

My apologies if this subject has been covered. I have tried USING the search, as well as drilling through many of the forum pages, but I just haven't seen an answer to what I need. I am not very experienced in DOS and batch files

situation: we have an .EXE file that is downloaded to a user's desktop. When run, the exe extracts a local version of a website to a specific folder on the c drive as well as a batch file. The batch file, among other things, pushes a pre-made shortcut to the desktop, and then removes the .exe file originally downloaded.

We recently moved to XP machines (from 2000) and i noticed that on SOME machines the batch wasn't working as intended. I made some fixes that fixed the adding of the shortcut to the desktop (I had to change "all users"), but I haven't been able to get the exe to delete from the desktop.

After doing some research, I think the issue occurs for users having more than one profile set up in the documents and settings folder. Some of us can log into multiple domains. So... instead of just one profile, for example, y1234567, i have an additional one named y1234567.000.

Unfortunately, when I use %username% to get DOS (or whatever the command shell is with XP) to return the value, the .000 doesn't appear to be recognized by the machine. I CLEARLY have a profile named y1234567.000 in the folder structure, but echoing the %username% request only displays y1234567... since the exe was run from this .000 profile, the batch obviously can't delete something it can't see.

Does anyone know how to get around this?

I thought I could do some CONCATENATION and force the machine to see the .000. I added this to the batch file:

set zeroes=.000
set secondid=%username%%zeroes%

running this in it's own batch file does indeed return the value y1234567.000 but I am not sure the machine recognizes this as the same value as the second profile on the machine. It doesn't appear to as when I create a delete command such the one below, in conjunction with the code above, it doesn't work:

del c:\"documents and settings"\%secondid%\desktop\execute.exe

I even tried a test telling it the specific profile, but no dice...

del c:\"documents and settings"\y1234567.000\desktop\execute.exe

I am thoroughly confused and frustrated as I feel this is probably an academic problem to knowledgeable persons. I apologize for the length of this post, and thanks in advance to anyone who might be able to help.I might not be much help but as far as I have known for PC's when you log in the .000 is removed and the profile shows as the USERNAME only. If you are logged into the PC and run the script with the %username% it should work.

Would it be possible to see the script without any server names or anything?Not much idea

Just try
del "c:\documents and settings\y1234567.000\desktop\execute.exe"

instead of

del c:\"documents and settings"\y1234567.000\desktop\execute.exethanks for the replies. I must admit I stumped by some of this... particularly when commands I test from the command prompt don't seem to execute from the batch file.

for instance... here is the pertinent code in the batch...

del c:\docume~1\%username%\desktop\site1*.*
@if exist c:\site1 rd /s /q c:\site1
move c:\site1tmp\site1 c:\
move c:\site1tmp\windows\desktop\*.* c:\docume~1\%username%\desktop
cmd /c rd "C:\site1tmp" /S /Q

atm.. I'm trying to fix why the exe that extracts the SITE (named site1.exe) and runs the batch doesn't delete the the site1tmp folder when everything is done...

Even more frustrating is that the command cmd /c rd "C:\site1tmp" /S /Q works when tried from the dos prompt, as well as when it's tried from a seperate batch file that only has that line. In fact, I got the format for that line by searching the forums.

I can only conclude that something in the other lines of code in this section prevent my command from executing..but I don't understand what. I thought commands are executed sequentially in a batch, and therefore by the time we get to the last line everything else is done and nothing can cause a problem. Obviously I'm wrong, lol. any help is appreciated.Could you use the %userprofile% var instead of %username%\

This var will return the path to the currently logged on users profile.

8195.

Solve : Little help with small script?

Answer»

Okay, I need a little help figuring out why this isn't working. The probem is no matter what the VAR outlook always gets set to 2003. The PC i'm testing on has only office 2K installed. I have confirmed that the errorlevel is retruned correctly (errorlevel=1) so I can only presume that the problem lies in the else statement. I dunno it looks right to me. Any ideas?

Code: [Select]for /f "delims=" %%a in ('reg query hklm\software\microsoft\office /s ^| find /i "common\installroot"') do call :process "%%a"
GOTO :EOF

:process
echo %~1 | find /i "11" > nul
if errorlevel == 0 (
set outlook=2003
) else (
set outlook=2000
)
for /f "delims=" %%b in ('reg query %~1') do set opath=%%b
set opath=%opath:~22%
set opath=%opath:~0,-1%

:EOF
I should ADD for those that may not know: Office 2003 is version 11 and all the registry settings are nested in a subkey of "office" called 11.0. Same for the other version (e.g. office 2k is 9.0)I don't know about the rest, but that's not how you do errorlevel.

It's:

If errorlevel N command


N = 0 - 255 in descending order ie if you expect to choose between errorlevels 5 6 and 7 you have to do this

if errorlevel 7 goto eggs
if errorlevel 6 goto bacon
if errorlevel 5 goto toast

Alternative strategy:


set outlook=2000 & echo %~1 | find /i "11"> nul && set outlook=2003








Removing the == did not work...but I don't care, the second method did.

Thanks for the suggestionsee edit. I don't think errorlevel statements can be extended with parentheses. one line and goto label seems to be the preferred method.

8196.

Solve : Need a Variable to Specify the Drive that the OS is installed onto..???

Answer»

is there a variable i can use to specify the drive that the OS is installed onto..??
do you mean that you want to KNOW if there is a variable that a command or batch file can read and find out where the OS is installed?



yuppers..The variable is %systemdrive%

c:\>echo %systemdrive%
C:


I am surprised that you don't know about typing SET at the command prompt to see the system variables.

c:\>set
ALLUSERSPROFILE=C:\Documents and Settings\All Users
APPDATA=C:\Documents and Settings\Mike\Application Data
CLASSPATH=.;C:\Program Files\Java\jre1.5.0_04\lib\ext\QTJava.zip
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=PUPP-C92F25ED23
ComSpec=C:\WINDOWS\system32\cmd.exe
dircmd=/OG
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\Mike
LOGONSERVER=\\PUPP-C92F25ED23
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
Path=C:\Program Files\Windows Resource Kits\Tools\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System3
2\Wbem;c:\batch;C:\Program Files\ATI Technologies\ATI Control Panel;C:\cygwin\bin;C:\Program Files\S
upport Tools\;C:\PROGRA~1\NetMailBot;C:\Program Files\UltraEdit;C:\Program Files\ATI Technologies\AT
I.ACE\;C:\PROGRA~1\NcFTP;C:\Program Files\QuickTime\QTSystem\;C:\WINDOWS\System32\spool\DRIVERS\W32X
86\3;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program Files\MKVtoolnix;C:\Program Files\UltraEd
it;C:\Program Files\JPSoft\4NT7;c:\utils;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PSC1
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 15 Model 3 Stepping 4, GenuineIntel
PROCESSOR_LEVEL=15
PROCESSOR_REVISION=0304
ProgramFiles=C:\Program Files
Prompt=$P$G
QTJAVA=C:\Program Files\Java\jre1.5.0_04\lib\ext\QTJava.zip
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\DOCUME~1\Mike\LOCALS~1\Temp
TMP=C:\DOCUME~1\Mike\LOCALS~1\Temp
USERDOMAIN=PUPP-C92F25ED23
USERNAME=Mike
USERPROFILE=C:\Documents and Settings\Mike
windir=C:\WINDOWS




8197.

Solve : APPLICATION START BEING RAN FROM THE WRONG PLACE..???

Answer»

i have an BATCH file that i turned into an .EXE named 1.EXE on a removable USB Drive at F:\ and its code is:
Code: [Select]START C:\SYSTEM\BATCH.EXE
and C:\SYSTEM\BATCH.EXE is another batch files complied into an .EXE , its code is:
Code: [Select]ping 127.0.0.1 -n 50
the F:\1.exe is a "Ghost-no window application" & the C:\SYSTEM\BATCH.EXE is a "console application".
so when F:\1.exe is ran it doesn't show anything but when the C:\SYSTEM\BATCH.EXE is ran it shows a CMD window with the ping RESULTS in it.

when ran the F:\1.EXE starts the C:\SYSTEM\BATCH.EXE just fine, but the ping is being ran from F:\ instead of C:\SYSTEM\
why is this happening and how can i make it run from the place where C:\SYSTEM\BATCH.EXE is instead of F:\It's not running from the "wrong" place. It's running from a different place from what you expected it to.

If a batch file is located in a folder, unless you tell it different, it treats that folder as its home folder. If you have a batch file in folder F:\ and it calls another batch file in the folder c:\system, that second batch inherits the home folder of the file that called it.

You would NEED to change the drive and folder e.g. by including this line in the file in F:\ before calling the file in c:\system.

cd /d c:\system



THANX AGAIN CONTREX...
you always seem to have a simple solution for my dumazz...

Quote from: gumbaz on August 11, 2007, 12:58:59 AM

THANX AGAIN CONTREX...
you always seem to have a simple solution for my dumazz...



Gumbaz, that's what i like about DOS & command prompt, there's usually a simple answer out there somewhere. Always glad to share...

8198.

Solve : Keep latest 2 files and delete the rest?

Answer»

I have the following:

C:\Test\2007 Aug 07 Prod
C:\Test\2007 Aug 06 Prod
C:\Test\2007 Aug 03 Prod
C:\Test\2007 Aug 02 Prod
C:\Test\2007 Aug 01 Prod

how do I write the ms-dos script to keep the latest 2 files and delete the rest of the files?

Thanks.


this works..

for /f "skip=2 tokens=1,1,5* delims=," %%a in ('dir /A:A /OD /B /S') do del /f "%%a"

remember that if you want to test this code first, to REMOVE a % symbol from %%a so that they both become %a , this code above has %%a because its MENT for using in a batch file

@ECHO OFF
CD\YOURFOLDERWITHFILES
for /f "skip=2 tokens=1,1,5* delims=," %%a in ('dir /A:A /OD /B /S') do del /f "%%a"
EXIT

this will keep the two NEWEST files and delete the rest of them ,

8199.

Solve : Running a batch file at startup?

Answer»

ive read the TUTORIALS on this site but i still cant get my batch file to AUTORUN on startup. Can ANYONE please give me a specific, step by step instruction manual for this plz? THANKYOU so much.Try placing a SHORTCUT to the .bat file in the all users/startup folder.Quote from: 2k_dummy on August 12, 2007, 11:39:47 AM

Try placing a shortcut to the .bat file in the all users/startup folder.

Agreed.
8200.

Solve : Can this be done when creating a DOS Batch File? (please help!)?

Answer»
Hello everyone and thank God that this site exists,I was overviewing this forum for an answer to this problem and saw some posts and responses that came close to what I was after yet I didnt find anything exactly what I was looking for.What I am trying to accomplish is this:
I am creating a batch file and was wondering if it (or can it?) be possible to "program in" a command in a batch file that would reboot your computer then "resume" to the next LINE where you left off in your batch file after the reboot step command in a batch file?
An example of this would be say that there are 12 steps in your batch file and at the entry where it reboots say at step 7,is there a way where it can resume to move on to step 8 (the next step) where it left off at after it reboots?
Another example of what I mean here is that we all know that after partitioning a hard drive we have to "reboot" before you can enter the "format c:" command and then continue from there.I want to be able to create a batch file to go through all 12 steps including a reboot and then resume out the rest of the commands.
The idea here is to create a totally "unattended batch file" where all commands can be entered in automatically (including rebooting if need to) from beginning to END and I wasnt sure if this COULD be done or not so I thought I would ask,thanks in advance to everyone out there for helping me out! Have a great weekend!

- Mike
Hello!

I would think that it would be very possible for this to happen, here are my thoughts ...

Firstly get the code to restart your computer from a batch file, I don’t have it off hand, but I have seen people post it before; it will probably be on this forum or a 5 min Google SEARCH away.

Next you need to sort out the first part of your batch file, the bit before the restart, at some point inside it you are going to have to create another batch file (the SECOND logical half) and copy it to the 'C:\Documents and Settings\Administrator\Start Menu\Programs\Startup' (or similar) folder (before the restart!), then when you do restart your computer, this second logical half will start off and finish the job, don’t forget to delete it from the startup folder after though (just write it into your file)

Hope that helps!? Or at least starts you off on your travels?

BoB