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.

2451.

Solve : adding a character to a txt file?

Answer» THANKS SOOOOOOO MUCH that WORKS a TREAT!
2452.

Solve : eof in skipspaces?

Answer»

I have some DOS software that has become CORRUPTED. When I RUN the executable BATCH file I get the ERROR "eof in skipspaces". I'm not SURE how this has become corrupted or how to fix it. Any help would be aprreciated.

2453.

Solve : Trying to Install Lexmark Z515 Printer?

Answer»

I'm trying to Install my Lexmark Z515 PRINTER & a pop-up reads 'Not compatible with MS-DOS'. The printer was installed once & someone in my family "uninstalled" it & the driver for it. I have Windows XP and am still pretty much computer illiterate. Please help!load the software first ...then attach the printer...it maybe that this printer is incompatable with winxp?/how old is this prt.you COULD NETWORK it with an old system win.........etc.....:'(ce Thanks for the advice, but it didn't work. The window still pops up that reads "AUTOEXEC.NT. This file is not suitable for running MS-DOS & MICROSOFT Windows applications. CLICK close to terminate." I went to a website & did what they recommended and it didn't work either. The site says that what's probable causing it is my ANtivirus thing is recognizing the file as a virus and deleting it. How can I check this & stop it?...Thx.

2454.

Solve : How to run a BATCH file while Computer is locked?

Answer»

Hi
I need to run a BATCH file which is containing thousands of commands. Normally I run this batch file just before I finish my WORK. so it is run in the night time when I'm not around. so I need to lock my PC while I'm not around. The problem is , from the moment I lock my computer batch file is pause it operation until I unlock the PC.

So pls Help me to find out a way to run a batch file while the computer is locked.
You can do that on Windows 2000 and XP using the task scheduler.

2455.

Solve : adding a label with another?

Answer»

how can we APPEND a LABEL with the ANOTHER

2456.

Solve : Can't overwrite because of Read-Only file?

Answer»

I MADE a batch file wich should overwrite ANOTHER exe, but the exe was made bij an installer so i can't change the exe before the installer was FINISHED, so is there any msdos command to Un read only a file? So my installer will work?the command you are looking for is attrib -r

For example, if you wanted to MAKE the file c:\test.exe to no LONGER be a read only, you would put in the command:

attrib -r c:\test.exe

Just add that into your batch before the overwriting and you should be good.Thanks it worked!

2457.

Solve : Backing up all files through DOS?

Answer»

Hey, I was wondering if someone could help me with this, if possible. I'm completely ignorant of DOS, and I'm looking for the CODE that will BACKUP all files on my COMPUTER to either a CD or external harddrive, using DOS code. There's quite good help for this elsewhere on the site, but I'm not sure what "directory" NAME I should use. Basically, it's everything in "My Documents" that I'm looking to back up. Apologies for asking something so basic, but I'd greatly appreciate any help anyone could give me. Thanks very much.Just wondering why you don't just drag My Documents to your backup drives. A lot quicker that DOS.

Mac
The computer's gone wonky, I think is the technical term, and the only thing that works anymore is DOS.Good answer!

OK, do START CMD
(or START COMMAND)

Then do CD until you reach "My Documents"

then do
copy *.* E:

(This assumes E: is the drive where you want your backup. Use whatever letter is assigned)

Mac
If you have an external drive that is E:, you would want:
Code: [Select]xcopy c:\ e:\ /e /h /k /c /d /yBy"all files" do you mean just document files or ALL FILES on the machine INCLUDING Windows, so you can reinstall it? If the latter, it will not work. If you want to back everything up this way and then reinstall Windows and copy back any non-program files that would be OK.

Windows and any programs would have to be reinstalled from CD.

That's great, thanks very much. I'm just looking to backup the document files, not the operating system and programs. I won't have access to the computer til next week, but I'll try what you all suggested. Again, thank you. Good luck.For document files you could use
Code: [Select]xcopy "C:\Documents and Settings\" e:\ /e /h /k /c /d /y
And I would also recommend skipping temp files. You can do this by creating a file called exclude.txt with
\temp\
\temporary internet files\
Then use the command
Code: [Select]xcopy "C:\Documents and Settings\" e:\ /e /h /k /c /d /y /exclude:exclude.txt

2458.

Solve : Modify a cookie file via .exe or batch  file??

Answer»

As you may well know, Google CREATES a "cookie" in our PC's, each with a unique ID that allows them to track our searches for God knows whatever commercial REASON. Being somewhat paranoid, I've been using a freeware utility known as "G-Zapper" which zaps the current current cookie and/or generates a new one. This is fine but once it executes, your Google Preferences are ALSO zapped and you must recreate them. No big deal but it's a nuisance.

This is my current Google cookie "%USERNAME%@google[2].txt" located at "C:\Documents and Settings\%USERNAME%\Cookies" starts with:
PREF
ID=752914db918a2b98:FF=4:LR=lang_en|........

I would like to replace the first six numbers (752914) with a random six digit number or it could even be the current time in format HHMMSS. The solution presented should also be an executable (.exe) FILE because I have a utility called IEPrivacyKeeper that, among other things, allows for the running of a program(s) upon exit from the last IE window.

Any help or suggestions would be greatly appreciated...
I wouldn't worry about it.

Google uses the query information to help you out.

Suppose I want to find
Cardinal Townsite : Home on the Range Real Estate, Inc.

But I'm lazy, so I just enter
Cardinal Range

If I have no history, I have to wade through a lot of bird stuff.

If I operate in the real estate business and have done a lot of related queries, they can guess what I want.

You can ask dumber and dumber questions and still get pretty good answers.

The history is also used to tailor any ads or "sponsored sites" you get. Without history, they just put up random ads that are annoying rather than helpful ads.

I have a hunch they keep your history on their supercomputers linked to your IP address ANYWAY and just use the cookie to record your preferences.

If you are paranoid, use Yahoo. It is pretty good lately.

Mac

2459.

Solve : boot disk does not boot?

Answer»

hello everybody-

i'm trying to reinstall the software on my toshiba satellite (which is off the warranty, so i'm told it will cost me $35 to ask them for help). because i blew my motherboard a few years back, i get a WRONG COMPUTER message when i try to boot from the RECOVERY cd.

i've downloaded a DMI update utilty and created a boot disk on a floppy, but when i restart it goes directly to windows rather than to the DOS utility where i'm supposed to be able to update my DMI values.

i have no idea why it won't work. the disk appears to have taken the information that it was supposed to have taken. is there a way to manually tell my computer to boot from the disk or is this a larger issue?

i appreciate any response :]Go into the bios and set floppy as the first boot device.2k_dummy -

my apologies. i'm ignorant re: BIOS and a google search has given me understanding only to the extent of it's wikipedia definition. this does SEEM to be the answer to my question however, and i'm very very thankful for that.

can i trouble you (or anyone) for a further explanation of how to manipulate my computer's BIOS?Watch the screen during initialization and should tell you which key to press to enter setup.gotcha. i know just what you mean. i should be able to figure it out from here.

if unsuccessful i'll be back soon :[

if successful i'll update in a few hours from my refreshed and rejuvinated computer :]ok now, that did work. it booted off the disk. another issue arises:

the DMI update loads and asks me select my model. i do so. then i get:

dmiset.exe unable to update DMI string TOSHIBA
dmiset.exe falied to write DMI data to machine
failed to update satellite 1905

when my motherboard blew, i took it to a computer repair guy because toshiba hung me out to dry. i recall he replaced the motherboard with one from the scrapheap.

i don't fully understand what a motherboard is, but is it possible my blown motherboard was replaced by a compatible motherboard not from the exact same series of satellites or even from another company? if that is so, is there any way to get my DMI values updated so i can use my recovery disks or is this a lost CAUSE?"Yep, if the mobo came from some other model, you are dead in the water. The DMI string applet won't work AND your recovery media will NOT work on a machine without the correct 1905 DMI string. Time to BUY a commercial copy of Windows"

this from JOHN of WUGNET in the compuserve forums. any thoughts?Quote

I blew my motherboard a few years back

Off topic, but the answer MIGHT help me and others avoid such a thing. How did it happen?

I once blew a motherboard while trying to fix my keyboard while the computer was on. Keyboards connect directly to the motherboard without any fuse. Dumb. And extra dumb because new keyboards are so cheap.

