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.

4051.

Solve : messaging using DOS?

Answer»

does anyone KNOW the commands and syntax for sending messages using DOS via IP addressess. I thought that it had something to do with ping/send etc but I FORGOT! who can help me?net send computername or ip - ADRESS .....To send messege : net send ip/host messege
To ping the server (to see if it is online or off,sometimes didnt WORK) : ping ip/host

4052.

Solve : undeleting command in dos??

Answer»

Please help me with the DOS COMMANDS for undeleting or recovering lost/ hidden files in the system.

RegardsAre you talking real DOS or some version of Windows command PROMPT?i mean command prompt in windows XP version
Quote

Are you talking real DOS or some version of Windows command prompt?

Hidden files are neither deleted not "lost". They have the file attribute h. If you want to "see" a hidden file or files change the attribute using the attrib command at the command prompt.

The undelete command is not available in XP/NT systems. If a file is deleted it MAY still be available in the Recycle bin. If the Recycle bin has been CLEARED you will have to use a third party program to recover the file.

See here for a list of commands available in XP/NT and here for an interesting article on file RECOVERY and here to download a recovery program named Restoration. The MS Command Line Reference can be found here

Good luck
4053.

Solve : Undeletable folders?

Answer»

How can you make a folder undeletable on Windows 2000/win XP. I'm not aware of any file attributes that make this possible. Usually files marked non-delete are protected system files (usually hidden) which are vital to the OS or files that are in use by another process.

If someone knows the answer, please share it with the rest of us.

So is there a way to create a protected system file?Not really. Windows has a mechanism (sfc) where it can protect it's own files. Since the definitions of those files reside within the OS itself, everything stays stable. On the other hand you can create encrycpted folders where you can password protect your files.

On a multi-user MACHINE, files PLACED within the %userid% DIRECTORY are unreachable by other users.

What are you trying to accomplish and why is this question in a DOS forum?

I want to make a folder that other people cant delete(PREFERABLY USING a password) and i wanted to know if theres a way of doing it with DOS

4054.

Solve : Saving doskey history to a text file?

Answer»

How can i save the doskey history to a TEXT file?If you think this thru it should be pretty simple:

doskey /history > doshistory.txt

Good LUCK. That really HELPED. THNX!

4055.

Solve : Printing MS DOS Screen?

Answer» HI,

I am PROGRAMMING in Turbo Pascal 7.0 and get some graphics and text as a RESULT.

But when I need to make hard copy og this issue I get stuck.
Even PRINT screen doesn't copy this graphics, but only text.

Does anybody have idea how to print Turbo Pascal result?

Any help APPRECIATED!
4056.

Solve : CACLS without prompt?

Answer»

How can you use cacls so when its asking"Are you sure yes/no" it atoumatically would SAY yes, without the user input There are no SWITCHES for this. Try writing a script to do this directly.

Happy Scripting. What about the /yes command. Ive seen it for other commands, but not sure if itll work for cacls. Thnx in advanceCACLS is used to list or modify the discretionary access control list. My research turned up nothing about a /yes switch. Keep in mind that switches must be programmed into each command. Apparently to CACLS the /yes switch is meaningless.

Specifically, what are you trying to do?

I want the CACLS to run and automatically choose yes when its asking for YES/NOYou could try piping the RESPONSE to CACLS:

echo Y | Cacls.exe or echo yes | cacls.exe

You may have to play around with this, but most (not all) UTILITIES will take input from the pipe.

Hope this helps. THANKS a lot! It worked!

4057.

Solve : print command?

Answer»

a fairly EASY question:
In batch files, what is the equivelent of the BASIC keyword 'PRINT' and how would I use it?ECHO is PROBABLY as near as you will get

Echo Get out of here

will display Get out of here on the monitor.THANKS, it's good enough for my needs.
I was struggling trying to do:
@echo
get out of here
@echo off
everytime I wanted the computer to 'PRINT' something.
needless to say, it didn't work the lazy WAY to do things>http://www.robvanderwoude.com/index.htmlmagic plank - you're welcome, thanks for coming on back.Maybe try thise :
msg * messege

4058.

Solve : Help with batch file which can copy, rename, edit?

Answer»

Hi, can ANYONE help me with this problem?
I need script which can copy directories and rename them (e.g. C:\path\a123 to c:\path\b123).
And one more thing. In this directories are files *.CFG which includes WORD "AKCEPT" and i need change this string to "INTEGR". Know SOMEONE how to?
ThanxMaybe :
copy c:\path\a123.txt c:\path\b123.txt
?

4059.

Solve : Im on a school computer without a run command,HELP?

Answer» IM on windows xp, no run command, how do i access DOS on this computer... i cant download anything either... PLEASE HELPI dont know a ton about this and im probably wrong but if you WANT to get a command prompt open notepad and type in "command.com" then save the file with the extension ".bat". when you run the file it should give you a command prompt
hope this works for youSince it is a school computer it's likely they might have those permissions turned off.

However you can try going to Start/Run and type in command and hit Enter.

patio. Downloading anything will be a problem as you won't be having write permissions.

I think you can open the command prompt.
Give US the scenario of what you have tried and what you can't.the run command is completely gone from this computer the notepad thing wont work... but one of the other classmates accessed dos using MS- Word and some thing he did in there, then the dos screen comes up, but i dont know how pleaaaase help, i need to be able to get it up i HAVE NO RUN COMMAND AT ALL..... please helpIf there is no Run command on the Start menu this tells me that this is how the school wants their machines...in other words they have disabled it.

Why not ask them about what it is you are trying to do.

patio. I have done this same trick at my school, because i am in the very same scenario...

IF you have Windows XP at home, or anywhere else where it is unrestricted...

Make a shortcut to the RUN program, and take it to your school computer.

When you click on the RUN shortcut type in CMD
and [glb]U GOT DOS![/glb]You need to talk to the ADMIN......

Quote
I have done this same trick at my school, because i am in the very same scenario...

IF you have Windows XP at home, or anywhere else where it is unrestricted...

Make a shortcut to the RUN program, and take it to your school computer.

When you click on the RUN shortcut type in CMD
and [glb]U GOT DOS![/glb]



Huh ? ? ? ?

patio. i think he means save it on a floppy or something and take it to ur school and load it on or u could if they dont have RIGHT click bloced then just right click goto new then shortcut then make the short cut to cmd or command.com or msdos command promt where ever but most likly ur admin will have blocked that

u have notepad and it dosent work?

just open it and type in start and save it as what.batQuote
You need to talk to the admin......


Or the admin may come to talk to you!
Quote

Make a shortcut to the RUN program, and take it to your school computer.


Where does RUN place to make shortcut to it?
Or any other way to make shortcut to RUN?
Quote
i think he means save it on a floppy or something and take it to ur school and load it on or u could if they dont have right click bloced then just right click goto new then shortcut then make the short cut to cmd or command.com or msdos command promt where ever but most likly ur admin will have blocked that

u have notepad and it dosent work?

just open it and type in start and save it as what.bat



as i said...HUH ? ?

patio.
4060.

Solve : Batch file inserts a charcter?

Answer»

I've created a batch file that copies all network DRIVES into a text file for me. If I TYPE each line into the command PROMPT individually, it works. However, if I RUN the batch file it inserts a character in the command line which causes the command to crash.

The line 'net use | find ": \\driver\folder" > c:\share.txt' becomes 'net use | find ": \\driver\folder" 1>c:\share.txt'

Is there a way I can stop this?The extra 1 you see is not really an extra character. When the interpreter PARSES your code, the extra character you see represents which data stream the output is directed to.

1 = STDOUT
2 = STDERROR

Hope this helps.

4061.

Solve : Search en replace text in files?

Answer»

