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.

6651.

Solve : Crystal Report?

Answer»

How can I display the last record in the perticular field into the crystal report. I have only FORMULA which is write the formula EDITOR in crystal report.

If any one KNOW it. PLZ. GIVE me the reply.

6652.

Solve : Batch game help?

Answer»

I'm working on a batch came thats manly text like say:

You come to a wall there is a small came
go through the cave? =a
go back =b

only its based on Halo but I cant get it to WORK

Code: [Select]@echo off
echo Halo: Combat Evolved
echo.
echo *******************************************************************************
echo.
echo.
echo o##o ."";. .'@%; .,0000O'. .;'"Oo""oOOO%";.
echo ##o .###" .""O##%; '000O 'o;. .;O#@"
echo ###@OOOOOO###" ,;"[emailprotected]###O, '000O oO. ,O;. ,###';
echo ###O .###" ,o##%, "@##o, '000O . .;"@#@o
echo "@##@", ."o '[emailprotected]#@O; ,%@##";, ;"00000000000 ;oOoOO%@#@%o'.
echo.
echo.
echo The Low RAM version
echo Bungi Gearbox Microsoft Comsi
echo.
echo Game Set to "easy"
set /p co="player code=""
if co= new goto: new

:new
cls
echo.
echo __________________________________________
echo / \
echo / \
echo | |
echo |----------------------------------------------|
echo | |
echo | |
echo | |
echo | |
echo |______________________________________________|
echo |________________________________________ |
echo | | |
echo \ | |
echo \ | |
echo | | |
echo | | |
echo | | |
echo /______________________________________| |
echo /_____________________________________________|
echo |\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\|
echo |----------------------------------------------|
echo | |
echo | |
echo |______________________________________________|
echo | |
echo \ ______ /
echo \ \ / /
echo | \ / |
echo | \/ |
echo |_________________________________________|
echo
echo you come to a hall way, go wich way? L or R
set /p co=" "
if co= R goto 2
if co= L goto 3

:2
cls
echo ________________________________________________
echo | |
echo / \
echo / \
echo/ \
echo| |
echo| ______________________ |
echo| / \ |
echo| | | |
echo| | | |
echo| | | |
echo| | | |
echo| | | |
echo| | | |
echo| | | |
echo|___ | | |
echo|____ \ \ / ____|
echo| \ \________________________________________ / |
echo| \_________________________________________/ |
echo| |
echo| |
echo \ /
echo \ /
echo \________________________________________________/
echo you come to a branch, go across or keep going down the hall? K or T
set /p co="k= keep going T go through"
if co= k goto 4
if co= T goto 5

:3
cls
echo ______________________________________________________
echo | |
echo | |\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\| |
echo | | | | | | |
echo | / | | | \ |
echo | / | | | \ |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | | / / | | |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | | \ \ | | |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | \ | | | / |
echo | \ | | | / |
echo |_______________________________________________________
echo door locked press any key to go back
Pause
goto new

:4
cls
echo ______________________________________________________
echo | |
echo | |\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\| |
echo | | | | | | |
echo | / | | | \ |
echo | / | | | \ |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | | / / | | |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | | \ \ | | |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | | | | | | |
echo | \ | | | / |
echo | \ | | | / |
echo |_______________________________________________________
echo door locked press any key to go back
Pause
goto 2
Here what I got.
(I have vista)
COPY it to notepad it looks better.Quote

if co= new goto: new

variables have percent signs around them when you want to use their values

you use quotes in if tests

and double equals signs

you don't use the colon when using the label in a goto

if "%co%"=="new" goto new
It still dosent work I dont know why.
It's all those....vertical lines. (I've forgotten what they're called).

You cannot simply have '|'. It needs to be '^|'

Try it for yourself.

Go to Command Prompt and type 'echo |' and press Enter
Then type 'echo ^|' and press Enter.Pipes.Oh, pipes? Really? Ok.Yes pipes. What's the problem with that?

here is the output of of type being piped (twice) to find:

type animal.txt | find "lion" | find /v "sealion"

Quote from: Dias de VERANO on December 12, 2008, 12:17:20 AM
Yes pipes. What's the problem with that?



What's wrong with the pipes? They're not leaking, are they?Yes, the '|'s are the problem, and yes they are pipes, and no they are not leaky. or as some disallusioned players of mario BROTHERS will try to contend, as they do on the game, that they are not "pipes" but rather "tubes"... a somewhat odd theory that will still officially correct is only so because of the basic tenement that a pipe is, by definition, a metal tube. However, calling the mario brothers pipes "tubes" is like calling a pop can a "pop cylinder".

That was weird; it went from the pipe character to a rant about the misuse of the word tube in mario brothers vernacular. Oh well.
6653.

Solve : shortcuts?

Answer»

How do i change the directory (not sure if thats what its called) of a shortcut? So what i mean by the directory is what happens when you click on the shortcut. thanksQuote from: davisw on April 24, 2007, 02:15:21 PM

How do i change the directory (not sure if thats what its called) of a shortcut? So what i mean by the directory is what happens when you click on the shortcut. thanks

And I'm not sure of what you meaning to ask.

But perhaps you'll be on the right track to your solution, if you look around in the Properties of the shortcut.

You forgot to say what operating system this is in reference to.... is it WinXP? ... or....?


With older versions of Windows, you can right click on a shortcut, and get a pop up menu. Then click on Properties. Have a look around in there.
On my system, there are entries for the Target directory, and for the 'Start in' directory. Maybe one of these is what you are looking for.


I HOPE this HELPS.

6654.

Solve : Batch File Question - "Set" Command?

Answer»

Can you use the "set" command inside of another "set" command? In my batch file, I've got a list of file names at the top which are intended to trickle down into the processes below, so that it eliminates the need to type them all twice (as they may change often). However, it keeps pulling only the first one out of nine in the final result.

For the final %mapname% variables, it doesn't seem to bring the user's choice into PLAY. It just uses "level1.map".

BTW...yes I am a noob with writing batch files, so if something doesn't look quite right, that's why.

Any thoughts?

Here's my code:
Code: [Select]:Duke Nukem 3D Batch File
:Written by Dez

@echo off

:Below are the map choices. Please change the values to
:coorespond with the actual map names.

set map1=Level1.map
set map2=Level2.map
set map3=Level3.map
set map4=Level4.map
set map5=Level5.map
set map6=Level6.map
set map7=Level7.map
set map8=Level8.map
set map9=Level9.map

cls
ECHO.Duke Nukem 3D Multiplayer Game Launcher
ECHO.Batch File Coded by DeZ
ECHO.


ECHO.
ECHO.
ECHO.Please select a map from the following:
ECHO.
ECHO. 1. %map1%
ECHO. 2. %map2%
ECHO. 3. %map3%
ECHO. 4. %map4%
ECHO. 5. %map5%
ECHO. 6. %map6%
ECHO. 7. %map7%
ECHO. 8. %map8%
ECHO. 9. %map9%

ECHO.
choice /c:123456789 /n Enter the number of your choice:
ECHO.
if errorlevel ==9 set mapname=%map9%
if errorlevel ==8 set mapname=%map8%
if errorlevel ==7 set mapname=%map7%
if errorlevel ==6 set mapname=%map6%
if errorlevel ==5 set mapname=%map5%
if errorlevel ==4 set mapname=%map4%
if errorlevel ==3 set mapname=%map3%
if errorlevel ==2 set mapname=%map2%
if errorlevel ==1 set mapname=%map1%

choice /n Are you the host (Y,N)?
ECHO.
if errorlevel ==2 goto client
if errorlevel ==1 goto host


:client
set /p ip=Host's IP Address?
ECHO.

@ECHO ON
duke3d.exe -map %mapname% /net /n0 %ip%
@ECHO OFF

goto end


:host
@ECHO ON
duke3d.exe -map %mapname% /net /n0
@ECHO OFF

:end
I think you have got the errorlevel checking a bit wrong.

It's not

if errorlevel ==1 (do something)

You don't need the double equals signs. "Errorlevel" is not a variable, and if it were it would have percent signs before and after.

It's

if errorlevel 1 (do something)

See here

http://www.google.co.uk/search?source=ig&hl=en&q=if+errorlevel+1&meta=&aq=t&oq=if+error



Contrex: Understood. I have now removed the "==" from the errorlevel checking, and my script still works...but it still doesn't report back the correct user choice. It's still pulling "level1.map" for some reason.

Thanks just the same though...

*Edit* - I just thought I'd add that I'm really WONDERING if the set command can be used the way I have. It basically has to lookup two values. For example, if the user chooses map 3, then when it sends the final command, it first has to lookup %mapname% to see that it's referencing %map3%, and then back to %map3% which is referencing level3.map. I'm just wondering if it even allows multiple uses like that.When you are checking the errorlevel, you have to jump out when you hit the right one otherwise the batch will just go down to the lowest one and that will be the result.

Code: [Select]:Duke Nukem 3D Batch File
:Written by Dez

@echo off

:Below are the map choices. Please change the values to
:coorespond with the actual map names.

set map1=Level1.map
set map2=Level2.map
set map3=Level3.map
set map4=Level4.map
set map5=Level5.map
set map6=Level6.map
set map7=Level7.map
set map8=Level8.map
set map9=Level9.map

cls
ECHO.Duke Nukem 3D Multiplayer Game Launcher
ECHO.Batch File Coded by DeZ
ECHO.


ECHO.
ECHO.
ECHO.Please select a map from the following:
ECHO.
ECHO. 1. %map1%
ECHO. 2. %map2%
ECHO. 3. %map3%
ECHO. 4. %map4%
ECHO. 5. %map5%
ECHO. 6. %map6%
ECHO. 7. %map7%
ECHO. 8. %map8%
ECHO. 9. %map9%

ECHO.
choice /c:123456789 /n Enter the number of your choice:
ECHO.
if errorlevel 9 goto map9
if errorlevel 8 goto map8
if errorlevel 7 goto map7
if errorlevel 6 goto map6
if errorlevel 5 goto map5
if errorlevel 4 goto map4
if errorlevel 3 goto map3
if errorlevel 2 goto map2
if errorlevel 1 goto map1


:map9
set mapname=%map9%
goto next

:map8
set mapname=%map8%
goto next

:map7
set mapname=%map7%
goto next

:map6
set mapname=%map6%
goto next

:map5
set mapname=%map5%
goto next

:map4
set mapname=%map4%
goto next

:map3
set mapname=%map3%
goto next

:map2
set mapname=%map2%
goto next

:map1
set mapname=%map1%
goto next

:next

choice /n Are you the host (Y,N)?
ECHO.
if errorlevel 2 goto client
if errorlevel 1 goto host


:client
set /p ip=Host's IP Address?
ECHO.

@ECHO ON
duke3d.exe -map %mapname% /net /n0 %ip%
@ECHO OFF

goto end


:host
@ECHO ON
duke3d.exe -map %mapname% /net /n0
@ECHO OFF

:end

Contrex: That worked just fine. Thanks for your help! I think I was just trying to be a little bit lazy and combine some steps. I was just under the assumption that once it found the MATCHING user choice, it would stop there.

Thanks again!did you see I edited my post? Seems to work OK
I do now, and in fact your code now looks virtually identical to mine.

Thanks again.

6655.

Solve : Batch File Help Please (resolved)?

Answer»

I'm trying to create a batch file to start Punkbuster(an anti cheating software) for a game and exit it when it finished but the game never starts so it just goes to the shutting down PB

This is what i have
http://pastebin.com/d188cb664

I use one i got of the internet for another game that USES punkbuster as WELL:
http://pastebin.com/m36c645ef

*Edit: Also i am useing Windows XP

*edit2: i found a work around. just create 2 different batch files. 1 to start and 1 to stopCode: [Select]@echo off
:: set punkbuster services to auto
sc config PnkBstrA binpath= "c:\windows\system32\PnkBstrA.exe" start= "auto"
sc config PnkBstrB binpath= "c:\windows\system32\PnkBstrB.exe" start= "auto"

:: start the punkbuster services
sc start PnkBstrA
sc start PnkBstrB

:: start BF1942
start /wait "C:\Program Files\EA GAMES\Battlefield 1942\BF1942.exe" /restart 1

:: after BF closes stop punkbuster services
sc stop PnkBstrA
sc stop PnkBstrB

:: RESET status of punkbuster services to disabled
sc config PnkBstrA binpath= "c:\windows\system32\PnkBstrA.exe" start= "disabled"
sc config PnkBstrB binpath= "c:\windows\system32\PnkBstrB.exe" start= "disabled"

Quote

I'm trying to create a batch file to start Punkbuster(an anti cheating software) for a game and exit it when it finished but the game never starts so it just goes to the shutting down PB

Logically, there doesn't seem to be a problem with your code. Why doesn't the game start? Any error messages? Are you sure /restart 1 is correct?

restart 1 is a command line so it DOESNT show the movies in the begining. It says its not RIGHT. should it be /+restart 1 since it was + for the command?
Also i says it couldnt start pb for some reasonQuote
but the game never starts so it just goes to the shutting down PB

Quote
Also i says it couldnt start pb for some reason

So the bottom line is nothing in the batch file works. Change the @echo off to @echo on in your batch file. That may give you some clues what's wrong or post the console list so we can see what's going on.

Did you need to modify your firewall to let Punkbuster through?



6656.

Solve : Echo at location...?

Answer»

Win XP H.

Is there a batch program command which will allow Echo to display information on a specific line and location on that line?

e.g. Echo 12,15 %date% would display the %date% env variable starting on line 12 position 15.