So I got a new motherboard and everything was fine until I tried to use some backups that were on floppies. The old motherboard had an error unknown to me whereby my floppies were not readable by anyone but me. My new motherboard, of course, couldn't read it and I lost a lot of data.

So I learned: Don't do any adjustments with the power on. (I sort of knew that, but was trying to see what was happening as I fiddled with the keyboard)

Mac

i dumped a cup of water onto the keyboard of my running laptop. everyone should avoid doing that :]
2460.

Solve : file name?

Answer»

i have a BATCH file which do the ftp and create a log file as ddmmyyhhmiss.txt format to record the ftp log.
when i run it manually the log file name generated correctly.
but when i use task schedular the the file name saved as ddmmyy, the rest hhmiss.txt is missing.

anny clue?It would help if you showed the exact BAT file. At least the line where you have something like
xxxx > %datetime%.log
or whatever.

With no data I have no way to test with my scheduler to see what you are talking about.

My guess is that it has NOTHING to do with FTP, so we could test with this bat file:

echo abc > %datetime%.log

(However you create datetime)

Then you are saying that bat file will work fine from the DOS prompt but not via task scheduler.

Need to see that to comment.

Mac
Here are the extracts from the batch file:
------------------------------------------------
echo off
SET YY=%date:~-4,10%
SET DD=%date:~7,-5%
SET MM=%date:~4,-8%
SET D4=%date:~0,-10%
SET HH=%time:~0,2%
SET MI=%time:~3,2%
SET SS=%time:~6,2%
ftp -s:d:\indump\bin\ftpcmnd.txt >d:\indump\log\ftp\[highlight]indump_%YY%%MM%%DD%%HH%%MI%%SS%.txt[/highlight]
pause ..


----------------------------------------------------------------------------
when i run it manually the filename becomes like
indump_20061103171734.txt

but when it runs from task schedular it becomes like
indump_20061106

hope you can help me now...I THINK your problem is that your scheduled time is running when your HH is a single digit padded with a space. I bet if you run it manually before 10 AM you will have the same problem. The way you are filling your variables is strange also. Try this instead:
Code: [Select]SET YY=%date:~-4%
SET DD=%date:~7,2%
SET MM=%date:~4,2%
SET D4=%date:~0,3%
SET HH=%time:~0,2%
SET MI=%time:~3,2%
SET SS=%time:~6,2%
if %HH% LSS 10 set HH=%HH:~1,1%
ftp -s:d:\indump\bin\ftpcmnd.txt >d:\indump\log\ftp\indump_%YY%%MM%%DD%%HH%%MI%%SS%.txt
pause ..The "if %hh%..." is to replace the padded space with a padded 0 for single digit HOURS, which I think is your problem.i have changed the system time now and run it manually after including your code.
it does not pad with 0
the filename now is like below.
indump_2006110685229.txt
but i want it to be
indump_20061106[highlight]0[/highlight]85229.txtThanx GuruGary,
I used this and now its working.

if %HH% LSS 10 set HH=0%HH:~1,1%You got it right. Yes, I had the code, but forgot the 0. Good job.

2461.

Solve : How to group the functions in IF statement??

Answer»

HI ,

May I know how to code the followings logic in DOS bat programs ?

if %mm%=01
{
set /A %mm1%=mm-1
echo mm is %mm%
echo mm1 is %mm1%
}

I have been TESTED with using {} but DOS gave the error msg.


THANKS,
I assume you are using WINDOWS cmd.

if "%mm%"=="01" (
set /A %mm1%=mm-1
echo mm is %mm%
echo mm1 is %mm1%
)

should work
hope it helps
uliIf i am not mistaken, the first bracket after a multiple line if statement is after the condition

eg

Code: [SELECT]if "%mm%"=="01" ( <--here
....
....
)

pls correct me if i am wrong.
You are right. Thanks for correcting my mistake.
I modified my posting.

uliThanks uli.
It did work.
Thanks a lot.


Quote

I assume you are using windows cmd.

if "%mm%"=="01" (
set /A %mm1%=mm-1
echo mm is %mm%
echo mm1 is %mm1%
)

should work
hope it helps
uli
2462.

Solve : Deleting 5 text files which are in 12122006.bak?

Answer»

please HELP as to how will we delete 5 text files which are in 12122006.bak mmddyyy format . all 5 files are in ascending ORDER of DATE.
can it be accomplished using a DOS SCRIPT and then schedule the job?
what will be the dos script?
kindly help soon

Regards

jheds
Jheds,

You will need to be more specific.
Do you have a given date and want to delete the next 5 files from the given date on?
Would it be ok to delete all files created before a given date?
Knowing what exactly it is for would help in suggesting a solution.

2463.

Solve : Start Command w/Parameters?

Answer»

On SEVERAL occasions I have needed to start a command with parameters in a .bat file but I am unsure how to pass the parameters properly. For example, I need to RUN the FOLLOWING command from a batch file:

start c:\RunProgram.vbs "cscript.exe %22c:\PROGRAM Files\Microsoft Shared Computer Toolkit\scripts\DiskProtect.wsf%22 /Save" /computer:xxx.xxx.xx.xxx /username:local\xxxx /password:xxxx

notice the % and the ", all of which need to be included. How can I do this properly?

THANKS!
sromine,

Use %% instead of %, i.e.:

[edit]start c:\RunProgram.vbs "cscript.exe %%22c:\Program Files\Microsoft Shared Computer Toolkit\scripts\DiskProtect.wsf%%22 /Save" /computer:xxx.xxx.xx.xxx /username:local\xxxx /password:xxxx[/edit]

DOS IT HELP?

2464.

Solve : My computer is a large paper-weight. Can any1 help?

Answer»

Hello!

I am newbie and was wondering if anyone could help me out because i have managed to make my computer stop doing a few things it used to do quite well, ie work.

I apologise if i dont make things clear as they should be...

''i wanted to clear my old computer of everything on it because it was running slow and i was thinking of not keeping it and giving it to someone (since then i have changed my mind and would now like to keep it). Its an old TIME computer running windows 98, I inserted the ''original recovery diskette'' hoping to restore its original factory settings - which i have sucessfully done before - but i reckon i went through the options in the wrong order or something and now cannot access windows at all, as all i see is the start up screen and the DOS thing..''

Do i have to type in something or reinstall something?, also the cd DRIVE light no longer wants to turn itself on so i presume i can only insert floppy discs. But i think i have relevant discs if i knew how to make my computer read them.

... so what im wondering is what have I done and how can i make it work?

Anyhelp will be greatly appreciated and recieve my goodwill!Have you tried your CD drive to see if it works? It could be just the light. If you have your old win98 cd or any newer version of Windows, just put it in and see if you can boot to it. Also make sure you have the boot settings in the bios fixed so that you can boot to it when you restart your computer.Hey, thanks for the reading the post and the quick reply. I would assumethe cd drive is working because it was fine before and it lights up when i initially turn on my computer. So thats okay i reckon. I read somewhere that i might need to go to this ''BIOS'' place and tell my computer to read my cd drive if it needs to, if it does... i dont know. I dont think i have a windows disc, if i could locate it would that be of any use? i have a microsoft works cd buts thats different.. i assume.

How do i check/enter BIOS?To get into BIOS on most computers is, as you are booting press the "DELETE" key. But it depends on what kind of motherboard you may have.The Windows disc is totally different than MS works, but if you can find a Windows disc laying around try using it to boot your computer to Windows installation.wow, (thanks to you) i have discoved the world of BIOS. this place looks interesting. So from what i said it seems like i need to locate my windows disc and things will work again.

I like the way you wrote ''if you can find a windows disc lying about'' because it pretty much somes up my computer area.No problem. Happy to help. i might be able to locate an XP disc in my house somewhere, would that be of any use? And if i placed inside how do i make my computer read it. do i change something in BIOS?YES, that will help alot. Could you list your system specs as to it will help in solving any problems that may occur before putting in your WinXP cd. Yes, you will need to modify the boot order in your BIOS set Cd-rom drive first, then EITHER harddrive or floppy(either way will work if booting from the cd).excellent. Okay system specs... hmm.. okay. Do you mean things like this?

external cache 512kb, enabled.

parallel ports: 378.

SDRAM at DIMMs: 1
Almost but, What kind of processor do you have and at what SPEED? How much RAM do you have? And What kind of video card and how much RAM.cool, just noticed its athlon processor 800Mhz. RAM is quite 'big' i think because Championship Manager (prior 2003) ran like a dream... sigh.

