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.

6451.

Solve : link?

Answer»

how can i CREATE a link in a batch file to a WEBSITE, that starts at 20:00Maybe this will help:

"C:\Program Files\Internet Explorer\iexplore http://www.microsoft.com"

USE the task scheduler to START your batch file at 20:00

Good luck. 8-)

Note: it's important that you keep the quotes.

6452.

Solve : Batch to refresh IE?

Answer»

I don't know all that much about batch FILES, but what I'm trying to do is make a batch that will refresh internet explorer about every 10 seconds...I'm doing it for my Dad for his FARM markets. If ANYONE could help me out or give me somewhere to start it would be really appretiated.
Thanks,
RevThe good new is that most of Microsoft's products are scriptable. The bad news is that batch language has problems with WINDOWS programs.

This little script may give you some ideas:

Code: [Select]Set IE = CreateObject("InternetExplorer.Application")
With IE
.Navigate "http://www.yahoo.com" ' change to actual site needed
.Visible = True
End With

Do While True
WScript.Sleep 10000 ' 10 seconds
IE.Refresh()
Loop

Change the http address to what you need. After saving the script with a VBS extension, you can run the script as: cscript scriptname.vbs

Good luck. 8-)

Note: the only way to end the script is to cancel cscript in the task managerThanks, it works great!!

6453.

Solve : Create directorylist of the last XXX?

Answer»

Hello,

I've searched the forum first for some answers, but can't find anything that does what I want it to do.

First of all, I'm a complete newbie in DOS, so don't shoot me when I ask some stupid questions.

I wan't to write a batch file to get a directory list of the System32 folder. I'm only interested in the files created in the last 40 days. Is there anybody who can show me?

My second question (a little more difficult I think )
How can I make it possible to let the people change the number of days? I know how to do it in VBA (offering an inputbox, and working with that result ), but in DOS ,............... I totally have no IDEA.

This is the code I USE.

cd\
cd %temp%\
DIR /a:-d /o:-d > %systemdrive%\system32.txt
start %systemdrive%\system32.txt
cls
exit



greetings
Hi,

I think my question is to difficult.

So, I was thinking to do it another way. (but need some help anyway )

The code in my previous message, results in a textfile.
The most important thing to me are the first 30 lines of that textfile.

Is it possible to delete the other lines, or is it possible to write the first 30 lines to another textfile?

greetingsyou question is not difficult just that doing date/time manipulation in batch is not quite straighforward.
my solution is not batch, but done in Python

Code: [Select]import os,time
dir = os.path.join("C:\\","windows","system32") #define your directory to search

def findfiles(path,numdays):
''' Function to go into a directory to find files for the last numdays from today.'''
now = time.time() #find today's time
os.chdir(path)
print "Finding files in %s less than %d days" %(path,numdays)
for f in os.listdir(path):
if os.stat(f).st_mtime > now - numdays * 86400: #1 day is 86400 secs
if os.path.isfile(f):
print "Found file: %s" %(f)

## Main ##
userinput = int(raw_input("Enter number of days: ")) #get user input on changing num of days
findfiles(dir,userinput) #do the processing.


Hi Ghostdog,

Thanks for the reply, but ................. now it's still difficult to understand.

How do I execute this textfile in Python? I know how to handle a BAt file to excute (just doubbleclick ) , but a "Python file" ?? I totally have no idea.

greetingsYou would need a Python interpreter to run a Python SCRIPT. You mention you know how to do this in VBA. Why not use VBScript which is a subset of VBA, comes free with Windows and has the functionality to do date calculations. You can check out VBScript at The Script Center

Batch date calcs seem to be a hot topic this week. Unfortunately you need a truckload of code to handle dates. Batch code is a command language not a programming language.

8-)yes, as sidewinder says, the python code is done using any text editor, save it as a .py file, and then using the python interpreter to execute. eg after successful installation of python,
Code: [Select]
c:\python yourfile.py
Python is the most easiest and module rich programing language that i have used for my job.
Anyway, if python is difficult for you, can try out what sidewinder says, use vbscript as it comes with windows. it has date calculations too. A search on google on "vbscript date time" also gives you some hits on date calc with vbscript.

Good luck
In case you are still looking for a batch solution, it can be as easy as this:

Code: [Select]@echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION

cd /d "%SystemRoot%.\system32"

set /p limit=Enter number of days:

call:jdate tnow "%date%"
for %%F in (*.*) do (
call:ftime tfile "%%F"
set /a diff=tnow-tfile
if !diff! LEQ %limit% echo.%%~nxF is !diff! days old
)
PAUSE&GOTO:EOF

:: Copy functions below here - :ftime :jdate :date2jdate

You will need to get the functions [highlight]:ftime[/highlight] [highlight]:jdate[/highlight] and [highlight]:date2jdate[/highlight] from:
[highlight]http://dostips.cmdtips.com/DtTipsDateTime.php[/highlight]

Hope this helps

6454.

Solve : batch file hrm...?

Answer»

daj0pe,

You will also need to CLEANUP your copy mess, i.e. you copied the :jdate function 1 1/2 TIMES. Quote

either that.. or is somebody can be nice enough, CREATE me a VB app, where i can enter a date (defaulting to today) and it will tell me the date in 120 days? hehe
if you don't MIND vbscript and if i am not wrong, there is a DateAdd function in vbscript that you could use.you GUYS rock ) works perfect

thanks for your time!!
6455.

Solve : Batch file help!?

Answer»

So, I've recently dug out my old copy of Doom ][, installed it, patched, and downloaded ZDoom.

Well, cutting to the chase, I've downloaded custom WADS for the game.

This means that if I want to run a custom WAD, I'll have to go into cmd, type: C:\Games\ZDoom\zdoom.exe -file WADNAME.WAD

This gets pretty tiresome, so I've basically made a workaround to this by making a BATCH file and dropping it in my C:\Documents and Settings\User\ directory so when I load up cmd, it's there and I can type commands:

Code used:

Code: [Select]:: wadload.bat
:: ZDoom WAD Loader
@ECHO OFF

C:\Games\ZDoom\zdoom.exe -file %1
This way I can type wadload enigma.wad per se.

But this makes me have to open cmd and I am lazzzzzy.

So I was wondering if there was a way that I could just have a batch on the desktop that would basically ask for my imput and load

So when it starts up it would go:

Quote

WAD Name: [where I type the name]

And upon pressing enter, would just load the proper commands.

Is there any way to do this?Like this?

Code: [Select]:: wadload.bat
:: ZDoom WAD Loader
@ECHO OFF
set /p name=Enter the Name:
C:\Games\ZDoom\zdoom.exe -file %name%

Does it help?Code: [Select]:: wadload.bat
:: ZDoom WAD Loader
@ECHO OFF
set /p name=Enter the Name:
C:\Games\ZDoom\zdoom.exe -file %name%.wad
EXIT
Thanks man! THREW in an EXIT there because the prompt is pretty much useless after I enter the name in. Also made it so the the .wad is already typed for über-laziness FACTOR.
6456.

Solve : Network Drive Mapping?

Answer»

I apologize in advance if its somewhere on here, but I've only found similar issues, but none that meet my need.

I created a basic batchfile to map network drives for users on laptops. They're all running winXP pro sp2. I need the batch to prompt for a DEPARTMENT ID #.

Here is the batch file currently:

Code: [Select]@echo off
net use U: \\lgfileserver2\888user\%username%
net use S: \\lgfileserver2\888share
net use Z: \\lgfileserver2\leapfrogshare
if errorlevel 1 goto error
CLS

echo Your network drives have been mapped!
Pause 10
goto end

:error
echo If you experience any issues accessing the drives or you are MISSING any drives, please contact the Helpdesk at 1(888) XXX - XXXX and leave this message on the screen.
pause
goto end

:end
I'm rather novice, so I may have an unneeded code somewhere, but I just need the prompts.
As you can see, this person will be mapping to department ID 888 (both USER and share). Is there a way that I can prompt the user to input that INFORMATION?

Thank you in advance.Code: [Select]@echo off
set /p dept=Enter Dept ID:
net use U: \\lgfileserver2\%dept%user\%username%
net use S: \\lgfileserver2\%dept%share
net use Z: \\lgfileserver2\leapfrogshare
if errorlevel 1 goto error
CLS

echo Your network drives have been mapped!
Pause
goto end

:error
echo If you experience any issues accessing the drives or you are missing any drives, please contact the Helpdesk at 1(888) XXX - XXXX and leave this message on the screen.
pause
goto end

:end

Note: The pause statement takes no parameters and does not act as a timer. The IF ERRORLEVEL statement only refers to the last NET USE statement. Not sure if NET USE issues ERRORLEVELS but if it does you'd need an IF statement for each of them.

Good LUCK. 8-)That worked perfectly. Thank you very much! I knew I had some extra/not completely correct codes in there.

And errorcodes seem to work for any type of error on net use.

6457.

Solve : Batch file help, passwords?

Answer»

Ho people im writing a batch file or a few so may need alot of help.

ive got one and it paths through to a SERVER is there any way i can tell it when it asks for a username and password to just continue.

i mean some how put my username and password into the bat file code so anyone can USE it and it will just path through for them?

this is the place where it will ask me for the details

net use z: /delete
net use z: "\\server and folder address will be here"
echo Ready to copy ROIS Auto Directory
pause

not SURE if there is AWAY i can do this

thanks people

ianyou could make it an if statment and sett a var like this

:pas_try
set /p pas_ask=Password:
if pas_ask==your_password goto good
echo The password was bad!
goto pas_try
:good
echo The password was corect!

then compile it to an exe. (I can do that for you if you would like!) <--just PM me

6458.

Solve : Recovering files and dates?

Answer»

Ok, I have a problem that I need some help with. I hope SOMEONE here can help... I am in the middle of a mess. My personal computer(yes, mine) was MISUSED by my ex. I know what was viewed on the internet, and now for sake of the divorce, I need to know WHEN it started. Is there a way to get into the DOS mode and recover that? The history and temp file were cleared... but I know you can recover all the sites ever visited, and papers ever typed in Word ECT.... can you get dates? and possible a backup file of the internet sites? maybe even e-mails? Even if someone COULD tell me how to boot up in DOS mode to clean this junk off would be great!! I do not want to go pay $200 for someone else to do it and risk LOOSING anything I want left alone. Any help is appreciated!
Kat

6459.

Solve : XCopy folders with relative paths!?

Answer»

Hi All

I would like to copy folders recursively from one location to another. The problem is that the folder names are changing slightly, but it retains something unique all the time. Below is an example of what the folders look like:

Copy:
\\server\path\10.200.10.777_Unique_name_lang\Something_else

-the numbers in front of the _Unique_name are changing all the time

Paste:
\\server\path\Test

I'm trying to automate this and I was wondering if it can be done using batch programming. Any help would be greatly appreciated!

