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.

8401.

Solve : How to Suppress MSDOS Overwrite Messages??

Answer»

Hi,

I've got some simple commands in a BATCH FILE. When I execute it, the overwite message comes up:

Overwite [Y|N]?

half way through the batch file. Is there any way I can suppress such messages or BETTER still, hardcode a 'Y' REPLY to this prompt? I tried doing this by putting a 'Y' on the line AFTER those commands which I expected to cause the overwrite messsages to appear but it didn't work!


Thx in advance!Check the help for copy and move, they both have parameters /Y to always supply YES to the prompt
Graham

8402.

Solve : Typing more than one command at the dos prompt?

Answer»

Anyone FAMILIAR with how to type more than one command at the Dos prompt. I have to enter 3 commands and the Enter key does not move me to the NEXT line. Is there a way to type all 3 lines on one line?aldejais,

TWO ways:
1. Use "&" to separate commands in a single line, i.e.:
Quote

ver & echo.two & echo.three

2. Start with an opening bracket. Now Enter will move to the next line asking form "More?" until you CLOSE the bracket.
Quote
C:\>( ver
More? echo.two
More? echo.three
More? )

DOS IT HELP?
8403.

Solve : Creating a Windows shortcut from a batch file?

Answer»

Is there a way to create a windows shortcut on the desktop from a batch file? The .ico file exists, I just need to automate the process of adding the shortcut to the USER's desktop.

Any suggestions greatly appreciated!

*CENSORED*Quote

Is there a way to create a windows shortcut on the desktop from a batch file?

Not that I'm AWARE of. If you've ever viewed the contents of a shortcut file (.lnk) you'll see why. Any reason you're restricted to batch code? This is easily ACCOMPLISHED in many of the Windows Script languages.

Let us know.
8404.

Solve : Missing NTLDR File?

Answer»

Hi my NAME is Al. Trying to HELP my nephew troubleshoot a error that involves a missing ntldr file. I got the directions from internet. But when we try to use DOS and type in the command, we need to go to the next line to type in another command. We press the Enter key to go to the next line but the cursor does not MOVE and we receive an error message.

To move to the next line to type a second and third command using DOS, don't we press the enter key? Any idea as to why it is not moving to the next line? Need help, thanks.Down ARROW ? ?

Tab ? ?Down arrow and tab ALSO does not work. Is anyone familiar with typing more than one command on a line? That way maybe I don't have to type the 3 separate lines. Thanks.You can download a startup disk containing NTLDR, NTDETECT.COM and BOOT.INI from here. There are downloads for use with a floppy and cd.

If you boot from the extracted/burned disk the system with NTLDR missing will boot and allow you to sort out the problem.

Good luck

8405.

Solve : playing music inside of a batch?

Answer»

Is it possible to make the batch file play music within it self
I'm using Window's XP

I need this info FAST for a project I am doing.Not directly. It's possible to make the PC beep (echo [ctl-G]) but a single beep does not a symphony make . You can launch an audio file by taking advantage of Windows' file associations. If you launch a mp3 file, Windows will launch the application that can play mp3 music files. Depending on how the mp3 file is launched, the batch file may WAIT for the music to finish or the music and your batch file may run totally independent of each other.

Batch code is not a programming language but rather a means to bundle a series of commands, SAVING the user from repetitively typing them in manually. Consider using any of the Windows Script languages (VBScript, JScript, REXX, Python, Perl, etc) for more FUNCTIONALITY than batch code offers.

ThanksSidewinder -- How do you pass the CTRL-G into an instruction in the batch. I was browsing over this one and never saw this command before, yet it works from command line, but when creating command in editor it does not show character set when pressing CTRL-G. I TRIED the same echo [ctl-G] and it doesnt take that as a valid command.

I thought Beeping was gone with MS removal of the Beep Command in earier DOS versions, unless you created a program to make the beep in basic etc that would execute through the batch.

Neat that it works when typing in directly to command line... I am sure there is a way to point it to a combination keystroke to make it happen, but not sure how.... So hows it done? Thanks!!!The bell or beep is ascii 7. You'll need an editor from the Dark Ages that can accept control keys.

Edit:

Type echo
Type space
Type CTL-P
Type CTL-G
Press enter

Edlin:

Type echo
Type space
Type CTL-G
Press enter

Note: CTL-G and CTL-P are key combinations, not literals.

I tried to post an example but the forum wouldn't accept the ascii 7 character.

PS. The square brackets in my post were misleading; was unsure how the represent an unprintable character.


8406.

Solve : 2 questions - Move inc subs + some harder question.?

Answer»

Question 1 is prob easy for most of u , but i couldn't figure out how ..

1 I got this code.
move "C:\something\something\"* "C:\something2\something2"
Instead of moving only files in the main dir , i want to move everything ( including SUBFOLDERS and " files inside the subfolders")
How can you do such thing?

