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.

5851.

Solve : Message Boxes?

Answer»

Hey everyone,
You know if you go to notepad, type msg * HELLO, save it as a .bat and open it there will be a MESSAGE saying 'message from %username% %date% %time%'
(see picture at below)

Is it possible to get rid of that top message and replace it with like 'Warning'?

Thanks for the help.That can't be done, but it will work if you use vbscript.

Code: [Select]MsgBox "hello",48,"Warning"
Save as "filename.vbs".

8-)fffreakhey thanks fffreakI got the following. How did you ever get a message box?

Mac

Microsoft(R) Windows NT(TM)
(C) Copyright 1985-1996 Microsoft Corp.

C:\work>notepad z.bat
( I made a one-line file containing msg * hello )

C:\work>z

C:\work>msg * hello
The name specified is not recognized as an
internal or external command, operable program or batch file.

C:\work>Quote

I got the following. How did you ever get a message box?

Mac

Microsoft(R) Windows NT(TM)
(C) Copyright 1985-1996 Microsoft Corp.

C:\work>notepad z.bat
( I made a one-line file containing msg * hello )

C:\work>z

C:\work>msg * hello
The name specified is not recognized as an
internal or external command, operable program or batch file.

C:\work>

looks like its time for an UPGRADE
msg is in XP, see here
Quote
looks like its time for an upgrade

LOL - Well, not THAT INTERESTED. Actually, the NT system had such a thing in a directory of special stuff for networks which I deleted on my home computer. Too much stuff I will not use.

Thanks for the info.

Mac

If you remove portions of the operating system there are a lot of things that won't work...Quote
If you remove portions of the operating system there are a lot of things that won't work...

True, but it was an add-on directory.
http://www.microsoft.com/resources/documentation/windowsnt/4/server/reskit/en-us/reskt4u4/rku4list.mspx

I deleted over 4 years ago and never had a problem. I note that MSG was not there and now I vaguely remember my DBA days where we use NET SEND, I believe, for that function.

Mac
That can't be done, but it will work if you use vbscript.

Code: [Select]MsgBox "hello",48,"Warning"
Can that only be a vb extension or can you put that in DOS somehow to have the same result?

Thanks just wondering
5852.

Solve : DOS programs only load in a small window?

Answer»

Long ago I asked this forum why my windows vista would only open DOS in a window. Someone suggested I go into the properties and check the "full screen" box. I did that. Now when I open DOS, it opens in a full screen. But when I load a program (Multimate, Nutshell, Managing Your Money) it reverts to a small window, and there's no way I can enlarge it. Can anyone help?Is it DOS or your program that reverts to a small window? Also, how do you open the program? If it's a program that goes small, then you could TRY opening the program by using:

start "" "Name of Program" /MAXOr click the icon in the top left corner of the DOS box & alter the Properties and save them, choosing "save properties for all windows with this name".
"Dias de VERANO" is right. But so is "Dark Blade"

Quote from: Dias de verano on February 16, 2008, 12:45:46 AM

Or click the icon in the top left corner of the DOS box & alter the Properties and save them, choosing "save properties for all windows with this name".

Quote from: Dark Blade on February 16, 2008, 12:31:29 AM
Is it DOS or your program that reverts to a small window? Also, how do you open the program? If it's a program that goes small, then you could try opening the program by using:

start "" "Name of Program" /MAX

The reason both can be right is that it all DEPENDS on the method you are using to start your program. If starting from a batch file use Dark Blade's fix. If starting with a windows shortcut, use Dias de verano's fix.

What is happening here is that you are only altering one windows shortcut at a time. For instance, if you have a copy of "Command PROMPT"(.lnk) (Windows shortcut to cmd.exe) in your game folder, the properties of that cmd shortcut only are altered. When you go to Start-Programs-Accessories-Command Prompt, you will still get the small window. Each shortcut must be altered individually. (If there is a way to do more than one at a time, I'm not aware of it.)

You can get to the shortcut properties the way described above, but what happens when you decide you want to change it back. "Ouch" there is no title bar to right click on. Remember - the properties you are altering are in the shortcut, not in the CMD window.

So:
Right click the windows shortcut-click Properties-Options-select Window or Full Screen-Apply-OK

Repeat on the shortcuts to each program, one at a time.

I should ADD. this method should work on nearly all of your programs, but on occasion, a program will simply ignore your setting to "Full Screen". Apparently the programmer didn't see the need to include that functionality.
5853.

Solve : deleting files older than 3 months?

Answer»

hi
i want to delete files from certain folders and subfolders in a directory, which are 3 months old. The modified date of the file is to be checked . if it is older than 3 months it is to be deleted.i need to use a batch file for this. can anybody help...you can use vbscript to calculate time or you can use GNU find for win32, downloadable here . Follow the instructions, then on the command line
Code: [Select]c:\> find path -type f -mtime +90 -exec del {} \;
thanx for the reply. I wanted to know is it not possible to write a batch file for this . Actually i require a batch script which i will schedule to run once a month , to achieve the purpose. So if anyone can provide me a batch file meeting my requirement , i would be really glad. and also thanx in advance.Here is one way to do it, and it would require use of a third party utility program. It can check the filedate, and exit with an errorlevel that can indicate if the file is more or less than 90 DAYS old.
You write your batch file to trap that errorlevel and ACT on it.

The utility program is free.
You can download it here:
http://home.mnet-online.de/horst.muc/main.htm
See Isdate

You would not be using any scripting, but only batch files and the free util program.
Before we go any further, would this be of use to you?



Quote from: elroth on February 15, 2008, 07:18:28 AM

thanx for the reply. I wanted to know is it not possible to write a batch file for this . Actually i require a batch script which i will schedule to run once a month , to achieve the purpose. So if anyone can provide me a batch file meeting my requirement , i would be really glad. and also thanx in advance.
i have shown you in my post. the utility is called find and how you would use it in a command prompt. you can easily adapt to a batch script. Just that one line will do what you want. And yes , its possible. What it takes is a LITTLE bit of effort to get started.Won't that conflict with the built in Windows find? I had to rename the GNU ECHO util to gnuecho.exe to avoid a similar problem.
Quote from: Dias de verano on February 16, 2008, 12:25:52 PM
Won't that conflict with the built in Windows find? I had to rename the GNU echo util to gnuecho.exe to avoid a similar problem.

it won't. If you installed GNU find in say C:\gnutils\bin , then just simply putting this path in front of your current PATH ENVIRONMENT variable will enable the OS to run the GNU find first. nobody says you need to install into system32 Quote from: ghostdog74 on February 16, 2008, 07:46:53 PM
If you installed GNU find in say C:\gnutils\bin , then just simply putting this path in front of your current PATH environment variable will enable the OS to run the GNU find first.

Excellent tip. Thanks.
5854.

Solve : Echo Text after running a batch file?

Answer»

Hi,

I have a batch FILE that executes a COMMAND. However when its done, my last line ECHO "FINISHED" doesn't display. What am I doing wrong?

Code: [Select]@echo off
echo Hello this is a test batch file for PDF and FO production.

SET disp=cmd /k
SET /P myval=Display Errors? [Y/N]

IF "%myval%"=="n" (
SET disp=
)

%disp% FOP -xml c:/temp/testme2.xml -xsl c:/temp/test.xsl -pdf foo.pdf -d

ECHO FINSHEDIf I understand your question right, this should work. Just put 'pause' (w/o quotes) on the next line. If you want it to say Finished and not the original 'pause' message, type 'pause > nul' (w/o quotes).Yes, dragonmaster is right.

What is happening in your CURRENT batch file is that it echoes FINISHED, but then exits, because all the jobs are done. By adding the pause (preferably pause >nul), the file waits until any button is pressed before continuing (or this CASE, finishing).Thanks for the help.

I've added the following line and dos windows still closes after it executes:

ECHO FINSHED

pause

or

ECHO FINSHED

pause >nul

Not sure what I am missing...
I believe that the program gets an error from this line:
%disp% Fop -xml c:/temp/testme2.xml -xsl c:/temp/test.xsl -pdf foo.pdf -d

Because of the error, the batch file just shuts itself off, without attempting to reach the end. I would recommend trying that line by itself, and seeing if it works (and if it doesn't, see what's been done wrong).Thanks... you're are right.

it was "cmd /k" causing the problem.

Thanks Again
Quote

ECHO FINSHED

That would make it echo "finshed" and not "finished"
5855.

Solve : close the console window from batch?

Answer» HI!

my batch file STARTED to play a video with camtasia player:

@ECHO off
CamPlay.exe /M /S test_TSCC.avi
@exit

i would like to close the cmd WINDOW while the video is playing, but it seems the @exit statement is unreachable, the console window appear all along. Does anybody know how i could close the cmd window?
Thanks!Use the START command like this then the Camplay app will be started and control will pass back to the batch which will then process the next line. You don't need the exit command if there are no more lines, because the batch will exit anyway, and you did not need the @ sign before exit, because you already TURNED command echo off at the beginning.

Quote

@echo off
start "" "CamPlay.exe" /M /S test_TSCC.avi
exit

okay, thank you very much!
5856.

Solve : help with IF Array?

Answer»

using an if array , how can i MAKE SOMETHING similar to this work? i want line 1 , to goto line 3 , and line 2 to goto line 4

:4PZ889Q
IF "%e.1%"=="D" (
IF "%e.1%"=="A"
Goto R99
Goto R98
)Not quite sure what an "if array" is, (they don't exist in batch language) but I think the answer to your question is that the action to be taken as a RESULT of an IF TEST IMMEDIATELY follows the test.

thus

Quote


IF "%e.1%"=="D" goto R99
IF "%e.1%"=="A" goto R98


I must say, in a friendly way, that you sure write cryptic, hard-to-read code!!! Ever heard of meaningful variable names? Or if you didn't write it, but have to maintain it, you have my sympathy!
5857.

Solve : Can u Convert a COM File back into a Batch File??

Answer»

thanks!ah crud. i used the ASCII characters in my batch FILE but they come out as different characters when i run the batch file.YES,
You can type most of the 256 ASCII charactors with the ALT-123 method, but be careful with the first 32 & the last one(ALT-255). Many of these have special functions that will give you unexpected results. I think most of the rest are SAFE. Use the space bar, unless you have a specific reason for the blank(ALT-255).

ALSO some of the charactors appear differently in one editor than than they do in another. Try the blank(ALT-255). In this window, it appears correctly(it looks a lot like a space(ALT-32) but is a completely different charactor.) In DOS editor for WindowsXP, it appears correctly also, but in some of the older versions, DOS 6.22 - Windows 98, It shows up as a visible charactor on the screen. In Note Pad you may get entirely different results. Some of the charactors can be typed only with a HEX editor, which is not what you want to do here.

Sometimes DOS Editor will not save the charactor as typed, especially the first 32. DOS Editor in XP has Save as Type - Unicode. This might help, but I doubt it, if you are trying to use the special charactors. I don't know whether Unicode was available in earlier versions or not.

WOW! we are way off on a tangent here, aren't we???
Quote from: macdad- on February 16, 2008, 07:29:02 AM

ah crud. i used the ASCII characters in my batch file but they come out as different characters when i run the batch file.

Sorry, should have mentioned that I use Edit.com in XP and W2k to create the script as this ties in with the 'Dos' side of THINGS, not sure what other editors will produce.

Apols.oh then i'll try edit
Man was i wrong ( I wasn't even in the ball park). Thanks for setting me straight patio and llmeyer.
5858.

Solve : Zipping files using batch file?

Answer»

Is there a way to:
1)LOCATE files with a known file extension on a known Drive and
2)send them to a zip file on windows XP desktop?

I know XP has a zip function, not sure what it's CALLED....could it be used instead of an old pkzip exec.

Also: how do you determine the Short File Name with XP as "Open Command Prompt Here" shows only Long File Names.
Actually PKZip is better suited for this task...have you read the PKZip Help files ? ?Apparently microsoft made it impossible to use command line to do this. Bottom line I still need a way, without software installation to locate files of a particular extension, compile them in a single file for emailing. What about using makecab.exe for the compiling??

Usage:

MAKECAB [/V[n]] [/D var=value ...] [/L dir] source [destination]

MAKECAB [/V[n]] [/D var=value ...] /F directive_file [...]

source File to compress.

destination File name to give compressed file. If omitted, the last character of the source file name is replaced with an underscore (_) and used as the destination.

/F directives A file with MakeCAB directives (may be repeated). Refer to Microsoft Cabinet SDK for information on directive_file.

/D var=value Defines variable with specified value.

/L dir Location to place destination (default is current directory).

/V[n] Verbosity level (1..3).


Let me clarify:

1) I need to go to a specific hard drive (EXAMPLE: D:\)

CD D:\

2) From there I need to locate all files, including those in any sub-directories with a particular file extension(EXAMPLE: *.mp3)

If exists *.mp3

3) Copy them to a folder called (EXAMPLE: MYMP3Z)

echo | Y copy file to MYMP3Z

4) Convert the folder or all files in the folder into a single file either .zip, .cab....whatever(EXAMPLE: MYMP3Z.CAB)

pkzip D:\MP3Z\*.* C:\Documents and Settings\John Doe\Desktop\MP3Z.zip

5) Place that file on the windows desktop(EXAMPLE: C:\Documents and Settings\John Doe\Desktop)

6) Delete the folder MYMP3Z

ECHO | Y DEL D:\MP3Z\*.*
RD D:\MP3Z

I don't think PKZIP for DOS can do all of that.

I may also need to a DOS zip executable to the Windows\System32 Directiry prior to running.



ionic,
Iam using 7-zip software for zipping and unzipping files using batch file.


http://www.7-zip.org/download.html

Download the .exe file from the above link and install on ur pc.

suppose u r installed in c:\programfiles\
Please assign the path in envirnomental variables (my computer--properties) ---system variables---path .
say: c:\programfiles\7z paste this path in the system variables---path

cmd for unzpping:
7z e c:\a.zip -oc:\

-o : output dir.
unzips the a.zip to a.txt file

cmd for zipping :
7z a -tzip c:\b.zip c:\a.txt
zips the a.txt to b.zip

Save the cmd in .bat format and execute

Hope this may help you.

regards,
chinna


I am currently playing around with XCOPY to copy the files from directories and subdirectories and place them in a specified folder. From there I can run a zip app to place them in one file where I want.

Not sure if XCOPY can copy only the files from a directory and subdirectories without maintaining the folder structure.

This is what I have come up with thus far:


@ECHO OFF
MD D:\TXTZ

XCOPY I:\*.txt D:\TXTZ\ /n

PKZIP -es -m -rp -r- D:\MYTXTZ.ZIP D:\TXTZ\*.*

IF EXISTS D:\MYTXTZ.ZIP (
ECHO Y|RD D:\TXTZ /s /q
)ELSE(
ECHO Missing file "MYTXTZ.ZIP"
)
exit


The results: Although I included the full path where XCOPY should find files, it copies files from where the batch file is located, in this case on the desktop. XCOPY did not copy any files in subfolders on the desktop.
If I set the switch for XCOPY to Coy folders and subfolders except empty ones with /S it does copy them, but
I'd rather leave the folders out of the equation.

PKZIP worked fine