SoncuPlease post the details on what part(s) of the path are static, and which part(s) change. The more details we have the better we can help you script a solution.Sorry I was a bit too evasive!

Here is the explanation in detail:

Path to copy:

\\server\path\10.200.10.777_Unique_name_lang\Something_else

10.200.10.777 - only these numbers change
_Unique_name_lang\Something_else - this is static

Copy the above path to:

\\server\path\Test

I hope this is clear enough! Thanks for the help!

Soncu It would be possible to use wildcards, provided the nonstatic DATA keeps the same format:

Example:
Code: [Select]xcopy \\server\path\10.???.??.???_Unique_name_lang\Something_else \\server\path\Test /s /e

You can WILDCARD as much or as little of the nonstatic data as you need.

Note: Suggest you use the ? wildcard instead of *. Less likely to run into problems.

8-)Sorry guys, your suggestion didn't seem to work. I'm using Windows XP Pro version. Any other suggestions?

"xcopy \\server\path\10..??._Unique_name_lang\Something_else \\server\path\Test /s /e"

Here is the code I have:

echo off
SET sourcedirMSI=K:\lang\10.0.1245.7777_Unique_name_lang\Something_else\FILE.txt
set sourcedirCAB=K:\lang\10.0.1245.7777_Unique_name_lang\Something_else\file.xml
set backupdir=C:\Test
for /f "tokens=*" %%a in ('dir "%sourcedirMSI%" "%sourcedirCAB%" /s/b') do (
xcopy "%%a" "%backupdir%%%~PA" /s/e
)
eof

The scenario is like this: The numbers in front are variables, they change often, so I want to find every folder that has _Unique_name_lang and file.txt/xml in it and copy it to C:\Test. At the moment I can only do a search in the lang folder for file.txt/xml, but this returns these files from all the folder and I only need the ones that contain _Unique_name_lang. I hope this makes sense!

Thanks
Soncu I must be missing something. I thought the numbers kept changing, but based on your code:
Quote

set sourcedirMSI=K:\lang\10.0.1245.7777_Unique_name_lang\Something_else\file.txt
they are set in stone. Would you not need to use the wildcards in the DIR command to create a collection of files or directories for the XCOPY to operate on?

Like I said, maybe I'm missing something. :-?Sorry Sidewinder, you're right! From that example it looks like is a set path! I just wanted to show how the folder looks with the full path. My humble apologies. Indeed, those numbers are changing. I need something like a wildcard or anything that would ignore those numbers and look only at what's after it _Unique_name_lang\Something_else\file.txt, copies only file.txt, including the dirs it come from too, into C:\test.. I hope I'm not getting more confusing...

Thanks
SoncuHow about this:

Code: [Select]set sourcedirMSI=Something_else\file.txt
set sourcedirCAB=Something_else\file.xml
set backupdir=C:\Test
FOR /f "tokens=*" %%a in ('dir /ad /b \\server\path\*^|findstr _Unique_name_lang$') do (
if exist "%%a.\%sourcedirMSI%" xcopy "%%a.\%sourcedirMSI%" "%backupdir%" /s /e
if exist "%%a.\%sourcedirCAB%" xcopy "%%a.\%sourcedirMSI%" "%backupdir%" /s /e
)

DOS IT HELP?Thanks for the help DOSItHelp but unfortunately your suggestion didn't work! Here is an example of the full path:

\\server\path\10.0.1234.7777_Unique_name_lang\Something_else

I need to bypass "10.0.1234.7777", read "_Unique_name_lang" and xcopy all the files with file.txt/xml found in all the subdirectories.

Thanks,
SoncuHow about this?

Code: [Select]set backupdir=C:\Test
FOR /f "tokens=*" %%a in ('dir /s /b \\server\path\*^|findstr _Unique_name_lang\\') do (
if /i "%%~nxa"=="file.txt" xcopy "%%a" "%backupdir%" /s /e
if /i "%%~nxa"=="file.xml" xcopy "%%a" "%backupdir%" /s /e
)[highlight]; )[/highlight]Hi DosItHelp

That works fine, but it only copies the files in the C:\Test folder in the root. I need the directories recursively as well. The /s/e switches don't seem to work.

Thanks again
Soncu How about this?

Code: [Select]set backupdir=C:\Test
FOR /f "tokens=*" %%a in ('dir /b /ad \\server\path\*^|findstr _Unique_name_lang$') do (
xcopy "%%a.\file.txt?" "%backupdir%" /s/y
xcopy "%%a.\file.xml?" "%backupdir%" /s/y
)[highlight]; )[/highlight]Thanks a lot DosItHelp! With a bit of tweaking it worked fine! How about making it to extract the files newer than 2 days without setting a fixed date!

Cheers
Soncu

Soncu,
This will be a little more tricky. Try this:

set TmpFile=%temp%.\%~n0.tmp
type NUL>"%TmpFileList%"
&REM makes sure tmpfile is empty

set backupdir=C:\Test
FOR /f "tokens=*" %%a in ('dir /b /ad \\server\path\*^|findstr _Unique_name_lang$') do (
xcopy "%%a.\file.txt?" "%backupdir%" /s/y/L&REM L-option Displays files that would be copied
xcopy "%%a.\file.xml?" "%backupdir%" /s/y/L&REM L-option Displays files that would be copied
)>"%TmpFile%"

SETLOCAL ENABLEDELAYEDEXPANSION
set /a AgeInDays=2
call:jdate tnow "%date%"&REM get today in julian days
for /f "tokens=*" %%F in ("%TmpFile%") do (
call:ftime tfile "%%F"&REM get file time in julian days
set /a diff=tnow-tfile
if !diff! LEQ %limit% xcopy "%%~F" "%backupdir%%%~F"
)

PAUSE
GOTO:EOF
:: Goto http://dostips.cmdtips.com/DtTipsDateTime.php
:: Copy :ftime :jdate :date2jdate functions below here
[/b]

You will need to get the functions [highlight]:ftime[/highlight] [highlight]:jdate[/highlight] and [highlight]:date2jdate[/highlight] from:
[highlight]http://dostips.cmdtips.com/DtTipsDateTime.php[/highlight]

Hope this helps
6460.

Solve : 2 DOS Questions?

Answer»

I am running Windows XP and want to know if there are any commands in DOS for
finding the following info. The set command doesn't do it...

1) Computer Description. Set command give computer name, but not value in
Computer description

2) Is there a way to LOG a DOS session so that I can have a file of what
I've done in a DOS window?

THANKS for any help!

I dont know how you COULD do the #2 but you could if it is a BATCH file have it output everything to a file > and >>Here as a good site for all of the commands.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=trueThanks for that site Dakota! LOTS of interesting commands out there!

6461.

Solve : Excluding files when using dir command?

Answer»

I need to output all the folders within a SPECIFIC directory, including subdirectories. However, I don't want to output all the contents of the directories - I just want the directories and subdirectory names. I know that with the dir command, it will display all files and subdirectories, but is it possible to exclude all the files?

I am not very proficient with dos other than running certain commands and so i don't know if this is even possible.

Nadia
This MAY help:

Code: [Select]
dir /a:d /b /s directoryname
You can eliminate the /b switch and get a slightly DIFFERENT view of the directories.

You can also use the TREE command which makes a cute little GRAPHIC of your directory structure:

Code: [Select]tree directoryname

Hope this HELPS. 8-)the tree command is exaclty what I needed.

Thanks!!

6462.

Solve : TOUGH!replace text in file where text like hello*?

Answer»

Hello

The mission:

1.search all files in c:\ and its subdir with the NAME text.txt
2.next,find a string inside the file where it is like "greeting=hello"
are replace it with the string "greeting=goodbye".
if the string is "greet=hello" i don't want to change it.
Note the differences between "greeting=hello" and "greet=hello"

Is this possible to do?

here is what I have so far.

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

setlocal enabledelayedexpansion
set pathToDirs=c:\test
set tmpfile=%TMP%\abc.123.aux
if exist %tmpfile% del %tmpfile%

for /f %%d in ('dir "test.txt" %pathToDirs% /s/b') do (

call :REPLACE_TEXT %%d hello goodbye
)
goto :eof

:REPLACE_TEXT
for /f "delims=" %%x in ('type %1') do (
set tmp=%%x
echo !tmp:%2=%3! >> %tmpfile%
)
move /y %tmpfile% %1 > NUL
never liked to do file manipulations in batch.
Code: [SELECT]##python code
import os,fileinput,sys
found = []
somedir="c:\\somedir
for root,dirname,names in os.walk(somedir): #traverse the directory and subdirectories
for files in names:
if os.path.isfile(files) and files =="test.txt":
found.append(os.path.join(root,files)) #get all test.txt into array
# process all found test.txt in place
for lines in fileinput.input(found,inplace=1):
if "greeting==hello" in lines:
lines = lines.replace("greeting==hello","greeting==goodbye")

The gurus here will come up with a batch one soon...There is a DISCONNECT with what you wrote, your DIR command and the SET statement:

Quote

1.search all files in c:\ and its subdir with the name text.txt

set pathToDirs=c:\test

'dir "test.txt" %pathToDirs% /s/b'

This may work a LITTLE better but Ghostdog is right. Batch code is not a programming language and data manipulation is easier is any of free Windows scripting languages VBScript, JScript, Python, Rexx, etc.

Code: [Select]setlocal enabledelayedexpansion
set pathToDirs=c:
set tmpfile=%TMP%\abc.123.aux
if exist %tmpfile% del %tmpfile%

for /f %%d in ('dir %pathToDirs%\test.txt /a:-d /s /b') do (
call :REPLACE_TEXT %%d hello goodbye
)
goto :eof

:REPLACE_TEXT
for /f "delims=" %%x in (%1) do (
set tmp=%%x
set tmp=!tmp:%2=%3!
echo !tmp! >> %tmpfile%
)
move /y %tmpfile% %1 > NUL

Good luck. 8-)Quote
if the string is "greet=hello" i don't want to change it.


setlocal enabledelayedexpansion
set pathToDirs=c:
set tmpfile=%TMP%\abc.123.aux
if exist %tmpfile% del %tmpfile%

for /f %%d in ('dir %pathToDirs%\test.txt /a:-d /s /b') do (
call :REPLACE_TEXT %%d [highlight]"greeting=hello" "greeting=goodbye"[/highlight]
)
goto :eof

:REPLACE_TEXT
for /f "delims=" %%x in (%1) do (
set tmp=%%x
set tmp=!tmp:%[highlight]~[/highlight]2=%[highlight]~[/highlight]3!
echo !tmp! >> %tmpfile%
)
move /y %tmpfile% %1 > NUL
[/b]

Have fun
6463.

Solve : Closing...?

Answer»

:-? how do you close a specific active program using dos? tskill will close all of the instances - but i only want to kill one - ie. two notepad text files are open but i want to close only the FIRST....

-- i want to implement this in a C++ prog by using the system command, might MAKE THINGS easier...It's easier in C++ by using FindWindow to get the window handle and then posting a WM_QUIT message to the window.