ThanksNot easily using built-in. (see thread about ANSI.SYS) Addon programs can do this, like Extra Echo by Claus Juergen

http://www.claus-juergen-claussen.de/htmls/xe_e.html
Quote from: Dias de verano

You don't get ansi SUPPORT in NT family command PROMPT under cmd.exe. But it is available under command.com. This may or may not be good NEWS!

Definitely not good news. Will have a look at XE.

Thanks again.
6657.

Solve : Acces denied in XP, changable in DOS??

Answer»

Hello all,

I seem to have an access problem with an old windows FOLDER, let me try to make it clear what occurred.

I installed XP on a new PC, that worked for a while until a power failure.
Installed XP again, under a new name, so there where actually 2 installations on one DISK.
I thought i could easily delete the folders from the first, but doesn't work.

Allready figured out that its possible to change the name of a folder in DOS so it isn't blocked anymore in XP.

Only thing now is how to do this? An extra problem is that the name of that folder contains a space EG: S B
I hope that one of you KNOWS the right commands in DOS to do this and that he/she can type this out for me.

Your help will be appreciated!I presume when you mention DOS, you're referring to the NT command prompt.

Quote

An extra problem is that the name of that folder contains a space

Place quotes around the file/folder name.

Quote
I installed XP on a new PC, that worked for a while until a power failure.
Installed XP again, under a new name, so there where actually 2 installations on one disk.
I thought i could easily delete the folders from the first, but doesn't work.

I suspect one installation will have to take ownership of the files owned by the other installation. This may help.

Good luck. Yes!

Thank you for the fast reply, after turning of 'simple file sharing' i got acces to the security tab mentioned in the ARTICLE you linked to.
After that the rest was like scratching my nose.

You just saved me 5 GB of disk space and some important files!

Thank you!
6658.

Solve : select a filepath in dos?

Answer»

Does anyone know how to BRING up the contents of a valid file path in DOS.

I am being told to do the following:

Change into the directory, in which you stored the two files, e.g. C:/Puppy. Enter these commands:
c:
cd \
cd puppy
dir *.*


In place of c:, I'm guessing they want the FULL file path of my files. The DOS reader defaults to:

C:\Documents and Settings\Tim K>

When I put in the full file path it's not recognised as a batch file etc.

I've attached the file path of the Linux app (this has got to surely be something very basic!):

http://www.puppylinux.org/manuals/puppy-40/english/how-get-puppy

N.B. I've unzipped the files, so all the files (35 of them) are on the c drive.

Quote

In place of c:, I'm guessing they want the full file path of my files.

to cd to a folder which has spaces in the path name ENCLOSE it in quotes thus

CD "C:\Path to files\folder"

Quote
N.B. I've unzipped the files, so all the files (35 of them) are on the c drive.

You should not have done that. You need 2 files: (1) an .iso file. This is a CD image. You burn it to a CD. (2) a .txt file. This contains the md5 checksum for the iso file.

6659.

Solve : need help making a simple program?

Answer»

I am trying to make a small program (.exe would be great) to close a program. My goal is to create a way to close a program called vkt.exe by running this program. The reason I need this is because the only way to close the program is to right click it in the SYSTEM tray, however for my application I have access to the entire windows desktop closed off.

The program that I am starting vkt.exe through only has the ability to start a external program but no way to stop one. THEREFORE I need a way to close vkt.exe through starting another program (this programs only PURPOSE is to close vkt.exe and then close itself).

Any help anyone can give me would be most useful.you could make a BATCH file to close the program a .bat i dont know if this would work for your situation though could you run a .bat file also if you press alt+tab you should return to the desktop or if you press windows key+M then you could access the system tray it would be helpfull to know what operating system you are using.
I am using windows NT 4.0 on this computer. the main program is designed so that you cannot access the windows desktop at all for security reasons. What I am trying to do is add a button to this program to bring up an onscreen keyboard program (vkt.exe) when clicked. However the main program can only open external programs and not close them, and vkt.exe doesnt have an "x" button, thus the only way to close it is via the system tray, but I don't have access to that.

What I was hoping to do is find a way to make a simple little program run through the DOS prompt that will end vkt.exe and then end itself. That way I can toggle this button I want to add to open vkt.exe when PRESSED down (value=1) and when you click it again or depress it (value=0) it will run the program to end vkt.exe.

Thank you,
Daveys93I'm sorry but my programing experience is VERY limited and i don't think I can help

6660.

Solve : Batch file to fill disk??

Answer»

Is it possible to create a batch file that will fill up all of the unused disk space on a hard drive? If the files could occupy one folder too that would be optimal. Code: [Select]@echo off
for /l %%x in (1,1,10) do (
for /f "tokens=* delims=" %%a in ('dir c:\temp /s /b') do (
copy %%a %%a_%%x
)
)

Started with a single 211KB file in the temp directory. After only 10 iterations, had 1024 files and 216MB. IMAGINE what you can do with 100 or 1000 iterations.

Hey thanks, I tried your script out and it works perfectly.

Now I'd like to understand what the script is doing exactly, can you walk me through each line a little and summarize what is happening?

I'm doing /? for each command but it's getting a little overwhelming trying to figure out all of what's happening.

I'm only used to creating really simple batch scripts... The first for varies %%x from 1 to 10 incrementing by 1. This is strictly used as a counter and limits the number of iterations.

The second for get a list of all the files in the c:\temp directory and copies each one back to the same directory appending the value of %%x to keep each file NAME unique.

Basically, each time %%x in incremented, the number of files in c:\temp doubles. Do this ENOUGH times and geometric progression should fill up a 250GB disk in no time.

Hint: If the initial file is extremely large, the time to fill the disk is reduced.



Wouldn't a format be easier?Quote from: Sidewinder on April 22, 2007, 05:09:57 PM

The first for varies %%x from 1 to 10 incrementing by 1. This is strictly used as a counter and limits the number of iterations.

The second for get a list of all the files in the c:\temp directory and copies each one back to the same directory appending the value of %%x to keep each file name unique.

Basically, each time %%x in incremented, the number of files in c:\temp doubles. Do this enough times and geometric progression should fill up a 250GB disk in no time.

Hint: If the initial file is extremely large, the time to fill the disk is reduced.



Wouldn't a format be easier?

Thanks,

Yes, as would using dban or eraser. I just thought having a batch file do something similar would be interesting. Though the missing randomness might somewhat negate the effect.

How can I change the path in ('dir c:\temp\ /s /b') to C:\Documents and Settings\username\Desktop\temp\

Everything I try seems to screw up the syntax.

Also, I did /? for tokens and delims but I'm still having trouble understanding what they're all about... can you point me to a good place that can break tokens and delims down into simpleton terms?

You need quotes when using values with embedded spaces:

"C:\Documents and Settings\username\Desktop\temp\"

This Site seems as good as any for explaining how a for works.

Good luck. Code: [Select]@echo off
for /l %%x in (1,1,10) do (
for /f "tokens=* delims=" %%a in ('dir "C:\Documents and Settings\username\Desktop\temp\" /s /b') do (
copy %%a %%a_%%x
)
)

I get "the system cannot find the path specified" when I run that. I have a folder named temp on my desktop and it has a file in it. I suspect username is not really your user name:

Code: [Select]@echo off
for /l %%x in (1,1,10) do (
for /f "tokens=* delims=" %%a in ('dir "C:\Documents and Settings\%username%\Desktop\temp\" /s /b') do (
copy %%a %%a_%%x
)
)

I have no idea if the path is CORRECT but at least the syntax is. Right, mine is actually "comp". I have the path absolutely correct, it just doesn't like that path for some reason. Oh well, it RUNS fine from C:\path\

6661.

Solve : "Cannot move multiple files to a single file."?

Answer»

When I execute the command:
move *.* ..\test\test1\

I get the message:
Cannot move multiple files to a single file.

Can anyone please help me out with this? It is rather frustrating...The directory ..\test\test1\ must exist. Move does not make new directories.

It does: I'm moving the contents of testy1 (a subdirectory within test1) to test1.Quote

moving the contents of testy1 (a subdirectory within test1) to test1.

Move didn't make a new directory. It moved the contents of one directory to another. I guess I worded that kinda funny, when I said Quote
It does: I'm moving the contents of testy1 (a subdirectory within test1) to test1.
, I meant the directory does exist, not that the command does make directories, because it doesn't. Does that clear that up? Does does even look or sound like a word anymore, because it doesn't to me...You can rename a directory with move:

move testy1 testy2

Yeah, it says that when you type help move. The message is the part that has me confused.