RMDIR did not delete the folder D:\TXTZ I think I'm stuck here. Any help would be appreciated. I think it should work but I need to lookup the switch options. Then again, maybe xcopy is not the right way to go.Try HereYou're making this harder than it has to be. You had all the pseudo-code laid out, all you needed to do was code it up:

Code: [Select]cd /d d:\
for /f "tokens=* delims=" %%x in ('dir /s /b /a:-d *.mp3') do (
copy "%%x" d:\mymp3z
)
cscript scriptname.vbs
rd d:\mymp3z /s/q

The cscript is below. You can indeed use Window's built-in zip ROUTINES; you just can't use batch code.

Code: [Select]strTargetFile = "C:\Documents and Settings\John Doe\Desktop\MP3Z.zip"

Set fso = CreateObject("Scripting.FileSystemObject")
Set zip = fso.CreateTextFile(strTargetFile)
zip.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)
zip.Close
WScript.Sleep 500

Set objShell = CreateObject("Shell.Application")
Set objFile = objShell.NameSpace(strTargetFile)
Set src = objShell.NameSpace("d:\MYMP3Z")

objFile.CopyHere src
WScript.Sleep 30000

Save the script (the name has to match the batch file reference) in the same directory as the batch file and with a vbs extension.

The Copyhere method runs asynchronous to the batch file. I built in a 30 second time delay but you may have to increase it based on the size and number of the mp3 files. The time interval on the sleep method is measured in milliseconds. This is important as you do not want to remove the mymp3z directory before you finish zipping the files.

Good luck. Quote from: Sidewinder on January 03, 2008, 02:16:23 PM

You're making this harder than it has to be. You had all the pseudo-code laid out, all you needed to do was code it up:

That's just it, the cscript and vbs stuff is completely foreign to me. Coding it up was not possible so I would need expernal programs like pkzip and batch file for a time delay...

I do appreciate your work and will let you know how it turns out.

ThanksI have run the code(bat & vbs) and encountered some problems:

There is the code I am using at present:
Code: [Select]@echo off
md c:\docume~1\brianb~1\desktop\TEXTZ\
cd /d i:\
for /f "tokens=* delims=" %%x in ('dir /s /b /a:-d *.txt') do (
copy "%%x" C:\docume~1\brianb~1\desktop\TEXTZ\
)
cscript grabnzip.vbs
rd C:\docume~1\brianb~1\desktop\TEXTZ\ /s/q
As a test I altered the code to copy some txt files...
The first problem I had was that a folder was not created, but rather a file with no extension. So I added the
line to make a directory. I also changed the folder path to be the same as the .zip destination.

Code: [Select]strTargetFile = "C:\docume~1\brianb~1\desktop\TEXTZ.zip"

Set fso = CreateObject("Scripting.FileSystemObject")
Set zip = fso.CreateTextFile(strTargetFile)
zip.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)
zip.Close
WScript.Sleep 500

Set objShell = CreateObject("Shell.Application")
Set objFile = objShell.NameSpace(strTargetFile)
Set src = objShell.NameSpace("C:\docume~1\brianb~1\desktop\TEXTZ\")

objFile.CopyHere src
WScript.Sleep 30000
After all the code ran I did get a folder created and the txt files(15) were copied to the folder. Then the folder
was deleted, but there was no zip file created.

It seems that at this point I might as well use pkzip as I can't achieve my goal with a single batch file. So if I use a .vbs file or pkzip.exe makes no difference.

You're also ignoring how powerful PKZip is/was...it went outside of DOS/batch limitations in ALOT of ways way before it's time and it would be a good learning experience to do some more research along with the link i provided...

XTree Gold is another example of batch/scripting on steroids but takes some getting used to...actually that's innaccurate. It's not a batch/script tool rather a powerful DOS shell.Using PKZip is a fine alternative. I only posted because you originally wanted to use the built-in capabilities of Windows.

When I tested my original code, it worked fine! I'm very surprised the TEXTZ.zip file did not end up in C:\docume~1\brianb~1\desktop. I'm going to take it on faith that brianb~1 is your account.

Good luck.

Quote from: patio on January 04, 2008, 02:01:59 PM
You're also ignoring how powerful PKZip is/was...it went outside of DOS/batch limitations in alot of ways way before it's time and it would be a good learning experience to do some more research along with the link i provided...

I will take the time to read the pkzip documentation. It's not a short doc but like you said it may be all I need.Quote from: Sidewinder on January 04, 2008, 02:44:47 PM
When I tested my original code, it worked fine! I'm very surprised the TEXTZ.zip file did not end up in C:\docume~1\brianb~1\desktop. I'm going to take it on faith that brianb~1 is your account.


At first it did not. After using PKZip.exe it did, but it contained files other than the ones from the TEXTZ folder.

The trouble I was having was that I refferenced a thumb drive for the test(I:\) and once there it could not change directories back to the hard drive(C:\). Not that I found this out the original code you wrote might work.

I am going to revisit it.

Yes brianb~1 is my account. I also searched all drives for the file but found nothing.

P.S. What does the "/d" after the CD command designate? It doesn't show up as syntax for the DOS CD command reference.

Sidewinder,

I got your code to run. as wel as a PKZip version. It might be possible for PKZip to do it all by itself, but for now I am satisfied.

This is the code that worked for me:

Code: [Select]cd /d d:\
md TEXTZ
cd /d d:\testfold\
for /f "tokens=* delims=" %%x in ('dir /s /b /a:-d *.txt') do (
copy "%%x" d:\TEXTZ\
)

CD /d C:\Docume~1\brianb~1\desktop\
cscript grabnzip.vbs

rd d:\TEXTZ /s/q
exit
Code: [Select]strTargetFile = "C:\docume~1\brianb~1\desktop\TEXTZ.zip"

Set fso = CreateObject("Scripting.FileSystemObject")
Set zip = fso.CreateTextFile(strTargetFile)
zip.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)
zip.Close
WScript.Sleep 1000

Set objShell = CreateObject("Shell.Application")
Set objFile = objShell.NameSpace(strTargetFile)
Set src = objShell.NameSpace("D:\TEXTZ\")

objFile.CopyHere src
WScript.Sleep 15000
I'd still like to know what CD /d means...

Thanks for your help.

patio, thanks for your insite as well. I will be examining the POWER of pkzip
soon!


Forgot...here is the batch file code using pkzip.

Code: [Select]@echo off
cd /d d:\
md TEXTZ
cd /d d:\testfold\
for /f "tokens=* delims=" %%x in ('dir /s /b /a:-d *.txt') do (
copy "%%x" d:\TEXTZ\
)
call PKZIP c:\docume~1\brianb~1\desktop\TXTZ.ZIP d:\TEXTZ\*.*
pause

rd d:\TEXTZ /s /q
exit
Brian
5859.

Solve : copy large files from unformated/unknown partition?

Answer»

hello everybody! first of all, i know Ive messed up....really bad

i was going to reinstall my dads laptop the other day. i USED the recovery Cd's he got from acer to set win xp back to square one. 5min after i started cd1 he came running and said he had forgot to copy some files to his usb stick. i cancelled the operation and tried to reboot win xp.... it didn't work. what a shocker.

i booted the laptop with a boot cd and started browsing the partition with ms-dos. the files were still there but the disc is unformatted, unknown or something like that.

Ive tried to copy files with ms-dos to a usb stick and it works. the only problem is that the larger files doesn't get bigger than 32KB on the usb-stick, I'm talking about jpg's and mp3's. SMALLER files like *.xls can be copied to the usb-stick and works perfectly when opened on other computers.

does anyone of you have a solution for this?

I'm thanksfull for all help i can get and i APOLOGIZE for my bad English.what copy command are you using?
have you tried using xcopy?yeah, ive tried both copy and xcopy. with copy the files doesnt get bigger than 32kb and with xcopy 48kb.

theres two PARTITIONS on that comp and i cant install windows on the other partition before i format the "unknown" partition where my files are. if i format the "unknown" partition and install windows on the other one. do you think ill be able to recover the files with any freeware after the windows installation?Yes!
If you are absolutely sure that you are installing to the other partition, you will be good to go.
A fantastic tool is "GetDataBack" Data Recovery program. www.runtime.org They have a version for FAT partitions and one for NTFS. I've used both.
You would have to have an operating system installed, which is usually done on a different physical HD, but that may not be possible in the case of the laptop. The other partition will work just as well. I have both the FAT and NTFS versions and have fully recovered data from several "Unformatted" Hard Drives.
Wish you well!
STOP!! I think I goofed!

I didn't read you post correctly. I thought you were going to format the other partition. Do NOT format the partition with the data on it. unless you use the /Q switch. If you format without the /Q (QUICK), you will possibly overwrite data.

I assume you are trying to install WinXP or 2000 to the NON-Data Partition, but the OP system is choking when it sees the unformatted partition. Is that the case?

Windows 98 setup might work, because it doesn't look for all the partitions. It will only look for the Active Primary Partition. Try first using Fdisk and setting the NON-Data Partition active. Then install your operating system. That won't work if the second partition is not a primary partition, which is likely the case. In that case, you may need something like the command line version of Partition Magic to change the attributes of the partition.

Another good option I just thought of is Bart's PE. Download and setup Bart's PE on another computer. Use the Bart's CD to boot the laptop. You will then have a stripped down version of WinXP to work with. This method is probably the quickest and safest, and will work for you. Guaranteed or your money back.

You did goof...since it's a laptop chances are the other partition is the Recovery partition which contains all the Recovery files and a copy of the OS...Quote from: patio on February 12, 2008, 09:23:41 PM

You did goof...since it's a laptop chances are the other partition is the Recovery partition which contains all the Recovery files and a copy of the OS...

Yes I goofed about telling marcusb to go ahead and format the partition with the data but I don't think the second partition is a recovery partition(even though many laptop makers do use that recovery method). marcusb said:

Quote from: marcusb on February 11, 2008, 03:10:06 PM
i used the recovery Cd's he got from acer to set win xp back to square one. 5min after i started cd1 ...

Most likely, since he has multiple recovery Cd's, the recovery data is on the Cd's, NOT on the HD.

At any rate my last suggestion would be the quickest, safest, and least expensive because the program is free, and safest because it makes NO changes to the HD.

Quote from: llmeyer1000 on February 12, 2008, 08:17:59 PM
Another good option I just thought of is Bart's PE. Download and setup Bart's PE on another computer. Use the Bart's CD to boot the laptop. You will then have a stripped down version of WinXP to work with. This method is probably the quickest and safest, and will work for you. Guaranteed or your money back.

The guarantee was meant as humor(in a not so funny problem), but the rest was serious. By the way it's available in XP or 98.

www.nu2.nu/pebuilder/

Bart's PE Builder helps you build a 'BartPE' (Bart Preinstalled Environment) bootable Windows CD-Rom or DVD from the original Windows XP or Windows 98 Cd's.

You might still need some recovery software if the partition is indeed formated, which I doubt. You said:

Quote from: marcusb on February 11, 2008, 03:10:06 PM
i booted the laptop with a boot cd and started browsing the partition with ms-dos. the files were still there but the disc is unformatted, unknown or something like that.

Ive tried to copy files with ms-dos to a usb stick and it works.

If you can see the files in DOS, I doubt the partition is unformatted. You should be able to see then in Bart's PE without any special software. I can't remember if Bart's will find the USB stick after it is booted up, so you may want to put it in first.

i tried to boot with this bartPE but C:\ is empty when i run "a43 File Managment Utility" It sounds like you did everything right. The "a43 File Management Utility" is the equivalent of windows explorer and would normally be able to see your files. I am surprised that since you said good ol' DOS could see them that the "a43 File Management Utility" could not. Did you DOS by itself, or some DOS based program, such as Norton Disk Editor or ...?

I'm guessing that it is a FAT partition rather than NTFS. (DOS by itself can see only FAT.) Obviously there are some serious problems with the partition. Anything is possible but since DOS can see quite a bit of the drive, it is very likely that the damage is limited to the system area of the drive. The MBR must be intact, or you couldn't see the partitions. It is most likely that the damage is in the Boot record of drive C: and possibly some FAT(File Allocation Table) damage. Since FAT partitions have 2 copies of the FAT, it is possible that DOS is using the second FAT table, while the Windows "a43 File Management Utility" is unable to.

But that doesn't help you recover the files. It is very likely that DOS's scandisk or Norton Disk Doctor(the command version) could identify the problem and fix the errors on the drive. Then Bart's PE should work for you. That "probably" will work,... I say probably BUT...

While Scandisk and NDD are awesome utilities and can usually (maybe 99% of the time) correctly identify and repair a drive, I have used both and on one drive NDD totally messed it up it up and made further data recovery virtually impossible. Anytime you write to a drive with data on it, you are taking some risks, and in the case of Scandisk, you are trying to repair the drive itself. Since the utility that comes with Bart's isn't working, you have 2 choices that I can see. The quickest is to use scandisk and let scandisk repair the drive, then boot with Bart's and hopefully the files are visible. There is a good chance that will work.

The safest method is to connect the HD to another computer if possible(possibly not on the laptop), Or...
Get data recovery program that is capable of reading the drive and analyzing the file system without making any changes to the drive itself. You would then make a new boot disk(Bart's PE) with the recovery program (possibly GetDataBack) on the disk. (Or the program could possibly be copied to an external drive and run from there.) This method will most likely cost a few bucks and will take considerably more time, but is the safest. It depends on how valuable the data is to you and your father.

It's up to you, but ... I think you might want to try scandisk(or NDD). They usually do the right thing.
Expect a message or 2 such as:
"Your boot record is corrupted. Do you want to repair it?"
"One of the copies of the FAT is damaged. Do you want to repair it?"
Say yes and hope for the best.i just have to say that everything is recovered now. the suggestions llmeyer1000 gave me with bartspe and getdataback worked out great
5860.

Solve : Change screen resolution in DOS?

Answer»

I am running Windows 98SE on a Dell Latitude CPi laptop with Neomagic graphics. I need to run an old graphics DOS APPLICATION. When I reboot from Windows to DOS not all the screen is used for the DOS prompt. I would like to change the resolution to use the full screen which is what the application requires. I don't know much about DOS but I have put the each of following lines in the config.sys and config.dos files in turn and rebooted the machine each time:

DEVICE=C:\WINDOWS\SYSTEM\NMGC.DRV
DEVICE=C:\WINDOWS\SYSTEM\NMGCVCC.VXD
DEVICE=C:\WINDOWS\SYSTEM\vmm32.vxd

The driver files are identified by Control Panel->System->Device Manager->Device Manager tab -> Display Adaptors->Properties->Driver tab->Driver File Details. None of the changes have worked, some caused the machine to hang. Any ideas about how to do this will be gratefully received. I have looked elsewhere on the web but not really found any answers.
Do you have a second operating system, you are rebooting to, such as DOS 6.22. If so what op system?

The smaller window you refer to suggests to me that perhaps you are only opening up a CMD window while still running in windows. If that is the case, Right Click the Title bar, click properties, and under the options tab, click Full Screen. After turning on the full screen, it will appear just like the Dos screen that you are looking for. When done type EXIT to return to windows.

Let us know either way!
I may not be understanding your situation.Thanks for the reply. I get to DOS by doing the following

1) Start-> Shut down
2) Select "Restart in MS DOS Mode"
3) Select OK

