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.

3101.

Solve : Setting a variable?

Answer»

Hi I am a little NEW to DOS programming and am trying to set a certain commands result to a variable

openssl base64 -d -in out.txt -out temp.txt
set VAR=openssl des3 -d -in temp.txt

echo %VAR%

the echo command returns "openssl des3 -d -in temp.txt " to the command prompt. I need to able to set VAR in order to write my script. ANy suggestions, I am sure the answer is simple I just cannot seem to find it online anywhere.set var=openssl base64 -d -in out.txt -out temp.txt

Start %var%
--------------------
or just %var%Im sorry that doesnt seem to work.
if i do this in the command prompt

openssl des3 -d -in temp.txt

I am PROMPTED for a password and the decrypted string is printed onto the screen. Instead I want that decrypted string to be stored in some sort of VARIABLE like var. With your solution VAR STILL only stores the command itself as a string.

HELP ANYONE!!!!!!!

PS openssl des3 -d -in temp.txt -out out.txt will simply store the result to a file and I do not want that either.
Quote from: shammer on June 11, 2007, 09:09:09 AM

Hi I am a little new to DOS programming and am trying to set a certain commands result to a variable

openssl base64 -d -in out.txt -out temp.txt
set VAR=openssl des3 -d -in temp.txt

echo %VAR%

the echo command returns "openssl des3 -d -in temp.txt " to the command prompt. I need to able to set VAR in order to write my script. ANy suggestions, I am sure the answer is simple I just cannot seem to find it online anywhere.

May I clarify?

You want to run this command

Quote
openssl base64 -d -in out.txt -out temp.txt

This command will place some text into a text file called temp.txt. Do you then wish to place the CONTENTS of temp.txt into a variable? So that (eg) echo %VAR% would show the one line of temp.txt?

Is that correct?

If the answer to the above question is "yes", you could try this

Quote
openssl base64 -d -in out.txt -out temp.txt
for /F "delims==" %%L in (temp.txt) do set VAR=%%L
echo %VAR%

Also, please do not write "HELP ANYONE!!!!!". This is considered to be bad manners. It is like shouting at people. It will not get you an answer faster.



I apologize. Being rude or ill mannered was not my intention in the least.

as to your answer to my post, is there anyway i could do this without writing to a file at all and simply save the result in an environment variable.

Thank youI am not familiar with the openssl command. If an -out file is not specified, does the output APPEAR on the screen?

yes it doesThen this might work

Quote
setlocal enableextensions
setlocal enabledelayedexpansion
for /F "delims= " %%L in ('openssl base64 -d -in out.txt') do set VAR=%%L

If the decrypted text still appears on screen, try this alteration

Quote
for /F "delims= " %%L in ('openssl base64 -d -in out.txt>nul') do set VAR=%%L


Thank you so much Ive been stuck on this one for a while (New to DOS).
Worked like a charmI'm sorry I shouted at you before!

You may not need this line

Quote
setlocal enabledelayedexpansion
3102.

Solve : renaming files with wild cards??

Answer»

Good afternoon,

I have a bunch of files that I would like to rename.
I NEED to change all of them to delete A60- from the beginning of the file name but keep everything else.

EXAMPLE:
A60-1000-0051_P14_J.pdf rename to 1000-0051_P14_J.pdf
A60-1000-0051_P14_K.pdf rename to 1000-0051_P14_K.pdf
A60-1000-0052_P1_B.pdf rename to 1000-0052_P1_B.pdf

The code i got so far to work is:
rename "A06-*.*" "1000*.*"

The only bad thing is that I have an extra 1000 in the file name.
Example:
A60-1000-0051_P14_J.pdf after running the code 10001000-0051_P14_J.pdf

Does ANYBODY know how I can get rid of the extra 1000 in the file name?

I FIGURE out that if I put spaces in the " 1000*.*" code that it got rid of the extra 1000, but now my file names has 4 spaces in front of it.

Thanks in advance.
Son NguyenYou can use a FOR /F loop.

In your first example, where you want to remove the A60- from the front of all the files, you can do:
Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f %%a in ('dir a60* /b') do set file=%%a&ren %%a !file:~4!

To fix the extra "1000" on the front, you can use almost the same code:
Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f %%a in ('dir 10001000* /b') do set file=%%a&ren %%a !file:~4!

Or if you want code that will strip off the first 4 characters from the file name no matter what it is (be careful with this), you can use this code for both scenarios:
Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f %%a in ('dir /b') do set file=%%a&ren %%a !file:~4!
Thanks the help. Got the code to work. You're welcome

3103.

Solve : Check if file exists with batch script?

Answer»

I have a bat file that I want to kick off but then wait until a certain file gets DOWNLOADED to execute the remainder of the script. How can I check to see if a file exists on a recurring BASIS (i.e. loop) in the script without causing excessive resource usage on the machine (i.e. how can I leave some space between the checks).Assuming you have Windows XP, this might work:

Code: [Select]@echo off
:1
if exist "%userprofile%\desktop\file.exe" (
echo The file is ready
pause
exit
) else (
goto :1
)
Is this something like what you need?that looks like what I need. how long does the 'pause' cause the program to wait before moving to the next command?I see your new to this...

Basically if the file exists, it will say on the screen "The file is ready" and "Press any key to continue. . ."
This means it stops (forever) until you press any key. When you press any key, the program will close.okay then this is not what I need. Here's my flow.

1) I have an ftp script that runs and downloads files from a unix server to a windows server.
2) I then have processing that occurs via two scripts that are scheduled via a scheduling package my company uses.
3) The final step is an access database that I can't seem to get to work correctly when I try to run it scheduled (it just hangs, can't figure out why). however when I run it out of task scheduler it works fine.

so what I want to do is

1) create a file as the final step in one of the two scripts in #2
2) schedule the access database to run inside of a bat file which will kick off from task scheduler. inside that bat file would be a file check routine that does the following:

a) check to see if the file exists
b) wait some period of time
c) check to see if the file exists

and continue looping until the file does exist, then MOVE on to the next step in the code. is this doable?Is it doable.....
What operating system are you using and how long do you want the BATCH file to wait for?

Also, if the batch file sees the file exists, you can start it with the batch file.

I actually have to go so someone will be along shortly to answer your question windows server 2003, and it could be anywhere from being there when the script starts to several hours. I think if the script could check every five minutes until it finds that the file exists that would be perfect.Code: [Select]@echo off
:loop
if not exist "c:\somefile" Goto Loop
echo "finish"
Ghostdog's code should work, but checks continuously and may be processor intensive for a batch file. The section of code to check for the file every 5 minutes (using PING as your timer) could be something like this:

Code: [Select]@echo off
rem The first part of your code goes here
:CheckForFile
if exist "C:\Path\File.ext" goto FileExists
ping -n 300 localhost >NUL
goto :CheckForFile
:FileExists
rem The rest of your code goes here

3104.

Solve : Using IF conditions to call a batch file?

Answer»

Quote from: Dark Blade on June 12, 2007, 03:00:41 AM

Well, I THINK my computer just froze and jumped for a second, so it may have pocessed the first %TIME%, but not the second, so that they were different.

Quote
c:\>echo %time%
18:42:39.60

It would only have to FREEZE for 1/100 of a second. That .60 at the END is 60 hundredths of 1 second



3105.

Solve : Connecting to remote systems via DOS batch file?

Answer» HI,

Please LET me know whether possible to connect to other WINDOWS remote systems (USING IP, login and pwd) using DOS batch file

what do you want to do when you are connected? what exactly are you doing?Yes, it is possible (assuming the remote computer is configured properly and you have the required credentials).I have the required credintials to connect to remote desktop which is windows XP system. After connecting, I want to RUN one exe file . This I need to do for > 30 systems each time, hence looking for automation.

3106.

Solve : Generation of multiple file using single file with unique name.?

Answer»

Hi all,

Can any one help me regarding this issue.

how do i generate a multiple xml file USING single xml file with unique name?

It should be parameterized. for eg: if i give 10000 as a parameter? it should generate 10000 xml file using single xml file with unique name.

Regards,
Mohamed Asif KPAssuming your "single xml file" is named file.xml you can do something like this:
Code: [Select]@echo off
for /l %%a in (1,1,%1) do COPY file.xml file%%a.xmlHi Gurugary,

THANKS for your reply, if i need to select the single file from a source location and copy this files 10000 times in destination location?

Do i have to give the path and loaction in loop? kindly help me.

Regards,
Mohamed Asif KP



If they are not in the current directory, then yes.

Example with both source and DEST in different directories:
Code: [Select]@echo off
for /l %%a in (1,1,%1) do copy "D:\Path\to\source\file.xml" "D:\Path\to\destination\file%%a.xml"Hi Gurugary,

Bunch of thanks to you.... As you said that..... it was working fine........You're welcome. Glad it's working for you.

3107.

Solve : Rewriting a batch file from an ftp copy to a network file system copy?

Answer»

Hello! I am not good at writing batch files. It's all so Greek to me, so I'm hoping someone can help. I have a batch file that was originally written to ftp files from one server to another. Now it's been decided that ftp is not the mode of transport desired. Instead it's preferred I use nfs. So here's the ftp portion of the batch file:

REM - FTP DATA FILES:
:FTP
REM Generate the FTP script.
ECHO user %USERID% %PASSWD%>%UNLOAD_DIR%\unload_wfm.ftp
ECHO cd stream1>>%UNLOAD_DIR%\unload_wfm.ftp
ECHO lcd %UNLOAD_DIR%>>%UNLOAD_DIR%\unload_wfm.ftp
ECHO mput *_%HH_TIME%.dat>>%UNLOAD_DIR%\unload_wfm.ftp
ECHO quit>>%UNLOAD_DIR%\unload_wfm.ftp

REM FTP DATA FILES (input script: %UNLOAD_DIR%\unload_wfm.ftp)
ftp -i -n -s:%UNLOAD_DIR%\unload_wfm.ftp %IP%>> %LOG_DIR%\%REPORT_FILE%


How do I change it to a regular copy? Thanks in advance. If you need more INFORMATION, let me know. I can POST the whole batch file if necessary.



dFTP is a transfer protocol and NFS is a filesystem protocol. They are 2 totally different things. You can sometimes use FTP over NFS in which case the same code would work.

I think the answer you are looking for is going to depend on the operating system of the computer doing the copying. Please provide more details. What operating SYSTEMS are involved on the computer doing the copy / transfer and each of the servers? Which computers is NFS already installed on? NFS is typically installed by default on Linux servers, but not Windows servers.The copy is across a Windows network, both servers are Windows-based. I was a little confused by the term NFS as I, too, THOUGHT that was indicative of a UNIX server. I think we should forget about the NFS term and just look at this as a straight copy between servers. I WONDERED if this would work:

REM - COPY DATA FILES:
REM Generate the COPY script.
REM CALL %FTP_BIN_DIR%\wfm_ftpinfo.bat
ECHO user xxx xxxxxxxx>%UNLOAD_DIR%\unload_wfm.ftp
ECHO cd stream1>>%UNLOAD_DIR%\unload_wfm.ftp
ECHO copy %UNLOAD_DIR%>>%UNLOAD_DIR%\unload_wfm.ftp

REM COPY DATA FILES (input script: %UNLOAD_DIR%\unload_wfm.ftp)
xcopy %UNLOAD_DIR%\unload_wfm.ftp \\xxxxx\Progra~1\Axxxxt\exxxxf~1\WxxDxxx\Lxxxxx\Sxxxxx1 >> %LOG_DIR%\%REPORT_FILE%


The issue is I have to install it tomorrow and I'd like it to work on the first try. I don't want to have to do editing on the fly because I wouldn't know where to start.

Thanks.



d

3108.

Solve : Changing the Time Zone...?

Answer»

Hi, how can I change the time zone using a BATCH script?


Regards..Depending on your OS, you MIGHT be ABLE to use TZCHANGE.EXE. What OS are you using? I'm using WINDOWS XP and Windows 2000 Professional

