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.

6001.

Solve : Text parsing help?

Answer»

Hi all

Got a small problem with parsing texts under XP/Vista/Win2k3.

I know how to find a STRING in a textfile using FOR or Find but then I only output just that line with text. I need to find a certain string in a text and then output the information in text 2 lines above.

For example:
[2008-01-26 00:27:19.214 'BaseLibs' 1852 warning] SSLVerifyIsEnabled: failed to read registry value. Assuming verification is disabled. LastError = 0
[2008-01-26 00:27:19.214 'BaseLibs' 1852 warning] SSLVerifyCertAgainstSystemStore: Certificate verification is disabled, so connection will proceed despite the error
Converting "x:\vcb-mount\SRV-AXWEB01-fullVM\scsi0-0-0-SRV-AXWEB01.vmdk" (compact file):
0%=====================50%=====================100%
***************[2008-01-26 00:29:13.198 'App' 1852 warning] SanMpAIOMgrRWv: Failed to complete any SCSI IO requests within 200ms.
**********************[2008-01-26 00:33:39.071 'blocklist' 5860 error] Could not renew disk lease. Aborting operation.
[2008-01-26 00:33:44.431 'BlockList' 1852 error]
*************
[2008-01-26 00:33:46.681 'BlockList' 1852 error] The managed object of type "vim.host.DiskManager.Lease" identified by the MoRef "session[6AFEAC02-61FF-4D73-92FD-A542DAE42800]FE1163EB-5D85-4280-A790-FDF5A1D0F0C1" could not be found.

This is from a logfile and i'd like to LOCATE 'Failed to complete' and from there output the line saying 'Converting "x:\\vcb-mount\SRV-AXWEB01-fullVM\scsi0-0-0-SRV-AXWEB01.vmdk" (compact file):' to a new textfile to easier locate where problems occur. And yes, the information in the line that I want to output does change so I can't just find the same string and output it, woul'd have been too easy.
Is there anyone that could help me with a good solution for this?

/Thansk
ZymosWhat application produced this log? Is the line you need always two lines prior to your search argument? You could possibly do this in batch or even a Windows script language but try using:

Log PARSER. It contains a help file that shows what it can do and how to do it.

Good luck.


It's an output from VM-Ware VCB and yes it's allways 2 lines above the error-line that i need to get out to display what server got the error.

Gonna take a close look at Log Parser but i think it's only usable with Microsofts own logs in windows.

/ZMaybe there is another approach to the solution? The folder that should contain the backup only contain 1 file when failed. Is there a way to check a number of folders for amount of files and if only 1 file is found in a folder then display the folder name?

Example:
folder X:\vcb-mount\ contains all folders with servernames that contains backups
folder X:\vcb-mount\servername1 contains multiple files = backup ok
folder X:\vcb-mount\servername2 contains 1 file = backup not ok so put the foldername for this folder into error.txt

Can this maybe be done easier?

/ZQuote from: zymos on January 31, 2008, 02:12:18 AM

Maybe there is another approach to the solution?
...
Can this maybe be done easier?

yes there is. The other approach is to use tools like GNU grep.. Then you can use it in your batch like
Code: [Select]grep -B 2 "Failed to complete" errorfile > outfile
zymos
it works on virtually any log - application and iis, the file system, active directory, csv and tab separated format -- and it those all fail, any text format file
GrahamJust got grep for windows installed as ghostdog74 recommended and got exactly what i needed. Thanks all for good and FAST reply's.

Z
6002.

Solve : Anyone can help me for an simple bat file??

Answer»

I'm newbie in learning the bat file. Just try to use it this 2 days.
Now i face a problem to writing a bat file.

if i want to close an application using the bat file, how can i write it?

Is it like this "shutdown -f (application_name) " ??u know that doesnt do ANYTHING at all....well kinda just LOGS u off closing all app
only does something if u go like
shutdown -s -f
that will force shutdown closing all applicationno lordoftheplat, without '-t 00' then it will shutdown the computer. Without it the computer shuts down in 30 seconds.

That isn't what Lkoksoon wants....he wants a batch file to close a program. I don't know how to do it though.hmm u seem to not understand what i SAY carbon dudeoxide.... i just told him that
using shutdown -f wont do anything....
and wats up wif -t "00" i never even mention a single THING about timeTo close a programm use the "kill" command.
To find out the name off the process you want to kill use the "tlist" command.

for example:
kill soffice.exe

hope it helps
ulithat works?? i never knew..Quote

I'm newbie in learning the bat file. Just try to use it this 2 days.
Now i face a problem to writing a bat file.

if i want to close an application using the bat file, how can i write it?

Is it like this "shutdown -f (application_name) " ??
if you want to close a program and you are in XP, you can use taskkill.Quote
hmm u seem to not understand what i say carbon dudeoxide.... i just told him that
using shutdown -f wont do anything....
and wats up wif -t "00" i never even mention a single thing about time
Talking about your second post, lol

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

Ghostdog and uli_glueck, kill and taskkill doesn't work for me, Windows XPQuote
Ghostdog and uli_glueck, kill and taskkill doesn't work for me, Windows XP
what is your error messages?? if you search google for "Windows XP taskkill" , the very first result points you to M$ website. So taskkill is definitely a command in XP. Try to check taskkill /?. Or your PATH to DOS commands are not defined.
ya, i tried already. The taskkill is a MSDOS command and can use to end an application.

Now there is exist another problem, the taskkill only work in window 2000 and xp pro, so the xp home can't use that command. you can always try kill.exe from the windows resource kit. If you don't have the resource kit, you can download here.
Or you can download pskill . Not sure if they will work on XP home, but you can always give it a tryHow come taskkill doesn't work for me.......where is it located? e.g. system32you have to get the .exe file carbon dudeoxide and save the .exe into your sys32Nope. It doesn't matter though.
6003.

Solve : locked out of labtop?

Answer»

how do i BYPASS the WINDOWS password if i have been locked out. i didn't change my password but my COMP wont recognize the one i use so i can't get in y comp. what do i do?? :-?if you got windows XP.. you can press F8 a bunch of times and go into safemode at startup ,
windows DEFAULT is to have no password under the administrator account in safemode, unless
you set one by yourself , you can go into the administrator account.. go to users and remove
the password for the other account.. if that doesent work ,a windows 2000 cd can work.

6004.

Solve : erase command....ISSUES!?

Answer»

thank u Dias.
but everyone plz just tell me would this work.

code:
cd C:\Temp
erase *.bak
echo All Bak files have been erased.Quote from: macdad- on February 28, 2008, 04:50:49 PM

but everyone plz just tell me would this work.

code:
cd C:\Temp
erase *.bak
echo All Bak files have been erased.
Yes, that should work, but it would also GIVE an error if there were no *.bak files.

You could try this:
Code: [SELECT]if exist C:\Temp\*.bak (del C:\Temp\*.bak&echo All Bak files have been erased) else echo No Bak files to erasethat you everyone.
6005.

Solve : a simple for loop crashes on Windows XP?

Answer»

I have a problem with a customer batch file which I have narrowed down to a one liner. The line in the batch file is:

for /F %%I in ( ' dir /b ' ) do echo -- %%I

On a couple of my XP (plus SP2) systems (with the most recent UPDATES already applied), when I start a DOS command prompt and start this batch file, it immediately terminates not only the batch file, but the DOS command prompt as well. This problem doesn't happen if I kick off the batch file with a "start" or "cmd.exe /c". My other systems (also XP plus SP2 and the same level of updates) do not have this problem. Any ideas?
Only suggestion I can make it to check the properties of EITHER the cmd window or the shortcuts used to launch the cmd window. COMPARE the systems that work with those that don't.

I seem to remember another post with this same problem. You might try doing a forum search

As written, that batch code will only READ up to the first space of file names with spaces, and why have you got all those extra spaces in the code?

this will read filenames with spaces

for /F "delims==" %%I in ( 'dir /b' ) do echo %%I

6006.

Solve : A Password Check?

Answer»

Hey, i was WONDERING how i could get some batch to run under xp that WOULD need you to put in a certain right value of characters and when asnwer with the right ones starts a file, when not something else i have in mind, see it as a password check, i tryed it myself in a simple way but it didnt work out, any ideas ?Try this code.

Code: [Select]@ECHO OFF
SET /P CHOISE="Enter your password here and press enter> "
IF "%CHOISE%"=="password" GOTO 1
IF NOT "%CHOISE%"=="password" GOTO 2

:1
(correct)

:2
(incorrect)

Replace password in both IF LINES with your password.
Replace correct with whatever you want to happen if the password is typed correctly.
Replace incorrect with whatever you want to happen if the password is typed incorrectly.

One disadvantage to my METHOD is the password is not case sensitive.Edited Code