2.
Is it possible to get the total size of your folder ( including subfolders / files) and log it in a txtfile as 1 line ( so only 'like : 400kb)
The thing i tried out now would put a whole list of things in the txtfile , but i only want the totalsize , so i can compare the size as logged in txtfile with the size the BATCH will find at that moment.

Thankyou ,here's a vbscript
Code: [Select]Set objFSO = CreateObject("Scripting.FileSystemObject")
strFolder = "c:\test"
strDestination = "c:\temp"
' Move the whole folder to destination
objFSO.MoveFolder strFolder,strDestination & "\test"
' Get folder size
WScript.Echo "Folder: " & strFolder & " is " & objFSO.GetFolder(strFolder).Size & " bytes."
save it as myscript.vbs or anything, and from command prompt:
c:\> cscript /nologo myscript.vbs
Sorry for perhaps being a little unclear before.
But instead of moving the whole folder itself , i only want to move all files and subfolders (with files) inside it..

The map itself should remain writable under the action ( thats why)

But i REALLY appreciate your time and effort! ,

I am saying this with a coke in my left hand , and a doughnut in my right
what hand is typing?




then use copy, not move. Since you are drinking coke and eating doghnut, i think I will get some too. So i will leave you to do the code yourself. If you need references, check this outI think i am not far from it , but still aint there"

I got this:

dir "C:\target\folder" /S /B > dirnames.log
type dirnames.log
for "%i" in (dirnames.log) do move "%i" "C:\destination"




The txtfile it creates look like this:
C:\target\folder\submap1\submap2\
C:\target\folder\submap1\submap2\file.txt
C:\target\folder\file.txt


like you can see the data in the txtfile would be EXACTLY what i wanna move .. i only don't know how to read the txtfile lines and move those.
I think i aint that far from it .. but can't figure it out . -> That why i hope some1here knows it







(i don't know if i could move those maps like in this way , but i should atleast be able to move all files that are included in subdirs
by just doing : dir "C:\target\folder" *.* /S /B > dirnames.log ( something like that)

8407.

Solve : name help?

Answer»

what does this NUMBER mean? \\kk 30309-7djfh91 it says its a comp NAME but could someone break it down? thanksIt says where?i went online at school and its the computer name.Says where?ok so i got on command prompt and typed in net view. it came up w/t over 1000 comp NAMES. this was one. i just need to know what is in it to see what computer it is
Why?because im helpin my school...
Judging by your sig i'm not convinced this is the case here...I'm not convinced either but I can't see you doing any damage with what I can tell you, so here you go.
On small home networks you'll usually give the computer names like Ian's laptop or My server. On large networks the names are often automatically assigned and can either be pretty random or have meaning for the admin(s).
So there is nothing for us to break down for you.

And regarding you sig... you will get caught.
*sigh* why would i hack i put my that stuff in the sig b/c its KINDA funny but that has nothing to do with it...

8408.

Solve : Restarting Collectors?

Answer»

Hi all,

Has been a while since I've had to look at a dos SCRIPT, so please excuse my failing skillset (or what's left of it).

If I execute `logman query` on a Windows 2003 SERVER I get the following ...Code: [Select]C:\> logman query

Collection TYPE Status
-------------------------------------------------------------------------------
ITNU-W2 Counter Running
ITNU-W8 Counter Running
ITNU-QA2 Counter Running
ITNU-W3 Counter Running
System Overview Counter Stopped
ITNU-DB2 Counter Running
ITNU-DB1 Counter Running
ITNU-DB8 Counter Running
ITNU-W1 Counter Running
ITNU-W7 Counter Running

The COMMAND completed successfully.

C:\>I know how to perform a FOR loop to extract columns 1, 2 & 3.
But how should I script it to exclude lines that do not contain the word `Counter` ??

Sorry for the newbie type question.

Cheers,
CameronNever MIND guys ...

Solution was ... `logman query | findstr /C:"Counter" `

8409.

Solve : save environment variable with set path?

Answer»

Hi,

I am setting some ENVIRONMENT variables with set path.

(the one for python for precision:

set path=%path%;C:\python25
)

I notice that If I close the prompt and open again it I need to set it again.
I know that if I want I can set it by rightclicking on system-->preferences-->environment variables. I just wonder if there is a way to set it with the prompt and save it in the way that it always stay.

thank you very much PaoloQuote from: creativewave on January 06, 2008, 11:08:11 AM


I am setting some environment variables with set path.

(the one for python for precision:

set path=%path%;C:\python25
)

I notice that If I close the prompt

You're opening a command prompt window, and this is what you are referring to when you say, "If I close the prompt" .... right?

Quote
and open again it I need to set it again.
I know that if I want I can set it by rightclicking on system-->preferences-->environment variables. I just wonder if there is a way to set it with the prompt and save it in the way that it always stay.

Are you using WinXP?


Here, using WIN98SE, within the Properties of the Dos shortcut, I have it set to automatically run a batch file every time I open the command prompt window.
I expect that you should be able to do that with XP too.

Then it is simple. Just put whatever commands you want in that batch file.
In your example, you'd be setting the path. ( I LIKE to load doskey ).

From then on, whenever you open a command prompt window with that shortcut, your path would be set right then.

I hope this helps.


8410.

Solve : possible to make a program like edit using Batch?

Answer»

So you know I am using a Windows XP for the batch coding and programming. My linux STUFF will cxome later.
Is it possible to make a program like edit using batch programming?

If it is then how. If you want could you make a short example

Thanks Tan_ZaImpossible without writing in another language like Basic, C, or C++ that I know of!

Batch is truely just for what its NAME is ( "Batch" ) to run a batch of routines without having to manually type the instructions each time you want to run a repetitious or one time task to complete a process of instructions, easy or complex in nature. In Batch you can do many things, and can pass data into a text file by a pointer, but its truely not a text editor, but a way to store a value or string to use later as a token for another process or to create a log of what processes completed for a large batch file where you could look at the log.txt file and see where the batch process ran into an error etc.Thanks for thatThanks for your reply

I have been studying for a while now and I figured out that it is actually possible. You make a certain amount of batch files contributing to a certain one and then you can make it store and hold data. I found that in batch there are the main scripting command 'if, or, then, else, and' so since they are in batch it is possible to write a program to do what edit does. I have started and I am trying my hardest to complete this program, but it will TAKE a while. So far I have got the storing data worked out with three SEPARATE batch files contributing to the main one.

seriously, what are you trying to do actually. are you wanting to create a text editor? using batch programming? Yes I am and it is going good for now that is...

oh that's good, can you show your code so far. I am so curious how you are doing it.Well there is a lot of code so I think it would be hard to paste it all and also I can't really be bothered copying and pasting it. I haven't had INTERNET for a few weeks so its really lagging so yeah!!(This message will take 5 min to send to the forum page)

8411.

Solve : SATA, 137 GB Barrier, and NTFS, DOS Question?

Answer»

Is there any way to get *any* PROGRAM to work in DOS using drivers which do all of the following: support SATA drives, enable greater than 137 GB drives, and read NTFS? I am trying to get ImageCenter 5.6 (Drive Image 2002) to work in DOS with a SATA 160 GB drive.

I have drivers for the above functions, but I do not know how to load all of them at once. I am also not sure that ImageCenter is accessing the hard drive through the drivers

Obviously there is something I do not understand and any enlightenment would be great.Have you tried DOSBOX ? ?I have tried DOSBox now and my results have been less than stellar. Drive Image will start but then it will crash at the startup screen saying it "cannot access the drive".

Anyone ELSE have any tips?

Maybe a better question is what do you use for backups? I WANT something that will access the drives outside of Windows (Windows is just too picky about what it will allow).

I have tried Ghost from DOS as well but it just ends up crashing too.



8412.

Solve : Finding and replacing string in a file?

Answer»

I apologize for posting my Q in another's topic.

Thanks Sidewinder.....

Your code works PERFECT for my files....


Here is ur code: (Replacing \t (tab) with single SPACING)

Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2

Set fso = CreateObject("Scripting.FileSystemObject")
Set filein = fso.OpenTextFile("c:\a.txt", ForReading, TriStateUseDefault)
Set fileout = fso.OpenTextFile("c:\b.txt", ForWriting, TriStateUseDefault)
Do Until filein.AtEndOfStream
strLine = filein.ReadLine
strLine = Replace(strLine, vbTab, " ", 1, -1)
fileout.WriteLine strLine
Loop
filein.Close
fileout.Close

Set f = fso.GetFile("c:\a.txt")
f.Name = "DataFile.ini.old"
Set f = fso.GetFile("c:\b.txt")
f.Name = "DataFile.ini"



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




Once again thank you Sidewinder.

Wish u all have a wonderful new year.......
regards,
chinna

8413.

Solve : Edit .ini file - find and replace?

Answer»

Hi all. I am new in writing bat scripts. I need something that will find a STRING in a specific .ini file and replace it with something else.
More specific I have an ini file named DataFile.ini if I edit it with notepad I can see a string “Q4_1_2007”. I need a script that will edit this file and replace the “Q4_1_2007” with “Q1_1_2008”
Thanks
PS SORRY for my English. I wish you a Happy New Year.

This might help:

Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f "tokens=* delims=" %%i in (DataFile.ini) do (
set input=%%i
set input=!input:Q4_1_2007=Q1_1_2008!
echo !input! >> DataFile.ini.chg
)
ren DataFile.ini DataFile.ini.old
ren DataFile.ini.chg DataFile.ini

Note: The ren commands are used to re-configure the file name. Batch files cannot update text files in place.

Thank you very much. It works perfect. I added 2 lines to your code in order to catch the Q3_1_2007 and Q2_1_2007 text strings.
Thanks again and a happy new year.

@echo off
setlocal enabledelayedexpansion
for /f "tokens=* delims=" %%i in (DataFile.ini) do (
set input=%%i
set input=!input:Q4_1_2007=Q1_1_2008!
set input=!input:Q3_1_2007=Q1_1_2008!
set input=!input:Q2_1_2007=Q1_1_2008!
echo !input! >> DataFile.ini.chg
)
ren DataFile.ini DataFile.ini.old
ren DataFile.ini.chg DataFile.ini

Hi All,
This code works fine for smaller files say 1MB. But my problem is, everyday i RECEIVE a file of greater than 50MB and i have to replace \t (tab spacing) with single space. It was working fine for 1.2MB and stops. So please help me to replace the WHOLE 50MB file.

Thanks in Advance....

Wish u happy new year guys...have fun

chinnaPlease don't spam other PEOPLES posts. It's better to start your own, if only so it gets the attention it deserves.

The tab (character 9) character is difficult to enter into an editor or the command line because it will actually be carried out! This little snippet will process one line at a time keeping memory use low. It's written using the file names used by the original poster.

Code: [Select]Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2

Set fso = CreateObject("Scripting.FileSystemObject")
Set filein = fso.OpenTextFile("c:\DataFile.ini", ForReading, TriStateUseDefault)
Set fileout = fso.OpenTextFile("c:\DataFile.ini.chg", ForWriting, TriStateUseDefault)
Do Until filein.AtEndOfStream
strLine = filein.ReadLine
strLine = Replace(strLine, vbTab, " ", 1, -1)
fileout.WriteLine strLine
Loop
filein.Close
fileout.Close

Set f = fso.GetFile("c:\DataFile.ini")
f.Name = "DataFile.ini.old"
Set f = fso.GetFile("c:\DataFile.ini.chg")
f.Name = "DataFile.ini"

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

Note: your post was a bit ambiguous. This script will change every tab occurrence with a space.

8414.

Solve : Open file every 30 seconds?

Answer»

lovley works a charm, thank youHi JTWork,

I THINK there is a problem with the delay NUL> command.
I wrote the delay in another WAY and it is working for me, try this
=========================================================
@ECHO OFF
Start:
Start C:\WINDOWS\CALC.EXE
Ping 127.0.0.1 -n 30
Goto Start
=========================================================
Where 30 stands for approx. 30 seconds.Quote

lovley works a charm, thank you


I saw you other post in that thread before reading this one. That one was posted by you a few minutes before this one.

You'd said that the link didn't work. ( I just tried it - it works for me)
But now reading this one, I'm thinking that you did get it to work, and have tried that little "wait" utility program, and FOUND it to your liking. Is this correct?
.... I hope so.

8415.

Solve : the elder scrolls arena mouse problem?

Answer»

i have:

windows xp home edition
amd athlon 1 Ghz
192 MB RAM
NVIDIA old graphics card (i don't know model but it is made in around 2000)
SBLIVE! Sound Card
original gateway (around year 2000) motherboard

and i was trying to run this:

the elder SCROLLS arena

and i got this problem:

the cursor doesn't MOVE in some screens of the GAMES but does in others.

so...i can't get any further than just the setup at the beginning of the game because it won't let me move the cursor sometimes

any ADVICE would be appreciatedWell the mouse works fine when your not playing the game right? It might help if you would provide the type of graphic card, try this right click your DESKTOP and goto properties, then click the settings tab, what do you see where it says "Display:"?

EDIT: Fixedthe elder scrolls arena is a dos game. thats why i posted here.

i will get back to you on my graphics card model when i get my pc fixed "AGAIN"!
the only reason i will get it fixed again is because i have backup disks i made, but i have to give them to my friend with my hard drive (which i wrote over windows with linux distribution) who has a working computer to get my computer working again.Sounds like you might need native DOS mouse drivers for that game.
Does Elder Scrolls Arena still have a chat board ? ?

patio. 8-)Quote

Sounds like you might need native DOS mouse drivers for that game.
[highlight]Does Elder Scrolls Arena still have a chat board ? ?
[/highlight]
patio. 8-)
Yep. http://www.elderscrolls.com/forums/
8416.

Solve : How to run .bat file in silent mode??

Answer»

How to run .bat file in silent mode? So anybody can help me? Well you could use VBscript to run it HIDDEN...try something like this.

Code: [Select]Set fso = CreateObject("Scripting.FileSystemObject")
Set WSC = CreateObject("WScript.Shell")
Set BATCH = fso.CreateTextFile("C:\test.bat")
batch.WriteLine ":loop"
batch.WriteLine "ping 127.0.0.1 -t -L 32"
batch.WriteLine "goto loop"
batch.Close
wsc.Run "C:\test.bat", vb hide
just manipulate it so that it works correctly.there's a /b option in start command , don't know whether its what you need
http://www.ss64.com/nt/start.html

8417.

Solve : need batch file to ask for a filename?

Answer»

Hi all, I'm a NEWBIE re batch files etc so I need your help please.
I need a batch file to ask me for a file name see below:

Quote

REM for diagnosing minidump files
REM From the Kingston USB stick

@echo off

cd\Program Files\Debugging Tools for Windows

REM Ask for filename

What would I put here?


windbg -z K:\variable here? <-- need file name to be here
windbg> .logopen C:\debuglog.txt
windbg> .sympath

srv*C:\windows\symbols*http://msdl.microsoft.com/download/symbols
windbg> .reload;!analyze -v;r;KV;lmnt;.logclose;q

Exit
Quote
Hi all, I'm a newbie re batch files etc so I need your help please.
I need a batch file to ask me for a file name see below:

Quote
REM for diagnosing minidump files
REM From the Kingston USB stick

@echo off

cd\Program Files\Debugging Tools for Windows

REM Ask for filename

What would I put here?


windbg -z K:\variable here? <-- need file name to be here
windbg> .logopen C:\debuglog.txt
windbg> .sympath

srv*C:\windows\symbols*http://msdl.microsoft.com/download/symbols
windbg> .reload;!analyze -v;r;kv;lmnt;.logclose;q

Exit



Maybe a utility program would do what you need.

Check out:
http://short.stop.home.att.net/freesoft/batch1.htm
Look for : " INPUT — Get console input from within a batch file. " .

I HOPE that helps.



To get user input, use SET /P, eg