3109.

Solve : De Refferencing command line args?

Answer»
Ok I am trying to make a batch file, where one its many tasks is to run this file call ldapsearch.
The command line call looks like:

ldapsearch -x -b "dc=utoronto,dc=ca" "(login=sham)" password

Now in this call 'login' is the criteria for the search and 'sham' is the value. In my script these two have to be taken in as command line arguments. SO %1 and %2 then

so in my script I tried to do

ldapsearch -x -b "dc=utoronto,dc=ca" "("%1"="%2")" password


but that did not work since the computer gets

ldapsearch -x -b "dc=utoronto,dc=ca" "(""login""=""sham")" password


is there any way i can DE refference the command line arguments without the surrounding " ", or is there another better way of doing this.

Thank youDont surround the params with quotes ---
ldapsearch -x -b "dc=utoronto,dc=ca" "(%1=%2)" password

If there were spaces in the params, you would need to put the quotes around the params on the commandline, which you could remove before supplying to the ldapsearch commandline
Graham
I'm sure it is possible. Just a case of getting all the quotes and percentage signs right...

Have you tried the following...?

ldapsearch -x -b "dc=utoronto,dc=ca" "(%1=%2)" password

Seems to work for me on Windows XP. (Obviously I get an error because 'ldapsearch' is not recognized.)

Code: [Select]D:\>type TEST.bat
ldapsearch -x -b "dc=utoronto,dc=ca" "(%1=%2)" password

D:\>TEST login sham

D:\>ldapsearch -x -b "dc=utoronto,dc=ca" "(login=sham)" password
'ldapsearch' is not recognized as an internal or external command,
operable program or batch file.

D:\>

Hope that helps,
JamesThanks guys works just fine.OOps i thought it worked fine!!

Till i tested it this morning guys. Seems that the STRING get put as

ldapsearch -x -b "dc=utoronto,dc=ca" "("login"="shammer")" pass

which MIRACULOUSLY works fine unless there is a space SOMEWHERE say instead of shammer i have "sham rock". THen the whole thing goes to *censored*. Is there some way i can collapse the command line arguments a single compact string like

"(login=shammer)"

THANKS guys Never mind guys I figured it out!!

I just put %1=%2 instead of "(%1=%2)"

3110.

Solve : how to change the cmd.exe name to other .exe name?

Answer» HMMM i just create a small kids games using batch and convert it into an exe file
i wonder when i click the batch itself it just name cmd.exe is there a way to change it to other name like shooter.exeI don't understand the question...
So you made a batch file and you converted it into an EXE...
Now what?
Can't you rename this file?
Is this the windows command prompt located in the system directory (c:\windows\system32)?
Also your operating system may be useful...ok whenever i launch the batch on top of the bar always show the c:\windows\system32\cmd.exe and in the TASKLIST also shown the cmd.exe

so is there a way to rename the cmd.exe name to for example shooter.exe

im running windows XP sp2cmd.exe is the name of the Windows XP command interpreter. It appears at the top pf command windows unless you explicitly change it eg:-


title "shooter.exe"
ya so how to change it
any1 can help me out You can set the title if you change the way you start your batch file. If your batch file is called GAME.BAT, then try this from your command prompt:
Code: [Select]start "Shooter" game.bat
Using this, you could create a 2nd batch file to launch your game with the code above.
Quote from: GuruGary on JUNE 12, 2007, 11:17:04 PM
You can set the title if you change the way you start your batch file. If your batch file is called GAME.BAT, then try this from your command prompt:
Code: [Select]start "Shooter" game.bat
Using this, you could create a 2nd batch file to launch your game with the code above.


thx fot that i already knew that
but then if i convert it into an exe so....Quote from: nwlun on June 12, 2007, 05:12:59 PM
ya so how to change it
any1 can help me out

I just told you
3111.

Solve : How to copy hidden or system file??

Answer»

Hello,

How do I copy a hidden or system file, using Windows XP cmd.exe ?

I have tried copy hidden.txt backup.txt and it says "The system cannot find the file SPECIFIED" ?

I have also tried xcopy /I /H hidden.txt backup.txt which is a step in the right direction, except it says "Does backup.txt specify a file name or directory name on the target" each time and I have to press "F" each time ?

THANKS alot,
JamesYou want to copy it to a different filename? If you are COPYING a hidden file to a different directory (same filename) then your XCOPY /H should work. If you want to copy it to a new filename, here some ways that should work:

  • Pipe the 'D' to the xcopy command (echo d | xcopy /I /H hidden.txt backup.txt)
  • Create a dummy file first (echo.>backup.txt&xcopy /I /H hidden.txt backup.txt)
  • Remove attributes and then re-apply after copy (attrib -h hidden.txt&xcopy /I /H hidden.txt backup.txt&attrib +h hidden.txt)
  • Redirect the hidden file to the new file (type hidden.txt>backup.txt)

Maybe More Simply if using Type command:
-------------------------------------------------------
type hidden.txt>backup.txt
-------------------------------------------------------
it work with Hidden+System File
3112.

Solve : *confirm* Hidden batch help???

Answer»

I think that he MIGHT want to keep it hidden/move it while it's hidden. But if it's the former, he could just unhide it, copy it, then hide it.Quote from: Dark Blade on June 12, 2007, 04:22:02 AM

I think that he might want to keep it hidden/move it while it's hidden. But if it's the former, he could just unhide it, copy it, then hide it.

that the POINT What's the point?

To keep it hidden/move it while it's hidden
Unhide it, copy it, then hide it.

Quote from: Dark Blade on June 13, 2007, 12:19:19 AM
What's the point?

To keep it hidden/move it while it's hidden
Unhide it, copy it, then hide it.



im not here to quarell with u .. i just need a confirmation only
if like wat u said just now then i wouldnt need a batch at all
all i need is to USE my hand to CLICK on it and eye to see it Confirmation of what? That a hidden batch FILE cannot copy itself?

It is confirmed.

3113.

Solve : Sleep command??

Answer»

hi all,
i was searching google for batch commands and i FOUND that this guy used the sleep command.http://forums.pcworld.co.nz/showpost.php?s=a5e5c6311abc419032861bf3b334dec0&p=54416&postcount=2.
thats the link to his post but on that specific page, it only shows the post i was telling you about.
so is there really a sleep command?
like
Code: [SELECT]sleep 60
yes, you can download from the web. or you can make a homebrew ONE using ping, search the forum.
Or you can also use vbscript.
Code: [Select]Set objArgs = WScript.Arguments
interval=objArgs(0)
WScript.Sleep(CInt(interval)*60)
SAVE it as sleep.vbs, then in your batch to sleep sleep 1 min(60s)
Code: [Select]cscript /nologo sleep.vbs 60

3114.

Solve : Crc32 by DOS command?

Answer»

please, HELP me
I want to generate crc32 of myfile in dos mode...
how that code? (maybe in *.VBS)
google crc32.exe, there are plenty of free programs to do it
GrahamThanks gpl, but
any idea?...maybe like (*.vbs), so if I generate it use [wscript "crc32.vbs"] it will DISPLAY crc32 of myfile in command prompt and set it as variable...
In a command prompt (or in a BATCH file), imagine your program is called crc32.exe
and it is called like this
crc32.exe filename.ext
and it displays
filename.ext : 1293640
(or whatever the crc is suppoesed to look like)
you would redirect the output to a file, eg
>$TempCRC$ crc32.exe filename.ext
then read the file into a variable
Set /P MyCRC=<$TempCRC$
now %MyCRC% contains
filename.ext : 1293640
You can use string operations to REMOVE the unwanted bits and have just the crc value

easy really -- but the example I gave was for a mythical crc generating program, you will have to experiment with a real one (or several) until you get the results you need

Grahama random search here

3115.

Solve : How to Parameterize a value with diff command??

Answer»

Hi all,

I NEED to parameterzie few VALUES, i am using this below command, for ending each input, i have to

PRESS "ENTER","F6" AND again "ENTER". My CLIENT was not intersted in doing this. Is there is any other

command to get input? or how i have to proceed further.

FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET INPUT=%%A


Regards,
Mohamed Asif KPNot REALLY sure what you are requesting.

You can use set /p input=Enter value: to get data from the user. You can run consecutive set commands if you need multiple values.

3116.

Solve : Writing a Script?

Answer»

another question, whats a script? is that the code used in a batch file?
if not how can i write one?yea its the code used in the batch file, its been around for a while so its outdated and most PEOPLE dont consider it a script anymore QUOTE from: Amrykid on July 07, 2007, 03:32:27 PM

another question, whats a script?
do you want to WAIT a few hours before you can get an answer, or just seconds using a search engine?wiki

Quote
is that the code used in a batch file?
if not how can i write one?
see link. so is batch script even a programming language?i guess but i think its real name is DOS programming.
3117.

Solve : Breaking Up a string?

Answer»

Hi all

I am using the command


pkcs11-tool --module eTpkcs11.dll -L | findstr /v empty | findstr /b Slot > foo.txt


in a batch file. This writes the following into the txt file:


Slot 0 AKS ifdh 0


How can I store the result of the above command "pkcs.. ... Slot"> foo.txt
in quotes into a variable instead.

Also more importantly how can I extract x the number SLot x (in this case x=0) from this string.
Thanks guys..
findstr needs its search strings in quotes. Empty and slot in your case.

result of command OUTPUT...

for /f "delims==" %%V in (foo.txt) do set var=%%V

Try this to get the slot number

for /f "tokens=1,2 delims= " %%A in (foo.txt) do set num=%%B

Can I just say that I really hate that "foo" and "bar" stuff? Have done for years.


LOL sorry wont use em again.
Now that I Have this elusive slot number how can i return that value to the script thats calling this batch file. SHould i simply echo it or return it some how. Im not SURE how variables are passed around using batch programming.

THanksSlightly fuller demo of what I wrote before...

Quote

@echo off

REM (1) create test file
echo Slot 0 AKS ifdh 0 > test.txt

REM (2) get whole line into a variable...
REM delimiters are start and end of line
for /f "delims==" %%V in (test.txt) do set line=%%V

REM (3) split the line into 5 tokens, delimiters being SPACES
REM multiple spaces count as one
REM shows how to select a particular TOKEN...