However using CMD you might want to run: TSKILL PROCESSID
by replacing the processid ID with the process id of the process you want to terminate.

Hope this helps.--- well then that project idea is toast...

well then for a secruity program like the one microsoft gives an example for in their scheduled tasks, how do you prevent it from simply being closed...

6464.

Solve : How to create a batch??

Answer»

I have a program (program.exe)(running on WinXPpro) which STARTS by opening a dialog with two text fields in which I have to type some code - example: 123456789 in the first box, and 987654321 in the second box and then click OK to actually start the program. Although I'm not new to computes, since Norton Commander and Wordstar, I'm not familiar with batch files and commands. I'm TIRED of opening the program, and then the text file CONTAINING just the two LINES with numbers and then copy and paste it, one by one, into the BOXES, and I was wondering if this could be done by excuting a batch file. By now, I've just managed to write a batch which starts the "program.exe" together with "notepad.exe" opening the text file containing the code, so the copy/pasting is easier, but, can I do something more? This batch file, I assume, should first start the program, then get the first line of numbers from the text file and paste it into the first textbox, and then the second line of numbers and paste it into the second box. Or should I create two separate text files, each one containing one of the lines?
Anyway, I don't have a clue how to do it - there should probably be a run command for the "program.exe", and then a get command to get the numbers from the plain text file(s) I would like to copy into the boxes, but, how do I go on and copy these lines (or the content of two text files) into the first and then the second text box - how do I define the location where to copy those numbers?
Any help would be appreciated! :-?

6465.

Solve : DOS disk commands?

Answer»

I am not familiar with DOS COMMANDS. I have a DOS disk to INSTALL Windows ME, but once I get to A:\ I have no clue as to what commands I need to start the installation! Can anyone out there help? You're going to need a LOT more help than that:

http://www.windowsreinstall.com/install/winme/installme/index.htmI have never installed ME but THINK this will work:

Put the ME cd in the drive then:

At the A:\> prompt type R:\SETUP (where R: is the letter of your cdrom drive.)

Then follow the on-screen prompts.

Good luck..

6466.

Solve : Dump errors from a batchscript in a log-file?

Answer»

Hello everyone,

For my work I made a little batchscript for file-renaming.
It looks like this:

@echo off
echo.
For /f "tokens=1,*" %%x in (lijst.txt) do @ren %%y %%x.*


This script uses a .txt file with 2 columns in it, the 1st column CONTAINS the new FILENAME and the 2nd column contains the old filename including the full path and extension and looks like this:

newname1 c:\test\oldname1.jpg
newname2 c:\test\oldname2.jpg
newname3 c:\test\oldname3.jpg

When I run my script and it tries to rename the file oldname3.jpg, but can't find the file in the DIRECTORY it comes up with the on-screen message "The system cannot find the file", but I would like to extend the script so it creates an error log-file so I can see WHICH FILES are not renamed because the script cannot find them.

I tried a lot of options with the "IF EXIST" option and command line parameters like "renamer.bat >>good.log 2>>error.log" or "renamer.bat temp >> %log% 2>&1" but it didn't work out.

I would like an error-log that looks something like this, so I can easily see what went wrong and with what files:


oldname3.jpg
oldname8.jpg
oldname12.jpg


Can somebody help me to adjust my script so it creates an error log that contains the filenames that are not found by the script in the directory?


Regards,

Molski
p.s. My English is "not all that", so I hope people will understand what I mean how about removing the "@echo off" statement?If I do that, or change it to "@echo on" then I STILL get (only) the message, "The system cannot find the specified file".

And I would like to know, what files it cannot find Please do not double post. This was answered in the Programming Section.

Cheesh :-/Okay, excuse me

6467.

Solve : FTP'ing?

Answer»

Hello all,

Am trying to work out how to save file(s) to a certain folder on my PC when obtaining them via FTP.

At the same time I'd like to rename them based on the date.

I need to make the process automatic, so the commands will be run from a text file.

Any help much appreciated!
To change the directory on your pc, use LCD (Local Change Directory)
To rename a file, do
get
so if you want to use todays date, you will have to create your SCRIPT on the fly, then call it

GrahamOr download the file always into the temp directory as gpl describes and then move afterwards.
I.e. LETS say you down LOADED file is named "server.log" that was downloaded to "C:\temp" and your final ARCHIVE folder is "c:\archive" then the following should work


Code: [Select]ftp -i -s:"FtpScriptName.txt"

set UNIQUE=%date:~10%%date:~4,2%%date:~7,2%
move /y "C:\temp\server.log" "C:\temp\server_%UNIQUE%.log"
Tips to embed a FTP script into a cmd batch file here:
http://dostips.cmdtips.com/DtCodeBatchFiles.php

Hope this helps That's really helpful, thanks!!

6468.

Solve : application file?

Answer»

Glad i could be of some HELP,

im not sure how you would configure your control THOUGH isn't that why you wanted to run th exe to do that?

i would have thought but i am really unsure that when you drag the exe file in you will need to clear the the calibration DATA to re do the calibration but that is a stab in the dark

ianatualy typeing cd C: would not have HELPED , it would have left you ware you are, al tho you did LEAVE out the ":" when you typed it..


What i should have Told you To do was Type "cd \" sry My bad

Looks like ian's way was a winner tho

6469.

Solve : Need some help..?

Answer»

I don't know that much about DOS or WINDOWS..or ANYTHING. im not /that/ computer literate. But i downloaded the shareware of Quake, and im not sure how to run the PROGRAM. Any information you need i'll gladly tell, im just not sure what to say.Wahotts....... Are you refering to the game ? If so go to the website ........ or post in the Games section .


DL65

6470.

Solve : how do you check to see if a program is running??

Answer»

tskill ends a program, but how do ou check to SEE if it infact running? (using commands not taskmanager)TaskList outputs a nice DISPLAY of running processes
You COULD FILTER this to see if the one you are interested in is running.

Graham

6471.

Solve : hmmm.. can i ask more??

Answer»

in win ME, can i ask if what other functions the "rundll.exe" aside from shutting down or restarting the computer..
ONE more, is there some kind of code on how can batch files detect if there are any diskettes on the floppy disk drive? cause i don't like people inserting diskettes on my computer when i'm not AROUND..
and one more thing.. =D aside from ^G w/c makes the computer BEEP (very funny)... are there other commands with a "^" in it? i wonder....Rundll.exe and Rundll32.exe EXECUTE code in dynamic link libraries starting at a specific entry point. Check out Rundll

For the floppies something like this may be all you need:

Code: [Select]@echo off
if EXIST a:\null echo There is a floppy in the drive
if not exist a:\null echo There is no floppy in the drive

Note: only works if the floppy has been formated.

The alt/ctl key combination is defined by the program where it it used. For instance in DOS, ctl-c will end a program, where the same combination in a windows program generally will do a copy operation to the clipboard.

8-)ei! thanks for the info.. uhm, the code prompts:
Code: [Select]Not ready reading drive A
Abort, Retry, Fail?

6472.

Solve : A counter in DOS?

Answer»

I use Windows 98

This is the script WRITTEN by me..
I did edit the autoexec.bat too..
My only problem is that i want a counter to count how many times my system reboot.

@echo off
echo Counter >>mylog1.txt
grep Counter C:\mylog1.txt -N -T -Q >>mylog.txt
IF NOT EXIST File1 md File1 >NUL
IF NOT EXIST C:\File1\*.ROM copy C:\BIOS\P12N0027.ROM File1 /I
IF NOT EXIST File2 md File2 >NUL
IF NOT EXIST C:\File2\*.ROM copy C:\BIOS\P13N0028.ROM File2 /I
IF NOT EXIST new md new >NUL
echo Rotate the Files >>mylog.txt
move C:\File1\*.* C:\new >>mylog.txt
move C:\File2\*.* C:\File1 >>mylog.txt
move C:\new\*.* C:\File2 >>mylog.txt
CHOICE /ty, 10 |pause >NUL
echo g=ffff:0000 | debug

as you can see, i'm using grep to count how many the word "counter" appear in the mylog1.txt. this is not really suitable.

let's say the system rebooting for 32 times then i hit Ctrl+C.. Next time when i boot the system i want the system counter to be started from 0.

please help me..
i've tried many ways@echo off
echo Counter >>mylog.txt
SET count=0
FOR /f %%L IN (mylog.txt) DO (call set /a count=%count%+1)
echo Counter=%count%

whenever i ran this script the answer always Counter=1..
REGARDLESS how many word counter appear in mylog.txt.

please..
is there anything i miss out?
i use DOS Microsoft Windows 98 (version 4.10.2222)Double the percent sign in the call statement like:

FOR /f %%L IN (mylog.txt) DO (call set /a count=[highlight]%%[/highlight]count[highlight]%%[/highlight]+1)

DOS IT HELP?THANKS DosItHelp...
it really works...

thanks alot FYI

i tried this out at WIN98 (4.10.2222)... and its not working

so, i used

@echo off
echo Counter >>Counter
find /c "Counter" Counter >>mylog.txt
echo Executed

then i think it should be ok...

6473.

Solve : a simple question?

Answer»

i think this is a silly question but still i need to know the answer.. hehe I added a new path using the "path" command.. but then, when i restarted cmd.exe, it was erased.. also in autoexec.bat, i added a few lines but then when i restarted windows, the lines i added disappeared.. kindly help me with this.. hope to hear from you GUYS soon and thanks Mixed signals. If you have CMD.EXE it's doubtful you have a AUTOEXEC.BAT FILE. Where did you add this new path? At the command line? In a batch file? In Windows?

Also please mention your OS.

8-)


Today everyone seems to be taking the wrong path.
Quote

Today everyone seems to be taking the wrong path.
LOL, for what it's worth I have a shortcut to cmd and in properties I changed the 'Start In' to c:\winnt\system32 (W2K) instead of the 'user' start in directory.I just have MINE at the root of C:. But I've written a few one-line batch files to quickly navigate to places like My Documents, the desktop, etc. In the command line.. I tried it both on the command prompt of dos and xp (command.com and cmd.exe) - if that's what you would like to know :-/Based on previous responses I'm not SURE what you want to do. CHANGING the path inside a command or cmd window is only in effect for the life of the window. To change the path permanently:

Right click My Computer==>Properties==>Advanced==>Environment Variables

Edit the PATH variable in the System Variables section and OK your way out.

To change the directory where the CMD or COMMAND window starts, take Fed's advice and create a shortcut to command or cmd and in properties change the 'Start In' box to whatever directory you want.

Hope this helps. 8-)

6474.

Solve : processing of files with a batch file?

Answer»

I want some insight. I need to process several input files using batch file. Input files are having a particular naming pattern. Say files are having names LIKE
photo_2001.jpg,
photo_2002.jpg,
photo_2003.jpg,
photo_2004.jpg,
photo_2005.jpg etc .