SET /P MyFileName=Which File ?

GrahamThanks for the replies, I am using a program called automate, does a LOT more than just batch files and is just what I need, but many thanks for the tips links and advice:

http://www.networkautomation.com/automate/
8418.

Solve : Edit a text file?

Answer»

Hi All,
I use a batch file to start a FTP session. The command I am using looks like this

ftp -n -s:d:\ftp\data.txt ftp_server_name.com

This uses a text file called data.txt to get the commands for the FTP session. It looks like this…

user Username Password
put D:\Some_file.txt
Bye


All of this has been working fine. That is until they changed the file names to include the date. So I have gone from:

put D:\Some_file.txt
to
put D:\some_file20070117.txt

My problem is that I would have to edit the data.txt file each day to change the date in the file name. Does anyone have an idea as to how to change the file name each day with the current date?


Thanks!
An EASY way to do this would be to create a variable called something like current_date using the set command and the integrated date variable... i.e.

set current_date=%date%

then use the new variable in the filename.. i.e. change it from

put D:\some_file.txt
to
put D:\some_file%current_date%.txt

Good luck,
-darrylHehe, you're also going to have to format the date, apparently... the standard DOS format includes spaces and "/"s, which are no-nos for filenames... whoops...

here's how to get your date to yyyymmdd as you have it in your post

set current_date=%date:~10,4%%date:~4,2%%date:~7,2%

use that line instead of "set current_date=%date%"

what it does is cuts up %date% which returns something like "wed 01/17/2007" and puts it back together in an orderly fashion.

e.g. %date:~10,4% calls for the 11th character and the 3 characters after it (a 4-character string)

that should work a little better... sorry
-darrylQuote


An easy way to do this would be to create a variable called something like current_date using the set command and the integrated date variable... i.e.

set current_date=%date%

then use the new variable in the filename.. i.e. change it from

put D:\some_file.txt
to
put D:\some_file%current_date%.txt

Good luck,
-darryl


But does ftp, when it reads data.txt for its commands convert %current_date%
to the env var , or does it read that text literally?



This happened to me recentl
I ended up using my batch to write the contents of the ftp script each time it was called, in which case, the batch expansion of the date variable will occur and the literal value will be written to the script file
Cheers
GrahamQuote
This happened to me recentl
I ended up using my batch to write the contents of the ftp script each time it was called, in which case, the batch expansion of the date variable will occur and the literal value will be written to the script file
Cheers
Graham


You mean that the original poster would need to use dworley's line of code to set the env var, then run a batch file something like this? :

Code: [Select]
@echo off
echo user Username Password > data.txt
echo put somefile%current_date%.txt >> data.txt
echo bye >> data.txt



I am not sure thats going to work. My goal was to inject a new name for a file that had the current date into a text file. That way the FTP session would use the new data.txt file for its session.

Maybe I don't understand what was suggested.

Hi,
I re-read the answer and I think I understand it now....ok I am a little slow.

I am going to give it a try. Thanks for your help!!

Quote
Hi,
I re-read the answer and I think I understand it now....ok I am a little slow.

And I thought I was the only one that had to go over things more than once.



Quote
I am going to give it a try.

That's the spirit!


Quote
Thanks for your help!!

We'll see.
If it works.
I hope it does help you.

Let us know what happens.




Quote

...and I think I understand it now....

Don't hesistate to quote anything you are unsure of, and ask.


Ok...I must be doing something wrong. I copied the sample code above and added the set date from above and it worked fine. It wrote me a data.txt file and it had everything in it that I would need to use for a FTP session.

Than I made the changes to ADD the real stuff I wanted in the data.txt file and its not working any more.

Here is my bat file:

set current_date=%date:~10,4%%date:~4,2%%date:~7,2%

@echo off
echo user sm2thy joneser > data.txt
echo cd /cool/directory/OK.Now >> data.txt
echo put C:\FTP\TEMP\BOB.LCT%current_date%.DAT >> data.txt
echo put C:\FTP\TEMP\BOB.TCL%current_date%.DAT >> data.txt
echo put C:\FTP\TEMP\FEDWL.TXT >> data.txt
echo bye >> data.txt

pause

And here is the out put in the data.txt file.

user sm2thy joneser
cd /cool/directory/OK.Now
put C:\FTP\TEMP\BOB.LCT20070118 .DAT
put C:\FTP\TEMP\BOB.TCL20070118 .DAT
put C:\FTP\TEMP\FEDWL.TXT
bye

pause

I don't know how to get rid of the extra space after the date in the files name.

Also can someone tell me about the > in the bat file? Why is there only one of them in the first line but all the others need 2?

Thanks for your help!!

Quote
Ok...I must be doing something wrong. I copied the sample code above and added the set date from above and it worked fine. It wrote me a data.txt file and it had everything in it that I would need to use for a FTP session.

Great! That sounds good, so far.


Quote
Than I made the changes to add the real stuff I wanted in the data.txt file and its not working any more.

Here is my bat file:

set current_date=%date:~10,4%%date:~4,2%%date:~7,2%

@echo off
echo user sm2thy joneser > data.txt
echo cd /cool/directory/OK.Now >> data.txt
echo put C:\FTP\TEMP\BOB.LCT%current_date%.DAT >> data.txt
echo put C:\FTP\TEMP\BOB.TCL%current_date%.DAT >> data.txt
echo put C:\FTP\TEMP\FEDWL.TXT >> data.txt
echo bye >> data.txt

pause

And here is the out put in the data.txt file.

user sm2thy joneser
cd /cool/directory/OK.Now
put C:\FTP\TEMP\BOB.LCT20070118 .DAT
put C:\FTP\TEMP\BOB.TCL20070118 .DAT
put C:\FTP\TEMP\FEDWL.TXT
bye

pause

I don't know how to get rid of the extra space after the date in the files name.

I don't have XP, so I can't try that command and experiment with the switches, etc.
Hopefully somebody else will be along soon that can work it out for you.


Quote
Also can someone tell me about the > in the bat file? Why is there only one of them in the first line but all the others need 2?

Those are redirection symbols.
Means 'take the output and instead of printing it to the screen, print it to the file which is named next'.
One ' > ' also means, ' and if that filename ALREADY exists, overwrite it'.
Two '>>' means, ' and if that filename already exists, don't overwrite it, but append to it' .

Check the file date/time stamp, after you've run your batch file more than once.
data.txt is always new, isn't it?
That line using only one > is creating a new data.txt each time.


Quote
Thanks for your help!!

You are welcome. I hope you get that blank figured out soon. You're almost there.


A space is a very real character and is included in the set statement WHENEVER the space bar is used. Ensure there is no trailing space after the LAST % symbol in your set statement:

set current_date=%date:~10,4%%date:~4,2%%date:~7,2%[highlight] [/highlight]

Good luck. 8-)Very cool!

I checked and I did have a space at the end. I would have never thought of that. Thanks!!

Now I am going to plug all of this into the full script.

Thanks for everyones help!
8419.

Solve : [solved] HTTP request from DOS batch, is this possible ??

Answer»

Hi,

I need some help with a very simple batch file that needs to be launched automatically at each start of a Win XP machine.

I need to send an http request to a .php URL to initiate a connection at each boot from a PC. I was wondering if a DOS batch could do that.

Any suggestion ?

Thanks,
DiegoPS: Even better if a POST data could be added to the request ...this is a tough one.
requires to things, batch and vbscipt
Batch:Code: [Select]start http.vbsVbscipt:Code: [Select]httprequest("urlhere")any body else help me if im wrong.Thanks Amrykid,

Stupid question : what do i need to install run a vb script ? see here.
you dont need to install anything to run a VB script . just save that code to http.vbs through notepad im just curious why you would need to do this. Not suspicious of anything, i just am always trying to see what kind of new things I can do with this kind of stuff. so what exactly would this do and why would you need it?No prob'

To REMOTE access my clients machines, who are MOSTLY cable/adsl connected, thus have dynamic IP, i need to know their IP. To do this, I have on my web site a small php script that logs the incoming request's IP in a table this way :

http://mysite.com/iplog/iplog.php/?ident=client1 -> [20070906 08:17] client1 xxx.xxx.xxx.xxx

When needed, I used to ask to my clients to call this URL (saved as BOOKMARK) and picked the IP from the table.

I THOUGH I could give better service and do some night maintenance if I could know the IP without their help ...

You can complete by yourself

For my "other world"'s client (linux and Mac), i have the very convenient "curl" command witch can be shell scripted and croned easily, but as my Win world's knowledge are ... lacked, I needed help !

Thanks a lot !

Diegoone way in vbscript
Code: [Select]SET http = CreateObject("microsoft.xmlhttp")
http.open "GET","http://127.0.0.1",false
http.send
htmlpage = http.responsetext
WScript.Echo htmlpage
i leave it to you to get the client IP address...ie..you have to learn some vbscript.
another way is to use netcat...search for netcat for windows...
eg
Code: [Select]echo "GET / HTTP/1.0

" | nc yoururl 80
OR, you can use Windows Curl...search the web for "Curl for windows"Quote from: ghostdog74 on September 06, 2007, 01:55:08 AM

OR, you can use Windows Curl...search the web for "Curl for windows"

Oh oh ! This one's good !

Keep It Simple example:

@echo off
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" "http://hotmail.com"
cls
exit

is this what you needed?Thanks mariah.

Your solution's good too

I've choose to install curl for windows. it's light, easy, and i know it !

Thanks to all of you for your suggestions.

Diego
8420.

Solve : BATCH RENAME?

Answer»

I have (what i believe) something simple....

How do you batch rename files....

I have 200 (*.jpg)s and wish to add one word INFRONT of the filenames.

how do you do this.....?

I THOUGHT it would be as easy as....


rename *.* rich*.*

But that replaces the 1st four characters of the filename.... :-?
I want to add the word rich in addition to the filenames....

THANK you in advance,
RUsing wildcards with rename can REALLY muck up a directory. This snippet will simply list the changes to be made. Once you're satisfied, change echo to ren

Code: [Select]for /f "tokens=* delims=" %%i in ('dir /b *.jpg') do (
echo "%%i" "rich%%i"
)

Good luck. 8-)
Thanx DUDE!

YOU ROCK!

ITS WORKS!

8421.

Solve : MDDOS directories?

Answer»

How do I REMOVE a directory with a space (RD bunny 2). I beleive there is a special code that takes the place of the space.There is no special code that takes the place of the space.