Anybody have any ideas? (If I'm completely missing the POINT, please make me feel like an idiot )I think you're confoozlicating yourself with all these oh-so-similar folder names.

Quote
I'm moving the contents of testy1 (a subdirectory within test1) to test1.

So when you're going from testy1 to test1, you're going from one directory to its parent directory, you're going up one level. (Look at what you wrote.)

This is what you have described as the relationship between the folders testy1 and test1



The command you said you used was this

Quote
move *.* ..\test\test1\

If executed from testy1, as you have written, the two dots take you up one level, to test1, then into a subdirectory of test1 called "test" (Huh?) then to a subdirectory of that called test1.

That's DIFFERENT from what you said about testy1 being a subdirectory within test1!

I just tried it and this is what i got

Code: [Select]
I:\test1\testy1>move *.* ..\test\test1\
Cannot move multiple files to a single file.

I:\test1\testy1>

To move everything from a folder to the one directly above, which is what you said you want to do, you do this

move *.* ..

Like this

Code: [Select]I:\test1\testy1>move *.* ..
I:\test1\testy1\image001.jpg
I:\test1\testy1\image002.jpg
I:\test1\testy1\image003.jpg
I:\test1\testy1\image004.jpg
I:\test1\testy1\image005.jpg

I just peeked and they are there, in test1.




Thanks, I'll give that a try. The reason for the CONFUSING names (you confused me with your recount ) is that I was completing an exercise for a class I'm currently enrolled in. The publishers of the exercise weren't very creative...

Thanks for the help, it WORKED. I think you were right when you said I was "confoozlicating" myself with the names, I felt like smashing my head off my keyboard while READING your post .
6662.

Solve : How do I convert from DOS of .img to .iso??

Answer»

How do I convert .img to .iso? These are MS-DOS 6.22. I tried following a guide for MagicISO. It didn't work. How do I use WinImage? I have the free one. Will someone please explain how I do it?Try IMGBurn; not sure of it's conversion capabilities, though.Where did you GET these .img's?

If you're doing what I think you're doing, trying to install MS DOS 6.22, it doesn't work like that.
As FAR as I know, you cannot install it with CD's.Quote from: BC_Programmer on December 13, 2008, 05:45:36 PM

Try IMGBurn; not sure of it's conversion capabilities, though.

How do I use IMGBurn?

Hmm, if it won't work for CD's then why did my other CD's work for me? I would like for the last poster to explain.Firstly, where did you get these .img FILES?Why won't you HELP me with IMGBurn? Fine, then do you have a forum to help? If you don't help then I will post on the official IMGBurn forums.Then I guess you obtained MS DOS 6.22 illegally then.....in which case, we cannot help you.There are different KINDS of img file. Not all are CD images.
6663.

Solve : Multiple Check?

Answer»

Okay, say I have a variable, it is a number.
How WOULD I check to see if it is divisible by 4, or by any other number.
Also, how would I create variables that are multiples of 4, or any other number. For instance %random%*4 may not be fully divisible by 4 and may be 4.1232424, which is not correct.

This is for HELP WITHIN a key generator, Say a customer has the key 8-16-4-12-24. They are all divisible by 4, so it returns true, just as an example. How would I produce a series of 5 numbers that are multiples of 4 and then check to see if they divisible by 4.
Thanks for your help.Wow, I think I have done it.
Take a look at this CODE, this file gets a random number, keeps taking away 4, if it ever gets to the number 4, it means that the number can be divided by 4 and therefore echos it. If it does not get to exactly 4 then it starts again with a new random number.
Code: [Select]@echo off
echo Creating Key...
:start
set key=%random%
set start=%key%
:divide
set /a key=%key%-4
If %key% LSS 1 (goto start)
If %key% NEQ 4 (goto divide)
If %key% EQU 4 (
echo %start% is divisible by 4.
pause >nul
)

yea it works Quote from: Jacob on December 14, 2008, 07:53:43 AM

Okay, say I have a variable, it is a number.
How would I check to see if it is divisible by 4, or by any other number.

Another way is to use the modulus operator which is two percent signs in a batch or one at the prompt

N modulus M means "the remainder left over after N is divided by M" and is zero if N can be divided exactly by M.

It is usually abbreviated to N mod M.

Thus:

17 mod 4 = 1

and

16 mod 4 = 0

(Any number) mod (4) will equal 0, 1, 2, or 3 at most, obviously.

Code: [Select]@echo off

:loop

set /a number=%random%

echo random number=%number%

set /a remainder=%number% %% 4

if %remainder% NEQ 0 goto loop

echo %number% is divisible by 4


Quote
For instance %random%*4 may not be fully divisible by 4 and may be 4.1232424, which is not correct.

In batch arithmetic, there are only integers (whole numbers) so that will never happen.

The number returned by %random% is an integer between 0 and 32767. So you may need to guard against %random% being zero, (which the code above will do.)

Quote
How would I produce a series of 5 numbers that are multiples of 4 and then check to see if they divisible by 4.

If they are multiples of 4 then they are by definition divisible by 4Thank you, very useful, I will be sure to use this. It is of course, also a lot faster than my method.You can use the modulus operator with %random% to restrict the range of random numbers generated.

Since %random%

...returns a number between 0 and 32767,

%random% %%N

...returns a number in the range 0 to N-1

so that:

set /a number=(%random% %% 20) + 1

...will provide a random number in the range 1 to 20





Quote from: Dias de verano on December 14, 2008, 01:58:32 PM
You can use the modulus operator with %random% to restrict the range of random numbers generated.

Since %random%

...returns a number between 0 and 32767,

%random% %%N

...returns a number in the range 0 to N-1

so that:

set /a number=(%random% %% 20) + 1

...will provide a random number in the range 1 to 20



Yes, I have used this method in my ACE combat engine to randomize damage between the players attack level , thanks for your help once again.
6664.

Solve : Batch + VBScript??

Answer»

Is there way to run VBScript via batch?TRY:
Code: [Select]cscript /?
WSCRIPT /?at cmd windowI don't get it?

cscript /?
-code here-?
Create the VBS script and save it as filename.vbs

To run the vbs script ENTER "cscript filename.vbs" or "wscript filename.vbs" (without the "") at the command line or click on filename.vbs in Explorer.

Enter cscript/? or wscript/? at the command prompt to view the help FILE(s).

Good luck

6665.

Solve : Query regarding my backup script ...?

Answer»

Hello all,

Has been some time again since I was last on the forum so I hope everyone is fairing well.

I have a backup script (+ associated file) that works well - no issues ... except on Tuesday mornings.

I can't understand why, but returns a "***WARNING*** - Only COMPLETED 4 of the 3 backups attempted." in the log - has me completely miffed.

Could someone spare a few minutes, TAKE a peek and make any suggestions.

Cheers,
Cameron


[attachment deleted by admin]I have never seen some of your techniques, but if you say it works, I guess that's true.

Quote

for /f %%i in (%TempFile%) do call %0 CheckNumOfBackups %%i

Quote
:CheckNumOfBackups
if not "%2"=="%NumOfBackups%" call %0 FoundWarnings Only completed %2 of the %NumOfBackups% backups attempted.
if "%2"=="%NumOfBackups%" set MailBody=%MailBody% - %2 of %NumOfBackups% completed ok.
goto :EOF

This appears to be the code where the message is issued. Does not a call to %0 create a recursion problem? TRY turning echo on to trace what value %%i has.

I couldn't find any code specific to Tuesday, only Sunday and Monday. The message is not logical (Only completed 4 of the 3 backups attempted.) so I would try debugging files left over from previous run that shouldn't exist for this run.

Quote
set Date=%%l-%%k-%%j

Suggest not using reserved words or command NAMES for your variables. Results can be unpredictable.

Hi SIDEWINDER,

Many thanks for the reply & taking the time to peruse the script.
I'll take all onboard your comments and have a further look after the New Year starts.

In the mean time - have Merry Christmas and a happy New Year.

Cheers,
Cameron
6666.

Solve : Batch script pipe question?

Answer» HI I am wondering if something like this can be done:
say ECHO %USERNAME% returns hitesh
And I have a variable hitesh with the value
set hitesh=savla

I am wondering If I can do this:

if(%%USERNAME%% eq "savla") {
.......................
}

I KNOW this can be done in shell and perl scripts.
Can I do this in Batch script. I am thinking maybe using pipe or I have to store this in a file and then read it?
If someone can help that would be great.

set result=no&call echo %%username%% | find "savla">nul &&set result=yesThis is quite easy .... sort of, using Call :

Call Set %USERNAME%=savla

The call forces the %USERNAME% to be evaluated and return its content, so the line then is processed as

set hitesh=savla

To do your test, move the value of the wanted variable to a general one and test that :

Call Set %USERNAME%=savla

Call set generic=%USERNAME%
if(%generic% eq "savla") {
.......................
}

Graham



call echo %%username%% | find "savla">nul && (

................................

)Thanks for the replies guys.

Unfortunately none of the solutions works for me.
Neither the assignment to a generic variable or using find.

Let me attach a config file and a piece of my code here which will make a bit more sense.

Code: [Select]for /f "tokens=1,2 delims==" %%S in (users.cfg) do (
set %%S=%%T
)

What I am trying to achieve here is: If you look at the attached file, based on the access level of the user executing the script which could be wither DEV or GSD, I will forward the control to another label.

for eg:

if (%%USERNAME%% eq "GSD") goto label1
else goto label2

Let me know if you want to paste the entire code here.

Keep up the GOOD work!!


[attachment deleted by admin]Quote from: hiteshsavla on December 24, 2008, 08:02:58 AM

Code: [Select]for /f "tokens=1,2 delims==" %%S in (users.cfg) do (
set %%S=%%T
)

That code is nonsense. You cannot assign a value to the loop variable %%S with SET like that.

Wouldn't want to argue with you sir. But the code works.
And I got the solution from this forum only. So let me grab the topic and get back to you.Quote from: hiteshsavla on December 24, 2008, 08:11:17 AM
Wouldn't want to argue with you sir. But the code works.
And I got the solution from this forum only. So let me grab the topic and get back to you.

I think I see how it works now. This is very interesting. If I am wrong, and the code works as described, then I would be very INTERESTED to see it. Please post on here for my education and maybe I can work further on this problem for you.
Unfortunaltely I am unable to find the topic where I got this solution. Maybe sidewinder posted it(No offence to sidewinder, he has been most helpful).

But the code works for sure.

Here is a working script. you might want to add your username in the users.cfg file attached earlier and try the %%USERNAME%% solution.


[attachment deleted by admin]Why not just read the access code from the file?

Code: [Select]@ECHO OFF
set /p username=input username?
for /f "tokens=1,2 delims==" %%S in (users.cfg) do (
if "%%S"=="%username%" set access=%%T
)
echo user %username% has access level: %access%

if "%access%"=="GSD" goto GSDACCESS
if "%access%"=="DEV" goto DEVACCESS
echo Error
goto end

:DEVACCESS

echo here is DEV access
goto end

:GSDACCESS

echo here is GSD access

:end

pause

Even better. This works amazing and it has reduced the complications in the code too.

Thanks a million sir!!

Happy holidays.
6667.

Solve : how to add an entry in autoexec.bat?

Answer»

Hi Dears
i have a batch file at this PATH in my PC (c:\mehdi.bat)
how can i put it in auotoexec.bat ?
please tell me all COMMANDS that i MUST add
to autoexec.bat
my OS is win XP
Thanks in advanceWelcome to the CH forums.

Except for SET and PATH all/any commands in the Autoexec.bat file in WINDOWS XP are ignored.

What are you trying to achieve?

6668.

Solve : Needing a batch file to delete all files in a folder older than 5 days old?

Answer»

Hey I need a batch file to delete all .avi files in a folder older than 5 days old. I looked at the set, for, if commands, and for examples , but so far can't find any examples that help me figure out how to use the commands,I have read the if,for,set/? , but i guess i am to inexperienced to understand without some examples of their uses.... I bought a security camera and see that it will keep me very busy sorting the files out. I don't know if it's possible or not but would appreciate any help... I have no knowledge using the for, set, and if commands... did look through the forums, but didn't find anything that will help me yet, but will keep searching.... any help would be greatly appreciated...Thanks WEW.


I'm running a dell dimension E510 with Processor Intel(R) Pentium(R) D CPU 3.00GHz
Processor Speed 2.92 GHz
Memory (RAM) 1024 MB
Operating System Microsoft Windows XP Professional
Operating System Version 5.1.2600
I am looking for the same SCRIPT so please answer this one


Many thanks in advanceHomework? Quote from: Carbon Dudeoxide on August 06, 2008, 03:48:35 AM

Homework?
Quote
I'm running a dell dimension E510 with Processor Intel(R) Pentium(R) D CPU 3.00GHz
Processor Speed 2.92 GHz
Memory (RAM) 1024 MB
Operating System Microsoft Windows XP Professional
Operating System Version 5.1.2600
homework?

don't understandQuote from: DJFLuFFY on August 06, 2008, 06:17:57 AM
homework?

don't understand
He thinks this persons query is a school assignment.LOL

i need it to delete my logfiles and .torrent files that i don't use Quote from: DJFLuFFY on August 06, 2008, 06:17:57 AM
homework?

don't understand

It's code for the paranoia factor.

Batch code does not handle date/time arithmetic very well. Dates can be formatted many different ways. The actual format can be extracted from the registry adding overhead to your batch file.

Aging files is simple arithmetic provided the current day of month is greater than age factor. When it's not, you may be dealing with multiple past months and their cumulative days.

Most scripting languages for Windows have functions to SPECIFICALLY handle dates. Any reason your solution must be batch code?




You can simply do a search of the computer for .log .txt and .torrent and then sort them by date.

Quote
It's code for the paranoia factor.
Heh, you will know it's bad when I just ask 'Why' if you have another script that does what i want it is welcome

i am a PHP coder so i know the basics for programming but making a Batch is really different

Quote from: Carbon Dudeoxide on August 06, 2008, 08:43:17 AM
You can simply do a search of the computer for .log .txt and .torrent and then sort them by date.

Quote
It's code for the paranoia factor.
Heh, you will know it's bad when I just ask 'Why'

this is how i work now, But it takes a lot of time to do. This little snippet is written in VBScript:

Code: [Select]Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("c:\scripts") 'point to your directory
Set fc = f.Files

For Each objFile In fc
If fso.GetExtensionName(objFile) = "avi" then
If objFile.DateCreated < date - 5 Then
WScript.Echo objFile & " " & objFile.DateCreated
'fso.DeleteFile(objFile) 'commented out
End If
End If
Next

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

The delete function is currently commented out. Script will currently list files to be deleted. When you're ready, uncomment the delete function and comment the wscript.echo line.

Good luck

Thanks this works really GREAT

only i have 2 new problems

because i forgot to tell you that it has to do the same with all the folders & subfolders

and now i can only select 1 extension by default it's avi. *.* works fine for me

Quote from: DJFLuFFY on August 07, 2008, 12:58:09 AM
Thanks this works really great

only i have 2 new problems

because i forgot to tell you that it has to do the same with all the folders & subfolders

and now i can only select 1 extension by default it's avi. *.* works fine for me < Yes i fixed this



But i still can't figure out how to include the subfoldersThe original code from the snippet closet had recursion built in. It took me days, hours, oh alright, a few minutes to rip it out. Should have gone with my gut feeling.

Again the delete function is commented. You can activate it when you're satisfied this works in your environment. Be careful, files deleted with this script do not MAKE a pit stop in the recycle bin.

Code: [Select]Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("c:\scripts") 'point to your directory
Set colSubFolders = f.SubFolders

For Each objFolder in colSubFolders
ShowFiles objFolder
Next

Sub ShowFiles(Fld)
Set k = fso.GetFolder(Fld)
Set s = k.SubFolders
Set kf = k.Files

For Each objFile In kf
If fso.GetExtensionName(objFile) = "avi" then
If objFile.DateCreated < date - 5 Then
WScript.Echo objFile & " " & objFile.DateCreated
'fso.Deletefile(objFile) 'commented out
End If
End if
Next

For Each SubFolder In s
ShowFiles SubFolder
Next
End Sub

Thanks again

but i get an error when i try to delete files. the echo part works great




ps. the recycle bin is for Pussies

[recovering disk space -- attachment deleted by admin]
6669.

Solve : using DOS command to change default OEM install??

Answer»

I am in need to install a second WIN XP Pro in the E: PARTITION of the HDD that already has one of it installed in the partition C: but the OEM toshiba installation disk from a WIN XP PRo get me only the OPTION to RESTORE the original default system installed in all default settings ( the default partition is the C:). Please, help me. What to do to install more one OS in partition E: with THIS SAME INSTALLATION DISK without overwrite the OS that is already installed in the default C: partition?

I have the drive D: where is the OS installer setup.exe
I have the drive C: where is the first default OS Win Xp Pro
I have the drive E: that I would install the OS with the same OEM disk

I think in the DOS prompt COPY the setup.exe to E: and run it.
It is possible?
I trued write the DOS line but is difficult and I am afraid of overwrite the OS installed in C:

Could someone help me?
Do you need a true install for running graphics ( games ) apps or do you think you could get by with a virtual copy of itself runing. You can run multiple copies of the same OS with Virtual PC 2007 running a virtual copy of XP. You would be able to run the oem of that system in a virtual environment that is isolated from the original main non virtual os, and will be able to do anything pretty much except games and graphic intensive apps. Virtual PC 2007 can be downloaded for free at microsoft. Installation is easy and the creating of a virtual system is easy as WELL. You can have pretty much as many virtual systems running at the same time as your system resources can handle such as if you have 2GB of Ram, you could run about 4 copies of XP at the same time as 4 different computers, computer names, and IPs.Ok Dave
I will do it. I think that is the fast and good solution. Thank you
cheers

6670.

Solve : Batch Variable require for copying....?

Answer»

I NEED a Variable for DOS. I want to copy Links.txt to all drives in a time.
copy links.txt %alldrives%

I don't know what should type in place of %alldrives% for every drive copy.
What value did you plan on %alldrives% having? It might be easier to do each drive separately in a loop.

Code: [Select]for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "partition"') do (
copy links.txt %%i:\
)

You can fixup the paths as necessary.

Good luck. Quote from: Sidewinder on December 20, 2008, 12:55:48 PM

What value did you plan on %alldrives% having? It might be easier to do each drive separately in a loop.

Code: [Select]for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "partition"') do (
copy links.txt %%i:\
)

You can fixup the paths as necessary.

Good luck.