I want to take file 1 ie photo_2001.jpg and do some processing then I want to take file 2 ie photo_2002.jpg for processing.

How can I change the file name in the batch file?dir C:\dir_name\*.* /a:d /B &GT;>dir-list.txt
FOR /f %%L IN (dir-list.txt) DO ....

i'm still new... this WORK fine in my script Quote

How can I change the file name in the batch file?

after reading the question, all you want to do is change file name? basically you can change filename using ren or move command.
But i GUESS your problem is not as simple as that...
6475.

Solve : Recover files from 'recycle bin' using cmd prompt?

Answer»

Hi, im new here and I am having trouble with my computer.

Long story short - I deleted a file (is now in the recycle bin) from my C drive and now I am unable to start windows. I can access the COMMAND prompt, so I was WONDERING if I could recover the file from the recycle bin using that. Any help :-?cam_s1..... Do you have any idea which file you deleted ?
Have you tried to boot up in safe mode ?
What operating system are you using ?


dl65 Quote

cam_s1..... Do you have any idea which file you deleted ?
Have you tried to boot up in safe mode ?
What operating system are you using?

Yes I know exactly which file i deleted (and what directory it is located in)
Yes I have tried to boot in safe mode but it comes up with the same MESSAGE as when trying to use normal mode
Operating system: Windows 98 Second Edition

EDIT: by the way the file is: C:\WINDOWS\system\VMM32\IOS.VXD

Another solution could be by someone else posting this file (in a ZIP file) so I could copy it to its original location and hope that it works.Before you attempt to recover a file from the Recyle Bin please READ this.

You cannot recover your file using its original path/filename as it will have been renamed.

Try running SFC from the command prompt, it might work.

Good luck

Yes it WORKED. thanks for that info on the recycle bin.

I opened the directory of the 'hidden' recycled folder and the file was sitting right there, so I copied and renamed back to its orginal place and eureka! it workedCam_s1 - thanks for getting back to us with your good news, most posters don't come back to let us know if our suggestions were successful or not.

D...
6476.

Solve : MS-DOS Corrupted??

Answer»

Hello Everyone. This is my first time posting here, im having some rather minor problems with my computer that just keep bugging me. I have looked EVERYWHERE, looked at every tutorial, called Microsoft and Dell numerous times, looked on every computer forum imagninable...nothing.
So, i find myself here.

I am using a Dell Dimension 2400, Running MS-DOS(or CMD??) Version 5.1.2600.
The problem is, CMD will not seem to recodnise alot of commands, i believe it is corrupted but...i am not sure exactly how to fix it. I was thinking of mabey GETTING a hold of MS-DOS 5.0, that i can do from bootdisk.com but im afraid to install anything that isnt 100% compatible...i have no idea if it is compatible or not with my computer.

Description: Ipconfig, and Ping will not work in CMD. I just get an error saying: "____(Ping, Ipconfig) Is not recodnised as an internal or external command, operable program or batch file." However, DIR or Exit will work, so that tells me its not completely screwed.

So, what can i do to fix?
And,incase this helps to figure out the problem...i tend to download alot of stuff onto this computer, so mabey will all my downloads from not completely trustable sources...i got a virus or somthing along the way. I do not remember when this started, as i didnt use CMD until now. I tried doing a System Restore to one month ago with no luck. I also ran spybot, and AVG Virus scan, with few results(all were fixed).


Thank you!
Quote

Version 5.1.2600
sounds like an XP machine. Check your path by entering path at a command prompt. Make sure the C:\Windows\System32 directory is included in the path.

If not you can add it permanently by right clicking My Computer==>Properties==>Advanced==>Environment Variables and then editing the PATH in the System Variables section.

It's not the downloading so much as executing the downloaded files. Whatever you do, do not use any programs from a MS-DOS 5.0 disk. The reason some programs work and others don't is some commands are internal to the CMD processor and others are external files which CMD cannot find.Quote
Quote
Version 5.1.2600
sounds like an XP machine. Check your path by entering path at a command prompt. Make sure the C:\Windows\System32 directory is included in the path.

If not you can add it permanently by right clicking My Computer==>Properties==>Advanced==>Environment Variables and then editing the PATH in the System Variables section.

It's not the downloading so much as executing the downloaded files. Whatever you do, do not use any programs from a MS-DOS 5.0 disk. The reason some programs work and others don't is some commands are internal to the CMD processor and others are external files which CMD cannot find.
Sorry, i forgot to add, the computer is running XP.
When i typed in path, it said...
"PATH=%SystemRoute%\System32;%SystemRoute%;%SystemRoute%\System32\Wbem"
Then there was alot of other stuff.
So, is that ok? Or is that not the right one?

So, where can i find these external files?
I was hoping i could atleast get "ping" and "ipconfig" working for now.Is this the English version of XP? If not all bets are off.

Quote
"PATH=%SystemRoute%\System32;%SystemRoute%;%SystemRoute%\System32\Wbem"

Not sure, but if you run set from the command prompt I'm pretty sure you will not find a variable called %systemroute%.

Try changing %systemroute% to %systemroot%\system32

If you run a DIR command from the c:\windows\system32 directory you should find PING and IPCONFIG. The PATH variable sets up a directory search order for CMD to follow when LOOKING for programs and the PATH must be synchronized with the variable names in the environment or hardcoded.

Hope this helps. 8-)Yes, it is the english version of XP, or i would suppose so...seeing as everything is written in english


Quote
If you run a DIR command from the c:\windows\system32 directory you should find PING and IPCONFIG.
Ok, so, i typed in dir C:/windows/system32 So many things actually came up that it would not let me scroll up to view them all However,if i clicked the scrollbar, i could stop it from scrolling, i did that and found ipconfig.exe as well as ping.exe thats what i needed im GUESSING?




However, i did not understand this at all:
Quote
The PATH variable sets up a directory search order for CMD to follow when looking for programs and the PATH must be synchronized with the variable names in the environment or hardcoded.

Hope this helps.

So...what should i do now?

I apoligize for being such a noob Im trying here.

This is what came up when i typed in set...mabey this will do you more good then its doing me.



Thank you so much.


Also,i went into system 32, found ipconfig.exe and ping.exe and clicked as to run, and they still do the same thing...cmd pops up for mabey half a second(NO time to read what is written,but there was somthign there) and EXITS, same with ping. It seems to be doing this for alot of(not all) .exe programs in system32.
Your path path=%systemroot%\system32 and your systemroot=C:\windows statements check out just fine. When the CMD environment is setup the symbolic %systemroot% will resolve to c:\windows and the path will be set to c:\windows\system32.

Using windows explorer and doubleclicking any command found in system32 will open a cmd window, run the command and then close the window. The same result will occur if you type in a command from Start==>Run.

Are you opening a CMD window and then typing the command (IPCONFIG or PING) from the prompt? If you type path at a command prompt, does %systemroot% get expanded to c:\windows?

A bit flustered why CMD cannot find valid commands. :-?

Quote
Your path path=%systemroot%\system32 and your systemroot=C:\windows statements check out just fine. When the CMD environment is setup the symbolic %systemroot% will resolve to c:\windows and the path will be set to c:\windows\system32.

Using windows explorer and doubleclicking any command found in system32 will open a cmd window, run the command and then close the window. The same result will occur if you type in a command from Start==>Run.




Tried it from RUN. Like i said previously, the window opens for .5 sec and says somthing then exits. I see that it said somthing...however it exited far to fast to read.

Quote
Are you opening a CMD window and then typing the command (IPCONFIG or PING) from the prompt? If you type path at a command prompt, does %systemroot% get expanded to c:\windows?

A bit flustered why CMD cannot find valid commands. :-?




Weird huh? Everything seems to be in working order, yet nothing works
Could it be a corruption with cmd itself? Just having issues executing .exe files?Very weird. Microsoft turned up symbolics not being able to get resolved due to dependencies...which I don't see any in your case.

The easiet way to fix this would be to hardcode the directory names in the environment; the ones in question are all pretty standard anyway.

Right click My Computer==>Properties==>Advanced==>Environment Variables

Edit the PATH variable in the System Variables section by replacing occurances of %systemroot% with c:\windows. Retain the same punctuation; spelling counts; and values are case insensitive.

Good luck. 8-)Quote

Edit the PATH variable in the System Variables section by replacing occurances of %systemroot% with c:\windows. Retain the same punctuation; spelling counts; and values are case insensitive.

Good luck. 8-)
I SWEAR YOU ARE JESUS!
That did it, first shot. No wonder they made you a mod...perfect!!!!!!!!!!
Man,im such a computer geek! Well,it works fine now! Thank you so much for your help, honestly!!
I may be back again with other computer problems, and ill read...but i probabley wont post much, seeing as far as computer softwhere, im a noob

Thanks a bunch!
Sincerly,
Adam
6477.

Solve : How to close another program from Dos Batch file?

Answer»

Instead of the boring beep, I wanted to ADD C:\WINNT\Media\notify.wav to my batch file to notify me when the process is complete. After the wav sound has PLAYED, is there a WAY for me to close the window for wmplayer.exe? Is there a way to send "Alt+F4"?

I tried the FOLLOWING items individually without success.

C:\WINNT\Media\notify.wav /c (only closes dos window, not wmplayer.exe)

tskill wmplayer.exe (I receive the reponse "This utility NEEDS terminal services to be running. What is terminal services?)
You can use the "kill" command from the ressource kit.

hope it helps
uli

6478.

Solve : USB keyboard on DOS?

Answer»

Hello everyone,

i was trying to refomrat the PC and INSTALL XPSP2 using an auto-boot CD...after inserting the CD and restarting the COMPUTER,the "press any key to boot from CD" appeared but nothing happend when i pressed a key...i tried to ACTIVATE the USB keyboard in the startup setup menu..but the keyboard was
of no effect ...so i couldn't change the option...my questioin is: how can i reformat a PC with a USB keyboard knowing that it is not ENABLED in DOS???

thanks..Some computers do not OFFER that, but check in the BIOS.

That is the advantage of the uncool old-style PS/2's. They always work! ok man i will..thx

6479.

Solve : dos (win98)?

Answer»

hi master's
iam useing software called YH this is for CNC maichine
this software is in the form of board it is instaled in isa slot
and another board called EPROM board it is also in isa slot . eprom board consits 21 file like command.com confic .sys autoexe.bat and yh.exe
when i copy that 21 FILES and paste in some folder in win98 os . i had removed
eprom board now only software board is present
when i open that yh.exe file my software works good.
but when i reboot pc in dos mode and and typed yh.exe file that software opens but it shows erorr message mouse drive not instaled
after EDITING confic.sys file mouse works after some time erorr message comes that is "MEMORY OUT OF USE" what to do
can some one help me.
i wil be thankfull to them.........What happens if you leave the EPROM board installed instead of removing it :-?

Please post the [highlight]exact[/highlight] error message you get and confirm the filenames on the EPROM.ups can 't be used. due to power failure frquently eprom board fails
it is worth about 10,000/-


those 21 files are:- Amouse.exe, Autoexec.bat,Userauto.bat, Cp.exe, Emm386.exe, Mp.exe, Setup.exe, Yh.exe, Egavga.bgi, Litt.chr, Pager.chr, Trip.chr, Ccpromp, Font.gph, Yhprn.grp, Command.exe, Code_3b.pun, Config.sys, Himem.sys, Ramdrive.sys & Romram.sys.
this board ver 6.2


ERORR message is 'MEMORY OUT OF USE '

it is posible for me can any one help me it is very important
Sorry about the delay but I really don't have a solution for your problem. The only reference I have found for YH.EXE is that it is malware and this is OBVIOUSLY not so in your case. The error message looks as if it's being generated by the application, not by your O.S. Can you REFER the problem to the eprom/program supplier for clarification :-?

6480.

Solve : Cannot find FCBS?

Answer»

Hi,
I try to use an old MSDOS-program in W98. The program ASKS for SCBS=40,40 in the CONFIG.SYS and I have not installed MS-DOS.
I owe MS-DOS 6.0 and searched all 4 floppys for SCBS and cannot find it.
It ought to be there since MS-DOS 3.1 but no SCBS even on my friends floppys MS-DOS 6.2 and 6.22.
How come?
Thanks, KeesFCBS (FILE control BLOCKS) is a setting not a file. Edit your CONFIG.SYS file and add the statement FCBS=40 You will need to reboot for the setting to take effect.

DOS uses this setting to reserve space for the data structures holding information about OPEN files.

Good luck. 8-)