Hi there, I'm here for asking a quite complicated script, I tried it for myself some thime but I can't write a good one. So perhaps you guys can help me. I would like to create a batch file that search (in the same FOLDER where the batch files stands) - in all files with the extention .html - at the FOLLOWING text in the files: menu=new obj("menu^^2^+^4^+^17^+^12^+^8.2^+^17^+^Arial^+^cccccc^+^f0f0f0^+^ffffff^+^000000^+^999999^+^ffffff^+^n",new obj("info^^^^^^",)

and replace it by -example-: testCan you use [highlight]WinGrep[/highlight]?
This what it's designed for:

Quote

Windows Grep is a tool for searching files for text strings that you specify.

Although Windows and many other programs have file searching capabilities built-in, none can match the power and versatility of Windows Grep.

The PROGRAM combines the power and flexibility of traditional COMMAND line grep utilities available on DOS, UNIX and other platforms with the ease of use of Microsoft Windows.

In addition to searching, Windows Grep also performs global replacing in your files, with complete safety.

Windows Grep is designed for searching plain-ASCII text files, such as program source, HTML, RTF and batch files, but it can also search binary files such as word processor documents, databases, spreadsheets and executables.
I want to do it in BATCH
4062.

Solve : flashing command line (netstat -a)??

Answer»

my friend was recently hacked by WAY of having a trojan installed on her computer. anyway, now she seems to have a problem with a flashing command line when she does a netstat -a. can anyone explain why this happens?
Some DETAILS might help us help you. OS, hardware, is a router in use etc...OS is windows xp, no router in use. computer is an HP. do you need me to be more specific? the command line/DOS opens up, just that when a command is entered, such as netstat -a, it flashes and closes instantly.Thanks for the info...

Quote

the command line/DOS opens up, just that when a command is entered, such as netstat -a, it flashes and closes instantly.

Can I now take it that the same problem occurs with commands other than netstat -a :-? Please try other entries at the Command Prompt such as the humble Dir so that we can narrow the problem to EITHER the command prompt or the command being entered.

Which command prompt is being used, Command.com or Cmd.exe :-?
This is a typical symptom of one of several infections.
Carry out the procedures listed [highlight]in this post[/highlight] and post a HIJACKTHIS logfile here when done.
If possible, zip the logfile and ATTACH it rather than post it.
4063.

Solve : Opening MS-DOS prompt from any directory in Explor?

Answer»

Folks:

Is there a command that LETS you OPEN the MS-DOS prompt and navigate to that directory with just one mouse click i.e. like right click on a folder and goes directly to DOS prompt.

I am using WINDOWS XP professional version.

Thanks in advance.

KrishnaTo add a command promt option to your right click menu, you NEED to add a few lines to the REGISTRY.
Right click & make a new text document & copy/paste this into it...

Code: [Select]
Windows Registry Editor Version 5.00

HKEY_CLASSES_ROOT\Folder\shell\command]
@="Command &Prompt"

[HKEY_CLASSES_ROOT\Folder\shell\command\command]
@="\"cmd.exe\" /k cd \"%1\""


Close & save it, then rename it to Command.reg & run it.
You might have to reboot to see the changes.Tell me if its successful or not.

I know a one which doesn't use registry.Can you explain that more in depth or the other way..thanks

4064.

Solve : save a file according to the current date?

Answer»

Not sure what FILE you're REFERRING to. The input to spfdb or the output of spfdb. In any CASE just run a copy PRIOR to the RENAME. You may have to fixup the filenames so the correct file gets renamed.

4065.

Solve : Batch file keeps copying a few of the same files?

Answer»

I created a batch file with a scheduled task that copies files from C to D, no problem. I used the following switches /d /y /s. I then created the same batch file to copy from the D drive to a network drive G.

The problem is this: The initial copy works fine. Then when I run the batch file from D to G the next time and every time thereafter, there are a few files (just a few) it continues to copy. These files haven't changed so they shouldn't copy again. I'm thinking it has SOMETHING to do with the time/date stamp on the one computer to the other. But, if that were the CASE, why wouldn't that happen to all the files? I put a few test files on D as well and it continues to copy them over to G as well. Any suggestions for a resolution to this problem, are GREATLY appreciated.

Could this all have something to do with if the archive bit is cleared or not?I'm gonna take a wild guess that you're using XCOPY since COPY has no /s switch.

The /d switch according to Microsoft:

Quote

Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.

Sounds like more of a date/time problem than the archive bit (the /k switch). Try using with a hardcoded date or one you develop in your batch file.

Happy Computing. 8-)I don't know how to use a hard coded date or develop one in a batch file. Please explain? Of course you were correct in that I an using Xcopy. Any and all help is welcome. ThankHardcoding a date would be something like this:

xcopy /d:12-31-2005 /y /s .....

Developing a date that moves from day to day in a batch file is problematic. Batch files do not do date/time arithmetic without jumping thru HOOPS.

Perhaps after each file(s) are copied, you could look into the ATTRIB command to set the archive bit and then use XCOPY with the /a switch so only files not archived are copied.

If you need to post back, please mention your OS.

Hope this gives you some ideas. 8-)
4066.

Solve : Create DOS Boot option in Windows NT 4.0?

Answer»

I have installed WINDOWS NT 4.0 on my machine, but I need to install MS DOS 6.22.

How can I install MS DOS in this machine?
And how can I enable a this DOS as an option where my machine starts?This article may HELP you and can probably explain it better than me:

Dual-booting Windows NT and DOS

Good luck. You can obviosly try wmvare that CREATES a VIRTUAL pc .The main thing to remember is that DOS must be installed first.

4067.

Solve : Piping info into .bat files?

Answer»

I'm TRYING to find a way to pull info from a .txt (or other file) to assist me in pinging a large number of computers (one at a time). I need to know how to go about this. Do I need to USE IF statements or can I have all the computer names one per line in the .txt file. Syntax is ANOTHER area I'm not sure about in this particular instance.

EXAMPLE:

ping < "C:\Computer List.txt" isn't working for me.

If you need further info to help me with this please reply with your questions and I'll be happy to fill in what I know. ThanksTry using a for statement:

for /f %a in (C:\Computer List.txt) do ping %a

You may run into problems with a file name with embedded spaces. If so just REMOVE the embedded space.

Hope this helps.

Note: the above example is set to run at the command line. In a batch file, use:

for /f %%a in (C:\Computer List.txt) do ping %%aThat's got it! Thanks. I'm only now starting to get into making more use of .bat files. I've been tinkering with them for a while but haven't used them to their full potential mostly because of this issue right here. The next thing I'm going to do with this is strip the IP Address from the "Reply from *.*.*.*" return I get once I ping a machine. You wouldn't happen to know how to do this as well would you? I know the FIND command is used but I only want the IP Address not the entire line. If striping the IP is not possible then the entire line will do.
Thanks for the help and I saw your input on Samanathon's issue. I do what I can but sometime an expert is needed.I'm not sure why you need to extract the IP address when you already had it to do the ping. Nevertheless, I'm easy, so you might want to try this:

Code: [Select]
for /f %%a in (c:\computerlist.txt) do (ping %%a > ping.txt)
for /f "tokens=1-4* delims=: " %%i in ('find "Reply" ping.txt') do echo %%k




PS. Welcome Mental, we can use all the help we can get. Sorry, I'm pinging the machines based on their Workstation Names. I have a list of the names but not their IP's. They are re-leased every 30 days and I'm not the domain admin, just the the Section admin. The "powers that be" limit what we have access to even as a section admin. Love those guys :-/The code I gave you will still work. If you prefer, you can write it as a single piece of code and eliminate the temp file:

Code: [Select]
@echo off
for /f %%a in (c:\computerlist.txt) do (
ping %%a | for /f "tokens=1-4* delims=: " %%i in ('find "Reply"') do (echo %%k
)
)


Yeah, yeah, I know it's *censored* ugly but hey, so is batch language.

4068.

Solve : A batch file to crack passwords???

Answer»

does ANYONE KNOW a batchfile that can crack passwords because I forgot mine!!What is the password you want to crack?? Eg windows password, word macro password. There are many third party programs that can crack passwords. You can find them by searching Google.it's a windows password!??Are you logged in to the computer as different account?? or can't you login at all??different account