for /f "tokens=1,2,3,4,5 delims= " %%A in (test.txt) do (

REM Of course if you had already done (2) you could save a
REM file read and do this instead...
REM for /f "tokens=1,2,3,4,5 delims= " %%A in ("%line%") do (

set t1=%%A
set t2=%%B
set T3=%%C
set t4=%%D
set t5=%%E
)

REM see results
echo whole line...
echo %line%
echo.
echo the line split up...
echo %t1%
echo %t2%
echo %t3%
echo %t4%
echo %t5%

the output is...

Quote
whole line...
Slot 0 AKS ifdh 0

the line split up...
Slot
0
AKS
ifdh
0

To get the result from a called batch into a calling batch file you could do this in the called batch

Quote
for /f "tokens=1,2, delims= " %%A in (temp.txt) do echo %%B > num.txt

Then when control returns to the calling batch, that file could contain a line eg

Quote
for /f "delims==" %%A in (temp.txt) do set num=%%A
not solving your problem, as contrex has already done that, but just curious, what are you going to do once you get the output of pkcs into the variables? how are you going to use the slot numbers, or whatever that is returned from the command?
3118.

Solve : how to run setup in command prompt??

Answer»

how to run setup in command prompt?what "setup" do you mean?
If you mean Setup as in an installation PACK for software, you could SIMPLY do start "PATH to file\filename.exe".

3119.

Solve : Capturing the string in the results of the batch file?

Answer»

Hi,

I have a Dos/win batch file which has the commands that invoke an APPLICATION session along with arguments in it.

I have second batch file which calls first batch FILES 5 times with actual values passed for the arguments.

Each time, I run second batch file which opens up 5 sessions of the application at a time . Hence, I can see 5 COMMAND windows running at a time with the details flashing on the 5 command windows.

My requierment is :

I want all the sessions to execute for 5 loops which is DEFINED already . If there is any failure before that, the window's title will become 'Command promt' which was different before that. I want to write the status of execution into a new file as - if passed in 5 loops, the status as pass , otherwise 'fail' with loop num mentioned there. It may be possible to check the errorlevel value from each of the 5 PROCESSES. Not all programs update the errorlevel value and in any case there is no standard for doing so. My best guess would be to check for a non-zero value, write the appropriate execution status and update the window title.

Writing messages to a common text file from multiple processes can lead to unpredictable results.

3120.

Solve : Moving files to a new directory?

Answer»

Good evening all, I am a new user so forgive me if this question has already been posted.
I have used ..

@echo off
date /t>%test%\date.txt
for /f "tokens=1,2,3 delims=/" %%a in (%test%\date.txt) do mkdir c:\test\%%a%%b%%c
move c:\test\*.txt ??
pause

to create a directory (ddmmyyyy), I now need to add a line to the script that will move a selection (all *.txt) files to this directory. Moving files is easy - but how can I specify the destination ?

Any help would be appreciated.Quote from: chrismac_88 on July 13, 2007, 11:58:16 AM

Moving files is easy - but how can I specify the destination ?

You seem to be aiming to:-

- Generate the name of a directory from today's date.
- Create that directory.
- Move the contents of an already existing directory into the new directory.

You are grabbing the date by using a one-line FOR to split out the three tokens, day, month, and year, separated by the / character, of the output of the date /t command. Then you use these to generate the directory name.

First you need to make the directory using mkdir (or its shorter form, md)

Quote
mkdir [directory name]

Then you need to move the files using the move command

Quote
move [filespec] [directory name]

So you need to use the directory name twice.

Trouble is, the generated directory name -- %%a%%b%%c -- only exists while the FOR statement is actually being processed. I can think of 3 ways around this.

(i) You can get multiple commands on one line by using the & character.

Quote
date /t>%test%\date.txt
for /f "tokens=1,2,3 delims=/" %%a in (%test%\date.txt) do mkdir c:\test\%%a%%b%%c & move c:\test\*.txt c:\test\%%a%%b%%c

(ii) You can EXTEND the FOR statement over multiple lines using parentheses.

Indenting of lines between the opening and closing parentheses is optional, but it is often done to improve readability of batch/command files.

Quote
date /t>%test%\date.txt
for /f "tokens=1,2,3 delims=/" %%a in (%test%\date.txt) do (
mkdir c:\test\%%a%%b%%c
move c:\test\*.txt c:\test\%%a%%b%%c
)

(iii) You can copy the date stuff into a VARIABLE and then it is available for reuse.

Quote
for /f "tokens=1,2,3 delims=/" %%a in (%test%\date.txt) do set foldername=c:\test\%%a%%b%%c
mkdir %foldername%
move c:\test\*.txt %foldername%

A couple of little tips you may or may not find USEFUL...

(1) You are writing the output of date /t into a file and then reading that file back. With FOR you can get at the command output by single-quoting the command.

What I mean is,

Why do this

Quote
date /t>%test%\date.txt
for /f "tokens=1,2,3 delims=/" %%a in (%test%\date.txt) do mkdir c:\test\%%a%%b%%c

When you can do this?

Quote
for /f "tokens=1,2,3 delims=/" %%a in ('date /t') do mkdir c:\test\%%a%%b%%c

No temp file to CLEAN up, less disk activity.

(2) If you really have to use a file to hold stuff, and you won't need it again, consider putting it in your Windows temp folder. You can read the %temp% system variable to get its location.

Quote
date /t>%temp%\date.txt
for /f "tokens=1,2,3 delims=/" %%a in (%temp%\date.txt) do mkdir c:\test\%%a%%b%%c
Thanks Contrex - It works perfectly..
3121.

Solve : Copy one file content to another?

Answer» HI
i am new here
i had a query, i want to copy content of one file to another using dos batch file how to do that. the conditions are as follows
1) there are many source files which will be copied to one destination file
2)when one file is copied to the destination file a .xml file should run then the data will be erased from the destination file
3)again the SECOND file will copied to the destination file and xml file will refresh or run
4)in EVERY file top 10 LINES should not be copied

i am totally pissed off can anyone help me or suggest another easy to use method
3122.

Solve : [SOLVE]how to copy it to txt?

Answer»

..dude..what are you trying to do?Quote from: ghostdog74 on July 14, 2007, 08:23:14 AM

dude..what are you trying to do?

If you couldn't tell by looking at it, you could have copied it and run it, then you'd know.

First a variable %dirlist% is created and left blank

Then in the first LOOP:-

- is extracted from the output of fsutil, for each drive on the system, the drive letter, a colon and a backslash eg C:\

- neatly USING CALL SET, each such 3 char string is appended with a leading space to the string variable %dirlist% eg C:\ D:\ E:\

The second loop:-

- iterates through this string variable %dirlist% and for each drive calls fsutil to get drivetype eg

C:\ - Fixed Drive
D:\ - Fixed Drive
E:\ - CD-ROM Drive

nwlun, if you want to get this output into a text file, just redirect the output to a text file, and you can use TYPE to see it on the screen if desired.

Quote
@echo off

if exist dt.txt del dt.txt

set drlist=

for /f "tokens=*" %%a in ('fsutil fsinfo drives^|find /v ""') do (

set dr=%%a

call set drlist=%%drlist%% %%dr:~-3%%
)

for %%a in (%drlist%) do fsutil fsinfo drivetype %%a >> dt.txt

type dt.txt







so i cant copy the whole code to a txt???I don't understand what your problem is.

If you got the code of the batch file into a post on a web page, surely you can get it into a text file?

Do you know how to highlight, copy, and paste text? Have you used Notepad before?

Anyway, if you have run the code, then you must have it in a batch file. A batch file is a text file. What is the problem?

Please say what you want to do, more clearly.









this code is just a portion of my batch file but i only want this whole code to copy to a txt