im gonna start my quest to locate my windows discs now, and hopefully return with good news! Thanks for all the help, i will post back when i find something (the cds).Well I just ask because if you install WinXP and you don't have enough RAM or processor is not fast enough, WinXP is going to be running pretty slow. I was able to get a computer with 500mhz processor and 64mb RAM to run but was really slow, put in another 64mb RAM stick and it ran a little faster but not much.cool, i get what you mean. i dont want to take 2 steps forward and 3 back. although tbh at the moment my computer isnt taking any steps anywhere to maybe she will just enjoy the exercise even if it is backwards.Quote

cool, i get what you mean. i dont want to take 2 steps forward and 3 back. although tbh at the moment my computer isnt taking any steps anywhere to maybe she will just enjoy the exercise even if it is backwards.

LOL very funny.
2465.

Solve : PLEASE HELP ME GUYS..... File Deletion SIDEWINDER?

Answer»

PLEASE Kindly guide me as to how will we delete back up files that are older than the LATEST backup file.

SCENARIO : We have automated the backup which takes place everyday.

Backup files are generated in the format WED_BACK.bak , THU_BACK.bak etc

The backup file generated is renamed to the daywise format : WED_BACK12192006.bak ,

THU_BACK12202006.bak etc

There are five different folders MONDAY,TUESDAY, WEDNESDAY till FRIDAY where the daywise backup

files are stored.


Now once in a week like on a MONDAY a backup file MON_BACK10122006.bak is generated in the MONDAY folder.
Next week on a MONDAY again a backup file MON_BACK18122006.bak is generated in the same MONDAY folder, which is the most recent file now.
The MON_BACK10122006.bak file is the older backup file and consumes a lot of space. There are a lot of MON_BACK.bak files in the MONDAY folder.
So now we want to SCHEDULE a batch program to delete the older backup files. ie MON_BACK10122006.bak and other old files also.


Please Guide me to the SCRIPT in DOS . Kindly help SOMEONE


i am working on windows xp and will prefer any dos script .

SIDEWINDER , ur script

@echo off
for /f "skip=5 tokens=1-5" %%i in ('dir D:\TEST\NEW\*.bak /tc /o:d /a-d') do -- I have chaged the path
(
del %%m
goto tag
)
:tag

this is not working . please help againg man.....

Regards,

JhedsThe easiest way would be to delete the old backup before creating the new one but many people may find that a bit scary. This little snippet should help you delete the oldest file in a directory:

Code: [Select]@echo off
for /f "skip=5 tokens=1-5" %%i in ('dir *.bak /tc /o:d /a-d') do (
del %%m
goto tag
)
:tag

You will have to modify the snippet for your ENVIRONMENT. 8-)I am very grateful for this SIDEWINDER .
I am giving it try.
if you can kindly jst spare some time and guide me as to how does this script of yours work line by line
i will really appreciate it
i am looking at this on my own also. but i am really new to this so
i expect some more help.
The old Backup file is in the format : WEDBACK13122006.bak and the NEW file in WEDBACK20122006.bck
and we have to delete the older one WEDBACK13122006.bak.
So in your code what do I have to replace and where to get this working.

Tkanking you in anticipation.


Regards,
JhedsThe snippet needs a path to the correct daily backup directory:

Code: [Select]@echo off
for /f "skip=5 tokens=1-5" %%i in ('dir [highlight]path\[/highlight]*.bak /tc /o:d /a-d') do (
del %%m
goto tag
)
:tag

It probably also needs to cd to the same daily backup directory.

If you were to run a dir command, you'd notice that the listing contains 5 lines of blank lines and heading info, a list of the files, and some totals info at the end. You'll also notice the file names are on the right side of the listing with date, time and size info all separated by spaces on the left.

The dir command is written to use the date created info, sort by date, and exclude directories from the list. The for command is written to skip 5 lines (heading info), create 5 tokens starting with the letter i, and to split each line on a space delimiter (which explains the 5 tokens).

As written, the snippet will process one line (the oldest file) and then quit the for loop. Simply put, the oldest file get deleted.

It might be easier if you posted your code. I'm guessing you have a working model and just needed help in getting rid of the pesky old backup.

8-)

Note: As with all coding, there are many ways to do things. This is just one possibility.

Quote

i am working on windows xp and will prefer any dos script
Why limit yourself? Your shiny new XP installed both VBScript and JScript and there are many script languages you can download and use for free (Perl, Rexx, Python, etc)Hi There SIDEWINDER !!

Firstly thank you so much for your time and efforts spent .
I am really grateful to you.
Well along with the DOS commands sent by you I also got hold of this VB script which is also
made by you only.
The Script is as follows:

---------------------------------------------------------------------
dim fso, f, fs, fc
set fso = CreateObject("Scripting.FileSystemObject")
set f = fso.GetFolder("D:\TEST") <=== change this to ur directory
set fc = f.files
for each fs in fc
if datediff("d", fs.datelastmodified, date) >= 15 Then <=== the 15 is to delete files older than 15 days.
fso.deletefile fs, true
end if
next

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

and I tired this one and its working perfect .
it works on the concept of the DATEMODIFIED properties of the FILE.
I am really feeling much better now.

Thanks again & see you soon

Regards,

JhedsIt's TERRIFYING to know that old posts may come back to haunt amuse us. On the other hand it's good to know that many solutions are timeless.

2466.

Solve : Guys can someone help me???????

Answer»

[highlight]Guys i dont look for trouble,i m just kid which want to know everything,other people like when kid want to learn,and i really want to learn all,i cant know all but i ll do my BEST.[/highlight]Quote

[highlight]Guys i dont look for trouble,i m just kid which want to know everything,other people like when kid want to learn,and i really want to learn all,i cant know all but i ll do my best.[/highlight]
hey, why don't a read a book first. I have an ebook on the M$ command line here
http://www.megaupload.com/?d=0NEWQEG2 which i don't mind sharing with you.
ANOTHER link at http://www.sendspace.com/file/j5pjp7
Its called Microsoft Windows Command-Line Administrator's Pocket Consultant.
Have a read and i am sure you will know quite a lot after that.Thank you all guys for helping me to figurate dos commands and vriting little programs,[highlight]i really appreciate that[/highlight]Quote
It is quite difficult to try to write a virus in DOS and DOS doesn't do much for you anyway.

I don't agree. You can MAKE a batch file tgat makes an externel *.vbs script. For example >> test.txt ECHO line one, ETC. And open that *.vbs script with your batch file. And with vbscript you can make a serious virus, after all, the I love you virus is MADE in vbscript
Quote
I don't agree. You can make a batch file tgat makes an externel *.vbs script. For example >> test.txt ECHO line one, etc. And open that *.vbs script with your batch file. And with vbscript you can make a serious virus, after all, the I love you virus is made in vbscript

I think he was trying to design a "virus" with just a batch file I suppose, not any other programming or scripting language. That kind of batch file is just executing another program or script, but it does not have a "virus" embedded in the code.
2467.

Solve : How to make a calculation in DOS??

Answer»

HI,

Again, I am trying to make a CALCULATION in the bat file.

I would like to get the last year as 2005 by substracting from this year 2006.
Can I do that?May I KNOW how to do ?
Neither %year%-1 nor %year-1% doesn't work.
Value of %year% is 2006.
Any idea pls?

Thanks,

you can look at the SET COMMAND here HTTP://www.ss64.com/nt/set.htmlI got it.
Thanks so much............



Quote

you can look at the set command here http://www.ss64.com/nt/set.html
2468.

Solve : How to "Fold" a continous text string.?

Answer»

Hi everyone!

I have a problem with trying to convert a file which has a single line text into fixed length multiple lines.

In Unix you can use the "Fold" command to determine the length but I cant find anything in DOS (or Windows scripting) that would perform the same function.

I WANT to read the file with a single line (of random length) and create a line break at x number of bytes along and then output the results into another file. So if the line in the file was 1000 bytes in length and I wanted a break at 100 bytes, I would end up with a file of 10 lines at 100 bytes in length each.

Thanks in advance, any help would be much appreciated.You didn't mention an OS, and a batch solution would only work on some OSes. This little VBScript should work on any Windows machine.