Hi Sidewinder,
Thanks for the answer but no, the program has a "FCB-test" and still reports the missing FCBS.
Does FCBS work even without installing MS-DOS, like in my CASE?
I have only W98SE on my computer.
Thanks, KeesI couldn't find any info on a FCB-Test. What old MS-DOS program are you trying to run? The program must be ancient to require file control blocks.

Quote

Does FCBS work even without installing MS-DOS, like in my case?
I have only W98SE on my computer.

You do indeed have DOS on your system. In fact Win98 runs on top of DOS. I also recall an option to restart a Win98 system in MS-DOS mode. Whether you boot into Win98 or DOS in full screen mode, the CONFIG.SYS file is processed and FCBS defaults to 4 if not present.

Did you put a FCBS=40 statement in your CONFIG.SYS file? Did you reboot? What was the SCBS=40,40 in your original post all about?

8-)



It is a very old Dutch program for bookkeeping and has a test to check the settings for share and fcbs.
It's OK now because I used the config.sys in C: to add scbs but it ought to be config.sys in Windows\system32 actually.
So, it works and thanks for the help!
Kees
6481.

Solve : How to set a variable with the current path?!?

Answer»

I'm developing an APPLICATION and i need to SET a variable with the current path for that aplication (it can be anywhere in the computer) after that i have to invoke the application itself.

There is a way to set a variable with the current path for an aplication?

I have tried desperate combinations like these:
CHDIR > SET APPLICATION_PATH
SET APPLICATION_PATH | CHDIR :-/

I'm not experienced with bat programming so any help would be apreciated

Thanks in advance for any helpwhats wrong with the %CD% variable ?Not sure what you're looking for, but after deciding where your application lives, your batch file can set the path pointer:

Code: [Select]set path=c:\yourdirectory;%path%
yourprogram

Some programs (you would know since your developing it ) need external components for the program to run, in which case this METHOD MAY be preferable:

Code: [Select]cd \yourdirectory
yourprogram

Good luck. 8-)ikanriu,

I think what you want is:

%~dp0 - will resolve to the drive and path of the batch
%~f0 - will resolve to the full QUALIFIED name of the batch

So that the following will set the APPLICATION_PATH variable to the path of the batch and then run the batch.

Code: [Select]SET APPLICATION_PATH=%~dp0
"%~f0"DOS IT HELP? Um....... how about this?

Code: [Select]SET CurrentDirectory=%cd%
Replace "CurrentDirectory" with the variable name of your choice.

6482.

Solve : Creating Text Files using DOS?

Answer»

Hi, I was just wondering if it's possible to create some sort of batch file that will create a text file and allow me to insert text into that file after it has been created?

Just trying to automate some manual processes.

Thanks,
PatrickQuote from: pbisaillon on May 15, 2007, 11:46:30 AM

Hi, I was just wondering if it's possible to create some sort of batch file that will create a text file and allow me to insert text into that file after it has been created?

Just trying to automate some manual processes.

Thanks,
Patrick

You use the echo command in a batch file, and follow it with redirection, so that instead of echoing text to the screen, it is redirected to a file.

For example:

echo Some text here &GT; textfile.txt


Would create a file named textfile.txt and in it would be Some text here
If the FILENAME textfile.txt already existed, it would be overwritten.



Or:

echo more text here >> textfile.txt

would not overwrite filename of textfile.txt, but would append
more text here to it.


I hope this helps.

Works perfectly..

Is it possible to add a paragraph of text rather than a single line? I realize that I'd have to put ECHO texttext >> text file.txt on each line, but are there parameters I can set for the entire blog?

IE: ECHO "Multiple lines of text" >> "text file.txt"

Thanks..
PatrickQuote from: pbisaillon on May 15, 2007, 01:48:54 PM
Works perfectly..

Is it possible to add a paragraph of text rather than a single line? I realize that I'd have to put ECHO texttext >> text file.txt on each line,

Right.

Quote
but are there parameters I can set for the entire blog?

IE: ECHO "Multiple lines of text" >> "text file.txt"


Off the top of my head - no.
Perhaps SOMEONE else will come along and post to confirm that.



Are you working in 'dos' command line under WinXP? or real DOS?
I ask because I'm reminded of something else - related, I suppose.

Check out:
http://home.mnet-online.de/horst.muc/wbat32.htm
and look for ClipText 1.3
Could that be utilized in whatever job you are working on?


If you had a ready prepared text file you could TYPE it to another text file.

type file created on %date% at %time% > newtext.txt
type C:\fixed\fixed-paragraph1.txt >> newtext.txt
type c:\fixed\fixed-paragraph2.txt >> newtext.txt

etc

This the standard way of "echoing multiple lines of text" in a batch file and the only way I know of doing it without explicitly including them.




pbisaillon:

The type command completely slipped my mind.

Try contrex's suggestion, and let us know if it does what you NEED.


6483.

Solve : HELP with batch FOR loop?

Answer»

Hello, I'm a week into learning batch files and I'm stuck on a few lines in a new file that I'm trying to write.

Here's an except from my code: (I'm having trouble with only 3 lines of it however: the TWO "set" lines and the "if" statement line.

Can someone give me some help with this?

for /F "delims==" %%d in ('type "%topfolder%\Assign1\dates.txt"') do (

cd %topfolder%\Assign1\%%d

dir /ad /b > locations.txt

for /F "delims==" %%l in ('type "%topfolder%\Assign1\%%d\locations.txt"') do (

for /F "delims==" %%s in ('type "%topfolder%\site files\sitefiles.txt"') do (

set templ=%%l
set temps=%%s

if %templ:~1,2% == %temps:~2,2% (copy %topfolder%\site files\%%s %topfolder%\%%d\%%l)

)
)
)You've been posting this at AfterDawn, haven't you? Maybe you'll get a better CLASS of help on here...

Put this at the beginning of your batch file

SETLOCAL ENABLEDELAYEDEXPANSION

for /F "delims==" %%d in ('type "%topfolder%\Assign1\dates.txt"') do (

cd %topfolder%\Assign1\%%d

dir /ad /b > locations.txt

for /F "delims==" %%l in ('type "%topfolder%\Assign1\%%d\locations.txt"') do (

for /F "delims==" %%s in ('type "%topfolder%\site files\sitefiles.txt"') do (


set templ=%%l
set temps=%%s


(1) You cannot do this in a loop.


if %templ:~1,2% == %temps:~2,2% (copy %topfolder%\site files\%%s %topfolder%\%%d\%%l)

You have to do this.

You don't need the rackets around the if statement, I think.

if !templ:~1,2! == !temps:~2,2! copy %topfolder%\site files\%%s %topfolder%\%%d\%%l


)
)
)Yes I have been posting this on AfterDawn. I'm new to posting on forums, and have been looking around. I couldn't believe at first that there were just people out there just helping other people with problems like this! This is something I'm glad I found!

Anyways back to my problem.

I have made the changes you have suggested. The program hasn't STARTED to work yet... so I have 3 further q's:

1) Is the addition of SETLOCAL ENABLEDELAYEDEXPANSION to take care of my problem with the two "set" lines?

2) I recieve the following error in the cmd prompt: "2! was unexpected at this time"
Do you have any further advice?

3) And finally, is it possible to disregard the set statements and just use the two variable %%s and %%l in the if statement?

Thanks!Perhaps you also need to know that the variables %%s and %%l are of the form: I17CI and I17CI.site, respectively.Try quotes in these places, aweathe...

if "!templ:~1,2!" == "!temps:~2,2!" copy "%topfolder%\site files\%%s" "%topfolder%\%%d\%%l"

PS How is Indochine Hey contrex,
Ya I would have used the same user name with AfterDawn too had they allowed longer usernames. haha And yes Indochine is great! he has been a huge help so far! Of course if you or someone else is able to help me solve my problem then I'll make sure he knows he doesn't need to spend any more time on it.

So back to my script! :

I tried the quotes.. without success. I think if I could make the two "set" statements work properly I would have no problems. Do you know why these two statements make no change to the variables templ and temps? Ie: the variables don't get set! Can you tell me why?

thanks I saw what you wrote on Afterdawn about the two files. It is different from what you wrote here.

AfterDawn
Quote

the ordering of the filenames is always the same for the two list;
first file:
one letter, two figures, two letters

second file:
two letters, two figures and ".site"

here
Quote
Perhaps you also need to know that the variables %%s and %%l are of the form: I17CI and I17CI.site, respectively.

The string slicing attempts with temps and templ make more sense if the former is the true case.

Quote
Ie: the variables don't get set! Can you tell me why?

Variables in FOR statements are EVALUATED once: before the command is
executed. Changes made to the variable aren't visible inside the
command.

You can use SETLOCAL and ENABLEDELAYEDEXPANSION and variables with ! instead of % to get around this.

If you (a) examine (b) ponder and (c) run this code I'm sure you'll get the idea, and maybe if you incorporate elements of it in your code, you can progress a bit further, and we can see if your COPY OPERATION is performed OK.

Code: [Select]
@echo off
REM put this at the start of your batch
SETLOCAL ENABLEDELAYEDEXPANSION

echo M13AZ> locations.txt
echo G99QR>> locations.txt
echo I17CI>> locations.txt

echo QP44.site> sitefiles.txt
echo FS15.site>> sitefiles.txt
echo JM17.site>> sitefiles.txt