I saved all in a batch.
also changed my paths like this....
Code: [Select]for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "G:") do (
copy links.txt %%i:\
)
But not working...Sidewinder, a batch file like that is excessively strong magic for a novice, I think!

Quote from: afzaldir on December 20, 2008, 11:15:59 PM

I saved all in a batch.
also changed my paths like this....
Code: [Select]for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "partition" ' ) do (

copy links.txt "%%i:\Path to Folder\Folder"
REM FIX THIS ^^^^^^ TO INCLUDE FOLDER FOR FILE TO GO TO
)
But not working...

You "fixed" the wrong path.Not Understand Yet.
also not working....
Please explain with code. [+path]
I want copy links.txt G: and D:
Code: [Select]for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "partition"') do (
copy links.txt %%i:\
)

that will copy the file links.txt to each visible logical drive. If you only wanted to copy to G: and D:

Code: [Select]for %%p in (D G) do copy links.txt %%p:
Or why not just do

copy links.txt d:\
copy links.txt g:\

?

Oh come on now, that's too easy This work good:
Code: [Select]for %%p in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do copy Links.txt %%p:
But first Code is not working yet.....
Thanks u all and special BC_Programmer
6671.

Solve : time log for every boot?

Answer»

I got a batch that log the windows startup time and date.
But recently, I receive a motherboard without CMOS design inside.
So everytime I power off the board, the time is reset.
so the date and time always overwritten.(only one line of time log)

How do I make the batch file always write different from last power off data?

example:
1st power on: write 1
then system power off
2nd power on: write 2
then system power off
3rd power on: write 3
....
so on

I don't know if it is posible without CMOS.....

the original command line is (stored it as log.bat at windows startup folder):
@echo off
cls
echo Windows Started %date% %time% >> c:\startup.txt



Could you tell US your OS?windows XPalright, let me get this straight, everytime you boot up you want to save the current time and date to a txt document.

is that it?yes..
so i can check is that a "loss/miss" boot..
i set a hardware timer to do reboot (AC on off) for 100cycles
but my motherboard do not have CMOS,the data and time will reset when AC loss.
so the time and date is same at every boot.Why not just get a new CMOS BATTERY?alrighty,
here's the code.

Code: [Select]@echo off
if Exist C:\startup.txt (
echo %date% %time% > C:\startup.txt
)
Else (
echo %date% %time% > C:\startup.txt
)

just save it as a BAT file and then goto Scheduled Tasks and add this as a scheduled task and set it for "When my computer starts" so it can run right at boot up.

Hope this helps
,Nick(macdad-)i save the text u given as power.bat at windows desktop
then create a new schedule task and point this bat file
then i power off and on my machine
but i didn't find any log at C:
it should be a startup.txt at C:
Am I doing in correct way?well, i read the command u given carefully.
I think it is working same with my previous command(i put it at windows startup folder previously)
i guess the log will have only one line no matter how many TIMES i turning on and off my machine.
because my machine will START the date and time 1/jan/07 00:00:00 everytime it power on from AC loss. because no battery
I need to work it another way round...
the bat should create a new line instead of overwrite it....
am i right???Quote

@echo off
if Exist C:\startup.txt (
echo %date% %time% > C:\startup.txt
)
Else (
echo %date% %time% > C:\startup.txt
)

The if and the else need to be on the same logical line.

Quote
i guess the log will have only one line no matter how many times i turning on and off my machine

There is no difference traveling the if path or the else path. This may help:

Code: [Select]@echo off
if Exist C:\startup.txt (
echo %date% %time% >> C:\temp\startup.txt
) Else (
echo %date% %time% > C:\temp\startup.txt
)

Good luck.

6672.

Solve : fun with linux?

Answer»

does any one know of a Linux emulator that I can call from a 95 boot disk?

I am working on a boot USB drive that will give you the ability to load a Linux environment and make modifications like add users, change passwords, ext.

I am trying to use syslinux but keep getting an error "can not run in dos".

thanks,
wayneWhat purpose will this disk be for?the disk currently is used for ghost, G disk, kill disk, and securerase. I am trying to load a Linux environment that will allow me to change user info.

I would be able to add, remove, change the password, elevate the PERMISSIONS, ext.

do you know of a win utility that will do this? Or is there a better option for this then Linux? I was concerned that you may want to create a hacking tool.no I work for the Florida Department of Transportation. I am trying to update a boot USB I have been working on. Currently I have it auto dect. the nic and load the DRIVERS. It also will erase the hard drive in the manner of the users choice.

I am trying to get a "admin tool set" for it. This would include the following:

HDD testing software.
memtest
local user access and control
defrag
ext.

thank you,
wayneYou are working for the State of Florida. How come you are getting advice on how to do your job from a teenage computer hobby site? That doesn't quite add up somehow. Don't they have an IT dept at the Transportation Dept? And software audit policies?
ok thanks!Quote from: wbrost on December 23, 2008, 11:32:47 AM

ok thanks!

QED I think.
yes we do. I am one of the techs. I was just trying to see if any one knew of a way to boot linux off of a win boot usb.

The reason I came to this site is because I have received help with my dos and batch efforts. Up to this point I have not had a bad experience.

I do not under stand the comment about software audit policies. And as far as the "OK thanks!" that was in response to your suggestion. SORRY. Crossed wires. It seems to me that if you are looking for a kind of sys admin's USB Swiss Army KNIFE, you should forget Win95 and a long look at MiniPE. Specifically a variant called BARTPE, or you could roll your own.
6673.

Solve : Batch file for text transformation?

Answer»

hello
I'm a novice here and facing a question about usage of bat file that you probably can help me


as an input I have a CSV file with repeated sets of values (see attached Input.txt - as SCV files are not allowed here - I CHANGED extension), like:
Code: [Select]ID;CODE;VALUE
ID;CODE;VALUE
...row by row - and the values are separated with semicolon inside every line.

I need as an output a TXT file with the same name as my CSV input file, but there should be some processing done.

So first of all instead of ';' there should be ',' used.

and the rows should contain (see attached Output.txt)
Code: [Select]CODE,CODE,ID,RU,VALUE,B
CODE,CODE,ID,RU,VALUE,B
...so first of all as you see I need CODE to be put at the beginning of the line and repeated twice
then ID follows
then a constat RU to be added, then VALUE and finally one more constant B to be added

I have searched for a solution and all I found is the following code:
Code: [Select]@echo off
SetLocal EnableDelayedExpansion
for /f "tokens=*" %%i in ('dir /a-d /b *.csv') do call :repl "%%i"

:repl
for /f "tokens=*" %%k in (%~nx1) do set i=%%k&AMP;echo !i:;=,!>>"%~n1.txt"which is doing the following: it creates for every provided CSV file the mirror TXT file and replaces all ';' to ','

Probably I need to use some regular expressions but I can not find how to put it in batch file.

I need from '^([^;]+);([^;]+);([^;]+)$' make '\2,\2,\1,RU,\3,B'

also it would be incredible if as an output there would be another file PRODUCED ErrorLog.txt saying which rows in a file do not fit the regular expression I mentioned, because I think there would be some inconsistencies in the input file, like instead of 3 values there would be passed only 2 values in a row.

hope I explained clearly
if somebody has an experience of such transformations - I would be full of thanks if you help me



[attachment deleted by admin]ok

for the HALF of the task I have done the following:
Code: [Select]@echo off
SetLocal EnableDelayedExpansion
for /F "tokens=*" %%i in ('dir /a-d /b *.csv') do call :repl "%%i"

:repl
for /f "delims=; tokens=1,2,3" %%a in (%~nx1) do echo %%b,%%b,%%a,RU,%%c,B>>"%~n1.txt"
now it is generating me the txt file with needed output

The only thing I still need is to verify each line whether it has 3 values separated by ';'
and if not - put a note to ErrorLog.txt file writing the number of erroneous line

Does anyone have an idea how can I check it?

6674.

Solve : .bat or vbs to change modify user template in word 2007?

Answer»

Word 2007

can I run a bat or vbs file to automacticaly change the file location or the USer Template to a new template I have STORED elsewhere.

If I can, can I SEE a sample code?Batch code is unsuitable for this task. VBScript may help:

Code: [Select]Const wdUserTemplatesPath = 2
Const wdWorkgroupTemplatesPath = 3

Set objWord = CREATEOBJECT("Word.Application")
Set objOptions = objWord.Options

objOptions.DefaultFilePath(wdUserTemplatesPath) = "C:\Templates"
objOptions.DefaultFilePath(wdWorkgroupTemplatesPath) = "C:\Workgroup\Templates"

objWord.Quit

Be aware this code was tested with Word 2002. Hopefully it WORKS for Word 2007. Be SURE to change the paths to something that makes sense on your system.

cool will test this outthank you this works a treat

6675.

Solve : execute a query on sybase Database and store back the result in a variable?

Answer»

Apologies If this question is not meant for this forum.
But since I am using a batch file, I thought someone might have used this before.

A small part of my batch file includes EXECUTING a query on sybase database. I want to store back the result in a variable or atleast check whether the result was SUCCESSFUL and based on this execute another set of lines.

For this I am using "isql" utility.

Here is the syntax for the same.

isql -S %server% -D %database% -U %user% -P %pwd% -i test.sql

Is there a way to store back the result in batch files.Batch code is text based. You can iterate line by line the results of a command:

Code: [Select]for /f "tokens=* delims=" %%v in ('isql -S %server% -D %database% -U %user% -P %pwd% -i test.sql') do (
.
. Your commands go here %%v contains a single line of output from the isql command
.
)

There are many variations on the for command. Depending on what you doing, some keywords can be very helpful, some not so much.

Good luck. Works LIKE a charm.

Many thanks Sidewinder. Appreciate it!!!using your code which works perfect:
for /f "tokens=* delims=" %%v in ('isql -S %server% -D %database% -U %user% -P %pwd% -i test.sql') do (
echo %%v
)

Basically the output I get is full of spaces and tabs and this is an issue with the Database output.

prioran GSD

agerma GSD

savlahi DEV

rotheam DEV
I want to REMOVE the tabs and spaces in between and set the first variable to the second. If this is confusing Apologies for my bad english.
let me give you an example.

set prioran=GSD and so on.

I know this needs a for loop and FINDSTR. Could anyone help?

6676.

Solve : Solved - "Batch file to give commands to different DOS programs"?

Answer»

How to create a batch file that will GIVE commands to different DOS programs..
Like a program to move the 'boot' flag to different primary partitions:

Code: [Select]DISKPART
SELECT DISK 0
SELECT PARTITION 5
ACTIVE

But the above shown code OPENS the DISKPART but does nothing more than that.
Thanks.
-AshutoshQuote

But the above shown code opens the DISKPART but does nothing more than that.

That's because Diskpart is WAITING for commands from the STDIN device which is the keyboard. You should try creating a script file and USING the /S SWITCH with Diskpart.

See here..

Thanks.

6677.

Solve : pass a value from a batch file once completed?

Answer»

I NEED to pass a parameter (pass/fail or 1/0) from a batch file if a condition is met within it. I think I can do it by creating a registry key and setting it to a 1 or 0. Is there a better or more efficient way to do this?

This 1/0 or pass/fail will then be read by a separate application (National Instruments Labview). Thanks in advance.I think this will work on Win2000:

Code: [Select]exit /b [returncode]

The /b switch will return control to the command window, not shut it down. The returncode will be placed in errorlevel where it can be TESTED in the normal batch ways.

Mucking around with the registry SEEMS a bit overkill. Thanks for the reply but I believe I am doing what you propose already.

Within my batch file, I look at the errorlevel to determine within the batch file WHETHER it is a 1 or 0. How do I see from a separate application (NI Labview) wheter that value is a 1 or 0? Thanks.Quote

Within my batch file, I look at the errorlevel to determine within the batch file whether it is a 1 or 0.

What condition produces a 1 or 0 errorlevel? What action does the batch file take? If you were to put this value in the registry does Labview have a mechanism to read it?

Can Labview read arguments on the command LINE? If so, this might work provided Labview knew what the command line data represents.

Perhaps Labview can test the condition that produced the 1 or 0 errorlevel and determine for itself what action to take.

Post the batch file. It should help us see what direction you're going with this. It works by having Labview read the registry entry. My batch file writes either a 1 or 0 depending on the if statment. It works fine, I just do not like messing around with the registry.

I believe what I will do is have the batch file create a .txt file if the else condition occurs and have Labview check to see if the file exists. From checking on this forum and others, this appears the least troublesome way to do it. Thanks again for your help.
6678.

Solve : Check whether a file is empty or not?

Answer»

Hi. How can I check whether a file is empty or not?

My execution of the next statement depends on this.
It seems to be simple but I am stuck on it.
I have tried searching this in the previous posts but haven't been able to FIND this.If you check a file with Windows Explorer, in Details mode, it will tell you exactly the size of the file.....even Zero ( 0 ) files.

This is almost too obvious. I GUESS I'm not FULLY understanding your question.
Please re-state, why you can't see the size of a file.

Shadow Oh Crap. I forgot to mention. I want to find the size of the file in a batch program.

Sorry about that!!REPLACE zero.txt with the NAME of your file:

Code: [Select]@echo off
for /f "delims=" %%a in ('dir zero.txt /s /b') do (
if %%~za==0 ....
)

The dots represent your logic when you find the file has zero bytes. There are probably other ways to do this but this just popped into my head.

Good luck. Perfect. Thanks again sidewinder.

6679.

Solve : Unusual error when trying to redirect output to a log file.?

Answer»