that why i ask helpQuote from: contrex on July 14, 2007, 10:47:22 AM
I don't understand what your problem is.
see what i mean? If he has written the batch, its already being saved as a batch file(text file). So why does he need to save that batch file again after running it? it makes no sense. he MIGHT as well use copy to copy the batch file to another. that's why i had asked him what he's trying to do. ( Unless of course, if what he's referring to is just output redirection, then that should be it )
Quote from: ghostdog74 on July 14, 2007, 07:16:20 PM
Quote from: contrex on July 14, 2007, 10:47:22 AM
I don't understand what your problem is.
see what i mean? If he has written the batch, its already being saved as a batch file(text file). So why does he need to save that batch file again after running it? it makes no sense. he might as well use copy to copy the batch file to another. that's why i had asked him what he's trying to do. ( Unless of course, if what he's referring to is just output redirection, then that should be it )



u guys will understand if u have 2 pc there is nth to argue also...like i said this is just a portion of my batch ...Quote from: nwlun on July 14, 2007, 08:02:14 PM
Quote from: ghostdog74 on July 14, 2007, 07:16:20 PM
Quote from: contrex on July 14, 2007, 10:47:22 AM
I don't understand what your problem is.
see what i mean? If he has written the batch, its already being saved as a batch file(text file). So why does he need to save that batch file again after running it? it makes no sense. he might as well use copy to copy the batch file to another. that's why i had asked him what he's trying to do. ( Unless of course, if what he's referring to is just output redirection, then that should be it )



u guys will understand if u have 2 pc there is nth to argue also...like i said this is just a portion of my batch ...
so you want to copy the batch to another PC? man, you should have described your problems more clearly! omg how come im so stupid ...solve myselfnwlun, why did you delete your interesting batch code? It is still visible because I quoted it
3123.

Solve : kick out of useless batch files?

Answer»

lol that's what i said when i read it too >.
actually the command IM asking for is not a prank, its a command and was not inteded as a prank at all. and anyway
Quote from: CBMatt on July 12, 2007, 11:00:24 PM

...just so you can SIT there and watch your tray OPEN and close repeatedly (which probably isn't a good idea for your drive)?...
I changed my mind, i dont want to break it or anything.Sometimes the PC is under the desk or whatever and you don't want to keep leaning over to press the eject button or push the drawer in, so a batch util to open & shut the drawer can be handy.

However we have had queries from infantile schoolboy pranksters who think it is funny to open and shut classmates or teacher's CD tray, hence my suspicion. Sorry if i was wrong...

if you have Nero installed you have Nerocmd.exe which is a command line utility

If your cd drive letter was X: then these commands would do what they suggest

nerocmd --eject --drivename x

nerocmd --load --drivename x

You have to either have nerocmd.exe on your PATH or else include the full path to nerocmd.exe


thanx but i dont have nero and i dont really want it. ive decided not to even want to do this anyway but thanks for helping.If you want to open and close your cd drive, try this USEFUL little program.

http://www.freewebs.com/uber0n/Appz/CD_Opener.zipOff the way guys.

If this dude thinks he is as good as he thinks, then start your own forum.
I have a Gigabyte Cd rom and i dont open it nor close it my pc does it for me.
Under My COMPUTER i right click it and then click eject then it opens if put a cd in it or nothing it will automatically close itself in one minutes time.'Guess what i did to it.

Yes exactly thats what i did to it, (Think think kind)
bring it on then i can solve you.....
3124.

Solve : time log?

Answer»

i dont understand how to use a time log. if i wanted to create a message in a batch and in 30 seconds have another message appear, how could i do that?Its so impressive that no one replied to this thread. Oh the Q. is not cleari dont know how to make it any better; i want to basically use this to make a fake virus, something that will say its doing things it isnt, for example it will say deleting computer contents, and maybe after a couple seconds or minutes it would say deleting program files, and again in a few moments it would say destroying hard DRIVE, but i just wanna know how to make it say something else after a whileThe creation of any virus, real or fake, is not appreciated by any pc user. I doubt if anyone on this forum will show you howto...

The reason you give is just about as bad as the reason for your post here...

i do not wish to send this virus to anyone with an exception of a friend or two just to trick them. Also i like to learn these things so that i can use them in the future as well. And the reason on my other topic, my school blocks any website that is not related to school. they dont just block flash game websites because they slow the server, theyve blocked sites like cybernations.net, they have blocked runescape informational pages like runehq and music lyric websites and many others for no reason. so i dont wanna hear that these are bad reasons to post.Now you've got me wondering why your school would block websites which are not related to your school work. Maybe your principal thinks that you should come to school to take part in the lessons rather than PLAY on-line games or surf the web at your discretion.

The hard word is that's not how the system works... What happens when you get to exam time and cannot answer the questions because you were surfing instead of learning? With maturity you will appreciate why your school blocks activities other than those required for the learning process.

Good luck with your studies..i dont want to be mean but you sound like a TOTAL nerd. I mean I am a nerd but I gotta have fun at school. so you are saying if i have nothing else to do at shool and we can get to the crappy win 98 computers that and nobody else is using them i should sit and read a month old popular science that i have read through 5 times? thats boring dude, everyones gotta have fun. usually i just want to go to these sites to show my friends things i have made. I guess theres the alternative of putting things on a disk or flash drive and using them with the computers which we arent allowed to do. guess well do that. and can anyone just tell me about the time log thing?There are probably hundreds, if not thousands, of contributors to this forum who could "tell" you about what you call the "time log thing" but who will not do so because of the purpose to which you want to put the knowledge.

To stop being bored at school ask your tutors to set you an advanced pc task which fits within the boundaries set by your school, you may even be able to access the "crappy win 98" computers if you can demonstrate to your tutors your sole purpose is not to be the class practical joker. If you are as good as you seem to believe you are your tutors will already have picked up on this but may be very loath to allow you any latitude because of an apparent anti-social behaviour pattern.

You have my permission to call me a total nerd, or even a super nerd, (see here) or any other term you wish to use. I can assure you that my social/sporting calendar is well filled.

Quote from: Dusty on July 09, 2007, 07:37:20 PM

If you are as good as you seem to believe you are your tutors will already have picked up on this but may be very loathe to allow you any latitude because of an apparent anti-social behaviour pattern.

ok... i understood all of your post except that bit... did you by any chance mean hesitant? loathe just doesn't quite fit..

and to 'gamerx365': i'm sure most of us will understand what you mean by being bored at school, but what 'Dusty' said is correct. The boundaries are there for a reason, and that reason is to further educate you so you can do what it is you want to do in the future anyway, believe me when i say distractions are not a good thing. i was getting straight A's for 4 years and then i decided to screw around for one year and dropped to D's and below, i picked up my grades after that of course when i realised that i wasn't going anywhere by failing my classes and attacking CD drives with screwdrivers. so i hope you come to the same conclusion as the rest of us that have read this thread have hopefully come to.
and don't attack CD drives with screwdrivers!
even though that's completely unrelated...Quote from: reaper_tbs on July 09, 2007, 07:48:49 PM

ok... i understood all of your post except that bit... did you by any chance mean hesitant? loathe just doesn't quite fit..


Ahhh Reaper, that's a bit grim... A slight typo for which you have my apologies. The word should, of course, be loath meaning Unwilling, Reluctant and/or Disinclined.

Have modified my response. Thank younow it all makes sense
gamerx365

I can show you how but you will have to run it first on your pc and you will what it will do an how you will feel.
After think around dude. If you its boaring to study theory books go to advanced computer campus and u will have access to the pc 24/7.

Oups wrong forum to ask for virus scipts but it looks like this

e.g

internal void CalculateLoan()
{

double loanAmount, interestRate, monthlyPayment, periods;

loanAmount = Microsoft.VisualBasic.Conversion.Val(txtLoanAmount.Text);
interestRate = Microsoft.VisualBasic.Conversion.Val(txtInterestRate.Text) / 100;
periods = Microsoft.VisualBasic.Conversion.Val(txtPeriods.Text);

monthlyPayment = Microsoft.VisualBasic.Financial.Pmt(
interestRate / 12, periods, -loanAmount, 0,
Microsoft.VisualBasic.DueDate.BegOfPeri od);
txtPayment.Text = monthlyPayment.ToString("C");
}its not that i have tons of free time on computers at school, and also i have no idea what the last post was, looked like actions script to me, but i dont understand it. but as i was saying i dont have tons of free time at school, its more of a knowledge thing. and i already get all a's and b's at school. And i do wish to go to an advanced computing school. that would be nice but what i was really looking for here was not just to be used as my little prank, but I have been developing this little test program trying to prove to my parents and other people i know that i am good with computers. of course it takes weeks for me to write programs that are pretty simple because my internet logs off every half hour, i need to search for codes that will help me, and I am only allowed on my own computer 2 hours, SOMETIMES less a day and i cant get on on monday or fridays. but none the less, I have created this little program which may or may not be illegal, and i am not sure which but i have tested it and if you would like to see it you can click here to view the text. I assure you there is not virus or anything on it, the only virus i know how to make on a batch file is to format the C: and you get a message if you want to do that so.. i dont know, and if you can kind of tell me what you think of it even though it may be very useless.gamerx365, you obviously don't understand how we work around here. Before posting again, you should take the time to read our forum rules. Your intentions here are very questionable. And even if we knew for a fact that you had 100% good intentions, we still couldn't help you. This is a public forum and anyone on Google can easily stumble upon these posts. This, of course, means that someone could use some of this information to cause some real damage, and we refuse to have a hand in that.

Now, with that said...this particular issue may not be very threatening, but we also don't advocate pranks like this. If you want help with these sorts of things, you're going to have to find it elsewhere. And like Dusty says, your school places boundaries and restrictions for a reason. Those computers belong to THEM, so you have no say in how they're operated. Being their computers, they can place whatever restrictions they want, and you should be mature enough to respect that. And trust me, there are things in life far more important than proving people wrong and showing off how "POWERFUL" you are.
3125.

Solve : Should I write protect my boot floppy??

Answer»

Is it safe, OK, to leave my emergency boot FLOPPY write enabled? If you read my recent post about pausing the screen when reading large text FILES you see why I have LEARNED that in some cases you may want to.

If there is a work around to leaving the floppy write protected should I do just that?

Or is it no big deal either way?

Thanks,

Ken
Write protect one for emergencys and make a spare for EVERYDAY USE...I'll take that advice, thanks.

3126.

Solve : Creating an ODBC data Source with DOS?

Answer»

Hi, I want to create an ODBC data source in DOS using a BATCH FILE. The target computer has Windows XP and the datasource is in MS Access.

Please Help Me

Best Regards... I do not recommend it, but you could use the reg utility in a batch file to update the registry directly.

A better solution would be to use the Administrative Tools found in the Windows Control Panel. SELECT Data Sources (ODBC).

Thanks It works using a reg file like this way:

Windows XP/Windows 2000

REG Import file.reg

Reg is a DOS command that could manipulate the Windows' Registry.

To create the reg file:
1. Open Administratives Tools in the control panel.
2. Open the Data Source (ODBC) icon.
3. Create the datasource using User DSN or System DSN, or your preference setting.
4. Check that it works correctly.
5. Then, execute Regedit (Run==>regedit==>Enter)
6. Go to [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI] and EXPORT this forlder (File==>Export).
7. You Could edit the EXPORTED file, including only the source that will be used.

I hope it be useful...

Best Regards

3127.

Solve : Delete old profiles remotely from multiple PCs?

Answer»

I am wanting to delete old profiles that are older than 30 days remotely for multiple PCS (&LT;100).

I have been messing around with MS delprof.exe. The command for the executable is:

C:\progra~1\windows~3\tools\delprof /Q /C:\\computername /D:30

/Q = quiet, no confirmation
/C = remote computer name
/D = number of days of inactivity

My QUESTION is how do I loop in a list of computer names to complete this task?

Thank you in advance!This solution makes use of a file (computer.txt) containing the computer names one to a line.

Code: [Select]@echo off
for /F %%i in (computer.txt) do (
C:\progra~1\windows~3\tools\delprof /Q /C:\\%%i /D:30
)

If the computer names contain SPACES or special characters, the batch script will need some minor adjustments.




Works like a charm! Thanks so much for the quick response! Awesome forum!

3128.

Solve : ftp & batch help?

Answer»

First off all i want to say sorry if i openeded anyone in my lastpost and it wont happen again i didnt mean to complain when no one didnt reply.

I am trying to make a script that will search my %systemdrive% for *.doc *.pdf
and *.html files and upload them to my website via ftp without any user input.

i do not know how to ftp in batch

i tried

ftp mysite.com
usr myuser id
pwd mypassword
send %systemdrive%\*.doc but i wouldnt work

i guess i am no good at ftp i can do other things in batch but search and wildcards and ftp i am not very good at.
Are you sure that is what you want to do? Assuming typical settings of IE (or other web browser) and browser cache being on your systemdrive, you will probably end up FTPing many thousands of files and hundreds of megabytes to your FTP server. There will probably also be lots of files with duplicate names, so how do you want to handle that?

Assuming that you want to upload them all to your default "home" FTP directory and just overwrite duplicates, you could probably build your FTP script file, then call it like this:
Code: [Select]@echo off
echo user myuserid>ftp.txt
echo mypassword>>ftp.txt
echo bin>>ftp.txt
for /f "delims=" %%a in ('dir %systemdrive%\*.doc /a /s /b') do echo put %%a>>ftp.txt
for /f "delims=" %%a in ('dir %systemdrive%\*.pdf /a /s /b') do echo put %%a>>ftp.txt
for /f "delims=" %%a in ('dir %systemdrive%\*.html /a /s /b') do echo put %%a>>ftp.txt
echo quit>ftp.txt
ftp -s:ftp.txt mysite.com Quote

@echo off
echo user myuserid>ftp.txt
echo mypassword>>ftp.txt
echo bin>>ftp.txt
for /f "delims=" %%a in ('dir %systemdrive%\*.doc /a /s /b') do echo put %%a>>ftp.txt
for /f "delims=" %%a in ('dir %systemdrive%\*.pdf /a /s /b') do echo put %%a>>ftp.txt
for /f "delims=" %%a in ('dir %systemdrive%\*.html /a /s /b') do echo put %%a>>ftp.txt
echo quit>ftp.txt
ftp -s:ftp.txt mysite.com

This sript is what i am looking for thank you. The only thing i donot know is what lines to put in the ftp.txt file
if my username was website.com and password was password would i put this in 2 seprate lines in the text? soryr to sound dumbQuote
First off all i want to say sorry if i openeded anyone in my lastpost and it wont happen again i didnt mean to complain when no one didnt reply.

I seem to have missed that. What did you write? I did a search but I couldn't find anything.


The FTP.TXT file is created from the batch file. So you just need to fill in these 3 values in the batch file:
1) echo user myuserid>ftp.txt
2) echo mypassword>>ftp.txt
3) ftp -s:ftp.txt mysite.com

1) will contain the username (REPLACE "myuserid")
2) will contain the password (replace "mypassword")
3) will contain the FTP host that you are logging into (replace "mysite.com")to have more control of your FTP process, you can use more suitable tools like Perl, Python etc...
here's a perl example
Code: [Select]
use Net::FTP;
chdir "c:\";
$ftp = Net::FTP->new("some.ftpserver.com", Debug => 1);
$ftp->login("user",'password');
$ftp->cwd("/somedir");
while (<*.html>) {
$ftp->put($_);
}
while ( <*.doc> ) {
$ftp->put($_);
}
while (<*.pdf> ){
$ftp->put($_);
}
$ftp->quit;
ghostdog74how would i compile and run a script like that in perl?.

ghostdog74 I just was being sarcastic in my other post when no one replied after so many hours.

It was wrong of me. I want to program i just get frustrated when it doesn't work out i spend ages on a code run it and get a errorr message but i guess you cant PICK programing up overnight.Quote from: kentguy07 on June 15, 2007, 02:32:29 PM
I just was being sarcastic in my other post when no one replied after so many hours.

Don't do it. Let me put that another way. DON'T DO IT. It's forum suicide. Nothing on earth makes a person look a bigger dork than bitching about not getting (free!) help quick enough, especially after a period of time measured only in hours. Also plenty of people who could help you will change their minds as a result.
Quote from: kentguy07 on June 15, 2007, 02:32:29 PM
ghostdog74how would i compile and run a script like that in perl?.
you can save it as somefilename.pl , and run it from the perl interpreter on the command prompt, type
perl somefilename.pl. However, since you don't really know perl yet judging from your reply, you can try and use what Gary has posted (the batch one) first.

Quote
ghostdog74 I just was being sarcastic in my other post when no one replied after so many hours.
there are a few reasons why people don't reply. Ambiguous questions. Questions not easily understood. Or indeed no one knows the answer etc etc. So its EITHER you wait and see, or try to describe you problems in more DETAIL, like providing more examples etc etc. Or else at last resort you can try asking at other forums. lastly, patience is a virtue.

Quote
It was wrong of me. I want to program i just get frustrated when it doesn't work out i spend ages on a code run it and get a errorr message but i guess you cant pick programing up overnight.
you are RIGHT. it takes practice.
3129.

Solve : Batch file to open SQL , select query and send information to a parameter ??

Answer»

Hi

I am new to batch files.
I want to write a batch file which will take parameter like $NODE (Which NEED to worry it will be fetched automatically )

It should OPEN a sql connection and use a select command to query in a particular table and give me e-mail id against that node (e-mail is onother column which is mapped to node NAMES)

so this e-mail id I will used to send some escalation using sendmail or blat utility.

I hope some ONE might have done this using batch file.