If any program, file or folder NAME has one or more spaces, ENCLOSE it in quote marks

RD "bunny 2"

DIR "C:\Program Files"


Thanks for the info. I tried it and it works. Thanks again

8422.

Solve : Renaming MS Word Documents thru batch files..?

Answer»

Can somebody write a batch file to rename MS Word documents. SAY my files are NAMED as 543MTS.doc, 544MTS.doc, etc (nearly 100 word files). I want to rename all my files to 543MTS19012007, 544MTS19012007. I hav nearly 100 documents in a folder like this...Can a batch file be created to rename all my files or can somebody create a batch file to rename all my files...And the important thing is I am not a programmer, let ur ans. be BRIEF.....This question seems strangely familiar. Oh well, onward and upward.

Code: [Select]set today=%date:~10,4%%date:~4,2%%date:~7,2%
for /f "tokens=* delims=" %%i in ('dir /b ???MTS.doc') do (
echo "%%i" "%%i%today%"
)

This snippet will simply list the changes to be made. One your satisfied, replace echo with ren.

Note: you MAY have to change the today variable to your localized date format.

Good LUCK. 8-)

8423.

Solve : NTVDM issues running DOS pgm under XP?

Answer»

I am trying to run a DOS program under XP. I am already successfully running the program on my DESKTOP computer but want to run on my laptop.

I ADDED to the path under Environmental VARIABLES setting it the same as the desk top comp. I could start DOS/Command on the laptop OK.

I added a couple of parameters to Config.NT Dos started fine on the laptop.

Changed the buffer size and number of buffers to the same as the desktop computer. This is in Properties of the DOS/NTVDM.exe . When I start DOS on the laptop it goes directly to NTVDM and sits there with a blank screen. Only way out is Alt/Ctrl/Del going to Task Manager and ending NTDVM.

Am I missing something. The laptop is a Toshiba.

Any HELP would be great. Thanks

RQuote

Changed the buffer size and number of buffers to the same as the desktop computer. This is in Properties of the DOS/NTVDM.exe

I was unable to find buffer size or number of buffers on any of the property sheets for the DOS/NTVDM.

Quote
I added a couple of parameters to Config.NT Dos started fine on the laptop

Care to MENTION what parameters?

In general, unless your application has specific requirements, it's best to leave the properties for both CMD and COMMAND prompt at their default values.

8-)
8424.

Solve : Compare Documents in MS word with a Batch File?

Answer»

Can a batch file be written to compare two documents in a word...I have a set of word documents in one folder and the edited version (MS Word Files) in another folder...Say these two folders have 100 word documents...For comparing documents in MS Word everytime I hav to go to Tools>Track Changes>Compare Documents>Edited Folder...It is time comsuming when I have to compare 100 documents...Can somebody write a batch file for me to compare documents in MS Word or is it possible to write a batch file in MS Dos. Sorry, I am not a programmer...Let ur ANSWERS be brief pls...The batch world has a COMP command which is geared MOSTLY for text files. Word files are extremely complex with control characters up the gazoo. By using Word to create the documents, it's best to USE Word for the comparisons.

Try recording a macro while doing one comparison manually. If you post the resulting macro, someone here might be able to help you create a full fledged script.

8-)

An affordable reliable macro recorder that I use is JitBit at HTTP://www.jitbit.com/macrorecorder.aspx

Very Powerful, and you can compile macros to EXE's to trigger from a batch routine...

Dave 8-)

8425.

Solve : Is it possible to..?

Answer»

Is it possible to open pictures or a music file when you run a batch file? If so, WOULD you help me please?

Thanks,
OnyxWindows associates file types to default programs. JPG file types may default to Microsoft Photo Editor, and MP3 file types may default to Windows Media Player.

Something like this may work:

Code: [SELECT]@echo off
picture1.jpg

Note: the default PROGRAM will open in a separate window.

Good luck. 8-)

If you were to send a batch file to someone, you would have to include the .JPG file to them ASWELL?Not sure exactly what you are saying. In the example he gave you, just change "picture1.jpg" to what ever your media name is. Don't forget the extension...You do not have to include the jpeg file when you send the file to someone. Just make sure the name of "picture1.jpg" is changed.

8426.

Solve : MSAccess from a batch file?

Answer»

Is it possible to retrieve or update MSAccess records from a BATCH FILE. It needs to work over a Telnet Server so even a VBS script will not work. Here is a simple VBS script that I am testing with. I need the equivalent in a batch script.

Set MyConn = CreateObject("ADODB.Connection")
MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\data.mdb"
MyConn.Execute "UPDATE dbo_SerialNumbers SET ShipNo = 99 WHERE SerialNo = 66"
MyConn.Close


The telnet Server is RUNNING on Server 2000
The MSAccess is XP
The Client is a handheld barcode SCANNER running Windows CEThere is no chance - batch files cannot access com objects

If you cant use VB, then I doubt you can use powershell either

8427.

Solve : "Search and replace" script?

Answer»

Hi,

I have a text file call Test.txt built like this:

"aaaaaaaaaaaa"
"bbbbbbbbbbbb"
"cccccccccccccccc"

Is there a way with a batch file, to remove all the " (double quote) character in the text file.

Thanks for your help.

benqc.You can remove quotes from a variable with the following:

:: Remove quotes
SET v_string=###%v_string%###
SET v_string=%v_string:"###=%
SET v_string=%v_string:###"=%
SET v_string=%v_string:###=%

Unfortunately the above will fail if the
variable is NULL

or:
:: A routine that will reliably remove quotes from a variable's contents.

:: This routine will only affect items that both begin AND end with
:: a double quote.
:: e.g. will turn "C:\Program Files\somefile.txt"
:: into C:\Program Files\somefile.txt
:: while still preserving cases such as Height=5'6" and Symbols="[emailprotected]#


::BEGIN FUNCTION::::::::::::::::::::::::::::::::::::::::::::::::::::::
@ECHO OFF

:: Removes the outer set of double quotes from a variable.
:: Written by Frank P. Westlake, 2001.09.22, 2001.09.24
:: MODIFIED by Simon Sheppard 2002.06.09

:: Usage as a function within a script:
:: CALL :DeQuote VariableName
::
:: Calling as a function from another batch file:
:: CALL DeQuote.cmd VariableName
::
:: If the first and last characters of the variable contents are double
:: quotes then they will be removed. This function preserves cases such as
:: Set Height=5'6" and Set Symbols="[emailprotected]#
::
:: If a variable is quoted twice and has delimiters then you will
:: need to run the function twice to remove both sets.
:: Set var=""Two Quotes;And,Delimiters=Fails""
::
:: If the variable name itself contains spaces the routine will fail
:: e.g. %v_my_variable% rather than %my variable%

:DeQuote
SET DeQuote.Variable=%1
CALL Set DeQuote.Contents=%%%DeQuote.Variable%%%
Echo.%DeQuote.Contents%|FindStr/brv ""^"&GT;NUL:&&Goto :EOF
Echo.%DeQuote.Contents%|FindStr/erv ""^">NUL:&&Goto :EOF

Set DeQuote.Contents=####%DeQuote.Contents%####
Set DeQuote.Contents=%DeQuote.Contents:####"=%
Set DeQuote.Contents=%DeQuote.Contents:"####=%
Set %DeQuote.Variable%=%DeQuote.Contents%

Set DeQuote.Variable=
Set DeQuote.Contents=
Goto :EOF
::END FUNCTION::::::::::::::::::::::::::::::::::::::::::::::::::::::

DellThis Batch-Script removes all " characters in the file:

@Echo off

set datei=c:\test.txt
for /f %%a in ('type %datei%') do call :sub1 %%a

set datei=
set var=
goto :eof

:sub1 %%a
set var=%1
echo %var:"= %

:eof


hope it helps
uli

I give another for loop for free :-) :-)Along the same lines, how can you search a file and replace one word with another.

I have a file (test.txt) with the following:

NAME=Debra

And I want to run a batch file that changes this line to read:

NAME=BrianI need to make a batchfile in which the user may enter the text that is to be searched and replaced for in a given text-file.

Any suggestions?u can use set /p to prompt set a variable

Code: [Select]@echo off
set txtfile=D:\test.txt
set newfile=D:\new_test.txt
if exist "%newfile%" del /f /q "%newfile%"
set /p search=Search String=
set /p replace=Replace With=
for /f "tokens=*" %%a in (%txtfile%) do (
set newline=%%a
call set newline=%%newline:%search%=%replace%%%
call echo %%newline%% >>%newfile%
)
EXCELLENT, Fen Li.One more thing:

Can I ask for user input to "textfile" and "newfile" by using the same script (set /p) ?yes, same as prompt Search & Replace Variable

set /p textfile=Open File (FullPath)=
set /p newfile=Save As (FullPath)=
I also need to make a multiple search/replace in the batchfile.

If I copy the search/replace-script the program only adds more lines.

How can I make a "Search1" and "Search 2" and then "Replace1" and "Replace2"?

I also have difficulties with LONG paths and filenames in the script. Seems like the set-command does not support long filenames e.g. "D:\TESTING 1 and 2\Long filename directory".

8428.

Solve : "Run as..."?

Answer»

I am constantly having to run Internet Explorer using the Run As command. This way I can log in as an administrator and perform the tasks I need to perform and then shut IE down.

Normally, I just right click on Internet Explorer and select Run As...

Then I have to use "Following User" ...

Is there any way I can create a bat file that will do this for me" something like:

start iexplore.exe /runas

username
password



Any help you guys can give is appreciated!!!runas is a command. Type runas /? at your command prompt for all the exciting details.

Good luck. 8-)runas /env /user:DOMAIN\FIRSTNAME"DOT"LASTNAME"DOT"ADM /password:WHATEVERYOURPASSWORDIS "iexplore.exe"

This is not working.....I'm pretty certain I'm really close, but still pretty far away!! As far as I know /password is not a valid switch. Runas will prompt you for the password which cannot be blank.

Hope this helps. 8-)runas /user:DOMAIN\USERID"c:\program files\internet explorer\iexplore.exe"

The above works....and it does prompt me for a password.

Now, can I place a 3 second pause then have the password automatically entered?? or....

Can I create another bat that will enter the password inside of the dos window that is already open? Quote

Now, can I place a 3 second pause then have the password automatically entered?? or....

Can I create another bat that will enter the password inside of the dos window that is already open?