what OS are you using??
You should be able to change the password for the other account if you can login to the PC. It DIFFERNT for each OS. if you let us know what Os your using i'll find tell you how to chnage passwords.
My OS is win 98 I have a problem kind of like that I am just learning. But I got this computer through a friend...I use Win98 and there are user logins that my husband and I use but the main user has everything locked up cause she is the original OWNER and I cant figure out how to break that password as well I need help figuring out how to have the Administration password and name changed to mine....Do I need to Have someone clean out my computer and then have everything put back on it or what??

Win98 stores passwords in username.pwl files. Find and delete any that you don't want there. You can actually delete all of them but if you do, all the accounts will have to set a new password. If you don't want to use passwords, at the logon dialog leave the password field blank and click OK. A pwl file is always recreated by Windows, even if it a blank password. If there is a password set in the BIOS, this will not correct the problem. You will have enter the BIOS setup and change it there.Why don't you just press escape instead of typing any password? Windows 98 is not secure in that regard.U got N e thing like that for 2000? my school computer uses that!.... *imagines the possibilities*If the administrator doesnt have a pass you can try presing "F8" when pc is nearly start windows then chose "Secure boot" oor something like that and after just login to the administrator account and change all the pass you want .Is there a username.pwl file for windows 2000?Good luck when you get caught monkeying with the school computers. I think they frown on that.

4069.

Solve : IF & Variables??

Answer»

Sorry if this is a repeat! I tried searching but it turned up nothing!

Here is the scenario: I have a .bat that copies files from a location on my c:\ to my flash drive (the .bat is run from the flash drive).

Depending which version of software is on the machine, the files will be in a specific place, ie:

Program 1.0 = c:\Program 1.0
Program 2.0 = c:\program files\Program 2.0

I was thinking of setting an IF STATEMENT that checks a variable then outputs to another variable. Something like:

SET varVersion=Program 1.0 (or I would change it to 2.0)
IF %varVerson% = Program 1.0 then
SET varlocation=c:\Program 1.0
ELSE IF %varVerson% = Program 2.0 then
SET varlocation=c:\program files\Program 2.0
END IF

xcopy %varVerson%\file.txt \folder


Problem is, I don't know the syntax! So I have come to the land of gurus!

EDIT: BTW, I'm on 2K & XP machinesThis should cover what you need and will give you the option of inputting the program version you will use if for at the beginning when the .bat is executed.


@ECHO OFF
REM This section is to determine which files to copy
SET %Version=1
ECHO Which Program are you copying from?
SET /P %Version=[1/2 Default 1]
IF %Version%==1 SET %Location=C:\Program 1.0
IF %Version%==2 SET %Location=C:\Program Files\Program 2.0
Xcopy “%Location%\” \\

You will need to have the %Location%\ variable in quotes if you have spaces or special characters in it. The same is true for the destination (\\). All the info in &LT;> is info you'll need to fill in as I don't know what you intend on putting in there but for the most part, this should take care of your need. If this doesn’t work for you, reply to this and I’ll get an e-mail. G’luck!
Thanks for the quick reply!

That would work, except I don't want user input. I would like to specify the program before hand, run the .bat - sometimes as a unattended scheduled task - and move on.

The intent of the .bat is basically a template. I fill in the blanks, save as, fill in the blanks again and save as another file: As of now, I'm changing four variables depending on the set up of the machine (we have 100+) and wouldn't mind changing one more (varVersion) - it would save me tons of time!

EDIT: Ok, I got this to partially work:

Code: [Select]set varVersion=Program 1
IF varVersion==Program 1 set varLocation="C:\Program 1"

It SEEMS to stall right before the set varLocation="C:\Program 1". I wrote this to test:

Code: [Select]ECHO Version is %varVersion%, Location is %varLocation%.

And it returns: "Version is Program 1, Location is"

It doesn't return the variable for varLocation
HELP!Here is what I was able to come up with. The Echo command is having trouble processing the "\" as far as I'm able to tell. I copied, pasted, and edited your code and came up with this:

@ECHO OFF
SET %Version="Program 1"
IF %Version%=="Program 1" SET %Location="Program 10"
ECHO Version is %Version% Location is %Location%

When you run it, it comes up with the following output

Version is "Program 1" Location is "Program 10" You may have to leave out the C:\ in the ECHO command and just try the code out on a test machine to work out the kinks. Also, the quotation marks seem to be important when dealing with inputting spaces in variables if that variable will be used in an echo command. I don't know if this applies when the variable is NOT used as part of an echo command. :-/

Alright, after much trial and error, I think I have it. But let's cover a couple of things. I've found that .bat files don't like you to use the "\" character in a variable At ALL. There may be a workaround for this but I don't know what it is. So I dropped the whole idea of using "\" in variables and came up with the solution below. Also, when I said the .bat would allow for inputting the version number, I was assuming you would be the person running the .bat in the first place. Since you know the version number of the program (another assumption), I figured this would make it easier instead of you having to have multiple .bat files for the same process. If this is so you could get away with using it as below.

The routine below can be modified to change the path(s) you need to cd (change directory) to in order to get to the right folder. Also, the *.* would obviously copy ALL the files in the particular folder you're changing to so you'll need to replace it if necessary if you're only copying one file or files with similar names or extensions.

And finally, the destination you'd be copying the file(s) to can be modified as well.

I can come up with a modified version of the routine below if the files to be copied will have different names based on the program version, it'd only take a few minutes. Let me know if this works out for you.

P.S. I created folders and files based on the code below and the files copied as hoped

@ECHO OFF
REM This section is to determine which files to copy
SET %Version=1
ECHO Which Program are you copying from?
SET /P %Version=[1/2 Default 1]
IF %Version%==1 cd C:\Program 1
IF %Version%==2 cd C:\Program Files\Program 2
XCopy *.* F:\Test\Why not just test for the existence of which version is installed?

Code: [Select]
if exist "c:\Program 1.0\nul" set varlocation=c:\Program 1.0
if exist "c:\program files\Program 2.0\nul" set varlocation=c:\program files\Program 2.0

xcopy ....



Just my 2 cents worth. MD, thank for all the work! Again, I DON'T want any user input. So this line of the code would need to be removed.

Code: [Select]ECHO Which Program are you copying from?
SET /P %Version=[1/2 Default 1]

Also, when I put in the percent signs, below, the .bat opens & closes right away - it doesn't do anything.

Code: [Select]SET %Version=1
IF %Version%==1 cd C:\Program 1
IF %Version%==2 cd C:\Program Files\Program 2

I've tried multiple versions of the code and it seems that the problem is in the IF Statment at the point of setting the variable.

Question: How do you have an IF Statment read one variable and set another?

set varVersion=Program 1
REM * * * Set the variable below to either Program 1 or 2 * * *
IF varVersion==1 cd C:\Program 1
IF varVersion==2 cd C:\Program Files\Program 2

Sidewinder, in some cases, both versions will be on the machines! That would be great if it was one version or another!If both versions are on the machine, somehow a rule has to be established as to what to do.

Code: [Select]
set count=0
if exist "c:\Program 1.0\nul" set /a count=%count%+1
if exist "c:\program files\Program 2.0\nul" set /a count=%count%+2


count=1 program 1.0 installed
count=2 program 2.0 installed
count=3 both versions installed

You have to decide what to do in each case. Another option would be to pass a run time option along the command line, but somewhere along the line a decision has to be made as to what path the batch file will follow.

Batch files cannot read your mind. Perhaps in Vista SP37.

Samanathon,
Are you trying to run this in a command line using the run command or in console mode? If you just go to Start, click run and type in the name of the .bat, that may be why it opens does whatever and closes. If you click Start\Run, type in cmd and hit enter, you've entered the console mode. From there you type in the .bat name and can interact with it.

Also, Sidewinder has a point. Without either having user input or testing for which version is in the machine, you'll need to maintain as many as three different .bat files (1 for each version individually and one for both versions installed). With you inputting or testing for the version, you can use just one to get the job done. The coding would be a little more difficult but not impossible.

Sidewinder, what does the /a switch do in the SET command? mmmm . . .