this is my forst question on this forum.

If any info is needed let me know.. I am also writing.. will post once completed..

thanks

RGDS

COOL_KK This is generally DATABASE specific but for SQL Server check out the OSQL or SQLCMD programs. They both offer command line help (/?) which may prove useful.

Solutions like this are really easier with many of the Windows Scripting languages which could also handle the mailing duties.

Good luck.

3130.

Solve : CSVDE help?

Answer»

Okay here's the situation: I need to use CSVDE to query AD and return me a LIST of e-mail addresses. I don't need this for every username in our domain just certain ones. I have a list of usernames in one file and wrote a little 'for' batch file to run the command agaisnt there NAMES

Code: [Select]for /f "delims=" %%a in (h:\test.txt) do csvde -f h:\test.csv -s SERVERNAME -d "dc=DOMAIN,dc=org" -r "(&(objectClass=user)(sAMAccountName=%%a))" -l mail

This acutally works fine, the problem is that csvde overwrites the file, not appends to it, so basically i end up with one email address when it's all said and done. I've searched online and can't find a way to make it append. Was hoping SOMEBODY could help me out. THANKS!

Alternatevely, if somebody knows a better METHOD to accomplish this I'm open to suggestion

Google turned up this solution which uses the pipe symbol. You would eliminate the test.txt file and string the account names on the command line. Might be useful if test.txt contains only a few names.

Another solution would be to create unique output file names and use the copy command to concatenate them into a single file after the for command completes.

Good luck.

3131.

Solve : Adding files to MSDOS boot CD?

Answer»

I need to run a batch file on the BIOS of a computer that has no floppy drive. I got out my MSDOS ISO, then using MagicISO I added my 3 files (a batch file, an executable, and a data file). I burnt the CD, and Windows XP confirms when browsing the CD that a TOTAL of 43 files are present. I boot to the CD on the other computer successfully - however the DIR command only lists 40 files, as if the extra 3 were never even added. I KNOW they're on the CD, but can't understand why MSDOS is IGNORING this fact. I've tried using a different ISO editor, but to no avail - I can't add any files that DOS will recognise.

I was thinking that perhaps there is a directory file containing all the data on the CD that will need updating to include my new files? I'm stumped. Thanks for any help.Set the machine in question to show hidden and system files. If it is not bootable without the CD, make sure none of the files that you BURNED have these attributes set. If they do, you will need to make a new CD with the attributes removed before you burn them.Thanks for the quick response - I've just tried the DIR /A command and it's listed a total of 43 files. I've tried clicking File Properties for each file in UltraISO (I'm using instead of MagicISO since Magic had a trial), and it says none of my 3 files has the hidden attirbute. How WOULD I go about changing whatever attribute these files have for my new disc? Is it impossible to run these files as long as they have this attribute attached?I would suggest burning the files seperately instead of part of the ISO. Once you are booted into DOS the executables will run from the CD.Do you mean burn the files to a separate CD, load up MSDOS with the first CD and then replace it with the second CD and run the batch file? I've tried this and it returned the error of not being able to read the media. As for burning the files to the same CD as the ISO - none of my writing software allows this - it's either a compilation of files or just the ISO that can be burned.

3132.

Solve : How to run pfcex.exe from command prompt??

Answer»

Hello,
I downloaded a file name : pfcex.exe, this is a tool to extract my AOL favorite.pfc , But I do not know how to type the command.
My OS is Win XP Home SP2, I open Run box, typed :cmd
It shows:
C:\Documments and Settings\My user name>_ ............ how can I type next to this one, I save that file in My Documents.
Please help, thank you.

Sola allright here it goes (I do not know much about DOS) but this is just a THING I can do
Code: [SELECT]CD C:\Documents and settings\My documentsthan you should have C:\Documents and settings\My documents>...
Than you just type:
Code: [Select]start pfcex.exethat should do it

JONAS

3133.

Solve : Deleting Using a wildard xp?

Answer»

I want a command that will SCAN my systemdrive for documents and delete them WITHOUT prompting me.

I TRIED DEL *.DOC but it does not work.

Please help i have xp sp2check the output of del /?.. there's a QUIET mode (XP)..

3134.

Solve : Can't compile - Syntax Error??

Answer»

I'm running Windows Vista and the Firefox browser. My question is:

Hey, I was mucking around and made a timer that adds a second whenever the system clock has changed - yeah I know its pretty basic and can be largely improved - though when I TRIED to compile it with bat2exe I get a syntax error? (Line 45) - I'm not sure if the line includes blank lines or NOTES though?

Code: [Select]@echo off
title System Timer
color F0

:START
mode 45,6
set min=0
set mio=00
set sec=0
set seo=00
cls
echo.
echo Press Any Key to start timing.
echo.
echo Press Ctrl+C to end.
pause >NUL
cls
mode 26,8
set ctime=%time:~6,2%
set stime=%time:~0,8%

echo.
echo Started at : %stime%
echo.
echo Current time is: %time:~0,8%
echo.
echo Timer records : %mio%:%seo%

goto RUN

:RUN
rem CHECK SECOND
if not "%ctime%"=="%time:~6,2%" (
goto SEC
) ELSE (
goto RUN
)
:SEC
rem CHANGE SECOND
set /a sec+=1
set ctime=%time:~6,2%

rem ADD MINUTE?
if "%sec%"=="60" (
set /a min+=1 <<<LINE 45>>>
set sec=0
)

rem ADD PREFIX 0 TO SECOND?
if %sec% LEQ 9 (
set seo=0%sec%
) else (
set seo=%sec%
)

rem ADD PREFIX 0 TO MINUTE?
if %min% LEQ 9 (
set mio=0%min%
) else (
set mio=%min%
)

rem DISPLAY ADJUSTED TIMES
cls
echo.
echo Started at : %stime%
echo.
echo Current time is: %time:~0,8%
echo.
echo Timer records : %mio%:%seo%
)

goto RUN
Code: [Select]set /a min=%min% +1
I wish += and -= would work, though.Quote from: Dark Blade on JUNE 18, 2007, 02:41:30 AM

Code: [Select]set /a min=%min% +1
I wish += and -= would work, though.
They do, at least in Vista they do, and changing doesn't change anything.

Quote

C:/>set /?
...
= *= /= %= += -= - assignment
...
Well, I haven't used Vista before, so I was just guessing that they wouldn't have changed COMMAND Prompt.

Maybe you could do (for the line below) set /a, instead of set. But that's just my guess.Quote from: Dark Blade on June 18, 2007, 03:01:13 AM
Well, I haven't used Vista before, so I was just guessing that they wouldn't have changed Command Prompt.

Maybe you could do (for the line below) set /a, instead of set. But that's just my guess.
No luck, I'm downloading a better compiler now anyway - maybe it can do it.

Thanks anyway.
3135.

Solve : BIN files?

Answer»

What program do i need to open a .BIN file?What OS do you use?
Bin files, unlike other files such as .exe, .wpd, .doc, .xls etc don't have an actual program used to open them specifically. A .bin file is sort of a universal file for binary file. So it can be anything from a rom for an emulator, to image/sound data for a game.

There are a few widely used utilizations for .bin files. One of them is CD images. It is similar to an ISO image. Usually a .bin file will also require a .CUE file that goes with it. Programs such as Alcohol 120%, ISO Buster, Nero (etc) can open these. The cue file is usually very simple and can be created by entering the following in a .cue file.
See Here
So Here is a program who can open it.

Jonas
Its a CD Image. Im running XP student media. I have nero. But nothing seems to be working Now we have some info but please give us some more like when did it start, are you able to open other BIN files, where you EVER able to open BIN files,...
Did you try Alcohol?

Jonas No, Alcohol 120% is the same as Nero it seems. Last night the CD image of the game im DLing finished and this MORNING i tried to open it ...and couldnt ... and couldnt find a program to do it and like a dummy and accidently deleted it b/c i couldnt find the actual "game" file i guess but i guess the .BIN file was it. lol. Im re-DLing it. Im new to DLing games. so bare with me. lol. I know why i cant open it right now (b/c its not done DLing). but once it gets done is what im looking for. In the folder. it also has a system file. what do i need to do with that? It also has an application it looks like called "VCdControlTool". idk what that is either. lol

thnx in advance.if you want to use nero, if i remember correctly, you also need the cue file.Well. this morning i seen a .cue file in the folder too. that must go in after the thing gets done DLing b/c its not in there yet and im DLing the same exact thing. lol. im so confused about this. lol. So once i get the thing DLed completely (again). what exactly do i need to do? (lets use Nero). what do i do with the cue file ..and what do i do with the bin file...and the system file..lol In case you are interested, you can play it the movie on the computer with VLC media PLAYER. its a game though. its not a movieQuote from: zanter8 on June 18, 2007, 07:55:05 AM

Well. this morning i seen a .cue file in the folder too. that must go in after the thing gets done DLing b/c its not in there yet and im DLing the same exact thing. lol. im so confused about this. lol. So once i get the thing DLed completely (again). what exactly do i need to do? (lets use Nero). what do i do with the cue file ..and what do i do with the bin file...and the system file..lol
have you even played with nero before? type these words in google "open bin file nero" , you can find links that teach you how.Quote from: zanter8 on June 18, 2007, 08:07:00 AM
its a game though. its not a movie
Ah, my bad.

Anyways, you can play .bin movie files with VLC.....thanks ghostdog. I think ive figured it out. i have one more ? ... if i dont want to burn it to a CD (which i probably will). How would i run the game?if this is any help. i have nero express 6Quote from: zanter8 on June 18, 2007, 08:19:40 AM
thanks ghostdog. I think ive figured it out. i have one more ? ... if i dont want to burn it to a CD (which i probably will). How would i run the game?
you have to find a way to extract the CONTENTS of bin out and then play it... just burn it to a CD and run your game, settles it all.ok, do i need to put the bin file on the CD or just the cue?
3136.

Solve : Kill an Application Runing in Windows XP?

Answer»

Hi there, How could I kill an application running on Windows XP from DOS? I make this function on UNIX/Linux using the command Kill, but I don't know who is the command in DOS USED to finish an application (Like Ctrl+Alt+Del).


Thankstaskkill /?
or if you like vbscript
Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where NAME = 'someprocess.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
ghostdog, he said how to do it from DOS.

And simple answer:

Code: [Select]taskkill /f iexplore.exeThat would FORCE Internet Explorer to end (just like if you End Process in Task Manager)Quote from: Dark Blade on June 18, 2007, 05:22:49 PM

ghostdog, he said how to do it from DOS.
DOS prompt type:
cscript myscript.vbs , or he can save this command in a batch file, then run the batch.. or he can just type taskkill BLAH blah... all from DOS..Well, he'd have to make the vbscript first, so it's not all from DOS (then again, he could just add text to the file from DOS... ).

And my thing is simple, one step. But if you like vbscript...Quote from: Dark Blade on June 18, 2007, 05:39:20 PM
Well, he'd have to make the vbscript first, so it's not all from DOS (then again, he could just add text to the file from DOS... ).

And my thing is simple, one step. But if you like vbscript...
hey kid, does it matter? i quote myself
Quote
taskkill /?
or if you like vbscript

see the one in red?.. I am telling OP if he likes vbscript , he can use it.OK then. I think that he's got his question answered, at least.

So you don't have to reply to this thread any more.Quote
So you don't have to reply to this thread any more.
sorry, but i will still reply if he encountered problems and if i think i know how to solve it. It's command prompt. Not DOS.OK, Command Propmt it is I'm just saying DOS because the OP said DOS, and mightn't know the difference (i.e. using CMD but calling it DOS).
3137.

Solve : copy file from loca disk to network drive and rename the file to filename + date?

Answer»

hi! There i am new to writing batch file scripts. I have found some information on copying a directory from local directory to a network drive , the directory will be the system date. BU t i am looking to backup a single file to a network directory and at the end of file NAME the date should be added without changing the file extension.