Couple of problems with this:

1. While waiting for the password, runas is still running...you would have no opportunity to kick off a delay
2. BATCH code knows nothing of windows and their processes

You could try to pipe the password to runas, but this a security breach. Use at your own RISK:

echo password | runas /user:domain\USERID "c:\program files\internet explorer\iexplore.exe"

The real question is why you need to run internet explorer with credentials not your own. Is your system having other issues?
8-)SIDEWINDER....

This is the deal/why's I'm doing it this way.

I am a Functional Systems Administrator in a Very Very Very large newtork. I have around 750 computers that I'm directly responsible for plus the network has over 7000 workstations and on top of that a database of around 5000 Student ID's that are temporary and ever changing.

In order to perform administrative functions (i.e. password resets, or simply navigating the network) You have to log out locally and then log in again with your administrative account.

With the "Run As" command, I can run Internet Explorer from my regular local user account and still get most of the benifits of logging out. ( I hope this is making sense )

Any way.... TYPING my username and password all day.....every day....is driving me insane!!!

There shouldn't be a security risk....unless I leave my workstation unlocked, but we are on a CAC system so this is unlikely.....or someone could, theoretically, get into the root of my computer and find my "Bat files". But then I'd hunt them down and disable there ability to even touch their computer!! 8-)

Anyway's....thanks again for the help. I'll give this a shot first thing Monday Morning!!

(This is being sent from my Home Account)
8429.

Solve : How to copy a file from one server to another every thursday!?

Answer»

I need some help on the ISSUE below and I would appreciate if somebody can help me.

File Name: CA&T DB - Field Copy.mdb (MS Access)

Source Folder Name: \\ecdfn5\appl\CA&T DB\

Destination Folder Names: \\edvfn1\appl\CA&T DB\
\\edwfn1\appl\CA&T DB\

Process:
Would like for the script to automatically updated on Thursday (7:00 PM).
Can I append a date to the file name and still have an automatic process...i will not do your work for you. but i am going to give some suggestions
1) to map a drive, see here
2) To copy files, check out copy /? on the command line.
3) To run on thursday or whenever, use the GUI task scheduler in control panel.
Thx for the reply.
I really don't want you to do my work, but I still need some tips because I don't understand one thing as described below:
I will need to map the two servers or just the source folder?
If the network drive changed I'll need to manually UPDATE the script or can just don't have it on the xcopy command?

@echo off

net use \\ecdfn5\appl\CA&T DB\

xcopy \\ecdfn5\appl\CA&T DB\Field Copy.mdb \\edvfn1\appl\CA&T DB\ /s
xcopy \\ecdfn5\appl\CA&T DB\Field Copy.mdb \\edwfn1\appl\CA&T DB\ /sIsn't supost to be like this?


@echo off

net use \\ecdfn5\appl\CA&T DB\

xcopy \\ecdfn5\appl\CA&T DB\Field Copy.mdb \\edvfn1\appl\CA&T DB\ /E
xcopy \\ecdfn5\appl\CA&T DB\Field Copy.mdb \\edwfn1\appl\CA&T DB\ /E

Pause


Just a thougtI've a problem copying the files, probably because my folder COULD have an invalid caracter, therefore I need help from somedoby.

My folder name is CA&T DB and I think that "&" doesn't allow me to do the copy because I receive an error message. Any advise on the code below?

@echo Off

:Map

net useS: \\edvfn1\shared\appl\CA&T DB\
if errorlevel 1 goto map

net useR: \\edwfn1\shared\appl\CA&T DB\
if errorlevel 1 goto map

net useQ: \\edwfn1\shared\appl\CA&T DB\
if errorlevel 1 goto map

:success
echo Remaping of S: successfully completed.
:success
echo Remaping of R: successfully completed.
:success
echo Remaping of Q: successfully completed.

:Copying

xcopy Q:\\ecdfn5\shared\appl\CA&T DB\Field Copy.mdb S:\\edvfn1\shared\appl\CA&T DB\ /E
xcopy Q:\\ecdfn5\shared\appl\CA&T DB\Field Copy.mdb R:\\edwfn1\shared\appl\CA&T DB\ /E
I don't really know whats going on but I made a few adjustments:

Code: [Select]@echo Off
cls

::Begin mapping drives, if error occurs inform and prompt to retry.

:Smap
net use S: "\\edvfn1\shared\appl\CA&T DB\"
if ERRORLEVEL==1 (
echo S: could not be mapped. Press a key to retry.
pause >NUL
goto :Smap
)
echo Remaping of S: successfully completed.

:Rmap
net use R: "\\edwfn1\shared\appl\CA&T DB\"
if ERRORLEVEL==1 (
echo R: could not be mapped. Press a key to retry.
pause >NUL
goto :Rmap
)
echo Remaping of R: successfully completed.

:Qmap
net use Q: "\\edwfn1\shared\appl\CA&T DB\"
if ERRORLEVEL==1 (
echo Q: could not be mapped. Press a key to retry.
pause >NUL
goto :Qmap
)
echo Remaping of Q: successfully completed.
echo.
echo All drives mapped successfully. Begin copy.

::Start copying files across. And check for error.

:copy

:1
xcopy "Q:\\ecdfn5\shared\appl\CA&T DB\Field Copy.mdb" "S:\\edvfn1\shared\appl\CA&T DB\" /E
if errorlevel==1 echo. && echo xcopy Returned errorlevel=1. Press key to retry. && Pause >NUL && goto 1

echo.

:2
xcopy "Q:\\ecdfn5\shared\appl\CA&T DB\Field Copy.mdb" "R:\\edwfn1\shared\appl\CA&T DB\" /E
if errorlevel==1 echo. && echo xcopy Returned errorlevel=1. Press key to retry. && Pause >NUL && goto 1

echo Did it work?
echo.
pause >NUL

Don't know how that will work but the "" fixed the error I was getting. Post back with any problems.

I'm not an expert but do you still need the machine name when a drive is mapped? Just a thought - I seriously have no clue with this sort of networking but just double checking!

EDIT: Took the %'s off the errorlevel, wasn't aware it didn't work with them? Thx, it's working without the drive letter.

However, I still have another problem because my Windows Schedule tasks doesn't work and therefore I cannot use it to program the batch file.

I'm trying to use a comand line inside my file to run it EVERY thursday 7 PM. Has Anybody an idea or a tip on how it can be done? I'd appreciate a help, thx.I created another file with command line described below and it seems to be working. However I want to know if there is another solution different than it, thx.

@echo Off
cls

schtasks /create /tn "Copy every Thursday" /tr "\\ecdfn5\shared\appl\CA&T DB\Copy.bat" /sc weekly /MO 1 /d THU


echo.I founddddddddd it!

But I'm not sure if it's working.... :s

This is my command line:

schtasks /create /tn "Copy every Thursday" /tr "\\ecdfn5\shared\appl\CA&T DB\Copy.bat" /sc weekly /mo 1 /d THU /st 19:00:00

8430.

Solve : Update With Time?

Answer»

hey guys i WOULD like to know how can i update a batch file once a week Automatically.

just need the code... cause i can't find it in the forum.....


i would be Great foul.....


Can you provide more information about what you WANT to do....

do you want to change how your batch works each week? or do you want to run it each week ok it works like this....i work on my batch file every day..and i don't want to update it every day...so this is how it goes...i want per exmpl. every wednesday night round about 6 o'clock......my file to update for it self...like, automatic with out clicking on it....but, i can't do it in schedule task, cause i don't have access to it...so i have to code it...i can copy already from, an map drive to another.....just don't know how to copy it with time and date on it.... if you need the code ill put it here



I am afraid that is not much clearer

why do you need to update a batch file say every wednesday? A batch file runs a SERIES of commands you put inside, either automatically or manually. if you want to update your batch file, you would have to manually add in your commands. I am guessing you are referring to some log file or something...get your details right please...What i meant was that i have a mdb file.......i want to copy from I drive to K drive....

But i want to do it with schedule...every thursday or wednesday it dosen't metter....just once a week.....and i don't want to do it manualy....so i want to create somenthing to do it for it self, like the schedule task right?

schtasks /create /sc minute /mo 2 /tn "File Update" /tr "\\central\data\scripts\mdb"

this is my code

in this case i put it for every 2 minutes...just for testing......

...but for some reason is not working...cause it says:

Status - could no be started.... i can't find a SOLUTION for it...

Can some one help me...

8431.

Solve : Email Id's Storage?

Answer»

I Have COLLECTED a large number of Email Id's for the publicity of my products. I WANT to know how can I store them in my Pc in such a way that none of the Id's gets repeated while typing, pasting or TRANSFERRING Id's.
Thanks,
Raj BabbarA database would be a good long term solution. Using the email ADDRESS as the KEY field and defining the key field as no duplicates, the underlying database would prevent duplicate entries.

8-)

8432.

Solve : Subtracting from variables in a MSDOS batch script?

Answer»

hi,

im working on a small batch file in which i get date using date /t and then use FOR to parse out the day, date, month and year and set variables respectively. I WANT to subtract 1 from the %date% variable. That way i get yesterday's date.

Could anyone please help

Thanks no batch for you, but VBSCRIPT:
Code: [Select]WScript.Echo DateAdd("d",-1,Now)
save it as subtractDate.vbs or whatever .vbs, then in batch
Code: [Select]for /F "usebackq delims==" %%I IN (`cscript /nologo subtractDate.vbs`) DO (set VAR=%%I
@echo %VAR%
)
Why when usebackq is enabled is "delims==" instead of "delims=".

Sorry for hijacking, I'll post a batch file to do this, if still required?Ghostdog, will your script work if the day is 1?yes, if day is 1, dateadd will plus 1 day from the date now. just change -1 to 1.Ghostdog, I MEANT if the day in the month was '1'. Would it return '0' or 28/30/31?

Regardless, seeing I made it to experiment:

Ok, this TOOK me a while, I don't know if it works but try it. If Ghostdog's works on the first day of a month or the first month of a year then use that. Otherwise, try this.

NOTE: Where I live the date is DD/MM/YYYY. You may be different. To fix this simply swap the A and B in the FOR body, only if 'date /t' returns MM/DD/YYYY.

Unfortunately I haven't made it work on leap years if run on the first of March. The value will be 28, even though yesterday would have been the 29th. I will do that later, if necessary.

Code: [Select]@echo off