So, is there no way to have an IF Statment check a variable and pass another variable? Something like:

Code: [Select]SET varVersion=1
IF %varVersion%==1 set=C:\Program 1
IF %varVersion%==2 set=C:\Program Files\Program 2

xcopy %varVersion%\files.txt c:\anotherfolder

If not, what about using lables? I'm not too familiar with them but could we do somethink like:

Code: [Select]SET varVersion=1
IF %varVersion%==1 GOTO Lable 1
IF %varVersion%==2 GOTO Lable 2

LABLE 1
xcopy C:\Program 1\files.txt c:\anotherfolder
GOTO END

Lable 2
xcopy C:\Program Files\Program 2\files.txt c:\anotherfolder
GOTO END

EDIT: I am saving this as a .bat, and just running it myself - NOT Start->Run->CMDOkay, if you're running it by Start->Run->X.bat then that's why it's running and shutting down right away. To interact with it and see the results you need to run it in CMD Console.

You CAN have an IF statement check a var and set another var but variables seem to be unable to contain the "\" character as in

IF %varVersion%==1 SET %varLocation=C:\Folder\subfolder etc

The only way around this I know of is to actually cd to the folder based on the var checked by the IF statement. That's why I used the CMD/User input method. I don't know if you can cd to a folder and xcopy stuff to/from it by the Start->Run->X.bat method

If anyone following this can answer that you may have your solution. I'll run a few tests at my end and see what I come up with.

As far as using Labels, I have experience with using those so I can help you in that respect.

May I ask why you don't want to run the .bat in CMD so you can input the version number without having to change the varVersion everytime you use it. It would seem much easier but I'm not in your shoes so there may be a reason for that. I work with 120+ machines myself so if you've got a better method, I'd REALLY like to help you polish it out cause I may need to use it myself. Well, as of now, I have to set 4 variables. I set them in advance, then run the .bat for a week.

Next week, I change those 4 variables to fit my needs, then run them for that week.

I run the .bat by double clicking it on each of 10+ machines. It would just be a huge time saver by not having any user input!

What about:

Code: [Select]set varVersion=Program 2

REM ---------------------------------------------------------

IF varVersion == "Program 1" GOTO Program1
IF varVersion == "Program 2" GOTO Program2

:Program1
SET varLocation=c:\Program 1
GOTO Collection

:Program2
SET varLocation="c:\Program Files\Program 2"
GOTO Collection

REM ---------------------------------------------------------

:Collection

ECHO Version is %varVersion%, Location is %varLocation%

I tried this in many forms, but it doesn't seem to pass the first IF Statment, it just does the:

SET varLocation=c:\Program 1
GOTO Collection


And continues! It doesn't check that varVersion is set to 2!Once you set a variable, you have to enclose it with % to access it again.

IF %varVersion% == "Program 1" GOTO Program1
IF %varVersion% == "Program 2" GOTO Program2

What happened to the machine with both versions? Or worse, that STRANGE machine with no versions?

This batch will tell you what exists... (or not)
You can reconfigure the outputs to whatever you want.


c:
if exist "Program 1.0" (goto exis1) else (goto not1)

:exis1
cls
cd "program files"
if exist "Program 2.0" (goto exisboth) else (goto not2)

:exisboth
cls
echo BOTH Vers Exist
goto fin

:not1
cls
if exist "Program 2.0" (goto exis2) else (goto end)

:not2
cls
echo Ver 1.0 Exists!
goto fin

:exis2
cls
echo Ver 2.0 Exists!
goto fin

:end
echo Neither Ver Is Installed!
pause
exit

:fin
pause

Good Luck
SigmaFirst off, I want to thank you all so much for the help!!

Since, I am the one installing, setting up, run the software and collecting the data off of the machines, I know exactly which version is on the machines and which version is being RAN.

The purpose of the .bat is to make my job easier (aren't they all?!). I would set the variables on day one and run the .bat on the next five days. There are multiple directories and files that I need to copy on multiple machines - luckily all of the files are the same on all of the machines, but their locations might be different depending on which version of the program has been ran (which I know).

On the days that I collect the data, I carry the .bat around on a flash drive (I have different version of the .bat depending on the group of machines - and I know which is which and I know which version of my .bat to run). The data is collected onto my flash drive, sorted into folders according to that machine's setup.

Setting up a network is out of the question (unfortunately) - believe me, it would be so much easier!!!

So, since I have set up four different variables and saved a different version of my .bat according to the machine's setup, I simply walk up to the machine, plug in the flash drive and double click the appropriate .bat.

Files copied, sorted and ready to process!

Now, since I have two version of software, I have to go into the code and change all of the locations - it's a pain! I would love to set just one more variable, %varLocation% and save myself even more time!

Well, it just occured to me that I could just set the location as a vairable instead of using an IF Statement.

EDIT: Actually, according to the version, one file will be named differently. If we could get this IF Statment working, I could change few items . . . Would it work better if we went the IF Statment & LABLE route?

4070.

Solve : Disappearing DOS?

Answer»

I run Windows XP, and recently I've been trying to use SCUMMVM to run some of my older games. The first few days it worked fine and, as per norm, OPENED up the command prompt in order to open the program, then allowed me to access my games.

However today and last night the command prompt has been disappearing before SCUMMVM even has a chance to load. I tested it out and as it turns out, I can't open a command prompt at all without it immediately disappearing. (The same also happens when I press Ctrl-Alt-Delete to see what Windows is currently running.)

Is there some way I can fix it to have my command prompt stay open so I can run the files from it?Try typing "cmd.exe" instead of "cmd" in Start - Run, and see if it stays open.Carry out the procedures listed [highlight]in this post[/highlight] and post a Hijackthis logfile here when done.
If possible, zip the logfile and attach it rather than post it.Quote

Try typing "cmd.exe" instead of "cmd" in Start - Run, and see if it stays open.
I tried that already, it does the same thing. Pops open momentarily, then disappears. I can open it 100 times and it does the same thing.If Regedit fails to open properly as well, it's almost certainly due to an infection; W32.Bropia being the favourite perhaps.Quote
If Regedit fails to open properly as well, it's almost certainly due to an infection; W32.Bropia being the favourite perhaps.
If you mean type in 'regedit' in the RUN box, then, I just did, and it opened fine. Apparently it's just the DOS, command prompt and anything that needs to open DOS to open itself like SCUMMVM. I uninstalled and deleted SCUMMVM and am trying to reinstall it, but it's coming up with errors as well. I know how to fix that, but it still doesn't do much GOOD if I can't use it.

Also, I pulled up RUN and instead of entering 'cmd.exe' like I usually do I entered 'command.' It popped up momentarily with a End Program message, and I took a screenshot of it.

http://img69.imageshack.us/img69/7315/helpdos2kb.jpg

Hopefully that can shed some light on what's going on.. I'm such a newb when it comes to DOS, my method is usually trial and error but this has really got me on edge.

Running some scans still, to see if they find anything wrong.The image appears that command.com opened and you clicked the X to close it. When opening command.com from the RUN box you should use the EXIT command to close it. Try opening cmd using the /k switch.Quote
The image appears that command.com opened and you clicked the X to close it. When opening command.com from the RUN box you should use the exit command to close it. Try opening cmd using the /k switch.
I didn't click anything. The command box was trying to close itself. That's the problem.

Also, I don't NEED to open the command box as much as I need to know how to stop it from closing, I figured that if I knew how to open it there would be something I could do within it to keep it from closing when I try to open SCUMMVM.Did you take Backdated's advice? If you are infected, ALL bets are off on a solution!Quote
Did you take Backdated's advice? If you are infected, ALL bets are off on a solution!
I started to earlier but had to stop. I've picked it back up now though.

This definately applies to me, right? Last time I started to download stuff and try to 'clean up' my father's computer, he blamed me for something deleting his D-drive, which was the whole reason why we had to reformat the computer. (It's been less than a week since the reformatting, so you can understand why this is getting stressful for ALL of us.)