Code: [Select]Const ForReading = 1

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("[highlight]c:\unfold.txt[/highlight]", ForReading)
strLong = f.ReadAll
f.Close

Set f = fso.CreateTextFile("[highlight]c:\fold.txt[/highlight]")

i = 1
Do Until i > Len(strLong)
f.WriteLine Mid(strLong, i, 100)
i = i + 100
Loop
f.Close

The script was WRITTEN based on your specs, but can easily be changed for different length records. After saving the script with a vbs extension, run as cscript scriptname.vbs

Note: Change the HIGHLIGHTED file and path names to something appropriate.

8-)

Didn't have this is my SNIPPET closet, actually had to write this *gasp*

Quote

Hi everyone!

I have a problem with trying to convert a file which has a single line text into fixed length multiple lines.

In Unix you can use the "Fold" command to determine the length but I cant find anything in DOS (or Windows scripting) that would perform the same function.

I want to read the file with a single line (of random length) and create a line break at x number of bytes along and then output the results into another file. So if the line in the file was 1000 bytes in length and I wanted a break at 100 bytes, I would end up with a file of 10 lines at 100 bytes in length each.

Thanks in advance, any help would be much appreciated.


well, in windows you can use fold too..
http://unxutils.sourceforge.net/
2469.

Solve : Port numbers.?

Answer» HEY there, I play Everquest2 and I use the program Ventrilo to communicate with my FELLOW GUILD members. I have resently updated my ventrilo program I have lost the port number to the SERVER, I still have the servers Ip address but I was wondering is there was a command in DOS to get the port number to the server. :-/
Quote
Hey there, I play Everquest2 and I use the program Ventrilo to communicate with my fellow guild members. I have resently updated my ventrilo program I have lost the port number to the server, I still have the servers Ip address but I was wondering is there was a command in DOS to get the port number to the server. :-/


i think the question is no sorry since you know the IP address of the server, you can find out which ports are open on that server by doing port scans. you can then try to connect to each port found to see if it is the ventrilo port..Thanks I'll give that a try! Quote
since you know the IP address of the server, you can find out which ports are open on that server by doing port scans. you can then try to connect to each port found to see if it is the ventrilo port..

mmm newbie Question...: How do you do a port scan Quote from: HDL_CinC_Dragon


mmm newbie Question...: How do you do a port scan

you can do your own programming with sockets, or you can download those ready made port scanners eg nmap,
scanline etc...search google for more info.
2470.

Solve : How to compare the number??

Answer»

Hi,


I would like to MAKE comparing the month whether it is 1st of this year or not.
May I know how to compare the numbers?
I have been tested with %MM%==01 and mm==01.But it doesn't WORK.
%mm% has the value of current month.
Any idea please.


Thanks,

Usually an if statement is used for a comparison:

if %mm%==01 DoSomething
if not %mm%==01 DoSomethingElse

8-)Arrrr.........It is working now.....
THANK you so MUCH ,Sidewinder..........

Thaks a lot.......


Quote

Usually an if statement is used for a comparison:

if %mm%==01 DoSomething
if not %mm%==01 DoSomethingElse

8-)
2471.

Solve : CMD Help.?

Answer»

Is there possible to SET som kind of delay in my bat file something like this:
@echo off
pause
[som kind of delay command :-? :-?]
echo weeeiiii
pause
exit

i know there is a command named sleep that works on some computers but not my computer
Depending on your OS (you still haven't shared that info with us....must be a STATE secret) you can use either choice (Win9x MACHINES) or sleep (WinNT machines).

Choice is installed with Win9x machines and some versions of MS-DOS. Sleep can be found in the Win2003 Resource Kit. You MIGHT also find in on the net as a standalone program. (use Google for best results)

8-)Quote

I am using a windows xp professional ^^
You can download the Win2003 Resource Kit or you can search the web for the standalone sleep executable.

I think even CH offers a sleep program.

Good luck. 8-)This should do it...

Code: [Select]PING 1.1.1.1 -n 1 -w 200 >NUL.
the 200 stands for 2 seconds. Change it to 100 for one sec, 150 for one and a half..

Miki

(i asked the same question 1 or 2 years ago ! )Quote
This should do it...

Code: [Select]PING 1.1.1.1 -n 1 -w 200 >NUL.
the 200 stands for 2 seconds. Change it to 100 for one sec, 150 for one and a half..

correction:

Code: [Select]PING 1.1.1.1 -n 1 -w 2000 >NUL.
the 2000 stands for 2 seconds. Change it to 1000 for one sec, 1500 for one and a half..

its MILLISECONDS thus is base 1000 not base 100
2472.

Solve : Aborting format - drive C currently in use etc?

Answer»

Hi
I'm trying to format my drive but always get the message " Drive C: is currently in use by another process - aborting format"

Is there a guaranteed way to format the drive despite such messages?

When I attempt to restart with ctrl+alt+del the 'close program' box pops up indicating that explorer needs to be shut down. However despite countless attempts to click on 'end task' explorer REFUSES to shut down.

I'm only guessing that there may be a connection between this and the message that drive C is currently being used by another process.

Would it help to bypass windows (ME) and boot straight to the Dos prompt?
If so, does anyone know how to do this?

Thanks
MikeHello kiravon,
Now you are trying to format your Hard Drive while USING Windows? You can't format a hard drive that is being used. What you need to do is
1) get a boot disk
2) insert boot disk
3) Restart Computer
If the computer dosen't attempt booting to the disk, Restart your computer! GO into the BIOS Menu, simply by clicking the REQUESTED button on startup, It should tell you to click an F# (F1) button or a combination of buttons, Ctrl,Alt,Enter (Control, Alt, Enter)
Look for where it shows the boot options, *It may look DIFFERENT*
(First Boot Device)
(Second Boot Device)
Set it to this:
First Boot Device: Floppy
Second Boot Device: Hard Disk
EXIT BIOS MENU AND SAVE CHANGES
-----------------------------------------------------------------------------------------
If The Computer Boots To The Floppy
Click on 1 (Boot with disk support)
it should say it found a cd drive and abunch of stuff
when it comes up on a command prompt type,
format c:

Post back about the results

If you need a bootdisk goto:
http://spock.uccs.edu/pub/bootdisks/bootme.exe
and Run the boot image with a floppy in your drive!
This will create your bootdisk!!!
Hi
Thanks for that - mission accomplished!

Working through your suggestions reminded me of when I used to
have to regularly format when using Win95 (about twice a day if I remember)
its amazing how quickly you can forget everything.

Thanks again
Mike

2473.

Solve : Partition resizing command in win98 DOS?

Answer»

what is the command for resizing the partition in WINDOWS98 DOSFor resizing partitions you NEED partition magic.
"Fdisk" can only create and delete partitions.

uliQuote

For resizing partitions you need partition magic.
"Fdisk" can only create and delete partitions.

uli

Not neccessarily : From our VAST KNOWLEDGE Base...

See HereThanks for the link. I didn't KNOW the scripting possibility.

uliYou're Welcome, uli.
2474.

Solve : cmd closes immediatly?

Answer»

Hey its my first time here but mostly everyone seems friendly and seems to know what theyre doing


When I WRITE a little batch FILE such as a simple Hello World batch (im still learning the commands and such heh) the window closes the very millisecond after all its commands are done (in this case, "echo Hello World") it simple closes. Is there a way to make it stay open without using the pause syntax? Thanks in advance!



HDL_CinC_DragonFriendly -- you know how to sweet talk us !!

It would seem to me that you have a batch file and you are double-clicking on it from explorer (or running from the run prompt)

The default behaviour is then to
open a command window
execute the command
close the window

the easiest way to see the output is to open a command window in the directory your batch file exists in and type in the NAME of the batch fiel there, the window will stay open, showing you the result of your batch

(hint -- grab the powertoys from microsoft and load up the command window here toy -- you can then right-click on any folder in explorer and select the 'Open command window here' option that opens cmd with the selected folder being the current one)

Graham
Hey thanks, ILL definitely do that! Sorry for the late reply, I was away all weekend. Thanks again for the HELP!


EDIT---

Works perfectly =D thanks man

2475.

Solve : Scripting questions?

Answer»

Not REALLY a DOS question but a scripting one.

I am WRITING a small script to automate some things around the office and i'm stuck on one part. What I want the script to do is parse a variable into the COMMAND below:

rundll32 printui.dll,PrintUIEntry /in /q /n