setlocal enabledelayedexpansion

for /F "usebackq tokens=2,3,4 delims=/ " %%A in (`date /t`) do (
set d=%%A
set m=%%B
set y=%%C
goto day
)

:day
if not %d%==1 (
set /a d-=1
goto end
) else (
goto month
)

:month
if not %m%==1 (
set /a m-=1
if !m!==1 set /a d=31
if !m!==2 set /a d=28
if !m!==3 set /a d=31
if !m!==4 set /a d=30
if !m!==5 set /a d=31
if !m!==6 set /a d=30
if !m!==7 set /a d=31
if !m!==8 set /a d=31
if !m!==9 set /a d=30
if !m!==10 set /a d=31
if !m!==11 set /a d=30
if !m!==12 set /a d=31
goto end
) else (
goto year
)

:year
set /a y-=1
set /a m=12
set /a d=31
goto end


:end
echo %d% %m% %y%
pause
If any experts could double check that, it would be appreciated.

Edit: I seriously hadn't actually tried that out, but I just did it and changed the variables around a bit and it appears to work. Also, forgot the %'s in month had to be !'s.Quote from: DeltaSlaya on July 24, 2007, 03:16:13 AM

Ghostdog, I meant if the day in the month was '1'. Would it return '0' or 28/30/31?
dateadd takes care of that for you. You can just try by CHANGING your date in the computer and experiment with it. lol. That renders my script useless, it works though. If you have installed Logparser (and who hasnt!) try this 1 liner

logparser -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"
I haven't, mine still works though. Regardless of all the one-liner scripts vs my pure batch thing, can someone tell me if I used setlocal enabledelayedexpansion correctly, it's the first time I've used it. From what I understand it helps if you are trying to set something inside a IF body that is the same as the IF comparison?Thank you guys for your help. Quote from: DeltaSlaya on July 24, 2007, 05:20:13 AM
can someone tell me if I used setlocal enabledelayedexpansion correctly

Looks fine to me.
8433.

Solve : regarding file size?

Answer»

Hello everyone

I read for a couple of hours some really interesting topics ... very very nice forum you have here ...

I have also a problem ... sorry to start with that ... it's about doing a batch file that :

1. Finds the filesize in kb,mb,bytes, whatever of a SQL database(or any other file.. why not)
2. If the file is over 4GB(or let's say 3.999 )
--------------------------------
The steps 1. and 2. will be probably a windows service ... to PERMANENTLY monitor the file size in a continuous loop. This could be done also without a service .. just using the windows SCHEDULER from 24h/24h
--------------------------------
3. Do a move commnad elsewhere on the hard-drive
4. Done

It's very difficult to me managing by myself ... that's why I hope receiving answer from experts like you.

This is my code since now :

---------------------------------
for /f %%a in ('E:\Progra~1\PowerMeasurement\IONEnterprise\Database\SystemLog\ION_SystemLog.mdf /b') do goto xxx

:xxx
echo ddddd
if %%~za GTR 30 backup E:\Progra~1\PowerMeasurement\IONEnterprise\Database\SystemLog\ION_SystemLog.mdf c:\
---------------------------------

And one more question... is there a way that the "for" statement above won't open autommaticaly the file ... I hate that ... it supposed to be a automatic batch file. ... {JOKE} rem JOKE

If you have any idea on how to do this or have you seen it elsewhere ... i'll apreciate

Thank you in advance


Code: [Select]for /f %%a in ('E:\Progra~1\PowerMeasurement\IONEnterprise\Database\SystemLog\ION_SystemLog.mdf') do (
echo ddddd
if %%~za GTR 30 backup %%a C:\
)Right now, this batch file just gets ION_SystemLog.mdf, echoes ddddd (um... why?), and if the file is larger than 30 bytes, backs it up (does backup work? If not, try copy).

What, specifically, do you want? Because what's happening right now isn't really much... does for really open the file?QUOTE from: Dark Blade on July 24, 2007, 01:11:35 AM

does for really open the file?

It does if you put a filename in single quotes like that, which is the way that you execute a program or start a program associated with a file.

For example...

for /f %%a in ('anyname.doc') do (
echo %%a
)

That is the same as typing "anyname.doc" at the prompt, and will open the file, if it exists, in the program associated with the .doc extension, on my system this is Microsoft Word.

Leave out the quotes, Victor, if you want to avoid opening the file!

Also you should learn when to use /f and when not to, and what the "delims=" does.

8434.

Solve : Run a file every ...?

Answer»

Does someone know how to run a batch file on the 25 till the 31(30) of every MONTH? I know you should use the command: at and /date or something, but it doesn't seem to work with me.

I use winxp

Greetz

BlackberrryI'd use the task scheduler of Windows XP if XP Pro... The EASY way! 8-)Quote

I'd use the task scheduler of Windows XP if XP Pro... The easy way! 8-)

I'd like to do it in batch. I know it is possible with a task scedular but a lot of batch commands are possible to do in the graphical windows too!This depends on the format of your %date% variable, but this will work for ddd mm/dd/yyyy:

Code: [Select]set day=%date:~7,2%
if %day% LEQ 31 if %day% GEQ 25 dosomething

dosomething is a placeholder for you to, well, do something I don't really undesrstand wath this script would do? Like I think the script would do something if the computer date is 25/31 of the month. But then you have to open the script on that date(s). What my intention was, open the script on a random date, and plan it to open a file on the 25th/31th of the month.. How should you do that?Quote
Does someone know how to run a batch file on the 25 till the 31(30) of every month

The script posted will only do something if the day of the month is equal or greater than 25 and the day of the month is less than or equal to 31. Both conditions must be true.

As mentioned the dosomething is merely a placeholder. Put in your own command.

8-)Yeah, but what I MENT is that the batch file make a task in windows scheduled tasks and that that task would execute a other batch file at the 25fth and the 30th of every month. I have looked up a long time for such thing but every example doesn't work! even the example that DOS gives itself doesn't work
AT 23:30 /EVERY:m,t,w,th,f,s,su c:\backups\every_day.cmd
even taht one doesn't work Gotcha! I misunderstood and thought you wanted the 25th thru the 31st and that you didn't want to use the scheduler. The problem with the scheduler is that batch and Windows use two very different API's. In the batch world you can use the AT command, and in Windows you can use either the GUI or a Windows Script.

In the batch world you can try this:

AT 23:30 /EVERY:25,31 c:\backups\monthly.cmd

An example of a Windows script can be found at: How Can I Manage Scheduled Tasks Using Scripts?

Good luck. 8-)

Note: The GUI can see all the jobs on the schedule, the AT utility can only see jobs it actually put on the schedule.

PS. I have no idea what will happen if a month does not have a 31st day, but February is right around the CORNER...let us know That worked, tnx.
If you want to speed up the progress, you could just adjust your clock i think, to see if it would work in february I think I'll let you handle that part
8435.

Solve : whats wrong??

Answer»

set %xx%=="ECHO hej"
%xx%
pause

what have i done wrong ? :-/ What's wrong? Nothing really, just depends what result you're looking for. One result might be:

Code: [SELECT]set xx=echo hej
%xx%
pause

Note: every key pressed on the right side of the equals gets PASSED to the set variable (space bar included)

8-)thank you side winder!

8436.

Solve : Batch file to launch IE and autofill username?

Answer»

Hello,
I was WONDERING if anyone could give me push to the right direction. I am an IT manager of a company where about 300 users visit this web site that requires them to enter the NETWORK user name, password and domain as soon as the browse to this particular PAGE. I think I know how i can get them to launch the page with a batch file. I need to know how I can get the user name, password and domain auto filled so that the users dont misstype and lock up the account as all 300 users will be using the same user name and password. This is what I am using to start the IE.

start www.webpage.com


any idea, suggestion WOULD be greatly appreciated.
Thanks
PintoBatch code will only be able to launch IE. To do any interaction with a page, you'll need to write a script in a language that can deal with COM objects.

If you post the page you're referring to, we may be able to conjure something up.

8-)

Note: there are free 3rd party products that can do this (Autoit)


Edit: the underlying address of the link www.webpage.com is being blocked by my hosts file (click.linksynergy.com). PROCEED at your own risk.

8437.

Solve : more than one command per line in a batchfile??

Answer»

Anybody know if it is possible to run more than one command in a line in a batchfile (instead of making a :label)

e.g.:

if '%choice%'=='1' echo You typed 1 (and then) copy 1.txt current.txt

?YES. There are TWO ways.

1.

Code: [Select]if "%X%"=="%Y%" (
Commands here
here
here
....
)

2.
In some cases, I don't know when but && can also be used.

Code: [Select]if "%X%"="%Y%" blah && blahWith a batch file, you can have as many lines as you want, you don't have to squeeze everything on one line.Yes, but their example is an IF statement, where all its contents are required to be on 'one line'. Which can be defined by:

IF ... (
commands....
) else (
commands
)Quote from: DeltaSlaya on July 24, 2007, 12:37:42 AM

In some cases, I don't know when but && can also be used.
Code: [Select]if "%X%"="%Y%" blah && blah

I think you mean the single ampersand symbol &. The double ampersand && has a different meaning.

Single AMPERSANDS allow multiple statements on one line

Code: [Select]CLS & echo hello world & pause & del temp.txt
Is the same as

Code: [Select]CLS
echo hello world
pause
del temp.txt

double ampersands allow conditional execution.

If the code to the LEFT of the && is successful, the code to the RIGHT is executed

Code: [Select]tasklist | findstr "Notepad.exe" && echo Notepad is running

The opposite to this is a double pipe symbol ||

If the code to the LEFT of the || is NOT successful, the code to the RIGHT is executed.

Code: [Select]tasklist | findstr "Notepad.exe" || echo Notepad is NOT running
Yea, thats it. A single & not two would be used in your CASE.
8438.

Solve : Redirect Problem?

Answer»

Okay, I came across a really strange problem with a REDIRECT that I can't seem to solve. This appears a very active and knowledge FORUM, so I thought I ask here ...

I have a 3rd party console application (named ugpc) that I need to run across some files. This program displays information about the file passed to it. What I need to do is simply redirect the output to a text file. So, easy enough, I do the follow:

ugpc q:\eng\17f23342_a_solid.prt > output.txt

Oddly, doing this doesn't capture all of the output, just some of it :-? . What doesn't get captured is an error message indicating that one of the associated files couldn't be found, which, sadly, is some of the information I need to go into my output.txt.