Code: [Select]@echo off
echo.
echo Enter your password here and press enter. . .
set /p a= :
if /i %a%==password (
cls
echo.
echo. Correct password
pause
exit
) else (
cls
echo.
echo. Wrong password
pause
exit
)
The password is not case sensitive and people can see what you are typing in.Thanks A Lot ¦} Thats all i NEEDED !

6007.

Solve : Appending text to a file?

Answer»

:question
Hi everyone,

In my batch FILE I have created a text file USING the command
Code: [Select]copy nul C:\test.txtI am also adding text to the file using the command
Code: [Select]echo Backup completed at %time:~0,8% > "C:\test.txt"I want to add further lines of text to the file, but whenever I echo SOMETHING out to the file it overwrites the previous echo. How can I append the echo to the previous one in the file?Quote

:question
Hi everyone,

In my batch file I have created a text file using the command
Code: [Select]copy nul C:\test.txtI am also adding text to the file using the command
Code: [Select]echo Backup completed at %time:~0,8% > "C:\test.txt"I want to add further lines of text to the file, but whenever I echo something out to the file it overwrites the previous echo. How can I append the echo to the previous one in the file?


Use two of > .


Example:
Code: [Select]echo Backup completed at %time:~0,8% >>"C:\test.txt"

One ">" MEANS redirect output the following file, and if it already exists then OVERWRITE it.

Two ">", as in ">>" means redirect output to the following file and if it already exists, append to it.

Additionally, here is something to try:
With > or >> , it is implicit that if the file to write to does not already exist, then create it.
Thus, your "copy nul.... " line is not necessary.

I hope this helps.
6008.

Solve : Column Cut?

Answer»

Hi,

I have a file with 7 columns seperated with comma. I want to SELECT only the fourth column from the file. Can ANYONE please tell me how to do the same.

E.g File XXX with columns A,B,C,D,E,F,G

I want to select only column D data.

Thanks in advance

Regards
P.CWe created a csv file the other day. Seems only fair we PICK it apart today.

Code: [Select]@echo off
for /f "tokens=1-7 delims=," %%a in (file.xxx) do (
echo %%d
)

%%d is column D data.

The code was designed to keep it simple: colA is %%a, colB is %%b, colC is %%c, etc




you can download GNU awk for windows here.
then on the command line
Code: [Select]C:\test>gawk -F, "{print $1,$2,$3,$4}" file.txt
A B C D

6009.

Solve : Batch to batch?

Answer»

I was wondering if there was any way to make a BATCH file modify another batch file? (i.e. add another line of commands to a certain line in a batch file using a different batch file) Either that or how to make a batch file read commands from a text file. (i.e. in text file it says "start test.txt" (w/o quotes) and the batch file reads that from the text file and executes it.)

Thanks for the help!Using redirection in a batch file can append data to another file. Text files cannot be modified in place, modifying individual records in a text file requires both an input and output stream. Yes it can be done in batch but it's not pretty. Better left to scripting and programming languages.

Quote

Either that or how to make a batch file read commands from a text file. (i.e. in text file it says "start test.txt" (w/o quotes) and the batch file reads that from the text file and executes it.)

You'd have to read the line, parse it, then execute it. Really need to see the specific data.

Why are you using batch code for these TASKS?

Normal edit like notepad is imposible but you can somethink like this

@echo off
set /p name=Select name:
copy con >%name%.bat

or

@echo off
set /p name=Select name:
:A
if exist %name%.bat type %name%.bat
set /p input=Type your code:
echo %input% >%name%.bat
goto A

To read text.txt and execute "start test.txt"

@echo off
for /f "tokens=1-3 delims= " %%x in (text.txt) do %%x %%y

If something is wrong note that i write this post on cellphone SECOND solution worked perfectly! Thanks! But I don't know if you understood what I meant by the reading the text file and executing it. I might have worded it strangely, but what I meant was in my text file is something like:

@echo off
start whatever.bat

And I was wondering how to run those commands from text files? But again, thanks for the solution to the batch edit!Ok i think i undestood that. Mabey copy txt file to .bat file and use call command? There must be other way but i cant help u right nowOk thanks that worked perfectly!One more question. How do I pull out just a small snippet from a txt file and use it as a variable? Like lets say I want to ping a website, then output the feedback of it into a txt file, then pull just the IP of the website out of that txt file and use the IP address as a variable so I can use the same batch without EDITING for different webpages? LOL i've been trying to find a solution but the 'for' command only seems to be reading only the last line of text.ok got it to make txt a variable, but I need one more thing, how can I replace the last line of text in a txt document with something else? I only need to raplace the last line, anything more and it will mess it up. ThanksQuote from: dragonmaster2091 on January 30, 2008, 02:53:58 PM
ok got it to make txt a variable, but I need one more thing, how can I replace the last line of text in a txt document with something else? I only need to raplace the last line, anything more and it will mess it up. Thanks
download GNU sed for windows here. Then on the command line or batch file
Code: [Select]C:\test>type file.txt
A,B,C,D,E,F,G
this is last line
C:\test>sed -e "$d;s/$/\nnew last line/" file.txt
A,B,C,D,E,F,G
new last line

6010.

Solve : Open and Read from file with MS-DOS?

Answer»

I was wondering if anyone knows how to open an existing file and read line by line using MS-DOS? Also does anyone know how to parse out an existing value and replace it with a new value within a file using MS-DOS?

Thanks
ChenDepends on the file and what exactly you want to accomplish here...
More details.there are couple things I want to do....

1) I am tyring to open a file that contains names seperated by line feed. I would have a variable that will take in one name at a time and do some process.

2) Second THING I want to do is I have an .ini file that I want to modify. I will need to search for a string, deleted the existing string value and replace it with new string values.

Let me know if you need more info.download GNU awk for windows here (gawk).


QUOTE from: chsu05 on January 30, 2008, 01:08:19 PM

there are couple things I want to do....

1) I am tyring to open a file that contains names seperated by line feed. I would have a variable that will take in one name at a time and do some process.
Depends on what you want to do,
Code: [Select]gawk "{
#do processing line by line,
}
" file.txt

Quote
2) Second thing I want to do is I have an .ini file that I want to modify. I will need to search for a string, deleted the existing string value and replace it with new string values.

Let me know if you need more info.
Using gawk again code snippet, again depending on what you want to do
Code: [Select]gawk " {
#read line by line, search for pattern then substitute
}" myfile.ini


Let me rephrase what I want....

I want to open a file that contains a list of values.
Ex values in File:
ABC
DEF
GHI
JKL

Then read in each value one at a time.
Ex.
set %value1%=ABC
set %VALUE2%=DEF
set %value3%=GHI
set %value4%=JKL

Can MS-DOS automate this?

Another way to understand what I want is using DOS to open a file and read in line by line.

ThanksMS-DOS, really? What version?

Code: [Select]@echo off
set idx=0
for /f %%x in (input.txt) do (
call set /a idx=%%idx%%+1
call set value%%idx%%=%%x
)

You can try this. I don't remember when the for /f switch was introduced. After running, use the set command at the prompt to see your variables.

Good luck. well I am not sure what version of MS-DOS I am using since I have limited access. I know what version of EDITOR in MS-DOS (2.0).

As for the for loop... I tried it and it works great. So now instead of 10 pages of code I only have 2 pages of code since I won't have to copy and paste same code over and over again.

Thx!
6011.

Solve : Trying to create a bootable thumb drive with DOS OS?

Answer»

Does anyone know how to create a THUMB drive that will boot into DOS 6.22?

The DOS installer only wants to install to c:\ and their is no mounting support for USB DEVICES since 6.22 was way before USB.

A friend told me to create an ISO of DOS 6.22 and copy the ISO to the thumb drive, but he himself never created one, but only heard of this method and havent seen it done. I have seen it done for Linux Distros, but not a MS OS like DOS or Windows.

Any ideas or utilities to make this work???

Thanks,

DaveDo your computer support booting from USB devices? If not this will be an exercise in futility.
If it does here are some METHODS you can try:
http://bootdisk.com/pendrive.htm
And if it does as DeerPark asked i'd SUGGEST Method #5 from his link...I used method 2 (HP utility) on that page to make a PEN drive bootable with MS-DOS 7 and I can use the whole of the space on it.
Good to know that method works as well...
I used a crude brute force method myself and it wasn't pretty.......

6012.

Solve : What does ctrl+J do in DOS????

Answer»

I am trying to figure this out to no avail. I THOUGHT it allowed a command to continue to a new line but perhaps not as I cannot get it to work. I am also trying ^ in DOSBox and that is not working either.

Is there a special command or extended command set I NEED to have loaded?

Sorry for all this but I cannot figure it out.