to get back to windows I type "exit" to the dos prompt
You may try this:
http://www.12noon.com/reschange.htmI have tried reschange (thanks for the suggestion) and I get the following:

reschange -listmode: gives an empty LIST of modes
reschange -width=1024 -height=768 -depth=8: says that the resolution is not supported.

I also tried depths of 16 and 32 with the same result as 8. When running Windows the resolution is set at 1024x768 with 256 colours or so the Display settings in the Control Pannel says. So the resolution I have tried should be OK. I can only think that DOS is running a different display driver to windows. Can anybody confrm this and tell me how to use the correct driver.

Thanks

RogerDOS does not have video drivers and uses either Standard VGA default resolution, or your video card default resolution. I'm not quiet sure, which one.
I'd bet 1024x768 is too high. Try something like 640 x 480.
Is it a wide screen, or regular one?I have tried the following command:

reschange -width-640 -height=480 -refresh=60 -force

and I get an error:

"Testing (640 x 480) 8bpp, 0Hz

Command Line:
(none)

An error occurred when changing display resolution"

I have tried the same resolution in Windows and the AREA of the screen that is used reduces to the same as used when I run DOS so I suspect 640x480 is the resolution that DOS is using anyway.

I should also have mentined before that when I boot back to DOS (Start->Shut Down->Restart in MS DOS mode) I can't run reschange as DOS says "This program cannot be run in DOS mode". To run reschange I have to run the DOS comamnd window and run reschange from there. I run the DOS window in full screen mode.

Thanks again for your help

RogerProblem Solved – embarrassingly

I have just been on the Dell support forum and searched for an answer and the second thread I looked at said I should type Fn F7, which worked. The label on the keyboard for Fn F7 says “Font” so I would never have guessed. I have spent hours on this so it just shows that you have to look in the right place, it hadn’t occurred to me that the solution was Dell specific. Thanks again for your help.

Roger
Hallelujah!...Cool I have looked into this further and it's possible to change the screen resolution that DOS uses. This can be done with the program in vmode11.zip from www.hitechlabs.tk. This accepts a hex value for the video mode that is required. Look at the end of the source CODE in the same zip file to see a range of video modes. For example to set 1024x768 with 64k colours requires the command “vmode 117’, 13, 10” where 117 is the hex value of the mode, I don’t know what the "13, 10" is for though but the command works. To find out what modes a video adaptor supports you can use System Analyser from www.sysanalyser.com. Scroll down to the section on the video adaptor to see the modes. There are probably other programs that display the video modes as well. Unfortunately the program I'm using resets the mode to a lower resolution when it starts and I doubt this can be fixed.

Roger
Thanks for the update.

5861.

Solve : SET variable not working in an 'if' or 'for' loop of windows batch script?

Answer»

Once I get into a 'if' block or 'for' loop in a batch script, it doesn't recognize the SET variable. I found something about CMD /V:ON to enable the delayed execution in a batch script; but then how would you run it in a batch script. When I enabled the CMD /V, the batch script won't run any further beyond that.

I finally had to change the logic using GOTO and do AWAY with getting into an 'if' block. Any solution to this?Welcome to the CH forums.

Please read >>this<< and post your script.

It is possible to enable delayed expansion within a script, using the setlocal command with the enabledelayedexpansion modifier.

This FIRST script won't display values for %number% and %answer%, because those VARIABLES are expanded at runtime, and will be empty.

Quote


@ECHO off
for %%N in (1 2 3 4) do (
set number=%%N
echo number=%number%
)

set count=11
if "%count%"=="11" (
set answer=yes
echo answer=%answer%
)


This second script will work because delayed expansion is enabled and because !number! and !answer! have exclamation marks INSTEAD of percent signs.

Once you are outside the IF block or loop you can use the variables with % signs and they will show up.

Quote

@echo off
setlocal enabledelayedexpansion
for %%N in (1 2 3 4) do (
set number=%%N
echo number=!number!
)

set count=11
if "%count%"=="11" (
set answer=yes
echo answer=!answer!
)

5862.

Solve : Set name?

Answer»

Hi
im trying to use the set command to change a variable to an html code then
copy that code ONTO the file. But it has a bunch of spaces in the code and
if there are quotes around the code, it wont work.

here the code
Code: [Select]:1
set name="<html><head><title>Google</title></head><frameset cols="*" frameborder="0" border="0"><frame src="http://www.google.com/" scrolling="auto"></frameset></html>"
pause


echo %name%>%NUM%.htm
pause>nul
call %num%.htm
pause
so is there ANYWAY to set the name without using quotes so
that the code is copied onto the file as is.

Certain characters have a special meaning in batch code: */ + | \ = ? [ ] ; : " . < > ,

In order to use them, they must be escaped with a carat (^). Your code will look like hieroglyphics by the time you're done.

Example:

set name=^<html^> equates name to

You'll have to precede every special character in your string with ^

Good luck.

i tryed this:
Code: [Select]@echo off
set name=^<html^>
echo %name%
pause
but it closes the window when i run it

im using windows vista btwDid you double click your batch file or run it from the command prompt? In any case the pause statement should have held the window open until you hit a key.