for /f "delims==" %%l in (locations.txt) do (
for /f "delims==" %%d in (sitefiles.txt) do (

REM set environment variables
REM as copies of FOR metavariables
REM this is allowed in a loop
set templ=%%l
set temps=%%d

REM but if you use them with percent signs
REM they will seem empty
REM and so an attempt to slice
REM them will give empty results
set percentnum1=%templ:~1,2%
set percentnum2=%temps:~2,2%

REM however this works
REM using delayed expansion
set exclamnum1=!templ:~1,2!
set exclamnum2=!temps:~2,2!

REM let's see the contents of the variables
REM 2 and 4 will be blank as explained above
echo 1 %%l %%d
echo 2 %templ% %temps%
echo 3 !templ! !temps!
echo 4 %percentnum1% %percentnum2%
echo 5 !exclamnum1! !exclamnum2!

REM now for string comparison
REM this works
if !exclamnum1! == !exclamnum2! (
echo MATCH
)

REM or your desired action
REM if !exclamnum1! == !exclamnum2! (
REM copy "Path\file" "folder"
REM )

REM However you can't do this, the batch crashes
REM with the message 2! was unexpected at this time
REM if !templ:~2,2! == !temps:~1,2! echo match

echo.
)
)
REM END OF CODE


Here is the output:-
Code: [Select]1 M13AZ QP44.site
2
3 M13AZ QP44.site
4
5 13 44

1 M13AZ FS15.site
2
3 M13AZ FS15.site
4
5 13 15

1 M13AZ JM17.site
2
3 M13AZ JM17.site
4
5 13 17

1 G99QR QP44.site
2
3 G99QR QP44.site
4
5 99 44

1 G99QR FS15.site
2
3 G99QR FS15.site
4
5 99 15

1 G99QR JM17.site
2
3 G99QR JM17.site
4
5 99 17

1 I17CI QP44.site
2
3 I17CI QP44.site
4
5 17 44

1 I17CI FS15.site
2
3 I17CI FS15.site
4
5 17 15

1 I17CI JM17.site
2
3 I17CI JM17.site
4
5 17 17
MATCH






IT WORKS!!!
6484.

Solve : An all deleting thing..?

Answer»

Hey, i'm looking for something to delete every single file of a the "log" extension, in every PATH and on every HDD..

I've seen this somewhere before a long time ago, though this was considerd a virus ..

Any idea's ?
Well, this will delete all log files on your c: drive
for /f %a in ('dir /s/b c:\*.log') do del %a

I will leave you to work out how to iterate through all your drives
GrahamHehe Thanks i'll look into that.. (no idea how yet)Hmm well when i tryd to printscreen quick before it closes with even the pause command in it ..,
I get this:



Any help would be appreciated.You want to delete all MP3 files?

Anyway, you are missing some characters in your statement. If you are REALLY sure you want to delete all MP3 files on your C: drive, the syntax for the command line (slightly modified version of gpl's code) would be:
Code: [Select]for /f "delims=" %a in ('dir /a /s /b C:\*.mp3') do del "%a"For your X: drive, it would be:
Code: [Select]for /f "delims=" %a in ('dir /a /s /b X:\*.mp3') do del "%a"If you are executing the command from a batch file, you need to double up on your %
To automatically run on all local drives, provide your OS and I'll provide the code.Hey yea i tested it with some mp3 on a new partion to see if it worked,
Im using Windows XP

And for the missing character well yea.. i put it in right but the output was just weirdSo it is working now?Hmm it atleast ran yea, though it sayd access denied on each file, and yea im running it from a batchWhat happens if you try to delete one of the same files manually from the command line? I assume you get the same error?

Assuming that you do get the same permission denied error, see if it is an NTFS permission (file properties -> security tab) issue, or a file attribute issue (read only), or something else.

Once we have that problem figured out, you can either fix it from the OS, or we can ADD code to your statement to work around the issue in your script.I'm sorry to have made you post again, i dont know what i did but i did it, it works
Thanks a lot for the help !

only thing LEFT now is every drive

6485.

Solve : Using MS-DOS and batch files to enable or disable the wireless card.?

Answer»

I can't SEEM to figure out what DOS command I can USE to enable or disable my wireless CARD in Windows XP.

Thank you
-potentatehttp://softwarecommunity.intel.com/isn/Community/en-US/forums/30234252/ShowThread.aspxThank you for the quick reply. It was very helpful.

Thanks
-Potentate

6486.

Solve : How do I cancel / remove dos command Chkdsk C:/ f?

Answer»

I'm running Windows XP Professional SP2. I was doing some disk maintenance and stupidly issued the command "Chkdsk C:/ f" in the Command Prompt while in Windows. Now at startup, my system runs checkdisk but hangs up and doesn't finish. This occurs in every normal boot.

Any simple way to remove this command? Any ideas would be APPRECIATED!

Thanks,

tom easyIf CHKDSK hangs, then that is something to look into further. I would not just ignore that issue. How long have you waited to see if it is really hung?

Anyway, to answer the question in your post, try this link:
http://support.microsoft.com/kb/831426
It wasn't stupid to issue the command "chkdsk C: /f" while in Windows. I do it every time I want to fix or diagnose the system volume, because the only way Chkdsk can get access to it is at boot time. It is normal practice and should not be giving you any problems.

Did you SCHEDULE it because you thought there might be a PROBLEM on the disk, or were you just experimenting?

Maybe merely seeking to remove the check would be the same category of mistake as asking "How can I stop that pesky fire alarm from making such a noise?".

When you issued the chkdsk /f command it had the effect of "setting the dirty bit" on the volume and what you could try to do is unset that bit.

However, I would be very concerned indeed to know why it is hanging! It suggests a HDD fault and MAKES me think about backups, replacement, etc...

It might be handy to know at what stage (they have numbers) the disk check hangs...

Every time Windows XP starts, autochk.exe is called by the kernel to scan all volumes to check if the volume dirty bit is set. If the dirty bit is set, autochk performs an immediate chkdsk /f on that volume. Chkdsk /f verifies file system integrity and attempts to fix any problems with the volume. It is usually caused by a hard shut down or a power loss during a write operation on that particular drive.

(I take it you are getting a message at startup saying that a disk check will start in X seconds unless you press a key?) If so, a diagnostic step you can take is:-

when you get into Windows click Start> Run> bring up a command prompt by typing in "CMD" and type "CHKNTFS /X C:" The X tells Windows to NOT check that particular drive on the next reboot. At this time, manually reboot your computer, it should not do a Chkdsk and take you directly to Windows.

Then click Start> Run> bring up a command prompt by typing in "CMD" and type " fsutil dirty query c: ". This queries the drive, and more than likely it will tell you that it is dirty.

Thanks for your suggestions. On bootup, chkdsk goes thru the fist of 5 stages no problem, then hangs on the 2nd stage, and state "0 % completed." I've waited quite a while but it never proceeds.

Yes, I'm getting the message that disk check will start in 10 seconds unless I press a key. I'll try the "CHKNTFS /X C:" command and reboot.

Although my initial command was CHKDSK, not CHKNTFS, which may be part f the problem.I am assuming that the volume in question is an NTFS one?
Yes, it is NTFS, so my initial command was in error. I haven't yet had time to re-boot but will let you know what happens.Quote from: tom easy on May 18, 2007, 03:29:53 PM

Yes, it is NTFS, so my initial command was in error.

Was it? That's news to me. Chkdsk /r and /f are both legal for NTFS.

6487.

Solve : HELP with running SSH from batch file?

Answer»

hello,

I would like to KNOW if the following tasks are possible from within a batch file:

1) Open an SSH connection on a 'typical' computer with WinXp, and have this computer connect to a Mac computer. (this step I'm able to do in the cmd, it's the next 3 I don't know how to do)

2) Copy files within the SSH transfer window from a large group of subfolders on the WinXP computer to a specific path on the Mac.

3) Run a program on the Mac to decompress these files (a program that can only be run on a Mac, and thus the SSH requirement).

4) And finally copy the decompressed files back through the SSH window to the same folder on the WinXP computer.

I hope this has made some sense! There are ALOT of iterations to be done.This is going to depend on your SSH client. Which SSH program are you using? Does your SSH program support file transfer?my SSH client is SSHSecureShellClient-3.2.9 and yes it SUPPORTS file transfers

I have preformed transfers before. The way it is set up at the moment is I just open the ssh program and click a profile then put in a password. From here I can transfer files, ect between the two computers.read the manual that comes with your version of SSH client. when you INSTALL, you should have command line version of SCP/SFTP. they can be used for file transfer automation.

6488.

Solve : MS-DOS Text Manipulation Question?

Answer»

Hey all,

I am trying to manipulate some text using a batch file. I need to find a specific string of text then append text right after it. It is for a script to code in multiple printers in client computers for a specific PROGRAM that uses a .ini file to find printers.

I can use FIND to get the string, but how do I append to it right after it?

Thanks.go through the text file in a FOR LOOP.

FOR /F "delims==" etc (

Test each line with eg
echo %%L >> output.txt

If it gets found do your append
echo %%L | find "some text" > nul && echo appended.txt >> output.txt

did you want to go around again?

)

Ok awesome! I will try this. Thanks for the help.[thought about it a bit more]

go through the text file in a FOR loop.

FOR /F "delims==" etc (

copy each line as you go
echo %%L >> output.txt

Test each line and
If it gets found do your append

echo %%L | find "some text" > nul && (
echo some appended text >> output.txt
echo more appended text >> output.txt
echo more appended text >> output.txt
etc...
)

did you want to go around again?
Or did you want to stop here?

)
and more...

Code: [Select]@echo off
REM make example files
echo apples> "fruit.txt"
echo oranges>> "fruit.txt"
echo lemons>> "fruit.txt"
echo bananas>> "fruit.txt"

echo --- are yellow> "append.txt"
echo --- and bitter>> "append.txt"
echo --- and citric>> "append.txt"

if exist "output.txt" del "output.txt"

for /f "delims==" %%F in (fruit.txt) do (
echo %%F >> "output.txt"
echo %%F | find "lemons">nul && (
type "append.txt" >> "output.txt"
)
)
type "output.txt"
pause

output...

Code: [Select]apples
oranges
lemons
--- are yellow
--- and bitter
--- and citric
bananas
Press any key to continue . . .
you can try edlin:
1)create a edlin command file with these 2 lines using an editor that can interpret Ctrl-Z
Code: [Select]1,#Roldstring&LT;ctrl-Z>stringnewstring
e
the above says to substitute your search pattern with string+newstring
2) save it as test.ed
3) then from command line
Code: [Select]C:\> edlin yourfile < test.ed
edlin CREATES a bakup of your original file, and "inserts" a new string after the search string.Oh wow edlin!!!! Takes me back 25 years!!! (Is this a joke?)
Quote from: contrex on May 19, 2007, 02:14:21 AM