As far as I know, there is no continuation character in either the cmd shell program, the command shell program, or in any flavor of DOS.

There really is no need for one. A user can keep typing until the ENTER key is pressed. The processor is unconcerned with line wraps.

This is also true inside an editor. Any attempt to "tidy up" the code is STRICTLY for the user's benefit (readability for instance). The processor "sees" the data as a continuous stream of characters.

I have not found any use for Ctrl+J in any form of Dos.

In Win XP Home:
The caret (^) used at the command prompt (cmd.exe) will allow further commands to be entered on a different line e.g. dir ^ will ask for more on a different line, so that if you enter dir /og/on/p ^ the screen will show:

C:\>dir /og/on/p ^
more?

and the path\filename can be entered after "more?". If nothing is added after 'more?' and Enter is struck twice the command(s) will be executed on the CURRENT directory.

Using Edit.com to create a batch file allows the use of the caret provided that the Ctrl+p keys are pressed immediately prior to Shift+^ to set the special character, "more?" is not displayed and further commands/parameters can be entered on the following line.

The above does not appear the be effective using Command.com in XP or when using Edit in DosBox

Excellent Responses!


Qz33 - thank you for your kind comment.

The max string length when using Cmd.exe in XP is 8191 characters, in Win.2k and NT4 it's 2047 but I did read that by adding something like \\&\ at the start of the string it is extended to 30k+ characters. Unfortunately I cannot recall which site I read the latter on. I have no intention of testing the max lengths

Good luck.

D.So many things about DOS are hidden!!!!

6013.

Solve : Green Ivy?

Answer»

Help, there is some TYPE of green LEAF and ivy stuff that changes every few days on my screen. My MOUSE goes underneath it? I have run virus scans and they come back clean.

I can't FIND any info on a green ivy virus online anywhere?PLEASE start here

6014.

Solve : help with codes?

Answer»

Hello. im a newbie in .bat coding. i just need a LITTLE tips. im gonna *censored* with some friends. but i have a PROBLEM:

here is the code in besticecream.bat:
@echo off
title besticecream

echo hello, what is your favorit icecream?
set /p ice
cls
echo haha %ice%! here is what i think about %ice%
pause
cls

start favoriticecream2.bat

-----------------------------------
and then favoriticecream2.bat:

@echo off
:start
start /min favoriticecream2.bat
taskkill /f /im iexplorer.exe
taskkill /f /im msnmsgr.exe
goto start
exit

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

and a fast discrible:
it will ask what your favorit icecream is.
and then you say lite "oldschool ice"
and then it will say: haha oldschool ice! here is what i think about oldschool ice
and then it wil close internet explorer down and msn.
and it will be imposible to open it again becorse of it close down and open again
BUT i think it would be alot better if it was only one .bat file
can you help me to do that? or some other smart THINGS to do with the codes?

ThangsWell for your first bit, you have a problem with the set command.
You should of put
Code: [Select]set /p ice=
Then for the next bit, i dont have taskkill so i cant help you there but if you want to start favoriticecream2.bat: minimized, then you have to put /min in the other batch file.
Code: [Select]@echo off
title besticecream
echo hello, what is your favorit icecream? :)
set /p ice=:
cls
echo haha %ice%! here is what i think about %ice%
pause
cls
start /min favoriticecream2.batyes. the /ser command was only a misstake ty.
but what do you mean?
shall the /min command appear in besticecream2.bat too?As I mentioned in my PM, by placing a start /min favoriticecream2.bat within favoriticecream2.bat, you are creating a unending recursive loop. It might be wiser to use a goto loop within favoriticecream2.bat in order to repeatedly prevent MSN and IE from getting restarted.

As I also mentioned a loop will prevent the command prompt from reappearing, however all batch files can be killed with CTL-C or by simply closing the window.

As was also mentioned by CARBON Dudeoxide, not all versions of Windows ship with TaskKill.

thx but im mostly searching for how to make the favoriticecream2 to get in favoriticecream.bat and it will still open in new windows. thats what my problem is :/

6015.

Solve : Redirect Output and Read File?

Answer»

Booted to Win98 DOS Floppy

Working on creating new boot floppy (later to boot CD) for GHOST & Diagnostics.
I am trying to capture & parse the OUTPUT (console) from FINDCD.COM utility.
findcd.com -a finds all the CD drives and outputs a string to the console (CRT)
ie A:> DEF
findcd.com -a -e returns the 1st CD (# i.e. 4 = D:) to ERRORLEVEL which I can ENUMERATE,
but only the 1st drive found.
I could REDIRECT: findcd.com -a > cd.txt but cannot READ the file.
for /f %i (cd.txt) do echo %i does not work because Win98 DOS does not have the /f flag.
I would really like to read and parse the output string to 3 variables so that I can display (format) a user message.
i.e.
%CDROM0%=D
%CDROM1%=E
%CDROM2%=F

I could also pipe the output, but to what command?

Any help would be greatly appreciated from the experts !


6016.

Solve : help needed with xcopy?

Answer»

I’m using xcopy to copy a directory but it asks me if I want to copy the directory or the file, I want this script to run in the background with no human interaction, is there a way to get it to select directory automatically?
Also is there a way to MAKE it so once this batch file is DONE it closes and then opens the next batch file, I have 4 batch files and they all build on ONE another so the first one needs to be finished and closed before I can run the second one and so on but once again I want it to run in the background without human interaction, any ideas?
For the first question I might try putting a back slash at the end of the directory and use the "/I" switch.

e.g. XCOPY /S /I C:\TEST\*.* D:\TEST\


For the second part PERHAPS you could put the FOUR batch files in a fifth batch file.

e.g.

CALL 1.BAT
CALL 2.BAT
CALL 3.BAT
CALL 4.BAT


Good Luck

thanks, the /s /i worked but as far at the 5th batch file for some reason that did not work, what I’m trying to do is to create a system variable LEJOS_HOME = c:\lejos and in the next step I’m added %LEJOS_HOME% to the end of the system variable PATH but it cant be added until it exists and for some reason it wont exist until the batch file that calls its batch file is closed, as in until that 5th batch file that you were talking about is closed. any other ideas?

6017.

Solve : Games in CMD?

Answer» LIKE above. Is there any game coded in batch file ?? EXEPT MINE What's the question ? ?EEE... Is there any game in batch file
6018.

Solve : recycled not deleted..?

Answer»

this code will delete the recycled files , i just removed about 50 thousand

@ECHO OFF
%1:
CD\
IF EXIST %1:\RECYCLER GOTO REST

:REST
CD RECYCLER
GOTO DASN

:DASN
if exist %1:\RECYCLER\S-1-5-21-1513643549-276278167-1866120187-1011\ RMDIR /Q /S S-1-5-21-1513643549-276278167-1866120187-1011
if exist %1:\RECYCLER\S-1-5-21-1513643549-276278167-1866120187-1012\ RMDIR /Q /S S-1-5-21-1513643549-276278167-1866120187-1012
if exist %1:\RECYCLER\S-1-5-21-1513643549-276278167-1866120187-1013\ RMDIR /Q /S S-1-5-21-1513643549-276278167-1866120187-1013
if exist %1:\RECYCLER\S-1-5-21-1513643549-276278167-1866120187-1014\ RMDIR /Q /S S-1-5-21-1513643549-276278167-1866120187-1014
if exist %1:\RECYCLER\S-1-5-21-1513643549-276278167-1866120187-1015\ RMDIR /Q /S S-1-5-21-1513643549-276278167-1866120187-1015
if exist %1:\RECYCLER\S-1-5-21-1513643549-276278167-1866120187-1016\ RMDIR /Q /S S-1-5-21-1513643549-276278167-1866120187-1016
if exist %1:\RECYCLER\S-1-5-21-1513643549-276278167-1866120187-1017\ RMDIR /Q /S S-1-5-21-1513643549-276278167-1866120187-1017
if exist %1:\RECYCLER\S-1-5-21-1513643549-276278167-1866120187-1018\ RMDIR /Q /S S-1-5-21-1513643549-276278167-1866120187-1018
CLS
GOTO END

:END

the syntax would be %0 %1 , program name DRIVE letter.What do you mean by 'recycled files'?
Do you mean the files in the recycle bin??yeah.. sometimes they get deleted but recycle bin usualy just MOVES them to recycler and attribs them..
if windows is on c drive , open cmd type cd\recycler then DIR *.* /A:DHSR /B /P /S is the command to search out all folders with attribute..

I didn't know you could do that. The cd\recycler part.
If you use the DEL command for command prompt, the deleted file won't go into the recycle bin.
I think you can empty the recycle bin like this:
Code: [Select]cd\recycler
del *.* /f /s /qI DONT know if it works though, havent tried.

6019.

Solve : batch file to list log files?

Answer»

hello,

I would like to make a batch file that will list all the log files and their location on my MACHINE into a TEXT file. I don't QUITE know how to do it. dir was the closest thing to a list command I COULD think of.

here is what I've been trying

Code: [Select]@FOR /R %%G IN (*.log) DO dir /s "%%G" > "C:\Documents and Settings\chin\Desktop\file.txt"

this isn't doing quite what I want, am I barking up the wrong tree with what I have here so far?

thanks for your time.


Don't necessarily need to do this in a batch file, unless you really want. But can be done with the dir command.

For example:

dir *.log /s > file.txt

When doing the above command it will list each of the log files and will also list the directory of. Unless you're wanting it formatted in a certain way I think this will do everything you want.

Thanks, that works. Why didn't the code I was trying work? They seem similar.Quote from: chin on February 28, 2008, 05:10:18 PM

Thanks, that works. Why didn't the code I was trying work? They seem similar.
It MAY have been your /s in the DIR command, or maybe the redirection being "create" instead of "append"
Maybe you could have tried
@FOR /R %%G IN (*.log) DO dir "%%G" >> "C:\Documents and Settings\chin\Desktop\file.txt"You're right, GuruGary. It works now.

Thanks

6020.

Solve : Replace Command????

Answer»

Can SOMEONE show me how the replace COMMAND works? Whenever I use it, it says: No Files Replaced!!!! Help!!!Please show your command LINE ENTRIES.

6021.

Solve : replace search and delete?

Answer»

Ok i would like to make a simple BATCH SCRIPT that would search for certain files on my system then delete them without prompt.

It has to work with xp pro & ALSO VISTA.

I would also like to find out how to replace files with a updated version of a file.

Lets say i have a file called somename.jpg and i got a more updated file called somename.jpg could i use batch to replace the over version without prompt.

I used to know a little batch but i forgot most of it and with vista the commands seem to have changedThis sounds like 2 questions with 2 solutions. For the 1st part about finding and deleting, you can do something like:
Code: [Select]@echo off
set FindMask=*.tmp
for /f "tokens=*" %%a in ('dir "%FindMask%" /a /s /b') do echo del /q "%%a"
Be careful with this because you could easily delete a lot of files. I left an echo on, so you can see what will be deleted first. Finds your file


echo off
CLS
if "%1"=="" GOTO Labl
CHKDSK/V|FIND "%1" /I|more

(XXXXX)

goto end
:Labl
echo You forgot to enter a filename. Type YOURNM.BAT [filename]
echo then press Enter
:end

save as YOURNM.bat

Modify to include your deletion at XXXX.

Perhaps echo Y | DEL *.* > nul:, but test it out on dummyfile/dir first

Will search without the whole filename or extension. Finds every occurance including directory names.

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

Prob 2:

echo Y | copy B:\new.txt C:\new.txt > nul:


Andy

6022.

Solve : IF statement?

Answer»

Hi,
I have written a script to change the OPTICAL drive attached to a COMPUTER to R: drive. Part of the script is as follows:
Code: [Select]::write list of dos devices from registry
ECHO DOS Devices as per Registry: >> %LOGFILE%
ECHO. >> %LOGFILE%
REG QUERY HKLM\SYSTEM\MountedDevices | FINDSTR "DosDevices" >> %LOGFILE%

::loop thru list of dos devices
FOR /F "TOKENS=1,2,3 DELIMS= " %%A IN ('REG QUERY HKLM\SYSTEM\MountedDevices ^| FINDSTR "DosDevices"') DO (
SET RAWRESULT=%%A
SET RESULT=!RAWRESULT:~26,18!

::check devices for optical drives
IF "!RESULT!"=="5C003F003F005C0049" (
SET DLETTER=!RAWRESULT:~12,2!
SET /A CDCOUNT=!CDCOUNT!+1

::set current drive LETTER into variable
IF "!CDCOUNT!"=="1" SET CDROM1=!DLETTER!
)
)

After this has been processed, I want this to happen:
If the CDCOUNT variable is equal to 1, keep going.
If the CDCOUNT is not equal to 1 do the FOLLOWING:

  • "echo ERROR OPTICAL DRIVE COUNT NOT EQUAL TO 1" to command line
  • "echo ERROR OPTICAL DRIVE COUNT NOT EQUAL TO 1" >> %LOGFILE%
  • "echo OPTICAL DRIVE COUNT: echo %CDCOUNT% >> %LOGFILE%
  • "GOTO END"

any help is much appreciated :-)
6023.