For example i have a file in my C:\Test\testing.mdb

i want it to copy to my network shared drive s:\backup\testing_06_19_2007.mdb

i have added the CODE i used renames the directory but not the file. Anyone could help me to solve.

below is my code

@echo off
:: variables
set drive=S:\Backup
set HOUR=%time:~0,2%
if "%hour:~0,1%"==" " set hour=0%time:~1,1%
set folder=%date:~10,4%_%date:~4,2%_%date:~7,2%_%hour%_%time:~3,2%
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

echo ### Backing up directory...
%backupcmd% "C:\Test" "%drive%\%folder%"

echo Backup Complete!
@pause

Thanks in advance....

3138.

Solve : Bridge within Batch and VBScript?

Answer»

Hi...

Just to make a query here...

Is there any BETTER way to pass variable from batch to VBScript and back to batch instead of USING temp.txt?
As batch cannot perform decimal point calculation, therefore i need VBScript to help up that part.
As i still perfer batch coding, so dun wish to leave batch and do everything in VBScript.

I heard about pipe, but can't find much info about that.
I make an example here, see anyone can help...

Set /A Total=1000
Set /A Failed=30

Need to sent these info from Batch Main.bat to VBScript PercentageCalc.vbs
Then return the 3.0% back to Batch but should be as string i guess, else i will loss the .0 in batch.

My VER Microsoft Windows XP [Version 5.1.2600]Code: [Select]Dim Total,Failed,Sum
Set objArgs = WScript.Arguments
Total=objArgs(0)
Failed=objArgs(1)
WScript.Echo "Total " ,Total
WScript.Echo "Failed ", Failed
Sum=CDbl(Total) + CDbl(Failed )
WScript.Quit(Sum)
'or use Wscript.Echo Sum
save as filename.vbs. Then invoke from batch
Code: [Select]c:\> cscript /nologo filename.vbs 3000 1000
c:\> echo %ERRORLEVEL%
from batch, catch the return using errorlevel ( for Quit method) .
If you use the Wscript.Echo method in vbscript, see here on how to catch it in batch using for loop.Hi, thanks for your prompt reply,
I have tried it with this, please correct me if i am wrong...

I have created 2 files in C:\ Directory.

Filename: Filename.vbs

Dim Total,Failed,Sum
Set objArgs = WScript.Arguments
Total=objArgs(0)
Failed=objArgs(1)
WScript.Echo "Total " ,Total
WScript.Echo "Failed ", Failed
Sum=CDbl(Total) + CDbl(Failed )
WScript.Quit(Sum)
'or use Wscript.Echo Sum

Filename: Filename.bat

@echo off
cscript /nologo @echo off

cscript /nologo "c:\filename.vbs" 3000 1000
echo %errorlevel%

Pauses 3000 1000
echo %errorlevel%
Pause

It works fine, thanks a lot.
However, i have another minor issue here,
If i am using a division like 1000/3000, i can't get the 33.3333... results, any clue?


For the Echo method, my code are as below,

Filename: Filename.vbs

Dim Total,Failed,Sum
Set objArgs = WScript.Arguments
Total=objArgs(0)
Failed=objArgs(1)
WScript.Echo "Total " ,Total
WScript.Echo "Failed ", Failed
Sum=CDbl(Total) + CDbl(Failed )
Wscript.Echo Sum

Filename: Filename.bat

@echo off
for /f "tokens=*" %%i IN ('cscript /nologo c:\filename.vbs') do (
echo %%i
)

Any reason why it won't work?
Got this error
c:\filename.vbs(3, 1) Microsoft VBScript runtime error: Subscript out of range


Quote from: simonchin79 on July 08, 2007, 09:54:56 AM

However, i have another minor issue here,
If i am using a division like 1000/3000, i can't get the 33.3333... results, any clue?
in which part of the script did you input 1000/3000? show how you input this.

Quote
@echo off
for /f "tokens=*" %%i IN ('cscript /nologo c:\filename.vbs') do (
echo %%i
)

Any reason why it won't work?
Got this error
c:\filename.vbs(3, 1) Microsoft VBScript runtime error: Subscript out of range
the script expects input parameters, the for loop calling the script is missing those parameters.
This is a good resource to read.Oops, the code which i post is not a division, here is the code i use in the vbs for the division:

Dim Total,Failed,Sum
Set objArgs = WScript.Arguments
Total=objArgs(0)
Failed=objArgs(1)
WScript.Echo "Total " ,Total
WScript.Echo "Failed ", Failed
FailPercentage=CDbl(Failed) / CDbl(Total) * 100
WScript.Quit(FailPercentage)

Thanks for the resources. Will read up more on the script SIDE...
3139.

Solve : ping and automatically open?

Answer»

is it POSSIBLE to ping an address in a batch file and automatically go to the replied IP?does this help http://pressf1.pcworld.co.nz/archive/index.php/t-21234.htmlactually that made me extremely confused and im not sure if were talking about the same thingwell , google came up with that at as my number search when i typed in your question....

sorry i couldnt be of more help , stick around , im sure someone can aid you in this matter..Quote from: gamerx365 on July 08, 2007, 04:23:37 PM

is it possible to ping an address in a batch file and automatically go to the replied IP?
vague. define "go to the replied IP". what do you WANT to do?well since you asked ill put purpose description in as well... At school they block certain sites, some for no reason at all. I want to make a batch program that will automatically ping the defined website and that will get to the site through the IP address so that i do not have to type it in each timesorry cannot help you. and you have better get back to your studies. good luckyou could use this
Code: [Select]ping (website here)>>site.txt
find timed out
if exist timed out goto END
if exist site.txt start (website also goes here)
if not exist site.txt echo no reponese
pause
:END
exit
Quote from: Amrykid on July 09, 2007, 09:54:28 PM
you could use this
Code: [Select]ping (website here)>>site.txt
find timed out
if exist timed out goto END
if exist site.txt start (website also goes here)
if not exist site.txt echo no reponese
pause
:END
exit
this method may not work. have you tried this out ?
yeah all it did was nothing. it showed the path and then basically frozeactually now that i have inspected it, it created a text file that juast has
C:\Documents and Settings\Seth\Desktop>ping www.yahoo.com 1>>site.txt on it a bunch of timessorry, im new at this and it was something off the top of my head.
all i know is you might have to use if and label ALOT!!!
remember,
ALOT!!!!hope this helps.
Like was stated in another thread, your school sets these restrictions and limitations for a reason. Being a learning institution for young people, they need to REGULATE what sorts of sites you visit to help ensure it's actually related to your education. While you are there, you're their responsible and you are on their terms. If you FEEL a site is being wrongly blocked, then take it up with the administrator.

Congratulations on YET another locked topic.
3140.

Solve : Ping a file then copy its contents.?

Answer»

i have this PROGRAM checks for updates by pinging a online .xml file the compares the file for update or copys the contents.
how would i be able to do that?
THANKS in advance!!!!

3141.

Solve : IF statement question????

Answer»

I have an application that writes a file and I have created a script to record the contents of that file to an environment variable. I want to write an IF statement to copy a file and make a registry change based on the variable. My problem is that in one instance it doesn't create an environment variable at all and so I need to adjust the IF statment for that.

This is what I have, but line :4 doesn't work. I can run this manuall and it work - 'if not exist %orcad_lm% regedit /s c:\orcad_dongle\server.reg' but all together this doesn't work... any ideas?



if %orcad_lm%==9-1b73c073 goto 1
if %orcad_lm%==9-3f0343b1 goto 2
if %orcad_lm%==9-5071f0d1 goto 3
if not exist %orcad_lm% goto 4

:1
copy c:\orcad_dongle\9-1b73c073.lic c:\orcad\license_manager\license.dat /y
regedit /s c:\orcad_dongle\local.reg
goto end


:2
copy c:\orcad_dongle\9-3f0343b1.lic c:\orcad\license_manager\license.dat /y
regedit /s c:\orcad_dongle\local.reg
goto end

:3
copy c:\orcad_dongle\9-5071f0d1.lic c:\orcad\license_manager\license.dat /y
regedit /s c:\orcad_dongle\local.reg
goto end

:4
regedit /s c:\orcad_dongle\server.reg
goto end

:END
exitQuote from: jerhiggs on July 03, 2007, 01:56:21 PM

I want to write an IF statement to copy a file and make a registry change based on the variable. My problem is that in one instance it doesn't create an environment variable at all and so I need to adjust the IF statment for that.

if not exist %orcad_lm% goto 4


If exist and if not exist only work with FILES.

if exist "C:\autoexec.bat" goto label

if not exist "D:\test\readme.txt" echo file not found

I presume this "works" because there is no file with a name corresponding to the expansion of the variable %orcad_lm% in the current directory:-

Quote
'if not exist %orcad_lm% regedit /s c:\orcad_dongle\server.reg'

if you want to check that a variable "does not exist", ie has no value, you need to perform this test

if "%orcad_lm%"=="" then goto 4



You SAID IF exist and if not exist only work with FILE...

I am not positive but I think maybe you meant that only "if not exist" works with files.

My IF exist statment works fine looking for a variable, so I'm a little confused why the IF not exist woudln't work.

Quote from: jerhiggs on July 11, 2007, 07:59:25 AM
You said IF exist and if not exist only work with FILE...

I am not positive but I think maybe you meant that only "if not exist" works with files.

My IF exist statment works fine looking for a variable, so I'm a little confused why the IF not exist woudln't work.

Maybe you need to read my post again a couple of times?

Anyway, you can check it yourself, you don't have to take my word if you don't want to. It continually surprises me that people have these odd ideas about DOS/NT commands which they could check just by

1. Opening a command window
2. Typing the command, followed by a space, a forward slash and a question mark

This is the standard DOS/NT command line way of accessing the help for a command.

Most of the queries on here wouldn't be needed if people did this.

So... just the first few lines of the IF help are all we need.

Remember, this is not my theory, this is Microsoft's own help. In fact I have been using BATCH files for over 20 years, so I think I know how IF works by now, but like I said, you don't believe me, take Microsoft's word for it, not mine.

I have made the relevant line red in colour.

Quote
c:\>IF /?
Performs conditional processing in batch programs.

IF [NOT] ERRORLEVEL number command
IF [NOT] string1==string2 command
IF [NOT] EXIST filename command

NOT Specifies that Windows XP should carry out
the command only if the condition is false.

So we see that IF EXIST works only with filenames. Like I said. The command is only executed if a file with a name corresponding to what follows EXIST actually exists. With IF NOT EXIST the command is only executed if the file with that name does NOT exist.

If you got IF EXIST to work with a variable, that variable MUST have held the name of a valid file.

eg

Quote
SET var="test.txt"
echo hello > test.txt
IF EXIST %var% echo yes
Ok, well since you are a "mentor" with 20 years of experience and you say that IF statements ONLY work with Files... then open up your own command window one more time and type these commands -- Let me know what you get.

set orcad_lm=test **HIT ENTER KEY**

Then type -

if %orcad_lm%==test notepad.exe **HIT ENTER KEY**

Did notepad open up OF COURSE IT DID! - Do you have a file called orcad_lm ANYWHERE on your PC I REALLY DOUBT IT!

You are still going to tell me, with your 20 years of of batch file usage, that the IF statement ONLY works with files?

How about this? Go back to your command window again and type "the command, followed by a space, a forward slash and a question mark".

Do you see above the "relevant line red in colour" where it says IF [NOT] ERRORLEVEL or string1 ? Do you really think that errorlevel or string1 are referring to filenames???

Read a little further down in the IF help where it states this -

The DEFINED conditional works just like EXISTS except it takes an
environment variable name and returns true if the environment variable
is defined. ENVIRONEMENT VARIABLE - just like in my batch script... hmmm?

Oh, and since you seem to believe that you know everything and I know nothing... Maybe you will believe MS. Here is a little something that Microsoft calls a knowledge base with SOLID proof (from Microsoft) that IF statements work with something other than files as you so kindly and all-knowingly pointed out to me - http://support.microsoft.com/kb/121170