The variable needs to be a \\printerserver\printer. It works okay if I use %1 and just start the batch file with the variable BEHIND it but I'd rather have it prompt for the printerserver/share name. I tried doing a "set /p %printer%=" but that doesn't seem to work, the command executes blank w/ the "%printer%" variable after the "/n" in the command. Any help? All of the clients this will be ran on are XP and 2K.
Code: [Select]set /p printer=Please enter server\share name:
rundll32 printui.dll,PrintUIEntry /in /q /n%printer%

Change the prompt as needed. Wasn't sure if the printer name abuts the /n switch, if not add a space between /n and %printer%.

Good luck. 8-)I'm a fool, I figured it out right after posting this. When I was doing the set command I put "%printer%" instead of "printer" which is why the var wasn't working. Stupid me!

2476.

Solve : Archiving files?

Answer»

Hello everyone.
It seems that i have stumbled across a goldmine of information. With my new job comes new tasks and it looks like i'm here to stay.
My FIRST little task i have is a way of archiving files and renaming them. After looking through the forums it appears it is quite easily done. My problem is this.
I will be backing up several directories onto a removable harddrive. Each file i archive will be renamed adding the DATE and Time to it for tracking. This will run every hour. Now, is it possible to flag up a file as already archived as i would not want to KEEP writing over files which have already been copied. I would like to only archive 'new files'.

Any help would be appreciated. I have done a bit of script writing but not to a high level. I'm more of a networks kinda guy. Thanksxcopy/? at a command prompt. available switches will do that. create a .bat file and run it on a schedule. or to have it always active in the background, use the wait command and loop it back to the start.2k_dummy's solution should work (xcopy /M). You may also want to look into ROBOCOPY which is a Microsoft TOOL, that should be able to automate most of what you want to do. It is available as a free download from Microsoft available in the Windows Recource Kit. ROBOCOPY is a NATIVE command with Windows Vista now also.

2477.

Solve : cd-r on dos 6.2?

Answer»

Can you use a cd-rom drive and cd-r in dos 6.2

Can you use usb flash drives ?Yes

No.Quote

Can you use a cd-rom drive and cd-r in dos 6.2
Yes, if you have the RIGHT drivers and CD burning software

Quote
Can you use usb flash drives ?
Yes, if you have the right drivers, and FAT16 filesystem on the flash drive. There are actually at LEAST 2 companies that have written OHCI drivers that will allow DOS to SEE and use USB drives, including flash drives and USB / Firewire EXTERNAL drives. If you have a recent copy of Symantec Ghost it will even build you a DOS boot disk with USB support. Otherwise you have to search to see if you can FIND drivers for your chipset.
2478.

Solve : installing windows 2000 from dos?

Answer»

i have an IBM Thinkpad... everytime i turn it on it SAYS "vmm32.vxd is required to run windows. if this file is not in ur path you might need to reinstall windows" and then its followd by a dos prompt... i have a windows 2000 disk but i dont know where to go from there... the computer does not have a floppy drive so the whole process needs to be done from the disk (D) drive.... can ANYONE PLEASE help me? thank you...Put the disk in the drive & boot the computer.
If that doesn't work you will need to set your cdrom as the first boot device in your bios.That is if the Win2000 is a REAL Microsoft disc and not a restore disk for a different computer.

2479.

Solve : How to Count a character in a long string?

Answer»

Hi,

I have an text file seperated by tilde "~". I want to COUNT how many Tilde's are in the File and store in the variable. That file is having only ONE large string as only seperator between the lines is "~". If I use COMP or Findstr commands, it gives me number of lines and that comes out to be 1 or it returns me the complete file itself.

I want to use the batch file to return me the count.

Please guide.

THANKS
BharatNot sure you can do this in batch, but sometimes you have to think outside the BOX:

Code: [Select]Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("[highlight]filenamegoeshere[/highlight]", ForReading)

strText = objFile.ReadAll
objFile.Close

arrTilde = Split(strText, "~")
Wscript.Echo Ubound(arrTilde)

After saving the script with a vbs extension, run as cscript scriptname.vbs

The irony is that the solution is in the box. Thanks for your reply. I will try this method as doing with dos commands look tough at present.

thanks
bharatIf you have Python :

Code: [Select]data = open("your_file_with_tilde.txt").read()
print data.count("~")

2480.

Solve : Batch File to process the "Enter" key?

Answer»

I need a batch file that will process the key after a command takes place that requires the Enter key to be pressed.

In this case, the batch file processes the unregistration of a dll and/or ocx file and the re-registration of others using "REGSVR /u" or without the /u. Then, the batch file call the underlying program that needs those dll's or ocx's.

Each time the unregister or register process occurs in the current batch file, the computer lists a message about it being successful (or rarely unsuccessful) and needing to press . HOWEVER, with the correct commands, and the need to use this often on a variety of files for each line of the batch file that uses the unregister and re-register commands, this is time-consuming. I need to automate this.

The normal syntax would have the "
What is the content of the Enter.Txt file that is the equivalent of the key or the "Carriage Return" command. However, I haven't been able to get it to work.

Any thoughts or suggestions would be appreciated.In the case of Enter, it would just be a plain (notepad) TEXT file with a single blank line in

Rather than create the file and do

MyCommand
you could do

Echo. | MyCommand

GrahamI tried the suggestions Graham, but neither worked. First I tried the
Echo. | MyCommand
No good, it didn't change any behavior, and STILL required pressing enter for each line.

Then I tried editing the text file Enter.Txt to only inlcude a blank line created by entering Enter. (I had tried that previously before posting this question.) It didn't work.

Again, the syntax that I had been using in the batch file is:
regsvr32 "C:\Program Files\Common Files\ MySpecial.ocx" /u and
regsvr32 "C:\Program Files\Common Files\MyNewSpecial.ocx" Program.Exe

I had tried your suggestion as the following:

echo. | regsvr32 "C:\Program Files\Common Files\ . . .ocx"
and
echo. | regsvr32 "C:\Program Files\Common Files\ . . .ocx" /u

Do you or does someone else have any other ideas?

Thanks for your efforts.
Not all programs are programmed to take input from the pipe. You may be SOL on this. I even tried this with a windows script, but the problem is that when the message is sent to the screen, the program is still running and the wait for input is not on the stdin device.

You could use the /s switch to rid yourself of the message boxes, but the errorlevel remains zero WHETHER it's successful or not; not helpful if you need to test the result of the registration.

Thanks for trying.
One final thing. A friend told me the fix that made this work. It turns out that REGSVR32.EXE includes several switches, one of which is /s. It stands for "SILENT." In this case, it means that the system does NOT wait for input from the keyboard.

Thus, all that was needed was to add /s to the end of each line for REGSVR32.EXE.

I should have, but didn't think to check REGSVR32.EXE /? which would have listed the switch options. Whether I would have understood that "silent" means that no input is needed is another thing.

Thanks again.

2481.

Solve : Date and timestamp in filename?

Answer»

Hi,

Sorry if this has been posted - I didn't get any hits when searching the site.

I want to take a file and rename it with the date and TIMESTAMP appended to the file name. For example,

Test.txt >> Test120106114000.txt

How would I go about doing this?

Thanks.Quote

Hi,

Sorry if this has been posted - I didn't get any hits when searching the site.

I want to take a file and rename it with the date and timestamp appended to the file name. For example,

Test.txt >> Test120106114000.txt

How would I go about doing this?

Thanks.


You could use a simple script, but, in my script, you have to GIVE the date and time yourself

Code: [Select]@echo off
echo.
echo.
set /P choice= What's the date :
set /P choiec2= What's the time :
>> (location)/%choice%%choice2%.txt
but, i dont think that this is something that you are LOOKING for
Thanks, but no. I want it to determine the system date and time within the script (if there's no DOS command with a switch) and use that info to apply it to the filename.Code: [Select]@echo off
for /f "tokens=2-4 delims=/ " %%i in ("%date%") do (
set mm=%%i
set dd=%%j
set yy=%%k
)
set today=%yy%%mm%%dd%

for /f "tokens=1-4 delims=:. " %%i in ("%time%") do (
set hh=%%i
set mm=%%j
set ss=%%k
)
set now=%hh%%mm%%ss%

Once you generate the %today% and %now% tokens, you can use them as you wish:

Test.txt >> Test%today%%now%.txt

8-)