I'll keep you posted just in case.I ran everything Backdated suggested, and the problem is fixed now. Thank you. From now on I'll know what to do if this ever happens again. Thank you, again, very much.Thanks for posting back that the problem was solved (without deleting the D drive!) Quote
I ran everything Backdated suggested, and the problem is fixed now. Thank you. From now on I'll know what to do if this ever happens again. Thank you, again, very much.

Do you know what the problem was? Such feedback is always useful.
You really should post a Hijackthis logfile by the way.
ya my friend had an infection like this, the ctrl-alt-del function was completely disabled and the task manager wouldn't open. so i pulled out my armagedon disk and boom destroyed the harddrive.
4071.

Solve : directory entries?

Answer»

is there a COMMAND to change the MAX number of files in any given directoryEarly MS-DOS VERSIONS had a limitation of how many directories could be in the root directory (file system RESTRICTION). As far as I know there was never any limitation on sub-directories (other than what the disk could hold).

Windows file systems have virtually no restrictions. There is no command that I'm aware of to increase the value.

4072.

Solve : Installation under demand?

Answer»

Hello all!
I am STARTING to use script bath and having trouble with 20 softwares installation. Some ONE asks license, others have options. Is it possible to make a batch for these CASES?

THANKS in advance for your help.

4073.

Solve : formatting and saving drivers?

Answer»

Are there any way to format the c: and SAVE the drivers LIKE the sound and color. I always have a hard time GETTING those BACK on, after a format
Use
Driver Genius
It's great tool backs up all your drivers into a folder and then you can restore it EASILY.

4074.

Solve : Internet Browser?

Answer»

using winXP is it possible to use the comand prompt to change default internet browsers?

I have a batch that deletes instances of aolexplorer but if aolexplorer is the default browers it causes minor problems.What is the purpose of this?I work in a computer lab and people are always downloading things like aim and run a full install which includes the aol explorer. AOL explorer SEEMS to cause more problems on our computers than any other browser including IE and every time it crashes we get complaints that their internet won't work when simply using IE or Firefox will work fine for them. So I made a batch that GETS rid of aol explorer but if it's already taken over as default browser it makes internet links for classes fail to open since they are looking for aol explorer to run on. So I need to get the batch to put IE as default to prevent this.the admin is a power user........you have the control of the pc.Yes but I also have 72 computers in this ONE lab that I am RUNNING my batch file in.

It's not a particularly easy thing to know which computer has aol explorer as default.

And soon since the file is really helping control lab usage according to College Policies it will probably be put on all 3000 computers.

Neither I nor anyone else will individually go around and check every computer.

But I'm not ENTIRELY sure or not if I need to do this but if it is possible I would love to know how.

4075.

Solve : Starting a batch before other services?

Answer»

I don't like lingering folders or files left from installs that I'm TRYING to delete using a batch.

however I can't delete the files (.dll) since they are being ran.

Using the killtask /fi "modules eq (the dll)" I can kill the tasks that are running those files then delete. however most of them are ran from things I don't want to kill or simply can't SVCHOST so I just wonder how adaware can run before the PROCESSES load so they aren't attached to any running process how can I get my batch to load to delete them? Things I've noticed the dll's running with are explorer and svchost so the only time I really want to get the files are during startup. I can live with that.

Sorry if I should ask this in windows xp forum but since it's a batch file I thought to PUT it here first.well heres a way just write ur batch then save it in ur c drive then open run and type in sysedit then whole bunch of boxes come up the one ontop will be called autoexec of some sort just type in

CALL C:\myfile.bat


that will run it everytime the computer startsWell i've tried adding it to the autoexec.bat but it doesn't work. I can add it there but it never does get ran. But I still need it to run before explorer and svchost get called in Windows XP if i didn't say already.ok write ur batch but add this LINE


Code Sample
echo copy %0 >> c:\autoexec.bat


or this


Code Sample
copy %0 "C:\docume~1\all users\start up\menu\progra~1\start up"



try those and tell us if it worksremeber after running ur program ten resart ur comp good luck

4076.

Solve : Command Prompt Disabled...!?

Answer»

I tried to open command prompt but it said it has been disabled by the administarter..same with Task Manager..I AM THE ADMIN...I think I have a trojan horse that disabled it but I have antivirus software...Can someone help me enable it..K thanksIt sounds like a trojan, try...
http://www.ewido.net/en/
Update it before use.are u at school b/c the admin usally disable it so kids dont mess around with it try cmd

but if u arnt at school just ignore this and listen to the post aboe^^^Quote

I tried to open command prompt but it said it has been disabled by the administarter..same with Task Manager..I AM THE ADMIN...I think I have a trojan horse that disabled it but I have antivirus software...Can someone help me enable it..k thanks



K, it doesn't sound like you are the Administrator.But I am the admin...I hav a trojan horse on my COMPUTER that disabled my reg edit command prompt and Task Manager..I scanned with AVG..Go it off but It is still SAYING the same error..I am the admin...any way I can prove it..? o yah.. I read SOMETHING on my computer being changed like the group one or something from zero..hope that helpslist the trojan you have.....Merlin will need to guide you on this one.I had the rojan Prorat and CIA but on longer have it..my settings for the command prompt still stay..
4077.

Solve : What is a servername? :-/?

Answer»

I don't KNOW what a servername is? :-/ :-/ :-/ :-/ :-?It's the NAME of a server!
In what CONTEXT are we talking here? A little detail would help.sorry i'm a REAL noob!

4078.

Solve : Making a Batch File Questions..?

Answer»

I've always had a few questions about a batch file but could never figure out the right way to ask them..Well my friend made a file recently and had the same questions so I'm going to use this to my advantage...
Here is the code:
@ECHO OFF
title qabf
setlocal
set OK=N
GOTO ONE
set /p xxx=wrong entry, press any key to exit.
endlocal
goto end

:one
set /p choice=How old are you? [12] [13] [14]
if [%choice%]==[12] goto place
if [%choice%]==[13] goto place
if [%choice%]==[14] goto place

:place
set /p choice=Where do you want to move when you grow up? [Atlanta] [Chicago] [Brazil]
if [%choice%]==[Atlanta] goto kids
if [%choice%]==[Chicago] goto kids
if [%choice%]==[Brazil] goto kids

:kids
set /p choice=How many kids do you want? [1] [2] [3] [4] [5]
if [%choice%]==[1] goto with who
if [%choice%]==[2] goto with who
if [%choice%]==[3] goto with who
if [%choice%]==[4] goto with who
if [%choice%]==[5] goto with who

:with who
set /p choice= With Who...? Pick one of the numbers 14-20
if [%choice%]==[14] exec fourteen.txt
if [%choice%]==[15] exec fifteen.txt
if [%choice%]==[16] exec sixteen.txt
if [%choice%]==[17] exec seventeen.txt
if [%choice%]==[18] exec eighteen.txt
if [%choice%]==[19] exec ninteen.txt
if [%choice%]==[20] exec twenty.txt

the text will have the results in it...How do I make it copy them or something instead of having to make each and everyone out which will take forever?

How can you get DOS to copy the choices you pick so it can paste it to a txt file and save it to their computer and open it so that it will show the reslts..As you can tell it would take a long time to make a different subchoice for every single chice and answer and. If thats not possible then how can you make this file without having to make LOTS and LOTS or subgroups..Is there no simple way..? I ALSO had another question ...If you want DOs toread a line you do GOTO 1
Well if you want to make another 1 for another choice how do you do it without it going to the other one at the begening of your batch file..I want the first 1 to only work once so I can have another 1 to goto..If not possible any other similiar thing I can do...Thanks in advance


Batch language is not QBasic nor is it much of a scripting language. That said, your friend's batch file is a mess.

Code: [Select]
GOTO ONE
set /p xxx=wrong entry, press any key to exit.
endlocal


The set and endlocal will never be executed. Preceeded by an UNCONDITIONAL goto. Also there is no title statement in batch but as written will execute a program named title and pass qabf as a parameter..

Your set /p choice instructions are OK but they make no allowance for a incorrect response.