(Is this a joke?)
what do you think?Quote from: ghostdog74 on May 19, 2007, 02:59:35 AM
Quote from: contrex on May 19, 2007, 02:14:21 AM
(Is this a joke?)
what do you think?

You can never tell in this place
Quote from: contrex on May 19, 2007, 03:01:40 AM
Quote from: ghostdog74 on May 19, 2007, 02:59:35 AM
Quote from: contrex on May 19, 2007, 02:14:21 AM
(Is this a joke?)
what do you think?

You can never tell in this place

well..
sample input:
Code: [Select]C:\TEMP>more input
This is a sample text file
to show that using edlin is a joke.

sample edlin command file:
Code: [Select]C:\temp>more test.ed
1,#Ra joke<ctrl-Z>not a joke
e

output:
Code: [Select]C:\temp>edlin input < test.ed
End of input file
*1,#Ra joke^Znot a joke
2: to show that using edlin is not a joke.
*e

final result:
Code: [Select]C:\temp>more input
This is a sample text file
to show that using edlin is not a joke.

I never intended to convey that the suggestion to use Edlin was a joke, in the sense that it wouldn't work. What I meant was that as someone who has been using PCs since 1981, I was so glad when better tools than Edlin came along! Edlin was created by Tim Paterson in two weeks in 1980, and was expected to have a six-month shelf life. Use of Microsoft's Edlin in today's environments is somewhat limited as it does not support long filenames. When attempting to describe Edlin's features, words like "crude" and "rudimentary" are often chosen. (Especially by me.)


Quote from: contrex on May 19, 2007, 03:21:33 AM
I never intended to convey that the suggestion to use Edlin was a joke, in the sense that it wouldn't work.
glad to hear that.
Quote
What I meant was that as someone who has been using PCs since 1981, I was so glad when better tools than Edlin came along!
edlin was just part of a myriad of tools that was available back then. sorry but i am curious , out of the box back then, can you suggest to me what better tools than edlin to do automated string manipulations like this? delete line number 10 to 15 for example?


Quote
Edlin in today's environments is somewhat limited as it does not support long filenames.
so just keep it short? FWIW, this should not be the reason for not using it when the need arises.

Quote
When attempting to describe Edlin's features, words like "crude" and "rudimentary" are often chosen. (Especially by me.)
well, batch is "crude"/"rudimentary" to me too if i am comparing against better tools to do the task at hand.
however, if i just want to move/copy files, i can quickly write in batch. its quick and fast. Its the same when i decided to use edlin.
6489.

Solve : Fun with dos..... help!?

Answer»

Nice to see you back, Lordoftheplat.
Still have that oddly big picture in your signature i see.....

QUOTE from: lordoftheplat on May 19, 2007, 08:54:10 AM

lol how many people have been trying
to do prank on this forum man....
See, pranks are fun.....harmless pranks......
I have 20mb of joke programs on my memory stick that do things like shake the screen or invert the colors of the screen. So funny You'd need to go to the hospital if you ever tried them on mine, dudeoxide.
Wow, you actually spared my LIFE. I thought you would just kill me off right there

Of course the joke programs aren't permanent (sadly)Actually, when I worked in an electronics factory, we used to scrape the polarity marking (a red blob) off electrolytic capacitors and re apply on the OPPOSITE side with a red INDELIBLE marker and place them in other peoples component stocks. They'd get assembled onto boards and when circuit testing time came, they'd explode. COULD have blinded someone, but hey...
i like the exploding part...but not the blinding part...

Gotta wear shades --> Quote from: contrex on May 19, 2007, 09:24:47 AM
Actually, when I worked in an electronics factory, we used to scrape the polarity marking (a red blob) off electrolytic capacitors and re apply on the opposite side with a red indelible marker and place them in other peoples component stocks. They'd get assembled onto boards and when circuit testing time came, they'd explode. Could have blinded someone, but hey...


Much less harmful than opening someone's CD Tray...see why we don't do it ? ?
6490.

Solve : CD command?

Answer»

he can use that to cd to his previous location.Quote from: WillyW on May 19, 2007, 09:36:59 AM

Quote from: contrex on May 19, 2007, 09:31:25 AM
Quote from: WillyW on May 19, 2007, 09:26:50 AM

echo. prints a blank line to the screen.


Yes I did know that.





and yet you asked anyway? .... odd.



Maybe English is not your first language? I meant, "What is the reason why you have put a period after the echo command?", not "What does a period do after an echo command?"

Lol, what does it matter.
I find it easier for me to use 'echo. text' than 'echo text'
You dont have to use the period for %cd:~20,0% but i did coz i could......Quote from: Carbon Dudeoxide on May 19, 2007, 09:38:24 AM
he can use that to cd to his previous location.

Oh right. So I'm in D:\My Folders\*censored*\Mom don't look in here\Babes\Redheads and I

type CD d:\

So now I'm in d:\

I type your command and it cuts the last 20 characters off the directory name, which is actually 3 characters long, so I end up with an empty string, which ECHO interprets as a request to SHOW ECHO status, so it SAYS "ECHO is on", and that GETS me back to my previous folder? Is that how it works?

That's a real clever DOS tip, dudeoxide! i WOULD nevah have thunk of that all on my lonesome!

well then you change 20 to a number that suits you.It's only useful if "where you were before" is a parent folder of where you are now. typing cd.. (enter) and then repeatedly recalling it with the up arrow would do the same thing.
Reinaker: You can use PUSHD and POPD.

For example, if you start off in
Contrex's directory of
D:\My Folders\*censored*\Mom
And you want to go to the directory D:\Foo, you could use the command
Code: [Select]pushd \FooThen to get back to the previous directory do
Code: [Select]popdOr if you wanted to go to C:\Documents and Settings you could use the command
Code: [Select]pushd "C:\Documents and Settings"Then to get back to the previous directory do
Code: [Select]popd
Another tip ... if you are writing a batch file that changes directories and it ends up leaving you in a directory used by the batch file instead of the original, you can use the SETLOCAL command. Example:
Code: [Select]@echo off
setlocal
cd \Temp
ren *.new *.oldIn this example the batch file would leave you in whatever directory you started in. Without the SETLOCAL command, the batch file would leave you in \Temp.
6491.

Solve : (solved)defragmentation at startup.(Pause for x many seconds?)?

Answer»

Here is the newer vesion:
Code: [Select]If %Quit%=1 GOTO Q1
If %Quit%=1 GOTO Q2
Exit
:Q1
Shutdown -s -f -t 25 -c "Sla al u gegevens op voordat de timer op 0 staat want dan zal de computer afsluiten!"
:Q2
Shutdown -r -f -t 25 -c "Sla al u gegevens op voordat de timer op 0 staat want dan zal de computer opnieuw opstarten!"
shutdown -s -t 01I forgot to post the end of the batch file srry for that.
But still can you give an answer on my question why you METHODE doesn't work?
By the way thanks for helping.Instead of pinging "1.1.1.1", you should ping either "localhost" or "127.0.0.1", like:
Code: [Select]ping localhost -n 5 >nul
Also add some sort of extra text in your string comparison which will reduce the possibility of errors or warnings if the user enters a blank value for "Quit". Also, use double equal signs (==), like:
Code: [Select]If {%Quit%}=={1} GOTO Q1
If {%Quit%}=={2} GOTO Q2
This is my newist version after editing those mistakes.
Code: [Select]TITLE Defragmenteren
@echo off
cls
echo Dit programma is gemaakt door JONAS Wauters.
echo Dit programma defragmenteerd C: en D: schijf.
echo Defragmentatie zorgt voor een optimaal gebruik van uw harde schijven.
Ping localhost -n 2 > nul
echo 5
Ping localhost -n 2 > nul
echo 4
Ping localhost -n 2 > nul
echo 3
Ping localhost -n 2 > nul
echo 2
Ping localhost -n 2 > nul
echo 1
Ping localhost -n 2 > nul
cls
echo Wat wil je doen NADAT het process voltooid is?
echo 1:De computer afsluiten
echo 2:De computer opnieuw opstarten
echo 3:Dit venster afsluiten en gewoon verdergaan met werken
:Retry
Set /P Quit=Typ (1,2of 3):
If {%Quit%}>3 GOTO error
Vol C:
defrag -f C:
If not exist d: GOTO e
vol d:
defrag -f d:
:e
if not exist e: GOTO f
vol e:
defrag -f e:
:f
if not exist F: GOTO g
vol f:
defrag -f f:
:g
If {%Quit%}=={1} GOTO Q1
If {%Quit%}=={1} GOTO Q2
Exit
:Q1
Shutdown -s -f -t 25 -c "Sla al u gegevens op voordat de timer op 0 staat want dan zal de computer afsluiten!"
:Q2
Shutdown -r -f -t 25 -c "Sla al u gegevens op voordat de timer op 0 staat want dan zal de computer opnieuw opstarten!"
shutdown -s -t 01
:error
Echo Dit is geen MOGELIJKHEID gevieve opnieuw te proberen.
GOTO Retry
Actually would it have worked on my way?
Again thanks for showing me my mistakes but isn't there a way to run this program at startup before the welcome screen?

Jonas
The only way I can think of to run the script before the Welcome Screen is Contrex's idea about using the Group Policy startup script. I think the GP startup scripts run before the Welcome Screen. I also think that if it is going to work, you would need to remove any prompts for the user, as there will not be a console to display any output. So if it were to work, you would have to change the script to something like
Code: [Select]defrag -f C:
defrag -f D:
defrag -f E:
defrag -f F:and it would defrag every time the computer booted. I think it will run as a process in the background, so you could still log in while it was defragging. The computer would probably run slow until the defrag was finished, unless you killed the process with a program like TASKMGR or TASKKILL.But F: is a removable disk and isn't always attached.
are you sure that it will not work if I use:
Code: [Select]defrag -f E:
defrag -f D:
defrag -f E:
if exists F: defrag -f F:Quote from: GuruGary on May 20, 2007, 12:38:17 AM

I also think that if it is going to work, you would need to remove any prompts for the user, as there will not be a console to display any output.
How do I have to do this?
I tryed it but I can't find any process My program is called "boot defragmentation.bat" but the only process I can find is "defrag.exe".

(edit)
Jonas The code you have should be fine the way it is written. Using the code you posted, you have already removed all prompts for the user.

The process you would have to end would be one or more of:
defrag.exe
dfrgntfs.exe
dfrgfat.exe

And you may have to end them as many as 4 times (once for each drive letter). Or better yet, let them run until they finish, or run the defrag command manually.OK thanks for all the help I really appreciate it.
Now it works fine.

Jonas
6492.

Solve : Batch file problem?

Answer»

I have a problem whenever i try to make BATCH file and GIVE him exit cammand it did not work any one can help me i try it on windows 2003 and windows xp or any one can make it for me or in an other program i am USING arp -s .... command Please help me



Thanks
Masroorwhat do you MEAN it did not work? What happens?