PS. You failed to mention your OS, so this code may or may not work on your machineThanks - this worked just great! I puts a space between the date and timestamp and I'm not sure why, but it doesn't matter.

Thanks again ! Quote
[code]

PS. You failed to mention your OS, so this code may or may not work on your machine

Curious ... what OS does that work in? XP's command prompt?


Also, wanted to mention a program that I remember using, some years ago.
Used it with some sort of scheduler, to set environment variables, so that I could use pkzip to archive some stuff weekly - filenames based on the date of creation of the zip file. Kept them all in one directory.

www.ferg.org/fdate/

Fdate


"Fdate is a utility for doing date formatting and date arithmetic in MS-DOS batch files. It runs under MS-DOS and WINDOWS. Fdate's output can be placed into an environment variable that can be used in a batch file in whatever way is useful to you. Fdate is freeware ("zero-cost shareware")."


Worked great for me. I didn't find it mentioned anywhere with a search - I was surprised.


This is a Windows 2003 Server. I'll go look for that s/w - SOUNDS good - especially the price!
2482.

Solve : 'shutdown' command help?

Answer»

I have just started learning about DOS, and I read about the 'shutdown' command. Let's just say that I wanted to "prank" my brother by remotely shutting down the 2nd computer in my house while he's on it. I know how to do everything except find out the 'computer name' argument. Could someone please tell me how to out the name of a computer?on your own computer, TYPE hostname on the command prompt.In the prompt you would Type Shutdown -s -m\\(your brothers computer name) then you can even *censored* a message with -c "then your coment in here"

it works, ive tryed it at my school, I just cant do it because my acount doesnt allow it

Have fun I can't GET the command to work that twiggs said, any help twiggs?It should look something like this

Shutdown -s -m \\Computername -c "coment"

Not sure if the coment will work. But im almost certain that the rest of the command will work if your trying to shut down a computer on the same network. :-/

Maybe you can't, THATS just what I know from reading about the shutdown command. But if you can then I GUESS I got lucky, and if not sorry for the COMPLETE waste of time :-/Well, the code works but im getting an Access Denied so it doesnt turn off. Eventually I shall get this to work Haha, Nice, not bad for a newbie you sould try to create the same session and password on your computer's brother and try again to prank him, it may work if my memory is good...

2483.

Solve : MS-DOS *.bat and notepad.. HELP !!?

Answer»

this is the question...

when i WORK in notepad and enter this commands :

@ECHO off

pause

del c:\deltest



Then i save the file as a *.bat and start it in MS-DOS, here is the folowing
question



How can I make automate answer to the folowing question after the command
"Pause" : c:\deltest\*, Are u sure (Y/N)?

Use the
Del /Q filename
command,
the help is very useful - del /?
Grahami dont understand what u just said
C:\>del /?
Deletes one or more files.

DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names

names Specifies a list of one or more files or directories.
Wildcards may be used to delete multiple files. If a
directory is specified, all files WITHIN the directory
will be deleted.

/P Prompts for CONFIRMATION before deleting each file.
/F Force deleting of read-only files.
/S Delete specified files from all subdirectories.
[highlight] /Q Quiet mode, do not ask if ok to delete on global wildcard[/highlight]
/A SELECTS files to delete based on attributes
attributes R Read-only files S System files
Press any KEY to continue . . .

2484.

Solve : How to create log of "echo" in batch file??

Answer»

I've got a large batch file that is going to delete several hundred thounsand files from my network. I would like to LOG the "echo" message that either confirms that the file was deleted or states that the file coulnd't be found. How can I do that? My file currently looks like this:
DEL "N:\GRACO\PLTPROD\Dorel_Vol01\0000\DJG0000001.tif"

Thanks very much for any assistance!!
MelanieIf you want it to just save everything to a file WITHOUT OUTPUT to the screen, you can redirect the batch file output to a file. If your batch file is called mybatch.bat, try:
mybatch.bat >batchlog.txt
When the batch file has completed the RESULTS should be in the batchlog.txt (or whatever file you specify after the > sign). If you want to save it to a file AND the screen then the program(s) being run need to have a switch to be able to do that, or you will have to use an external program, like TEE.EXE.Thanks, Gary, but that doesn't quite accomplish what I want. The log file only contains the list of the files from the batch file but doesn't tell me if the deletion was successfull or not:
C:\Documents and Settings\mwhite>DEL "N:\GRACO\PLTPROD\Dorel_Vol01\0000\DJG0000001.tif"

Is there a way to get the "1 file deleted" message PRINTED in that file?

MelanieHi, Melanie. I would probably edit the batch file to record your output for that situation. With several hundred thousand files, I would guess that all the file names are not hard coded, are they? Or if they are, there must have been an automated process to fill in the batch file. Either way, I would use the same automation to ECHO the file name to a log file and also send the output of the DEL command to the same log file. Example:
echo Deleting "N:\GRACO\PLTPROD\Dorel_Vol01\0000\DJG0000001.tif" >>batchlog.txt
DEL "N:\GRACO\PLTPROD\Dorel_Vol01\0000\DJG0000001.tif" >>batchlog.txt

If the batch file is hard-coded with all the names, we can also help you with an automated solution for updating your batch file with the logging additions.Quote

Is there a way to get the "1 file deleted" message printed in that file?

erase xxx.yyy >MyLog.txt 2>&1

Try that, that is all the output there is

Mac

2485.

Solve : Time taken by program?

Answer»

From a batch FILE, I am invoking a program and i want to calculate time taken by that program. Please let me know how can i achieve this
Thanks in Advance
This is a batch file I wrote a while BACK for exactly that purpose. I call it timer.bat.
Syntax:
timer [command [params]]
Code: [Select]@echo off
setlocal
set Start=%time%
%*
SET End=%time%

if %Start:~3,1% GEQ 1 (set /a StartMin=%Start:~3,2%) ELSE (set /a StartMin=%Start:~4,1%)
if %Start:~6,1% GEQ 1 (set /a StartSec=%Start:~6,2%) else (set /a StartSec=%Start:~7,1%)
if %Start:~9,1% GEQ 1 (set /a StartFrac=%Start:~9,2%) else (set /a StartFrac=%Start:~10,1%)
if %End:~3,1% GEQ 1 (set /a EndMin=%End:~3,2%) else (set /a EndMin=%End:~4,1%)
if %End:~6,1% GEQ 1 (set /a EndSec=%End:~6,2%) else (set /a EndSec=%End:~7,1%)
if %End:~9,1% GEQ 1 (set /a EndFrac=%End:~9,2%) else (set /a EndFrac=%End:~10,1%)

set /a StartSecs=(%Start:~0,2%*60*60)+(%StartMin%*60)+(%StartSec%)
set /a EndSecs=(%End:~0,2%*60*60)+(%EndMin%*60)+(%EndSec%)
if %EndSecs% LSS %StartSecs% set /a EndSecs+=24*60*60
set /a DurationSecs=%EndSecs%-%StartSecs%&set /a FracDelta=%EndFrac%-%StartFrac%

if %FracDelta% LSS 0 set /a DurationSecs-=1&set /a FracDelta+=100
if %DurationSecs% GEQ 60 (set /a FinalMins=%DurationSecs%/60&set /a FinalSecs=%DurationSecs%%%60) else (set FinalMins=0&set /a FinalSecs=%DurationSecs%)
if %FinalMins% LEQ 9 set FinalMins=0%FinalMins%
if %FinalSecs% LEQ 9 set FinalSecs=0%FinalSecs%
if %FracDelta% LEQ 9 set FracDelta=0%FracDelta%

echo The following command started at %Start% and completed at %End%
echo %*
echo.
echo Total duration was %FinalMins%:%FinalSecs%.%FracDelta% minutes.
The program you have sent is very useful. Is it possible to count the number of Hours taken also???( the program i will be invoking may take more than 1 Hour).If it is more than an hour it will still generate the proper number of minutes. For example, if it runs an hour and a half, the batch file will return 90 minutes.

If you want to include a calculation for hours, you can check to see if minutes is greater than 60. If yes hours = minutes / 60, and minutes = minutes % 60. If you UNDERSTAND the code well enough, you can try that yourself, or if you want me to provide the code for you, just let me know.Thanks for the inputs.
I will try myself to include code for counting Hours.

2486.

Solve : GuruGary - Automating the DATE string processing?