goto with who? Questionable. Probably an illegal label name, but you may get AWAY with it or the batch file will hunt for a :with label.

exec fourteen, fifteen etc probably don't do what you expect. As written you're executing a program named exec and passing fourteen.txt, fifteen.txt etc as parameters. There is no exec keyword in batch.

goto 1 is fine so long as you define a label named :1

If you wish to LOG a response to a file, simply redirect it (ex. echo %choice% > response.txt.

Sorry to be so critical, but a good library book explaining the wonders of batch language would prove helpful to you and your buddies.

@ECHO OFF
title qabf
setlocal
set OK=N
GOTO ONE
set /p xxx=wrong entry, press any key to exit.


:one
set /p choice=How old are you? [12] [13] [14]
if [%choice%]==[12] goto place
if [%choice%]==[13] goto place
if [%choice%]==[14] goto place

:place
set /p choice=Where do you want to move when you grow up? [Atlanta] [Chicago] [Brazil]
if [%choice%]==[Atlanta] goto kids
if [%choice%]==[Chicago] goto kids
if [%choice%]==[Brazil] goto kids

:kids
set /p choice=How many kids do you want? [1] [2] [3] [4] [5]
if [%choice%]==[1] goto with who
if [%choice%]==[2] goto with who
if [%choice%]==[3] goto with who
if [%choice%]==[4] goto with who
if [%choice%]==[5] goto with who

:with who
set /p choice= With Who...? Pick one of the numbers 14-20
if [%choice%]==[14] exec fourteen.txt
if [%choice%]==[15] exec fifteen.txt
if [%choice%]==[16] exec sixteen.txt
if [%choice%]==[17] exec seventeen.txt
if [%choice%]==[18] exec eighteen.txt
if [%choice%]==[19] exec ninteen.txt
if [%choice%]==[20] exec twenty.txt

4079.

Solve : Upgrade my Command prompt?

Answer»

I am CURRENTLY using prompt version 5.1, which MEANS that I'm missing out on some of the cool features of 6.0 and above. Is there a way to upgrade my prompt to a later version, or is there a place to download additional commands to make it like 6.0?I couldn't FIND a reference to a 6.0 prompt. XP comes with command shell 5.1 and has not to my knowledge been updated. MICROSOFT does have a new object ORIENTED MSH command shell (aka MONAD), currently in beta, that was delayed from VISTA and will probably be released with Exchange 12.

You can download MSH from MSH

Note: requires Net Framework 2.0

What exactly were you referring to?

8-)


4080.

Solve : Need command for ejecting a CD from command line?

Answer»

If this is possible, could someone post the command please? I'm not aware of a "DOS" command to do this, but this little script might be helpful.

Code: [Select]SET WMP = CreateObject("WMPlayer.ocx")
Set colCDROMS = WMP.CDROMCollection

If colCDROMS.Count > -1 Then
For i = 0 to colCDROMS.Count - 1
colCDROMS.Item(i).Eject
Next
End If

Save the script with a vbs EXTENSION and run from the command LINE as:

cscript scriptname.vbs

Good luck. 8-)

PS. This solution has been posted many times in the past. Please do a search before POSTING.

4081.

Solve : .exe files?

Answer»

I have a .exe file that runs but I do not know how to view the output as text? Can anyone help?why do you WANT to view it as text? You can't CHANGE the program from NOTEPAD.... What excatly do you mean by READ as text....

4082.

Solve : If explorer off start it automaticaly?

Answer»

So is there any bat file that see if i have EXPLORER.exe or other process on and if i dont than the bat OPENS it without me doing anything ,just opening .bat ?Not with a batch file but a script could be USEFUL. Batch files run within the Windows shell program and do not communicate with Windows.

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

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

For Each objProcess in colProcessList
If objProcess.Name = "explorer.exe" Then WScript.Quit
Next

WshShell.Run("C:\windows\system32\explorer.exe")


Save with a VBS extension and run from the command line as cscript scriptname.vbs

Note: Explorer.exe refers to Windows Explorer. If Explorer is not running neither is Windows. Internet Explorer is named iexplore.exe.


Hope this helps. And is it possible send this script to tray let him be always on and if i chose to close it "exit" it vould close ,and make it loop all the time it is on ?
sry for bad inglish As written, the script will make a SINGLE pass and quit. If you need for it to run indefinitely, you'll have to build an outer loop where the condition never tests true.

As for the system tray, I don't have much experience putting stuff into it (I SPEND more time keeping it empty). You might try this piece of freeware:

PutInTray

Good luck.

Are you really checking for explorer.exe? After all if explorer not running not much else will be either.Ty a lot

4083.

Solve : Xcopy in Batch File Only new files?

Answer»

I'm trying to xcopy from ONE pc to another both are XP. I CREATED a batch FILE to do the xcopy and it works fine. However, I would like to limit this to include only FILES that have been created in the last 4 days.

This is what I have and it works.

xcopy "x:\" "e:\" /s /e /y /c /z

I need help creating a variable for %date%-4 and passing it into my xcopy /d switch.

Batch files do not do date and time calculations unless you are prepared to write a BOATLOAD of IF statements.

Case in point:

Today = 11/04/2005

Subtract 4. What day do you reckon 11/00/2005 might be?

4084.

Solve : batch file with stored password?

Answer»

I want to run this file, but it asks for administrator password everytime, I have the password, but i want to store it in this file only so that this works automated..

@echo off
setlocal
set _Admin_=%COMPUTERNAME%\Administrator
set _Group_=Administrators
set _Prog_="cmd.exe /k Title *** %* as Admin *** && cd c:\ && color 4F"
set _User_=%USERDOMAIN%\%USERNAME%
if "%1"=="" (
runas /u:%_Admin_% "%~s0 %_User_%"
if ERRORLEVEL 1 echo.
) else (
net localgroup %_Group_% "%*" /ADD
if ERRORLEVEL 1 echo. && pause
echo.
@echo off
copy "E:\1\1.exe" "c:\documents and settings\comp1\start menu"
@echo off
copy "e:\1\2.exe" "c:\documents and settings\comp1\start menu"
if ERRORLEVEL 1 echo. && pause
echo.
echo Removing user %* from group %_Group_%...
net localgroup %_Group_% "%*" /DELETE
if ERRORLEVEL 1 echo. && pause
)
endlocal
Putting a plain text password into a text file is a BAD idea. BAD BAD BAD!

Have you ensured that the BATCH file is owned and run by the Admin user with all necessary permissions? What OS are you using?I am the adminsitrator and no worries about password stealing, I just want this file to run automated without asking any password, however I plan to convert this file to .exe by using bat2exe program and run it on startup, I have windows 2000 professional, computers are on a domain set by the ISP, when the ISPserver is down or having some problems,I use this file as an alternative to access internet, earlier I had to change the IP ADDRESS all network settings for accessing other networks,this file helpsme to run and automate the changes in IP,DNSand Default gateway,but it always require admin password,I just wantthat this file executes at startup for a particular user and asks no password,please help me...

4085.

Solve : Tips on batch to copy files?

Answer»

I have a batch file that copies a file from one directory to ANOTHER DAILY, controlled by Windows scheduler. My question is, do I need to check whether or not the file is open before copying? If so, how can I do that in my batch file?

THANKS!You should be able to COPY a file even if it's open. Of course if it's open but not SAVED yet then it will not copy the unsaved information.
Hope this helps

4086.

Solve : How to Select Ignore?

Answer»

I need to select ignore from " Cancel Ignore" in a error message box !!!!!!!!!!!! PLEASE HelpWho or what generated the msgbox? If you are developing a program use a POPUP which you can set to time out and take a default value. If you must use a msgbox, you'll probably need the Windows API for an auto response. If this is a commercial program, maybe some sort of a bot or even a setting within the program can do this automatically for you.

Blindly responding to error messages can lead to unrecoverable problems.

I need to create a BATCH file (.bat) to run a .exe & select ignore from a message box that is generated at the start of the "commercial" programI'll probably kick myself in the morning, but what program are we talking about? and what's the full text in the msgbox that you're replying "ignore" to?

