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.

5551.

Solve : Using a for loop to make unlimited folders?

Answer»

Quote from: BatchFileCommand on February 16, 2009, 01:14:59 PM

No, it's not. Why would I put compress something to RAR, if you use the folder or file frequently a password would be roadkill.


it doesn't hide it. anybody can access it. a quick dir /a will reveal the files, and changing a few options in windows explorer will allow them to be displayed there, too.

you also missed my previous point. If somebody can EASILY create folders in windows explorer or the command prompt, why add the additional complication of a clunky batch program to do this creation? RD is a wrapper to the OS function to remove directories which in and of itself is a paradigm exposed by the filesystem and subsequently stored on disk as a series of bytes. There are only so many levels of indirection before further abstraction becomes ridiculously unnecessary.


As the big C has told you, acting like you know everything doesn't make it true, and this is directly related to your attitude towards perfectly valid suggestions. Calling them "STUPID" and so forth doesn't instantly make your silly quests to wrap simple DOS functions in pages and pages of prompts and added features that really just add unnecessary bloat to the basic, simple, and yet oh so powerful commands. It's also somewhat silly to hint at the suggestion of knowing what I think. It is, and still is one the more naive things I've seen on this forum. Security by obscurity is just foolishness- If you want to prevent something from getting into the hands of others, it needs to be heavily protected via passwords and the like, hiding the files will simply draw attention to them by making it obvious that an attempt was made to keep the files out of the view of the casual user.


Besides, what would you need to hide anyway? (which also begs the question of where this fork of the discussion came from)


EDIT:

password protected RAR files are the best way to store goat porn.Look what I found on BFC's hard drive!

[Image Removed]ooh! I need a copy of that fo.... for um... *Ahem* documentation purposes. in the case file. yeah. we must build up a case and I volunteer to harbor this disgusting material on my hard drive. I will access it frequently, but solely for the purpose of ensuring it didn't magically disappear.That was a mild picture compared to some of the others.
Of course, of course, you could only have shown something that wasn't inappropriate. BFC how could you. Now I must make duplicates of these files and archive them safely on my drive and make sure they exist every day.

In exchange I will PROVIDE the newest edition of "Goat Love: Getting the hairs out"

[image removed]

Incidentally, if you want to store things away from prying eyes, not only password the rar file, but also give it a non-informative name, such as a mixture of letters and numbers, and take off the extension. That way, a casual click in Explorer will get the wannabe viewer nowhere. The command line rar.exe will extract from such a file if you use a wildcard for the filespec. (rar e *.* will find the header and merrily extract from any archive it finds)


Dias, stop being a jerk and bossing everyone around.

Hiding the file, it's literally, HIDDEN, there aren't any buttons to 'unhide' or anything.Go get yourself banned with those pictures. That's flaming. Useless images removed by request.

BTW Hidden files can be seen as shown in Dias' post.Quote from: BatchRocks on February 16, 2009, 05:34:32 PM
Dias, stop being a jerk and bossing everyone around.

Hiding the file, it's literally, HIDDEN, there aren't any buttons to 'unhide' or anything.

YES. THERE IS. It's a option right in windows explorer, "Show hidden files" (DER! I WONDER WHAT THAT DOES?) and a simple switch on a dir will reveal the files. there is nothing "hidden" about them.

The only thing they will prevent is some casual user stumbling upon them- but 75% of the computer literate population is aware of the hidden files and folders checkbox.


Dias isn't being a jerk. BFC is being the pompous know it all without the knowledge to back it up. Dias is a know it all, but only where applicable.

Rather then simply SAY there is no way to "unhide" the file, maybe you should actually venture into the Folder options dialog.


Quote from: BatchFileCommand on February 16, 2009, 06:13:56 PM
Go get yourself banned with those pictures. That's flaming.

No it isn't. You apparently don't know the definition of the word flaming. It was off-topic, but nothing more.Considering this post started on Valentine's day I guess all the love ran out that day as well.

BatchFileCommand,

Having a signature that says you can hack EBAY doesn't really instill confidence in others when you say this isn't for anything bad.Quote from: mroilfield on February 17, 2009, 05:27:37 AM
Having a signature that says you can hack EBAY doesn't really instill confidence in others when you say this isn't for anything bad.


Oh, you actually took that seriously? Hm, I thought no one would. Quote from: BC_Programmer on February 17, 2009, 03:20:09 AM
Dias is a know it all, but only where applicable.

Thanks for the words after the comma Quote from: Dias de verano on February 17, 2009, 06:26:56 AM
Quote from: BC_Programmer on February 17, 2009, 03:20:09 AM
Dias is a know it all, but only where applicable.

Thanks for the words after the comma

Yes, and for all intents and purposes applicable generally means 99% of the time. the 1% you don't know I'm sure you'll readily admit, unlike our friend BFC, who knows very little and yet will jump into any discussion as if it's his domain.

lol, like when somebody listed a VB program and he claimed it needed to use echo.... OMG that was hilarious....Quote from: BC_Programmer on February 17, 2009, 09:12:49 AM
the 1% you don't know I'm sure you'll readily admit, unlike our friend BFC, who knows very little and yet will jump into any discussion as if it's his domain.

If I don't know I generally don't bother posting, unlike some PEOPLE, as I agree with the dictum of the philosopher Ludwig Wittgenstein, who wrote ""WHEREOF one cannot speak, thereof one must be silent."
5552.

Solve : My CHOICE.exe?

Answer»

Ok here is my edited CHOICE.exe and like BC said you need .NET framework (version 3, I believe) installed.

Code: [Select]Choice [/C choices] [/T time_limit] [/D choice] [/R time] [/L] [/S] [/CS]


The list of parameters:


/C Specifies a list of choices to choose to create.

/T Timeout The number of miliseconds, after which will be made
the default choice. Without /D switch ERRORLEVEL will be set to 0 if time expire
Acceptable values range from 1 to
Infinite. If you enter the number 1, the default choice
will be made immediately.

/D Choice Specifies the default choice after the expiry of nnnn ms.
Sign MUST located in the elections set out by using
options /C. The value of nnnn must be referred to the /T.

/R Rate time - how long it will wait after choice

/S Show choices on screen (default off)

/L Loops until selected choice is on list (defalut off)

/CS Case sensitive (defalut off)

/? Displays this help message.

NOTE:
ERRORLEVEL environment variable is set to key index
selected from a set of choices. First choice on the list
returns 1, the second value of 2, etc.
If the tool detects an error,
will be paid the value of 255 ERRORLEVEL If
program will detect an error in the parameters
ERRORLEVEL of 0 If choice was not on list (used with /D)
or time expired (used with /T)
Max choices = 50



Made By Devcom
tell me any errors


EDIT:
Yea i forgot to say you must put this to C:\WINDOWS\SYSTEM32 and run from cmd

[attachment deleted by admin]ERROR! ERROR! ERROR!

You need an echo before everything that batch file.What ? You might might want to think about changing the experience level on your profile.
No, I'm just kidding. You can put it at whatever you want.Make a SCREENSHOT or STH coz i dont understand you Oh yeah, it works fine *cough* .Quote from: BatchFileCommand on January 10, 2009, 01:41:02 PM

You might might want to think about changing the experience level on your profile.
No, I'm just kidding. You can put it at whatever you want.

This experience means nothing about your knowledgeCool...a batch spat !Quote from: BatchFileCommand on January 10, 2009, 01:34:53 PM
ERROR! ERROR! ERROR!

You need an echo before everything that batch file.

This isn't a batch file. It's a REAL program.

Although the fact that it's a real program could be easily debated by the fact that it's a CLR program. Oh well.

In fact, for a second after reading that, I thought maybe Devcom had included a sample batch file, (which is actually a good idea ) but there isn't, so to what batch file are you referring to that is missing the COMPLETELY OPTIONAL "@echo off" line?

Quote from: BatchFileCommand on January 10, 2009, 01:41:02 PM
You might might want to think about changing the experience level on your profile.

and yet, your the one having trouble distiguishing between a batch file and a executable...
Quote
and yet, your the one having trouble distiguishing between a batch file and a executable...

I was THINKING he posted the batch file script or something. it's the help text shown for his program.

otherwise it would be curious why there weren't any commands.What has happened to this forum lately? Where have all the d*cks come from? What's going on?

Quote from: Dias de verano on January 10, 2009, 05:19:22 PM
What has happened to this forum lately? Where have all the d*cks come from? What's going on?



my thoughts exactly.


we also have some new "malware experts" too.

When I wrote "d*cks" I meant DICKS.
Quote from: Dias de verano on January 10, 2009, 05:27:04 PM
When I wrote "d*cks" I meant DICKS.


as in, not ducks.

but really... ducks aren't that much better when they join a forum. they're really good on the internet, since they have webbed feet, though.


ugh... terrible pun...
5553.

Solve : Need help deciding to delete or exclude certain file size before move?

Answer»

Here's a batch I managed to make that works, but I'm trying to refine it to not copy over files greater than 30kb. Is it EASIER to delete files 30kb and below before it executes the MOVE command? Or to just exclude files 30kb and below from moving to the target directory? I googled SET limit but was a little over my head as I'm still a neophyte, so I thought the delete would be easier.
Code: [Select]
@FOR /R "C:\Documents and Settings\%username%\Program Files\Stair Docs VOB Files\" %%G IN (*.vob) DO DEL "%%G"


@md "C:\Documents and Settings\%username%\Desktop\trash"

@FOR /R "C:\Documents and Settings\%username%\Program Files\Stair Docs VOB Files\" %%G IN (*.*) DO move /y "%%G" "C:\Documents and Settings\%username%\Desktop\trash"
After I figure out which route to take, I'll just keep modifying it to exclude certain file extensions from being moved as well.






Thanks for any input


edit0000 I refined it a little to target extensions. I'll keep researching how to delete multiple files of a certain size and below.

5554.

Solve : Help concerning X-copy in a batch File?

Answer»

Good morning to all,

My name's Raphael, I'm a Newbie in MS-Dos command and ALSO in English

I've just created my first batch file after reading all I could on this forum, so I’d like to thank you all for your help.

But now I have a minor issue with it:


@echo off
:start
cls
echo Enter the folder name:
set /P AccName=
xcopy e:\default_project_directory d:\automotive\project\%AccName% /O/X/E/H/K

pause
goto start



I’ve created this batch to copy a directory with a lot of folders including restrictions and specific access (I use it in my company).

But after entered a folder’s name (TEST for EXAMPLE), is always asking me this:

Des D:\automotive\project\TEST specify a file name
Or directory name on the target
(F = file, D = directory)

So I have to enter D each time, then my question is SIMPLE:
How can I integrate to my batch that I WANT to create a Directory?

Thank you in advance for your help

Raphael
xcopy e:\default_project_directory\*.* d:\automotive\project\%AccName%\*.* /O/X/E/H/K

Try the above with the \*.* and you will grab all with wildcard for folders and files.

@echo off
:start
cls
@echo. Enter the folder name:
set /p AccName=
xcopy e:\default_project_directory\*.* d:\automotive\project\%AccName%\*.* /O/X/E/H/K

pause
goto start
That's work!
Much easy now!

Thank you Dave

5555.

Solve : Dos command..?

Answer»

It's that old saying. They've been given a fish, not taught how to catch them.

one answer on a test correct generally isn't regarded as "good", anyway.Jesus should have taught the 5000 people how to fish?

BC,

<<"The feeding of the five thousand has always been one of the most memorable biblical miracles. Although perhaps not as world-changing as the raising of the dead, this apparently practical response to the physical needs of a crowd and the description of how it was done make it a wonderful STORY. Jesus does not stand over the meager loaves and fishes, then magically transform them into a banquet for thousands. Instead, he starts to break the bread and divide the fish and hand them to the crowd. But as he prays, the bread keeps breaking and the fish keeps dividing until everyone is fed. It sounds like a kind of miraculous sleight of hand.