I am trying to copy files from one location to another USING XCOPY (across DIFFERENT servers using UNC Paths)
Then LOGGING the files copied. It works fine on my machine and the people around me here. But works differently when executed from a different location. We have offices in seperate buildings. So it works fine in My building, But does not in the other one.
Its not a permissions issue for sure.

Here's a part of the code(The entire one is too lengthy).

REM ****** MAP A DRIVE TO WORK WITH UNC PATHS**********
pushd %~dp0

set source="%cd%"

set logdir=C:\Logs
IF NOT EXIST "%logdir%" mkdir "%logdir%"

set today=%date:~10,4%%date:~4,2%%date:~7,2%
set target="\\Path\to\server"
for /f "tokens=* delims=" %%i in ('echo all ^| xcopy /l /d %source% %target% ^| find /v /i "overwrite"') do (
if exist %target%\%%~nxi (
copy %target%\%%~nxi %target%\%%~ni-%today%%%~xi >nul
echo %target%\%%~nxi >> "%logdir%\Code_Log-%today%.log"
)
)
echo all | xcopy /d %source% %target% >> "%logdir%\Code_Log-%today%.log"

IF EXIST "%logdir%\Code_Log-%today%.log" move "%logdir%\Code_Log-%today%.log" %target1%\Logs
IF EXIST "%logdir%" RMDIR /Q "%logdir%"

If I remove the Logging(redirecting the output to log files), It works perfectly fine on everyone's machine. But when I log the outputs, it works fine on my machine but not on others.

Very unusual according to me. I am stuck here for a while now, trying to figure out what the problem. Seems to be a small issue.

If you see Any unusual coding style where there are possibility of errors, would appreciate some information on that as well.
Any help is appreciated. That's it! I tired of writing responses only to have the CH connection time out. I'm taking my ball and going home.

Which line actually fails? Echo is a fairly transparent command, so logging a string to a file should not create a problem.

I know we don't have a full VIEW of you code, but where does target1 get a value from in this line:

IF EXIST "%logdir%\Code_Log-%today%.log" move "%logdir%\Code_Log-%today%.log" %target1%\Logs

Setting the source variable could be a problem, as not every machine is likely to have the same current directory.

Just a thought.

See thats the SURPRISING part.

The only issue here is: When I replace this part of the code:

echo %target%\%%~nxi >> "%logdir%\Code_Log-%today%.log"
)
)
echo all | xcopy /d %source% %target% >> "%logdir%\Code_Log-%today%.log"


with the following part:


echo %target%\%%~nxi )
)
echo all | xcopy /d %source% %target%


Basically getting rid of the logging, It works fine.

Also I am pushing the UNC Drive to map to any available drive , So for anyone who executes the script, the current drive would be the drive that gets mapped to it.

Was this confusing??

Thanks a lot SideWinder for the quick reply. Really appreciate it.I think I found the problem.

This is the reason I think. Although a small mistake but Its hard to find such issues when the actual program grows bigger.
This is what I read somewhere:

DIR>file.txt and DIR > file.txt are identical, ECHO Hello world>file.txt and ECHO Hello world > file.txt are not, even though they are both valid.

Its because of the space before and after the redirection.
Haven't tested this yet. As this problem does not occur on my machine or my building. Need to find someone from the other office to test it. So can't be 100% sure.Ok My Bad. I thought I had found the solution. But its still not working.

The problem is redirecting output to the log file. The moment I remove the lines I get the program working fine.

Unable to find a reason behind this. Is it something to do with mapping a Drive?
Is Pushd good to map to a drive or I should use something else?

I need to find a reason quick. Can someone help please?If you need to me post the entire code, let me know.
As you can see I am kinda getting desperate here. Could it be a question of write permissions?
Na. I dont think its a write permissions issue. But aneways I am first creating the Log file on one's local machine.. "C:\Logs" and then moving it over to the target location.

So the script should only fail in the last step. Apart from that XCOPY is also writing to the server, i.e creating new files if it does not exist. So I dont think there is a permissions issue here.

Any other Ideas??The problem is localized on your end. Try turning echo on in the machines where it fails. You'll have to see how the code runs and it may give you come insight as to the problem.

Just a hunch, but is the copycmd variable set on the machines where is fails? If so it may be preventing the code from entering the if statement.

Good luck. Thanks Sidewinder. Seems to be a problem that i am unable to understand. Works fine on my machine and the machines on my floor.

Let me try the solutions you gave me. Will post back If the problem gets solved.

Thanks again..

God Bless!!

6680.

Solve : Check several locations in a .vbs script to delete files by date.?

Answer»

I found a script on the forums by Sidewinder to delete files by date for a specific location, the code is below and I would like to be able to specify different locations and have it loop through for each location. Either by looking at an external file or by adding something in the current script and listing out each location. Can anyone assist me with this?

Code: [Select]Set FSO = CreateObject("Scripting.FileSystemObject")
fs = "c:\dvr_data"
ShowFiles(fs)

Sub ShowFiles(Fld)
Set k = fso.GetFolder(Fld)
Set s = k.SubFolders
Set kf = k.Files

For Each objFile In kf
If fso.GetExtensionName(objFile) = "avi" then
If objFile.DateCreated < date - 3 Then
WScript.Echo objFile & " " & objFile.DateCreated
'fso.DeleteFile objfile
End If
End if
Next

For Each SubFolder In s
ShowFiles SubFolder
Next
End Sub

I had a beautiful ELOQUENT response to this post, but just as I hit the post button, CH took a header into the mountain again. You'll have to deal with the salvaged wreakage:

If you don't have too many directories, you can hardcode an array otherwise you can use an external file.

Array:
Code: [Select]Set fso = CreateObject("Scripting.FileSystemObject")
arrDir = Array("c:\dvr_data","c:\dir2","c:\dir3") 'use correct directories

For Each fs In arrDir
ShowFiles(fs)
Next

Sub ShowFiles(Fld)
Set k = fso.GetFolder(Fld)
Set s = k.SubFolders
Set kf = k.Files

For Each objFile In kf
If fso.GetExtensionName(objFile) = "avi" then
If objFile.DateCreated < date - 3 Then ' age factor is days
WScript.Echo objFile & " " & objFile.DateCreated
'fso.DeleteFile objfile
End If
End if
Next

For Each SubFolder In s
ShowFiles SubFolder
Next
End Sub

External File:
Code: [Select]Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\input.txt", ForReading) 'point to correct file
Do While f.AtEndOfStream <> True
fs = f.ReadLine
ShowFiles(fs)
Loop
f.Close

Sub ShowFiles(Fld)
Set k = fso.GetFolder(Fld)
Set s = k.SubFolders
Set kf = k.Files

For Each objFile In kf
If fso.GetExtensionName(objFile) = "avi" then
If objFile.DateCreated < date - 3 Then ' age factor is days
WScript.Echo objFile & " " & objFile.DateCreated
'fso.DeleteFile objfile
End If
End if
Next

For Each SubFolder In s
ShowFiles SubFolder
Next
End Sub

Both snippets list files to be deleted. When satisfied, comment WScript.Echo objFile & " " & objFile.DateCreated and uncomment 'fso.DeleteFile objfile

If you use the array method, each directory must be quoted with either a space or comma as separator. If you use the external file method, the file should contain one directory per line.

Good luck. Ok gave it a shot with the external file and this is what was returned.

Quote

C:\delbydate.vbs(11, 4) Microsoft VBScript runtime error: Path not found

I am assuming it is stating 11 line and 4th character in there is an issue?

At that location is the following code.

Code: [Select] Set k = fso.GetFolder(Fld)The error is reproducible by entering an invalid directory name in the external file. I added some code for the snippet to crash and burn if a directory from the external file is not found.

Code: [Select]Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\temp\input.txt", ForReading) 'point to correct file
Do While f.AtEndOfStream <> True
fs = f.ReadLine
ShowFiles(fs)
Loop
f.Close

Sub ShowFiles(Fld)
If fso.FolderExists(fld) Then
Set k = fso.GetFolder(Fld)
Else
WScript.Echo "Invalid Directory:",fld
WScript.Quit
End if

Set s = k.SubFolders
Set kf = k.Files

For Each objFile In kf
If fso.GetExtensionName(objFile) = "txt" then
If objFile.DateCreated < date - 3 Then ' age factor is days
WScript.Echo objFile & " " & objFile.DateCreated
'fso.DeleteFile objfile
End If
End if
Next

For Each SubFolder In s
ShowFiles SubFolder
Next
End Sub




But those directories work fine if I use them in the first script, why would that happen?

The paths are UNC name btw not sure if that effects it differently in this version of the script.Your not giving us enough information. Did the last posted version of the script ISSUED an Invalid Directory message? Can you GIVE us an example of what is in the external file?

This script has been tested with directories containing embedded spaces and UNC paths, with no problems.



Are you STILL getting a VBScript error, or just no results at all? Keep in mind the script is filtering only txt extensions.That was it I was missing a letter in one of the paths, sorry about not giving as much detail. Looks like the script doesn't do anything once it runs into a bad path.

Thanks so much for you assistance Sidewinder!
6681.

Solve : Timing a command.?

Answer»

Sorry, I know for a fact this has been posted before but I cannot seem to find it.
I want to see how long a command takes to execute, but the problem at the moment is that when I minus the start time from the end time it cannot do it because it contains :.
Here is what I have so far:
Code: [Select]set start=%time%
command
set finish=%time%
set /a length=%finish%-%start%
echo %length%
if your %time% looks like
Code: [Select]20:33:46,92
then

Code: [Select]set start=%time%
command
set finish=%time%

set start=%start::=%
set start=%start:,=%
set finish=%finish::=%
set finish=%finish:,=%

set /a length=%finish%-%start%
echo %length%My time Is 00:00:00.00
I adjusted your code, and managed to get something remotely correct, thank you.

Code: [Select]set start=%time%
command
set finish=%time%

set start=%start::=%
set start=%start:.=%
set finish=%finish::=%
set finish=%finish:.=%

set /a length=%finish%-%start%
set /a length=%length%/100
echo %length% SECONDS
it may "work", but it won't be accurate, because there are more than 10 seconds in a minute, and more than 10 minutes in an hour. (in other words, the "number" PRODUCED is not a true decimal number you can do MATH with.)

Furthermore, it may well crash if it has to process a time before 10 AM.
elapsed-calc.bat

Code: [Select]@echo off
REM remove surrounding QUOTES (if any)
set time1=%~1
set time2=%~2
set hh1=%time1:~0,2%
set mm1=%time1:~3,2%
set ss1=%time1:~6,2%
set cs1=%time1:~9,2%
if "%hh1:~0,1%"==" " set hh1=%hh1:~1,1%
if "%mm1:~0,1%"=="0" set mm1=%mm1:~1,1%
if "%ss1:~0,1%"=="0" set ss1=%ss1:~1,1%
if "%cs1:~0,1%"=="0" set cs1=%cs1:~1,1%
set hh2=%time2:~0,2%
set mm2=%time2:~3,2%
set ss2=%time2:~6,2%
set cs2=%time2:~9,2%
if "%hh2:~0,1%"==" " set hh2=%hh2:~1,1%
if "%mm2:~0,1%"=="0" set mm2=%mm2:~1,1%
if "%ss2:~0,1%"=="0" set ss2=%ss2:~1,1%
if "%cs2:~0,1%"=="0" set cs2=%cs2:~1,1%
set /a msec1=3600000*%hh1%+60000*%mm1%+1000*%ss1%+10*%cs1%
set /a msec2=3600000*%hh2%+60000*%mm2%+1000*%ss2%+10*%cs2%
set /a elapsed=%msec2%-%msec1%
echo %elapsed%


How to use it...


Code: [Select]@echo off
set time1=%time%

echo time1 %time1%

rem ****** code to be timed here ***********
sleep 1

set time2=%time%

echo time2 %time2%

for /f %%A in ('elapsed-calc.bat "%time1%" "%time2%"') do set elapsed=%%A

echo elapsed time %elapsed% msec
Okay I think this will do it for seconds.
Code: [Select]set time1=%start%%~1
set time2=%finish%%~2
set hh1=%time1:~0,2%
set mm1=%time1:~3,2%
set ss1=%time1:~6,2%
if "%hh1:~0,1%"==" " set hh1=%hh1:~1,1%
if "%mm1:~0,1%"=="0" set mm1=%mm1:~1,1%
if "%ss1:~0,1%"=="0" set ss1=%ss1:~1,1%
set hh2=%time2:~0,2%
set mm2=%time2:~3,2%
set ss2=%time2:~6,2%
if "%hh2:~0,1%"==" " set hh2=%hh2:~1,1%
if "%mm2:~0,1%"=="0" set mm2=%mm2:~1,1%
if "%ss2:~0,1%"=="0" set ss2=%ss2:~1,1%
set /a msec1=3600000*%hh1%+60000*%mm1%+1000*%ss1%
set /a msec2=3600000*%hh2%+60000*%mm2%+1000*%ss2%
set /a elapsed=%msec2%-%msec1%
set /a length=%elapsed%/1000
echo %length%
Quote from: Jacob on December 22, 2008, 01:35:50 PM

Okay I think this will do it for seconds.
Code: [Select]set time1=%start%%~1
set time2=%finish%%~2
^^^
this doesn't look right
Quote from: Dias de verano on December 22, 2008, 03:21:04 PM
Quote from: Jacob on December 22, 2008, 01:35:50 PM
Okay I think this will do it for seconds.
Code: [Select]set time1=%start%%~1
set time2=%finish%%~2
^^^
this doesn't look right