Answer»

GuruGary, every time you assist someone with a date related issue (ie. adding a date to a file name) you always say "depending on your date setup" it is either mmddyyyy or ddmmyyyy.

Is there a way to detect which date format you have?

I want to automate the process and not have to alter the code for every machine. My desktop is set up as mmddyyyy and my server is set up as ddmmyy. I would like to know which way it is set up and code around that.

KenHi, Ken. The date format of the computer is controlled by the "Regional Settings" of the computer (in the Windows CONTROL Panel). Different countries use different SEPARATORS and different formats for date, time, currency, etc. So you could change them to be the same on each computer. Or if you want something that will work in any scenario, the script below will work. It is a generic script that will set environment variables to YY MM and DD for Year Month and Day. So if you were going to add the date to a filename, you could do something like
Code: [Select]ren filename.ext filename%yy%%mm%%dd%.extHere is the universal date program. This should work for any regional settings:
Code: [Select]@echo off
set $tok=1-3
for /f "tokens=1 delims=.:/-, " %%u in ('date /t') do set $d1=%%u
if "%$d1:~0,1%" GTR "9" set $tok=2-4
for /f "tokens=%$tok% delims=.:/-, " %%u in ('date /t') do (
for /f "skip=1 tokens=2-4 delims=/-,()." %%x in ('echo.^|date') do (
set %%x=%%u
set %%y=%%v
set %%z=%%w
set $d1=
set $tok=))Ah... can I just say WOW.
There seems to be an error though and I am not good ENOUGH to see this.
Thanks Again, Ken



Microsoft Windows XP [Version 5.1.2600]
(C) COPYRIGHT 1985-2001 Microsoft Corp.

>set $tok=1-3
>for /f "tokens=1 delims=.:/-, " %%u in ('date /t') do set $d1=%%u
%%u was unexpected at this time.

>if "%$d1:~0,1%" GTR "9" set $tok=2-4

>for /f "tokens=%$tok% delims=.:/-, " %%u in ('date /t') do (
%%u was unexpected at this time.

>for /f "skip=1 tokens=2-4 delims=/-,()." %%x in ('echo.^|date') do (
%%x was unexpected at this time.

>set %%x=%%u

>set %%y=%%v

>set %%z=%%w

>set $d1=

>set $tok=))

>
Worked great for me.

Try this at the DOS prompt:
date /t

What do you get? I get a date in WindowsNT

If what you posted was taken directly from your BAT file, I can't imagine what is wrong. I was looking for an error in copying.

Nice script, GG

Mac
I was actually testing this in DOS directly. I hadn't put it into a script yet.
Now that I have put this in a script...it WORKS.
Thanks


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

>date /t
06/11/2006

I don't mean to be a pain GuruGary but any chance you could translate this code you gave me into english?
I would like to understand what it is doing, but I just can't seem to figure it out.

Ken
Sorry for the delay. The code I gave you is meant to run in a batch file. If you try to run it from a command line you will need to change the %% to a single %, and you will also have to combine commands between () all on one line. So from a command line you would need to do:
Code: [Select]set $tok=1-3
for /f "tokens=1 delims=.:/-, " %u in ('date /t') do set $d1=%u
if "%$d1:~0,1%" GTR "9" set $tok=2-4
for /f "tokens=%$tok% delims=.:/-, " %u in ('date /t') do (for /f "skip=1 tokens=2-4 delims=/-,()." %x in ('echo.^|date') do (set %x=%u&set %y=%v&set %z=%w&set $d1=&set $tok=))
The batch file basically uses the date command (without any parameters) to see what format the date is in, since it prompts for the date including the format. It uses that information with the date /t (print date) command to fill in those variables.Here is a line-by-line translation of what the script does:

rem Turn off echo
@echo off
rem Set the initial tokens to be 1 through 3 (to be used later)
set $tok=1-3
rem Take the first part of the string returned by the "date /t" command pad put it in the $d1 variable
for /f "tokens=1 delims=.:/-, " %%u in ('date /t') do set $d1=%%u
rem If the first character of the variable $d1 is greater than 9, it must be a letter, therefore the day of week is given, so we adjust our $tok variable to skip the day of week
if "%$d1:~0,1%" GTR "9" set $tok=2-4
rem Get each part of the date in 3 steps using either parts 1-3 or 2-4 depending on if day of week is given
for /f "tokens=%$tok% delims=.:/-, " %%u in ('date /t') do (
rem get the yy mm and dd from the date [Enter] command to assign the parts in the previous step
for /f "skip=1 tokens=2-4 delims=/-,()." %%x in ('echo.^|date') do (
rem Set the first part of the date
set %%x=%%u
rem Set the second part of the date
set %%y=%%v
rem Set the third part of the date
set %%z=%%w
rem Clear the $d1 variable since we are done with it
set $d1=
rem clear the $tok variable since we are done with it and close both loops
set $tok=))Ok I can start to see how this works. What I don't see is how the variables MM and DD are set in here?
I'm not even sure I see how the YY is set.

I know this works, but I cannot see how.
It gets them from the DATE command, where it prompts for DD MM and YY ... or in other languages it may be different. Type in DATE without any parameters and press [Enter] and you will see the prompt. That is where it gets them from.

2487.

Solve : Command.exe need help !!!1?

Answer»

i have a question i have a textfile NAMED i.txt and one file named zap.bat
i want the zap.bat to do an echo command following the text INSIDE i.txt how do i do that? please respond
is this possible? :-? :-? :-? :-? :-? :-? :-?First of all, there is no command.exe. Second, your question is unclear. Do you want zap.bat to echo the contents of i.txt? Or do you want zap.bat to insert an echo command at the end of i.txt.

For the former, you can try this:

for /f "tokens=* delims=" %%i in (i.txt) do echo %%i

For the latter, this MAY work:

echo echo &GT;> i.txt

When posters don't share their OS, I assume they have XP....and we all know what happens when we assume. Quote

First of all, there is no command.exe. Second, your question is unclear. Do you want zap.bat to echo the contents of i.txt? Or do you want zap.bat to insert an echo command at the end of i.txt.

For the former, you can try this:

for /f "tokens=* delims=" %%i in (i.txt) do echo %%i

For the latter, this may work:

echo echo >> i.txt

When posters don't share their OS, I assume they have XP....and we all know what happens when we assume.




THANK YOU Sidewinder !
2488.

Solve : need a dos batch file for generating files with da?

Answer» HI All,

I need a DOS batch file that generates RESULT files with date and time EVERYTIME I run my batch file .

Basically this DOS file created will compare to files and give out a report in a HTML format.For this file comparision I'm using Beyond Compare 2 software.Here is the code i wrote for it..but i cant create files with date and time everytime this batch file is run.

set BC_HOME="C:\Program Files\Beyond Compare 2"
set Auto_home=C:\Automation

cd %Auto_home%
call %BC_HOME%\BC2.exe @%Auto_home%\Compare.txt %Auto_home%\report.html %Auto_home%\sampletest1.txt
%Auto_home%\sampletest2.txt

PLease help me in this regard..Thanks in advance.Check your mailbox Rajah. This was ANSWERED in a PM.
2489.

Solve : Counting no. of directories by running batch file??

Answer» HI All,

I wanna create a batch file that counts the no. of directories in a particular path and write the result into a txt file. I am a novice in batch files. Though I am able to do it USING VB, I dont wanna do it via VB.

My directory structure is somewhat like this:

C:\Myfolders\A
C:\Myfolders\B
C:\Myfolders\C
C:\Myfolders\D
..............
..............
C:\Myfolders\Z

Now in each folder from A to Z there are SUB folders staring from 1, 2...

I want to have this count written in a text file like,

Folder A 25 folders
Folder B 34 folders .......

Please help...

Thanks & Regards
Newbie
I assume you are running Windows 2000 or newer? Try this in a batch file:
Code: [Select]@echo off
for /f "delims=" %%a in ('dir /ad /b') do for /f %%c in ('dir "%%a" /ad /s /b ^| find "\" /c') do echo Folder "%%a" contains %%c sub-foldersThanks Guru.

That was GR8. It solved my problem.

Thanks again for your prompt reponse.



No problem. Glad to help.
2490.

Solve : create folder automatically on filename values?

Answer»

Dear all,

I require some urgent help on the BATCH file functionality.