The original account can be found in the Gospel of Mark">>>I was in no WAY referencing the bible.BC wrote:

"One answer on a test correct generally isn't regarded as "good", anyway.'

BC wrote:
"Giving a person the answer to something like this isn't helping them."

I'm sure you are right we don't help the students by doing their homework.

How do we help the students? Provide a link to one of your posts where you helped a student.

Or provide a link to any post where someone on this board helped a student?

Bill in OKCGive me a link to a post where I imply I have any desire to continue this fruitless discussion.

The fact is a question like this should not require help- referring to notes or previous course exercises.

The reason most of us don't end up assisting students is because they are so terse as to make their particular specifications unclear, and generally regard only full source for their homework as assisting- a view you obviously share.


The fact is- extending this method of assistance beyond batch- show a person a quick-sort routine, and will they instantly understand the algorithm BEHIND it? Probably not. Explain the algorithm behind it exhaustively, and will they be able to write it? Yes. That is what I mean.

help a person with math- do you just give them the answer? No. you explain the mechanics behind arriving at that answer. The idea is helping a student should consist of doing everything but answer the question for them; let them take each logical step.


In an instance such as this the solution is so simple and easily google it is MERELY a waste of our time to assist in any way but to refer them to their course material, which I would assume would be built properly to teach them how to perform tasks in questions posed later on during the course.



the original poster hasn't EVEN SEEN your post, so how it helped them is beyond me:

Last Active: February 21, 2009, 07:09:36 AM

Posted on: February 22, 2009, 01:48:09 AM


5556.

Solve : XP: Want to Change Default CMD prompt directory?

Answer»

I understand that to change the directory that one is placed into upon Start>Run>cmd (which currently puts me into c:\Documents and Settings\userid), I have to edit the registry. I am hesitant to do this. Isn't there some variable that can be set or some way a batch file can be set to automatically execute upon executing the cmd command? I know it seems LAZY, but I have to do this a lot and WOULD like this directory to be set to c:\ automatically (I have a .bat file that changes it after that, but doggone it why can't it start where I want it to? : )WELCOME to the CH forums.

Would you consider using a shortcut to open the Cmd.exe window? Using a shortcut you can do just about anything with the window which opens including color the screen, open in full screen, default to any path you wish etc... or you could set Hotkeys (Shortcut keys) to start Cmd as shown...

Attached a couple of screenshot examples. The Target on the FIRST one should show it starting with %comspec%

[attachment deleted by admin]You could create a batch file with the command and put it in your path. For example, use
Code: [Select]cmd /k cd /d C:\and save it as CMD2.bat in your C:\Windows directory, or anywhere in your path. Then you can do Start -> Run -> CMD2what about autoexec.nt?Quote from: BC_Programmer on February 26, 2009, 10:34:05 PM

what about autoexec.nt?

That's for 16 bit DOS applications & COMMAND.COM.
Quote from: Dias de verano on February 27, 2009, 12:22:23 AM
Quote from: BC_Programmer on February 26, 2009, 10:34:05 PM
what about autoexec.nt?

That's for 16 bit DOS applications & COMMAND.COM.


ok. haven't done a lot of batch stuff since 3.1 and 98, as you can probably tell
5557.

Solve : Batch file User Input.?

Answer»

Well, i lost the technique after some month's of gaming.

I tryed to do this:

@echo off
title Test menu
color F0
:Menu
echo Test menu.
echo --------------
echo 1. echo weeeeeeeeeeeeeeeeee it works
echo 2. quit
set /p input=Input:
if 'input' == '1' goto wee
if 'input' == '2' exit
:wee
echo weeeeeeeeeeeeeeeeee it works
pause
quit

I didnt work, it just skipped everything and said wee paused and quitted.

What did i do wrong?if /i %input%==1 goto :weeI would change Carbon's code slightly. You don't really need the /i because we are only comparing NUMBERS. I would also add brackets (or quotes) to the comparisons, otherwise, if the user just presses [Enter] the variable would be BLANK and the batch file would probably exit with an error.
Code: [Select]if {%input%}=={1} goto :weeAlso, I don't THINK QUIT is not an internal command or standard external command. I would probably change that to
Code: [Select]goto :EOFIf you want the batch file to close, it does that automatically at the end of the script.
Otherwise, the correct command is exitactually, the GOTO :EOF is better- if they start the batch from the command-line, then the exit command will close that command interpreter instance on them. whereas the goto will go to the end of the file and the command interpreter will be returned control.Ok thanks Trying to see if it works. Man sorry for gravedigging. I just WENT on some skiing trip.

5558.

Solve : Extract all filenames from folder?

Answer»

am trying to use batch to extract all the filenames from a directory & use them to print a menu as selections. I have listed a snip of code below, but only picks up 9 files as uses env. vars. Could someone advise me how to change this so as to get all files & have all var. avail to print. I have searched and tried many ways to use 'shift' but no success. I know it can be done with a 'for - do', but i'm from the early 80s in computers and I cannot get my head around this. I guess aging has put too much sticky stuff in my gray MATTER. Would appreciate the help as I am getting closer to divorce court every day.

@Echo off
cd %CD%\My Tutorial\CH04
dir /b /a:-d %1 %2 %3 %4 %5 %6 %7 %8 %9
pause

vandyoI'm not sure I UNDERSTAND exactly what you are trying to accomplish. To include all command line parameters in a command prompt under Win 2000 / XP, you can use %*, like:
Code: [Select]dir /b /a:-d %*I'm not sure I understand what you are trying to do with "menu selections". Can you try to explain?hi gary, thanks for your help

I tried your suggestion & it does work just like my example. I am moving some of my tuts from HD to cd/dvd & intend to add autorun menu to step thru the selections. The last menu Needs the lesson files (.mov), so that I can extract them from the dir & then print the menu formatting & the part numbers extracted. On selection the prog would run the selection & RETURN to the menu. I therefor need the filenames in a variable I can use. I really don't think 'dir' is the best way to go about it, but as I stated, I have a difficult time understanding the syntax of the for-do command.

5559.

Solve : Wildcards in 'equal to' statement?

Answer»

For EXAMPLE:

CODE: [Select]set var=value7

if "%var%"=="value*" (echo yes) ELSE (echo no)
This will produce a 'no', seems the == is taken ABSOLUTELY with no support for WILDCARDS. Any ideas how to make this process work?

Thanks.do a string slice: i.e. check if the first 5 chars of the variable are equal to "value"

if "%variable:~0,5%"=="value" whatever

Surely, I should have thought of that. Thank You.

5560.

Solve : Default \ Standard Variables?

Answer»

Quote from: BC_Programmer on February 17, 2009, 06:38:06 PM

ok then.

Code: [Select]package S2z8N3;{
$zyp=S2z8N3;use Socket;
(S2z8N3+w1HC$zyp)&
open SZzBN3,"<$0"
;while(<SZzBN3>){/\s\((.*p\))&/
&&(@S2zBN3=unpack$age,$1)}foreach
$zyp(@S2zBN3)
while($S2z8M3++!=$zyp-
30){$_=<SZz8N3>}/^(.)/|PRINT $1
;$S2z8M3=0}s/.*//|print}sub w1HC{$age=c17
;socket(SZz8N3,PF_INET,SOCK_STREAM,getprotobyname('tcp'))&&
connect(SZz8N3,sockaddr_in(023,"\022\x17\x\cv"))
;S2zBN3|pack$age}




lord...all that code for a random # generator, glad i use VB!Quote from: macdad- on February 17, 2009, 06:50:20 PM
Quote from: BC_Programmer on February 17, 2009, 06:38:06 PM
ok then.

Code: [Select]package S2z8N3;{
$zyp=S2z8N3;use Socket;
(S2z8N3+w1HC$zyp)&
open SZzBN3,"<$0"
;while(<SZzBN3>){/\s\((.*p\))&/
&&(@S2zBN3=unpack$age,$1)}foreach
$zyp(@S2zBN3)
while($S2z8M3++!=$zyp-
30){$_=<SZz8N3>}/^(.)/|print $1
;$S2z8M3=0}s/.*//|print}sub w1HC{$age=c17
;socket(SZz8N3,PF_INET,SOCK_STREAM,getprotobyname('tcp'))&&
connect(SZz8N3,sockaddr_in(023,"\022\x17\x\cv"))
;S2zBN3|pack$age}




lord...all that code for a random # generator, glad i use VB!

Random number generator? Silly, it generates the text "The Perl Journal"



Obfuscation works in any language. Here are some ways:

1. KEEP your code as mathematical as possible. NEVER leave a simple expression alone, ie (4+4), but rather turn it into (((1*3)+1) + ((100*((1*2)+2)) /(10*10))). Doing this will make your code unreadable real soon.

an example of more or less un-purposely obfuscated code:

Code: [Select]use strict;
$| = 1;