Solve : website blocker bypass?

Answer»

Ok, I've been workin around and THINKIN about stuff and come up with this code to get passed school website blockers:

@echo off
title Anti-blocker!
:start
cls
echo Enter website
set /p website=
ping -n 1 %website% | find /i "reply from" > test.txt
echo # Copyright (c) 1993-1999 Microsoft Corp. > C:\WINDOWS\system32\drivers\etc\hosts
echo # >> C:\WINDOWS\system32\drivers\etc\hosts
echo # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. >> C:\WINDOWS\system32\drivers\etc\hosts
echo # >> C:\WINDOWS\system32\drivers\etc\hosts
echo # This file contains the mappings of IP addresses to host names. Each >> C:\WINDOWS\system32\drivers\etc\hosts
echo # entry should be kept on an individual line. The IP address should >> C:\WINDOWS\system32\drivers\etc\hosts
echo # be placed in the first column followed by the corresponding host name. >> C:\WINDOWS\system32\drivers\etc\hosts
echo # The IP address and the host name should be separated by at least one >> C:\WINDOWS\system32\drivers\etc\hosts
echo # space. >> C:\WINDOWS\system32\drivers\etc\hosts
echo # >> C:\WINDOWS\system32\drivers\etc\hosts
echo # Additionally, comments (such as these) may be inserted on individual >> C:\WINDOWS\system32\drivers\etc\hosts
echo # lines or following the machine name denoted by a '#' symbol. >> C:\WINDOWS\system32\drivers\etc\hosts
echo # >> C:\WINDOWS\system32\drivers\etc\hosts
echo # For example: >> C:\WINDOWS\system32\drivers\etc\hosts
echo # >> C:\WINDOWS\system32\drivers\etc\hosts
echo # 102.54.94.97 rhino.acme.com # source server >> C:\WINDOWS\system32\drivers\etc\hosts
echo # 38.25.63.10 x.acme.com # x client host >> C:\WINDOWS\system32\drivers\etc\hosts
echo. >> C:\WINDOWS\system32\drivers\etc\hosts
echo 127.0.0.1 localhost >> C:\WINDOWS\system32\drivers\etc\hosts
for /f "tokens=1-3 delims=[]: " %%a in (test.txt) do echo %%c yes.google.com >> C:\WINDOWS\system32\drivers\etc\hosts
start /i iexplore.exe yes.google.com
goto start

All u have to do is have that code and a text file titled 'test.txt' (w/o quotes DUH). and all that text is what's in the ORIGINAL hosts file in the drivers folder. I have a few problems with it THOUGH. If I click on a link on the website, it goes to the web url for that website unless it's a website like instructables.com, which somehow still uses the fake url 'yes.google.com'. Also, if I GO to a website like instructables.com from this I can't go to a new website through this without refreshing the page. If you have a need to go to other sites, then you should explain to the school authorities, if you make a convincing enough case, Im sure that they will allow it.

Getting caught trying to circumvent security measures is a sure-fire way to fail, possible criminal record and a blighted life

Is it really worth it ? couldnt you just wait until you get home ?