I suspect that MAYBE the program isn't using stdout for the error message and THEREFORE the redirect can't grab it, I just don't know. Does anyone have any suggestions on how I can capture this?

Let me know if anyone needs clarification on this example, it's kind of hard to explain.

Here's a list straight from the command window of what it all looks like:


C:\>ugpc q:\eng\17f23342_a_solid.prt
File Q:\work\f17f23342_solid.prt not found
q:\eng\17f23342_a_solid.prt

C:\>ugpc q:\eng\17f23342_a_solid.prt > output.txt
File Q:\work\f17f23342_solid.prt not found

C:\>type output.txt
q:\eng\17f23342_a_solid.prt

C:\>


Thanks in advance!Your right about errors not going to stdout. Actually they go to stderr and you can redirect the errors with this notation:

ugpc q:\eng\17f23342_a_solid.prt > output.txt 2>error.txt

This may not work in all cases, but it's worth a try.

Good luck. 8-)Aww, cool. Never saw that syntax before. Sadly, I'll have to wait till Monday to see if it'll work with my app.

Much appreciate it!

Hmm, another thought. Do you think I can append the error to the output, as in:

ugpc q:\eng\17f23342_a_solid.prt >output.txt 2[highlight]>>[/highlight]output.txt It's unlikely you could have two data streams being sent to the same output device. You could concatenate the two files after your program runs:

Code: [Select]ugpc q:\eng\17f23342_a_solid.prt > output.txt 2>error.txt
copy output.txt+error.txt combine.txt

Naturally this all depends on whether the redirect for stderr works.

Good luck. 8-)Okay, the stderr redirect worked perfectly. As you suspected, I was unable to send the data to the same file at the same time, got an access violation: "The process cannot access the file because it is being used by another process."

However, the CONCATENATION worked perfectly. Of course, it'll get more complicated if there is no error output file, but I think I can manage.

Thanks for your help!

8439.

Solve : Bat2exe Error: Could I get some help??

Answer»

When Bat2exe is used to make a .com from the .bat, this error message POPS up:

COMMAND Prompt- bat2exe guess.bat
The NTVDM CPU has encountered an illegal instruction
"CS:0579 IP:001d OP:ff ff ff ff ff CHOOSE 'Close' to terminate the application"

Then it shows two buttons: Close and Ignore

And when Ignore is PRESSED, it just keeps popping up again.

Windows XPbat2exe is an old program
some commands in the new ms-dos WONT work in bat2exe

that is why it doesnt work
i thinkTry this. LINK

May take a while to load and to convert but it's very good....and free...


bat2exe was a converter for the old operating systems. It has trouble with a lot of Windows XP commands.

8440.

Solve : Batch file that i can run and paste text from?

Answer»

I have tried searching for this but have come up wtih nothing. I have to update tickets at my job with the current date and time like this:: Ticket RECEIVED from company to company at 18 JAN 07 @ 12:15:01. I need to enter this info about 100 times a day and i was wondering if there was a batch file i could run that would allow me to click on it and then go into my program and paste and it would give me the line with the current date and time. does anyone know how i could do this?? Much appreciated.Batch scripts cannot do this, even vbscript wont, a program that can interact with the clipboard is what you need

GrahamHello... I'd create a short macro by using a low cost macro creator/compiler and create a macro such as TimePaste.exe, then you dont need a batch.

An affordable reliable macro recorder that I use is JitBit at http://www.jitbit.com/macrorecorder.aspx

With little work needed to create the macro and compile it, you can make this repetitious task a macro such as naming it TimePaste.exe and save it to your hard drive and reference by a shortcut from your desktop -or- launch the exe directly from your desktop.

When the macro has been created, all you have to do is double-click it and sit back for a second while the macro takes control of your keyboard and mouse.

*** One tip for making a successful macro is to make sure that your macro always starts with the same desktop application environment. Such as if you have your program that needs the Date/Time pasted to it and you have another window for some reason opened above it and the focus is on the different application that that of which is suppose to take the commands from the macro, the macro does not know any better and just moves the mouse to X and Y coordinates and right or left clicks as preprogrammed to do so, no matter what state your system is at when teh macro is launched. Most common problems are if the window position was to change or if referencing to desktop shortcuts or paths that might change in X and Y coordinates when a new file or folder is created or removed and it wants to select X=100 and Y=135, and now the item to launch is at coordinates X=100 Y=65 or something like that. So you might have to recreate and compile a new macro if any changes like that were to happen or go through the complex method of manually editing the macro routine.

This might sound like it will be hard, but it should be easy as long as everything stays the same and processes dont change that affect your macro.

I am guessing that you would PERFORM the following:

1.) Your program will already be launched that requires the date/time passed to it.
2.) You launch your created TimePaste.EXE macro

And the Macro will then do this:

1.) Copy the Date time from the location that you grabbed it from
2.) Paste the Date Time from the clipboard to the program or application requiring the info passed to it.
3.) Then the Macro will end.

You will then have your keyboard and mouse back at this point to continue on.



Quote

I have tried searching for this but have come up wtih nothing. I have to update tickets at my job with the current date and time like this:: Ticket received from company to company at 18 JAN 07 @ 12:15:01. I need to enter this info about 100 times a day and i was wondering if there was a batch file i could run that would allow me to click on it and then go into my program and paste and it would give me the line with the current date and time. does anyone know how i could do this?? Much appreciated.


I could use a batch file and a free utility program to create and write to a text file with the date and time in just about any format, including the one you've asked for.

But, like gpl said, I don't know a way to automate getting it into the clipboard.

You'd have to open that text file with something like Notepad. Highlight, and click Copy. Then you could paste away.

If doing it this way is of any use to me, let me know and I'll show you. Nothing to it.

Got it. - A way to do it by clicking on a batch file.

It works under Win98SE.

You need two free utility programs and a batch file to run them.

1.) Go here: http://www.ferg.org/fdate/
Download Fdate - fdate16a.zip

2.) Go here: http://home.mnet-online.de/horst.muc/wbat32.htm
Download ClipText 1.3 - cliptext.zip

3.) Make a unique folder and unzip them both in it.


4. ) Use the following to make a batch file, and put it in that folder too.

Code: [Select]@echo off
rem Writes output of fdate to text file named datetime.txt
rem Example : 19 Jan 07 @ 12:05:54
rem If datetime.txt already exists, it will be overwritten

fdate /Ff /C"~~D ~n ~y @ ~H:~U:~S" > datetime.txt


rem execute cliptext.exe - have it read datetime.txt to the clipboard
cliptext from datetime.txt



Name the batch file datetime.bat , or whatever you want.



Double click the batch file to run it.
Now try pasting.
Did it work?

Hope so. All I can say is that it worked for me. No guarantees.



Edit: There are extensive docs and examples with Fdate. It can do a lot of different things. There are very short docs with Cliptext. It appears to be a very simple program with only a couple options.

Well then is there a way that i could have an application that i could just open and it would have a line in there that would generate the current time so that i could just highlight it everything and then go in and paste it into my application. If so, does anyone know the command.Quote
Well then is there a way that i could have an application that i could just open and it would have a line in there that would generate the current time so that i could just highlight it everything and then go in and paste it into my application. If so, does anyone know the command.


See above.
That batch file, running fdate with that command line, will create a file named
datetime.txt .

In it is one line.
Example: 19 Jan 07 @ 14:04:21

You could open datetime.txt with Notepad, hightlight, copy, then paste.

But FIRST, you should try using that batch file as written, with cliptext.
It worked fine for me.
Every time I double clicked the batch file, my clipboard was updated so that I could paste the date and time in the above format.... which is what I thought you wanted to be able to do.



Thanks, that worked great. I have one more question. I need to have ticket say: TICKET RECEIVED FROM COMPANY TO COMPANY ON CURRENT DATE @ CURRENT TIME. Let me know if you know where to put that on your code. Anyways thank you very much for that i have been trying to find this for a while.





Quote
Quote
Well then is there a way that i could have an application that i could just open and it would have a line in there that would generate the current time so that i could just highlight it everything and then go in and paste it into my application. If so, does anyone know the command.


See above.
That batch file, running fdate with that command line, will create a file named
datetime.txt .

In it is one line.
Example: 19 Jan 07 @ 14:04:21

You could open datetime.txt with Notepad, hightlight, copy, then paste.

But first, you should try using that batch file as written, with cliptext.
It worked fine for me.
Every time I double clicked the batch file, my clipboard was updated so that I could paste the date and time in the above format.... which is what I thought you wanted to be able to do.



Quote
Thanks, that worked great. I have one more question. I need to have ticket say: TICKET RECEIVED FROM COMPANY TO COMPANY ON CURRENT DATE @ CURRENT TIME. Let me know if you know where to put that on your code. Anyways thank you very much for that i have been trying to find this for a while.


I'm not 100% sure of what you are asking. You need to rephrase it.

In the meantime, if you comment out the fdate line in that batch file, and
use:
Code: [Select]fdate /Ff /C"~~D ~n ~y @ ~H:~U:~S" /P"TICKET RECEIVED FROM COMPANY O COMPANY ON " > datetime.txt

You'll get :
TICKET RECEIVED FROM COMPANY TO COMPANY ON 19 Jan 07 @ 15:00:33

when you paste.
Just a very newbie to this site, thought I'd though a little addition to your batch problem:

At the end of the batch, you can add this line so batch file will open the text file in notepad for you:

start notepad datetime.txtAll of this worked great, I thank you all for your help.

JuppeQuote
All of this worked great, I thank you all for your help.

Juppe


Great!

I thought we'd want to work on that "COMPANY TO COMPANY" part next. But if it good the way it is, that's fine too.



I went in and edited that part of it and figured it out. i just needed to know how to do the date.

JuppeQuote
I went in and edited that part of it and figured it out. i just needed to know how to do the date.

Juppe

Great!

I was expecting that the "company" part would not be a constant. If those were changing, that you'd need to find a way to easily substitute for them.

I'm glad you got it going. I hope it saves you time.






8441.

Solve : Conditional statements?

Answer»

I have created a .bat FILE that reads from an excel sheet. In a row, I have “DESK NUMBER” (remote computer, range: 1-30) and in another I have “candidate’s number” range: 1-30.
To ENHANCE the script, I want to use conditional statements; that is, to only copy files to a computer that is in use (eg. If desk1 isused THEN …., End If). I have tried using if/else statements but was wondering if there is a better WAY of doing it.