It seems to work, as far as I am concerned. But it may not be correct for other uses.It "works" because the parameters %1 and %2 do not exist.

Better is this code.

Code: [Select]set time1=%start%
set time2=%finish%
Also, I do not think you realise that you have destroyed the accuracy of my code? Because you are dividing the millisecond figure by 1000, and because batch arithmetic is integer only, that means that 3999 msec would become 3 seconds for example.


I have adjusted the code so that it does not calculate milliseconds, but just seconds. The division is to get rid of the 3, 0's after the time for instance it outputs:
7000.
But yes, it is still inaccurate, but that is fine for the purpose that I am using it for. Thanks for all your help.Quote from: Jacob on December 23, 2008, 02:47:54 AM
I have adjusted the code so that it does not calculate milliseconds, but just seconds. The division is to get rid of the 3, 0's after the time for instance it outputs:
7000.
But yes, it is still inaccurate, but that is fine for the purpose that I am using it for. Thanks for all your help.

Well, why don't you do it properly, by reducing these multipliers by 1000:


like this...

Code: [Select]set /a sec1=3600*%hh1%+60*%mm1%+%ss1%
set /a sec2=3600*%hh2%+60*%mm2%+%ss2%
Then you don't need to divide by 1000.

Also, you do know the code will break if the start time is before midnight and the finish time is after? (And therefore measured time interval must be less than 24 hrs)

Works perfectly, thanks ever so much, and about the midnight glitch, its fine.
6682.

Solve : Multiple commands once per directory?

Answer» HEY all,

I have multiple commands I want to execute. I want to execute these commands once for every directory, starting at the location of the batch file, and walking down the directory tree. It's important that all commands complete for a sole directory before moving on to the next. This, essentially creating a loop at each new directory. Hope that makes sense.

For simplicity's sake, lets just call the commands; command a and command b

Thanks for the help.
@echo off
for /f "tokens=1*" %%a in ('dir /a:d ..\ /b /s') do (
cd "%%a %%b"
attrib +s +h
)



use for /f , the above when put in a batch file will use for /f and dir
to search out all directorys starting at the drive root ..\ , the loop uses cd to change to the current directory, then uses attrib to add attributes to everything in that folder, the folder path is stored as a variable , %%a and %%b , %%a %%b combined is the full folder path, if you use %%a or %%b individually you will not get the folder path, for example %%a=C:\documents %%a %%b=C:\document and settings\program files , so for this reason its important to add quotations around %%a %%b so that the full path will be used in certain commands ,its also important to notice that "%%a %%b" doesnt include the final slash needed, so if you WANTED to copy a file .. copy "%%a %%b\file.txt"Thanks diablo416.

That solved my problem and I learned a couple of tricks in the process. Thanks again.Crap, ran into a problem USING the code. Here's a snippet.
Code: [Select]@echo off
setlocal enabledelayedexpansion

for /f "tokens=1*" %%a in ('dir /a:d /s /b') do (
cd "%%a %%b"
set group.counter=1
: group.loop
for /f "tokens=!group.counter! delims=," %%c in ("%group.string%") do set group.name=%%c
)

pause
It produces this:
Code: [Select]!group.counter! delims=," was unexpected at this timeMultiple times depending on how many sub-directories there are, which is expected.
What's wrong?Well I solved the problem by putting quotes around the [tokens=] in the second [for /f] command.

I don't understand why they would have to be there, if the [group.counter] variable is always a value containing no spaces....continuing the conversation with myself

The quotes around [tokens=] did not work after all, tokens simply got set to [""], der

It seems that no matter what I do, a variable that is set within the first [for /f], cannot be called within the second.

Code: [Select]for /f "tokens=1*" %%a in ('dir /a:d /s /b') do (
set var=1
for /f "tokens=!var! delims=," %%c in (%some.var%) do set group.name=%%c
)
If I use [!var!] then I get:Code: [Select]!var! delims=," was unexpected at this time It doesn't seem the [!!] are processed.

If I use [%var%] then I get:Code: [Select] delims=," was unexpected at this time Note the leading space. The variable value was not transferred, leaving an empty [tokens=], hence that error.

Can someone please try this, or tell me why this does not work?

Thanksk i fixed the errors , but i cant figure out what this batch is suppost to do?
there must be more to it then this?


@echo off
setlocal enabledelayedexpansion
for /f "tokens=1* delims=," %%a in ('dir /a:d /s /b') do (
cd "%%a %%b"
call set group.counter=1
for /f "tokens=%!group.counter!%*" %%c in ("%group.string%") do set group.name=%%c
echo %group.string%
)
pause
Thanks again diablo416

There is more to the batch, much more, but there is no need to add confusion. The problem exists in this small snippet of code, which I simplified slightly in my last post. Try running the code below, both the WAY it is, and what you had DONE when you made [!var!] --> [%!var!%]. They both return errors. The task here to accomplish seems simple; set a variable within the first [for /f], then call it within the second [for /f]. If you leave echo on, you can see the variable is never transferred into the second [for /f]. I don't know what I'm doing wrong or if it just does not ever work.

Code: [Select]for /f "tokens=1*" %%a in ('dir /a:d /s /b') do (
set var=1
for /f "tokens=!var! delims=," %%c in (%some.var%) do set group.name=%%c
)This, on the other hand, works fine. Take the variable outside of the [for /f] and it works. It's not where I need it however. I've decided this cannot work, unless someone can tell me otherwise.

Code: [Select]setlocal enabledelayedexpansion

set var=1
for /f "tokens=1*" %%a in ('dir /a:d /s /b') do (
for /f "tokens=%var% delims=," %%c in (%some.var%) do set group.name=%%c
)

pause
6683.

Solve : batch to run certain apps on start up?

Answer»

hi, im on a windows NT here, its a slow pc, everytime when i start it, takes sometime to load up
is there a way to make a batch to run on start up? im ok with editing my reg, or copying files to a certain folder.

maybe something like this, after i move this to the start place, and if i did anything wrong in this batch, correct me
Code: [Select]Title:"Apps Runner"
taskkill /f /im aim6.exe ]------------------}just some annoying apps
taskkill /f /im googleupdate.exe]------- }same
cd C:\
start firefox.exe [i have set it in c:\]
any HELP to get this on run ups?
and by any CHANCE it can run in the backround? my idiot friends or FAMILY MIGHT break it up when its doing its stuff

thanksanyone?
i just need to know a run-script I'm assuming it's NT4 you're USING? Any particular service pack? (I would assume 6)

It's been a few years since I've used NT 4. This may or may not be useful

Well I'm all for enthusiastic use of batch files when they may or may not be appropriate but it seems like you could just as easily use MSCONFIG. If NT 4 had MSCONFIG, maybe that's just a 98/2000/XP sort of feature. Anyway try running MSCONFIG and if it comes up disable aim and google update that way. Seems much more effective. Do you need every profile to do the task killing or just yours? I assume just yours.

For running applications like firefox every time just put a shortcut in
"%userprofile%\Start Menu\Programs\Startup"

No need to re-invent the wheel though, right?

You could also put a shortcut to a batch file in that startup path.

I don't know if this helped or not.

6684.

Solve : notepad?

Answer»

Hi friends..

I am new to dos.. and i am STUCK...

Please give a sample code to
1.open
2.Delete contents
3.ADD new lines
4.save

a notepad in dos pro mt...
Notepad can be scripted, but not with batch code.

Code: [Select]SET WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad C:\temp\test.txt" 'Point to existing FILE
WScript.Sleep 1000
WshShell.AppActivate "test - Notepad" 'Must match window title(handle)
WScript.Sleep 1000
WshShell.SendKeys "^(a)"
WScript.Sleep 1000
WshShell.SendKeys "{DEL}"
WScript.Sleep 1000
WshShell.SendKeys "1. Open notepad"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
WshShell.SendKeys "2. Delete contents"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
WshShell.SendKeys "3. Add new Lines"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
WshShell.SendKeys "4. Save"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 2500
WshShell.SendKeys "^(s)"
WScript.Sleep 500
WshShell.SendKeys "%(f)"
WScript.Sleep 2500
WshShell.SendKeys "x"
WScript.Sleep 500

Notes:

1. Script opens an existing file test.txt. Change if necessary.
2. Window handle format is filename - Notepad; filename does not contain the extension.
3. Script will overwrite existing file; take precautions if necessary

Good luck.

Creating files with VBScript and sendkeys is very inefficient. Code: [Select]@echo off

rem open
start "" notepad "c:\path to file\test.txt"

rem delete contents
echo >test.txt

rem add new lines
echo.>>test.txt

rem no need to save, already done.
exit

6685.

Solve : How can i copy one file to StartUp? (in batch file)?

Answer»

for EXAMPLE i want copy 1.txt to startup and i dont KNOW user profile ...
Code: [Select]copy 1.txt C:\Docume~1\??????????\StartM~1\Programs\Startup
how?
sorry for my english ...If you don't know the user profile then you are possibly intent on copying this file on someone else's computer. This could be malicious and CH members do not assist with such practices.

I DISAGREE with your assumption this is malicious. In corporate networks there are PCs with literally 20+ profiles. If you wanted to write a script that did something profile-specific at each user's logon, setting the default printer comes to mind, this would be a perfectly legitimate need. It's just a file copy

Of course I'm not entirely sure what Mental is really trying to do. If he wants to copy 1.txt to all profile's startup group he could use the
%ALLUSERSPROFILE%