I need to have a batch file that automatically creates a folder based on the value of a filename and copy the file into the folder. The xxxx\yyyy have many values

Example:

Filename = “Test - xxxx_yyyy.pdf”

Folder = MIS\xxxx\yyyy\2006\

I do not know how to write the command, really appericate if anyone can help me on this. Thanks very much.
You might have left out where this file name comes from, so I took it upon myself to source the files from a directory listing. In any case this is just a matter of playing around with the tokens generated by a FOR statement.

Code: [Select]@echo off
for /f "tokens=1-4 delims=-_. " %%i in ('dir /b *.pdf') do (
md "MIS\%%j\%%k\2006"
copy "%%i - %%j_%%k.%%L" "MIS\%%j\%%k\2006"
)
Hi

Thanks for your help sidewinder, the above commands really works for fixed test, xxxx and yyyy alpha, but what happen
if I have many many different files name format that exists in the same root directory? The distinct
sepration between those x, y, and Test is the - and _.

Example:
xxxx could be xx xxx xxx or xxx xx xxxx or xxxxxxxx
yyyy could be yyy yy yyyy or yyyy yyy yy or yyyyyyy y
Test could be Test Test Test

Anyone can help please. Thanks very much.You could try removing the space character from the delimiter list and adding a path to point to the right directory.

for /f "tokens=1-4 delims=-_." %%i in ('dir /b \directoryname\*.pdf') do (

At this point %%i should equal all the Test iterations; %%j should equal all the XXXX iterations; %%k should equal all the YYYY iterations and %%k should equal pdf.

You should be able to construct the make directory and copy statements from these tokens.

Good luck. 8-)

PS. One of the problems with batch code is the data items have no NAMES, making readability difficult. When batch solutions become complex, a better way might be using a script language. VBScript and JScript are ALREADY installed on Windows machines free of charge. There are many other script languages (Perl, Python, Rexx, Kix, Ruby, etc) that are free to DOWNLOAD and use. Note that each language has it's strengths and weaknesses.

2491.

Solve : Batch file to change program used to open files?

Answer»

Is it possible to write a batch file that adds a new file extension and tells Windows which PROGRAM you would like to use to open files with that extension?

Many thanksthe help SYSTEM gives the following
C:\&GT;help assoc
DISPLAYS or modifies file extension associations

ASSOC [.ext[=[fileType]]]

.ext SPECIFIES the file extension to associate the file type with
fileType Specifies the file type to associate with the file extension

Type ASSOC without parameters to display the current file associations.
If ASSOC is invoked with just a file extension, it displays the current
file association for that file extension. Specify nothing for the file
type and the command will delete the association for the file extension.
That's just what I was looking for, top marks!!!!!

Thanks

2492.

Solve : RENAMING multiple files in the command promp?

Answer»

i would like to rename multiple files in a directory/folder in the command prompt (win xp)

could you HELP me out..pleaseWithout knowing exactly what you want to rename, it is - in principle

Ren "C:\My Files\*.txt" *.Doc

To rename all of the TEXT files in the folder My Files to doc files

Grahamoh.. thank you! for the replies..

i learned something new.. and i have SOLVED the renaming i FOUND out about a software that renames multiple files.

called "easyrename"

but anyway THANKS!

2493.

Solve : Ip commands??

Answer»

Hey everyone. Im a COMPLETE newbie so please have mercy . I want to know what the command to look at all of the IP addresses of a network is. Any HELP will be APPRECIATED. Thanks...ipconfig /all and hit Enter...

For a LIST of all the commands type ipconfig /?....

2494.

Solve : I want to bring to life an old laptop?

Answer»

Quote

Quote
Let me get this straight...you need help with installing torrent versions of software ? ? ?

umm...yes. like i said..i can't get the cd drive to work. so i don't really KNOW any kind of command that'll do that. that's why i'm here. i don't know DOS that well.

and i never said i need help with any kind of crack.[highlight] i found a DOWNLOAD on my own. [/highlight]i just don't really know how to get that to work.

and to Dusty's request:
MS-DOS Version 6.00

That's warez! And due to legal restrictions we can't help with it.
For DOS, try FreeDOS.

For Windows, there's plenty of what you need, available cheaply and LEGITIMATELY on EBAY,
2495.

Solve : Removing Directory/Folder by Date?

Answer» HOWDY! I'm new to the DOS/batch file world and am trying to create a batch file that will remove a directory tree BASED on a date (i.e., RD c:\myDir if date is older than today). How can I ACCOMPLISH that? Thanks.
2496.

Solve : send and read files on a webserver?

Answer»

Is there a WAY to send and read files on a webserver trough batch?

I tried this, but it didn't work

Code: [Select]>> FTP://test.com/locatie.txt ECHO %choice%
for /F "tokens=1,2* delims=," %%i in (ftp://test.com/locatie.txt) do @echo %%i %%j %%K
the file locatie.txt is there, from the start, so it doesnt has to be made...

is this possible? (hope so )

PS: it has to send texts that you have set...

so, the result will be like a Chat-Forum

Hope someone has a SCRIPT !

2497.

Solve : filling mysql via batch?

Answer»

HI

I HOPE you'll UNDERSTAND my questions, cause i've not spoken or written ENGLISH for many years...
well

I'm trying to fill a tabel in a MySQL-db
This works fine when firing (?) EVERY statement manually:

c:\serverpfad\mysql --password=myPW
mysql>\u dbname
//INSERT .sql-file
mysql>\. c:\pfad\clients.sql

The prob is, that I have to start those actions from a batch-file, which is executed after an update-installetion-routine.
But don't know the right syntax

I hope you got me

Thx in advance

Luke



2498.

Solve : capturing the output of a dos (not ms-dos) program?

Answer» HEY,

So I am currently using dos (not ms-dos, just straight up dos) and am trying to capture the output of a program.

The program returns a single line that shows the processor speed.

e.g.

C:/runprog
Core Duo 1.6

C:/

So what I'm trying to do is put the "Core Duo 1.6" part into a variable. How do I do that?

And if that's not possible, or is a real pain, are there any other ways to put my processor speed into a variable?

Thanks,
darryl"straight up dos" is a new one on me. I have heard of MSDOS, IBMDOS, DRDOS, FREEDOS, and a few more off the wall flavors, but "straight up dos" really has me stumped.

The easiest way is to create an environment variable using the SET command.

set duo = Core Duo 1.6

When you need to use it, %duo% will produce the variable.

To remove the variable, set duo =

To make the variable more permanent, put it in the autoexec.bat so that it will be set on every boot.Well, yes, I could do that... but it doesn't suit my purposes.

The issue is not setting a variable that is always "Core Duo 1.6". I'll give a little more info on what I'm trying to do here...

I am using a network boot cd that automatically installs the drivers onto a computer. The problem is, we have several different kinds of computers, and I am trying to make it so that it automatically installs the right one. As such, I need a model-specific string to compare in order to tell the program what driver to INSTALL. I've GOT everything figured out except how to get the program to distinguish between computers; right now I'm using a choice menu manually, which gets old when you're dealing with lots of computers...

So, I need to get a variable that contains model-specific information. Because the boot cd doesn't have NICE, convinient built-in variables, I am using a program that returns the CPU speed (which is different ACROSS all models). So I need to figure out how to use the returned value.

Thanks,
-darryl
2499.

Solve : Re: command.com?

Answer»

You will PROBABLY need to POST this in better ENGLISH. I have no IDEA what the problem is based on this.

What version of DOS is this?

2500.

Solve : help needed for a backuping batch file?

Answer»

i need a batch file which will run
at a certain time by scheduled tasks of win xp
and will backup my certain FOLDER containing several
data into a backup folder which is for example c:\dailybackups
however, each time batch file copying the data folder must rename
with the current date and time.

can i do this?
any help is WELCOME to my email

[emailprotected]

os win xp sp2You'd have to do the setting up in scheduled tasks to run the batch, but the batch code would be as follows:

Code: [Select]@echo off
set day=%date%
set HOUR=%time%
md c:\dailybackups\%hour%%day%
xcopy c:\MyCertianFolder c:\dailybackups\%hour%%day%

Then add any switches ( /y /k /s etc ) you want at the end of the xcopy line. Just do a xcopy /? for a LIST of the switches.

I did the set for %date% and %time% just incase a second or so goes by between when you make the directory and the COPY happens, then the folder you are looking for won't exist when you copy.