POST your batch file on here so we can see it.

i am using as like this

e.i
@echo
arp -s 192.168.0.17 00-11-22-33-44-55
exitSo it is getting stuck in the arp command?
when i try arp -s 192.168.0.22 00-00-00-00-00-00 it constantly repeat i waana only one time to run this command and close it automatically but i can'tThen you should talk to Network Administrator.


can you help! me ?I know nothing about arp.

Try this

start "" "arp" "-s 192.168.0.17 00-11-22-33-44-55"i am getting error from this command

6493.

Solve : chang name of START button?

Answer»

hi

i have a program to chang a name of start button temporary
but i need chang permanent on dos & windows
halp meeeeeeeeeeee
mayank Changing the text on the Start Button INVOLVES changes to both explorer.exe and the registry. It MAY also create issues with Ad-Aware and the Windows Search function.

If you are absolutely sure you want to risk this, check out Change Text on Start Button

Proceed at your own risk and make backups of everything you make changes to.

I'm just trying to figure out why you would want to do this.

I couldn't come up with a SINGLE one. Quote from: GX1_Man on May 20, 2007, 05:10:54 PM

I'm just trying to figure out why you would want to do this.

I couldn't come up with a single one.

I couldn't either, but it certainly is one of the more IMAGINATIVE ways to turn a PC into a brick. And sometimes that is a good thing.
6494.

Solve : Fdisk and Skandisk?

Answer»

Fdisk error MESSAGE is No fixed disk preasent. But when I run scan disk it says no errors on Drive. What does that mean? Is it possible for SCANDISK to work when Fdisk says no fixed disk preasent?

The system is older HP 63702 Then INSTALLING bootdisk into a: drive It asks with what type of support to start computer with. Then at the end of the BOOT it says that the FAT32 needs to be done

Tried to Fdisk then I got the error message.

there is CDrom FLOPPY, Zip, and 6 gig hard drive.How about a detail or two about the system, what drives are installed and why you are even trying to use fdisk? What got you to this point?

See below.

6495.

Solve : Boot disk commands?

Answer»

Can someone give me some pointers on MODIFYING a BOOT disk to launch a batch file automatically? I have a lot of COMPUTERS that I routinely format with aefdisk and I'd like to just be able to just put in my boot disk and not type in anything. I have a batch file on the disk that has my commands but I'm not sure how to set it up as either a menu (just in case) or have it just run the batch file after the system boots up. Any suggestions WOULD be great.

TIAI would edit the autoexec.bat file and add the batch commands you want executed to that. There is probably a way to get a yes or no to procede prompt but I'm not sure how to do that.

6496.

Solve : Get a substring from the file?

Answer»

I have one file 'filename.txt' which have contents like

SHCS112.txt
SHCQ112.txt
SHMSTR114.txt
CQCS113.txt
CSCQ114.txt

I have to read the contents and move it to different file according to their name.

For example, the name which is having "CS" in 3-4 range should be moved to another file

Example:

SHCS112
CQCS113
should be moved to cs_files.txt

similarly, the name which is having "CQ" in 3-4 range should be moved to another file
SHCQ112
CSCQ114
should be moved to cq_files.txt

I used findstr "cs" filename.txt> cs_file.txt
but it is reading

SHCS112
CQCS113
CSCQ114----- wrong out put

give me idea to move the files according to their name.Flying blind without a mention of an OS can be tricky, but this may work on your machine:

Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f %%i in (filename.txt) do (
set var=%%i
set var=!var:~2,2!
if !var!==CS echo %%i >> cs_files.txt
if !var!==CQ echo %%i >> cq_files.txt
)

You never mentioned where the MS file goes.

Good luck. 8-)I am using Windows XP operating system. The code that you have given is not working.

Code:

set var='SHCS112.txt'
set var=!var:~2,2!
echo %var%

Result:
!var:~2,2!

It does not take 3rd and 4th characters from that VARIABLE. My result should print 'CS'.
Please guide me to solve this issue.
Actually the code works fine on my machine, also XP.

Quote

set var='SHCS112.txt'
set var=!var:~2,2!
echo %var%

Where did the SINGLE quotes come from? Although they would not prevent the batch file from functioning properly there is no mention of them in the original post.

It should be echo !var! due to the delayed expansion

8-)Hi,
This is my screen shot of my command window.
------------------------------------------------------------------------
C:\>setlocal enabledelayedexpansion

C:\>set var=SHCS112.txt

C:\>set var=!var:~2,2!

C:\>echo !var!
!var!
-------------------------------------------------------------------------
My result is !var!

Please help me in solving this as I am new to WRITING Batch Script.






Cut and Paste this code into your favorite editor (notepad works just fine):

Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f %%i in (filename.txt) do (
set var=%%i
set var=!var:~2,2!
if !var!==CS echo %%i >> cs_files.txt
if !var!==CQ echo %%i >> cq_files.txt
)

Save the file with any name you choose but be sure to give it a .bat EXTENSION. You can then run the file you SAVED from the command line.

8-)Hi,

Thanks a lot for guiding me. Its really awesome. I got the exact result.
This is really a wonderful site which makes me do the task easily.

Thanks a lot!
Thanks a lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6497.

Solve : batch files in XP??

Answer»

Hi everyone...I was just trying to make a batch file to delete cookies from a system. I was forgetting that in XP the cookies are in the user directory and I'm having trouble figuring out what to do with this LINE.

Code: [Select]del c:\"Documents and SETTINGS"\Smitty\Cookies\*.txt
It works fine when I use it on my machine but what should I do to allow someone to use it on another machine with a different account name? Is it even possible with DOS batch files?

I've tried a wildcard with no luck...

Code: [Select]del c:\"Documents and Settings"\*\Cookies\*.txt
Does anyone happen to have a solution for this? I appreciate any help I don't believe wildcards will identify a directory STRUCTURE...you would have to customise it to each users directory naming structure.

patio. 8-)If you want to delete all the cookie files from all the users. you can use the /S switch of del command to go into subdirectories to delete the cookie files.For the current user only:
Code: [Select]del %homedrive%%homepath%\Cookies\*.txt
For all users (from a batch file):
Code: [Select]for /f "delims=" %%a in ('dir "C:\Documents and Settings" /b') do del "C:\Documents and Settings\%%a\Cookies\*.txt"
For all users (from a command line):
Code: [Select]for /f "delims=" %a in ('dir "C:\Documents and Settings" /b') do del "C:\Documents and Settings\%a\Cookies\*.txt"^ Thanks a lot...It works like a charm hei guys, I need to brows dirs recursively stoppind each TIME I find specific files (DEPENDING on their extension) is it posible to be done in a batch file? i need to run a program for everyone of them...

Thanks.

6498.

Solve : check if CD Rom is enabled or disabled?

Answer» HI...

I would LIKE to know if there is a way in which one can through a batch file find out :
1. if the CD ROM is enabled or disabled
2. If any of the USB ports are being used and if yes what are the peripherals they are attached to?

Please can someone help me out?Question 1:
This code checks if the driveletter in variable %CDROM% exists.
(If a CD is in the drive or not.)
I don't think it is possible to check the device with batch in the windows world.
The solution is a bit unfortunate.

hope it helps
uli

snip ----------

set CDROM=d
for %%x in (%CDROM%) do (
if exist %%x:\NUL (echo CDROM - Drive is active %%x: ) else (echo CDROM- Drive is not active)
)

set CDROM=

---------- snapHi,
You can check for removable drives with fsutil fsinfo drivetype. I.e. if the drive you want to check is D:\ then use:

fsutil fsinfo drivetype D:\

It might return:
D:\ - Removable Drive
D:\ - Fixed Drive
D:\ - Network Drive
D:\ - CD-ROM Drive
D:\ - RAM Disk Drive
or
D:\ - No such Root Directory

Or check all drives with a loop as described here:
http://www.dostips.com/DtCodeSnippets.php#_Toc141112837

USB drives would show up as "Removable Drive" I guess, just like Floppy Drives.
All this is not exactly what you are asking for but hope it still helps you in the one or other way.
Thanks a lot guys
it helped me a lot
6499.

Solve : batch file will not run from windows?

Answer»

My batch file will run fine if executed from the command prompt, but goes nowhere if executed from windows (start/run or DOUBLE click in windows exploror). When started from Windows it simply starts DOS and stops. Any help?POST your coding please...an example of batch file, display-dir.bat, that stalls:

c:
cd temp
dir

this simple batch file will run properly if executed from the dos prompt, however, if executed from Windows (either Start/Run or windows explorer) it opens a DOS window, but does not run.

All batch files respond the same way.

ThanksSimple .bat files run commands consecutively so your file gets to the end and exits before displaying the output of your dir command.

Just put a Pause command after the dirYour batch file does run, but it doesn't have any reason to stay open after it finishes executing your commands.

Just put a Pause command like dusty SAID or DIRECT the said output into a TEXT file.

6500.

Solve : Birthday?

Answer»

I want to make a program that remembers your birthday. In a extern file are the dates; for instance LIKE : Miki 07/06 . If you type in the program the date 07/06, i want the program to show : on 07/06, its miki's birthday

can someone give me a idea or script?
Microsoft has a habit of adding features to batch language with each new release of WINDOWS. Without knowing your OS, it's difficult to write a script that will run on your machine.

This may work:
Code: [Select]@echo off
set /p bdate=Enter Date mm/dd:
for /f "tokens=1-2" %%i in (bdate.txt) do (
if %bdate% EQU %%j echo It's %%i's birthday
)

bdate.txt would be the label of your external file.

Hope this gives you some ideas. 8-)Quote

Microsoft has a habit of adding features to batch language with each new release of Windows. Without knowing your OS, it's difficult to write a script that will run on your machine.

This may work:
Code: [Select]@echo off
set /p bdate=Enter Date mm/dd:
for /f "tokens=1-2" %%i in (bdate.txt) do (
if %bdate% EQU %%j echo It's %%i's birthday
)

bdate.txt would be the label of your external file.

Hope this gives you some ideas. 8-)

It's windows xp, I found out by looking at his last posts, it's mentioned there


Thank you for that BlackBerry. Actually I was trying to hint to the poster to be more forthcoming with information that is not a state secret. Unless this a CONTINUING REQUEST spread over multiple threads, I'm just not sure it should be necessary to research information from past posts in order to respond to the current post.

8-)

Quote
Thank you for that BlackBerry. Actually I was trying to hint to the poster to be more forthcoming with information that is not a state secret. Unless this a continuing request spread over multiple threads, I'm just not sure it should be necessary to research information from past posts in order to respond to the current post.

I think it is up to the poster to make his information known, rather than our RESPONSIBILITY to ferret it out. After all, it is HIS problem. Right, but clicking on the recent post button costed me a few second and after all, beeing nice is never wrong


Quote
I'm just not sure it should be necessary to research information from past posts in order to respond to the current post.

I agree, it's not our job to do it, so I think from now one I will let them say it