environment variable. A command like
copy 1.txt "%ALLUSERSPROFILE%\Start Menu\Programs\Startup"
(include the double quotes (") )

The all user's profile is there so it will affect everybody who logs in, new or old etc.

There's also the %USERPROFILE% variable that just points to the current profile. I guess you could use a for loop and go through each FOLDER in the "c:\documents and settings" folder. Unless he's in PLAIN MS-DOS?

Hope this helped Mental.

6686.

Solve : increment a variable?

Answer»

Is there a way to INCREMENT a variable in a BATCH file such as the way its done in C? (tick++ or ++tick)

ThanksTwo alternatives:

Method (1)

Can be USED in a loop or parenthetical expression, or elsewhere:

Code: [Select]set /a variable+=1
Method (2)
Code: [Select]set /a variable=%variable% + 1
In a loop or parenthetical expression you must USE delayed expansion and

Code: [Select]set /a variable=!variable!+1

6687.

Solve : DOS limitations?

Answer»

I've been trying to copy a folder and group of subfolders from C:\program_files to another hard drive. The first folder and several layers of subfolders copy fine, but the deepest subfolders aren't copied. When I tried to view that subfolder using DOSSHELL or DOS Navigator, neither can open it. I can open it fine in Windows or Linux. Is there a depth limit on subfolders DOS can access or a limit to the number of characters in a path? Is there some place these and similar limits would be documented? I've tried searching Google but apparently I'm not using the correct search terms.http://www.google.co.uk/search?num=100&hl=en&safe=off&q=dos+path+max+length+characters&btnG=Search&meta=&aq=f&oq=

Did you mean real MS-DOS or Windows command prompt? And if the latter, which type of Windows? And does your Program Files folder really have an underscore in the name?
I'm using Windows 98SE. The program files directory uses the standard windows given name. I am booting to real DOS with a bootdisk. The actual path as copied from the Windows address bar is:
Code: [Select]C:\Program Files\Connectix\Virtual PC 5.1 Online Installer\Installer\program files\Connectix\Connectix Virtual PCThe last subfolder and everything beyond it is not copied and I can't access them while in DOS. QUOTE from: still_learning on December 16, 2008, 07:51:40 AM

I'm using Windows 98SE. The program files directory uses the standard windows given name. I am booting to real DOS with a bootdisk. The actual path as copied from the Windows address bar is:
Code: [Select]C:\Program Files\Connectix\Virtual PC 5.1 Online Installer\Installer\program files\Connectix\Connectix Virtual PCThe last subfolder and everything beyond it is not copied and I can't access them while in DOS.

Try using double quote marks around the path that you describe.

copy C:\Program Files\Connectix\Virtual PC 5.1 Online Installer\Installer\program files\Connectix\Connectix Virtual PC c:\some_dir
will not work.

copy "C:\Program Files\Connectix\Virtual PC 5.1 Online Installer\Installer\program files\Connectix\Connectix Virtual PC" c:\some_dir
should.

Experiment with it a bit. You'll get the idea quick enough.

I hope this helps.Quote from: still_learning on December 16, 2008, 07:51:40 AM
I'm using Windows 98SE. I am booting to real DOS with a bootdisk.

The explanation is that you are using MS-DOS version 7. All versions of MS-DOS limit a file name including path to 80 characters. The path+filename you quoted is 113 characters LONG.

Quote
All versions of MS-DOS limit a file name including path to 80 characters.
That explains it. Even using truncated names, some of the subfolders still push the length to over 100 characters.

I'm familiar with 3RD party drivers that overcome the long file name limitation. Does anyone make a driver, modified file, etc that will raise this limitation? Do any of the other versions of DOS (FreeDOS, 4DOS, etc) have higher limits?I think this is a limitation of all versions of MS-DOS and the other non-MS "DOS" variations.

Anyway, that doesn't mean you can't get to the folder you are interested in and perform operations on the files therein.

You don't have to use the FULL path, you can just CD from folder to folder down the path until you get there.

Or go part way until the path remaining is less than 80 chars



6688.

Solve : How to get rid of the "Novell Login" dialog box??

Answer»

Dear all,

I have an application that runs in WINDOWS XP and is started through a Novell Client net using a batch file.

The command line of the batch file that starts the application is:
"start /wait C:\WINDOWS\system32\loginw32.exe EMPRAC_TREE/.USERJ.use.empr /TREE".

Notice that in the command line above ".USERJ.use.empr" is exactly the "User name" that fills the proper field of the Novell Login dialog box.

Every time I run the batch file, the Novell Login dialog box shows me the "User name" above and prompts me click on the “OK” button (The application does not request a Password).

How do I get rid of this dialog box? I mean, since the password is not requested, how do I insert the “Enter” command (the OK button) in the line of command of the batch file?

Thanks for your helpI doubt you can. Batch code cannot mimic key presses or mouse clicks. VBScript has a sendkeys method that might WORK. It ALSO has a run method where you can launch your application.

If you need further help PLEASE post the title of the Novell Login dialog box.

Good luck. use /cont at the end of the command

http://www.novell.com/support/php/search.do?cmd=displayKC&docType=kc&externalId=10013294&sliceId=&docTypeID=DT_TID_1_1&dialogID=43967425&stateId=0%200%2043963818Quote from: SIDEWINDER on October 13, 2008, 04:22:43 PM

I doubt you can. Batch code cannot mimic key presses or mouse clicks.

What about

echo.
echo Y
etc?

Hy Guys,

I wanna thank you all for your time, but I must congratulate "erobby" for his tip.
It works just perfectly.
Once more, thank you all for your help.

Gustavo
6689.

Solve : running Visual studio Command prompt or XSD.exe from a batch file.?

Answer»

Can someone help me with a way (or script) to run a visual studio command PROMPT or XSD.exe tool to convert an XML file to XSD and later to a .Net class (using C# lang). I want to write a .bat file that runs this tool (VS command prompt or XSD.exe) with suitable parameters and convert an xml (from a location of a file) into a xsd and then into a class. Any help would be APPRECIATED

Thanks a lot in advance.A visual studio command prompt is result of a standard command window after vcvarsall.bat has been run. Basically a mess of Visual Studio directories are added to the beginning of your standard path.

The XSD utility will generate class files from a source.

Based on your post, I think you would need this format:

Code: [Select]xsd <instance>.xml [/outputdir:]

Hope this gets you started. Thanks SideWinder for your quick response.
I basically wanted to create a tool (using winform) that will take the xml string or a location where this xml string is located and generate a class and place it in some directory. But to generate a .Net class we need an xsd. I know that using VS command prompt or XSD.exe we can generate an xsd from xml and later using the same command promt, to genererate a class from the xsd. But I dont want the user to do all this manually. I am thinking of AUTOMATING this, so that just by entering the xml the user should get a class.

I am thinking of using the xsd.exe or VS cmd prompt in another batch file which will do everything step by step by giving suitable PARAMS. Do you think it will be possible?

Thanks a lot once again :-)This should help you out. The script works on-demand. If you want to automate an entire directory of XML files, this script can be reworked.

Code: [Select]@echo off
set arg=%*

:loop
if "%arg%"=="" (
set /p arg=Enter XML Name:
GOTO loop
)
drive:\path\xsd drive:\path\%arg%.xml /outputdir:%temp%
if not errorlevel 1 drive:\path\xsd %temp%\%arg%.xsd /classes /language=CS /out:%temp%

You'll need to fix up the drives and paths. Also you might want to change the %temp% variable. I only used it because all Vista machines have it defined.

Good luck. thanks again sidewinder.
That's very helpful. I'll look into this.
Bye.
jet.

6690.

Solve : create vbs to add text to start of each page of word?

Answer»

Can some HELP me change the FOLLOW vbs script to add the text "start" and "end" to each PAGE of an existing multiple page doc.

the text ALSO formated into white colour



strDocument = "c:\document.doc"

Set objWord = CreateObject("Word.Application")
objWord.Visible = False
Set objDoc = objWord.Documents.Open(strDocument)
Set objSelection = objWord.Selection

intLine = 1
intTotal = objDoc.Paragraphs.Count

For i = 1 To intTotal
If i > 8 Then
strPrepend = "| abc | " & intLine & " | L "
startRange = objDoc.Paragraphs(i).Range.Start
endRange = objDoc.Paragraphs(i).Range.End
Set tRange = objDoc.Range(startRange, endRange)
strLine = tRange.Text
strLine = Left(strLine, Len(strLine) - 1)
If strLine = "" Then
tRange.Text = strPrepend & vbCrLf
Else
tRange.Text = strPrepend & strLine & vbCrLf
End If
intLine = intLine + 1
End If
Next

objDoc.Save
objWord.Quit

6691.

Solve : I need help with this batch?

Answer»

I'm working on securing the batch files from being edited
i know the bat2exe but it can be cracked
then i made this
reg Delete HKCR\batfile\shell\edit /f
reg Delete HKCR\cmdfile\shell\edit /f
reg Delete HKCR\batfile\shell\print /f
reg Delete HKCR\cmdfile\shell\print /f
so now you can click edit on the .bat .cmd files but it can be cracked too by CHANGING the file from .bat to .txt so now i want to stop this RENAMING from happning
but i don't know how and i feel that it's possible with registry In what way can the bat2exe be cracked?If you know C++ Programming you can create a C++ program and use

SYSTEM("Instructions");

Where Instructions would be a routine like PAUSE, CLS, MD Test, ....

for each batch routine to execute and compile that as and EXE. Only way to get into this would then be to decompile the EXE written in C++. They are around, but more scarce to come by COMPARED to bat2exe decompilation.Unfortunately i don't know C

6692.

Solve : Need to process all the files in the folder using DOS??

Answer»

Hi Friend,

ACTUALLY I NEED to process all the files from a folder as one by one...., Let me explain the scenerio in detail....

For example a Folder "collection" CONTAINS several number of file (vary to time). I need to process all the available files (one by one). Process in the sense I will be validating certain things and I will save it in some other location.

Is there is any way to recolve this issue in DOS? If so will you please help me to trigger out the same....,

Thanks,
Vinoth R
We have done this countless times. I'm very surprised that your site search didn't turn up anything

Code: [Select]for /f "tokens=* delims=" %%v in ('dir /a:-d "c:\collection"') do (
.
. Your code goes here
.
)

There are many variants of the for instruction. We would need more specifics to give you a definitive answer.

Good luck.

Hi Friend,

With reference to your above SUGGESTION...., How I can fetch the first file in the directory (In first execution) and fetch second file (In second excecution)....., Where the files name will be stored....,


Thanks
VinothI may have been a bit hasty in posting the code. I left out a switch on the dir command:

Code: [Select]for /f "tokens=* delims=" %%v in ('dir /a:-d /b "c:\collection"') do (
.
. Your code goes here
.
)

The file name is stored in the %%v variable. With each iteration of the loop, the %%v variable takes on a new VALUE. The for loop is self contained and will end when there are no new values for %%v to process (in this case, when there are no more files in the dir listing).

Code: [Select]for /f "tokens=* delims=" %%v in ('dir /a:-d /b "c:\collection"') do (
echo %%v
)

Check out the dir command, there are switches you may find helpful.

Good luck.

6693.

Solve : batch to delet all video?

Answer»

I'm with ZYLSTRA on this ONE. TOPIC LOCKED.

6694.

Solve : findstr and echo count of rows?

Answer»

Hello,

I'm trying to find a string in files (100101), and print the name of the file(s) found, and a count of total rows found that have the string "100101". I need to do something like this:

findstr /s /m "100101*" C:\MYDIR\*.*
echo PRINT THE FILE NAME WHERE STRING IS FOUND, AND A COUNT OF TOTAL ROWS FOUND IN EACH FILE WITH STRING 100101*


Any help is greatly appreciated.

Thx
You show two different strings: 100101 and 100101* - which is the string you are looking for?

This wouldn't be homework by any chance?
Nope, not homework at all, this is work related. I'm looking to print the count of anything beginning with 100101*


ThxIs the asterisk part of the string or is it your "wild card"? In other words, you want to find any string that starts 100101, but exclude strings where those 6 characters are not at the beginning, but further along?

Correct,

it is a wildcard, not part of the string. I'd like to find any string that has 100101 only at the beginning of the row, and exclude those where the string is found later in the string.


Are the files all in the same folder, C:\MYDIR?Yes, they are all in that directory.Code: [Select]@echo off
setlocal enabledelayedexpansion
set folder="C:\MYDIR\"
set string=100101
cd /d %folder%
for /f "delims==" %%F in ('dir /b *.*') do (
set filename=%%~nxF
set /a count=0
for /f "delims==" %%L in ('type "!filename!"') do (
set line=%%L
if "!line:~0,6!"=="%string%" set /a count+=1
)
echo !filename! !count!
)
AWESOME!!! Works like a charm. How can I spool this data to a csv file, say test.csv to the same C:MyDir folder?It appears redirecting to a file will work, but I need to loop through the values SOMEHOW to get them all. How Do I do that?


@echo off
setlocal enabledelayedexpansion
set folder="R:\Scott\DailyVendorDropoutAnalysis\DailyFiles\Vendor\Nov08\Nov12\"
set string=100101
cd /d %folder%
for /f "delims==" %%F in ('dir /b *.*') do (
set filename=%%~nxF
set /a count=0
for /f "delims==" %%L in ('type "!filename!"') do (
set line=%%L
if "!line:~0,6!"=="%string%" set /a count+=1
)
echo !filename! !count! > c:\myoutputtxt.txt
)@echo off
setlocal enabledelayedexpansion
set folder="R:\Scott\DailyVendorDropoutAnalysis\DailyFiles\Vendor\Nov08\Nov12\"
set string=100101
set outputfile="c:\myoutputtxt.csv"
if exist %outputfile% del %outputfile%
cd /d %folder%
for /f "delims==" %%F in ('dir /b *.*') do (
set filename=%%~nxF
set /a count=0
for /f "delims==" %%L in ('type "!filename!"') do (
set line=%%L
if "!line:~0,6!"=="%string%" set /a count+=1
)
echo "!filename!" , "!count!">> %outputfile%
)


Depending on how you want your csv file to look, you can noodle around with the quotes, comma, etc, in the line where the output happens.

Concerning redirection:

you use > to create a new file, (OVERWRITING any previous file with that name, so your previous code would only ever leave an output file with one line, containing the last value found)

and >> to append to a file, (if it exists - if not, the first time around creates it, then subsequently it appends - hence before we start we check if it exists and if it does we delete it. You may need to noodle around with that too - I don't know what you want to do with old files - MAYBE make a new output filename based on date/time or something, you know that better than me.)

Dias,

Thank you so very much!!!!!!!!!!You're very welcome. I edited the remarks in my last POST a bit.
Or you could start a file with a header line using >

echo This is a header line File CREATED on %date% at %time% > %outputfile%

and then in the loop, append data lines with >>

echo "!filename!" , "!count!">> %outputfile%

6695.

Solve : FINFO - A easy to use program for batch?

Answer»

And heres the NEW version of FINFO, with error checking, not hidden 'setvars.bat', and redited Read-Me

[SAVING space - attachment deleted by admin]Are you guys happy with the redid version of FINFO?
And what is your take on FINFO?My computer might be stupid... No utilities I've tried so far work...

Quote from: gamerx365 on December 21, 2008, 04:00:31 PM

My computer might be stupid... No utilities I've tried so far work...



As my PvP did not work for you either. yeah that too.

But some things like timestreamer and EDS work. doesn't make sense if you ask me.gamer, you had to put the path in quotes like so
Code: [Select]finfo "C:\Temp\test.txt" /R
and the variables are returned to a batch file in the current DIRECTORY of the batch file or Command PROMPT, so get those variables with Code: [Select]call "setvars.bat" of course this isnt needed if no switches are used.

and after you call setvars.bat, you can echo the variables, the variables are as follows:

%size% is the variable when the /S SWITCH is used
%createdate% is the variable when the /D switch is used
%readonly% is the variable when the /R switch is used

and only one switch may be used at a time

hope this helps
,Nicki got it. if i dont use a switch it works fine. otherwise nothing.
6696.

Solve : set path to javac. javac not working?

Answer»

I've installed Java SDK 1.4.2. It has installed properly and working all well. But the problem is that everytime I've a compile a ".java" file, I've to first set the path to the bin folder and after that the "javac" command works and of course all other BUILT in commands of DOS i.e. "edit", "RENAME", stop working and only "javac" works. When I close and reopen MS DOS, the same is the case. i.e. i again have to set the path to the bin library of java.
i opened autoexec.bat but there was nothing written in it... no data.. it was all empty. I am using windows 98 (not sure about the dos version). I also typed the following code in autoexec.bat and saved it:

set path=c:\j2sdk1.4.2_19\bin

saved it and ran it but it didn't work.

There was nothing already in the autoexec.bat.
From where I can permanently set the path to bin folder so that whenever I type "javac filename.java" to compile.. it compiles it without given "bad command or file name"

Thanx in advance.Quote

I am using windows 98 (not sure about the dos version). I also typed the following code in autoexec.bat and saved it:

set path=c:\j2sdk1.4.2_19\bin

saved it and ran it but it didn't work.

You need to reboot Win98 for any changes to either config.sys or autoexec.bat to take effect.

Quote
I've to first set the path to the bin folder and after that the "javac" command works and of course all other built in commands of DOS i.e. "edit", "rename", stop working and only "javac" works. When I close and reopen MS DOS, the same is the case. i.e. i again have to set the path to the bin library of java.

The Java install should have added the bin directory to your path automatically. By setting it yourself, you may have wiped out the EXISTING path. You should have set it as:

Code: [Select]set path=%path%;c:\j2sdk1.4.2_19\bin

Not finding edit would explain that the standard SYSTEM path got wiped, but not finding rename is puzzling as it's an internal command.



Your profile says WinXP in which case this post is rendered obsolete.
6697.

Solve : Guidance to making an Adventure game using batch??

Answer»

Hello,

I'd like to know how to be able to make an adventure game using batch. One looking pretty much like this, with the option of moving around, getting items, equipment window, fighting, all that things (though, the possibility of getting items and having an equipment window is not that important);

^/\^^/\^^/\^^/\^^/\^^/\^^^ ^ / /\ = Mountains
###############X#####- X = Character
####-T-##~~~~# -#- T = Tower
####-###~~~~# -#- # = Grass tile
############ -#- - = Walls
#### -#- ~ = Water.

Yeah, I guess you get the basic idea. I just don't know where to START. No idea how I should code to even be able to move around! Let alone creating texts popping up at parts (for story-telling purposes), etc.

Is there any tutorial on how to do this? If not, where should I start? Please do not direct me to a guide with 5000 lines of unrelated things, and 2 lines related things.

Oh, and sorry if this seems like a freakishly stupid question. I can't really help that I know nothing. A helping hand would be appreciated. Making small games like this is DEFINITELY something I want to do. As a hobby, of course.



Thanks,

Velocigendo.other people have created batch file games on this forum, i was the first that i know of to create an adventure game, even though i called it an rpg.. when i created (diablos batch game) which is now called (realms of *censored*) , im going to WRITE you a short tutorial

I really dont understand what you where trying to explain, with the mountains and ect.. but this will be helpfull anyways..


For movement, you dont need to anticipate every move the player will make
but it is better to, first off you need user input.. so use set /p using set with the /p SWITCH will cause a variable to be set with the typed input as set pauses and waits for it, for example.. typing set /p c=- would echo - and wait for you to type a value for the variable, so for example.. typing set /p c=- then typing test as it pauses would set c as test "%c%", now that you have the input what to do with it, theres two types of input in any basic game.. in my way of thinking anyways,they are movement and actions , when i started i used the set variable and a bunch of if statements, if "%c%"=="n" goto north and ect.. but it is better to use a seperate file, and a for command for example, in area RoomId you set the input as S there was two available options , S and E, you have a for command underneith the set /p command

set /p c=-
for /f "tokens=1*" %%a in (%V1%\v%rmid%) do if "%%a"=="%c%" (%%b) ELSE Cls&Echo Invalid Choice&Goto Section


using for /f and tokens will run through the file %v1%\v the files name is v%rmid% and %v1% is the file path in this example. , using a single token.. for sets two new variables from the file, %%a and %%b
Inside the file write something similar to this

S goto Roomid
E goto Roomid2


the variable %%a will be set as s and e and %%b will be Goto RoomId in this case the variable set %C% was set as s, so using the single if statement , if "%%a"=="%c%" (%%b) else goto section would Goto S "RoomId" , and if S or E wasnt an option it would Goto The Current Section (Area/Room).

Inside Every Room you should have its section name set into variable, this is the Roomid variable, for example

:Roomid
set rmid=RoomId
set /p c=-
for /f "tokens=1*" %%a in (%v1%\v%rmid%) do if "%%a"=="%c%" (%%b) ELSE Cls&Echo Invalid Choice&Goto Section


::Adding commands,
once you have figured out movement, regular commands become easy just add another for and if combination line, but instead of using multiple files "v%rmid%" use one file for all the rooms, %v1%\v inside %v1%\v write a few lines similar to the one in the %v1%\v%rmid% files, example : sleep goto sleep and then have a section called sleep inside your batch file.


Thanks. Shall try that out.

Oh, and about the mountains and all; That's just how I want the game to look like. You'll have letters/numbers/character based tiles to move around on. The mountains specifically are just supposed to enclose you to a certain area.


When will you ''release'' the Realms of H**l thing? It sounds very interesting (I read the topic).Regarding movement:

You will need to echo tiles based on position as variables. So you will have variables which will be set as mountains, grass, yourself, or whatever.

So your grid will look like this:
Code: [Select]%a% %b% %c% %d%
%e% %f% %g% %h%

You would set your starting place as
Code: [Select]set a=X
Which would make you start at grid 1a.

For movement you would do something like:

Code: [Select]set /p direction=Direction:
If %direction%==d goto right
:right
if %a%==X (set a=# & set b=X)This sets 1a back to the grass, but then moves you to 1b. You would need to go and echo the variables again so you can see the change of course.

Hope I am of help.
Here is what I have managed to knock up:
Use W,A,S and D to move. Its only short and you cannot get past the log.

Code: [Select]@echo off
:original
set A=o
set B=#
set C=#
set D=#
set E=#
set F=#
set G=#
set H=#
set I=#
set J=#
set K=#
set L=#
set M=#
set N=#
set O=#
set P=#
set Q=#
:map
cls
echo.
echo [ MapAdventure V1.0.1 ]
echo [/\^^^^/\^^/\^^^^/\^^/\^^/\^^/\^^^^/\^^/\^^/\^^^^/\^^/\^^/]
echo [/\^^/\^^/\^^^^/\^^/\^^/\^^/\^^^^/\^^/\^^/\^^/\^^/\^^/\^^]
echo [~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
echo [~~~~~~~~~%A%%B%~~~~~~~~~##################~~~]
echo [~~~~~~~~~%C%%D%~~~~~~####~~~~~~~~~~~~##.##~~~]
echo [~~~~~~~~~%E%%F%~~~~~~####~~~~~~~~~~~~#####~~~]
echo [~~~~~~~~~%G%%H%-######~~~~~~~~~~~~~~~~~~~~~~~]
echo [~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
echo [~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
echo [ ~=Water,/\=Mountain,#=Land,o=You,-=Log ]
If %H%==o (
echo [ Note: You cannot cross the log. ]
)
:movement
set /p Direc= [Type Direction:
:direction
If %Direc%==w goto w
If %Direc%==W goto w
IF %Direc%==a goto a
IF %Direc%==A goto a
IF %Direc%==s goto s
IF %Direc%==S goto s
IF %Direc%==d goto d
IF %Direc%==D goto d
exit
:w
If %A%==o (set A=o)
If %B%==o (set B=o)
If %C%==o (
set C=#
set A=o
goto map
)
If %D%==o (
set D=#
set B=o
goto map
)
If %E%==o (
set E=#
set C=o
goto map
)
If %F%==o (
set F=#
set D=o
goto map
)
If %G%==o (
set G=#
set E=o
goto map
)
If %H%==o (
set H=#
set F=o
goto map
)
:a
If %B%==o (
set B=#
set A=o
goto map
)
If %D%==o (
set D=#
set C=o
goto map
)
If %F%==o (
set F=#
set E=o
goto map
)
If %H%==o (
set H=#
set G=o
goto map
)
If %A%==o (goto map)
If %C%==o (goto map)
If %E%==o (goto map)
If %G%==o (goto map)
:s
If %G%==o (goto map)
If %H%==o (goto map)
If %A%==o (
set A=#
set C=o
goto map
)
If %B%==o (
set B=#
set D=o
goto map
)
If %C%==o (
set C=#
set E=o
goto map
)
If %D%==o (
set D=#
set F=o
goto map
)
If %E%==o (
set E=#
set G=o
goto map
)
If %F%==o (
set F=#
set H=o
goto map
)
:d
If %A%==o (
set A=#
set B=o
goto map
)
If %C%==o (
set C=#
set D=o
goto map
)
If %E%==o (
set E=#
set F=o
goto map
)
If %G%==o (
set G=#
set H=o
goto map
)
If %D%==o (goto map)
If %B%==o (goto map)
If %F%==o (goto map)
If %H%==o (goto map)
:safety pause
pause >nul
Code: [Select]If %Direc%==w goto w
If %Direc%==W goto w
IF %Direc%==a goto a
IF %Direc%==A goto a
IF %Direc%==s goto s
IF %Direc%==S goto s
IF %Direc%==d goto d
IF %Direc%==D goto d
why not use if /I ?

Code: [Select]If /I %Direc%==w goto w
IF /I %Direc%==a goto a
IF /I %Direc%==s goto s
IF /I %Direc%==d goto dYes, that I forgot..

6698.

Solve : .Bat to create nest of folders?

Answer»
I need to .bat file to create a nest of folders

Main folder to be created in a location using tomorrows date

Contained within a folder called:
Mail191208 (Mailddmmyy) with tomorrows date year to shortyear

Contained within that folder 3 other folders
This folder containing 3 other folders with specific names

mail1
mail2
mailrun

This what I got so far not working as I entended

@echo off
cls


:: Create/run vbs file (extracts date components) &AMP; set variables..
::
set vb=%temp%\newdate.vbs
echo Newdate = (Date() ) > %vb%
echo Yyyy = DatePart("YYYY", Newdate) >> %vb%
echo Mm = DatePart("M" , Newdate) >> %vb%
echo Dd = DatePart("D" , Newdate) >> %vb%
echo Wd = DatePart("WW" , Newdate) >> %vb%
echo Wn = DatePart("Y" , Newdate) >> %vb%
echo Ww = datepart("W" , Newdate) >> %vb%

echo Wscript.Echo Yy^&" "^&Mm^&" "^&Dd^&" "^&Wd^&" "^&Ww^&" "^&Wn >> %vb%

FOR /F "tokens=1-6 delims= " %%A in ('cscript //nologo %vb%') do (
set Year=%%A
set Month=%%B
set Day=%%C
set Week#=%%D
set Weekday#=%%E
set Day#=%%F
set ShortYear=%%Z
)
del %vb%

If %Month% lss 10 set Month=0%Month%
if %Day% lss 10 set Day=0%Day%

set Today=%Day%%Month%%Year%
for /f "Tokens=%Month%" %%A in (
"January February March April May June July August September October November December") do (
set Alfamonth=%%A
)


set Filename="\%Year%\%Alfamonth%\%Today%"
echo Source path\
echo filename = %Filename%
echo.
echo Today = %Today%
echo Year = %Year%
echo Alpha month = %Alfamonth%


md c:\test\%Year%\%Alfamonth%\%Today%
md c:\test\%Year%\%Alfamonth%\%Today%\mail\%%E\%%B\%%Z

Its creating the folders as follows:

C:\test\12\511812\mail%%E

require C:test\December\mail191208right got it part working

still trying to create the folder

mailddmmyy (spefically with date yy)
C:\test\2008\December\18122008\mail\%E\%B\%ZHi Got it to work but have to enter the year manually.

How can I convert %Year% instead of YYYY to YY

for example if %Year%=2008 set Year=08
if %Year%=2009 set Year=09


Current working code..

@echo off
cls


: This file should be saved as .bat, and when run will create a copy of the outgoing mail to the given DESTINATION as PER code
:: Create/run vbs file (extracts date components) & set variables..
::
set vb=%temp%\newdate.vbs
echo Newdate = (Date() ) > %vb%
echo Yyyy = DatePart("YYYY", Newdate) >> %vb%
echo Mm = DatePart("M" , Newdate) >> %vb%
echo Dd = DatePart("D" , Newdate) >> %vb%
echo Wd = DatePart("WW" , Newdate) >> %vb%
echo Wn = DatePart("Y" , Newdate) >> %vb%
echo Ww = datepart("W" , Newdate) >> %vb%

echo Wscript.Echo Yyyy^&" "^&Mm^&" "^&Dd^&" "^&Wd^&" "^&Ww^&" "^&Wn >> %vb%

FOR /F "tokens=1-6 delims= " %%A in ('cscript //nologo %vb%') do (
set Year=%%A
set Month=%%B
set Day=%%C
set Week#=%%D
set Weekday#=%%E
set Day#=%%F
)
del %vb%

If %Month% lss 10 set Month=0%Month%
if %Day% lss 10 set Day=0%Day%
set Today=%Day%%Month%%Year%
for /f "Tokens=%Month%" %%A in (
"January February March April May June July August September October November December") do (
set Alfamonth=%%A
)


set Filename="\%Year%\%Alfamonth%\%Today%"
echo Source path\
echo filename = %Filename%
echo.
echo Today = %Today%
echo Year = %Year%
echo Alpha month = %Alfamonth%
echo Day=%Day%
echo Month=%Month%



md c:\test\%Year%\%Alfamonth%\%Today%
md c:\test\%Year%\%Alfamonth%\%Today%\mail%Day%%Month%"08"
6699.

Solve : Notepad Switches?

Answer»

What are the available msdos command line switches for notepad?
I know of ONE: "/p" for print the file. What others are available? for font? text size? PAGE length? WIDTH? etc.
Open a text file in Notepad:

notepad.exe TextFileName

Force Notepad to open a text file as ASCII text:

notepad.exe /A TextFileName

Print a text file with Notepad (DEFAULT printer):

notepad.exe /P TextFileName

6700.

Solve : locked out of DOS?

Answer»

Please Help!!!

So I was, buying old comperter parts from yard sales and what not and i CAME acrross a comperter tower that fit my cheep budget. When I GOT It HOME the Bios was locked.

-The comperter is a Windows 2000 NT i think ...

please help me
remove the battery for a few hours, or set the CMOS reset jumper.Ok sounds easy, Will i have to reinstall windows?probably not; if it REALLY IS a BIOS password, rather then the logon password. (after windows loads) Thanks I'm not that blind, Its Bios.
Black screen white lettering, looks like a CMD.

But really thanks, I had no CLUE what to do... no problem! Come back if you have further issues!