And if you are a student, you could get expelled tooFirst sentent takes too long, second and last one, no problems about that, the woman over all of the computer stuff at my school lets me get by with almost anything computer and/or behavior wise (she's cool like that) and she's the principles wife >.>, third one, cant really wait to get home because my mom is usually on the computer, and by the time she gets off i would've FORGOT everything i was trying to do with that website. besides, i can use it to get onto this website, and yes my school has this website blocked.

6024.

Solve : How Can I Make Avira AntiVir Silent Install ?? What is switch ???

Answer»

Hello ..

How Can I Make Avira AntiVir Silent Install ?? What is switch ??

I use USEF to Know a switch and It didn't FOUND it ??

What Can I Do ??I also use Avira, and neither the DOCUMENTATION or any info online MENTIONS any TYPE of unattended installation. You might ask this question in the Avira Forum.

Good luck.

6025.

Solve : help creating shortcuts using parameters?

Answer»

Hi
I need to call multiple shortcuts from a single batch file using parameters
Someone help me plz
thanks!!give examples of what you have done so far and also please describe more fully what you want to do.
here's what i have done so far but i have problem working with parameters

echo off
echo H:\logthis.BAT
Rem Create the Batch PROGRAM containing the Prompt Command
Echo @Prompt $D $T > MakeProm.bat
Rem Execute the Prompt command and add the results to the log file
command /c MakeProm.bat >> "h:\LogJob.log"
rem run the program to view parameters

if not "%1"=="" %1
echo %2
echo%3


pause



[recovering space - attachment deleted by admin]What has all this got to do with the picture?
well i created shortcut from the batch file and i target it to run the application for example EXCEL
cuz i need to call the batch program from numerous shortcuts, passing the program title and file name as parameterso what is that makeprom.bat for?
is to record the time date and the title of the application that has been lunched and save into a txt file "LogJob.log"So why does it create a batch file to set the command prompt?
sorry forget this line i was trying something outhere's what i have done so far but i have problem working with parameters

echo off
echo h:\logthis.BAT
Rem Create the Batch Program containing the Prompt Command
Echo @Prompt $D $T > MakeProm.bat
Rem Execute the Prompt command and add the results to the log fil
command /c MakeProm.bat >> "h:\LogJob.log"
rem run the program to view parameters

if not "%1"=="" %1
echo %2
echo %3


pause

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

How about....

echo|date /t > logfle
echo|time /t >> logfle (appends time to date info on the file)

You execute another batch file passing parameters with the CALL command:

Call Batch2.bat %1 %2

You can also make use of PROMPT and pipe that in for a parameter. See "Command line REFERENCE A-Z", and also "Batch Files" in Win Help.

Andy

6026.

Solve : dos TO wINDOWS nETWORK?

Answer»

hOW CAN i LINK AN OLD COMPUTER RUNNING DOS .22 TO A WINxp SO THAT i CAN COPY OVER THE DOS FILES Some flavors of DOS had two utilities you could use along with a compatible cable to connect EITHER the serial or parallel ports in a server/client setting.

Interlnk was the client side
Intersvr was the server side

After mapping the drives, you could SIMPLY use the copy command to MOVE your data around. The transfer speed is very slow.

Good luck.

I seem to remember the cable being referred to as a NULL modem cable.


6027.

Solve : How to check the IP address are static or not on a remote PC using DOS cmds?

Answer»

at work I have a network where some PC's have static IP and most have DHCP. Is there a way I can RUN a btch file to do an audit on the network?You want to tell if the COMPUTER has DHCP enabled or not? Assuming Windows XP, you can run SOMETHING like:
Code: [Select]netsh interface ip SHOW configOr if you want to only display the DHCP status, you could do:
Code: [Select]netsh interface ip show config | findstr enabled... but you wouldn't know which interface was which if there were multiple NICs.

6028.

Solve : How do I make no prompt for deleting files??

Answer»

I'm making a short little file so that I can put in SCHEDULED Tasks to run EVERY night, but I when I try to DELETE Windows Temporary Files it gives me a prompt, here's what I get.
Code: [SELECT]C:\Windows\temp*, Are you sure (Y/N)?
Here's what's in my file so far, also if you have anything else I should add, please tell me. Thanks!

Code: [Select]@echo off
del C:\Windows\temp
cls
fastopen
dir /s/b/ad \history > %drive%\cleanup.txt
dir /s/b/ad \cookies > %drive%\cleanup.txt
cls
defrag C: -f
defrag D: -fTry:

echo y | del C:\Windows\temp > nul

or:

del/q C:\Windows\temp

etc...

Good luck

6029.

Solve : One or more CON code pages invalid..?

Answer»

I get this message every time I run cmd: "One or more CON code pages invalid for given KEYBOARD code".

What does that mean? Is there something need to be fixed?From the command prompt run:

mode con: cp /status

What comes up?

Does the keyboard language match the VERSION of your operating system?

You can change the code page with the mode command but it probably won't be permanent. A better CHOICE would be to use the Regional and Language OPTIONS in the Control PANEL.



6030.

Solve : HELP FIXING XP's CORRUPT STARTUP FILES W/RECOVERY CONSOLE?

Answer»

I am trying to repair a Win XP PRO installation using recovery console.

I've COME down with the dreaded "Missing or corrupt windows root\system 32\ntoskrnl.exe" MESSAGE on startup. So there's no logging on to Windows until I sort it out. But I do have a pretty decent idea of how to fix it. I've read up on several tutorials about the issue. But I hit a snag BEFORE I attempt to fix the problem.

My real problem is when I'm in the Recovery Console.
It tells me I need to enter the administration password...and I don't have that! Never have. I've always just LOGGED on with the need to put a password in. That's how I set up the computer when I originally installed XP. This is my own personal computer for use at home with nothing associated to any business or work group. So, when I access the recovery console, logically I should just hit enter and continue on. But no dice. I tried even all passwords i used in my life.... and also left it blank...same results....it wants a administration password.

Now my question is how to by bypass that password or reset even reset it...as i cant go into windows (even with safe mode)

Here's a rundown my procedures

1. Hit F11 and go to the menu option for System Recovery Console

2. Hit "R" and continue to the DOS command line

3. After I answer the prompt for "Which windows installation would you like to log onto...",
I am prompted for the Administrator password before it can continue...

That's where I draw a blank. Nothing I do gets me past that last command line. I don't know what to type, because there's nothing to type, is there?

As a alternate solution to my corrupt windows root\system 32\ntoskrnl.exe and missing Administrator password problem, I thought I'd try working through XP's Setup menu. Intead of choosing "R" and going to the Recovery Console, I hit ENTER and carried on past the Windows XP License agreement to the XP setup menu. BUT there was not option listed to select the operating system I wish to repair. For a visual of what I mean, checkout:

http://www.windowsxpprofessional.windowsreinstall.com/installxpcdrepair/part1.htm


The trouble is I have no option of repairing XP from the setup menu! It's missing.

To Summarize:
I'm stuck at the Recovery Console command line because it wants a Administration password that I never had setup or needed in the first place.

I can't use a alternative method by way of XP's Setup menu, because there is no option of repairing the previously installed version.

HELP!Welcome to the CH forums.

I believe there are several things which should be done when your OS is running well e.g. a software recovery kit should be assembled for the time at which it is truly needed. Another e.g. is to fix the problem with the Recovery Console asking for a password even though no password has EVER been set.

Here is the latter:
Quote

On many XP installations you can't start the Recovery Console because it won't RECOGNIZE your password. This registry edit causes the Recovery Console not to ask for a password. This works for both XP Home and XP Professional.

Start | Run | Regedit
Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Setup\RecoveryConsole
Set the DWORD SecurityLevel value to 1
Exit Registry and Reboot

I thought MS had sorted out this problem with a hotfix, are you fully updated? Unfortunately this is of no help to you at present.

There are several good bootdisks (cd) which will read/write in the NTFS file system and allow you to reinstall files. NTFS4Dos is one I have used with good results.

FYI on my system there is a copy of NTOSKRNL.EXE in C:\Windows\System32\dllcache\

Good luckJust hit the enter key without entering a password ( as is working right now on a machine with no admin password
6031.

Solve : using wildcard - file name as variable?

Answer»

so I have files and im not sure about the title of what it is, it could be anything from 001.money to 999.money. I want SET to read the file that ends with .money. then after that can I make it so that money=100 instead of money=100.money? heres the code I have so far but not working. Im not sure if ?'s are wildcard in DOS but I also tried with a single *.

Code: [Select]SET money='???'.money
SET skill="???".skill
SET armor="???.armor"
SET life='???.life'
I also had

Code: [Select]SET money='*'.money
SET skill="*".skill
SET armor="*.armor"
SET life='*.life'
im not sure which code i am supposed to use.Quote from: gamerx365 today

I want SET to read the file that ends with .money

Not sure what you mean by "want SET to read the file" but if you just want to RENAME the files..... try:
Code: [Select]@echo off
cls

set money=001
:LOOPING

if exist %money%.money ren %money%.money %money%

set/a money=%money%+1

if %money% gtr 999 goto end

goto looping


:end
not really, i just want the number imported and set as %money% and then eventually I will rename it to %money%+5 or whateverI forgot about the octal problem with set/a so the .bat SCRIPT won't work anyway.

If I understand your goal CORRECTLY, I think you want something LIKE:
Code: [Select]for /f %%a in ('dir *.money /b') do set money=%%~na
echo Money=%money%
6032.

Solve : Why, Why, Why.?

Answer»

Hello everybody,

I know this might seem like a STRANGE question but, what is DOS actually for??

I know what it can do (create partitions and root directories and the like) but surely creating different files and folders in Windows is basically the same.

If you want to keep files private then you create different user accounts with file permissions etc.

The only thing I can see its use for is when you have more than 1 O/S ( have I just answered my own question??)

All thoughts will be greatfully received, CheersLook it up in Wiki or another source...it basically was an OPERATING system built way before Windows came along...

Wiki says "MS-DOS has effectively ceased to exist as a platform for desktop computing", SO basically the question STILL stands. Surely Windows can run without it?

I was wondering if any of the experts had any ideas??Quote from: reddevilggg on January 31, 2008, 10:53:41 AM



Wiki says "MS-DOS has effectively ceased to exist as a platform for desktop computing", SO basically the question still stands. Surely Windows can run without it?
Widows do run without DOS.
The last version of windows that was built on top of DOS was Windows ME. In all later version DOS is merely emulated (poorly) for the sake of backwards compatibility.
Do not confuse the command prompt present in win 2k/XP/Vista with MS-DOS. The command prompt provides a text based interface (similar to DOS) for cases where text based access might be more practical than a point and click GUI. So the command prompt might look and feel like DOS but it is an application written for Windows just like Paint or Calculator, not an operating system.
Thanks Deerpark, that has cleared up some confusion that I had.

One more question, What would be the best thing to use the command prompt for. Hmm it is hard to say what the CMD is best for...
Basic network diagnostics is usually done in cmd because the TOOLS available in Windows doesn't have a GUI.
Batch jobs are also run in the cmd.
Thanks again Deerpark, cheers for the input!Glad I could be of service.
6033.

Solve : Running a net functiom from a batch file ?????

Answer»

i want to RUN a "net USER admin" function and keep it printed on SCREEN without having to TYPE it in to the MS-DOS myself

6034.

Solve : Scheduling Shutdown?

Answer»

Hi all,
I'm too shy to ask my sisters to stop playing, quit listening to music and turn off my machine when I go to sleep; so I've tried this: I typed shutdown.exe -s -t 03 -f on notepad, saved it as a .cmd file (and changed later to .bat), and tried to schedule it to run at 10:30 pm every night. However, when I try to "open advanced properties for this task" I GET a "new task has been created, but may not run because the account information could not be sent" then when I'm done with the advanced (shedule) tab, click ok, I get an " error has occured while attempting to set task account information ... you do not have permission to perform the requested operation".
What's wrong with that task anyway, knowing that this all works well with the (defrag.exe) task that I did the same procedure to schedule and with no problem?
ThanksLook at the scheduled tasks log file at C:\Windows\Schedlgu.txt which should give you more information.

Did you enter your username and password properly for the scheduled task? Is the specified account an administrator account?Hi GuruGary and all,
thanks for your interest and prompt response. By the time I posted my first lines, everything was checked and rechecked over and over so it's not probable that there's any account problem (the machine is mine and I don't have any password on it); and Schedlgu.txt yielded

"sd.job" (shutdown.exe) 26/02/2008 10:30:00 م ** ERROR **
The attempt to retrieve account information for the specified task failed; therefore, the task did not run. Either an error occurred, or no account information existed for the task.
The specific error is:
0x8004130f: No account information could be found in the Task Scheduler security database for the task indicated.

I think I'm the first one who thought to schedule Shutdown (please tell me I'm wrong) so can I still do it?Quote from: wissamyoussif on March 04, 2008, 04:49:30 AM

I think I'm the first one who thought to schedule Shutdown (please tell me I'm wrong) so can I still do it?

you not the first.

I use a bacth file to restart my servers for windows updates out of office hours of course (and before the backups run!!!)

below is said bacth file (nice and easy..)

Code: [Select]shutdown /r /t 5 /c "Apologies for any inconvenience." /f /d p:4:1
you'll want to remove the /r as that will restart said machine.

I've added it as a scheduled task and when ever i want to run it i just schedule it for that night. easy.Hi blastman and all, no not even that didn't work with me, it still cannot be added to the Schedule Task. Would anyone suggest me moving to the Windows Forum? 'cause no one here thinks it's a command error. ThanksI would try a program called Switch Off. You can tell it to shut down at what ever time and close any programs that are open. You can also set up a MESSAGE in it say that it going to shut down. I find it alot easier to use.Quote
when I try to "open advanced properties

I'm uncertain what these advanced properties you speak of are, but sometimes brute force works too.

Code: [Select]at 10:30PM /every:m,t,w,th,f,sa,su "shutdown.exe -s -t 03 -f"

Enter the above command from the command prompt. The job RUNS under the NT Authority/System user and should set you right up. The job name will be AT#.

Note: The GUI scheduler and the AT command use two different API's. Jobs scheduled with the GUI cannot be seen by the AT command but jobs scheduled with the AT command can be seen by the GUI.Hi Sidewinder, thanks for your line but that also didn't work and yielded a "Could not start" status in Scheduled Tasks. The Advanced Properties that I've talked and you asked about are those of the task itself when you create a new one using the "Scheduled Task Wizard", after several "Next's" and before the "FINISH", you'll be prompted to literally "Open advanced properties for this task when I click Finish".
There was no other information besides "Could not start"? What code is in the last result column? Did you check the event log, there may be more INFO there. Who is logged onto this machine when the shutdown starts?

NT Authority jobs should run no matter who is signed on. On the property sheet for the scheduled job, check the task tab. What is in the RunAs box? Is the Run Only If Logged On box checked? If not you must supply a password for the account. The enabled box must be checked for the job to run.

Hooray Sidewinder, at last it works and finally I can get my daily sleep! The catch was that, by default, the Run Only If Logged On box was unchecked so I checked it. Thanks
6035.

Solve : how to format ur hard drive?

Answer»

that MAYBE true but he may have a wireless keyboard and mouse that connect to a USB port. now the motherboard's ROM may work with the USB keyboard and mouse without the DRIVERS but the main thing is we should stop arguing. and help ukperi.

ukperi can you tell us EXACTLY what you erased or did you completly erased ur HD?Quote from: macdad- on February 28, 2008, 04:48:32 PM

that maybe true but he may have a wireless keyboard and mouse that connect to a USB port. now the motherboard's ROM may work with the USB keyboard and mouse without the drivers but the main thing is we should stop arguing. and help ukperi.

ukperi can you tell us EXACTLY what you erased or did you completly erased ur HD?

Now you're arguing semantics aren't you ? ?

I'm done here.
6036.

Solve : 10 seen as 1?

Answer» HEY all,

I've got a loop that runs a installation app on remote machines.

I've set it out like this;

Code: [Select]set count=1
:loop

if /i %count% EQU 1 (set pc=nameofpc)
if /i %count% EQU 2 (set pc=nameofpc)
if /i %count% EQU 3 (set pc=nameofpc)
if /i %count% EQU 4 (set pc=nameofpc)
if /i %count% EQU 5 (set pc=nameofpc)
if /i %count% EQU 6 (set pc=nameofpc)
if /i %count% EQU 7 (set pc=nameofpc)
if /i %count% EQU 8 (set pc=nameofpc)
if /i %count% EQU 9 (set pc=nameofpc)
if /i %count% EQU 10 (goto end)

net use \\%pc%

installation code here....

set /a count +=1
goto loop


:end
script complete
exit

my issue is that when count reaches 10 the if statement only See's it as 1, so instead of going to :end to redoes the first PC again.

I've changed the numbers so they read 0-9 so it works, but I'd like to add another PC to it and I'm a little LOST as to why it is happening.

NOTE; I have also tried putting " " around the number but that hasn't helped.

any ideas???Seems %count% always has a value of 1 as it's never updated.

The line "set /a count =+1" maybe should read "set /a count=%count%+1"

Thanks for the reply.

%count% ADDS an extra 1 every time passes 'set /a count +=1' fine. (i have added an 'echo %count% just before it trys to map to the PC, so I know which one it is doing)

The problem is that after it gets to 9, it adds another one (becomes 10) but the 'if' statement fails to see it as 10 and See's it as 1 so it does the first PC again.

As i said, I have changed the numbers to read 0-9 so that this isn't an issue at the mo and it works fine. But I'm going to have to add another PC withing the next few days so I'm trying to find an answer!!!!Sorry, I was wrong, but I have been unable to replicate your problem, there's just gotta be something else. I butchered your coding slightly as below and it runs without hitch. No problem with the IF statements picking up numbers >9.

Code: [Select]set count=1
:loop

if /i %count% EQU 1 (set pc=nameofpc) & echo %count%
if /i %count% EQU 2 (set pc=nameofpc) & echo %count%
if /i %count% EQU 3 (set pc=nameofpc) & echo %count%
if /i %count% EQU 4 (set pc=nameofpc) & echo %count%
if /i %count% EQU 5 (set pc=nameofpc) & echo %count%
if /i %count% EQU 6 (set pc=nameofpc) & echo %count%
if /i %count% EQU 7 (set pc=nameofpc) & echo %count%
if /i %count% EQU 8 (set pc=nameofpc) & echo %count%
if /i %count% EQU 9 (set pc=nameofpc) & echo %count%
if /i %count% EQU 10 (set pc=nameofpc) & echo %count%
if /i %count% EQU 11 (set pc=nameofpc) & echo %count%
if /i %count% EQU 12 (set pc=nameofpc) & echo %count%
if /i %count% EQU 13 (set pc=nameofpc) & echo %count%
if /i %count% EQU 14 echo %count% & (goto end)

:: net use \\%pc%

:: installation code here....

set /a count +=1
goto loop


:end
:: script complete
:: exit
I always surround both sides of IF tests with QUOTES & use double equal signs rather than EQU & I never have this problem. Also, why the parentheses around "goto end"?

if /i "%count%"=="10" goto end
Quote from: Dias de verano on February 28, 2008, 05:44:34 AM
why the parentheses around "goto end"?

Force of habit really. I usually have '(goto end) else goto wherever'.

I'll have another look at my code later this afternoon.Quote from: blastman on February 28, 2008, 06:41:10 AM
I usually have '(goto end) else goto wherever'.

That's a good tip. Thanks!
well,

I've added " " to numbers over 9 (ie. more than one didget) and it seems to have done the trick!!

I had done originally and then changed it cos I though it was causing other errors. I must have had it wrong.

I've stuck it on a server, scheduled it to run and put it to bed. - (hopefully)

job done.

Thanks

6037.

Solve : how to verify the native language of MS XP PRO in DOS?

Answer»

Hi all

the QUESTION is : is it possible to verify the native language of MS XP PRO (French or English) in DOS ??

if it is How do I do it ?? what is (are) the command(s) ??

Thank you allI don't know for sure, but I found SOMETHING that might work (it works on my COMPUTER). I see a registry key that appears to show the language version. Try this command:
Code: [Select]reg QUERY "HKLM\Software\Microsoft\Windows NT\CurrentVersion\WOW\boot.description" /v language.dll
Assuming that works, you can use this code to set an environment variable:
Code: [Select]@echo off
setlocal
for /f "tokens=3*" %%a in ('reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\WOW\boot.description" /v language.dll ^| findstr /i language') do set Lang=%%a
echo Language is %Lang%
thanks !!

i'll try that

then if I want it to do a certasin action like :

call install_FR.bat if french or call install_eng if English.... who might I do that ??Then you cold do something like:
Code: [Select]if %Lang%==English call install_eng.bat
if %Lang%==French call install_fr.batfinaly the command you gave me wans'nt returning what I was looking for...

so I've decided to verify the existance of a known component and a Major difference between the 2 versions...

the Desktop/Bureau element

if one is Desktop : call int_eng.bat
if one is Bureau : call int_fra.bat

easy enough !! don't you think

6038.

Solve : DOS and ur Modem?

Answer»

is it possible for DOS to Dial ur modem(yes, a Dial-Up modem) to a specific phone number like if you have ur phone connected to ur modem? Quote from: macdad- on March 16, 2008, 09:46:57 AM

is it possible for DOS to Dial ur modem(yes, a Dial-Up modem) to a specific phone number like if you have ur phone connected to ur modem?

Back when we all used MS-DOS, there were MANY programs out there for dialing and connecting. Same for receiving and connecting.
Some were free, some were shareware, some were commercial software.

I liked Telix. Still keep a copy handy... just in case I want/need it.
It is uncrippled shareware.

You can download it here:
http://www.chebucto.ns.ca/Services/PDA/DosComm.shtml

If, after reading the docs, you are not sure what to do with it, post here and I'll try to help. Bear in mind that it has been quite a while since I last set it up from scratch, so I might stumble a bit.
It is REALLY not very difficult though.

I don't know what os you are using - assuming XP.

I don't know about XP and its command line, as to how it likes an old fashioned DOS program wanting to control a serial port. You might have to get advice on that part from the XP folks here on CH.

You'll need to post the brand name, make, mode number, whatever, of your modem too.



What is it that you are trying to accomplish though?yes, that is just wat i need thnx! Quote from: macdad- on March 16, 2008, 01:18:29 PM
yes, that is just wat i need thnx!

You're welcome.

Telix was a very nice terminal program for its TIME.


What is it that you are trying to do though?well i have a DSL modem already but i needed a program that could Dial my ISP using my Dial-Up Modem in the case that my DSL modem was down.Quote from: macdad- on March 16, 2008, 01:39:59 PM
well i have a DSL modem already but i needed a program that could Dial my ISP using my Dial-Up Modem in the case that my DSL modem was down.

Dialing your ISP is probably not enough. You have to have a meaningful connection too.

Unless your ISP allows a shell account, and they probably don't, Telix won't do what you need.

For example, you want to be able to browse the web, right?
Win98 had Dial Up Networking for this. I assume that XP has it too.
That's what you want to negotiate a connection that will let you use the internet with your ISP.

On the other hand, if you wanted to dial a friend's computer direct, then Telix would be useful.

If you both run Telix successfully, you could connect over a regular dial up phone line. Transfer files, 'chat', etc.

As a matter of fact, if I recall correctly, that Telix package included some scripting that would let Telix auto-answer and allow the caller to log in.
Bare bones bbs software.



well does Telix allow you to send data?
if so then all i do is dial up my ISP then i send the username and password data thats how my ISP functions with Dial up conncection,simply dialup the ISP then send the username and password data.Quote from: macdad- on March 16, 2008, 01:52:48 PM
...
if so then all i do is dial up my ISP then i send the username and password data thats how my ISP functions with Dial up conncection,simply dialup the ISP then send the username and password data.

So how did that work out for you?

yup, WORKS lke a charm. ty
6039.

Solve : Calling a command window to run in the background?

Answer»

Thanks to those who helped me on my previous problem with my batch FILES and calling up command windows. The shell program WORKS great, now the only downfall is that when the command windows CALLED up by my batch file open, they are always the focus or active window. Is there any way to call them up so they will not keep jumping to the top layer on the screen? I ASK this because right now it takes about 3 hours to run the program that my shell is utilizing so it essentially MAKES that computer unusable for 3 hours. Thanks for the help.Try this: start /min yourfile.batJPH's suggestion should work.

But you should be able to switch to any other open program even though the command window is on top.

Try an OLD trick that goes back all the way to Windows 3.1(or before).
ALT_Tab
Press and hold the ALT key.
Press and release the Tab key one or more times until an icon for the program you want is displayed.
Release the ALT key.
You can use this method to switch between any open programs, but really comes in handy when your task bar is hidden under a full screen command window.

6040.

Solve : Select and Delete Files older than 2 Weeks and 1 Month?

Answer»
Hello.

Would anyone know how to :

1. do a count of files in a DIRECTORY
2. output count to a txt file
3. and then delete files that are older than 2 WEEKS? 1 month?

Thanks.The first 2 are easy, the last really needs to be done with VBScript - batch files really dont do date manipulation.

The count can be taken using the FIND command, COUNTING the output from a DIR

dir /b /a-d|find /c /v "" > CountOfFiles.txt

the dir shows basic info about all files that do not have the attribute Directory
The find then provides a count of all the lines that do not contain a blank (ie those that have something in)
It then directs the count into the file CountOfFiles.txt

GrahamQuote
The first 2 are easy, the last really needs to be done with VeBScript

Might as well get the VBScript while you're here.

Code: [Select]Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("c:\scripts") 'Start directory
Set colSubFolders = f.SubFolders

For Each objFolder in colSubFolders
AgeFiles objFolder
Next

Sub AgeFiles(Fld)
Set k = fso.GetFolder(Fld)
Set s = k.SubFolders
Set kf = k.Files

For Each objFile In kf
If objFile.DateCreated < date - 30 Then 'Age factor
Wscript.Echo objFile & " " & objFile.DateCreated
End If
Next

For Each SubFolder In s
AgeFiles SubFolder
Next
End Sub

Change the start directory and age factor to your needs. The script uses recursion, any subdirectories of the start directory will also be processed.

As a safetly PRECAUTION the script reports back the aged files. When you're ready replace Wscript.Echo objFile & " " & objFile.DateCreated with fso.DeleteFile objFile
6041.

Solve : Open url direction from MS-DOS?

Answer» HI there!

Does anyone know how to open an url direction from MS-DOS?

Thank youWhy the poll? What exactly do you WANT opinions on? Don't you find it odd that both choices are IDENTICAL?

Perhaps this will help with your COMMAND line URL:

Code: [Select]"C:\Program Files\Internet Explorer\iexplore.exe" http://www.google.com

Quote from: Sidewinder on March 19, 2008, 06:26:45 AM
&LT;sigh>


6042.

Solve : Set command?

Answer»

how do u do math using the set command?
im trying to do this Set /A %TIME% - 12
the %TIME% variable is in 24 hour format so if i subtract 12 from %TIME% variable only if the the time is GREATER than 12 o'clock say its 12PM then it goes to 1PM which would be 13PM in 24 hour format. but plz help me.
I don't know where you are, but in my locale TIME has colons in it so set /a will fail

that is,

7:21:14.41

is not a valid number.

Macdad's %time% also has AM or PM appended to it. With 24-hour time setting these are superfluous.

The should work for a bare 24-hour %Time% setting:

Code: [Select]@echo off
cls

set this=%time%
set/a hour=%this:~0,2%-12
set newtime=%hour%%this:~-9%
also to overcome the 12 hour problem you have to (a) get the time in 24 hour format (b) learn about modulo arithmetic (c) decide what to do about "yesterday".

THNX Dusty it worked. Quote from: macdad- on March 20, 2008, 06:56:49 AM

thnx Dusty it worked.

GOOD, but be aware that if the hour in %Time% is less than the number of hours to be deducted you must use base 24 i.e. add 24 to the hour in %time% before deducting. e.g. if the current hour is 11 and you deduct 12 then you will get -1 whereas you really wanted 23 but 11+24-12 is 23.

Similarly when manipulating MINUTES and seconds base 60 must be used.

However, another problem(?) is that when SET/A encounters a number beginning with 0 (zero) it treats it as Octal (base eight). So if you try to do arithmetic calculations using SET/A on 08 or 09 (zeroeight or zeronine) the number is invalid in base 8 so the script will fail. My solution is to always remove the leading zero from numbers less than 10 (when dealing with two-digit numbers).

Good luck & thanks for coming back with your success story.

6043.

Solve : How to specify a filename or foldername with space in batch file?

Answer»

Can somebody HELP me how to WRITE a CODE in DOS batch file for a filename/foldername with spaces?quote marks
Quote from: Prince748 on March 19, 2008, 02:31:03 PM

Can somebody help me how to write a code in DOS batch file for a filename/foldername with spaces?

Examples -

This line won't work here (Win98) :
cd\test\dir name with spaces


This line does work:
D:\>cd\test\"dir name with spaces"

D:\test\dir name with spaces>




Yes. But what if part of the file name (i.e. "Report 2008 April.xls") needed to be calculated based on the current date?
How could the string be CONCATENATED?
Thanks in advance!
6044.

Solve : 1/100 chance of something?

Answer»

When working on Eternal Death Slayer Version 2, I thought it would be cool if there is a chance of something you dont expect, so i decided on a 1 out of 100 chance that a monster attacks you when you GO to the lobby, although when i inserted the code, all it did is make the WINDOW close. Here's my code:

Code: [Select]SET /a rmonster=%random% %%100>nul
IF %rmonster%=5 GOTO rmonsterattck
And then I was wondering maybe its something at the rmonsterattck that was going wrong, so here you go (THOUGH theres not much code here):

Code: [Select]:rmonsterattck
CLS
ECHO Logged in as %name% - Random Monster
ECHO ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
ECHO º STATS
ECHO º Life=%life% Money=%money% Skill=%skill% Armor=%armor%
ECHO ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
ECHO.
ECHO
PAUSEtry
Code: [Select]SET /a rmonster=%random% %%100
IF %rmonster% equ 5 GOTO rmonsterattckwell i ADDED it and it doesnt close the window but i was testing to make sure it would work properly and it wouldn't goto rmonsterattck
Code: [Select]SET /a rmonster=%random% %%1
IF %rmonster% lss 0 set rmonster=1
IF %rmonster% equ 1 GOTO rmonsterattckwell when i executed code it try to do
Code: [Select]if 0 LSS 0 set rmonster=1so it never set rmonster to 1. try use equ but i think it will mess in code right ?

6045.

Solve : create a folder by date?

Answer» PLS HELP me create a batchfile for backup that will create a folder by DATE so that the backup will be overwritten.
sample command " test 020409 " where test=batchfile, 020409=mmddyyHave you tried the HANDY SEARCH function at the top of the page ?
Folder Date

Returns many useful threads on this

Graham
6046.

Solve : Create folder from Volume name?

Answer»

I want to copy numerous CD's to a server. I want to place the files from each CD into a folder named after the CD Volume name.

There are about 4 cd's that have the same volume name so I would need to be warned about over writing a folder and have the option to modify the target folder name if there is a conflict. Since there are only a few of these I can manually handle it vs. trying to program it as long as the folders don't get over written by the batch file. Ideally I want to just opo in a CD and RUN the batch without having to babysit it, so prompting should only be when a decision must be made. All the folders will be in one main folder on the server.

I ALSO want to create a database for all the files that will contain the filenames, type (extension), last write date and folder location. I will be using Access. All I need are delimited text files with the needed fields that I can import into Access.

I used to work with DOS years ago and have made some simple batch files so that would be the easiest for me.

TIA,
NeilI found a utility that will create the text files for the database so that part is covered.Welcome to the CH forums.

The following script might do what you want, you will have to modify the drive letter for the cdrom and source and destination paths to suit your purpose. The script is totally untested...

Code: [Select]@echo off
cls

for /f "tokens=1-6" %%A in ('vol c:') do (
set vol=%%F & goto rumble
)

:rumble
if exist path\%vol% (
echo Destination folder %vol% already exists... & goto newname
) else (
md path\%vol%
copy "c:\*.*" "path\%vol%\"
)
cls
exit/b

:newname
set /p vol=Enter new name for destination folder:
goto rumble

Good luckI GOT your program to work Dusty. All it needed was a few minor tweaks, namely change the COPY command to XCOPY, take out the wildcards and add the /s parameter to XCOPY and put the quotes only around the destination path.

Thank you!

6047.

Solve : Xcopy Exclude?

Answer»

Need help on syntax for Xcopy Exclude
This works fine:
Xcopy /S /I /C /D /H /Y "C:\Documents and Settings" "F:\Documents and Settings"
But this doesn't:
Xcopy /S /I /C /D /H /Y "C:\Documents and Settings" "F:\Documents and Settings" /Exclude:"New York Times" I GET "Can't read file "New York Times"
Nor does this:
Xcopy /S /I /C /D /H /Y "C:\Documents and Settings" "F:\Documents and Settings" /Exclude:"\New York Times\" I get "Can't read file "\New York Times\"

Any suggestions? Thanks.Figured it out! Created a file NAMED Excludes.Txt containing, one name on each line, a list of the files and folders to be excluded. Then used the following syntax: Xcopy from to /Exclude:Excludes.Txt

6048.

Solve : how to create a batch file which gives us mail notification on application failu?

Answer»

HI all,

PLEASE help me as I want to configure mail alert system on failuar of my application which it self is a batch file.

Sorry.....you want to what?

More INFO...I wanted to give mail alerts to system admin on failuar of any application.

Suppose,
I have xyz application (an executable batch file through which we run an we application), if any time my aplication (xyz) goes down , then this should be INTIMATED to sys admin through mail.

So I want an application , which check any system failuar is occured or not, if yes then it will put a mail to sys admin.

next thing is , I want to create this as batch file as my application is on windows.

If it is not possible in windows then please let me know other means."failure" is the correct spelling. Quote

I want to create this as batch file as my application is on windows



If you're monitoring only the xyz application, you can check the errorlevel and use BLAT to send a batch email.

It is possible to create a VBScript to monitor program terminations system wide, however, I could not find a property to CAPTURE a return code which might indicate success or failure.

Good luck. Oh yeah, have you ever tried Blat. Because I tried it last time and it didn't work with me.
6049.

Solve : osql to MSSQL?

Answer»

Is there any EXPERT who knows how to send a log to a designated MSSQL DB when a BATCH file completed by MS DOS. The log should containing CLIENT IP ADDRESS, Datetime etc....

many THANKS,
dcheong



6050.

Solve : Prompt for user input of file?

Answer»

I need to execute specific files based on a Change Request. The files names change with every change request. The directories where the files reside changes from time to time as well, depending on the version being DEPLOYED. There are usually many files residing in each version directory. Currently I COPY the FILE to a separate "staging" directory, but I was WONDERING what I would need to add to my batch file to prompt the user to insert the directory name\file name in the command window so it can execute that specific file without having to copy the target file to a separate directory?Try this
Set /P MyDirectory=Enter Directory:

This will wait for the user to enter a directory name, this will be held in %MyDirectory%

GrahamYou can use set /p to get user input into a variable

Code: [Select]set /p path.and.name="Please type file path and name: "
echo The user typed %path.and.name%
Don't forget to use it as "%path.and.name%" for file OPERATIONS if there is any possibility of it containing spaces.
That did the trick! Thank you both very much!