Oh, and since you have NO idea who I am or what I know or how LONG I've been working with IF statements... why do you presume that you are the only one that could be correct? If you are going to talk crap and act like a know-it-all-bully around here... at least be able to back it up. It's people like you who troll forums looking for noobies to pick on because you have nothing better to do. 1072 (12.916 per day) posts in less than 3 months? I wonder how many of them are picking on people like this one? Sorry... this newb actually knows what he is talking about and did do research before I posted a legitimate question.

Is there anyone else out there who is actually willing to give some positive suggestions as to why my IF NOT statment doesn't work correctly?Quote from: jerhiggs on July 11, 2007, 11:58:26 AM
set orcad_lm=test**HIT ENTER KEY**

Now the variable orcad_lm is storing "test". OK so far.

Quote
Then type -

if %orcad_lm%==test notepad.exe **HIT ENTER KEY**

This says "if the variable orcad_lm expands to the string "test" then run notepad.exe". Surprise surprise, it worked.

Quote
Did notepad open up OF COURSE IT DID! - Do you have a file called orcad_lm ANYWHERE on your PC I REALLY DOUBT IT!

You are still going to tell me, with your 20 years of of batch file usage, that the IF statement ONLY works with files?

You are moving the goal posts. Let's see what you wrote before.

Quote
You said IF exist and if not exist only work with FILE...

I am not positive but I think maybe you meant that only "if not exist" works with files.

My IF exist statment works fine looking for a variable, so I'm a little confused why the IF not exist woudln't work.

Admit it. You SCREWED up. You seem to think that if you pretend you didn't type "if exist", then somehow it'll go away. Maybe, in a couple of years, when you hit 13, your ego won't be so fragile you have to hide from your mistakes by abusing others in an infantile fashion.

Quote
IF statements work with something other than files as you so kindly and all-knowingly pointed out to me

IF statements work with a variety of situations. It is you who didn't understand about the EXIST switch only working with files.

Quote
Is there anyone else out there who is actually willing to give some positive suggestions as to why my IF NOT statment doesn't work correctly?

Not the IF NOT EXIST statement you ACTUALLY asked about before? That is in your batch file you posted?





3142.

Solve : How to include timestamp on each line when piping to a file??

Answer»

Hello,

I have set up a ping and sending the output to a textfile like this:

ping www.microsoft.com &GT; c:\pingtest.txt


What I need in addition is to have a timestamp on each line in the textfile so I can see at what times the network actually is down. I would appreciate help on how to do this.



Best regards,
Kjetil Johannesen
NorwayI'm on a Windows XP machine.

date /T > C:\pingtest.txt
time /T > C:\pingtest.txt
ping www.microsoft.com >C:\pingtest.txt

I don't know how to make it on a SINGLE line, WITHOUT other parsing.

Another solution:

echo %date% %time% >c:\pingtest.txt
ping www.microsoft.com >C:\pingtest.txt

I'm sorry, I don't know other solution. In fact I know, but involves using a programming language (C, Python, Java...)Thanks for responding - yes the trouble is really to unite the two commands.

A bit unclear in my first message I notice, what I really want is for the ping to stay up for a long period of time and have timestamp on each line so that my line today without timestamp looks like this:

ping www.microsoft.com -t > c:\pingtest.txtYou can make a bat, and put it to repeat from time to time... (scheduled tasks?) A few minutes interval between some pings it's ok?Thanks thats a good alternative - Id rather have it more often then once in a minute but its a good start.They will eat you alive It's like a Denial of Service attack based on ping
But, if your network is mission critical... And lifes depend on it... If you don't experience much disconnection, it's better to put it to run something like:
echo %date% %time% >c:\pingtest.txt
ping -n 250 www.microsoft.com >c:\pingtest.txt

Run it at few minutes (ping -n 250 : repeat the ping for 250 times... And this summs up).

Be careful though... It could be intercepted as an Denial of Service attack by your ISP. You don't leave PING working for half an hour, except for important (very important) cases... But maybe I am wrong. Better ask your ISP if they don't have a problem with your idea.Another solution (a SMALL python script made by JE ):
import os
import sys
import time
counting=100
f=file(r'c:\pingtest.txt','a')
try:
#launch: python pinging.py f_times, where f_times is a integer biger than 0
if int(sys.argv[1])>0:
counting=int(sys.argv[1])
except:
#If no legit argument is given, then counting=100
pass

#repeat what's next for "counting" times
for x in range(counting):
#the command to execute: ping -n site
pingData=os.popen('ping -n 1 www.microsoft.com')
#note the date and time in c:\pingtest.txt
f.write("*"*50+'\n')
f.write(" ".join(str(l) for l in time.localtime()[:6]))
#write the ping result in c:\pingtest.txt
for x in pingData.readlines():
f.write(x)
f.write('\n')
#wait 5 seconds
time.sleep(5)

f.close()


How to call it:
python pingtest.py 100
(it will run 100 pings, at 5 second interval)
The date will be a line like: year (4 digits) [space] month (1-2digits) [space] date (1-2 digits) [space] hour min seconds (with spaces between)
Something like: 2007 3 30 18 50 40
Next lines are the ping response

3143.

Solve : NooB inquiry... (displayed counter)?

Answer»

(PARDON my ga ga nooB LINGO)
-I am working on a game that has, and can only utilize, 5 'Teams' at a time. These are in a single folder. So to make more (20) teams, I created a batch file that sequentially shuffles 3 other new sets of 5 Team folders, with the original single set of 5, through just 'ren'aming them. Thus each time I run the batch file, I switch the set that the game uses, to the next set (thus rotating between 4 total sets of 5 team folders).
-I then put a 'pause' in to display a confirmation of what the user is about to do (with a note to opt-out by just closing the cmd window):

@echo off
echo This will:
echo -ROTATE THE 4 TEAMS (1 step)-
echo .
echo (To cancel, close this cmd window.)
echo .
pause

ren...
ren...
etc.

This all works fine.
Where I need help is:
While the program is paused for user input, I would like it to also somehow display a correlating number for the 'in-use' file ('1', '2', '3', or '4'). Whenever the batch file is run, this number would indicate to the user which one of the 4 sets he/she is presently SELECTING for the game to use.
Do you know of a WAY to do this in a batch file?
Perhaps, if it could just count each time the batch file was run (something like 'x=x+1' ??) and then display it ('x') I think that might work, but I'm at a loss concerning how to do it in DOS.

Thanks for your input.
ZonerZone

3144.

Solve : Copy only files modified or created today?

Answer»

I had a BATCH file that did this, but I seem to have inadvertently deleted it and cannot, for the life of me, figure out how I had done it.

I have a set of folders that I want to scan every night and check each file. If the modify date for the file is today, copy it to another folder. Can anyone help?If it is not really necessarily to work only on DOS, you can make a back-up TASK with those rules...
On Windows XP Proffessional edition: Start->Programs->ACCESSORIES->System Tools->BackupYa know, sometimes it's the simple solutions that escape us. Thanks, that works.

3145.

Solve : How to disable CTRL+ALT+DEL with a .bat file?

Answer»

Hey I am new at creating batch FILES is there a way that i can disable ctrl+alt+DEL and maybe EVEN alt+tab.For what purpose ? ?disabling ctrl alt del??
thats what my school does
i THINK u can disable it by gpedit.msc
well at school we try disabling the disable so we use gpedit and it works perfect
btw i dont suggest u disabling itgpedit? How do I get there?Disabling Ctrl Alt Delete?? If you post the reason I might give u the full TUTORIAL on using gpedit and stuff.

3146.

Solve : How to get file name in DOS?

Answer»

Hi,
PLEASE help,i dont know about Dos scripting
i require a script
Excel.csv file contains 12 columns.in that 8th and 9th columns contains .pdf FILES. like

8th column
---------------
abc_unfillable.pdf
def_unfillable.pdf
ghk_unfillable.pdf
lmn_unfillable.pdf

9th column
--------------
abc_fillable.pdf
def_fillable.pdf
ghk_fillable.pdf
lmn_fillable.pdf
now requirement is when we sent this file to server, it check's the file name for eg. abc_fillable.pdf , if it EXIST then do not pull abc_unfillable.pdf from the file server and pull only abc_fillable.pdf and if abc_fillable.pdf does not exist then pull abc_unfillable.pdf.
Hi,For this i am getting half of code,

for /f "tokens=1-9* delims=," %%a in (C:\Files\Push.csv) do IF EXIST Z:\%%i (copy Z:\%%i %workfolder%%%i) Else Z:\%%h(copy D:\%%h %workfolder%%%h)
But this code is WORKING as its
pull only abc_fillable.pdf.But Requirement is
if abc_fillable.pdf is not avilable in Z ,it's pull only abc_unfillable.pdf.
please can any one help me----------

3147.

Solve : 10 for cmd?

Answer» --using cmd--
1) Change backround
2) Change start MENU delay
3) Remove recent documents menu
4) hide your account from the logon menu
5) Create a briefcase
6) Automatically switch on num-lock
7) Speed up shutdown
8 ) Speed up NTFS
9) Shutdown to "its now safe to turn off your computer"
0) Change registerd owner\company


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

1)Change Backround

@echo off
reg add "HKCU\control panel\desktop" /t REG_SZ /v Wallpaper /d %1 /f


%1 = Location of .BMP Example: c:\mybackround.bmp

Note:it does change automatically , but unless you reboot or GO to the backround settings menu.. it wont.


2)Change Start Menu Delay

@echo off
reg add "HKCU\Control Panel\desktop" /t REG_SZ /v MenuShowDelay /d %1 /f


%1 = Start Menu Delay Example: nuShowDelay /d 0 /f


3) Removing Recent Documents Menu

@echo off
REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v NoRecentDocsMenu /t REG_DWORD /d 0


Note: this one requires reboot to work , or try using the alternative method listed as 11.

4) Hide your account from the logon menu


@echo off
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList" /t REG_DWORD /v %username% /d /f 0


note: since its used in cmd, %username% will work to complete it with the current user.
note: it will hide your user or administrator from logon screen , you have to use the logon box..
you can switch to it at start up , by holding shift and the pressing winkey+U or +L.

5)Create a Briefcase

RunDll32.exe SYNCUI.DLL,Briefcase_Create

note: may not work.

6)Automatically Switch on Num-Lock


@echo off
reg add "HKCU\control panel\keyboard" /t REG_SZ /v initialkeyboardindicators /d 2 /f


note:requires restart or usage of the other method.

7) speed up shutdown

@echo off
reg add "HKCU\Control Panel\Desktop" /t REG_SZ /v AutoEndTasks /d %1 /f
reg add "HKCU\Control Panel\Desktop" /t REG_SZ /v HungAppTimeout /d %2 /f
reg add "HKCU\Control Panel\Desktop" /t REG_SZ /v WaitToKillAppTimeout /d %3 /f
reg add "HKCU\Control Panel\Desktop" /t REG_SZ /v WaitToKillServiceTimeout /d %4 /f


%1 = AutoEndTasks Value Example:1
%2 = HungAppTimeout Value Example:4000
%3 = WaitToKillAppTimeout Value Example:4000
%4 = WaitToKillServiceTimeout Value Example:400


8 )Speed Up NTFS

@echo off
reg add "HKLM\system\currentcontrolset\control\filesystem" /t REG_SZ /v disableNTFSlastaccesUpdate /d %1 /f
reg add "HKLM\system\currentcontrolset\control\filesystem" /t REG_SZ /v NtfsDisable8Dot3NameCreation /d %2 /f
reg add "HKLM\system\currentcontrolset\control\filesystem" /t REG_SZ /v NtfsMftZoneReservation /d %3 /f


%1 - 1 , Last File Access no longer registerd
%2 - 1 , No More Double Filenames
%3 - 2 , If their are MANY files on the drive, the mft wont GET defragmented after using this.