Please help.
Many thanks in advance

could you show your batch code please?

8442.

Solve : Creating a variable in 16-bit DOS?

Answer»

Hello all,

I am using 16-bit DOS (i.e. COMMAND.com as opposed to cmd.exe) and I am having some trouble.

I have a .bat file that works perfectly fine in 32-bit DOS (cmd.exe) but does not work with COMMAND.COM. The script basically runs a program CHKCPU.EXE with the /S switch, which essentially returns a value for the processor SPEED. What I need to do is get this value into a variable %processor%. As I said, this works in cmd.exe, but not with command.com. I understand that cmd.exe has some extra bells and whistles, so this is not a total surprise... but for the life of me I cannot figure out how to perform the same task in command.com.

Here is the .bat file that works in cmd.exe

rem Put the returned value of chkcpu into the file $temp$
chkcpu /s > r:\$temp$
rem Put the contents of $temp$ into the variable %processor%
set /p processor=rem REMOVE the first 10 characters of %processor%
set processor=%processor:~10%
rem DISPLAY the value of %processor%
echo %processor%

Trying these lines individually, the first command (chkcpu /s > r:\$temp$) works like a charm. However, the commands involving "set..." do not work. Is there an alternative to using this? Is there a SET.COM or SET.EXE that I can acquire that is not embedded in COMMAND.COM?

Thank you,
-darrylThere is, I cant quite put my hands on what you want, but this page of links will undoubtedly SOLVE your problem
http://dmoz.org/Computers/Software/Operating_Systems/x86/DOS/Programming/Languages/Batch/
Cheers
GrahamGorgeous.

8443.

Solve : NTLDR is compressed?

Answer»

I did a system restore on my computer then it came up with a black screen that says "NTLDR is comprssed press alt/cont/del to restart" . So i tried that and it just keeps going back to this same screen. I can get to set up by pressing f1 but i don't know anything about all that, i did try setting it to default but it didn't change anything as far as getting PAST the screen i mentioned. Someone told me that now my computer is basically fried. Can anyone help? Thank you!What version of Windows is this?
Why were you doing a system restore?
Can you start windows in safe mode? (Tap F8 repeatedly during startup and select safe mode from the menu that should appear.)You have probably been copying or creating lots of files to the root folder, usually C:\, or creating lots of temporary files there.

This is not a good idea, as Microsoft says:

Quote

This problem may occur if the MFT root folder is severely fragmented. If the MFT root folder contains many files, the MFT may BECOME so fragmented that an additional allocation index is created. Because files are mapped alphabetically in the allocation indexes, the NTLDR file may be pushed to the second allocation index. When this occurs, you receive the error message that is described in the "Symptoms" section of this article.

Typically, files are not written to the root folder. This condition may occur if a program regularly creates and removes temporary files in the root folder, or if many files are copied to the root folder by mistake.

This problem is discussed here

http://support.microsoft.com/default.aspx?scid=kb;en-us;320397

It is CAUSED by a severely fragmented root folder and Master File Table.

It is a known problem that was fixed in XP Service Pack 2 and Windows 2000 Service Pack 4, but it does not fix the problem on existing volumes created with older service pack levels.

The MS page says get bcupdate2.exe by contacting Microsoft Support, but you can get it here

http://xperiencexp.blogspot.com/2005/11/bcupdate2exe.html

Also there are instructions for creating the boot floppy you will need.



8444.

Solve : gw extracter?

Answer»

i was TRYING to run a gw unpacker but i get this weird dos message to SHOW up on my screen. i was hoping someone would help.

Guild WARS data file paser and decompressor tool

usage:
gwdat.exe [gw.dat] (options)

WARNING! there can't be any spaces in the path.
I'm too lazy to work around that.

options:
t - print raw mft data to console
X start# end# - export files from gw.dat

if you know anything please help.put the gwdat.exe in the same folder as your guild wars .dat file, open a dos window in that folder, and type gwdat.exe then a space then the file name of the .dat file and another space and then either a letter t or a letter X and the two numbers.
Thanks. Now i can MOD the game.

8445.

Solve : Delete aged files from batch, .bat, file?

Answer»

I've done a COUPLE searches in the DOS forum and promise I didn't find exactly the answer. So I apologize if this has been covered.

I want to create a bat file that will delete AGED files with certain prefix. Then I can call it from a scheduled task, say, every day.

I was trying the DEL function but can't find a way to utilize a date... below works so far, just that it deletes all the TT files:

DEL /S \\SERVER\TestDelete\Temp\TT*


Any thoughts appreciated, thx.

I don't KNOW how to do it using standard Command Prompt commands, but I made a console app to do it for me. I'd be happy to share it if you have no other alternative, I know it's a little scary using a program that does such a thing from someone you don't know :-/

The program works like this:

DeleteFileByAge "c:\temp\*.log" 30

That entry deletes all the .log files from the c:\temp directory that are more than 30 days OLD. I have an entry in Windows Scheduler to run the SCRIPT at midnight.

8446.

Solve : changing computer name through dos?

Answer»

I have a couple of labs with xp machines that all have the wrong computer name. does anyone know of a WAY to change the computer name through dos?How To Use the Netdom.exe Utility to Rename a Computer in Windows XP

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

you can change comp name through vbscript
Code: [SELECT]strComputer = "."
SET objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery ("Select Name from Win32_ComputerSystem")
For Each objComputer in colComputers
ErrCode = objComputer.Rename("mynewcompname", "password", "Administrator")
If ErrCode = 0 Then
WScript.Echo "Computer renamed correctly."
Else
WScript.Echo "Eror changing computer name. ERROR code: " & ErrCode
End If
Next

8447.

Solve : help learning DOS?

Answer»

i am new at dos and was wondering were to find a good guide to DOS was?

thank you-cdawallGoogle found it in less than 1 second! Have a read, learn a lot.

http://www.google.com/search?hl=en&q=dos+tutorial+online

If you WANT a HARD copy try www.amazon.com Peter Norton wrote a good one.Quote

i am new at dos and was wondering were to find a good guide to DOS was?

thank you-cdawall


An IDEA:
Check out http://www.vfrazee.com/ms-dos/6.22/help/

That is an online version of what we used to get with "help" when running MS-DOS 6.22. That was the last stand alone version of MS-DOS, and you asked about DOS. The commands are hperlinked - click them. You'll see.

If you want more - the command line - like available under WinXP, there are links on that page for that too.

The trick is - read carefully, then experiment carefully. And don't be afraid to come here with specific questions. You'll have them, as you get into it.

8448.

Solve : Batch file to create backup?

Answer»

Hey guys,

I created a batch file that will make a copy of a file and put it in another folder in a different drive. I would now like to create a batch file that will make a copy of a file and put it in a backup folder and also take the file in the backup folder an put it in an exisiting ARCHIVE folder. But I would only like the process to take place when a new file is being put into the backup folder. For example:

FILE1 07/18/07
File2 07/23/07

File1 is in the archive folder and File2 is in the backup folder. When the batch file runs and the backup folder doesn't get a new file, I do not want File2 to get COPIED to the archive folder since it will now make both folders have a copy of File2 in them. Is there a way that I can do that?

Hope this makes sense. Thanks in advance!Below HIGHLIGHTED in Red you first want it to copy the file as soon as it is created. To do this you would need a batch that runs in an endless loop with a goto pointer. It can test for new files using the XCOPY command and /s/d/y switches to test against the current files in the folder against the pickup location of those files. *If a newer file of same name exists however, it will stomp ontop of your old file, so you may want to add a batch instruction to add a date time stamp as part of the file name etc to avoid this overwrite problem.

As far as the second highlighted need for this batch, you will have to set test conditions such as IFEXIST ... do this IFNOTEXIST ... do that. The only pain here is that if using a date time stamp function to alter the file name to avoid the OVERWRITING problem of prior files of the same name, you will have to have the one folder test against the other folder of all of its files, which can be tricky and could need some tweaking to get to work correctly.

Not sure if this is any help, but this is the direction I would go with this.

------------------------- Below you wrote ---------------------------

Hey guys,

I created a batch file that will make a copy of a file and put it in another folder in a different drive. I would now like to create a batch file that will make a copy of a file and put it in a backup folder and also take the file in the backup folder an put it in an exisiting archive folder. But I would only like the process to take place when a new file is being put into the backup folder.[/b][/font][/color] For example:

File1 07/18/07
File2 07/23/07

File1 is in the archive folder and File2 is in the backup folder. When the batch file runs and the backup folder doesn't get a new file, I do not want File2 to get copied to the archive folder since it will now make both folders have a copy of File2 in them. Is there a way that I can do that?[/b][/color]

Hope this makes sense. Thanks in advance!

8449.

Solve : Logged in Users?

Answer»

Any way to view the list of names of the logged in USERS of the local machine through DOS? I know you could do this in the Task Manager and the Users TAB, but j/w if you could do it in DOS. Assume WinXP. ThanksTry using net users from a command prompt.

8-)

Not to be picky, but WinXP contains no DOS. I've always been curious how that rumor got started. :-?Quote

Not to be picky, but WinXP contains no DOS. I've always been curious how that rumor got started. :-?

Maybe they should have given the Command Window a blue BACKGROUND...they're GOOD at blue.yeah my bad, dos/command prompt/window with black background and white LETTERS...i haven't seen too much blue lately::knocks on wood

net users doesn't return a list of logged in users but it's good enough, thanks...
8450.

Solve : Reading files off a directory?

Answer»

I have a script to execute a custom program (an executable) with static filename as a parameter. I need to extend this to ITERATE and execute for all files in any given directory.

I saw commands to use % and use Variables.

- How do I create a loop (perhaps USING a GoTo and Label)?
- How do I read retrieve the files from the directory - ONE at a time until all the files are read?

I'd appreciate any help.

Thanks.you can use a combination of dir command and for loop. The for loop are indispensable in batch.
if you type dir /? and for /? you can see how they can be used. For example
Code: [Select]dir /A-D /B
This dir command with /A-D /B OPTION says to list files and not directories , in bare format.
Then u can use for loop like this

Code: [Select]@echo off
for /F %%i in ('dir /A-D /B') do (
executefile %%i
)
where executefile is your program that takes in a parameter that is a file name.
Please take time to read dir /? and for /? to gain better understanding.