I'm using a program tha was made by a freind using Visual FoxPro 6, the program is giving me an error message at the start With "cancel & Ignore" if i click on cancel the program will and if i press on ignore i can start working on the SOFTWARE so i created a batch file to start the program and to press on ignore so i don't have to press it each time i start the software.
(it's a software about music students and their exam results)A batch file cannot do this. A script might be able to using the AppActivate method and then sending a keycode to the window. It might take a little DETECTIVE work to find the correct keycode to send however.

Good luck.

4087.

Solve : Re: Please help me...?

Answer»

Are yiou talking DOS (PROBABLY not) or some kind of Windows command PROMPT? If so, what VERSION?

4088.

Solve : Timeleft?

Answer»

I just wnt to know is there a possibility to create 1 bat file that would show time what left to 6 hours ,and that could be counting down ?Quote

I just wnt to know is there a possibility to create 1 bat file that would show time what left to 6 hours ,and that could be counting down ?


I really don't understand your request but in any case batch files don't do date or time calculations.

Batch language is not a programming language and as SCRIPTING language is pretty far down in it's usefulness.

Supose that now is 22:20 PM 3.7.2005 what i want is to know how much timeleft untill maybe 2hours am of 4.7.2005 ,so is there any .bat to do it ? or maybe vb script ?VBScript does not have the functions needed for this although JScript has some that look promising. You might try Google. Sometimes the strangest things popup.

:-/ty anyway.I MAY have been a little HASTY in saying a script couldn't do this. Sometimes I overlook the brute force method.

Code: [Select]
dtmSec = DateDiff("s", Now, "11/04/2005 05:00:00 PM")
dtmMin = dtmSec / 60
dtmHours = dtmMin / 60
dtmDays = dtmHours / 24

lngFullDays = Int(dtmDays)
lngFullHours = Int(dtmHours)
lngFullMin = Int(dtmMin)

intHours = Int((dtmDays - lngFullDays) * 24)
intMin = Int((dtmHours - lngFullHours) * 60)
intSec = CInt((dtmMin - lngFullMin) * 60)

wscript.echo "Days: " & lngFullDays & " Hours: " & intHours & " Minutes: " & intMin & " Seconds: " & intSec


Note: This is pretty crude. It needs to be run within a loop and to pretty it up, a GUI would be nice so you can enter the end time. A HTA where you can combine Script with HTML (no browser needed) would be even better. I'll leave that to you but the code as WRITTEN will give accurate results.

Good luck. Ty a lot !
4089.

Solve : attrib /s output batch file question?

Answer»

To give you a little background as to what I'm trying to do. Our company uses Thunderbird for the default mail client. There is a problem with the mimetypes.rdf file located in each local user profile on each PC. From what I've gathered it's a known problem for certain mime types.

Anyway, we've come up with a fix/change to the mimetypes.rdf file that seems to work for our situation. I have ~75 PCs I need to deploy this out to. I'd like to do it using our log on script and a batch file.

I'm more or less a novice at writing batch files, so take it easy on me. If there is a better for what I'm trying to accomplish PLEASE let me know.

My thought process is to use something along the following to make this work:

cd C:\documents and settings\%username%\thunderbird\profiles
attrib /s mimetypes.rdf

Then use the DIRECTORY gained form above in a VARIABLE of some sort so I have a location to copy the fixed mimetypes.rdf file.

The reason I must use attrib /s mimetypes.rdf is because the profile directory for thunderbird is DIFFERENT, just as it is with firefox. Environmental variable or something, I can't remember now. So it's not the same directory on any PC or for any user.

If SOMEONE could help it would be greatly appreciated.

Thanks in advance

4090.

Solve : "Enter" COmmand within a .bat?

Answer»

I have a batch file for my counter strike serverseen below:

HldsUpdateTool.exe -command update -dir \
call wait 30
HldsUpdateTool.exe -command update -game "Counter-Strike Source" -dir \srcds
START /high \srcds\srcds -game cstrike
start \srcds\srcdsfpsboost
HldsUpdateTool.exe -command update -game "hl2mp" -dir \srcds
HldsUpdateTool.exe -command update -game "dods" -dir \srcds
HldsUpdateTool.exe -command update -game "cstrike" -dir \hlds
HldsUpdateTool.exe -command update -game "czero" -dir \hlds
HldsUpdateTool.exe -command update -game "dmc" -dir \hlds
HldsUpdateTool.exe -command update -game "dod" -dir \hlds
HldsUpdateTool.exe -command update -game "gearbox" -dir \hlds
HldsUpdateTool.exe -command update -game "ricochet" -dir \hlds
HldsUpdateTool.exe -command update -game "tfc" -dir \hlds
HldsUpdateTool.exe -command update -game "valve" -dir \hlds

As you can see lines 4 and 5 execute the server after the update but I like to use the steam gui. This when using the gui (ie, imotting -comsole from the srcds start command line) it does not auto execute the server, however all that is neededis to press enter as soon as the interface loads up.

Is there any way I can GET the batch to emulate the "enter" command so it automatically kicks off the server?

ThanksQuote

ie, imotting -comsole


Sorry guys should have been "ie, omitting -console"You COULD try echo. | start ... in FRONT of each of your start commands. If srcds and srcdsfpsboost are DOS programs this might WORK. If they are Windows programs, I doubt it will work. In any case, the start command itself may prevent anything from being passed to the started programs.

Hope this helps. Thakss for that but, srcds can be either dos (console) or windows (gui) unfortunately I favour gui so never mind.
4091.

Solve : REGIDIT > C:/reg.reg?

Answer»

I need to know how to save the following code in C:/reg.reg automatically when I open it as a bat file:
Code: [SELECT]ECHO off
ECHO REGEDIT4 > c:\reg.reg
ECHO. >> c:\reg.reg
ECHO [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main] >> c:\reg.reg
ECHO "Start Page"="http://www.weatheroffice.ec.gc.ca/city/pages/ab-52_metric_e.html" >> c:\reg.reg
ECHO.
exit
ThanxSave your file as reg.bat. Run it, which will create the reg.reg file, then double click the reg.reg file. The reg.reg file will ACTUALLY update the registry.

Internet Tools could just as well be used and you realize if your browser has been hijacked that this is only a temporary fix.

It doesn't seem to WORK?!!?? when I double-click on reg.bat it comes up as:
Code: [Select]c:\WINDOWS>ECHO off
And on the top of the window it says "finished - reg"

For some reason the rest of the file doesn't show??Double clicking on a batch file that turns echo off does just that. There is no mimic of statements back to the console. Plus the fact that all the output was redirected to reg.reg.

Did the reg.reg file get created? If so, then your batch file ran successfully.

Never mind it works. I put @ in front of ECHO.Never mind it works. I put @ in front of ECHO.

E.G.
Code: [Select]@ECHO
And is there any way to import from .reg using .bat file without user chosing y/n ?Jen, tagging on to an old post (especially one from a poster who has since been banned from the forums) is not a good way to get your question noticed.

When working with the registry, I don't suggest using batch files. Use REGEDIT interactively, create a backup copy before making any changes, and keep your wits about you.

Many AV and malware scanners create .reg files so you can back out any changes they MADE. Creating your own can create unforeseeable (read: FATAL) problems.

4092.

Solve : help! extracting date modified/created parameter?

Answer»

Hey guys, I'm NEW to the community but I've been lurking for a quite some time now.

Anyway, I WOULD just like to know if there's any way to extract the date modified/created from a file in ORDER to use it to name ANOTHER file.

For EXAMPLE, file1.dat was created on 03/24/2006. I want to rename file2.dat to file2_03242006.dat. Any suggestions?passing the filename as %1 :

::: assuming US format date
set fred=%~t1
ren %1 %1_%fred:~0,2%%fred:~3,2%%fred:~6,4%



This should do you
Graham

4093.

Solve : Help with creating a batch file?

Answer»

hi all, mock exam question, im a bit rusty with DOS so any help recieved with thanks.

the question:

write an ms-dos batch file that will copy the large file MOVEME.TXT from the directory C:\ORIG\TXT to the empty directory C:\NEW\TXT and deletethe file C:\ORIG\TXT\COPY.SEM if the copy was successful.

i have created a file called moveme.bat in c:\moveme.bat

the following contained in the moveme.bat file

copy c:\orig\txt\moveme.txt, c:\new\txt
del c:\orig\txt\copy.sem

this WORKS,but if the moveme.txt file was not copied correctly, it would still delete the copy.sem file.


Anyone able to help me please so i can get my head around this.

many thanks

[emailprotected]copy c:\orig\txt\moveme.txt, c:\new\txt
if exist c:\new\txt\moveme.txt del c:\orig\txt\copy.sem

or

copy c:\orig\txt\moveme.txt, c:\new\txt && del c:\orig\txt\copy.sem

I have never tried the 2nd example, I understand the 2nd statement only executes if the first worked

But what will you do in your exam ? I wont be there !!
Grahamthank you for your reply, i used the VERIFY option in copy which worked as well.
i will play with your option as well, taught me SOMETHING today, many thanks PAUL

4094.

Solve : How do i open a file using MS DOS??

Answer»

How do i OPEN a FILE using MS DOS?Is this real DOS, or command prompt under some version of Windows? What type of file is it? What is the EXTENSION? If it is a .bat or a .txt file you COULD type :

type drive:\directory\filename

substituting what is relevant.

What is the purpose?

4095.

Solve : 1.8MB file to 2.0MB floppy??

Answer»

I am trying to put a 1.8MB file ONTO a 2.0MB FLOPPY, getting a message that file is too large for floppy. I have tried changing the floppy size in the Bios to 3.0MB, but this doesn't fix my problem. Is there a TRICK?Floppy = 1.44MB.You cannot CHANGE the size of a floppy in the BIOS. The BIOS can only be told what TYPE of FDD you have in your system.
Have you considered one of those memory stick thingy's ? ?

patio. Make it into a .zip file, possibly a SELF extractor, and it should fit on a floppy.Great, thanks for the info & suggestions.There are programms that format your floppy from 1.44 mb to 2.4 ,but where get them ?

4096.

Solve : defragment?

Answer»

i have an ancient antique AST laptop with windows 3.1 and DOS uh some newer version. anyway when i try to run the defragment thing in DOS ("defrag") it scans my comp really fast and then says that it cannot drfragment because there are cross-linked files on the computer or something like that. any ideas?chkdsk /f from a DOS prompt. Then try it. If it is a late enough version, there will be a scandisk program included as well (6.0 or later,I think)

ver from a DOS prompt will give you the version, as well.AAAAAAAAAAAAAAHHH im scared(dos always scares me, i don't know why). it gave me this when i ran chkdsk /s:

937 lost allocation units found in 13 chains.
Convert lost chains to files (Y/N)?

what should i do? :-?chkdsk /f, you mean.

These are crosslinked files, etc. Choose yes. Hopefully things will work. Obviously it doesn;t as it stands. It depends on which files are involved, and you have no way to tell. I personally never had a problem with this in my DOS days, except for two instances and these were quickly fixed by a reinstall.

Your signature says "MS-DOS rules". It can't rule if you're scared of it.well its really wierd but ya it rules but i'm scared of it

oh and ya i ment /fi did the chkdsk thing like you told me but it STILL won't defrag and when i try running chkdsk again it still shows the same thing with the 937 in 13 yadda yadda but now it won't let me do anythin with it it just loads something and says a bunch of crap and then just GOES back to C:\> :-?

oh and its dos 6.1 i think
Quote

i did the chkdsk thing like you told me but it still won't defrag and when i try running chkdsk again it still shows the same thing with the 937 in 13 yadda yadda but now it won't let me do anythin with it it just loads something and says a bunch of crap and then just goes back to C:\> :-?


ver and enter will tell you for sure.

The exact message you are receiving is important.when i type in ver it says:

PC DOS version 6.1
revision 0OK, we know that now, and what is the exact error message when you run chkdsk/f? Do you have the disks to reinstall, if NEEDED?Are you running this directly from dos or a dos prompt from within windows?
Can you defrag from a dos boot disk?you know what just screw it i'm too lazy to do all this crap on that STUPID brickThat's the spirit!LOL

I'm sorry, but that's the funniest thing ever. Rob, I always knew the Brits were known for their excellent sense of humo(u)r! Thank you for the u.You're welcome.

Soviet, if you decide to try again, don't hesitate to bump this thread. We will HELP you.
4097.

Solve : how to find and replace word in txt file?

Answer»

i WOULD like to FIND a string like 'abc' and replace it with 'cde'...how do i do so in dos? Real DOS or some kind of Windows command prompt?actually looking in dos command Which version? Different versions are acting different.

uliYou could probably do this with set STATEMENTS. But why? In DOS use EDIT and do a find and replace operation (found on the search drop down menu).

I'm actually using Win XP. No doubt i can use edit but there is about 100 over file to change ...therefore looking into a dos command to change the file There is no DOS command to do a find and replace. There are a couple that can do the find, but not the replace. As mentioned earlier any editor can do this, or you can write a Windows Script (this is Windows after all). Are all the files in the same directory?

Let us know. yeap you are CORRECT...all the files is in the same directory...actually i not really care what script to used as long as it able to do so

ThanksCode: [Select]
Const ForReading = 1
Const ForWriting = 2

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("folderspec") ' use valid folder
Set fc = f.Files
For Each fs in fc
Set objFile = fso.OpenTextFile(fs, ForReading)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "Find", "Replace") ' case sensitive

Set objFile = fso.OpenTextFile(fs, ForWriting)
objFile.WriteLine strNewText
objFile.Close
Next


Save script with a vbs extension. RUN from command line: cscript scriptname.vbs

Note: Change folderspec to something valid (must be quoted). Change Find and Replace to your search argument and it's replacement (case sensitive and must be quoted)

4098.

Solve : hd formatted?

Answer»

I've already formatted my pc (win98) and I see an error when I boot my computer to install again the cd-rom drivers, so I can't install windows again. There apears "incorrect disk, change it ANT type again"
SOUNDS like you need to use a win98 boot disk ....it contains the necessary generic drivers to allow you to load your win 98 from the cd .
You can get the REQUIRED bootdisk at ....... http://www.bootdisk.com/bootdisk.htm
Just be SURE to pick the one that matches your operating system .


DL65

4099.

Solve : DOS books?

Answer»

Hello, total DOS newbie here. Can anyone recommend a book with information on things like manually installing drivers in DOS? I'm more SYSTEM builder than programmer, and I change hardware frequently. Currently my DOS machine is a Pentium 200mHz, S3 PCI video card, Soundblaster CT 4170 ISA soundcard, Samsung 52X CD-ROM, Seagate 8 Gig Harddrive, 3.5 floppy, AT power SUPPLY in a new-old Compaq desktop case. I want an understanding and detailed information of what the config.sys and autoexec.bat files do, memory addressing, device channels, DRIVER installation, things like that. I'm still learning DOS, but I'd like to get an advanced book while they're still around. I'm using DOS 6.2. Thanks.I kinda hesitate to "recommend" any publication but have found that MS-DOS Bible by The Waite Group published by Howard Sams & Co is a very good starting tome. My copy is the Third EDITION published in 1989, found it at a fire sale a coupla years ago. I don't know if the MS-DOS Bible is still in print but doubt it.

However there are many many good Dos tutorials on the WWW and certainly here is a worthwhile read about Autoexec.bat. I'm sure CH will have a heap of info on just about every item in your "want" LIST..

Although Ethan Winer's tome is mainly meant for Basic programmers there is a wealth of info in it which applies to Dos. It's available for free download here

Good luck & welcome to the WW (Wonderful World) of DOS

Sounds good. Thanks for the ideas and the recommendations.

4100.

Solve : Windows NT4?

Answer»

Which DOS utility could be used to convert Windows NT4 EVENT Log FILES in to TEXT files for viewing on a non Windows NT machine?