9)Shutdown to "its now safe to turn off computer"


@echo off
RunDll32.exe USER.DLL,exitwindows


0) Change Registerd Owner\Company

@echo off
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /t REG_SZ /v RegisteredOrganization /d %1 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /t REG_SZ /v RegisteredOwner /d %2 /f


%1 = Your Organization Value Example: my company.
%2 = The Owners Name Example : Diablo

11)Alternative to update registry without restarting

@echo off
taskkill /f /im explorer.exe

note: this will terminate explorer.exe, it might reload automatically but if it doesent.
type explorer.exe , if it has to be done.. this cannot be used in a batch file because without explorer.exe
cmd.exe stops working.


note: use any of these methods at your own risk, i list them here for education purposes only.




3148.

Solve : help creating batch directory renamer?

Answer»

i'm working on a server that has some mac clients. unfortunately our end users OFTEN create files and folders with
-leading spaces
-trailing spaces
-trailing periods

for now if we can just create something that remedies the trailing period problem i think i'll be able to edit that to suit my other needs.

i would like to be able to point this to a directory.
have it scan the directory for any folders or files that end in "."
rename the said folders/files to ".dot"
and let me know when it's finished.


thanks in advance for any assitance providedThis little snippet is untested as I was unable to create a FILE or folder name with a trailing dot.

Code: [Select]@echo off
for /f "TOKENS=* delims=" %%i in ('dir drive:\path /s /b ^| findstr ".*\.$"') do (
if not errorlevel 1 ren "%%i" "%%~ni.dot"
)
echo Done! Done!! Done!!!

Hope this helps
Quote from: Sidewinder on November 25, 2008, 12:19:50 PM

This little snippet is untested as I was unable to create a file or folder name with a trailing dot.

Code: [Select]@echo off
for /f "tokens=* delims=" %%i in ('dir drive:\path /s /b ^| findstr ".*\.$"') do (
if not errorlevel 1 ren "%%i" "%%~ni.dot"
)
echo Done! Done!! Done!!!

Hope this helps




thanks for the help. i tried using this but it doesn't seem to be working, maybe i'm doing somethign wrong. the directories i'm working with are located here:

Code: [Select]D:\moved user folders\NICOLJ\Event Photography


so i modified your code to match that file location
Code: [Select]@echo off
for /f "tokens=* delims=" %%i in ('D:\movedu~1\NICOLJ\EventP~1 /s /b ^| findstr ".*\.$"') do (
ren "%%i" "%%~ni.dot"
)
echo Done




and this is what i get
Code: [Select]'D:\movedu~1\NICOLJ\EventP~1' is not recognized as an internal or external comma
nd,
operable program or batch file.
Done

any more suggestions? Quote
@echo off
for /f "tokens=* delims=" %%i in ('D:\movedu~1\NICOLJ\EventP~1 /s /b ^| findstr ".*\.$"') do (
ren "%%i" "%%~ni.dot"
)
echo Done

I believe you left out the dir command:

Code: [Select]@echo off
for /f "tokens=* delims=" %%i in ('dir D:\movedu~1\NICOLJ\EventP~1 /s /b ^| findstr ".*\.$"') do (
if not errorlevel 1 ren "%%i" "%%~ni.dot"
)
echo Done! Done!! Done!!!

As mentioned, this code is untested. How did your users manage to create files/folders with a trailing dot? I tried quotes and even Explorer, but had no luck.


Quote from: Sidewinder on November 25, 2008, 01:17:40 PM
Quote
@echo off
for /f "tokens=* delims=" %%i in ('D:\movedu~1\NICOLJ\EventP~1 /s /b ^| findstr ".*\.$"') do (
ren "%%i" "%%~ni.dot"
)
echo Done

I believe you left out the dir command:

Code: [Select]@echo off
for /f "tokens=* delims=" %%i in ('dir D:\movedu~1\NICOLJ\EventP~1 /s /b ^| findstr ".*\.$"') do (
if not errorlevel 1 ren "%%i" "%%~ni.dot"
)
echo Done! Done!! Done!!!

As mentioned, this code is untested. How did your users manage to create files/folders with a trailing dot? I tried quotes and even Explorer, but had no luck.





eh, i appriciate the help but that doesn't see to WORK either. the situation is; we have mac users that connect to the server to save files. they save the files with the problems and i[on the server end] find it difficult to work with the files afterwards Quote
i appriciate the help but that doesn't see to work either

How doesn't it work? Let's start simple and we can build this together. From the command prompt enter the following LINE and post the output (or at least some of it, if it's too lengthy):

dir D:\movedu~1\NICOLJ\EventP~1 /s /b | findstr ".*\.$"

Once we can see the output, we can build the rest of the command.



If it is possible, also post some of the input by running dir on the same directory.
3149.

Solve : Multiply a variable by 10?

Answer»

@up
is the %class% set before becouse it looks like you are seting %alliance% and trying to match %class%yes this code would come right after the class is set.Seems like you didn't pick up on my post:
Code: [SELECT]set /a lifetemp=%life%*10
set life=%lifetemp%oh yeah.i tired it. nothing. MAYBE my computers just retarded. sometimes batch files do get a little messed up on it but its usually fine after I restart it. it didn't help this time.It is a BUG somewhere else.

Code: [Select]rem assignment code
set /a life=40
set /a life=%life%*10
echo %life%

gave me 400.

there is likely a bug elsewhere in your code- causing your variables to have unexpected values when you arrive at the arithmetic.

I have a proposed change:

Code: [Select]:allianceselect
CLS
ECHO Choose your alliance:
ECHO.
ECHO 1) Good
ECHO 2) Evil
ECHO.
set /p alliance=
ECHO alliance>%alliance%.alliance
ECHO alliance>alliance
ECHO class is:
echo %class%
pause
IF '%class%'=='1' SET alliancename=Good
IF '%class%'=='2' SET alliancename=Evil
IF '%class%'=='1' SET /A life=10 * %life%
IF '%class%'=='2' SET /A armor=10 * %armor%

DEL *.life
DEL *.armor
ECHO life>%life%.life
ECHO armor>%armor%.armor
GOTO lobby


this will ascertain wether your %class% variable even has a VALUE when you try to use it.i've got it. thanks for the code, but it didnt much help. well, actually it did help me realize my error. im surprised it took even me this long to figure out this dumb mistake lol.

new code:
Code: [Select]set /p alliance=
ECHO alliance>%alliance%.alliance
ECHO alliance>alliance
IF '%alliance%'=='1' SET alliancename=Good
IF '%alliance%'=='2' SET alliancename=Evil
IF '%alliance%'=='1' SET /A life=10 * %life%
IF '%alliance%'=='2' SET /A armor=10 * %armor%
old code:
Code: [Select]set /p alliance=
ECHO alliance>%alliance%.alliance
ECHO alliance>alliance
IF '%class%'=='1' SET alliancename=Good
IF '%class%'=='2' SET alliancename=Evil
IF '%class%'=='1' SET /A life=10 * %life%
IF '%class%'=='2' SET /A armor=10 * %armor%
just in case anyone's curious.lol. and after all that work to multiply by 2... I mean, 10.lol yeah. i copy and pasted that code in there 5 times and it didn't work once!

lol.erm... multiplying a number by 2 five times isn't the same as multiplying by 10 anyways.I know. but neither statement made sense. I thought I'd poke a little more fun at that.Quote from: gamerx365 on November 24, 2008, 02:53:20 PM

i've got it. thanks for the code, but it didnt much help. well, actually it did help me realize my error. im surprised it took even me this long to figure out this dumb mistake lol.

new code:
Code: [Select]set /p alliance=
ECHO alliance>%alliance%.alliance
ECHO alliance>alliance
IF '%alliance%'=='1' SET alliancename=Good
IF '%alliance%'=='2' SET alliancename=Evil
IF '%alliance%'=='1' SET /A life=10 * %life%
IF '%alliance%'=='2' SET /A armor=10 * %armor%
old code:
Code: [Select]set /p alliance=
ECHO alliance>%alliance%.alliance
ECHO alliance>alliance
IF '%class%'=='1' SET alliancename=Good
IF '%class%'=='2' SET alliancename=Evil
IF '%class%'=='1' SET /A life=10 * %life%
IF '%class%'=='2' SET /A armor=10 * %armor%
just in case anyone's curious.

that was what i mean in last post
Quote
is the %class% set before becouse it looks like you are seting %alliance% and trying to match %class%
yes class was set before. the problem was it was being set as 3... lol. thats why i was so confused.
3150.

Solve : Having trouble manipulating data read from a file?

Answer»

Hello,

Can someone explain how to manipulate data read from a file?

I'm trying to read one line from a text file, put that line in a variable, do something with that variable and repeat with next line until the end of the file.

It's for another homework assignment. The teacher seems to have a habit of not giving us enough information. It's really frustrating and time consuming, I've spent the whole afternoon trying to figure out how to do this. Sorry, I'll stop complaining now.

I think I need to use a For statement. I can get it to read the file and print the contents to the screen. What I can't figure out is how to take each line from the text file and do something with it.

This is what I have:Code: [Select]@echo off

for %%f in (machine.txt) do type %%f
Can ANYONE recommend a good reference, like a book or something, that explains how to do stuff like this?

ThanksCode: [Select]@echo off
for /f %%F in (machine.txt) do (
echo %%F
)
pause
this will echo each line in file

and try for /? in cmd to get more infoThis site has good inflammation of the FOR command.
FOR /f means to read lines for just one file.

Otherwise FOR often means the file names found in a directory

The example you gave was FOR without the /f switch, that is what changes the meaning of the for command.This is a kind of metal abuse that MS has imposed on us. Instead of a /f option, they shroud have named a new command. like maybe
ROF. Which is FOR slept backwards and means Read One File. and that would be easy to remember. But nobody can remember to use the /f with FOR command, except the experts on this forum , they can withstand the heavy mental abuse.

Excuse me, I need a Prozac. Quote from: The Hansenator on April 04, 2009, 03:08:17 PM

Can someone explain how to manipulate data read from a file?
there are better tools to do file manipulation than using batch. even VBSCRIPT has a fair amount of FUNCTIONS for that. splitting up lines, replacing text, storing data into arrays, etc that makes things easy for a programmer. If you are learning programming, at least get a proper programming LANGUAGE. (or change your teacher )Perl is specifically designed to be easy to use for manipulating text files, I believe.Quote from: BC_Programmer on April 04, 2009, 07:45:36 PM
Perl is specifically designed to be easy to use for manipulating text files, I believe.
not just Perl. Python, sed, awk , even Ruby and PHPQuote from: The Hansenator on April 04, 2009, 03:08:17 PM
The teacher seems to have a habit of not giving us enough information.

It's a well known teacher's trick, called "hopefully making you think and learn how to discover things". Like the fact that commands have help that you see by TYPING the command, a space, and /? at the prompt.

Try typing FOR /? at the command prompt.
Quote from: Dias de verano on April 05, 2009, 03:54:25 AM
It's a well known teacher's trick, called "hopefully making you think and learn how to discover things". Like the fact that commands have help that you see by typing the command, a space, and /? at the prompt.

Try typing FOR /? at the command prompt.


I'm familiar with that trick but it wasn't until yesterday, after stumbling across it on the internet, that I knew there even was a FOR command. It's hard to look up something when you don't know what to look for.

I did type FOR /?, and maybe I'm a little slow, but I wasn't able to figure it out by looking at the help file.Thank you to both of you, that was just what I needed!

Quote from: devcom on April 04, 2009, 03:15:32 PM
Code: [Select]@echo off
for /f %%F in (machine.txt) do (
echo %%F
)
pause
this will echo each line in file

Quote from: Geek-9pm on April 04, 2009, 03:59:24 PM
FOR /f means to read lines for just one file.

Otherwise FOR often means the file names found in a directory