You can type the set and echo statements at the command prompt to give yourself an indication of how the carat character works (that's what I did )

k i got that working but it doesnt fix my problem.
I need it to copy the html code without the quotes.
everything else is fineThe set statement does not require quotes to define the string. In fact if present, they become part of the string. If you need to keep the quotes for cols= or border= then you must escape them.

This should get you started:

set name=^<html^>^<head^>^<title^>Google^<^/title^>...

Good luck.

PS. This COULD get very messy very fast. There are many scripting languages available including VBScript and JScript which are installed with all Windows versions (except Win95A & B). Others like Python and REXX can be download free and are way better than anything batch has to offer. I just like to toss this PS. in once in a while.

5863.

Solve : Mountvol questions?

Answer»

I am as the name IMPLIES a newbie. I have a HP with windows XP Home with several Mountvol's listed. Why would this be? Is this part of system restore? I deleted one and was shut off of the computer, nothing WORKED. I had to do a complete restore with the HP disks and they are all back.
How do you get them off without losing the ability of using the computer? Quote

I have a HP with windows XP Home with several Mountvol's listed

Where do you see this list? EVERY PARTITION on your system has a mount point, so I'm unsure why you want to eliminate them.

You can check the Mountvol command for more info.

5864.

Solve : Installing MS-DOS 6.0 over MS-DOS 5.0 - will I lose my data???

Answer» LAST night I had one of those heart-stopping moments when my pc went wrong - the oldest and most stable of the four computers we have at home......

Its a Viglen Professional 486 PC, model 4DX33, November 1993 vintage, with what must be a very small hard drive and a 3.25 inch floppy drive. It is being run using MS-DOS 5 and Windows 3.1. Yesterday my next door neighbour gave me an almost new wide-screen monitor, and in attempting to get it working with this pc I have, to cut the story short, corrupted MS-DOS, such that I can no longer access the hard drive.

Last night I succesfully reinstalled MS-DOS 5.0 and then Windows 3.1, apparently without losing any data. This morning, in attempting to get the mouse cursor to appear on MS-DOS Works, (and obviously not knowing well enough what I was doing) I started installing MS-DOS 6.00 - but when I got to the part of Setup which says "To have Setup configure your hard disk choose the recommended option (which was to configure the first hard disk). If you choose this option all files on the disk will be removed" Horrors!! I don't want to lose any data - I mustn't - so I aborted the process.

I thought (!) that I might be able simply to GO back to MS-DOS 5.00 and work with that, but restarting (ctrl+alt+del) with the MS-DOS 5.00 Setup disk in drive A eventually brought the message "MS-DOS version 5.00 files cannot be installed on you hard disk because all the primary partition table entries on your disk are already in use. To create a set of MS-DOS version 5.00 disks, press enter"

I duly made a set of v.5.00 disks, though I do have my original 1993 disks anyway, but these were of no help.
The situation now is that I can only run the A drive - I can't change to/access the C drive, so I can't get to my data (which is all in Works - both DOS and Windows 3.1 versions). Most of it is financial and membership information relating to various organisations I am involved with, going back 30 years in one case, and it would be impossible to resurrect it all by transcribing it from paper records, apart from the time involved, so I'm FEELING rather at my wits end.

When I reinstalled MS-DOS 5.00 last night no data was lost. Would installing MS-DOS 6.00 on top of it really wipe all files, including the data, from the hard drive, as the on-screen wording suggests, or is it just the operating system files which will be removed?? Are there any other options open to me?

I should be most grateful for any advice. Thank you. From a devastated and distraught 72 YEAR old in North Wales, UK

peterb
5865.

Solve : For each?

Answer»

Does anyone know how to do in a loop certain actions for each line there is in a text file.

For EXAMPLE
textfile:
one
two
three
dunnow

for each line, add a number near the word
converted text file
one1
two2
three3
dunnow4


thanks in advanceThis snippet is down and dirty. Actually it's coded specifically for the data presented and is not a generic solution.

Code: [Select]@echo off
setlocal enabledelayedexpansion
set count=0
for /f %%x in (input.txt) do (
call set /a count=%%count%%+1
echo %%x!count! >> output.txt
)

Quote from: Sidewinder on January 03, 2008, 03:36:51 AM

This snippet is down and dirty. Actually it's coded specifically for the data presented and is not a generic solution.

Code: [Select]@echo off
setlocal enabledelayedexpansion
set count=0
for /f %%x in (input.txt) do (
call set /a count=%%count%%+1
echo %%x!count! >> output.txt
)


That worked perfectly sidewinder. I'm glad to see that you're still on these forums and so helpfull towards others. I haven't been here in a long long time, how are you HOLDING up?

EDIT: another quick question: how do I make that I see in the begin from the output (so before the loop) I see a total of all the lines in the other file (plus one) (=the count of the last line + one).
for example there are five lines
lines=6
(what the LOOPS give you)
..Hey Blackberry, GOOD to see your posts again. You should have stuck around, the regulars all got 10% pay increases (you do the math).

Numbers sort before alpha, so using your data simply sorting the file is one solution:

Code: [Select]@echo off
setlocal enabledelayedexpansion
set count=0
for /f %%x in (input.txt) do (
call set /a count=%%count%%+1
echo %%x!count! >> output.txt
)
set /a count=%count%+1
echo %count% >> output.txt
sort output.txt > final.txt

A more generic solution would be to force the count to be the first record no matter what the data:

Code: [Select]@echo off
setlocal enabledelayedexpansion
set count=0
for /f %%x in (input.txt) do (
call set /a count=%%count%%+1
echo %%x!count! >> output.txt
)
set /a count=%count%+1
echo %count% >> output1.txt
copy output1.txt+output.txt final.txt

You may want to delete some of the intermediate files.



PS. I hope this is what you wanted. I had a dickens of a time figuring out exactly what you needed.Hi! Thanks a lot for your help, my final script is now:

Code: [Select]@echo off
setlocal enabledelayedexpansion
set count=0
for /f %%x in (input.txt) do (
call set /a count=%%count%%+1
echo [link!count!] >> temp.txt
echo URL=%%x >> temp.txt
)
set /a count=%count%+1
>>links.txt echo [Info]
>>links.txt echo Links=%count%
for /f %%a in (temp.txt) do @echo %%a >> links.txt
del temp.txt

I use it because I have a program rapidget that auto downloads files from rapidshare. But you can only add one link at the time in the GUI from the program. As seen I have everyday 100+ links, that was really a big waste of time. Fortunally, the added links in the GUI are saved in a config files (links.txt). Thanks to your help I can now create that config file in one click accept by clicking add link, add link one by one in the GUI.

Thanks for your help
5866.

Solve : Help with batch script to move files (win xp)??

Answer»

i am trying to divide 2000+ files from a folder and move them to other FOLDERS (35 files per folder)

e.g., move files from \src_folder\*.* (2000 files)
to \src_folder\dest_folder0\*.* (35 files)
\src_folder\dest_folder1\*.* (35 files)
\src_folder\dest_folder2\*.* (35 files)
\src_folder\dest_folder3\*.* (35 files)
\src_folder\dest_folder4\*.* (35 files)
...
...

Can anyone help to write this batch script?ok, I can help - but as Im in the office, I can only point you in the direction you need to go, you will have to fill in the blanks !!

You want to process 35 files at a time, I assume it could be any 35, they ARENT in any particular grouping.

firstly, list your files into a text file
Dir /b >\$list$

(if you want them ordered, use the appropriate ordering switches in the dir)

now, a clever bit, create a blank file
echo.>\$blank$

you can use FC to compare the $blank$ and $list$ files to show the difference (all your files) but - we can limit this to the specific number of mismatches that you want, in your case, 35 :

fc /LB35 \$blank$ \$list$ > \$batch$

now, look at this file, it contains a few lines of preamble then the list of files you want to move; you can process this with a simple FOR loop

now repeat the process (you dont need to recreate the \$blank$ file) until there are no files left (if you are moving the files out, they wont appear on the next iteration of the dir) .... your LOGIC to control the iteration should also work out what the directory names are -- these might be created ALREADY, in which case you need to work out how to GRAB the names from a fiel or whatever, or you might just want to have them numbered - again you can do this in a FOR loop.

Sorry about leaving so much work for you, but Im a bit rushed ... if its a 1-off job, just use windows explorer, it will be quicker

Happy new year
GrahamWhen this is all said and done, that is, working good, Please post here. I could use something like this myself.ionic
Why not try to do it yourself and share with the rest of us ??

GrahamSeems unfair the OP should have to wait for a response which may or not ever come.

Code: [Select]@echo off
setlocal enabledelayedexpansion
set fldrct=0
set filect=0
md \src_folder\dest_folder%fldrct%

for /f "tokens=* delims=" %%x in ('dir /b \src_folder\*.*') do (
call set /a filect=%%filect%%+1
if !filect! gtr 34 (
call set /a fldrct=%%fldrct%%+1
md \src_folder\dest_folder!fldrct!
set /a filect=0
)
copy \src_folder\%%x \src_folder\dest_folder!fldrct!
)

The code uses copy, not move so as to keep the original data intact. I dislike writing destructive code for other people's machines.

Good luck. Quote from: gpl on January 02, 2008, 09:15:03 AM

ionic
Why not try to do it yourself and share with the rest of us ??

Graham

Mostly because I am not that smart eith batch code.
I do, however, learn from the code.

Sidewinder, thanks for your time and efforts.

Christine W
, I hope Sidewinder's efforts work out superbly for you. I didn't intend to hijack your thread!That's OK ionic, I didn't mind it at all.

Sidewinder's script works perfectly.
It has saved me a lot of time to manually move files from windows explorer. Thank you.
5867.

Solve : Searching for a file in DOS, then moving it.?

Answer»

Alright, so an EXCEL spreadsheet was given to a lot of people on my network, but I need to make a change to that spreadsheet. What I need is to create a batch file that looks under the the C: drive and under every sub-directory for a ceratin .XLS file, move it from that location to just a temp folder so that I can then transfer it to my computer (I use a DIFFERENT program for that) and edit it. After that point I'll be able to re-email them the correct spreadsheet. Any help would be great.
Thanks!cd\folder
for /f "tokens=1*" %%a in ('dir %CD:~0,1%\yourfile.XLS /b /s') do move %%a After doing more searching (my first SEARCHES didn't come up with great results, why I posted) but I was able to put together the FOLLOWING for this:

For /f "tokens=* delims=" %%a in ('dir C:\ /a /b /s ^| find /i "The Spreadsheet.XLS"') do move "%%a" C:\Folder

This worked perfectly for FINDING all files with that name to my folder.
Thanks!

5868.

Solve : Microsoft Word...........PLEASE HELP!!!?

Answer»

I am sure this is probably a stupid question to most of you but I am pretty much cluless on computers but I am needing to know Does Microsoft Word include DESKTOP PUBLISHING features? This is for my threaded discussions in an ONLINE class for college. If any one can help me out I would greatly appericate. Thanks No, Microsoft PUBLISHER is the desktop publishing SOLUTION in the Office suite.

5869.

Solve : Key press?

Answer»

Just WANT to know if it is possible to do the FOLLOWING with a batch file.

On one of your services we get quit a lot of POPUPS, we then press a to abord it so that the screen is clear, how can I mae a batch file to send a keypress (a) to tell the popup to close.A Macro would work better for this to create a hot key COMBINATON. A batch could be used if you knew the PID of pop up, although the PID of the pop up may be masked behind IE or whichever browser you are using.

5870.

Solve : Batch file passing parameters??

Answer»

I okay I'm completely new to batch files so I need some help. I've been reading almost all the tutorials and FAQ that I've seen, however i cant find one that will answer my question.
I want to call a batch file from a Vb Script function.
I want the batch file to write some lines of text to a textfile and that's it, however the lines of text will be determined from the script. Is it possible to pass parameters to a batch file? From everything I've read it seems like it's not possible.
All help appreciatedPassing parameters to a batch file is very possible:

This is as simple as it gets:

Code: [Select]@echo off
for /l %%X in (1,1,%1) do echo This line is output >> output.txt

When you run the file, pass how many lines you want on the command line. For instance, if the name of the file is mybatch, running mybatch 7 will write 7 lines to the output file.

You can generate the count in your VBScript and pass it along when you run the batch file. If you need help with the VBScript, get back to us.

thanks sidewinder...however it's not the answer I'm looking for. I would like to pass to the batch file strings of text as parameters, right now I'm looking at just using the openTextFile method in the script to write to the file, after the batch file has created it.
I would like to pass the string of text as parameters to the batch, as that would streamline the process in a single call.??
Sorry about my original post it was a little too vague. thanks.
If the string contains just one word you can pass the string as is, if the string contains embedded spaces you can pass strings of text provided they are quoted. Do not confuse this with the quotes needed in VBScript for strings. You need to pass double quotes [Chr(34)] as part of the string. When the quoted string arrives in the batch file, you can either strip the quotes or insert them into the file as is:

Strip the quotes:

echo %~1 > output.txt

or

Keep the quotes:

echo %1 > output.txt

Quote

right now I'm looking at just using the openTextFile method in the script to write to the file, after the batch file has created it.

I'm baffled. Maybe I'm just misreading this, but you're saying the batch file will write a file and then the script will also write to it?

Why keeping shelling out to the cmd processor to create a file? Can't you use the script by opening a text file forwriting and using the FileSystemObject Writeline method?


Thanks that what I was looking for!!

EXCEPT how I am suppose to pass down the quotations as parameters when i;m calling the batch FORM the script.

this is what I have so far in the script I get all the correct colors that represent dim's and strings but

(batchFileFolder) is a var that hold the path to the where the batch file is located
Code: [Select]Set WShShell = CreateObject("WScript.Shell")
dim name
name ="carter"
dim hello
hello ="Hello_World"
dim number
number = "5344"
RetCode = WShShell.Run("""" & batchFileFolder & "myBatch.bat" &" "& name &" "& hello &" "& number"")

thanksPutting quotes around strings that are quoted parameters to methods is enough to drive one to drink, so I grabbed a beer and did it the easy way.

Code: [Select]strRun = batchFileFolder & "myBatch.bat " & """" & name & " " & hello & " " & number & """"
WshShell.Run(strRun)

When it enters the batch world it LOOKS like:

...\mybatch.bat "Carter Hello_World 5344"



batchFileFolder needs to end with a backslash. One parameter is passed to the batch file as a quoted string. Use the method in the previous posts to keep or drop the quotes. I suggest you put a path on the output file in the batch code; you never know what directory the cmd window will default to.

Correction to previous post: Use >> instead of >

Thanks, for the help... really appreciate it.. Actually one last question?

what could possibly prevent a batch file from executing when called from a script?

b/c i'm actually calling a second batch from the same script, but the one that you helped me with is falling to run. however I still get a return code of zero??? but with no output file? could this then be a problem in the batch and not in the script
thanks-Did the batch file actually fail to run or can you not find the output? I believe the default directory for the cmd processor is the %userprofile% value. You can override this by pointing the path of the output file in the batch code.

If you could post the contents of the batch file and the console output of the batch file run, perhaps we can see where to GO next. If you're using echo to create your file, it's difficult to imagine not getting a zero return code.

Quote
this is what I have so far in the script I get all the correct colors that represent dim's and strings

If you have some sort of a VBScript editor you may be able to step through the code and see what is happening.

this is is contents of the batch file...

Code: [Select]@echo off

echo %~1>"C:\Inetpub\buildInstaller\batchFiles\output.txt"
echo %~2>>"C:\Inetpub\buildInstaller\batchFiles\output.txt"
echo %~3>>"C:\Inetpub\buildInstaller\batchFiles\output.txt"
The output that I mentioned was just response.write(retCode) the second batch file that I was comparing it too was contained in the same directory and was outputting to the same destination was as this was. Both batch files were located in this directory and were outputting to the same one. this batch works fine when I call it from the START>RUN dialog just not when I call form the script.
The second script is using the same WScript object and is being called after this one. thanksIt might help to know what the second batch file is doing. There are parameters to the run method which might help:

Code: [Select]object.Run(strCommand, [intWindowStyle], [bWaitOnReturn])

If the second batch file needs the output of the first batch file, it may be necessary to set bWaitOnReturn to True:

Code: [Select]strRun = batchFileFolder & "myBatch.bat " & """" & name & " " & hello & " " & number & """"
WshShell.Run(strRun,,True)

I'm still unsure why you're using batch code especially now that it appears this is ASP code. I'm also confused by the %2 and %3 parameters. The quotes indicate only one parameter was passed (%1).

It might be interesting to see the console log of the batch file.




5871.

Solve : copying last modified file?

Answer»

Hi all,

I'm trying to copy the last modified file in dos.

I can USE 'dir /OD' to search a directory for the last modified file, but how do I capture the top result as a variable???

any ideas??

Cheers in advance This will almost do it:
Code: [Select]dir /OD /B>dirlist.txt
FOR /F "tokens=1,2" %%i IN (dirlist.txt) DO set lastfile= %%i

@echo %lastfile%
But I didn't have time to finish it. I have to run out to a client, when I come back I'll refine it the rest of the way for you.Try this

Code: [Select]dir /-OD /B>dirlist.txt
set /P lastfile=<dirlist.txt
@echo %lastfile%
This does a directory listing, sorting the newest file to the top of the list. The Set /P takes the first line from the supplied file (the newest file) and stores it in the variable %lastfile%

GrahamNice, that /P is the flag I was looking for and couldn't find before I had to leave.Easy to grab the first or last file or folder name in a list of any of the properties DIR can sort using the /O switch - size, name, extension, ETC

Quote


@echo off
REM earliest file in directory
FOR /F %%i IN ('dir /b /a-d /o-d') DO (
set firstfile=%%i
set firstdate=%%~ti
)

REM latest file in directory
FOR /F %%i IN ('dir /b /a-d /od') DO (
set lastfile=%%i
set lastdate=%%~ti
)

echo first file %firstdate% %firstfile%
echo last file %lastdate% %lastfile%

Quote from: gpl on February 19, 2008, 09:26:57 AM
Try this

Code: [Select]dir /-OD /B>dirlist.txt
set /P lastfile=<dirlist.txt
@echo %lastfile%
This does a directory listing, sorting the newest file to the top of the list. The Set /P takes the first line from the supplied file (the newest file) and stores it in the variable %lastfile%

Graham

Nice, that did the job.

I had to move the - to before the D, other wise it's all good.

Cheers guys!!Since we're on the subject of setting a variable with the outcome of the Dir command...


I'd really like to have ANOTHER variable with the date that it was last modified.

then I could display the date that it was last modified at my menu and the user could decided weather to use or not.

cheers for all your help guys. Quote from: blastman on February 20, 2008, 04:00:44 AM
I'd really like to have another variable with the date that it was last modified.

See my post of 19 FebQuote from: Dias DE verano on February 19, 2008, 09:53:57 AM
Easy to grab the first or last file or folder name in a list of any of the properties DIR can sort using the /O switch - size, name, extension, etc

Quote

@echo off
REM earliest file in directory
FOR /F %%i IN ('dir /b /a-d /o-d') DO (
set firstfile=%%i
set firstdate=%%~ti
)

REM latest file in directory
FOR /F %%i IN ('dir /b /a-d /od') DO (
set lastfile=%%i
set lastdate=%%~ti
)

echo first file %firstdate% %firstfile%
echo last file %lastdate% %lastfile%


Hey thats cool.

Thanks.

One problem, if i want to run this for a different directory then it seems to not pick up the time and dates, only the file names??

EXAMPLE,

REM latest file in directory
FOR /F %%i IN ('dir c:\stuff\*.* /b /a-d /od') DO (
set lastfile=%%i
set lastdate=%%~ti
)

echo last file %lastdate% %lastfile%

Would only display;

last file "what-ever-the-file-name-is"

any ideas??

Cheers for all your help. Hmmm... I'm at work right now, so I'll try to solve this later, but for now...

try e.g.

set directory="C:\mystuff"
cd /d %directory%
FOR /F %%i IN ('dir /b /a-d /od') DO (

(etc)
Hi,

Yep that worked a treat


Setting the working directory before running the loop was the ticket.

cheers for all your help.

Thanking you!!!
5872.

Solve : REASON FOR MS-DOS?

Answer»

HI GUYS


WHAT IS MS-DOS USED FORGO HERE. YOU'D BE SURPRISED HOW MUCH INFO YOU CAN FIND ON WIKIPEDIA AND GOOGLE. PLEASE DON'T USE CAPS LOCK AS IT GIVES MOST PEOPLE HEADACHES WHEN THEY READ IT.Basically it is used to provide an environment in which other software can execute. This is the same function as Windows now fills on most home computers. This is called an operating system. Without an operating system software would need to communicate directly with the HARDWARE in a computer. This would complicate software development immensely.
Today MS-DOS is mostly used to run old software that can't run under Windows or in some extent to help fix Windows installations that fail to load.
A lot of people also call the command prompt in Windows 2000/XP/Vista for DOS although this isn't technically correct.Quote from: 4OCKII on January 19, 2008, 12:38:38 PM

it states nothing about what it was used for plus wikipedia is full of s**t.

Did you read the article ? ?Turn off your capslock...HI PATIO HOW R U PALI'm fine.
What point is it you're trying to make ? ?WOW THIS IS AN INTERESTING TOPIC, HUH PATIO? OR IS THIS CAPS LOCK THING A SERIOUS ISSUE AND I SHOULD STOP?Quote from: gamerx365 on January 22, 2008, 06:56:28 AM
WOW THIS IS AN INTERESTING TOPIC, HUH PATIO? OR IS THIS CAPS LOCK THING A SERIOUS ISSUE AND I SHOULD STOP?

YES, you should stop. It's very annoying for most folk and generally bad manners.
5873.

Solve : Troubled by `set`?

Answer»

Hi again guys,

Am trying to count the number of "Running" counters listed in a text document.
Unfortunately I can't see where my SCRIPTING has gone so far south...

The textfile contains ...Code: [Select]SRVR-W2 Counter Running
SRVR-W8 Counter Running
SRVR-QA2 Counter Running
SRVR-W3 Counter Running
SRVR-DB2 Counter Running
SRVR-DB1 Counter Running
SRVR-DB8 Counter Running
SRVR-W1 Counter Running
SRVR-W7 Counter Running
The portion of script that is going south ...Code: [Select]:: Push 'logman query' to a text file.
logman query | findstr /C:"Counter" | findstr /V "System" &GT; %LogmanTxt%

@echo -Collection----- -TYPE------- -Status------
For /F "tokens=1-3 delims= " %%x in (%LogmanTxt%) do (
@echo %%x %%y %%Z

if %%z==Running set /A Run=%Run%+1

)

@echo // Total Running: %Run%.
Currently returns 1.

Any help appreciated.

Cheers,
CameronAnything inside a for loop is like going down the rabbit hole.

Code: [Select]:: Push 'logman query' to a text file.
logman query | findstr /C:"Counter" | findstr /V "System" > %LogmanTxt%

@echo -Collection----- -Type------- -Status------
For /F "tokens=1-3 delims= " %%x in (%LogmanTxt%) do (
@echo %%x %%y %%z

if %%z==Running CALL set /a run=%%run%%+1


)

@echo // Total Running: %Run%.
Hello SideWinder,

Many thanks for the reply.
Unfortunately it wasn't a positive result ...Code: [Select]:: Push 'logman query' to a text file.
logman query | findstr /C:"Counter" | findstr /V "System" > %LogmanTxt%

@echo -Collection----- -Type------- -Status------
For /F "tokens=1-3 delims= " %%x in (%LogmanTxt%) do (
@echo %%x %%y %%z

if "%%z"=="Running" set /A Run=%%Run%%+1

)

@echo // Total Running: %Run%.It did return a farmiliar error during the loop.Code: [Select]-Collection----- -Type------- -Status------
SRVR-W2 Counter Running
Missing operand.
SRVR-W8 Counter Running
Missing operand.
SRVR-QA2 Counter Running
Missing operand.
SRVR-W3 Counter Running
Missing operand.
SRVR-DB2 Counter Running
Missing operand.
SRVR-DB1 Counter Running
Missing operand.
SRVR-DB8 Counter Running
Missing operand.
SRVR-W1 Counter Running
Missing operand.
SRVR-W7 Counter Running
Missing operand.
// Total Running: .Would you have an alternative to what I'm trying to do ??

Cheers,
CameronFound the solution ...

Thought about your comment regarding the loop and the last major script I wrote had issues retaining values within the FOR loop and returning the value after the FOR loop.

The solution I've found (rediscovered) ...

SETLOCAL ENABLEDELAYEDEXPANSION
...
set /A Run=0
:: Push 'logman query' to a text file.
logman query | findstr /C:"Counter" | findstr /V "System" > %LogmanTxt%

@echo -Collection----- -Type------- -Status------
For /F "tokens=1-3 delims= " %%x in (%LogmanTxt%) do (
@echo %%x %%y %%z

if "%%z"=="Running" set /A Run=!Run!+1

)

@echo // Total Running: %Run%.
...
ENDLOCAL

Works a treat. Thanks for the reminder.

Cheers,
Cameron

5874.

Solve : goto help...?

Answer»

I am TRYING to make a batch file with a menu, but it doesn't work. No matter what i push it just goes onto the next line or just exits:
Here is an example:
-----------------------------------------------------------------------------------------------------------------------------------------
@echo off
echo PLEASE PRES 1, 2, 3 ,4 OR 5
@echo.
echo 1.
echo 2.
echo 3.
echo 4.
echo 5.
@echo.
pause

if errorlevel 1 goto 1
if errorlevel 2 goto 2
if errorlevel 3 goto 3
if errorlevel 4 goto 4
if errorlevel 5 goto 5

:1
echo YOU PRESSED 1
pause

:2
echo YOU PRESSED 2
pause

:3
echo YOU PRESSED 3
PAUSE

4:
echo YOU PRESSED 4

5:
echo YOU PRESSED 5You're assuming that pressing a key will set errorlevel?

I hoped (and this is the first time i have used the goto COMMAND) !
Any help will be much appreciated !You could do something LIKE this:

@echo off
:choosenum
set /p num="Choose a number (1-5): "
if %num% GTR 5 cls & goto choosenum
if %num% LSS 1 cls & goto choosenum

if %num% EQU 1 cls & goto 1
if %num% EQU 2 cls & goto 2
if %num% EQU 3 cls & goto 3
if %num% EQU 4 cls & goto 4
if %num% EQU 5 cls & goto 5

:1
echo YOU PRESSED 1
pause> nul & goto end

:2
echo YOU PRESSED 2
pause> nul & goto end


:3
echo YOU PRESSED 3
pause> nul & goto end


:4
echo YOU PRESSED 4
pause> nul & goto end


:5
echo YOU PRESSED 5
pause> nul & goto end


:end

That works quite well, and you can always add in extra stuff if you wanted.And the next homework assignment will be Quote from: Dusty on FEBRUARY 19, 2008, 11:59:55 PM

And the next homework assignment will be
They'll never end...incidentally, if you are checking for errorlevel, you need to arrange the test in reverse order, with the highest errorlevel tested for at the TOP, and errorlevel 1 at the bottom of the list, because "if errorlevel 1" means "if errorlevel is equal to or greater than 1" and if you have it at the top, any nonzero errorlevel will trigger it and the rest will be skipped.

Right about the order of the "If errorlevel" commands.

Nobody mentioned the way you want to set your errorlevel. Set it with the choice command. But wait Microsoft dropped the choice command in recent versions.(I don't know why. It seems that they would have kept it for backward compatibility, even if there are better ways to do the same thing.)(yes I read on this forum that there is a choice written by someone else that you can use, but that is extra baggage.)

By the way Dark Blade, Thanks for the set /p var=... method you posted.
I have been away from writing batch files for a few years and was not familiar.
I will be trying this as it is close to something I'm trying to do.
Quote from: llmeyer1000 on February 20, 2008, 08:50:02 AM
...
Nobody mentioned the way you want to set your errorlevel. Set it with the choice command. But wait Microsoft dropped the choice command in recent versions.

Explore here:
http://hp.vector.co.jp/authors/VA007219/dkclonesup/choice.html
to download various versions of choice .

Quote
(I don't know why. It seems that they would have kept it for backward compatibility, even if there are better ways to do the same thing.)(yes I read on this forum that there is a choice written by someone else that you can use, but that is extra baggage.)
...

No moreso than any other external command. Just put a copy of it in a directory that is in your path, same as MS would have done if they had included it in the first place.


Thanks Dark! i had just been looking at the set /p command before i came back to this forum but didn't know exactly how to use it.

And for those that think this is a homework assignment its not!!! I was just making a batch file for fun.
5875.

Solve : LIST?

Answer»

how to make a list in .bat file where i'll input ex. a number and it go to second third etc place
if i type 1 it will echo:
Code: [Select]1: 1
2: 0
3: 0if 3
Code: [Select]1: 3
2: 1
3: 0etc etc
sorry for bad engWhat is the application for this? More info can help. If a static list, you can have the VALUES passed in memory, but if you want to be able to close the batch and go back in and have it PICK up where it left off, you will want it to read and write from a text file like list.log

DaveIf you want to play with arrays, you can look into vbscriptCode: [Select]If a static list, you can have the values passed in memory,
but if you want to be able to close the batch and go back in and have it pick up where it left offyes that im going to do
but is it possible or no?anyone I've done this in C++ before, but not batch. Only written data to a file in batch.

Just Googled and this is what I came up with for you. One solution other than C++ is Perl. And the person with the problem got it working with the FOR instruction for their application.

http://www.aota.net/forums/archive/index.php/t-7059.htmli made somethink like this and it work
Code: [Select]@echo off
set num1=0
set num2=0
set num3=0
set num4=0
:A
set /P num=
if %num% geq %num1% set num2=%num1% & set num3=%num2% & set num1=%num% & goto B
if %num% geq %num2% set num3=%num2% & set num2=%num% & goto B
if %num% geq %num4% set num4=%num3% & set num3=%num% & goto B
:B
cls
echo.1: %num1%
echo.2: %num2%
echo.3: %num3%
goto Ahow can i do that i have in file
Code: [Select]5 4 3and make
Code: [Select]a=5 b=4 c=3 if you use the for loops and set some tokens, you can get what you want.yes i tryied work on it from hours and it dont workQuote from: ghostdog74 on JANUARY 22, 2008, 12:31:57 AM

if you use the for loops and set some tokens, you can get what you want.

Quote from: devcom on January 22, 2008, 02:23:27 AM
yes i tryied work on it from hours and it dont work

Ghostdog pretty much laid it out for you. Show us some code. We THRIVE on constructive criticism. i have something like this if there are some bugs tell me
Code: [Select]@echo off
if exist list.txt [Here i wont to do for loop like gostdog says] & goto A
set num1=0
set num2=0
set num3=0
set num4=0
:A
set /p num=
if %num% geq %num1% set num2=%num1% & set num3=%num2% & set num1=%num% & goto B
if %num% geq %num2% set num3=%num2% & set num2=%num% & goto B
if %num% geq %num4% set num4=%num3% & set num3=%num% & goto B
:B
cls
echo.%num1% %num2% %num2% >list.txt
[Here i wont to do for loop like gostdog says]
echo.1: %num1%
echo.2: %num2%
echo.3: %num3%
goto A
ok i have it
Code: [Select]For /F "tokens=1-3 delims= " %%x in (list.txt) do (
set a=%%x
set b=%%y
set c=%%z
)
5876.

Solve : can u make a bat file check for any keyboard buttons being hit?

Answer»

i wuz wondering if there is a way for a bat file the look for if any keyboard key was pressed.
not talking about the "pause" command.
but this is wat i want
1st the bat file waits until a CERTAIN button(on keyboard) was pressed(the button would be specified in the bat file)
2nd the bat file responds to the certain button eg.
An FPS GAME
Fire - CTRL
Jump - Space
and so on and so forth.
plz respondQuote from: macdad- on February 20, 2008, 01:59:55 PM

i wuz wondering if there is a way for a bat file the look for if any keyboard key was pressed.
not talking about the "pause" command.
but this is wat i want
1st the bat file waits until a certain button(on keyboard) was pressed(the button would be specified in the bat file)
2nd the bat file responds to the certain button eg.

I haven't gone and researched this - it is just something that I remember from way back in my memory.
Do a Google search for GETKEY . It should be a free dos utility program.

You'll need to read whatever docs you can find with it, along with whatever help the program itself might provide.
Hint: Often with Dos util programs, you can get the program itself to output some BRIEF help to the screen with filename /? or filename -h .

Play with GetKey. Set it up in a batch file, and have your batch file trap for returned errorlevels. (If you don't know what the previous sentence means, just ask.)


Quote
An FPS game
Fire - CTRL
Jump - Space
and so on and so forth.
plz respond

I don't know what that part is about, so I won't comment on it.


Here.... I googled it quickly. You can grab a few utils here, including GetKey.
http://ourworld.compuserve.com/homepages/ken

Have fun learning!


the "An FPS Game" was an example the Fire -CTRL and other things were examples on the getkey thing u were talking about
dude i went to that website, downloaded the file and i now realize u are a complete

GENIUS!!!!!!!!!!!!!!
the utilities solved my problem and also showed me how to Jazz up my bat files THANKS!
Quote from: macdad- on February 20, 2008, 05:43:31 PM
dude i went to that website, downloaded the file and i now realize u are a complete

GENIUS!!!!!!!!!!!!!!




Actually, I'm not. In comparison (to you, I suspect) - what I am, is old .


What that really means is that I've just had more time to accumulate experience(s).
As far as computers and especially batch files go, I've played with a lot of old stuff. And a lot of convoluted batch files. But that was a while back.

Quote
the utilities solved my problem and also showed me how to Jazz up my bat files THANKS!


Having read your post here, and I believe some others AROUND here - in which you'd asked "How do I....?" type questions, I read between the lines and thought that some handy-dandy third party utility type programs are what you need to learn to look for and learn to use.... to accomplish some of the things you want to do.
GetKey is an example of one of those good ol' util programs.
And it does a lot more that I thought you might like to fiddle around with.

You should know that this stuff is considered out of date. Obsolete. Passe.
I'm saying that in fairness.
That does not mean that it is not good stuff to learn. Learning exercises the mind. Can't hurt you.
Besides.... if you spend a bunch of time on a project, and learn how to do it, only to later discover that there was a more modern way to do the job..... well, that in itself is a learning experience too!


I hope you have some fun, and enjoy whatever you learn.

5877.

Solve : Drag and Drop batch file?

Answer»

I want to make a simple batch FILE that will let me drag a file to it and rename it.

IF *.jpg NEQ A.jpg GOTO 1
IF *.jpg EQU A.jpg goto end
:1
ren *.jpg A.jpg
goto end
:end
exit

This script works if you CLICK on the batch file, but no drag and drop.Could someone TELL me what I'm missing.

ThanksThis may make your code generic enough:

Code: [Select]IF %~n1.jpg NEQ A.jpg goto 1
IF %~n1.jpg EQU A.jpg goto end
:1
ren %~n1.jpg A.jpg
goto end
:end
exit

5878.

Solve : Changing Directory Structure / Moving Folders and Files?

Answer»

I am looking for direction in writing a batch file that will move data from 1 directory structure to ANOTHER on a 2003 server.

I did this the first time over the weekend to move approximately 376 GB of data, and I have to do this again for another department in the near future. We are now seeing that some files are missing, while others are not, and we lost about 65 GB that we cannot ACCOUNT for. Thank gawd for backups!

We used the xcopy / delete method as follows:

xcopy e:\Department\SubDept1\%1 e:\Department\Jobs\%1\SubDept1 /e
rmdir e:\Department\SubDept1\%1 /s /q

xcopy e:\Department\SubDept2\%1 e:\Department\Jobs\%1\SubDept2 /e
rmdir e:\Department\SubDept2\%1 /s /q

xcopy e:\Department\SubDept3\%1 e:\Department\Jobs\%1\SubDept3 /e
rmdir e:\Department\SubDept3\%1 /s /q

...and so on.

Is there anyway I can include error checking? I've now added the "tree (dir) /f /a > text.txt" command to write out file names and folder structures both before and after I run the batch so I can visually confirm after the fact, but I would like something that can warn me of an error before it deletes folders and files.

Also, I will be renaming all the Job\%1 folders based on job numbers (ie. 203, 204, 205, ETC.) -- can I make a .txt file containing this job list and run a loop so that it will parse through the numbers from top to bottom?

I've looked for a couple days now and I can't seem to come up with the right solution for either scenario.

Any help on this is greatly appreciated.Hmm... Maybe try to compare the copied files to the original ones using the fc command.

Like this (/A /B /C are only sample commands) :
------------------------------------------------------------------------------------------------------------------------------------------
fc /A /B /C DRIVE1:\First file DRIVE2:\Secondfile
fc /A /B /C DRIVE1:\First file DRIVE2:\Secondfile

I haven't used the 'fc' command for a while so if this doesn't help much go into cmd and type fc /?
Hope this helps! Your original method is not very safe for the data being copied. It seems like it would be very easy to lose files with the copy, then delete without any error checking as you mentioned.

I would personally try ROBOCOPY which is a Microsoft tool that is a free download available in the Windows Server 2003 RESOURCE Kit Tools (http://www.microsoft.com/downloads/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en). With Robocopy, you could use a command like:
Code: [Select]robocopy "e:\Department\SubDept1\%1" "e:\Department\Jobs\%1\SubDept1" /E /MOVE
robocopy "e:\Department\SubDept2\%1" "e:\Department\Jobs\%1\SubDept2" /E /MOVE
robocopy "e:\Department\SubDept3\%1" "e:\Department\Jobs\%1\SubDept3" /E /MOVE
If for some reason a file was not copied correctly, it would still exist in the source, and robocopy would also give you a report at the end telling you how many files (if any) failed.

5879.

Solve : How Many Files Was That????

Answer»

Hey all, I'm WRITING a small script file that will install a number of Windows XP hotfixes using the following SYNTAX in a batch file:

Code: [Select]FOR %%X in (*.exe) DO %%X /quiet /norestart
I also want to be able to display the number of files processed once the script has run its course. Can anyone help me out with that?You can either write logic and count them yourself or let the machine do all the work:

Code: [Select]@echo off
FOR %%X in (*.exe) DO %%X /quiet /norestart
for /f "tokens=1-2*" %%x in ('dir *.exe ^| FIND /i "file(s)"') do echo Total Files Processed: %%x

Hope this helps. Sidewinder, Your tip worked GREAT. Thanks for the help. Can you tell me what's going on in the line of code you OFFERED. Thanks again.

5880.

Solve : Loading programs into memory before executing?

Answer»

Short question: Can I load programs into memory before executing, allowing me to take out the disk while it executes?

Explanation: I'm using a dos boot disk (floppy) that has 5 programs on it, and an autoexec file that executes each one in a specific order.

The 5 files all together (including autoexec) take up 465 KB, enough to fit in conventional memory.

I'm using dos 7.1 right now, but can switch to any version if a certain version will execute the task faster.

As stated, my goal is to be able to put in the disk, let it load to memory, and begin executing. It's a disk I've created for my COMPANY that allows us to speed up computer upgrades.

Thanks in advance for any and all help.I know this may seem silly, but I found the ANSWER to my question shortly after POSTING it (hey, I have been LOOKING for this for weeks, so it's not like this was a simple thing that I didn't RESEARCH)

The program I'm using is called xmsdsk, and is a freeware program for DOS. It does the job perfectly!

5881.

Solve : Batch file that copies text files according to date?

Answer»

Does any one know have a batch file that can search across a network for files that were created today and then copy them to another location across the network?I have had to do that, but try USING this program, Auto mate 6. Download a 30 day trial from here:

http://www.networkautomation.com/downloads/am6download.cfm

Tell me if it helps !
Will try DOWNLOADING the tool

This is the code that some one suggested, but i cant get it to work for my SETUP

@ECHO OFF

IF "%1" == "" GOTO COPY-TODAY
IF NOT "%1" == "" GOTO COPY-DATE


:COPY-TODAY
ECHO. | DATE | FIND /I "Current" > c:\BATCH\CUR-DATE.BAT
ECHO @SET CUR-DATE=%%4 > C:\BATCH\CURRENT.BAT
CALL C:\BATCH\CUR-DATE.BAT

XCOPY *.* C:\BATCH /D:%CUR-DATE% <


GOTO END

:COPY-DATE
XCOPY *.* C:\UPLOAD /D:%1 /-Y

:END
ECHO.
CALL C:\BATCH\DR.BAT C:\UPLOAD



SET CUR-DATE=


DEL c:\batch\CUR-DATE.BAT
DEL c:\batch\CURRENT.BAT




have been trying to get it to work in with this next bit of code

@echo off
echo copying files from 192.168.0.141
pause
xcopy /d \\192.168.0.141\d$\Hypercommain\*.txt \\192.168.0.108\d$\Hypercom\

@echo off
echo renaming file
pause
for /f "tokens=2 delims= " %%A in ('date/T') do (
set date=%%A)
for /f "tokens=1-3 delims=/" %%A in ('echo %date%') do (
set m=%%A
set d=%%B)
ren "\\192.168.0.108\d$\hypercom\*.txt" ZSW%m%%d%

@echo off
echo backing up to ZEDI Backup
pause
xcopy /e \\192.168.0.108\d$\Hypercom \\192.168.0.141\d$\testing


automate 6 didn't work i wanted it to
The whole point of this batch file is to avoid user error
Have designed this batch file so that the user simply clicks on it and it does all the work and thinking involved. Without me having to worry that the user has messed around with the wrong files or settings
Any help is greatly appreciatedWell im stumped. I have never really had to do something like that.Have decided to use a combo of the program you suggested and a bit of my batch file
Automate will find the files i need, copy them to the location i want them to be, and the my batch file will kick in and rename my files as i want them
Thanks for all the help

5882.

Solve : Making Dos Batch create sequencial folders?

Answer»

I am trying to simplify a method for creating a batch file tha will create X number of new folders of the same name but different suffex... 01, 02, 03.

This is the CODE I have so far, but i would like to select the number of folders to make and possible even the name of the folder prefix.

@ECHO OFF
mkdir vids01
mkdir vids02
mkdir vids03
mkdir vids04
mkdir vids05
exit

Can anyone SHED some light here PLEASE!

@echo off
set idx=0
cls & echo. & echo Enter a number & set /p CHS=- & Goto AAA1
:AAA1
Mkdir Name-%IDX%
set /a IDX=%idx%+1
If "%IDX%"=="%chs%" Goto AAA2
If not "%IDX%"=="0" Goto AAA1
:AAA2
cls & echo done. & DIR /a:d /b name **
Super Job. Short and SWEET!

Thanks, Diablo416, I appreciate it.



5883.

Solve : STOP a .exe file by using a .bat command?

Answer»

I'm running XP and AOL 9.0
AOL is good at hogging the processor and thrashing the HD even when AOL is not running. There are 3 or 4 AOL software .exe files that I can stop using the Task Manager bt I'd like to write a small .bat file to stop them for me, running it from the Desktop is possible.

I need to stop aolsoftware.exe , AOLacsd.exe and AOLSP Scheduler.exe in particular.

I don't see any .bat commands that will do this. Any IDEAS please? The simpler the betterYou can use the taskkill utility:

Code: [Select]@echo off
taskkill /im aolsoftware.exe /f
taskkill /im AOLacsd.exe /f
taskkill /im "AOLSP Scheduler.exe" /f

Is that the real name for the third one? If so keep the quotes.

Thank you for that, looks good, but I'm getting the message

'taskkill' is not recognised as an internal or external command, operable program or BATCH file.

I've now found that TSKILL is the equivalent for XP home, TASKKILL only works with Pro.

HOWEVER, it stil doesn't work as I'm getting Could not find process. How do I tell it where to find it? The PID changes each time aolsoftware runs, so this can't be used, I guess.

I have found that TSKILL aolsoftware (without the .exe) kills the process from the DOS prompt but it does not work from the .bat file. TSKILL AOLacsd does no work either way, giving: Access is denied. What next pls?

Took a different approach by iterating the running processes:

Code: [Select]@echo off
for /f "tokens=2" %%x in ('tlist') do (
if /i %%x equ aolsoftware.exe tskill /im %%x /f
if /i %%x equ AOLacsd.exe tskill /im %%x /f
)

I'm stumped with that third one however (AOLSP Scheduler.exe). The embedded space presents a problem. Does it really show up on the task LIST with a space? If not just add another if statement; if it does we may have to use VBScript.

In fact, its only aolsoftware.exe that is the real troublemaker, so the others are just so I can get ALL AOL software stopped, not essential.

However, tlist doesn't work and is not recognised, and has supposedly been replaced with Tasklist. However, my XP doesn't recognise that either. It turns out that I can download Tasklist.exe (where should I put it so it can be accessed easily?)

Tasklist now works from C:/ which is where I put it, and the .bat file now executes cleanly but doesn't stop anything!

(Yes, btw, AOLSP Scheduler.exe does have a space in it)Apparently TLIST came with the NT & 2000 toolkits. TASKLIST came with the XP toolkit. I try not to ask posters to download anything, so let's try this:

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

Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process")

For Each objProcess in colProcess
If objProcess.Name = "aolsoftware.exe" Then objProcess.Terminate()
If objProcess.Name = "AOLacsd.exe" Then objProcess.Terminate()
If objProcess.Name = "AOLSP Scheduler.exe" Then objProcess.Terminate()
Next

Save the script with a vbs extension. You can run from the command prompt with this command: cscript scriptname.vbs You can also run it from the run box as wscript scriptname.vbs. If run from the run box, you'll need path information for scriptname.vbs

Good luck. Excellent - that does indeed stop aolsoftware.exe and aolsp scheduler.exe, although it leaves AOLacsd.exe still running. I don't know what this does, but it doesn't seem to do much and isnt a processor hog, so far.

So, many thanks for your patience and diligence, and do have a good time over the next few days.@ sidewinder: Nice! :-D

@ lifesvoyager: I was playing with the script a bit to kill some other processes and found that this seems to be the case where Windows acts likes UNIX and REQUIRES exact case. Or at least on this machine it did. It is currently running XP Pro with SP2.Thanks for that redeye, but case is correct and AOLacsd.exe still refuses to stop. Also AOLLOAD.EXE won't disappear either. The ones I need to kill are obliging however. odd, innit? (XP Home + SP2)Just a hunch, but it could be that the modules that won't stop are running as services. You can check this by running services.msc from the Start==>Run box.

This piece of code should help. You may have to adjust which modules are processes and which are services.

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

Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process")
For Each objProcess in colProcess
If objProcess.Name = "aolsoftware.exe" Then objProcess.Terminate()
If objProcess.Name = "AOLSP Scheduler.exe" Then objProcess.Terminate()
Next

Set colService = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objService in colService
If objService.Name = "AOLacsd.exe" Then objService.StopService()
If objService.Name = "AOLLOAD.EXE" Then objService.StopService()
Next


well now, I note that the ones that are killable have me as their User Name in Task Manager, but the awkward ones have SYSTEM as their user name.

Is this relevant?Quote

Is this relevant?

Could be. Actually I think the user name is who initiated the job.

There is a fine line between a process and a service more having to do with function. In the services.msc window were you able to find the modules that won't die? Another variable would be are you running as the system administrator? Did you try running the script? Any results?

Note: Stopping a service with the GUI or a script is only valid for the Windows session. The service will revert to it's startup status (automatic/manual/disabled) at boot.'AOL connectivity service' is in the services.msc list - I presume this is AOLacsd.exe?

AOLLOAD.EXE is not in the list by any recognisable name. These are both ones that only die if I kill them from the Task Manager. But they don't seem to be problematic anyway. The ones that thrash the HD are killed by your earlier script which I now run each time I log off from AOL. So all is well, in fact.

Mind you, it amazes me how many processes are listed in the Task Manager and I wonder how many really need to be there.

I'm looking into Linux in the hope of distancing myself from MS if possible.

A successful and enjoyable 2008 to all.
5884.

Solve : Start up windows 311 from dos?

Answer»

im in computer engineering at school, and im stuck on a problem that i have to figure out how to fix for a grade... when i turn on my comp it loads dos, then windows 311 but then it goes back to dos and says hit alt+tab to switch between the 2... but i need it to stay at 311, how would i do that? an answer would be great before noon tomorrow lol...thanksDid you try pressing ALT + TAB?lol of course, but the req for the test thing is that i get it to start up without me having to push that... im GUESSING its the autoexec.bat that i gotta put a command in but idk which one.Any error messages before it switches back to DOS mode?no it just flashes the 311 screen then goes back to the thing that gives u some options to make the dos prompt smaller on the 311 screen, to exit dos, and the alt tab thingWhat happens if you choose to exit DOS?it goes to 311, but thats not the issue, i need it to go there on its own so i can just turn on the computer and it will go straight to 311 and stay at it without me typing anything...While you're in Windows 3.1, in the Program Manager and go to Startup. Do you see something like "MS-DOS Prompt"?

If not, go back to the MS-DOS Prompt and type in:

edit c:\autoexec.bat

The file should text should be similar to the text on THIS PAGE.

Are there any more commands that are different to the commands in the web page above?in addition to the startup FOLDER, verify that there is no RUN=COMMAND.COM type of line in WIN.INI, in addition to looking for a WINSTART.BAT file in C:\WINDOWS ) or wherever windows is installed). if there is a winstart.bat at all, it is possible one of the commands is COMMAND.COM which woud cause this problem as well.


If I was the one who PURPOSELY munged up computer like that ,I doubt anybody would pass. I'd disable the RUN command from program manager using the INI file and REMOVE all GROUPS from the window. Then I'd get config.sys to try to load a text file as a driver. MWA HA HA!

sorry, I got kind of carried away there.

but they actually TEACH this stuff? I gotta boost my ego by taking one of THOSE courses

Also, Dairyman, the only way autoexec.bat could be involved is if the line that started windows also started command prompt, as in WIN COMMAND.COM or something similiar. Other than that, all the other commands will execute when windows is closed.


Ahhh nostalgia. INI files. FAT16. ahhhhhhhlol my comp runs on FAT32 and Win98' is there a Way I could puposely screw up my comp like that lol, I luv DOS
anyway I would probably know how to fix it, just do the exact opposite of what I did lol.Its quite easy to screw up a windows 98 computer, just click "start". lol jk.

5885.

Solve : problem whith converting my .bat to .exe and other problems?

Answer»

I have a program that it can only START once (ex.msn messnger) and i like to RUN it many times i tryed copying file.exe into other names and runned them all in the same time using "start program.exe & start copy1.exe & start copy2.exe" and that worked, so if some one can help my with the batch, the batch file must 1-copy the original file into any name and 2-then it must kill existing processes of the program and the 3-starts the copies and the original the batch i made was :
-------------------------------------------------------------------
@echo off
cd "\Program Files\my prog"
IF NOT EXIST copy1.exe (
xcopy /Q original.exe copy1.exe
)
IF NOT EXIST copy2.exe (
xcopy /Q original.exe copy2.exe
)
taskkill /F /IM original.exe /IM copy1.exe /IM copy2.exe
start original.exe & start copy1.exe & start copy2.exe
exit
-------------------------------------------------------------------
if some one can help me makeing ADVANCED batch file (user can choose the number of files to copy and start -in this case they are 3 two copies and one original) and hiding the error messange ERROR: The process "copy2.exe" not found. this batch is important for many programs,,,,,,,, my other probles is when i USED bat2exe utility which i downloaded from this site and converted that same batch i got error messages:

Parameter format not correct - "\Program
Bad command or file name
File not found - original.exe
0 File(s) copied
Bad command or file name
Bad command or file name
File not found - original.exe
0 File(s) copied
Bad command or file name
Bad command or file name
File not found - original.exe
0 File(s) copied
Bad command or file name
i solved all problems except i couldnt figure away to make the number of files to be run optional for the user, i also like to ask is there is any was to make a GUI INTERFACE for my silent exe file i only need one option (do it) thats all

5886.

Solve : DOS Batch Cmds?

Answer»

Curiosty: in the parameters for
copy extract.exe %ramdrive% > NUL
what is the > NUL parameter

Now to the pertinent question
How to display (ECHO) errorlevel returned from a call?
ECHO %errorlevel% ? which does not seem to work {actually i guess the return from 'ECHO' would be displayed.

IF errorlevel 255 {goto echo255, :echo255, echo 255}
IF errorlevel 254 ...Welcome to the CH forums.

Quote from: kosmith

Curiosty: in the parameters for
copy extract.exe %ramdrive% > NUL
what is the > NUL parameter

> NUL directs output, which would normally be displayed, to a non-existent device. So used with Copy the "1 files copied" and some error messages will not be seen.

For the rest of your here is the guru ROB Van der W on the subject.

When you post please, as a minimum, tell us what Operating System you are using.

Thanks & good luckThanks !!!
Already read Vander w on error return.
OS is Win98 DOS (6.2?)
Still have a question, maybe I did not ask the correct question(s).

1. If a bat, exe or com returns an errorlevel, how do I display it?
set errnum=
someexe.exe /switches
set errnum=%errorlevel%
echo %errnum%
??

2. When an exe or com returns a string value (like a function return) what (local or global) is it returned to?
%1 ? %2 ?
How do I access the return value to parse it?
Sorry for the naivety, but I searched everwhere all day and can't seem to find the therory.
You guys are the last bastion of "Hope" !
Thanks againRe: 1. Quote from: Rob Van Der W
@ECHO OFF
IF ERRORLEVEL 1 SET ERRORLEV=1
IF ERRORLEVEL 2 SET ERRORLEV=2
IF ERRORLEVEL 3 SET ERRORLEV=3
IF ERRORLEVEL 4 SET ERRORLEV=4



IF ERRORLEVEL 254 SET ERRORLEV=254
IF ERRORLEVEL 255 SET ERRORLEV=255
ECHO ERRORLEVEL = %ERRORLEV%

Also see the section headed "In DOS for the rest of us, we can use FOR loops to determine the errorlevel:" in the Rob Van Der W site.
--------------------------------------------------------------------------------------------

Quote from: kosmith
ECHO %errorlevel% which does not seem to work

Not surprising - here's another quote from the Rob van der W site:

Quote from: Rob van der W
However, Windows NT 4 and later make it easy by storing the latest errorlevel in the environment variable ERRORLEVEL:
ECHO.%ERRORLEVEL%
will display the errorlevel.

The %errorlevel% environment variable is only available in Win.NT4 and later, you are running Win.98.
------------------------------------------------------------------------------------------------

Re: 2. Sorry, I don't know but believe this is program dependent. The answer may or may not be found in the program documentation. Perhaps someone else will join in with better info.

Good luck

Dusty,
Thanks for the help ! ! !
I think the light has finally come on.
Now I'll go visit the sponsors websites.
Great Forum, please keep up the great work.
K.O. SmithQuote from: Dusty on January 21, 2008, 12:48:49 AM
Re: 1. Quote from: Rob Van Der W
@ECHO OFF
IF ERRORLEVEL 1 SET ERRORLEV=1
IF ERRORLEVEL 2 SET ERRORLEV=2
IF ERRORLEVEL 3 SET ERRORLEV=3
IF ERRORLEVEL 4 SET ERRORLEV=4
...

It's been a while, but I seem to remember - - shouldn't testing for errorlevel be done in descending order?
Quote from: WillyW
It's been a while, but I seem to remember - - shouldn't testing for errorlevel be done in descending order?

Yes, that is also explained on the Rob van der W site I posted. Here is another extract from that site, the underlining is mine:

Quote from: Rob van der W
The safest way to use errorlevels for all DOS versions is the reverse order check.
Start checking the highest errorlevel that can be expected, then check for the one below, etcetera:

IF ERRORLEVEL 255 GOTO Label255
IF ERRORLEVEL 254 GOTO Label254



IF ERRORLEVEL 2 GOTO Label2
IF ERRORLEVEL 1 GOTO Label1
GOTO Label0

:Label255
(commands to be executed at errorlevel 255)
GOTO End

etc.....

Thanks for your interest.Quote from: Dusty on January 21, 2008, 01:19:39 PM

Yes, that is also explained on the Rob van der W site I posted. Here is another extract from that site, the underlining is mine:

Quote from: Rob van der W
The safest way to use errorlevels for all DOS versions is the reverse order check.
Start checking the highest errorlevel that can be expected, then check for the one below, etcetera:

IF ERRORLEVEL 255 GOTO Label255
IF ERRORLEVEL 254 GOTO Label254
...

hmm... interesting. I'll have to try to remember to check that out.

I find it curious that he used the term "safest". As I remember it, it wouldn't work at all if not in descending order.

In other words, a line like:
if errorlevel 5 some_command
would really mean, ' if the current errorlevel is equal to, or greater than 5, then do some_command '.

So I'm THINKING that if they were in ASCENDING order, like in the first example,
a line like ' if errorlevel 1 ..." would be true with ANY of the errorlevels between 255 and 2 also.

Maybe it's been too long since I've played with this stuff.....

Quote from: WillyW
n other words, a line like:
if errorlevel 5 some_command
would really mean, ' if the current errorlevel is equal to, or greater than 5, then do some_command '.

So I'm thinking that if they were in ascending order, like in the first example,
a line like ' if errorlevel 1 ..." would be true with ANY of the errorlevels between 255 and 2 also.

That's also on the Rob van der W site - here's the quote:Quote from: Rob van der W
IF ERRORLEVEL construction has one strange feature, that can be used to our advantage: it returns TRUE if the return code was equal to or higher than the specified errorlevel.

This means most of the time we only need to check IF ERRORLEVEL 1 ... and this will return TRUE for every non-zero return code.

Yep, a very strange feature indeed but that's typical of the world of programmers





So he is saying that that the code of his that you first quote/posted doesn't work.

That sure seems odd to me. I don't see why he published it.Hold on a second guys.....
The correct (often published) is decending order.
But this works just fine:
FINDRAMD

IF ERRORLEVEL 255 GOTO NoRamDrive
IF NOT ERRORLEVEL 3 GOTO NoRamDrive
echo %errorlevel%

IF ERRORLEVEL 3 SET RAMDRIVE=C:
IF ERRORLEVEL 4 SET RAMDRIVE=D:
IF ERRORLEVEL 5 SET RAMDRIVE=E:
IF ERRORLEVEL 6 SET RAMDRIVE=F:

...

IF ERRORLEVEL 24 SET RAMDRIVE=X:
IF ERRORLEVEL 25 SET RAMDRIVE=Y:
IF ERRORLEVEL 26 SET RAMDRIVE=Z:

IF ERRORLEVEL 27 GOTO NoRamDrive

ECHO RAMdisk drive letter is %RAMDRIVE%
GOTO End

This may become an issue after the errorlevel is higher then 99 (or maybe 200)
It would depend upon the internal storage (should be a single byte 0xFF)

I have tested both, but on on Win98, XP, and 6.21 DOS....................
Wanna bet the issues were back in DOS 3.1 ?
5887.

Solve : URGENT BATCH RANDOM HELP?

Answer»

ok i have windows xp home edition, i have this code

@echo off
set random=
if not '%random%'=='' set random=%random:~0,1%
start C:\docume~1\********\desktop\copyof~1\%random%.txt

and it brings up a random txt file named of numbers from 1 to 9, the problem is, i only need 1 to 5, so how do i set it to only to go from 1 to 5?

using the "if not '%random%'=='' set random=%random:~0,1%" makes it use 1-9 (the "1%" in it sets it to use just the first DIGIT, which can be from 1 to 9, idk what the "~0" does though...)

would appreciate any help!Look at the help for Set
the /A parameter allows you to do arithmetic

the modulo function is % so any number % 5 gives you the remainder after DIVISION by 5 -- a number in the range 0-4
Add 1 to it to get 1-5

Grahamjust so i dont SOMEHOW mess that up, can you give me an example to go with my batch? Thank you for your help!OK - HERES a quick demo

@echo off
set /A randno=%RANDOM% %% 5
set /A randno=%randno% + 1

I have used the variable randno so it doesnt clash with the built-in variable %RANDOM%

Because % is 'special', it has to be DOUBLED within a batch file (on the commandline, you will only need a single %)

GrahamTHANK YOU VERY MUCH!

5888.

Solve : Importing a .reg file using DOS??

Answer»

Hey everyone,

Most likely because of a bad regedit to get rid of a nasty trojan, I now need a password to LOGIN to windows (XP Home), EVEN when trying to login as the Administrator in safe mode, when I never set any passwords in the FIRST place But that's another story...

Luckily, I did export a .reg file before I edited the registry and after hours and hours of searching, haven't come across an in depth guide to import that file into the registry using DOS or the Recovery Console since I'm unable to login. Is it even possible to do this? I have some very important work on this HARD drive so I'm more than willing to do whatever it takes to at least salvage the files I need.

Any Help would be greatly appreciated

-DanJust an update, I just gave up on restoring Windows on that drive, I just bought a new drive and am installing a clean version of windows.Great.
In the meantime to avoid this issue in the future read up on creating and restoring SOLID backups of the registry...
I use ERunt.

5889.

Solve : compair a black space to a string?

Answer»

Hi,

As the title saids really....


I have a varible that sometimes gets set to nothing (if no file present) and I'd like to change the varible to "No File Avaiable" if the VARIABLE is blank.

example,

REM Searching for latest PRICE file and setting varaible's

set directory="t:\price_updates"
cd /d %directory%

FOR /F %%i IN ('dir /b /a-d /od') DO (
set lastfileP=%%i
set newdateP=%%~ti
)

if /i %Lastfile%==" " (set lastfile="No UPDATE Avaiable")

echo %lastfile%

but my if statment doesn't work.

any ideas??



Try this
if /i "%Lastfile%"==" " (set lastfile="No Update Available")

But if the value is truly blank, you might need to test this way
if /i "%Lastfile%"=="" (set lastfile="No Update Available")

GrahamHi,

Thanks for the suggestion.

I've tried both ways but sadly neither has worked.


The variable "lastfileP" is still echoing as a blank.


ggrrrrrr!!!

no wait.......



my bad,

if /i "%Lastfile%"=="" (set lastfile="No Update Available")


does work.

nice. cheers dude.

Quote from: blastman on February 21, 2008, 02:26:53 AM

if /i %Lastfile%==" "

That tests if the string Lastfile is one space, not an empty stringQuote from: Dias de verano on February 21, 2008, 04:48:05 AM
Quote from: blastman on February 21, 2008, 02:26:53 AM
if /i %Lastfile%==" "

That tests if the string Lastfile is one space, not an empty string

would the other example work for an empty string then??

Quote from: blastman on February 21, 2008, 05:18:27 AM
Quote from: Dias de verano on February 21, 2008, 04:48:05 AM
Quote from: blastman on February 21, 2008, 02:26:53 AM
if /i %Lastfile%==" "

That tests if the string Lastfile is one space, not an empty string

would the other example work for an empty string then??



In an IF test, you need to enclose BOTH strings in quotes

if /i "%Lastfile%"=="" (set lastfile="No Update Avaiable")

and available has a letter 'l'.
here try to set it up like dis
set /p Lastfile=What is the name of the file u are LOOKING for?
asks for ^ the name of the file

if not %Lastfile% exists set %Lastfile%="No Update Avaible"(may not have proper spelling)
echo %Lastfile%
^looks for the specifed file and the if the file doesnt exist the it says "No Update Avaible"Quote from: macdad- on February 21, 2008, 05:52:36 AM
here try to set it up like dis
set /p Lastfile=What is the name of the file u are looking for?
asks for ^ the name of the file

if not %Lastfile% exists set %Lastfile%="No Update Avaible"(may not have proper spelling)
echo %Lastfile%
^looks for the specifed file and the if the file doesnt exist the it says "No Update Avaible"

I am afraid this is nonsense
Dias de verano,

You sir, are a star!!

thanks for all your help over the last few days.

Couldn't of DONE it without you.

Cheers.
5890.

Solve : How to Browse a file in DOS..???

Answer»

can anybody tell me...??how to browse a file in dos..??plz..TQif you just want to read a text file, then
more < filename
will page through the file
GrahamIf you would LIKE more functionality than the BUILT in more command, then try list.com .
For example, more does not allow you to scroll up and down, but only pages through in one direction. List will let you scroll.

List has MANY more functions than just this though.

You can download list91k.zip here:
http://www.oregonfast.net/~steen/msdos.htm

I like to create a DIRECTORY for utility PROGRAMS such as this. Unzip the archive there. Be sure to INCLUDE this new directory in your path, so that any utilities like this are available from any directory.

List.com is a must-have for me.

5891.

Solve : Checking disk space on a remote drive from a batch file?

Answer» HELLO,
I am running Windows XP 5.1 SP2, and do daily backups to a networked machine using a scheduled batch file.
I need to do a disk space check, but I don't have Freedisk. I have downloaded several versions but none of them worked.
Instead, I would like to use
dir |FIND "bytes free">tempfile
and then parse the output to check space but I can't get the contents of tempfile into %x batch file parameters.
Please can you suggest some way of doing a disk space check from a batch file?
Thanks
limebear
Code: [SELECT]for /f "tokens=3" %%x in ('dir <path> ^| find /i "bytes free"') do echo %%x

The value of the free space is in the %%x variable and there is no need for a tempfile. Keep in mind that the value is an edited string and not numeric. Replace with a valid value.

Thank you for that, I have that working. But I am still stuck.
for /f "tokens=3" %%x in ('dir ^| find /i "bytes free"') call parse.bat
gets me one instance of parse.bat with an indeterminate number of %1 %2 %3 etc filled with portions of the free size. But I can't see a way to get these into a single integer. Can it be done with SET and then tested with IF > ?
Thanks very much
limebear
Sorry I should have said at the outset that I'm trying to AUTOMATE a warning when disk space gets below a threshold, so printing out a string indicating the actual space won't do it. I need some kind of test.
Thanks
limebearQuote
Can it be done with SET and then tested with IF >

YES, but it gets very strange accessing the variable.

Code: [Select]setlocal enabledelayedexpansion
for /f "tokens=3" %%x in ('<path> ^| find /i "bytes free"') do (
set size=%%x
set size=!size:,=!
echo !size!
)
echo %size%

By replacing the commas with nulls you should be able to do compare operations. Just note that within the for loop you access the size variable with !size!, and from outside the for loop you access the size variable as %size%.

I'll leave the rest to your imagination. Thank you very much,
it's all working now.
cheers
limebear
5892.

Solve : Trying to use DOS to re-load missing XP file?

Answer»

This really is a DOS question, so bear with me: Our Compaq Presario 2100 won't boot (running XP Home for a couple of years now)--we get a box saying it can't find "lsass.exe". No luck booting in any of the alternate modes, either--same message.

Can't use the QuickRestore disk set 'cause that reformats the HD, and we need data that's been stored since our last backup. So that won't help.

I don't think this is hard-drive failure but rather a fluke deletion or file rename due to our cat walking on keybd (seriously). If that's the case, I wondered if it would be possible to make a DOS boot disk, boot the Compaq to DOS and then copy the missing file (from another of our XP computers) to its normal LOCATION on the Compaq.

So...I've made a bootable DOS CD (6.22), using the bfd/bfl instructions. And the Compaq does indeed boot to DOS. **Problem is** the computer comes up under drive R or A, but regards C as an invalid drive letter. And I don't know the DOS command to tell the computer to shape up and find C!

Other than the missing lsass file, the hard-drive is working normally--as verified by watching how fast files loaded when trying to boot into Safe mode--but still can't find a command to get it to recognize C:. From reading the command syntax and functions I don't think Assign and Subst will solve anything, so...any ideas would be greatly appreciated.

Thx. --sfThe Windows partition is given the letter C by XP Home but your DOS disk but it will not appear at all to a DOS boot disk if the file system is NTFS. (DOS does not read NTFS)

Have you looked in drives A and R?


You may have several options:

One option is insert your original WindowsXP CD, and boot the computer.
Hopefully you will get an option to GO to a repair mode. XP will attempt to replace the missing or corrupt files. I have used this option successfully, but it's been a while and I can't remember the details of how to get to the menu and what to do when there. Maybe someone else can fill you in on this option, or Google "Windows XP Repair" and read up on it.
I think I would try the repair before I went messing around copying the file manually, but if you want to do that, here is option 2:


Go to:
www.nu2.nu/pebuilder/
and make a Bart's PE boot cd from your WindowsXP cd. This boot cd will recognise your NTFS partition and better yet if you are not good in DOS, it is Windows XP along with the GUI you are more familiar with.(maybe a stripped down version of XP, but XP nonetheless) Instead of My computer or Windows Explorer, you will be using the "a43 File Management Utility"

See the recent thread named :
"copy large files from unformated/unknown partition" started by marcusb
(His problems were much WORSE than yours.)


If you get the operating system booting up again, great! Otherwise see option 3.


Similar to option 2, the Bart's PE boot is your best bet for getting your data (that you never backed up before) backed up now. Then you can use the restore disks, or whatever to reload a new operating system.
Thanks to both of y'all--good points, good info.

Dias: I'd forgotten that XP typically (or is it always?) uses NTFS, and that DOS can't read it. But I would have thought that DOS would recognize the *physical device*, even if it couldn't read any data from it. But that's what I get for thinking.

Drives A and R: A: is a virtual device created in RAM by the CD. The Bart-disk guy noted that lots of new 'puters don't have floppy drives, so he needed a workaround. The A drive holds DOS, in a dozen or so directories that I didn't recognize. Some of these directories contain ".cab" subdirectories, so I suspect there's a lot of higher-level capability there if I just knew the magic words.

The R drive seems to be just two files, one of which is the missing lsass.exe that I added to the CD in case I could copy it. I forget the other, but it was only 1Kb or so, and may have been an autoexec.bat that created the virtual A drive and loaded DOS to it.

LLMeyer: Option One seems very attractive but unfortunately the Compaq, like most machines that came preloaded with XP, doesn't have a Windows CD as such. Instead the info on the CD is loaded on the hard drive at the factory. Then the image file unpacks itself as the XP OS.

Though we don't have an XP CD as such, we do have a set of 4 "QuickRecovery" CDs, and it *may* be that if you insert one it may give you the option of just scanning for any missing XP files. I think that's the feature you used once before. But the manual said the QR utility would re-format the HD, so I was reluctant to pop it in just in case it had an autorun on it and wouldn't give me a choice. Yeah, I realize that's unlikely but I've run into crap like that before!

Tried making a Bart's PE bootable CD from another XP machine (different mfr) but Bart's instructions say that using an "OEM version" of XP to make a boot CD almost never works--and sure enough, it didn't. Evidently there's a machine-specific file on OEM versions that prevents the OS from booting other machines. Understandable.

Since at this point it seems there's no way to boot the Compaq with enough functionality to permit copying the missing file to C:, I considered one other idea that was a longshot but...: What about removing the Compaq's HD, putting it in our XP desktop, and then explore it like any other hard drive? Since I wouldn't be needing it to boot up the desktop, the missing file shouldn't be a problem.

So...anybody heard of the adapter? Or why moving the HD to the desktop won't fly? Thanks. --s
I realize the connectors on notebook drives are different from those on standard HDs but surely there's an adapter to enable their use. At least, I'd think so.Quote from: sf44

Since at this point it seems there's no way to boot the Compaq with enough functionality to permit copying the missing file to C:, I considered one other idea that was a longshot but...: What about removing the Compaq's HD, putting it in our XP desktop, and then explore it like any other hard drive? Since I wouldn't be needing it to boot up the desktop, the missing file shouldn't be a problem.

So...anybody heard of the adapter? Or why moving the HD to the desktop won't fly? Thanks. --s
I realize the connectors on notebook drives are different from those on standard HDs but surely there's an adapter to enable their use. At least, I'd think so.

Very common practice in data recovery. Adapters are shown in the attachments. Hopefully your desktop hard drives are ATA.

The bootable NTFS4DOS will read/write in the NTFS file system using a version of Dos. It's free, can be downloaded and is also available on the Ultimate Boot CD which is also freely downloadable.

Good luck



[file cleanup - saving space - attachment deleted by admin]I agree, except it's not really a long shot.

Like Dusty said:
Quote from: Dusty on February 19, 2008, 01:02:37 AM
Very common practice in data recovery.

Once you get an adapter you will be nearly home free.

Or, maybe one of your friends has a good copy of XP and would make up the Bart's PE disk for you. That and a USB drive would work equally well, without waiting for an adapter to be delivered.

The NTFSDOS program Dusty mentioned might also work for you, but would be awkward for a person not too familiar with DOS.
Thanks to all for the suggestions. I was able to d/l the NTFS4Dos utility, make a DOS boot disk and explore the hard-drive. Drive checked out fine--no bad sectors, and total size was as expected. But to my surprise, when I entered the cmd to copy the replacement "lsass.exe" file (for which Windoze had said "Object name not found" when I'd tried booting normally) to Windows/system32, the utility asked if I wanted to overwrite the existing file.

I then checked and the lsass.exe file was in its normal location, showing the usual size.

So now the question is, Why is Windoze saying it can't find a file that DOS shows as being where it's supposed to be? Of course at this point I guess this is no LONGER a DOS question so I'll be heading over to one an XP forum. But many thanks for the help. I can confirm that NTFS4Dos is quick and effective, and its chkdskg utility works well. --s
Are we clear about whether the file is lsass.exe with a small L as the first letter, or Isass.exe with a capital I as the first letter?

And, those with longer memories may remember the Lsass worm.

Quote
The LSASS process manages user logins, and as such is a common target for infections on PCs running various versions of Windows.

Here's a description of this virus from Trend Micro:

"This worm exploits the Windows LSASS vulnerability, which is a buffer overrun that allows remote code execution and enables an attacker to gain full control of the affected system. To propagate, it scans the network for vulnerable systems. When it finds a vulnerable system, this malware sends a specially crafted packet to produce a buffer overflow on LSASS.EXE. This worm can cause LSASS to crash and FORCE Windows to restart."


Quote from: sf44
I was able to d/l the NTFS4Dos utility, make a DOS boot disk and explore the hard-drive.

Good news - this utility should be in just about everyones software toolkit, at least those who use the NTFS...

Lsass was\is associated with the Sasser worm, I thought it was dead-in-the-water, what malware defences are you using?

Suggest your first move should be to backup essential files then, and only then, attack your problem.

Good luck again.At any rate you'd be better off using the Recovery Console from an XP CD to do these repairs anyways...Dias: I'm *reasonably* clear that the file is Lsass as opposed to Isass. But I'll look again-- since I'd seen lsass I may well have seen what I expected to see instead of what was actually there!

Dusty: We use AVG-Free. Got tired of Norton/Symantec locking up the computer all the time. Since the change, no lockups. We get virus def updates daily.

I'll certainly admit to not backing up as often as I should. As inexpensive and large as external HDs are, you'd think someone would have automated that by now for those of us who sometimes forget. Losing even a week's work is too costly!

Patio: Can you use Recovery Console by booting with a CD that's not the one on the ailing computer? I would think Windoze would pitch a fit, but... How do you call Recovery Console?

Thanks to all.Patio-- Just found your comment in the XP forum on how to call Recovery Console. Now if just one of our computers had come with actual boot disks instead of having the OS loaded on the HD, we'd be in great shape!

Does anyone know if Compaq's "Quick Recovery" CDs offer the same Recovery Console option instead of just automatically reformatting the HD?Any Windows XP CD will work for running the Recovery Console...
The one important thing is that the CD match what version and service paks you have installed: XPPro w/SP2 needs a CD that contains exactly that.

Some OEM CD's but very few have the ability to load the RC from them but they are rare. Best bet here would be to contact the manuf.

Another more tedious way would be to DLoad the 6 floppy set from Microsoft and do it that way. There are instructions on the DLoad site for making it a bootable CD if no floppy drive is available.

More Info...
5893.

Solve : Need help accessing a Directory in DOS?

Answer»

I need to know the RIGHT "CD" or "CHDIR" information to get access to a CERTAIN directory in DOS. I have Windows Vista.

Here is the directory I"m trying to get to: mysql5.0.45

See it has them periods in the directory name. When I do "cd mysql5.0.45",
it gives me this error message : "Invalid directory".

Thanks,

ChrisWhat exactly is the name of the direcory, including the whole path ?
Your cd command would then be
cd "c:\the whole complete path\mysql5.0.45"
GrahamTry with the directory in quotes...CD\" mysql5.0.45"I have tried the things listed buy they never worked. Does anybody know of any other ways or some where else I can get help at?it would help if you told us where it lived !

Use windows EXPLORER to navigate to the mysql5.0.45 folder, then copy the full path from the address bar at the top, paste it into a reply and we will be able to help
GrahamC:\wamp\bin\mysql\mysql5.0.45In that case, the following line will take you there

CD /D "C:\wamp\bin\mysql\mysql5.0.45"

note the /D PARAMETER, it will even CHANGE drives for you if you arent on the C: drive
Graham

5894.

Solve : Caps Lock Toggle in CMD?

Answer»

Hello,

Is there a command to toggle the caps lock key on and off? I am working with a batch file, and I would like to have the batch turn on CAPS when running and turn it off when it exits.

Thanks! Google is your friend !

SEE here -> http://support.microsoft.com/kb/71511

Graham@ Graham

Thanks for the tip! I TRIED their directions, but sadly it will not work. I can create the .COM file and everything, but it will not turn caps on. Back in the day, ONE could edit the config.sys file. But that only affected boot-up not runtime.

Other things that might have been "better brought to your attention yesterday."

  • I am using Windows XP Pro.
  • I don't have DOS installed separately.
  • Coffee may be the answer.

I will run with your earlier piece of advice and ask the Google sages and see what else I may find. I was really hoping it would be something simple vs compiling assembler code. what about this link ?
http://answers.google.com/answers/threadview?id=411459

Graham@ Graham

I read that second link and I am avoiding downloading other SOFTWARE if possible. I did find a script that will send the key, but cannot check current state of the caps lock.

Here is the script:
set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "{CAPSLOCK}"

Which may work ok for my purposes as long as I remember to keep my caps lock key off by default. I might try to keep digging to find any information about testing conditions, but I may just call it here.

Thanks for the help!!I cant believe how long Ive been searching for a solution for this !

this page http://www.robvanderwoude.com/debug.html#KeyLocks

explains why the caps_on program does not work using XP (or greater) ... he shows a batch that will test the status of the caps etc locks -- depending on this, you could call your vbscript to toggle the status

GrahamQuote from: redeye on January 02, 2008, 09:51:14 AM
Hello,

Is there a command to toggle the caps lock key on and off? I am working with a batch file, and I would like to have the batch turn on CAPS when running and turn it off when it exits.

Thanks!
you may WANT to show what you are doing in the batch file. In a batch, its non-interactive, so I don't see why you want to turn on CAPS.
5895.

Solve : Date problems in a btach file?

Answer»

I need to set up a new batch FILE that will move files from one directory to another. The problem that i am having is everyday my system CREATES the files in a date folder like 20080220. Is there a WAY to do a copy command that can look at the system date and change the format of that date into the format that my system is USING?Quote from: helpneeder on February 20, 2008, 03:41:22 PM

Is there a way to do a copy command that can look at the system date and change the format of that date into the format that my system is using?
Yes (assuming you are RUNNING a current version of Windows). It will depend on the date format your computer is using, but for U.S. English, my default date is in the format of:
Thu 02/21/2008
in which case the following should work:
Code: [Select]set DateFolder=%date:~-4%%date:~-10,2%%date:~-7,2%Thanks this is perfect!!!!!!!!!!
5896.

Solve : Formatting Variables?

Answer»

Hi Guys,

In Unix land I can easily format VARIABLES by using the 'typeset' operator, however I'm at a loss to know if I can achieve the same in DOS.

As an example:
My variable listing count will NEVER reach +99.
So I'd like to prefix numbers 1 thru 9 with a 0 (zero) to keep reporting neat.
01
02
03
...
08
09


Is this possible in DOS ??

Cheers,
Cameronyes - and no
there are no simple commands, but check out the SET command, you could prepend a 0 then take the rightmost 2 digits

GrahamThanks for the response Graham.

Unfortunately that doesn't do the trick ....

Tried a number of variations with no success.

C:\>set /a var2=%VAR1:~2,2%+1
1
C:\>set var
var1=01
var2=1

C:\>set /a var2=00%var1%+1
2
C:\>set var2=00%var2%

C:\>set /a var2=00%var1%+1
2
C:\>set var
var1=01
var2=2

C:\>set var2=00%var2%

C:\>vbscript.
Code: [Select]For i=0 To 99
WScript.Echo Right(String(2,"0") & i, 2)
next
Try this test :
Code: [Select]for /l %%a in (1,1,15) do call :doit %%a
goto :EOF

:doit
set test=0%1
echo %test:~-2%
GrahamMany thanks gpl,

That's done the trick.
Darn my memory sucks.

Thanks also to Graham and ghostdog74 for your suggestions.

Cheers,
Cameron

5897.

Solve : Viewing short file name(SFN) on an XP system(simple I hope)?

Answer»

I've searched the internet a bit for this topic but did not come up with anything good. All the help seemd to AID in getting LFN from older systems.

Want to do a DIR C:\?\ and sent to a TEXT FILE >sfn.txt essentially I need a TREE listing of a DIRECTORY outputted to a text file.

Thanksdir /x c: **if you want only the short names

for /f "tokens=5*" %%e in ('dir /x C:**') do echo %%e>>yourfile

5898.

Solve : Call Shell Script from a DOS batch file?

Answer»

Hi,

I want to call a Unix SHELL SCRIPT from a DOS batch file. Could you please assist.


Thanks and Regards
Bhaskar Wahal.show how your shell script looks LIKE. If you don't have environment to RUN *nix commands installed on your system, you can't run.

5899.

Solve : Simple batch file help for noob?

Answer»

I downloaded shutdown.exe and everything works great when I SUSPEND (standby) the computer. The computer suspends automatically and starts up automatically. However, I still have the no hibernation problem. I don't have the hibernate BUTTON when I hold down the shift key, and when I use shutdown.exe to hibernate i get a WINDOWS error. "Insufficient system resources exist to complete the API". Anybody know how to fix this? SOUNDS like you may need the KB909095 fix from Microsoft.

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

Quote

The computer occasionally does not hibernate and you receive an "Insufficient System Resources Exist to Complete the API" error message in Windows XP with Service PACK 2, in Windows XP Tablet PC Edition 2005, or in Windows XP Media Center Edition 2005

SYMPTOMS

You use a computer that is running Microsoft Windows XP with Service Pack 2 (SP2), Microsoft Windows XP Tablet PC Edition 2005, or Microsoft Windows XP Media Center Edition 2005. When you try to put the computer in hibernation, the computer occasionally does not hibernate. When this problem occurs, you receive an error message that is similar to the following:

Insufficient System Resources Exist to Complete the API.

When you experience this problem, the hibernate feature is not available on the computer until you restart the computer.

This problem typically occurs when the computer uses 1 gigabyte (GB) or more of RAM.




5900.

Solve : Current Date -1?

Answer»

Hi

I need some help creating a batch file which basically takes the NAME of a file (which is made up of the date) and then the date being reduced by one. For example:

I import IIS Weblogs on a daily basis, however I always TAKE yesterdays file. Therefore this morning I imported the file labelled ex080102.log. What I would like to do is using a variable which takes the current date, get the batch file to retrieve the day befores log file.

The code I have so far is as follows:

@ECHO OFF
REM **********************************************
REM ** Batch file to open location of Weblogs on Web Server 1
REM ** and Web Server 2 and then copy to E:\weblogs
REM **********************************************

:BEGIN
CLS

REM ** Set the variables

SET WS1=Web Server 1
SET WS2=Web Server 2
SET CurrDate=%date:~-2,2%/%date:~-7,2%/%date:~0,2%

REM ** Create mapped drives on both web servers

net use P: \logs\W3SVC1597409361 /persistent:no
ECHO %WS1% weblogs directory mapped successfully to P:\
ECHO.
net use Q: \Logs\W3SVC1597409361 /persistent:no
ECHO %WS2% weblogs directory mapped successfully to Q:\

REM ** Give the USER 4 options to choose from

ECHO.
ECHO 1
set choice=
set /p choice=Select the number of weblogs you wish to copy from the web servers:
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto One
ECHO "%choice%" is not valid please try again
ECHO.
goto start
:One



goto end
:END

What I need is the code that is executed when the user selects option 1 to copy 1 days worth of logs back from the servers. Once I have this I can then update the code to have 2 or more days worth etc.

Thanks in advance.Microsoft have a very useful utility program, Logparser - FREELY downloadable from here http://www.iis.net/downloads/default.aspx?tabid=34&i=1287&g=6

I use it to put the date into variable %yesterday% like this :

Code: [Select]"C:\Program Files\Log Parser 2.2\logparser.exe" -o:NAT -q:on "Select Top 1 TO_STRING(SUB(SYSTEM_TIMESTAMP(), TIMESTAMP('01-02', 'MM-dd')), 'yyMMdd') as d1 Into '\yesterday.txt' From System"
Set /P Yesterday=<\Yesterday.Txt
Del \Yesterday.Txt
Or you could search for a vbscript solution

Graham
Thanks Graham

That worked perfectly.