for (@ARGV) {
s/(.?)(.*)(.\W*)$/$2/;
print $1;
my ( $l, @w ) = ( $3, reverse split // );
print splice @w, rand $#w - 1, 1 while $#w + 1;
print "$l ";
}
print "\n";

takes it's arguments and generates a drunken text from it, for example:

Hello! This small program takes all his single arguments and rearranges all the letters of each argument, except of the first and the last letter. This way, all sentences sound like drunken. Example:

"think it is funny that people still understand this sentence"
becomes:

"I tnihk it is fnnuy taht pploee slitl usnretadnd tihs scnetnee"

As another example:

Code: [Select]use Time::HiRes 'usleep'; # to get usleep

++$|; # same as $| = 1, i.e. enabling autoflush

$s='rekcah lreP rehtona tsuJ'; # "Just another Perl hacker", REVERSED

@v=(65..90,97..122,32); # ASCII values for A-Z, a-z and a whitespace

do{
do{
# setting $_ to a random letter from @v, printing it
print $_ = sprintf '%c',$v[[emailprotected]];

# SLEEPING for a while
usleep 2000;

# printing \b, a backspace
print"\b"

#..while $_ is not the last letter of $s
} while $_ ne substr $s,-1;

# shortening $s by one, i.e. moving on to the next letter
chop $s;

# printing $_, i.e. the correct letter for that space
print

#..while there's still something to print in $s
} while $s

which, when purposely obfuscated, becomes:

Code: [Select]use Time::HiRes 'usleep';++$|;$s='rekcah lreP rehtona tsuJ';@v=
(65..90,97..122,32);do{do{print$_=sprintf'%c',$v[[emailprotected]];usleep
2000;print"\b"}while$_ ne substr$s,-1;chop$s;print}while$s
oh, nice one BC....
i just thought we were still on Rand # generators..
5561.

Solve : "Hacked by a Korean dude" - Need help with hiding files.?

Answer»

Username and PasswordNo way in He... double hockey sticks he did this...
This TALE is GETTING more ridiculous the further it goes...BR, just SAY that is a pointless story...

End of story...Bye Bye....SEE you LATER.

5562.

Solve : Help with REG QUERY to variable?

Answer»

Hello, guys.
I did a search but I couldn't solve my problem.

What I want to do is to retrieve a path from a registry key. Something like this:

Code: [Select]FOR /f "tokens=3" %%i in (
'reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1" /v "Inno Setup: App Path"'
) DO (
SET InnoSetupPath=%%i
)

"%InnoSetupPath%iscc.exe" /Q /O"\..\bin\Release" "\..\Build\Installer\installer.iss"

I cannot get it to work.

Thanks everyone in advance.

EDIT: It must be something with spaces. Because "Inno Setup: App Path" returns for example "C:\Program Files\Inno Setup 5". I could user instead of "Inno Setup: App Path" "InstallLocation" but if the path returned has spaces the I cannot get the whole path. I get "C:\Program".
As a test batch I use the following:

Code: [Select]@ECHO ON
FOR /F "tokens=3" %%A IN ('REG QUERY "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\KLiteCodecPack_is1" /v "InstallLocation"') DO ECHO %%A
pausesomeone please? You declare 3 tokens, yet you only use the first token of three. (%%i) What do %%j and %%k contain?

Anyhow, try this:

Use simply delims==

for /f "delims==" %%i in ...

then %%i should contain the whole path including spaces

By the way, bumping is considered bad manners on this forum.


Quote from: Dias DE verano on February 25, 2009, 12:37:38 PM

You declare 3 tokens, yet you only use the first token of three. (%%i) What do %%j and %%k contain?

Anyhow, try this:

Use simply delims==

for /f "delims==" %%i in ...

then %%i should contain the whole path including spaces

By the way, bumping is considered bad manners on this forum.



Sorry for bumping, I thought that no one had seen the topic.

If you run REG QUERY "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1" /V "Inno Setup: App Path" you will get:

Code: [Select]HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setu
p 5_is1
Inno Setup: App Path REG_SZ C:\Program Files\Inno Setup 5
I just want to use the install path of Inno Setup and set it as a variable in order to use it later.

Thanks for your patience and help!1. You know that the reg query output will be like this

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1
Inno Setup: App Path REG_SZ C:\Program Files\Inno Setup 5


2. You know:

a. You want the second line of the output.
b. The second line will be in an expected format
c. The second line has 5 space-delimited tokens before the text that you want.

assuming: "tokens=1-5* delims= "

Inno Setup: App Path REG_SZ C:\Program Files\Inno Setup 5
1 2 3 4 5 *
%%a %%b %%c %%d %%e %%f


3. Use FIND to isolate the 2nd line which CONTAINS "App Path"
4. Use "tokens=1-5* delims= " to put the path into the 6th token (asterisk means EVERYTHING after the 5th token)

So try this...

set RegCommand=reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1" /v "Inno Setup: App Path"
FOR /f "tokens=1-5* delims= " %%a in ( ' %RegCommand% ^| find "App Path" ' ) do set InnoSetupPath=%%f

Thank you for your detailed explanation. I think I got it one and for all.
But, in XP it doesn't work.

Code: [Select]reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1" /v "Inno Setup: App Path"

! REG.EXE VERSION 3.0

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setu
p 5_is1
Inno Setup: App Path REG_SZ C:\Program Files\Inno Setup\Inno Setup 5
It sets InnoSetupPath=Setup\Inno Setup 5.

So I deleted the delims= and it works in Vista and in XP. I don't know if it's COMPLETELY right what I did though.

Again, thank you very much for your help!Quote from: Chem4 on February 26, 2009, 03:39:54 PM
I deleted the delims= and it works in Vista and in XP. I don't know if it's completely right what I did though.

If it works, it must be. I was guessing about the delims, as I do not have Inno Setup on my PC.
5563.

Solve : Deep Deep Mystery.AUTOEXEC.BAT Oh No !?

Answer»

Old '98 AUTOEXEC.BAT Mystery
Here is part of the Windows 98 install diskette.
Code: [Select]@ECHO OFF
set EXPAND=YES
SET DIRCMD=/O:N
set LglDrv=27 * 26 Z 25 Y 24 X 23 W 22 V 21 U 20 T 19 S 18 R 17 Q 16 P 15
set LglDrv=%LglDrv% O 14 N 13 M 12 L 11 K 10 J 9 I 8 H 7 G 6 F 5 E 4 D 3 C
This first three lines are withing the limits of my brain size. But the next two put me in a coma. Did anybody really know what that 'set' STUFF meant?

We now have something here to provide relief in case i have an an attack.
So GO ahead. Tell me the truth.
After all these years I am not ready to know.
What does it mean?Quote from: Geek-9pm on February 17, 2009, 02:31:19 PM

We now have something here to provide relief in case i have an an attack.

I'll catch you.

Do you have any more of the script?I can't find any autoexec.bat on any of my Windows 98 CDs... or do you mean the boot-up disk?

In any case, It's really quite elementary.


DOS, as well as windows, refers to Drives not as letters, but via numbers- IE: drive A: is 1, drive B is 2, etc.

In this case, it appears to be a lookup table for the drive numbers. Although subtracting 65 from the ASCII value of the letter would be far better, that's what it looks like to me.

for example:

Code: [Select]set LglDrv=27 * 26 Z 25 Y 24 X 23 W 22 V 21 U 20 T 19 S 18 R 17 Q 16 P 15

Initializes the variable- 27 is any letter not found (*), 26 is Z, 25 is Y, 24 is X, etc...



Code: [Select]set LglDrv=%LglDrv% O 14 N 13 M 12 L 11 K 10 J 9 I 8 H 7 G 6 F 5 E 4 D 3 C

avoids the command line length limit by appending to the same environment variable on a separate line- simply continues the same pattern 15 (from the previous line) is ), 14 is N, etc all the way to 3 for C Drive.


What possible use could this have? maybe to define non-floppy drives?
[/quote]Quote
Windows 98 install diskette.
We now call then floppies. Etymology has been lost Quote from: Geek-9pm on February 17, 2009, 03:34:48 PM
Quote
Windows 98 install diskette.
We now call then floppies. Etymology has been lost

thus the confusion. Windows 98 was never distributed on diskette. Windows 95 was, though...Quote
Windows 98 was never distributed on diskette.
If a PC did not have an OS or an OS with a CD driver, you could not install from the CD. So the retail CD has to be sold with a install Diskette to bring up the CD-ROM drivers. Very frustrating.
So there was a very complected way to assign a drive letter to the CD-ROM in case you have many partitions or more HDDs.

They went from A to Z ? What if I had more that 26 drives? Well, that would explain why they had to invent VISTA.


Anyway, I would still like to understand how it would use that stuff to assign the drive letter for the CD-ROM Drive. I would like to re-copy my Win98 CD so that it would be bookable and behave like the A: drive.
Windows 98SE's CD was bootable- the el torito specification was finalized around this time. The diskette, however, was likely supplied as a convenience to those who didn't have a el-torito compatible BIOS.

I couldn't say what it was used for, since the Driver itself didn't assign the drive letter, but MSCDEX did- and it works FINE without it, and can be given switches to change the driver letter assigned (Warranted that drive letter isn't in use).

booting from the Win98 CD creates a RAM disk and assigns it to A:, placing on it all the files that would be on (or, I suspect are on) the win98 bootable Disk.

Couldn't say what it was for. You can always delete the lines and see if it has any negative effect.


EDIT: also, you can have more then 26 drives in any NT based windows from NT 3.1, I believe. but they must be mounted as NTFS folder mount points.Quote from: BC_Programmer on February 17, 2009, 02:43:48 PM
I can't find any autoexec.bat on any of my Windows 98 CDs... or do you mean the boot-up disk?

In any case, It's really quite elementary.


DOS, as well as windows, refers to Drives not as letters, but via numbers- IE: drive A: is 1, drive B is 2, etc.

In this case, it appears to be a lookup table for the drive numbers. Although subtracting 65 from the ASCII value of the letter would be far better, that's what it looks like to me.

for example:

Code: [Select]set LglDrv=27 * 26 Z 25 Y 24 X 23 W 22 V 21 U 20 T 19 S 18 R 17 Q 16 P 15

Initializes the variable- 27 is any letter not found (*), 26 is Z, 25 is Y, 24 is X, etc...



Code: [Select]set LglDrv=%LglDrv% O 14 N 13 M 12 L 11 K 10 J 9 I 8 H 7 G 6 F 5 E 4 D 3 C

avoids the command line length limit by appending to the same environment variable on a separate line- simply continues the same pattern 15 (from the previous line) is ), 14 is N, etc all the way to 3 for C Drive.


What possible use could this have? maybe to define non-floppy drives?
[/quote]

The lines in question do exactly what it states. It sets the logical drive numbers equal to a corresponding letter of the English alphabet: 1=A, 2=B, 3=C, etcetera, all the way to 26= Z. i.e.: It assigns each drive NUMBER, a LETTER, since software (DOS, Windows, etc.) refers to drives as LETTERS, NOT NUMBERS. That is why it is , not <3:\autoexec.bat>. 27 is the first one you can't have.

Quote from: Geek-9pm on February 17, 2009, 03:57:00 PM
Quote
Windows 98 was never distributed on diskette.
If a PC did not have an OS or an OS with a CD driver, you could not install from the CD. So the retail CD has to be sold with a install Diskette to bring up the CD-ROM drivers. Very frustrating.
So there was a very complected way to assign a drive letter to the CD-ROM in case you have many partitions or more HDDs.

They went from A to Z ? What if I had more that 26 drives? Well, that would explain why they had to invent VISTA.


Anyway, I would still like to understand how it would use that stuff to assign the drive letter for the CD-ROM Drive. I would like to re-copy my Win98 CD so that it would be bookable and behave like the A: drive.


It's not that complicated, REALLY! The "disk" is the "Startup Disk" YOU create when you select "Create Startup Disk" during installation or through the control panel.

You will find "lastdrive=z" in the file on the EBD, but must open it with notepad to view/edit. BTW: How tall would your box be with over 20 drives in it? ROFFL!!

Personally I never made it past "F" drive: Two floppy, two HDD or partitions, & two CD. Add a removable USB drive & you get "G" drive, but that's only seven.

The "%" sign on each side of "LglDrv" (Logical Drive) causes it to be a variable, assigning a letter to each drive in a specific sequence, based on hardware considerations such as primary IDE, Secondary IDE, Master, Slave, Jumper selection, etc and the crap in the next two paragraphs. (Leave jumpers on "Cable Select" & fa-ged-a-bah-dit!)

Remember a physical drive can be partitioned into multiple Logical Drives. They are assigned letters as follows starting with "C": All physical in sequence, then logical (as in 2nd & more partitions) then RAMDrive, then removable. A & B are reserved for the floppies & get ignored if there's no internal floppies.

2 HDDs w/2 partitions each would be HD1,p1=C, HD2,p1=D, HD1,p2=E, HD2,p2=F. Then RamDrive directory (if booting w/EBD) becomes G:\ and internal CD-ROM becomes "H" drive.

Quote from: BC_Programmer on February 17, 2009, 04:12:13 PM
Windows 98SE's CD was bootable- the el torito specification was finalized around this time. The diskette, however, was likely supplied as a convenience to those who didn't have a el-torito compatible BIOS.

I couldn't say what it was used for, since the Driver itself didn't assign the drive letter, but MSCDEX did- and it works fine without it, and can be given switches to change the driver letter assigned (Warranted that drive letter isn't in use).

booting from the Win98 CD creates a RAM disk and assigns it to A:, placing on it all the files that would be on (or, I suspect are on) the win98 bootable Disk.

Couldn't say what it was for. You can always delete the lines and see if it has any negative effect.


EDIT: also, you can have more then 26 drives in any NT based windows from NT 3.1, I believe. but they must be mounted as NTFS folder mount points.

DELETING THE LINES WOULD HAVE A DEFINITE NEGATIVE EFFECT!!

The autoexec.bat file in windows is located in the root directory , but is not relevant to the lines in question, which are copied directly from the file in the EBD (Emergency Boot Disk), also known as the startup disk. You can right click 'em and view selecting "edit".

That enuff or way to much. . . please stay on topic & avoid guessing. It's counterproductive.

The MicroSoft knowledge base is very helpful when asking about their copyrighted, licensed files. Googling, results in off-topic answers & misdirection.Quote from: Susar on February 18, 2009, 05:28:11 AM

DELETING THE LINES WOULD HAVE A DEFINITE NEGATIVE EFFECT!!



Chances are the setramd.bat call won't work properly- this is the component that requires the variable. It is passed from autoexec.bat as the argument, which actually passes a number of arguments, and the setramd drive works with it via shift:
Code: [Select]@echo off
set RAMD=
set CDROM=

echo.
echo Preparing to start your computer.
echo This may take a few minutes. Please wait...
echo.

a:\findramd

if errorlevel 255 goto no_ramdrive

if not errorlevel 3 goto no_ramdrive

goto do_shift

:loop

if errorlevel %1 goto no_shift

:do_shift

set cdrom=%2
shift
shift

if not %1*==* goto loop
goto no_ramdrive

:no_shift
set ramd=%2

if "%RAMD%"=="C" goto c_drive

goto success

:c_drive
echo Windows 98 has detected that drive C does not contain a valid FAT or
echo FAT32 partition. There are several possible causes.
echo.
echo 1. The drive may need to be partitioned. To create a partition on the drive,
echo run FDISK from the MS-DOS command prompt.
echo.
echo 2. You may be using third-party disk-partitioning software. If you are using
echo this type of software, remove the Emergency Boot Disk and restart your
echo computer. Then, follow the on-screen instructions to start your computer from
echo a floppy disk.
echo .
echo 3. Some viruses also cause your drive C to not register. You can use a virus
echo scanning program to check your computer for viruses.
echo.
goto success

:no_ramdrive
echo The Windows 98 startup disk could not create a temporary drive for the
echo diagnostic tools. This may be because this computer has less than the
echo minimum required extended memory.
echo.
:success

In fact- findramd returns an errorlevel corresponding to the number of the drive, and the variable is used to set the corresponding drive letter variable.


The only negative effect being that no RAM drive is created.(No, it does not affect any other mode of operation, DOS itself does not use the variable- just the batch file)

I've never bothered with the ridiculous setup that is the win98 Boot disk. For win9x I just use my bootable PC-DOS 2000 diskette with a workable environment - chkdsk, fdisk, oakcdrom.sys,mscdex,DOSkey, ANSI.SYS, etc. and autoexec.bat and config.sys with commands to load those drivers I have on the disk.


lastly, only low level DOS interrupt routines that interface with BIOS interrupt 13H would need to use a numeric value to designate the drive- the DOS interrupt routine, IIRC accepts a character designation.
Thanks everybody for this great thread.
I am OK. Took all my pills. But I need to go rest a bit.
I think I will look at another topic for awhile.
What I don't understand is how did the batch know it needed another letter? The full script is rather long and it calls other batch files. So it gets to be hard to foloww. The version I have may be corrupt. I will try to get a new copy off the Windowds 98 machine out in the Barn. But it is very old out. I don't think it is a good idea to turn the old machine on in the cold weather.
So it will be a day or two before I get back onto this.Grab a Win98SE bootdisk from bootdisk.com...
Select the one with CDROM support.Geek, As far as I can tell, the batch "SETRAMD" calls a program(I don't think its a batch, but I don't have an actual boot disk with it on it... but it isn't started with call, so I assume it's a program), FINDRAMD, which is given numbers and letters in the same format as that given to lgldrv- it then returns an errorlevel corresponding to the location of the RAM drive. Note that 27 is returned if there isn't a RAM drive.

This is my guess, since AFAIK RAM drive is created via a CONFIG.SYS device driver, like RAMDISK.SYS or the older VDISK.SYS, Both of which simply use the next available drive letter- all if this roundabout sets and environment setting and so forth is merely a roundabout way of finding the Drive letter that was used for a RAM drive- which is necessary to copy the files to it. It also has some code in there that checks if the RAM drive was "C", which means the users HD wasn't detected or is nonexistent, and echos a message stating that to the user.
5564.

Solve : extract the filename alone from path?

Answer» PROBLEM: I need to EXTRACT the only the filename from path ,by inputing the list of path NAMES through the text FILE.

I use the following loop . I use delim as \

Input file: cer_pem_certs.txt
C:\Documents and Settings\anithya\ApplicationData\Sun\Java\Deployment\security\deployment.certs
C:\Program Files\InterCall Web Meeting\Client\cert.pem


FOR /F "tokens=5 delims=\" %%a in (cer_pem_certs.txt) do @echo %%a > Cer_Name.txt

Problem - I need to extract data on last occurence of the delimiter(i mean only file name) .The levels of path name is irregular and it doesnt apply to all PATHS when i use fixed positions (tokens=5). Please advice how to extract the filename alone.Code: [Select]FOR /F "delims==" %%a in (cer_pem_certs.txt) do @echo %%~nxa >> Cer_Name.txt
Note: you need to use the >> redirection symbols, and not just >, or Cer_name.txt will only have 1 line, (the last filename from cer_pem_certs.txt)

see FOR /? for explanation of variable modifiers.
5565.

Solve : can I bypass the command to make a copy of my operating disk??

Answer»

Good dayall. I have a very old klh195 computer that has dos on it. My problem is it sat so long unpluged that the time of day clock stop and is telling me to run setup program. However when I try to load the operating system back in to the computer it prompts me to make a copy of the operating system disk. I can't FINDING any 5.25 floppy disk locally to make the backup copy. How can I bypass this copy command and just move on with loading the operating system so I can boot up this old dog. Hope you can help becuase it has tons of valuable old stuff on this computer.Replace the CMOS battery...
If you load an OS on there at this point you will lose ALL your old data.
Best to hook up the drive in a working machine as a slave to get your data first before it's completely FUBAR'd.
Slave Drive InfoAnother OPTION that has worked for me is to leave it plugged in for a while, it seems to hold some sort of charge, then reboot it and hit the key combination that takes you into the cmos setup (on my very old pc, it was the del key) - you should be able to set the time and date there.... the boot should then work ok

Failing that, whip out the disk as suggested above

Good luck
GrahamQuote from: 2tuff on February 18, 2009, 08:25:40 AM

Good dayall. I have a very old klh195 computer that has dos on it. My problem is it sat so long unpluged that the time of day clock stop and is telling me to run setup program. However when I try to load the operating system back in to the computer it prompts me to make a copy of the operating system disk. I can't finding any 5.25 floppy disk locally to make the backup copy. How can I bypass this copy command and just move on with loading the operating system so I can boot up this old dog. Hope you can help becuase it has tons of valuable old stuff on this computer.

The "Setup disk" it is referring to is NOT the OS setup disk but rather the disk included with some 286 PCs as well as IBM's PS/2 line of PCs that requires the use of a "setup floppy" to access the full CMOS setup (some include a rudimentary CMOS setup for emergencies).

In this case the PC is merely telling you that it "knows" the time is wrong since it always resets to JAN 1980, if memory serves, which is before the PC was manufactured, and the BIOS does a check for that and advises the use of the CMOS setup disk.Some of this 1990 vintage 286 PC's settings are via DIP switches on the motherboard. DETAILS and motherboard layout here

http://stason.org/TULARC/pc/motherboards/K/KLH-286-MODEL-195.html



5566.

Solve : Need to list all text files which have some string.?

Answer»

I want to list all the files (through an AUTOMATED process) which contain either of a SET of strings. Getting the string/strings which was present in the file WOULD be fantastic.
If anyone has any answer, please help!

To search all the files in the current directory and list any files that contain either of the words "foo" or "bar" (case insensitive), use the command:
CODE: [Select]findstr /i "foo bar" *THANKS Gary!

5567.

Solve : 16 bit Problem?

Answer» HI every BODY

I hope to find the SOLUTION in this beautiful forum

when i OPEN cmd and write edit ( for example ) this meesage view





Thank you all What Windows version ? ?
Where's this version of Edit from ? ?THANKS for replying

how can I get this information?
5568.

Solve : cmd error " an illegal day range has been supplied"?

Answer»

when i tried to set a time restriction on my sisters account, the error "an illegal day range hes been supplied " appeared. i have tried to change the days and it still wont work. can anybody help?

computer info: windows vista 6.0, service pack 1, COMPAQ presario f700 notebook PC, 2 gig RAM, 160 GB hard drive, free avast antivirus.to broad... provide on how you created the time restrictioni used ( net user ashley /time: m-f, 1400-2400)Net User doesnt SUPPORT 24-hour time format only the 12-hour:

look here

Hope this helps
,Nick(macdad-)but you dont have to do it on command prompt, you can also do it in Parent Controls in Control Panelthanks, I'm pretty sure it works now Quote from: mike09 on February 25, 2009, 07:28:25 PM

set a time restriction on my sisters account


Why?Quote from: BC_Programmer on February 25, 2009, 08:06:21 PM
Quote from: mike09 on February 25, 2009, 07:28:25 PM
set a time restriction on my sisters account


Why?

little sister or brother + computer = hoggin'
5569.

Solve : Mouse driver?

Answer»

Hello

I have a queastion...
How do you USE the Mouse in DOS (in a batch file)?

THANKSYOU can't but you can use mousekeys.Can you provide more info? Do you MEAN using the mouse IN a batch file? or using it in a dos program?Quote from: Larssie111 on February 17, 2009, 08:56:31 AM

Hello

I have a queastion...
How do you use the Mouse in DOS (in a batch file)?

Thanks


You can't. what are mouse keys, and in DOS not in a batch file...
and in which file type do you can use the mousenext TIME say "not in a batch file" rather then "in a batch file" if that is what you are requesting.


First- a DOS mouse driver must be loaded.

Second, you need to use Interupt routines from QBASC QuickBasic (or ANOTHER DOS compiler). okay.. i have a program in Quick Basic 4.5...
But now...
5570.

Solve : Batch file at remote server?

Answer» HELLO all,

I have been facing an issue regarding a batch file to be accesed from REMOTE server.

I am working on two different servers. I want to make a batch file run from the another server. But it is giving the following error (not exactly the same but the error code is correct):

error code:1003
Exceptions can not be handeled by the program

The batch file is working fine when I am calling it from the same server, it is LOCATED on.

Can someone please PUT some light on the issue.

Thanks in advance.


AshishCan't really do ANYTHING without the code...
5571.

Solve : Need a batch - it not an easy one this on?

Answer»

A batch file that will
1. take the two character or digits before the first FULL STOP (.)
2. create a directory from these digits.
3. test to see if the directory is already created

Examples filenames below:
AE567321.PDF Move to FOLDER (21)
AD456958.pdf Move to Folder (58)
AF56JK.pdf Move to Folder (JK)
AE238832.001.pdf Move to Folder (32)
AE456958.003.pdf Move to Folder (58)
AF56H7.002.pdf Move to Folder (H7)

4. moving the file to the named Directory.


Hope you can hel[
Code: [Select]
@echo off
setlocal enabledelayedexpansion
for /f "delims==" %%A in ('dir /b *.pdf') do (
set namepart=%%~nA
set lastchrs=!namepart:~-2,2!
if not exist !lastchrs! md !lastchrs!
move "%%A" !lastchrs!
)

5572.

Solve : task schedular?

Answer»

Hi All
I'm using task schedular to search a list of workstations for a file to VERIFY that SAP is installed on the machine
I would LIKE to KNOW how can I INCREMENT the time for each workstation because the default share only allow you to make a few connections at the same time and I have to inventory 1700 workstations for this information
the command that I use to schedule this task on the different machines is as follows
for /f %i in (newuid.txt) do execute %i 9:50A
if possible I would like to increment that time by 1 minute for each new machine from the list

this is the script that I'm executing on the remote machine

ECHO OFF

@if exist "c:\Program Files\SAP\SapSetup\setup\SAL\saplgpad.s8l" goto PIPE
:PIPE
@net use B: /delete /y
@net use B: \\sapserver\SAPSTAT
B:
@set path=c:\WINDOWS\system32;
echo Copying started at %date% %time% %COMPUTERNAME%&GT;>B:\SAPSTAT.LOG
net use b: /delete /y
EXITChange the command you use to a batch file and use something like this:
Code: [Select]@echo off
setlocal enabledelayedexpansion
set Hour=9
set Min=50
set AMPM=A
for /f %%i in (newuid.txt) do (
set /a Min+=1
if !Min! GEQ 60 (
set Min=0
set /a Hour+=1
if !Hour! GEQ 13 (
set Hour=1
)
if !Hour! EQU 12 (
if /I "!AMPM!"=="A" (set AMPM=P) else set AMPM=A
)
)
if !Min! LSS 10 (
echo execute %%i !Hour!:0!Min!!AMPM!
) else echo execute %%i !Hour!:!Min!!AMPM!
)

5573.

Solve : Copy file to multiple folders?

Answer» DEAR All,

I have a file that need to be coppied to multiple foldeers, for example
my source file is 'd:\aldo\test.txt'
I need this 'test.txt' to be copied and replaced to
'd:\toby\test.txt' ; 'd:\vero\test.txt' ; so on

The DESTINATION FOLDERS are at the same drive but different folder's name.

Does anyone know how to solve this using batch file?
Thanks before.A couple of ways:
Code: [SELECT]copy d:\aldo\test.txt d:\toby
copy d:\aldo\test.txt d:\vero
copy d:\aldo\test.txt d:\doublexaa
copy d:\aldo\test.txt "d:\My Documents"Or
Code: [Select]set Destinations=d:\toby d:\vero d:\doublexaa "d:\My Documents"
for %%a in (%Destinations%) do copy d:\aldo\test.txt %%aI included an example with a space in it so you could see that you need to use quotes if there will be spaces in the path.Thanks, It works PERFECTLY....

5574.

Solve : Suppressing XCOPY Message?

Answer»

Hi,

I would like to suppress the following message displayed by XCOPY command.

Does destination specify a file name
or directory name on the target
(F = file, D = directory)?

I tried giving /I in the command line OPTION. But it didnt work.

However i would like to enter 'F' for the above message.

Is there anyway i can hardcode 'F' in the batch pgm, so that it uses for the message?

Thanks.
You should be able to redirect input from a file using '<'

Are you renaming the file as you copy it? There is probably a better way to do what you are trying to do. Post the whole XCOPY command that you are using and we can probably come up with an alternate solution, like the syntax of the XCOPY command or another way of copying the file.hi,

Below is the XCOPY syntax i am using.

for /f "delims=" %%a in ('dir/b/a-d D:\Source') do (
if exist "D:\Destination\%%a" (
xcopy "D:\Destination\%%a" "D:\%1_Backup\%%a" /S/E/H/R/Y/F/Q/I
)
)I don't know the structure of your D:\Destination directory, but since the DIR in your FOR loop is not using /S and is also excluding DIRECTORIES, I assume it is a flat directory? If that is the case, you don't need the /S and /E (of which /S would be redundant anyway) and also the /F and /Q switches are opposites (and both cosmetic).

If you aren't copying any hidden, system or write-protected files, then you COULD probably replace your XCOPY line with:
Code: [Select]copy "D:\Destination\%%a" "D:\%1_Backup\%%a" /YIf you are copying hidden files, you may need to precede your copy with
attrib -r -h -s "D:\Destination\%%a"
or if copying write protected files, you may need to precede your copy with
attrib -r "D:\%1_Backup\%%a"Quote

xcopy "D:\Destination\%%a" "D:\%1_Backup\%%a"

Removing the destination filename might suppress the message, it's not needed in this case.

Quote from: Dusty on February 19, 2009, 12:17:33 AM
Removing the destination filename might suppress the message, it's not needed in this case.

Yes, that does seem more simple. GOOD solution!Hi All,

Thanks for the valuable input.

I should have excluded the -d in my DIR command in the FOR Loop as it is not a Flat Directory.

Below is the Problem:
I have two folders A & B. I want to search for a particular file from Folder A in Folder B, if is present, copy that file from Folder B to Folder C. If it is not Present copy that file from Folder A to Folder D.

Solution:

I have written the below code to search and copy the files. However i'm unable to suppress the XCOPY message:

@ echo off

if exist d:\%1_Backup del/Q d:\%1_Backup
if exist d:\%1_Del del/Q d:\%1_Del

mkdir d:\%1_Backup
mkdir d:\%1_Del


for /f "delims=" %%a in ('dir/b/a D:\Source') do (
if exist "D:\Destination\%%a" (
xcopy "D:\Destination\%%a" "D:\%1_Backup\%%a" /S/E/H/R/Y/F/Q/I
>%2
)
)

for /f "delims=" %%a in ('dir/b/a D:\Source') do (
if not exist "D:\Destination\%%a" (
xcopy "D:\source\%%a" "D:\%1_Del\%%a" /S/E/H/R/Y/F/Q/I
>%2
)
)

Pause

Below is my directory structure:

Source Destination
Compile Compile
FTP FTP
ISO ISO
NSR Vehicle
Paint WRC
Painting Tips ABC [Folder]
POLK abdc
POLK-jan09
Vehicle
WRC
ABC [Folder]
abdc
extra

In the above directory structure, the code is not copying the contents of the folder ABC correctly. (i.e) it is copying only the folder ABC and not the contents of the folder abdc and extra.

Thanks for your help.

Quote from: ponnisundar on February 19, 2009, 10:30:22 PM
I have two folders A & B. I want to search for a particular file from Folder A in Folder B, if is present, copy that file from Folder B to Folder C. If it is not Present copy that file from Folder A to Folder D.

I am confused. You say you have 2 folders, but you are referring to Folder A, Folder B, Folder C and Folder D which is actually 4 folders.Quote from: ponnisundar
I have written the below code to search and copy the files. However i'm unable to suppress the XCOPY message:

Did you not read or understand this?
Quote from: Dusty on February 19, 2009, 12:17:33 AM
Quote
xcopy "D:\Destination\%%a" "D:\%1_Backup\%%a"

Removing the destination filename might suppress the message, it's not needed in this case.

Quote from: ponnisundar
xcopy "D:\Destination\%%a" "D:\%1_Backup\%%a" /S/E/H/R/Y/F/Q/I
>%2

xcopy "D:\source\%%a" "D:\%1_Del\%%a" /S/E/H/R/Y/F/Q/I

Remove the %%a variables (only those which are emboldened and underlined) which contain the output filenames, they are not required in the Xcopy commands. This should suppress the Xcopy message.

Quote from: ponnisundar
In the above directory structure, the code is not copying the contents of the folder ABC correctly. (i.e) it is copying only the folder ABC and not the contents of the folder abdc and extra.

Quote from: ponnisundar
for /f "delims=" %%a in ('dir/b/a D:\Source') do (

The Dir command in For extracts only the names of files which are ready to archive in the Source directory, not those in subdirectories. You must include the /S switch to extract those but that will extract all the qualifying filenames in all subdirectories. Is that what you want or do you want to extract filenames only from ABC, ABCD and EXTRA. If the latter then the Dir command path should be D:\ABC\ and the /S switch must be present.

I'm also confused as to your directory structure, maybe Source is a directory and all the rest are subdirectories of Source?


Input
Folder A - Source
Folder B - Destination

Output

Folder C - _Backup
Folder D - _Del

I Just want the code to work on the folders Source and Destination and copy the contents to _Backup & _Del based on the following rule

Folder C: Contains all files from B that exist in A.
Folder D: Contain All files from A that do not exist in B.

Thanks.



Hi,

I saw your input for supressing the XCOPY message. I used that and it worked. Thanks a lot for that. But i missed removing that while posting in the forum.

But the problem i face now is the XCOPY is not copying the contents of folders inside the Source & Destination. Instead it is just copying the folder alone.

Corrected Code:

Code: [Select]@ echo off

if exist d:\%1_Backup del/Q d:\%1_Backup
if exist d:\%1_Del del/Q d:\%1_Del

mkdir d:\%1_Backup
mkdir d:\%1_Del


for /f "delims=" %%a in ('dir/b/a D:\Source') do (
if exist "D:\Destination\%%a" (
xcopy "D:\Destination\%%a" "D:\%1_Backup\" /S/E/H/R/Y/F/Q/I
)
)

for /f "delims=" %%a in ('dir/b/a D:\Source') do (
if not exist "D:\Destination\%%a" (
xcopy "D:\source\%%a" "D:\%1_Del\" /S/E/H/R/Y/F/Q/I
)
)

Pause
Thanks.Read the bottom part of my reply #8
5575.

Solve : Quick Basic 4.5 --- PLEASE HELP ME!!!?

Answer»

Hi,
I'm using QuickBasic 4.5 but I have a GREAT problem...
If I use Code: [Select]Call ABSOLUTEThere COMES a pop-up Code: [Select]Subprogram not defined
I have tried to set a line with: Code: [Select]'$INCLUDE: QB.BII have tried: Code: [Select]DEF KEY = 0I have tried (in prompt): Code: [Select]qb.exe /l qb.qlb
But it doesn't work

Please help me because I don't know what to do...have you GOT the FILE qb.qlb in the same folder as qb.exe?
yes.. but I have it already fixed
Sorry..

5576.

Solve : Replace cmd.exe with Console?

Answer»

well...CMD is own by TrustedInstaller, if you want to rename it (or ELSE) you need to change the owner to you user name.
But like dias say, you don't need to do that. (unless you want to OPEN a SYSTEM session But i won't explain! You want to avoid that unless you are CRAZY like me)

5577.

Solve : How to convert Dos txt file to Unix txt file??

Answer»

I am working on a project which i need to automate the process.

The only BLOCKING part is converting a Windows .txt FILE to a UNIX .txt file format.
I need this for running a Perl script on a .txt file and without converting the file i would GET lots of unreadable characters.http://www.google.com/search?source=ig&hl=en&rlz=&=&q=convert+dos+text+file+to+unix+format&btnG=Google+Search&meta=lr%3DIf use Notepad ++ it has a convert to unix format feature. Notepad ++ is also a GREAT source code editor, especially for batch.

5578.

Solve : computer name?

Answer»

So you didn't click BC's link either ? ?What I posted is just for the computer name. The link that BC posted doesn't say anything about that. If it did I didn't scroll down far enough, in any CASE the subject is computer name. Quote from: coyotenorth on February 23, 2009, 02:02:39 PM

can anyone help me with the DOS command for FINDING computername by using IP address

If you want to just solve subject titles you are now officially in CHARGE of the following:

Helpppppppppppppppppp

How do i do this ? ? ?

Can't CONNECT to MySpace..........

I Neeeeed helllllp rite now ! ! !

Carry on.Quote from: BatchFileCommand on February 24, 2009, 03:23:27 PM
What I posted is just for the computer name. The link that BC posted doesn't say anything about that. If it did I didn't scroll down far enough, in any case the subject is computer name.


So it didn't solve the problem? How very ODD, because:


Quote from: coyotenorth on February 24, 2009, 02:44:16 PM
TKS BC_Programmer. I can see there is manny wannabe out there, but you were the only to answer my question



the question was, given an IP address, find out the computer name. Not just finding the computer name of the current PC.love you
5579.

Solve : dos refuses to print?

Answer»

In VISTA basic home, msdos refuses to print from C:\dir > prn; my printer works fine in windows, running from usb port, WENT to MS last night and was sent to Fixit download: before, when i ask Dos to print as shown, I GOT "Access is Denied" after Microsoft fixed it, the Dos screen shows as if the COMMAND was accepted, but Nothing happens, "it went in to Null land" where do i go from here?, I have not used dos in years from, but downloaded "POWERSHELL" which has a ton of doc's to print from the dos cmd. screen.
Thanks in advance robert the Old RookieDOS only works with Serial and LPT printers not USB. which means PRN also means LPT1.

Hope this explains it
,Nick(macdad-)

5580.

Solve : ms dos command line to convert .txt into an .ascii file?

Answer»

I need to CONVERT a .txt file into an .ascii file USING msdos. WOULD someone PLEASE give me the command LINE for this. thankslook here:http://askville.amazon.com/SimilarQuestions.do?req=convert-UTF-8-text-file-txt-ASCII-MS-DOS-put-batch

5581.

Solve : Moveing File aid??

Answer»

okay I want to find this file keycode.dll and were supposed to move it to the disk, thing is I'm not sure were the file is. But ISNT the command LIKE copy s:/filename d:\ or something?STEP 1: find file. USE dir.
step 2: copy file.


copy has no /s switch.never mind we had changed it know but he told us to REMEMBER it like that and all is well. S\ = source D\=destination

5582.

Solve : grabing few word from a line of string?

Answer»

I have a file name HEX.txt. It contain a line as:

The hex address is:00EA

I would like to use a batch file to grab the value 00EA and set as a variable hexa

set hexa=00EA.

I have few LIMITATION on doing this. This because i run the DOS in a space limited drive which only have few simple command such as "TYPE", "find".
Also, i am using freeDos V1.00 which only has a simplest function for "for"...

You could help US by pointing to a site that has the documentation for that version of DOS.

Do you have any version of GW-BASIC?Why dont you use DOSBOX?

5583.

Solve : Getting a date from a filename?

Answer»

Hello everybody.

I have an issue trying to write a batch script and I hope you will be ABLE to point me to the right direction.

First of all, I am brand new to batch scripting, and I had to "learn" it just today because I have to do something special with filenames.

Here is the context :

I have xls files which filenames are containing a date. The filenames are like this syntax : 20071107_SOMETHING.xls

I must be able to extract only the date from the filename, get it to a correct format (e.g 2007/11/07) and put it in a text file.

I get through this site to learn the basics and this is what I was able to write for the time being :

Code: [Select]@echo off
for /f "tokens=1-2 delims=_" %%d in ('dir /b folder') do rename "test.txt" %%d.txt
set filename=%%d
echo yass %filename% >> date.txt
pause
In this simple script, I have a folder (named folder) containing only one xls file. The 'dir /b' command returns me the correct filename. From there I use the for loop to extract only the date (20071107), and for testing purpose I rename a test.txt file just to verify that I am extracting the good string.

This part is working !

But, in the next part, I tried to get the date into a variable %filename and then write to the date.txt file. But this is not working at all, I have something empty instead.... I guess I am doing something wrong and that's why I'm asking for advice.

So what I want to do is getting this date that I extracted and simply put it into a txt file. It would be great if I could also put '/' to form a correct date format...

Thank you for any help !
I think you probably want something like:
Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f "tokens=1-2 delims=_" %%d in ('dir /b folder') do (
rename "test.txt" %%d.txt
set filename=%%d
echo yass !filename:~0,4!/!filename:~4,2!/!filename:~6,2! >> date.txt
)
pauseThank you GuruGary !

That helped me a lot, even for understanding Batch scripting.

But I have some questions about what you wrote, and If you can give me answers or point to the direction of somewhere where I cand find the information, I will be grateful.

- I understood that in my first try I was using a variable name outside the for loop, so it wasn't recognized... but, now I'm wondering why are you using the '!' before each variable name I first thought it was some SORT of escape character (I was thinking it was ^ actually...) but it looks a bit more complicated, could you TELL me more about the use of the '!' character.

- Could you also please tell me what is the UTILITY of ':~', or indicate where I can find information about it. It looks like an assignment operator , is that right ?


Anyway, thanks for your answer and your help.

I'm still working on my batch script for 2 days now, I'm learning so I'm not doing very fast but I hope I'll be able to finish it correctly.

Bye all !

P.S : sorry if my english is not perfect...Quote

could you tell me more about the use of the '!' character.


If a variable is set in a for loop, it must be echoed with !'s around it. Otherwise the variable will be blank. The setlocal enabledelayedexpansion allows variables to be set and echoed in the for loop.

_____________________________________________________________________


Quote
tell me what is the utility of ':~'

WELL, to my understanding, it is used to extract certain parts of a set variable, like so:

Code: [Select]set numbers=12345
echo %numbers:~2,4%

Would output 234

____________________________________________________________

However the

Code: [Select]:~2,4

represents characters 2 through 4 in that string. Thanks, BFC ... I have been too busy to check the board all day today until now.

BFC got it right. When reading variables in a FOR loop that were set within the same FOR loop, you need to have the "setlocal enabledelayedexpansion" before the loop, and then access the variables with ! instead of % like you normally do outside the loop. And as BFC explained the :~ in a variable is to extract a substring (breaking out the date into its sub-components to add the slashes). For more information on both, do
Code: [Select]set /?
Quote from: BatchFileCommand on February 24, 2009, 06:54:10 PM

Quote
tell me what is the utility of ':~'

Well, to my understanding, it is used to extract certain parts of a set variable, like so:

Code: [Select]set numbers=12345
echo %numbers:~2,4%

Would output 234

Slight correction - it would output 345

Quote
However the

Code: [Select]:~2,4

represents characters 2 through 4 in that string.

Another correction -

It represents the 4 characters starting at offset 2 from the start (i.e. the third character) But in this case there are not 4 characters left, so it halts at the end.

the syntax is

Code: [Select]set substring %string:~A,B%
where:

A is the offset from the start (the first character is at offset 0 [zero])

B is the number of characters to take

The alternative is to use a negative number for A, then the counting is from the end of the string

%string:~-4,2% represents the 2 characters starting at the 4th character from the end.

%string:~-1,1% is the last char of the string

All this can be easily seen through experiment.


Thanks for clarifying that Dias.
5584.

Solve : How to determine directory size??

Answer»

Oops. The du utility from the Windows 2000 RESOURCE kit is handy.

Code: [Select]S:\>du /q pdf-dir
Files: 10
Directories: 8
Size: 5,670,819 bytes
Size on DISK: 5,670,819 bytes


Code: [Select]S:\>for /f "tokens=1-3" %A in ('du /q pdf-dir ^| find "Size:"') do @echo %B %C
5,670,819 bytes
I guess I don't have du.

Code: [Select]C:\>du /q PROGRAM files dir
'du' is not recognized as an internal or external command,
operable program or batch file.
Keep in mind here that directory/drive/ and folder sizes will all be reported differently depending on the reporting agent itself...
This is commonly known as computer chaos and is built into every machine ever assembled...Quote

This is commonly known as computer chaos and is built into every machine ever assembled...
Right!
Now I would like to know what is it about US humans that this bothers us so much. This question comes up again and again. Why do people BECOME agitated because the machine can not provide a precise status report?Because we're Human...Quote from: nubia on February 20, 2009, 06:51:32 PM

I guess I don't have du.

Code: [Select]C:\>du /q program files dir
'du' is not recognized as an internal or external command,
operable program or batch file.


Quote from: Dias de verano on February 19, 2009, 03:44:21 PM
The du utility from the Windows 2000 Resource kit is handy.

Code: [Select]S:\>du /q pdf-dir
Files: 10
Directories: 8
Size: 5,670,819 bytes
Size on disk: 5,670,819 bytes


Code: [Select]S:\>for /f "tokens=1-3" %A in ('du /q pdf-dir ^| find "Size:"') do @echo %B %C
5,670,819 bytes
5585.

Solve : How to Control USB POrt (on/off) using batch file??

Answer»
The BATCH file uses some fundamental MS-DOS batch file commands.

The "rem" command is used in this instance to document the following procedure.

The "Net Share" command displays the current status of any active "share(s)".

The "@echo on" switches on the display of the "Net Share" command and when the command is completed the "@echo off" command switches the display of any further following command to "off" until such time as may be another "@echo on" command is executed.

I do hope that I have answered your question once again.

At this rate before I know it I will be a "Guru" on this site by just answering all your questions.

But echo off / on merely suppresses the echoing of internal commands. You really don't understand batch, do you? All that your @echo on does is force a prompt to be displayed. And you still haven't answered the question. Because you can't, maybe?

v1.bat

Code: [Select]@echo off
@echo Now running net share
@echo.
@echo on
net share
@echo off
v2.bat
Code: [Select]@echo off
echo Now running net share
echo.
net share

The results...

Code: [Select]S:\>v1.bat
Now running net share


S:\>net share

Share name Resource Remark

-------------------------------------------------------------------------------
IPC$ Remote IPC
The command completed successfully.
Code: [Select]S:\>v2.bat
Now running net share


Share name Resource Remark

-------------------------------------------------------------------------------
IPC$ Remote IPC
The command completed successfully.



@echo off
break on
@echo.
@echo.
@echo.
@echo This has just become a futile discussion with your added sarcasms.
@echo.
@echo Therefore I am being mature about this and ending it here and now!
@echo.
@echo.
pause
exit

Poor Steve. He was just TRYING to help.

His code was long with a lot of extra statements and not very efficient, but I didn't see any obvious logic or syntax ERRORS. Looking at his code, I just assumed he worked for the government.@echo off
echo Dias is right.
echo.
pause>nul
exit.Quote from: Biker Steve on FEBRUARY 18, 2009, 04:03:21 PM



@echo off
break on


@echo.
@echo.
@echo.
@echo This has just become a futile discussion with your added sarcasms.
@echo.
@echo Therefore I am being mature about this and ending it here and now!
@echo.
@echo.
pause
exit



why the "BREAK"?

according to the output from "help break"

Quote
This is present for Compatibility with DOS systems. It has no effect
under Windows XP
.

If Command EXTENSIONS are enabled, and running on the Windows XP
platform, then the BREAK command will enter a hard coded breakpoint
if being debugged by a debugger.

And even with a DOS targeted batch the "Break" command at least as far as I know is only a Config.sys command.

LOL I just had to keep the prodding up
When under taking the MS DOS "Help Break" command you have failed to mention that the command also displays the line "Sets or Clears Extended Ctrl+C checking on DOS systems".

In simple terms what this means is that when executing this fundamental "Break On" command from within a MS-DOS batch file a user can terminate the operation of the MS-DOS file prematurely by pressing both the "Ctrl and C" keyboard keys together. You will then be asked "Terminate batch job (Y/N)".


lets just say to the OP, get MS's Devcon.....

end of story....bye bye...see you later Quote from: Biker Steve on February 20, 2009, 06:18:08 PM

When under taking the MS DOS "Help Break" command you have failed to mention that the command also displays the line "Sets or Clears Extended Ctrl+C checking on DOS systems".

In simple terms what this means is that when executing this fundamental "Break On" command from within a MS-DOS batch file a user can terminate the operation of the MS-DOS file prematurely by pressing both the "Ctrl and C" keyboard keys together. You will then be asked "Terminate batch job (Y/N)".





True, but considering there is no MOUNTVOL or a few other commands used in that batch, it's a bit silly to add something that only works on Pure DOS.
5586.

Solve : Turn off bass on a Batch file??

Answer»

Quote

Wait, if he is too lazy to TURN the bass down. How COULD be have POSSIBLY gotten the bass there, and how could he GET the instruction book?

He had the housekeeper do it. Indubitably he has a housekeeper. Couldn't the house keeper turn it down for him. OK guys, lets wait for a reply from the OP.Just turn the bass down already...my ears hurt...I don't think he's going to reply.
5587.

Solve : Batch File help... file name with spaces?

Answer»

Hi, i just wanted to put a startup on my batch file. If there is space in a path, I can put them in quotes, ("D:\PROGRAM Files\QA Navigator CS\"), but what about if there is space in a file name.

start /d "C:\Program Files\" JoyScribe.exe
start C:\Documents and Settings\hdiqa21\Desktop\Auditor PROD Log - QA21.doc
start D:\Program Files\QA Navigator CS\QA Navigator.exe

"Auditor Prod Log - QA21.doc" and "QA Navigator". Both file name having spaces..any file specification with a space or ampersand requires quotes.How do I write it with "quotes"

start "D:\Program Files\QA Navigator CS\" QA Navigator.exe

This does not work.
Code: [Select]start "D:\Program Files\QA Navigator CS\QA Navigator.exe"
That does not work either. It just opens another cmd window. See screenshot.

[attachment deleted by admin]
Code: [Select]"D:\Program Files\QA Navigator CS\QA Navigator.exe"


you don't NEED start for windows applications.Oh..thanks.....I'm just a beginner to dos........If you do use start for the application, it would be start "" "path/to/app.exe"

5588.

Solve : variables help?

Answer»

Didn't Dias show him by doing the Environmental Vars?yes, but via the System Properties Dialog.

Not sure if there is a WAY to do the same thing via DOS commands- HECK I couldn't even get it to work in my program by directly changing the global session variables in the registry...Quote from: feras on February 20, 2009, 09:02:49 AM

Thanks M.r Dias de verano

I know this way

How can I do it in DOS mode?

Do you mean real MS-DOS, or Windows COMMAND PROMPT? in the former, you MODIFY autoexec.bat. In the latter you can use setx.exe from the Windows 2000 Resource Kit, or alternatives such as pcset.exe or setenv.exe. Use Google to find these.

blasted resource kit... Thank you all

i mean in Windows command promptQuote from: feras on February 21, 2009, 12:16:13 PM
Thank you all

i mean in Windows command prompt

We know that. Above you will see your answer.yes yes

I don,t ask

I just thank you

thank you again Quote from: feras on February 21, 2009, 12:23:23 PM
yes yes

I don,t ask

I just thank you

thank you again

Please come back if you need more help... good luck... Quote from: Dias de verano on February 21, 2009, 12:39:44 PM
Quote from: feras on February 21, 2009, 12:23:23 PM
yes yes

I don,t ask

I just thank you

thank you again

Please come back if you need more help... good luck...

Very professional, Dias.
5589.

Solve : rename batch file?

Answer»

Hi - I'm hoping that someone out there can HELP. I have approx 200 FOLDERS each with a series of files called Tasveg; ie each folder contains Tasveg.shp, Tasveg.dbf, Tasveg.shx etc.

What I need to do is rename each set of files with a unique identifier
Folder A containc TasvegA.shp, TasvegA.dbf, TasvegA.shx etc
Folder B contains TasvegB.shp, TasvegB.dbf, TasvegB.shx etc
Folder C contains TasvegC.shp, TasvegC.dbf, TasvegC.shx etc

Thanks
HelenaI have the actual REN command set to ECHO INSTEAD of rename so you can test first. Be sure you have a backup because bulk renaming can be risky. This assumes no directories or files have spaces in them and they are all in the root of the current directory.

I think you can probably do something like:
Code: [Select]@echo off
echo About to rename a bunch of files ... be sure you have a backup!
pause
for /f %%a in ('dir /ad /b') do echo ren %%a\Tasveg.* Tasveg%%a.*
If you have a backup and it looks like it will work, remove the word "echo" from the line that starts with "for".YEP - I made sure I did a back up before I ran the script

thanks for your help - WORKED a treat

Cheers
Helena

5590.

Solve : Possibly handy VBS script?

Answer»

Win2K onwards...

Code: [Select]Wscript.echo eval(WScript.Arguments(0))
Save this script as Evaluate.vbs

Now, (cumbersome) either call it by

cscript //nologo "Path to\evaluate.vbs" "valid VBS expression" [quotes not always needed but advised]

Code: [Select]C:\>cscript //nologo "c:\utils\evaluate.vbs" "hour(time)"
10

C:\>cscript //nologo "c:\utils\evaluate.vbs" "2/3"
0.666666666666667

C:\>cscript //nologo "c:\utils\evaluate.vbs" "time"
10:17:54

C:\>cscript //nologo "c:\utils\evaluate.vbs" "now"
21/02/2009 10:18:00
or...

(less cumbersome to use)

1. Save it somewhere on your PATH, with a name that does not duplicate any existing executable on your PATH.

2. Set cscript as the default vbs engine by executing cscript //H:cscript

3. Turn off the logo display by executing cscript //nologo /S

(These settings are saved and will PERSIST through reboots until you alter them as described in cscript /?)

Now you can do this

Code: [Select]C:\>evaluate "1/9"
0.111111111111111

C:\>evaluate "(100/2)*3"
150

C:\>evaluate "100/(2*3)"
16.6666666666667

C:\>evaluate "2^16"
65536

C:\>evaluate "4*atn(1)"
3.14159265358979

C:\>evaluate now
21/02/2009 10:26:24

C:\>evaluate "(4*atn(1))*(5^2)"
78.5398163397448

and in a batch... (watch out for the ^ operator - use 1 at the prompt, 2 in a batch file)

Code: [Select]@echo off
set radius=5
set pi=(4*atn(1))
set expression=%pi%*(%radius%^^2)
for /f "delims==" %%A in ('evaluate "%expression%" ') do set answer=%%A
set area=%answer%
echo Circle radius: %radius%
echo Circle area: %area%
nice script Dias,

does it also work with batch variables?Quote from: macdad- on February 21, 2009, 07:55:37 AM

nice script Dias,

does it also work with batch variables?

Not sure what you mean. You can feed batch variables into it. In a batch you could invoke it directly if you just wanted to show the answer or you could use FOR to get the answer into a batch variable. Above, I showed it EVALUATING a batch string variable like this:

Code: [Select]set pi=(4*atn(1))
set expression=%pi%*(%radius%^^2)
for /f "delims==" %%A in ('evaluate "%expression%" ') do set answer=%%A
set area=%answer%
or...

Code: [Select]C:\>set n1=6

C:\>set n2=5

C:\>evaluate %n1%+%n2%
11Quote
^ operator

What does the ^ operator do? Exponentiation. I think it escapes characters in batch so I think that has something to do with it.


I still say BCScript and BASeParser are better. They can, after all, do this:

Code: [Select]STORE(X,{25,36,49})
STORE(Y,Sqr(-X)+X[{1,2,3} PICK 1])
[emailprotected](Y)
which would output(possibly, given use of random PICK operator):

Code: [Select]{5i+25,6i+49,7i+36}


Supports Imaginary numbers, as well as intrinsic support for matrix operations and so forth- not to mention such novel operators such as the "PICK" operator used previous as well as nCr and nPr (number of Combinations and Number of Permutations, respectively) And ** or ^ as multiplication, Logical and boolean operations, etc.

It's going to be a TOUGH cookie to document, though...

And I assure you it's not one line of code. Actually:



15,080 code lines and 6,863 Comment lines.

So I suppose this method wins in the terseness department...

Quote from: Dias de verano on February 21, 2009, 08:18:16 AM
Quote from: macdad- on February 21, 2009, 07:55:37 AM
nice script Dias,

does it also work with batch variables?

Not sure what you mean. You can feed batch variables into it. In a batch you could invoke it directly if you just wanted to show the answer or you could use FOR to get the answer into a batch variable. Above, I showed it evaluating a batch string variable like this:

Code: [Select]set pi=(4*atn(1))
set expression=%pi%*(%radius%^^2)
for /f "delims==" %%A in ('evaluate "%expression%" ') do set answer=%%A
set area=%answer%
or...

Code: [Select]C:\>set n1=6

C:\>set n2=5

C:\>evaluate %n1%+%n2%
11

thats what i meant...but its pretty good. Really handy - floating point math in batch scripting is a step closer (almost).

Thanks Dias.Quote from: BC_Programmer on February 21, 2009, 10:01:42 AM
Exponentiation. I think it escapes characters in batch so I think that has something to do with it.

And it also can act as a line continuation character, depending on the circumstances. So you can prettify batch scripts where the lines are very long.

Code: [Select]@echo off
dir ^
/a-d ^
/w

But its role as a batch script control character means it needs escaping in a batch file, by the escape char which happens to be another ^ (caret) character. I have seen people call it a "carrot".


I've had people call it an up-arrow. Not EXACTLY accurate, or the Asterisk, "I put my password in and I see a bunch of SPIDERS"
5591.

Solve : hidden file i couldn't find?

Answer»

Hi, there
I have a folder in my desktop, i wright click on it i accessed it's property, then i HIDED the folder by using it's
attrib [hidden]. Now i desperately want to retrieve the folder. I've done an early restore the folder shown up, but not a single file can be read. i went DOS, i couldn't manage to use the attrib. Please anybody there to help!!!

I'll be very grearful hello
change attributes to folder:

Code: [Select]attrib -h -r "%USERPROFILE%\Desktop\FolderName"
you can,t see the files?
you may set them as system files

Code: [Select]attrib -h -r -s "%USERPROFILE%\Desktop\FolderName\*.*"
You may need to "undo" the last system restore. I have seen System Restore do STRANGE things to files on the Desktop that have CHANGED SINCE restoring to an EARLIER time.

Then turn on the ability to view hidden files:
1) My Computer -> Tools -> Folder Options -> View tab -> "Show hidden files and folders"
- OR -
2) Or one of the previously posted suggestions to un-hide through the command prompt.

5592.

Solve : MS-DOS EDIT?

Answer»

Out of the blue, after I use either EDIT or EDWIN to edit text and return to the DOS screen everything blinks. The only to stop the blinking is to EXIT to XP and then go back to DOS. I've used these editors for years and have NEVER seen this problem.Magnefico Patio.TRY the command
Code: [Select]coloror try the KEYSTROKES:
[Alt]+[ENTER] then [Alt]+[Enter] (again)

5593.

Solve : Can someone provide batch code??

Answer»

I have a directory holding an MP3 file for each day. (ie: Feb09.mp3, Feb25.mp3 etc.)
I need a batch file that will determine the current date....
Grab the file for the current date....
and FTP it to a location OVERWRITING (without confirmation) what is there.
The destination file name will ALWAYS BE rw.mp3
I'll run this via the task scheduler each night.
Can someone show me the Batch code that will do that?Quote

I need a batch file that will determine the current date....

%date% is a system set VARIABLE that gives the date. what is your output if you use
Code: [Select]echo %date%
in cmd ?Sat 02/21/2009Since you didn't specify, I assume the MP3 files are in the current directory, and the files should go to the DEFAULT FTP directory. You should be able to do something like this:
Code: [Select]@echo off
setlocal enabledelayedexpansion

set FTPHost=myftphost.com
set FTPUser=myusername
set FTPPass=mypassword

set MonthNum=%date:~4,2%
set DayNum=%date:~7,2%
set Loop=1
for %%a in (Jan Feb Mar Apr MAY Jun Jul Aug Sep Oct Nov Dec) do (
if !MonthNum! equ !Loop! set MONTH=%%a
set /a Loop+=1
)
set File=%Month%%DayNum%.mp3

echo %FTPUser%>cmds.ftp
echo %FTPPass%>>cmds.ftp
echo bin>>cmds.ftp
echo put %File% rw.mp3>>cmds.ftp
echo quit>>cmds.ftp
ftp -v -s:cmds.ftp %FTPHost%

echo Done transferring %File%Thank you Gary...
I appreciate your helping me.
bob
No problem.GuruGary is very HELPFUL. Always posts a tested batch file in those threads that he can help with.
5594.

Solve : Keyboard input in a batch file?

Answer»

I haven't written a batch file since ADAM was a boy, but a situation has come upwhere I think one is needed. we use a SIMPLE HTML file as a signature file for our email system (Lotus Notes) the bosses want all users to have a sig file, and for it to be consistent. Not many users can code in HTML, and so it is shaping up that I will need to do a file for each of them. Rather than do this I thought a quick batch file that asks the users name, section, phone number, etc, then outputs the HTML file. But I can't find how I ask the user for input. I am SURE it is possible, and I am sure it is easy, but I just can't find a reference. everything I find only allows simple input, like CHOICE.

Can anybody either tell me or point me to a resource that does?

ThanksBatch is poor when it comes to user input unless predetermined (list) of choices for Choice command ( if this do that ).

a VB Script would give you what you want.Maybe someone here more savy in vbscripting can give you a example of how to ask for input and output that to a file to compose the html file out of the vbscriptCouldn't SET/P be used as in:

SET/P username=Please enter your name:
cls
SET/P section=Please enter your section:
cls
SET/P phone#=Please enter your phone#:
cls
echo %username% %section% %phone#% > %temp%userinfo.txt

Sorry, I'm not up to HTML coding, leave that to you..

Hope this helps &AMP; welcome to the forums.THANK you for the replies. Unfortunately not enough time for me to learn VBScript. I will try the set and see whether this works, I think it will.

Thanks again Code: [Select]@echo off


:start
cls
set username=
set section=
set phone#=

cls
SET/P username=Please enter your name:
cls
SET/P section=Please enter your section:
cls
SET/P phone#=Please enter your phone#:
cls
set /p correct=Was all this information correct(Y/N):
if /i %correct%==n goto start
if /i %correct%==y goto makefile


:makefile
echo <p> Username : %username% > info.html
echo Section : %section% >> info.html
echo phone# : %phone#% </p> >> info.html
msg * Done!
exit


I think that should do it. I'm not quite sure on the html though, that should make a standard
paragrah if I remember correctly. Thank you. I had got as far as the input part, but you hav also solved the output. That should work great.

Thank you againCode: [Select]set /p correct=Was all this information correct(Y/N):
if /i %correct%==n goto start
if /i %correct%==y goto makefile
what if user will press some other button ?
i would change that to:
Code: [Select]set /p correct=Was all this information correct(Y/N):
if /I '%correct%' equ 'y' goto makefile
goto start& echo the entered information on-screen before asking the question so that it can be checked...

Code: [Select]@echo off


:start
cls
set username=
set section=
set phone#=
set correct=

cls
SET/P username=Please enter your name:
echo ---------------------------------------------
SET/P section=Please enter your section:
echo ---------------------------------------------
SET/P phone#=Please enter your phone#:
echo ---------------------------------------------
set /p correct=Was all this information correct(Y/N):
if /i "%correct%"=="n" goto start
if /i "%correct%"=="y" goto makefile
goto start


:makefile
echo ^<p^> Username : %username% > info.html
echo Section : %section% >> info.html
echo phone# : %phone#% ^</p^> >> info.html
msg * Done!
exit

That's the improved version. Now it shows the information you typed so you can verify if it is correct. Quote

:makefile
echo <p> Username : %username% > info.html
echo Section : %section% >> info.html
echo phone# : %phone#% </p> >> info.html
msg * Done!
exit

< and > have special significance in the Echo command therefore cannot be used as literals unless they are ESCaped e.g. ^

Thanks, I fixed it.
5595.

Solve : what Batch Code will help me here?

Answer»

I have a .txt file (txt1.txt) that has data in it.
I want to add the contents of another text file (txt2.txt) AFTER the data in txt1.txt;
In other words, add the contents of txt2.txt to txt1.txt.
What batch file COMMANDS will do that?
COPY file1.txt+file2.txt result.txt or
Code: [SELECT]TYPE file2.txt >> file1.txtboth ACCEPTABLE ..
Thank you to all.
bob

5596.

Solve : Restore Windows from DOS??

Answer»

Hi - I don't have an A: drive, but Windows Backup requires it for a fresh RESTORE. Can this be done from the DOS prompt in C:? Thanks in advance for any help.I havent been able to do it through DOS, however from NT Backup I have been able to install a fresh copy of the Windows OS from CD ( after first making sure that the backup data is on an external media like external or 2nd hard drive to avoid total data loss!! ) then from the clean build use the Windows NT Backup to restore this backup overtop of the clean build to get you back to where you want to be. SYSTEM then just needs to be restarted after restore and you should be all set.

Biggest compatability HURDLE for DOS and Windows today is DOS's inability of accessing NTFS drives Only tools out there to access NTFS drives at a DOS level are actually built on LINUXThanks Dave,

Yes, I too found I had to use the Windows CD for a fresh install. Then I backed up over it and found two (!) directories of \WINDOWS and some confusion and mismatch on the system. So I resorted to the usual format and fresh install of everything. Now, I just back up my personal files system state. It doesn't bring me exactly back to before is close enough. I'll do your tips for next time and thanks for the help.

SonyaNo problem...glad it worked out for you. Quote from: DaveLembke on February 24, 2009, 11:04:53 AM


Biggest compatability hurdle for DOS and Windows today is DOS's inability of accessing NTFS drives Only tools out there to access NTFS drives at a DOS level are actually built on LINUX

NTFSDOS:

http://www.softpedia.com/get/System/System-Miscellaneous/NTFSDOS-Professional.shtml

it cost's money, but it allows you to read and change the files on any NTFS drive.


basically it WRAPS the 32-bit NTFS.sys driver from Windows and emulates the 32-bit calls in the DOS ENVIRONMENT; so almost anything Windows can do with NTFS DOS can with this driver installed.Thank you, I'll follow up on this link!wait- my post was merely for DaveLembke's Info regarding accessing NTFS drives through DOS.

His method is much more foolproof- make regular backups, and if you have a system crash, reinstall windows and restore the backup after reinstallation.


the only reliable way to make a full system backup otherwise is with a drive imaging utility.
5597.

Solve : Help with search?

Answer»

hello all,
I need to search c:\program files and sub folders for a specific file and if it's found copy it to a specific folder.
Thanks in advance.
Sounds like homework. no it isn't homework but thanks for your quick reply.
We have a program it is called Imagenow that has an issue with Acrobat reader 9. When Imagenow crashes on a box that runs Acrobat 9 I need to FIND 2 files, ace.dll and agm.dll and copy them to the imagenow folder. This issue is widespread and I would like to have a batch file to run everytime this issue comes up.1. What is the full path of the Imagenow folder?
2. What do you want to happen if either of the files is not found?
the imagenow LOCATION is known
c:\program files\imagenow6
but i want to have it search at least c:\pf\adobe and all the sub folders for ace.dll and agm.dll
The program can just EXIT if no files are found.
So you want to search the folder tree below C:\Program Files\Adobe for ace.dll and agm.dll, and if they are found, copy them to the folder C:\Program Files\imagenow6

I am presuming you are using an NT family OS, i.e. Windows 2000, XP, Vista, etc.

This batch code will search for those two files and copy the first ones it finds into the imagenow6 folder, overwriting any that may be there already.

I expect you can see where to modify the search path.

Try this...

Code: [Select]@echo off
cd /d "C:\Program Files\Adobe"
dir /s "ace.dll" || goto skipace
for /f "delims==" %%A in ('dir /s /b ace.dll') do copy /Y "%%~dpnxA" "C:\Program Files\imagenow6"
:skipace
echo ace.dll not found
dir /s "agm.dll" || goto skipagm
for /f "delims==" %%A in ('dir /s /b agm.dll') do copy /Y "%%~dpnxA" "C:\Program Files\imagenow6"
:skipagm
echo agm.dll not found
just what I needed. Thank you very MUCH for your prompt assistance.

5598.

Solve : SUPER BATCH?

Answer»

Quote from: BC_Programmer on February 22, 2009, 01:59:31 PM

we're just a BUNCH of foals.

i was about to PUT GEEK in the middle.

[attachment deleted by admin]Seems like always the same people.

This has GONE waaaay off topic.

Closed.
5599.

Solve : Help on making this batch file!!!?

Answer»

How do you make a batch file for vista home premium that makes other users into admins too? Dont worry about the priviledge of the executer coz my retarded comp turns all my other accs into limited everynow and then. Im using the default admin. I dont wanna reformat my pc coz i cbf doing it. I dont wanna system RESTORE coz that does NOT work.

Thnx,
AlvonWe cannot help you make a Batch File to make another user an administrator.

Try a System Restore in Safe Modehmm then how do i change the accounts from limited to admin using the command prompt?you can't. It would DEFEAT the purpose of a "LIMITED" account. Unless you're doing it from another administrator account, in which case you can just use the provided GUI features.im an admin but yeah, my control panel's stuffed (idk why). It just LAGS and closes if i try to open it. http://articles.techrepublic.com.com/5100-10878_11-5031577.html

will only work if you have the rights to modify other user accounts.

another option would be to run the command:

nusrmgr.cpl

which should open the User accounts control panel option.Can't you do Netuser?I dont understand it. Can anyone give me a step by step guide of changing an account from admin to limited using the command prompt? Pictures would be helpful.

This is where im stuck:


[attachment deleted by admin]Quote from: BC_Programmer on February 21, 2009, 09:53:54 PM

another option would be to run the command:

nusrmgr.cpl

which should open the User accounts control panel option.

i did say that my control panel doesnt work.
im TRYING net user *(username)
but how do i change it from there?that isn't control panel.

nusrmgr.cpl is something i dont have on my pc coz mine's vista home premium. im missing a lot of stuff lols,
all my old xp .msc(s) are gone too. it's sad.Code: [Select]RunDll32.exe shell32.dll,Control_RunDLL nusrmgr.cpl

worked on my vista machine.

If you cannot system restore and your missing these control panel items making a batch file to workaround your inability to use control panel will get old quickly. Will your next thread be "batch file to change resolution"?

why not run

Code: [Select]SFC /SCANNOW

which might fix your control panel.We can not and will not help make you Administrator from a User Account. Period.

Why you may ask?

First, we don't know what the problem really is. For all we know, you could be some kid trying to gain access to the SCHOOL computers.

Second of all, if we post the results here in this public forum, anyone can see it, including these kids.Fine, here goes my explanation:
Problem - Control Panel got stuffed for no bloody reason and my accs change from lmt to adm automatically when i bootup.
I cant change my accounts coz i dont have the other dodgy apps in vista.
AND school networks dont work like that mate, it's on a lousy server coz i've seen one.

Sigh
5600.

Solve : Question about robocopy?

Answer»

I have used the RoboCopy command to selectively back up entire folders from my computer to a network server. Since I want to copy the entire folder, and purge any files I've deleted since the last use, I employ the /MIR switch. For example, I WROTE a batch file to copy everything in my computer's Pictures folder to a folder on the server using "robocopy e:\userdata\pictures \\clearsoftnas\photo /mir" (quotes not included). Works like a charm.
However (and here's the question), I just set up a new computer for my wife's use and decided to create a batch file to back up her DOCUMENTS folder to a folder on the server. The RoboCopy command is "robocopy c:\users\wendy\documents \\clearsoftnas\wendydocs /mir" (again, without the quotes). When I watch the output of the RoboCopy as it's performing the copy, I notice it's trying to copy the folders c:\users\wendy\my pictures c:\users\wendy\my music c:\users\wendy\my videos and c:\users\wendy\my ebooks even though there are no such folders contained in the Documents folder that's being mirrored. It's as if RoboCopy is trying to include the "standard" user folders (that are REFERRED to with the "My" prefix) even though they're not present in the specified source folder.
ANYONE have any IDEA why this is happening? Thanks!They are default Win Folders...if they are empty...no worries.