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.

2101.

Solve : Games in DOS 3.2?

Answer»

Quote from: Barometer on FEBRUARY 12, 2012, 01:30:53 PM

Never thought of that. GOOD idea.

$17.00 for example

AS for the screen saver, I GUESS you could find some MS-DOS slideshow PROGRAM and put in on a floppy with the company logo as a GIF... it would be good if it moved AROUND...

2102.

Solve : Add leading zeros to batch file name?

Answer»

I am trying to modify a batch file created by somebody else, to add leading zeros depending on the number found on line 4 of the file. The actual filename is a concatenation of the name found on line 3, and the numbers on line 4. So if the first few lines are as follows:
3.1.19
-1
TEST
560
The file name would be v_TEST00560.TXT. As you can see, the total number of digits in the file name should be 5. If the number which appears on line 4 is 8 (see below), then:
3.1.19
-1
TEST
8
The file name will be v_TEST00008.txt.
The file I have is as follows: Code: [Select]Echo Off

Setlocal EnableDelayedExpansion

REM File: rename5.BAT
REM The script will look for and parse one (or more) input files
REM Input files can containrecords for one or more vessels.
REM This script assumes that each record starts with the "3.1.19" string.

REM %%%%%%%%%%%%%%%%%%%%%%% Configuration Section %%%%%%%%%%%%%%%%%%%%%%%

SET INPUT_DIR=C:\Files\RenameFileName\Input
SET OUTPUT_DIR=C:\Files\RenameFileName\Output
SET ARCHIVE_DIR=C:\Files\RenameFileName\Archive
SET TEMP_DIR=C:\Files\RenameFileName\tmp
SET INPUT_FILENAME=INTERFACE.TXT
SET REC=3.1.19

REM %%%%%%%%%%%%%%%%%%%%%%%%%%%% Checking Section %%%%%%%%%%%%%%%%%%%%%%%%%%%%

FOR /F "usebackq TOKENS=* eol= delims= " %%d IN (`date /t`) do SET RUNDATE=%%d
echo [%RUNDATE% %TIME%] Script starting...

IF NOT EXIST %INPUT_DIR% (
SET MESSAGE=Input directory not found.
goto END
)

IF NOT EXIST %OUTPUT_DIR% (
SET MESSAGE=Output directory not found.
goto END
)

IF NOT EXIST %ARCHIVE_DIR% (
SET MESSAGE=Archive directory not found.
goto END
)

IF NOT EXIST %TEMP_DIR% (
echo Temporary directory does not exit.
echo Creating %TEMP_DIR%
mkdir %TEMP_DIR%
)


REM %%%%%%%%%%%%%%%%%%%%%%%%% Main Processing %%%%%%%%%%%%%%%%%%%%%%%%%

dir %INPUT_DIR%\%INPUT_FILENAME% 1>NUL 2>NUL
IF %ERRORLEVEL% EQU 1 (
SET MESSAGE=Input files not present.
goto END
)

FOR /F "usebackq tokens=* eol= delims= " %%d IN (`date /t`) do SET RUNDATE=%%d
echo [%RUNDATE% %TIME%] Input files found. Start Processing...

FOR /F "usebackq" %%I IN (`dir /b %INPUT_DIR%\%INPUT_FILENAME%`) DO (
SET INPUT_FILE=!INPUT_DIR!\%%I
echo READING Input file: !INPUT_FILE!

SET N=
FOR /F "tokens=* eol= delims= "  %%A IN (!INPUT_FILE!) Do (
set LINE=%%A
set LINE2=!LINE:~0,6!
if !LINE2! EQU !REC! (
SET /A N+=1
echo Creating temp file !TEMP_DIR!\!N!.tmp
)
echo !LINE! >> !TEMP_DIR!\!N!.tmp
)

FOR /F "usebackq" %%Y in (`dir /b !TEMP_DIR!\*.tmp`) DO (
SET TEMPFILE=!TEMP_DIR!\%%Y
SET N=
FOR /F %%A IN (!TEMPFILE!) DO (
SET /A N+=1
IF !N! EQU 3 SET S=%%A
IF !N! EQU 4 SET T=%%A
)
SET S=!S:~0,10!
SET T=!T:~0,10!

echo CREATING Output File: %OUTPUT_DIR%\V_!S!00!T!.TXT
MOVE !TEMPFILE!  %OUTPUT_DIR%\V_!S!00!T!.TXT
)
)

REM %%%%%%%%%%%%%%%%%%%%%%%%% Archiving Section %%%%%%%%%%%%%%%%%%%%%%%%%

FOR /F "usebackq" %%t IN (`CSCRIPT "%~dp0timestamp.vbs" //Nologo`) do SET TIMESTAMP=%%t

FOR /F "usebackq" %%I IN (`dir /b %INPUT_DIR%\%INPUT_FILENAME%`) DO (
echo ARCHIVING Input file %%I to %ARCHIVE_DIR%
rem COPY !INPUT_DIR!\%%I !ARCHIVE_DIR!\%%I.!TIMESTAMP!
MOVE !INPUT_DIR!\%%I !ARCHIVE_DIR!\%%I.!TIMESTAMP!
)

REM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

FOR /F "usebackq tokens=* eol= delims= " %%d IN (`date /t`) do SET RUNDATE=%%d
SET MESSAGE=[%RUNDATE% %TIME%] Processing Done.

:END
echo %MESSAGE%
FOR /F "usebackq tokens=* eol= delims= " %%d IN (`date /t`) do SET RUNDATE=%%d
echo [%RUNDATE% %TIME%] Script finished.


As you can see, its quite sophisticated, and I have no idea how to make these changes myself. The BAT runs perfectly, but the number of zeroes if fixed, and not generated depending on the number of digits already present. Any help appreciated. Code: [Select]FOR /F "usebackq" %%Y in (`dir /b !TEMP_DIR!\*.tmp`) DO (
SET TEMPFILE=!TEMP_DIR!\%%Y
SET N=
FOR /F %%A IN (!TEMPFILE!) DO (
SET /A N+=1
IF !N! EQU 3 SET S=%%A
IF !N! EQU 4 SET T=%%A
)
SET S=!S:~0,10!
SET T=!T:~0,10!

echo CREATING Output File: %OUTPUT_DIR%\V_!S!00!T!.TXT
MOVE !TEMPFILE!  %OUTPUT_DIR%\V_!S!00!T!.TXT
)

This is the section you are going to need to modify under the main processing section. It's just a matter of adding an extra variable and doing a little modification. See below:

Code: [Select]FOR /F "usebackq" %%Y in (`dir /b !TEMP_DIR!\*.tmp`) DO (
SET TEMPFILE=!TEMP_DIR!\%%Y
SET N=
FOR /F %%A IN (!TEMPFILE!) DO (
SET /A N+=1
IF !N! EQU 3 SET S=%%A
IF !N! EQU 4 SET T=%%A
)
SET S=!S:~0,10!
SET T=!T:~0,10!

SET OUTNUM=0000!T!
SET OUTNUM=!OUTNUM:~-5!

echo CREATING Output File: %OUTPUT_DIR%\V_!S!!OUTNUM!.TXT
MOVE !TEMPFILE!  %OUTPUT_DIR%\V_!S!!OUTNUM!.TXT
)

Let us know if you need this explained or would like to know more in depth what is happening.Thanks for replying so quickly and indicating the changes needed so clearly. One last question. Any goo sites where I can BRUSH up on DOS scripting?http://www.robvanderwoude.com/
http://www.dostips.com/

2103.

Solve : trouble writing ! to a file?

Answer»

I am working on writing this batch file which will create a cshtml file for each item in a file (emailList.txt). I have it working except for one little issue. When I try to write and lines with >> destination.cshtml)  the ! will not write to the file. I'm sure I am missing something simple here, but I'm stuck. Any assistance would be appreciated.


Code: [Select]echo off
setlocal ENABLEDELAYEDEXPANSION
set emailList=%userprofile%\desktop\cshtmlPages\emailList.txt
set pageID=100001

:: this loop writes a separate web page for each email address found in the emailList
for /F %%z in (%emailList%) do (



echo ^<!DOCTYPE html^> >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml

echo ^<html LANG="en"^> >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo ^<head^> >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo ^<meta charset="utf-8" /^> >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo ^<title^>Test SITE^</title^> >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo ^</head^> >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo ^<body^> >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo { >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo //this is used to create the variables to be written to the database. >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo var pageName = "!pageID!"; >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo var month = DateTime.Now.Month; >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo var day = DateTime.Now.Day; >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo var year = DateTime.Now.Year; >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo var hours = DateTime.Now.Hour; >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo var minutes = DateTime.Now.Minute; >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo } >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml


echo ^<!-- display the variables for testing purposes >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml


echo ^</body^> >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml
echo ^</html^> >> !userprofile!\desktop\cshtmlPages\test!pageID!.cshtml





set /a pageID+=1

)


exit
I see that you are escaping the < by doing this ^<

So couldn't you just change it to: echo ^<^!DOCTYPE html^>I thought that was the case originally so I tried it and got the same results. It did not write the ^ or ! to the file. It seems that the ! is not actually a control character though. If you open a cmd prompt and type echo ! it will print ! to the screen. It has something to do with the combination of
echo ^<^^!DOCTYPE html^>thanks! I don't know why I didn't think of that.  Haha I don't know why you should have to. Batch is a pretty convoluted language. Maybe you should try AutoIt or VBS for FUTURE projects.I figured this would just be a quick write up and I'd be done with it. Instead I spend two hours looking for a solution on Google and couldn't find anything related to it. Quote from: Dan O on January 13, 2012, 02:51:54 PM

Instead I spend two hours looking for a solution on Google and couldn't find anything related to it.

What were you typing?

1. Google Groups
2. alt.msdos.batch.nt (Usenet archive)
3. Search box
4. Type: echo exclamation mark to file
5. Second hit.. thread titled "Echoing exclamation mark with delayed expansion enabled"
6. Second reply... "Prefix it with ^^ (two escape characters)" (Apr 17 2003, 1:27 pm)

30 secs approx

or even without Google Groups...

1. Google
2. Type: Echoing exclamation mark cmd
3. First hit: How can I escape an exclamation mark ! in cmd scripts?

http://stackoverflow.com/questions/3288552/how-can-i-escape-an-exclamation-mark-in-cmd-scripts

4. First answer: echo I want to go out with a bang^^!

("bang" is what older programmers call the ! character)

approx 20 seconds






Dan O - try saving yourself a lot of typing and produce a cleaner script listing, repeated output Paths\Filenames are not required on each Echo command LINE.

For.......... ) do (
echo etc...
echo etc...

etc....
)>Path\Filename

Good luck.I am not quite sure why you are using exclamtions on the user profile variable. You could use the percent signs and be just fine.
Is my eye sight gone funny? I don't ever see you using the loop variable in your output.
I would have just made that base directory a variable as well.
And since you are reading and writing to that same directory you could have just used the Pushd command to set the working directory. Then you wouldn't have had to keep typing out the path as well. Quote from: Squashman on January 13, 2012, 10:39:46 PM
I am not quite sure why you are using exclamtions on the user profile variable. You could use the percent signs and be just fine.
Is my eye sight gone funny? I don't ever see you using the loop variable in your output.
I would have just made that base directory a variable as well.
And since you are reading and writing to that same directory you could have just used the Pushd command to set the working directory. Then you wouldn't have had to keep typing out the path as well.

I imagine he just thinks you have to use exclamation marks in a loop...


And since you are not using the loop variable which means you are not using any data from your emaillist.txt file you could have just used a FOR /L loop instead and then you could get rid of the counter variable and then you don't need delayed expansion at all. Quote from: Squashman on January 14, 2012, 10:13:04 AM
And since you are not using the loop variable which means you are not using any data from your emaillist.txt file you could have just used a FOR /L loop instead and then you could get rid of the counter variable and then you don't need delayed expansion at all.

The effect of for /F %%z in (%emailList%) do ( is to iterate the loop once for each line in maillist.txt; but as you say %%z (which holds the text of each line) makes no further appearance in the loop code. Either he has missed out some lines, that he does not wish the world to see, from his actual code, or he has only a hazy notion of batch syntax because e.g. he has been copying code from web sites without understanding it.

[edit] looking back through his earlier posts I see that in June 2011 he published a piece of code in which a variable was not changing in a loop. He was advised to use delayed expansion and the ! notation and seems to have not quite grasped the circumstances in which these things are needed, and has decided to throw them in because they fixed up his earlier effort.

To recap what I have written many times:

In a batch or cmd script running in a Windows NT family command environment, where you have a PARENTHETICAL structure (examples below), you need to use delayed expansion for any variables which are both set and expanded inside the parentheses. In the examples below, var1 was set before the parentheses and therefore does not need delayed expansion, and can have % signs. var2 and time are both created and expanded inside the parentheses and need the ! symbol, and prior enabling of delayed expansion. Note that once the closing parenthesis is passed, var2 is accessible with ordinary % signs.


set var1=hello

for blah blah blah (
     set var2=%%X
     echo !time!
     echo %var1%
     echo !var2!
     etc
     )
   
     echo %var1%
     echo %var2%

if a==b (
    set var2=whatever
    echo !time!
    echo %var1%
    echo !var2!
    )

    echo %var1%
    echo %var2%

command1 && (
    set var2=whatever
    echo !time!
    echo %var1%
    echo !var2!
    )

    echo %var1%
    echo %var2%






2104.

Solve : batch file to run program in another partition?

Answer»

Hi;

I'm running an old dos file manager called stereo shell on a P4 pc under XP SP3.

This batch works;

echo off
e:
cd \TRUE\grid\2011
D:\stereo\sts.exe
C:

but this file doesn't;

echo off
c:
cd \zzz\Precur~1
D:\stereo\sts.exe
C:

Stereo shell comes up correctly but in black and white instead of color and it doesn't know where it's associated files are.

Please help

RogerFirst, and this is more of a personal preference than ANYTHING, why aren't you using cd /d to change the folder and drive on one line?

cd /d e:\TRUE\grid\2011

or

cd /d c:\zzz\Precur~1

The reason I believe your second line isn't working is because you are using 8-dot-3 FILENAME structure when you don't have to, and if there is any other file under the zzz file that starts with similar letters, you are asking for trouble. Why not use:

cd /d "c:\zzz\Precur..."

Using the quotes, you won't have any trouble with SPACES or the like. Because it is a shell, my though is that it will do the conversions to 8-dot-3 file structure when the shell is started, and having the file already in 8-dot-3 is screwing up it's functions somehow. Try it and see what you come up with. If you are still having issues, try posting the full file path of the "c:\zzz" target so we can try to provide better and more accurate help.I don't use the cd /d because a) I didn't know about it (I'm an OLD dos user) and b) it doesn't work

If I put the /d in, it ignores that line entirely and executes the next line, INVOKING stereo shell in it's own location.

Quoting the path makes no difference. The full path is C:\zzz\Precursors

The idea behind this is to move to a target directory and invoke StS from there so I don't have to manually change to the place I need to be. It works (normally) but not in this case.

Roger Quote from: rogernh on January 10, 2012, 11:18:32 AM

If I put the /d in, it ignores that line entirely and executes the next line, invoking stereo shell in it's own location.

That's odd. Try opening your cmd prompt and typing in the command and see what happens. Post any errors here so we can see them.

Since there are no spaces, you should be able to just type cd c:\zzz\Precursors and it should work. Try this in the cmd prompt and if you run into anything, post it here. In fact, the best way to troubleshoot a script if it isn't a particularly long one is to manually type each line into a cmd prompt. Don't type echo off though. You want echo to stay on so you can see what is going on.

Try your original method of changing the drive, but try one change with your original script. On your cd lines, you don't need to include the /d, but do include the drive letter. Otherwise, if you type c: and it defaults to c:\Documents and Settings\rogernh you won't be able to find the zzz\Precursors folder because it will be looking under your profile instead of on the c: drive.If I enter cd in the run command window it says it's an unknown command.

No variation of the full pathname works, quoted or otherwise

I agree, the c: jumps to the wrong location but How can I tell it the correct location?

RogerCorrection; the full path works in the run window but not in the batch file.

now I'm really confused.

Roger Quote from: rogernh on January 10, 2012, 01:12:20 PM
If I enter cd in the run command window it says it's an unknown command.

Are you typing "cmd" in the run window and then these commands from the cmd prompt that pulls up? Just checking, as the way you are describing it is a little vague.

Have you tried using CHDIR instead? If it is still giving you problems, then there are some underlying issues that you will need to address before trying this batch file (sounds like there may be if CD is not a recognized command anyway.)

Quote
No variation of the full pathname works, quoted or otherwise

With the CD command not working, this doesn't SURPRISE me. When we get the command working, we can concentrate on getting the parameters correct as well.

Quote
I agree, the c: jumps to the wrong location but How can I tell it the correct location?

That will be taken care of when we get the CHDIR command working correctly. All you need to do is CHDIR to the full filepath (including drive letter) and it should work.Ok, I'm using the "Run" window under XP SP3

If I type c:\zzz\Precursors in the space provided the correct directory appears

If I type cmd c:\zzz\Precursors a black command line box pops up and typing c:\zzz\Precursors in there changes it to that directory as entering dir proves.

BUT it does not work in a batch file.

This seems just really strange.

Please copy and paste the code below into the batch file, then run it. Once all is done, copy and paste the contents of the log.txt file here so I can see what happens.

Code: [Select]echo on
c: >>log.txt
chdir c:\zzz\Precursors >> c:\log.txt
start d:\stereo\sts.exe >>c:\log.txt
cd d:\stereo >>c:\log.txt
exit
The log.txt file is empty.

RogerOkay, let's hit some basics. I apologize if these are really base to you, but I would like to make sure we are all on the same page.

1. When you type these commands into notepad (or a similar plain text processor), you save it as test.bat (or some name with the .bat extension)

2. When you run the batch, you do so by either:
  a. Start -> Run   "test.bat" OR
  b. Double-click the file in Windows Explorer window.

So long as all of this is correct, it seems very strange that it isn't giving you anything.

Try Start -> Run  "cmd"  then type in the script below line by line, and post the log and errorlog.

Code: [Select]echo on
c: >>c:\log.txt 2>>c:\errorlog.txt
chdir c:\zzz\Precursors >>c:\log.txt 2>>c:\errorlog.txt
start d:\stereo\sts.exe >>c:\log.txt 2>>c:\errorlog.txt
cd d:\stereo >>c:\log.txt 2>>c:\errorlog.txt
exit

Thanks, and hopefully we are getting closer.log.txt says:

echo on
c: >>c:\log.txt 2>>c:\errorlog.txt
chdir c:\zzz\Precursors >>c:\log.txt 2>>c:\errorlog.txt
start d:\stereo\sts.exe >>c:\log.txt 2>>c:\errorlog.txt
cd d:\stereo >>c:\log.txt 2>>c:\errorlog.txt
exit

errorlog.txt is empty

RogerThen something is really wrong with your computer. The fact that the redirection is so screwy that it shows everything that was typed in makes me think that there are some really strange things going on with your computer.  The only other thing that could cause this is simple operator error, but if you are following all the steps I gave in my previous post, then that should not be the case.

You can try renaming your log.txt file into log.bat, run it, and see what happens. Though at this point I don't expect anything different.

Unfortunately at this point, the only way I know to correct any wonky issues with cmd.exe is a full reinstall of the operating system. I just don't understand how cmd.exe can be so messed up but everything else work fine. Once that is done though, please try these steps again and see what you get.A full reinstall is pretty drastic and I hate losing all my installs.

But thanks for trying. I'll just have to live with it.

RogerOne other possibility.

C: is on one HD, D: and E: are on another HD

Is it possible that STS doesn't know which drive its files are on?

DOS used to have a PATH file but XP doesn't as far as I know.

Roger
2105.

Solve : dir %userprofile% not working?

Answer»

Okay, so as part of college, we are learning DOS. As part of the notes, we are working with environment variables. Operating system is Windows XP, service pack 2, running on a virtual machine. Our notes quote us as being able to run the directory command with the %userprofile% as the target.  The output from trying this command is as thus:


C:\Documents and Settings\Administrator>dir %userprofile%
The system cannot find the file specified.

Using the command >echo %userprofile% outputs thus:

C:\Documents and Settings\Administrator>echo %userprofile%
C:\Documents and Settings\Administrator

Can someone please advise? Is what our notes tell us to do possible? Thanks for your time.you need to use quotes.

Code: [Select]dir "%userprofile%"

This is because the path has spaces.


Quote from: happy2pester on January 10, 2012, 04:16:04 AM

Okay, so as part of college, we are learning dos.

Quote
Operating system is Windows XP

This is not "DOS".
Quote from: Salmon Trout on January 10, 2012, 12:21:45 PM
This is not "DOS".

Eventually you will change the world, one DOS confused person at a time. Until then, informing everyone is doing great things for your post count. Quote from: Raven19528 on January 10, 2012, 12:42:07 PM
informing everyone is doing great things for your post count.

As someone who used to be very fond of accusing all and sundry of boosting their post count, it is especially galling to be on the receiving end...


Quote from: Salmon Trout on January 10, 2012, 12:45:52 PM
it is especially galling to be on the receiving end...

It's all in fun. One word describes it best though...

"Karma" Quote from: Salmon Trout on January 10, 2012, 12:21:45 PM
This is not "DOS".

Joking aside, I don't think this is altogether a trivial bit of obsessive anality. A person starting out learning Windows NT family command scripting is not going to get the most focussed and useful help if they use a search engine for e.g. "DOS tips" or "DOS syntax" or "DOS batch help" or "DOS batch examples". Command.com and cmd.exe are very different. Coding is something where it is actually important to get things right. If the syudent is actually being told they are learning "DOS" it calls into question the quality of the teaching.

Excellent point...i agree.I was going to point that out myself but couldn't be bothered. Quote from: Salmon Trout on January 10, 2012, 02:36:55 PM
If the student is actually being told they are learning "DOS" it calls into question the quality of the teaching.

And here's where the trouble really LIES. If the teacher is under the impression that Command.com and cmd.exe are the same as DOS, and then passes it along to the students, we have a case where ignorance breeds ignorance. This however may not be the case, as I have learned that the youth of today like to cut out "unneeded" letters, words, sentences, and PARAGRAPHS in multiple aspects of their lives (text translation is a full out brain exercise for me some days), so while the instructor may be passing along correct information, the students in their zeal to compartmentalize the information lump Command.com, cmd.exe, and DOS into one and the same in their own minds, because it fits easier. Unfortunately, ignorance breeds faster than knowledge in many cases because it is easier. All we can strive to do is educate correctly and HOPE that eventually, it makes a difference. Quote from: Salmon Trout on January 10, 2012, 12:21:45 PM
This is not "DOS".
Okay. We are learning to use a command line environment within windows XP. I just feel it easier to call it DOS and as such automatically referred to it as such.

Quote from: BC_Programmer on January 10, 2012, 04:51:41 AM
you need to use quotes.

Code: [Select]dir "%userprofile%"

This is because the path has spaces.


Thank you for being the only person in this thread to address the actual issue. I need to put quote marks around the %userprofiles% do I? I'll check that first opportunity I get. Quote from: BC_Programmer on January 10, 2012, 04:51:41 AM
you need to use quotes.

Code: [Select]dir "%userprofile%"

This is because the path has spaces.




Once again, thanks. I've tested this on an XP computer and it does work - I've yet to get a chance to check this on the virtual machine that I was using, and will have to wait for Tuesday for that. Quote from: happy2pester on January 12, 2012, 06:58:44 AM
Once again, thanks. I've tested this on an XP computer and it does work - I've yet to get a chance to check this on the virtual machine that I was using, and will have to wait for Tuesday for that.
You think the outcome is going to be different? Quote from: Squashman on January 12, 2012, 11:53:54 AM
You think the outcome is going to be different?

I don't think it will be different, but I wish to double check.
2106.

Solve : IF %in% contains Nick then?

Answer»

I need to know if there is a command to use

i have Code: [Select]:[email protected]
echo %username% has joined >> %cd%\Rooms\C\Logs\log.txt
:chat
set in=0
CLS
type %cd%\Rooms\C\Logs\log.txt
set /p in=Say:
:CmdIF

::No entry refresh
if %in%==0 ( goto chat )
::

::Change Username
if %in%==Nick   ( Call Nick.bat )
Thats only a snippit of code
%in% will be like Nick Awash and Awash can change.
Any help is accepted.
If i dont reply right away im proably working on the code you gave me.Also i would like to know how to seperate Nick from the username they wanna change to

(this is not changing the windows %user% its changing a chat username

Nick.bat Code: [Select]Set Username=%in%-Nick
rename %user12%.bat "%username%.bat" User12 is used in other part of codeIf "Nick" is always at the beginning of the name, you can simply parse the VARIABLE and you should be ABLE to grab "Nick". An example would be:
Code: [Select]if /i "%in:~0,4%"=="Nick" (call Nick.bat)
If it is not always at the beginning, then you can try to use the find command  to see if a string contains "Nick". The FOR command would be how you would seperate the username. Examples:
Code: [Select]echo %in% | find "Nick"
if errorlevel 0 call Nick.bat Code: [Select]for /f "tokens=1*" %%A in ("%in%") do set Username=%%B
ren "%user12%.bat" "%username%.bat" Quote from: Raven19528 on January 10, 2012, 10:01:03 AM

you can try to use the find command  to see if a string contains "Nick".

You can pipe to find and CHECK the errorlevel all in one line with the && operator.

command1 && command2 (execute command1 and if the errorlevel is 0 execute command2. The opposite is a double pipe: command1 || command2 means execute command1 and if the errorlevel is not zero, execute command2)

Code: [Select]echo %in% | find "Nick" && call Nick.bat
Quote from: Raven19528 on January 10, 2012, 10:01:03 AM
If "Nick" is always at the beginning of the name, you can simply parse the variable and you should be able to grab "Nick". An example would be:
Code: [Select]if /i "%in:~0,4%"=="Nick" (call Nick.bat)
If it is not always at the beginning, then you can try to use the find command  to see if a string contains "Nick". The FOR command would be how you would seperate the username. Examples:
Code: [Select]echo %in% | find "Nick"
if errorlevel 0 call Nick.bat Code: [Select]for /f "tokens=1*" %%A in ("%in%") do set Username=%%B
ren "%user12%.bat" "%username%.bat"

Okay i tried this but it sets the username to nick

I WANT to take nick out of the variable so Bob can say Nick Bobby and his name becomes bobby ( sets variable username to bobby )and not Nick BobbyYou did know that %username% is already used by Windows? Why don't you use a different variable name?

Try "%NoNick%", or something similar. The more creative you can become with your variables, the less of a chance you have of running into already taken variables.

Alternatively you can grab a list of all of the variables that already EXIST by typing set into your cmd prompt.

2107.

Solve : Connect to FTP with Acount and username?

Answer»

I have an ftp site that requires an account along with the username and a password. I know there is the USER command for the username and password but what is a command for me to enter the account?

Host: ftps01.oracle.com
User:
Account:
Password:

Thanks.If you are doing this with a batch file you need to create a script file that the ftp commad uses.
 http://www.dostips.com/DtTipsFtpBatchScript.phpThank you for the response. But the problem is with login in to this account using the dos command. The ftp requires to enter a username, password and account. What's the dos command for specifying the account?I am not understanding what you mean by account?

You need three things to login to an ftp site.
Ftp address
Username
PasswordSome ftp sites, like this one, have a fourth requirement: account.From what I have read on most websites just from the little Google Searching I did for you. It looks like you specify the Account after the password.
So if you have an ftp script that looks like this.

open ftp.domain.com
user MyUserName
mypassword
myaccount
put myfile.txt
quitOk thank you for helping me. Here's where I'm stuck now:

530 Non-anonymous sessions must use encryption.
Login failed.
ftp>

I THINK it is because I need to SET FTP over SSL Encryption. But how do I do that in dos command?

Here's what I get:



Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\AdemarN>ftp ftps01.oracle.com
Connected to bigip-ftps01.oracle.com.
220-    ========================= Security Notice ========================
220-    = Access to Oracle On Demand and the Oracle network is limited   =
220-    = to Oracle On Demand customers and authorized Oracle users.     =
220-    = A customer's access to On Demand is subject to the terms of    =
220-    = its On Demand contract; use by authorized Oracle users is      =
220-    = subject to Oracle company policies.                            =
220-    = Unauthorized use of or access to Oracle On Demand is subject   =
220-    = to civil and criminal PENALTIES.                               =
220-    ========================= Attention ==============================
220-    = All files older than 30 days will be purged without notice.    =
220-    ========================= Attention ==============================
220-
220-
220
User (bigip-ftps01.oracle.com:(none)): [usernamehere] [passwordhere] [acconthere]
530 Non-anonymous sessions must use encryption.
Login failed.
ftp>AFAIK you can't with the builtin ftp.exe in Windows.And that's by design...If you Google search HARD enough you will a couple of free ftp clients that support ssl and one of them uses the same syntax as the windows ftp client.

2108.

Solve : How do I Copy a File to the Current users startup folder...????

Answer»

i know how to use xcopy & robocopy to copy files and such to diff places.
but how would you i copy a FILE to the startup location "C:\Documents and Settings\USER\START Menu\Programs\Startup" of the current user if i don't know the users NAME & the user is on a limited Xp account..??
Is there a certain code that would copy the file to the current ushers startup folder without having to PUT the EXACT location address like "C:\Documents and Settings\USER\Start Menu\Programs\Startup"  ...Use %username%. That returns the username of the current user to make coding more generic.

i.e.
Code: [Select]"C:\Documents and Settings\%username%\Start Menu\Programs\Startup"Or even more robust would be:
Code: [Select]copy file.ext "%userprofile%\Start Menu\Programs\Startup"

2109.

Solve : Xcopy form network?

Answer»

I'm trying XCopy from an folder on the network.
Since it is not working I'm wondering this is EVEN possible.   

Code: [Select]xcopy \\Nlf18s01\nlf18$\Test\*.* /a/e C:\Test /y
I'm not exactly sure, but try this:
Code: [Select]xcopy \\Nlf18s01\nlf18$\Test\*.* C:\Test /a/e/y 

Quote

Copies files and directory trees.

XCOPY SOURCE [destination] [/A | /M] [/D[:DATE]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
                           [/EXCLUDE:file1[+file2][+file3]...]
I think that you need the source, the destination, and then the parameters.
2110.

Solve : Alt+255 command / RESOLVED?

Answer»

I'm running Windows Vista Home Premium and Internet Explorer browser 7. My question is:
Can anyone instruct me in how to delete, rename desktop folders whose names have been BLANKED OUT by using the Alt+255 command? I was advised that it could be done in DOS. I am not a DOS user, and a bit vague on it. I have tried a couple of different "DELETE programs but with no luck. I searched this forum but nothing came up about Alt+255.
Kind REGARDS
Perijon. Have you tried running Pocket Killbox?

The person that told you it could be removed in DOS was probably talking about the command prompt \\.\ notation.  If Killbox doesn't work then you can try the command prompt.  Do you know EXACTLY what characters are in the file?  From your explanation, it would be something like:
del "\\.\C:\Users\username\Desktop\file.ext"
If the file has a control character in it, then it must be entered as WELL, by holding down the [Alt] key, and pressing keys 255 on your keyboard's numeric keypad (or whatever the control key is).

How do you know the filename contains the Alt+255 character?
Thankyou for the reply. The command line is C:\Users\dell\Desktop
I typed the command Alt+255 myself, in fact I did it to 3 folders. Alt+255(first folder) Alt+255, Alt+255(second folder),Alt+255, Alt+255, Alt+255 (third folder). Problem with the third folder is that I tried to rename it a couple of times by right clicking it, then rename, and using the back space to delete any characters that were there. Now I can't remember how many times I Alt+255ed the third folder. I read that Alt+255 Ascii is not recognised by windows.When I go to the Desktop directory I can't see the folder.

Regards
perijonWhy aren't you able to delete these folders?  Did you encrypt them?  Is there anything inside of the folders or are they empty?  Under normal circumstances, you should be able to delete these folders.

You can't delete or rename them, but can you move them?I am able to make a directory named (ascii255 character) as well as move, rename and delete it on my system from Windows Explorer, command prompt and the desktop.  I made a directory named LPT1 (using the special notation) and I am not able to rename, delete or move the file in Windows, but I don't have any problems with the [Alt]+255 directory.

Have you tried using the command completion to remove it from the command prompt? Quote from: CBMatt on June 10, 2007, 10:16:39 PM

Why aren't you able to delete these folders?  Did you encrypt them?  Is there anything inside of the folders or are they empty?  Under normal circumstances, you should be able to delete these folders.

You can't delete or rename them, but can you move them?
Hi, WOW, just as I was replying to GuruGary and was ready to post you popped up. GuruGary put me onto "KILLBOX", and it did the job. I managed to delete the folder from the desktop. I had to be careful the way I did it. First I went back to the folder on the desktop and right clicked to rename the folder, then I back-spaced until I was sure I got all the hidden characters. Then I downloaded "POCKET KILLBOX"abd proceeded per instructions. It has a neat little FEATURE to the right of the command path entry box to click on so you can view the file or folder to see if you have the correct one. The only one you cannot delete or rename is the recycle bin. There is another program to do this, mentioned at:                 http://www.howtogeek.com/howto/windows-vista/hide-desktop-icon-text-on-windows-vista/

Thanks very much for you help!
Regards
Perijion Quote from: GuruGary on June 10, 2007, 10:29:47 PM
I am able to make a directory named (ascii255 character) as well as move, rename and delete it on my system from Windows Explorer, command prompt and the desktop.  I made a directory named LPT1 (using the special notation) and I am not able to rename, delete or move the file in Windows, but I don't have any problems with the [Alt]+255 directory.

Have you tried using the command completion to remove it from the command prompt?
Thanks for your great help GuruGary, please read my reply to CBMatt.
Regards
PerijonWell, KUDOS to Gary.  I'm glad it's all sorted out.
2111.

Solve : Can't access D from the command line?

Answer»

Hi I tried googling but couldn't find a answer ,tried TYPING   d:  from the command line but can't seem to access the D drive,was wondering if anyone could help?

What command line? Real MS-DOS? A command session in Windows? What kind of disk is D:? What filesystem?

Yeah hi I didn't know they was different kinds of command lines its the one in windows xp service pack 3..
I don't know about file systems ,do you mean NTFS5 I would THINK that is the one,the D drive is the CD ROM drive by the way,can't think what would cause this recently I changed the properties of the D drive so as to enable recording but I don't think that would be the cause.I kinda fixed the problem in a way because when I open the command line from the run box and typing in command.....I can switch drives USING  d: ...
But if I open it using CMD  the d: won't work...COMMAND  and  CMD may not have the same drive list.
Search the MS KB for info about the diff between CMD and COMMAND.

2112.

Solve : help with cmd script?

Answer»

hello
i just have a quick question
is there a way or a script trough cmd
that can take some data in a line and put it in other line
like this:

boris


is there a way to take the boris name and paste it in


so it will look like this
boris
boris

and for multiple cases if theres multiple
name of someone

and under that theres an empty


it will look for the data in and place the variable in
in the whole file


thanks.
download gawk for windows, then  use this gawk script

Code: [Select]BEGIN{ FS="[&LT;>]" }
/<name>/{ name=$3 }
/<vir_name>/{ $0="<vir_name>"name"</vir_name>" }
{print}
save as myscript.awk, and on command line

Code: [Select]C:\test>type file
<name>boris</name>
<vir_name></vir_name>
blah
<name>becker</name>
<vir_name></vir_name>
blah

C:\test>gawk -f myscript.awk file
<name>boris</name>
<vir_name>boris</vir_name>
blah
<name>becker</name>
<vir_name>becker</vir_name>
blah

redirect using ">" to save to a new file as desired. Quote from: ghostdog74 on April 21, 2010, 03:21:17 AM

download gawk for windows, then  use this gawk script

Code: [Select]BEGIN{ FS="[<>]" }
/<name>/{ name=$3 }
/<vir_name>/{ $0="<vir_name>"name"</vir_name>" }
{print}
save as myscript.awk, and on command line

Code: [Select]C:\test>type file
<name>boris</name>
<vir_name></vir_name>
blah
<name>becker</name>
<vir_name></vir_name>
blah

C:\test>gawk -f myscript.awk file
<name>boris</name>
<vir_name>boris</vir_name>
blah
<name>becker</name>
<vir_name>becker</vir_name>
blah

redirect using ">" to save to a new file as desired.

thanks for the reply but specifically this i can do with simple cmd script
what i am looking for is a script that will be more dynamic

if i am working on an xml file and have multiple properties in there and the property names are
blabla
and i also have a property


i would want it to fill every value that in in to
and there can be a dynamic number of properties
and the property is already in the xml file
so i dont need to create it
i just need to insert the data from in to Quote
thanks for the reply but specifically this i can do with simple cmd script
what i am looking for is a script that will be more dynamic

More dynamic than what? If you already have a simple cmd script, why are you not using it?

Microsoft provides an object (actually two) for traversing the nodes in a XML file, however yours is ill-formed and would choke a VBScript. For instance, judging from your post, <name> and <vir_name> are siblings. What is the parent node?  Where do <DISPLAY_NAME> and <CANONICAL_NAME> logically fit into the tree? Is there a root to the tree and if so what is it.

Personally I don't find Gawk to be very intuitive, but it WORKS and sometimes you need brute force instead of dynamic.

  Quote from: Sidewinder on April 22, 2010, 05:48:03 AM
More dynamic than what? If you already have a simple cmd script, why are you not using it?

Microsoft provides an object (actually two) for traversing the nodes in a XML file, however yours is ill-formed and would choke a VBScript. For instance, judging from your post, <name> and <vir_name> are siblings. What is the parent node?  Where do <DISPLAY_NAME> and <CANONICAL_NAME> logically fit into the tree? Is there a root to the tree and if so what is it.

Personally I don't find Gawk to be very intuitive, but it works and sometimes you need brute force instead of dynamic.

 

hi, i have a script that does what the gawk script above but i dont really need it in most situations
for example i have properties in some xml

       
           
            4
            Hello
           
            1
            0
            0
           
            1
           
            1
            11111111
           
           
           
           
           
       

these are most situation and the properties are build that way so what i need is
a script that will take 'Hello' from and paste it in
so the FINAL file will look like that

       
            Hello
            4
            Hello
           
            1
            0
            0
           
            1
           
            1
            11111111
           
           
           
           
           
       

putting manually a possible situation in the script will force me to write a wall of scripting
and i have numerous properties in the xml that the structure are the same as above but only the property_id changes and the labeling values
so what i need is that it will go trough the file and put value in
thats pretty much it...

thanks I had to add a ROOT node to the tree structure. The root node ties the entire file together.

Quote
<?xml version="1.0"?>
<ROOT>
   <PROPERTY>
      <CANONICAL_NAME>Hello</CANONICAL_NAME>
      <CURRENT_STATE>4</CURRENT_STATE>
      <DISPLAY_NAME>Hello</DISPLAY_NAME>
      <FORMAT_STRING></FORMAT_STRING>
      <IS_COMPUTED>1</IS_COMPUTED>
      <IS_MANAGED>0</IS_MANAGED>
      <IS_MULTI_VALUED>0</IS_MULTI_VALUED>
      <IS_PCODE></IS_PCODE>
      <IS_STRING>1</IS_STRING>
      <IS_URI></IS_URI>
      <LOCALE_ID>1</LOCALE_ID>
      <PROPERTY_ID>11111111</PROPERTY_ID>
      <STORAGE_UNIT></STORAGE_UNIT>
      <TIP_TEXT></TIP_TEXT>
      <VALUE_SORT_TYPE></VALUE_SORT_TYPE>
      <VIEWBY_UNIT></VIEWBY_UNIT>
      <MANAGED_PROPERTY_VALUES></MANAGED_PROPERTY_VALUES>
   </PROPERTY>
   <PROPERTY>
      <CANONICAL_NAME>Goodbye</CANONICAL_NAME>
      <CURRENT_STATE>4</CURRENT_STATE>
      <DISPLAY_NAME>Goodbye</DISPLAY_NAME>
      <FORMAT_STRING></FORMAT_STRING>
      <IS_COMPUTED>1</IS_COMPUTED>
      <IS_MANAGED>0</IS_MANAGED>
      <IS_MULTI_VALUED>0</IS_MULTI_VALUED>
      <IS_PCODE></IS_PCODE>
      <IS_STRING>1</IS_STRING>
      <IS_URI></IS_URI>
      <LOCALE_ID>1</LOCALE_ID>
      <PROPERTY_ID>11111111</PROPERTY_ID>
      <STORAGE_UNIT></STORAGE_UNIT>
      <TIP_TEXT></TIP_TEXT>
      <VALUE_SORT_TYPE></VALUE_SORT_TYPE>
      <VIEWBY_UNIT></VIEWBY_UNIT>
      <MANAGED_PROPERTY_VALUES></MANAGED_PROPERTY_VALUES>
   </PROPERTY>
</ROOT>

Code: [Select]Set xmlDoc = CREATEOBJECT("Microsoft.XMLDOM")

xmlDoc.Async = "False"
xmlDoc.Load("c:\temp\test.xml")          'Change as needed (input XML file)

Set colDisplayNodes=xmlDoc.documentElement.selectNodes("/ROOT/PROPERTY/DISPLAY_NAME")
For Each displayNode in colDisplayNodes
  Set colCanonNodes = xmlDoc.documentElement.selectNodes _
  ("/ROOT/PROPERTY " & _
"[DISPLAY_NAME = " & "'" & displayNode.text & "'" & "]/CANONICAL_NAME")
  For Each canonNode In colCanonNodes
     canonNode.text = displayNode.text
  Next
Next

xmlDoc.Save "c:\temp\Testout.xml"         'Change as needed (output XML file)

Save the file with a VBS extension and run from the command prompt as cscript scriptname.vbs Can also be run from a cmd file the same way.

Good luck. 

The XMLDOM object will realign your XML file correctly. No extra charge.
2113.

Solve : Batch menu that works on every windows version??

Answer»

Since the CHOICE command is not available on WINDOWS 2000 and XP, I used a construction like this:

Code: [SELECT]:start
ECHO.
ECHO 1. Print Hello
ECHO 2. Print Bye
ECHO 3. Print Test
set choice=
set /p choice=Type the number to print text.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto hello
if '%choice%'=='2' goto bye
if '%choice%'=='3' goto test
ECHO "%choice%" is not valid please TRY again
ECHO.
goto start
Thing is that this batch isn't just for me and needs to WORK on a variety of windows versions. So my QUESTION is this: Will this work on Vista/Win7?
See no reason why it won't. Best way to find out is to test it. The code will not work on Win9x machines.

To make it completely idiot proof, you could test what version of Windows is running (use the ver command in a for loop) and design your file to use either choice or set /p.

  Quote from: Kolya on April 22, 2010, 06:30:24 AM


Thing is that this batch isn't just for me and needs to work on a variety of windows versions. So my question is this: Will this work on Vista/Win7?


Test on Win7:

C:\>type  menu.bat
echo off
:start
ECHO.
ECHO 1. print Hello
ECHO 2. print  Bye
ECHO 3. print Test
set choice=
set /p choice=Type the number to print text.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto hello
if '%choice%'=='2' goto bye
if '%choice%'=='3' goto test
ECHO "%choice%" is not valid please try again
ECHO.
goto start

:hello
echo Hello
goto start
:test
echo test
goto start
:bye
echo bye

C:\>menu.bat

1. print Hello
2. print  Bye
3. print Test
Type the number to print text.1
Hello

1. print Hello
2. print  Bye
3. print Test
Type the number to print text.3
test

1. print Hello
2. print  Bye
3. print Test
Type the number to print text.
"" is not valid please try again


1. print Hello
2. print  Bye
3. print Test
Type the number to print text.2
byeI don't have access to Windows 7, so I couldn't test it. I also thought about running two ways with an OS check and using "choice" or "set /p".
But I got confirmation meanwhile that it works on Windows 7.
Thanks for your help.
2114.

Solve : Embed VBScript in cmd/bat script?

Answer»

... with one gotcha: no labels. I make no great claims for this, I just present it as a curiosity. There are other ways of doing this.

A LEADING colon in a batch file is ignored because it denotes a label; it is ignored in VBscript because it is a command separator. Thus the batch script can search itself for lines beginning with a colon and write them out to a temporary vbs file and then execute it.

CODE: [Select]echo off
echo This is batch
:wscript.echo "This VBScript"
:wscript.echo "Today is " & day(date) & "-" & month(date) & "-" & year(date)
findstr "^:" "%~sf0">temp.vbs & cscript //nologo temp.vbs & del temp.vbs
echo This is batch again

Code: [Select]This is batch
This VBScript
Today is 21-4-2010
This is batch again
Maybe you want to use some GUI feature of wscript e.g. to get user input

Code: [Select]echo off
:wscript.echo InputBox("Enter your name")
findstr "^:" "%~sf0">temp.vbs & for /f "delims=" %%N in ('cscript //nologo temp.vbs') do set name=%%N & del temp.vbs
echo You entered %name%Neat!
Worked firs time!but why does anyone want to write hybrids in the first place? i don't understand.
1) makes code uneasy to read and troubleshoot
2) have to take care of different syntax between vbscript and batch.
3) creation of temp files everytime the batch is run. why not just write one vbscript and run it instead.

ghostdog74 ,
Your point of view is valid. Many will agree with you.

Yet others will just love the way he put it all in one box.A large number of everyday real world coders often use hybrid methods.

The novelty of this batch file is that it is a legal batch file!

The concept is by no means new. Some COBOL Programs had FORTRAN embedded in the source code. There was COBOL  statement to invoke the FORTRAN compiler for some calculations.


Quote from: ghostdog74 on April 21, 2010, 06:27:21 PM

but why does anyone want to write hybrids in the first place? i don't understand.
1) makes code uneasy to read and troubleshoot
2) have to take care of different syntax between vbscript and batch.
3) creation of temp files everytime the batch is run. why not just write one vbscript and run it instead.





Quote from: Salmon Trout
I make no great claims for this, I just present it as a curiosity. There are other ways of doing this.
Quote
1) makes code uneasy to read and troubleshoot
As opposed to, of course, the perfectly easy to read perl.

Quote
2) have to take care of different syntax between vbscript and batch.
perl programmers have no PROBLEM taking care of the different syntax between perl and Regular Expressions. .NET programmers have no problem differentiating language constructs from those provided by LINQ, and I hardly see batch+VBS as a exceptional case.

Quote
3) creation of temp files everytime the batch is run. why not just write one vbscript and run it instead.

As surprising as this may sound there is a lot of functionality in batch (particularly in the various NT extensions) that, while doable in VBScript, are far more verbose. also, we cannot forget that a a good number of the very tools you recommend (sed, gawk, and a few others) are at their best when combined with the shell in which they run- piping output to and from SED is it's very purpose, just like find and sort, both of which have functionality that is verbose and prone to errors when attempting to duplicate in VBScript. also, this allows one to combine Batch with SED and other tools of that nature with VBScript.


There is a rather large downside, and that is the extraneous use of find in order to "extract" the vbscript, but one can generally assume that a batch files run-time is far less important then it's results, and unless it is run extensively and/or with a large batch file it's usually of little consequence.



Quote from: Geek-9pm on April 21, 2010, 07:46:14 PM
The concept is by no means new. Some COBOL Programs had FORTRAN embedded in the source code. There was COBOL  statement to invoke the FORTRAN compiler for some calculations.

I embed machine code instructions in my Visual basic programs in the form of a string variable or constant, and then use that as a Window Procedure for subclassing; The Machine Code is given access to the Vtable of a specific Interface and calls the methods on that interface, which I implement elsewhere. (in a class module, for example).

VB6 of course has built-in "support" for callback routines (in the form of the addressof Operator) however, one can only use addressof on functions/routines in public modules; managing and dispatching each callback to the appropriate object that is to receive it is nothing short of difficult. Also, it means that using the debugging tools (break, stop, breakpoints, etc) will cause a instant Fault and VB will crash. Using a String variable containing Machine code has two advantages- first, it can be used without a module (meaning each class is self-contained) and second, since the string pointer remains valid, it doesn't crash the IDE when the break/end etc. buttons are used. My first concern using this technique was that it might somehow trigger DEP (data execution) but it didn't, and it's worked fine so far.

A prime example of this facility in use was a class I wrote for better control of window sizing- namely, to allow for the handling of the WM_GETMINMAXINFO; the class itself simply needs to be instantiated, given a form/hwnd, and it does the rest; allowing the use of properties to control the minimum and maximum size of the form/window. I've used this mechanism extensively in a number of classes designed for various features, They generally implement a particular feature, such as, for example, handling combobox histories, or listview sorting messages, etc.

Of course newer languages (such as .NET) have most of these features built in, (namely, I speak of the ability to handle WndProc for nearly any hWnd) but such luxuries come at a price- the installation of the framework, which is not always quick, small, or always error-free.

I'm not sure about Python, But I do know that  Perl was intentionally designed in a way DISSIMILAR to most languages. Most languages make you think of your problem in terms of the language, Perl is designed to allow you to think of your problem and code your solution to the problem.

it's not about what language you use, it's about solving the problem. Wether a batch file, a python script, a perl script, VBScript, or even a batch file with VBS inside solves it is completely irrelevant.


Quote from: Geek-9pm on April 21, 2010, 07:46:14 PM
Yet others will just love the way he put it all in one box.A large number of everyday real world coders often use hybrid methods.
in one box? what do you mean ?  when you write a pure vbscript script, you are also putting them in one box right?

Quote from: BC_Programmer on April 21, 2010, 08:21:31 PM
it's not about what language you use, it's about solving the problem. Wether a batch file, a python script, a perl script, VBScript, or even a batch file with VBS inside solves it is completely irrelevant.
That's not true. The language you use have a part to play as well. Yes, all of these you mention , including batch, are able to solve problems,  but there are many ways to arrive at the solution to that problem, especially if its a complex one. With good language features, you arrive at the solution faster and with much ease than others. A good language helps the user(programmer/sysadmin etc) increase productivity(every where and anywhere)Can have labels that start with a certain string

Code: [Select]echo off
:wscript.echo InputBox("Enter your name")
findstr "^:" "%~sf0" | findstr /i /v ":label" >temp.vbs & for /f "delims=" %%N in ('cscript //nologo temp.vbs') do set name=%%N & del temp.vbs
echo You entered %name%
:label1
2115.

Solve : Would Like a "Simple" Batch file, I think...?

Answer»

Can't find a way to create a text file of all files on a drive sorted by Dir, sub dir.. with attributes.
It seems simple, but I am not getting it!

Can anyone help?This little snippet may help:

Code: [Select]echo off
for /f "tokens=*" %%i in ('dir /s /b /a d:\') do (
  attrib "%%i" >> dir.txt


Be sure to change the drive letter in the dir command and you might want to add path information to the output file (dir.txt)

Good luck.  This is what I am using:
Code: [Select]echo off
for /f "tokens=*" %%i in ('c: /s /b /a d:\') do (
  attrib "%%i" >> c:\dir.txt

notepad c:\dir.txt
and I get a blank notepad doc.

Thus, It doesn't seem to be working for me.

hmm...

tree /f does everything you want except showing attributes.echo off
del d:\dir.txt
for /f "tokens=*" %%i in ('dir /s /b /a /a-d d:\') do (
  attrib "%%i" >> d:\dir.txt



small part of output file...

A    R       D:\Multimedia\Rail Videos\DVD-1\avi\87012.avi
A            D:\Multimedia\Rail Videos\DVD-1\avi\90 [pal-vcd][mpeg2video][mp2].mpg
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\90.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\90024-tpo-rugby.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\90029-tpo-rugby.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\91119-snow-h.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\d9000_1.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\d9000_2.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\d9000_3.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\d9016-cw.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\d9016.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\deltic-firestarter-h.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\e-star_rescue.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\gn-cannons.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\grice-deltics-h.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\kings_cross.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\lickey-h.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\pendolino_euston_h.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\pendolino_euston_walkthro_h.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\run1_10-23.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\run3_11-29.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\run4_11-47.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\run8_14-20.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\serco-spoonz.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\spanish_inquis-h.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\spinnin_state_iv-h.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\spin_doctor_nuneaton-h.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\uosa.avi
A    R       D:\Multimedia\Rail Videos\DVD-1\avi\welham_green.avi
A            D:\Multimedia\Rail Videos\flv\2-Rickmansworth to Amersham driver pov.flvYes silly me changed "dir" to "c:".  It works great... Thanks all.

SolvedAlternative, better attribute info by using %%~a variable modifier to get a 9 char attribute STRING, EXPLANATION below,

Code: [Select]echo off
del d:\dir.txt
for /f "tokens=*" %%i in ('dir /s /b /a d:\') do (
  echo %%~ai %%~dpnxi >> d:\dir.txt
 ) 


Code: [Select]d--hs---- d:\$RECYCLE.BIN
--a------ d:\msdia80.dll
dr-h----- d:\MSOCache
d-------- d:\Multimedia
d-------- d:\Sandbox
d-------- d:\SIEVE
d--hs---- d:\System Volume Information
d-------- d:\templogs
d-------- d:\Tempvu
d--hs---- d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000
d--hs---- d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1001
d--hs---- d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1002
d--hs---- d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1017
d--hs---- d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-500
d--hs---- d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-501
--a------ d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\$I4LZW3U.srt
--a------ d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\$I5OT8XX.nfo
--a------ d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\$IBD8E95.zip
--a------ d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\$IBRM3TZ.nfo
--a------ d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\$IGILP8T.txt
--a------ d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\$IIKWE2S.exe
--a------ d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\$IM079V9.rar
--a------ d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\$R4LZW3U.srt
--a------ d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\$R5OT8XX.nfo
--a------ d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\$RBD8E95.zip
--a------ d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\$RBRM3TZ.nfo
--a------ d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\$RGILP8T.txt
--a------ d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\$RIKWE2S.exe
--a------ d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\$RM079V9.rar
--ahs---- d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1000\desktop.ini
--ahs---- d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1001\desktop.ini
--ahs---- d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1002\desktop.ini
--ahs---- d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-1017\desktop.ini
--ahs---- d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-500\desktop.ini
--ahs---- d:\$RECYCLE.BIN\S-1-5-21-2475452901-1092781832-1925167435-501\desktop.ini
dr------- d:\MSOCache\All Users
dr------- d:\MSOCache\All Users\90000409-6000-11D3-8CFE-0150048383C9
d-------- d:\MSOCache\All Users\90000409-6000-11D3-8CFE-0150048383C9\FILES
--a------ d:\MSOCache\All Users\90000409-6000-11D3-8CFE-0150048383C9\PRO11.MSI
--a------ d:\MSOCache\All Users\90000409-6000-11D3-8CFE-0150048383C9\SKU011.XML
d-------- d:\MSOCache\All Users\90000409-6000-11D3-8CFE-0150048383C9\FILES\PFILES
d-------- d:\MSOCache\All Users\90000409-6000-11D3-8CFE-0150048383C9\FILES\SETUP

Code: [Select]attrib string has 9 characters

each character is either a letter if the attribute is YES or a - symbol if attribute is NO
their meanings:

123456789
drahscotl

1 d=is a DIRECTORY
2 r=is read only
3 a=has archive bit set
4 h=is a hidden file
5 s=is a system file
6 c=is a compressed file
7 o=is an offline file
8 t=is a temporary file
9 l=is a link (junction point)

note that in 4,5 and 6 'file' should read 'file or directory', possibly 7 and 8 too

2116.

Solve : Batch Commands?

Answer»

You changed the word damned to asterisk-censored-asterisk??? Is this 1810? Is my calendar broken? What planet are you from? Planet God Hates Profanity?





Quote from: Helpmeh on March 26, 2010, 03:55:30 PM

I don't think he realized that he was on his Greg ACCOUNT and not his other account when he was complementing himself.

Quote from: Helpmeh on March 22, 2010, 04:22:49 PM
"Maybe he will post to deny these accusations."


Greg Explains:
I sent the bogus information about Greg (me) having several current LOGINS to the CH staff. I used the abuse button  to send the message.

I have never had more than one current login at CH.

The CH staff can verify this with my ip address. 

Only the CH staff has my ip address.

Helpmeh is not CH staff Quote from: Salmon Trout on March 26, 2010, 05:39:19 PM
You changed the word damned to asterisk-censored-asterisk??? Is this 1810? Is my calendar broken? What planet are you from? Planet God Hates Profanity?






No, I have the word filter enabled. I didn't change what I saw in any way. Quote from: Helpmeh on March 26, 2010, 06:47:20 PM
No, I have the word filter enabled. I didn't change what I saw in any way.

Helpmeh,

Salmon Trout's "asterisk-censored-asterisk" comment was for the CH staff. Quote from: greg on March 26, 2010, 07:03:12 PM
Helpmeh,

Salmon Trout's "asterisk-censored-asterisk" comment was for the CH staff.
No. He was asking why I filtered out a word he wrote, when in fact the system filtered it, but did not un-filter it for him. Quote from: Salmon Trout on March 26, 2010, 12:14:10 PM
What is the point of greg's posts on here? They do absolutely nothing.


I usually just sort of shake my head in a dissapointing way, like a grandson when they finally realize that their grandfathers best friend is a old sock puppet and/or imaginary.

re: the "censored" thing, I find that it does that when you use the quote button, regardless of profile settings.

Either way, the meaningless demonstration of how Greg/Whoever doesn't understand that not everybody in the world has this lpr program nor access to this print server is rather entertaining, especially given the delicious hypocritical twist since he constantly uses "sed" and other TOOLS with absolutely no mention of their source or where to get them, or REALLY, anything other then a post containg his code and the output from a completely different set of code. And of course complaining about how other peoples solutions don't work after he butchers them.

IN any case, All I can suggest is the use of quotes around "%1" in the lpr command. Quote from: BC_Programmer on March 26, 2010, 07:32:11 PM

IN any case, All I can suggest is the use of quotes around "%1" in the lpr command.

BC is a sad case. All BC can do is repeat the misinformation started by other troublemakers.

Greg has not had more than one current username. "OLD sock puppet" is an insult ( abusive post ).
 
Before anyone can be a "sock puppet" they need more than one current "username."  BC cannot list any current "usernames" used by Greg other than Greg.  Where are the posts ( BC ) where Greg is using another "username?"

BC pretends he is a computer programmer that uses "C" and many other programming languages.

But BC has never used or heard of Sed.  Sed is a Unix utility that was created by AT&T in 1970. Anyone who has used Linux or Unix has used Sed.

BC can always tells us what is wrong ( and his idea is usually false ) but seldom offers any suggestions for the Original Poster of any question at CH.

The only suggestion by BC had for the Lpr problem was to repeat what Helpmeh had already suggested.

__________________________________

reference:
http://www.yourdictionary.com/computer/sock-puppet
2117.

Solve : Batch file Question MSGBOX?

Answer»

can i create a msgbox which asks something like

Do you like cheese

Yes                  No

if no then :no
if yes then :yes

:no
echo how could it be
goto end

:yes
echo great !
goto endBatch is a non-GUI (graphic user INTERFACE). That means it doesn't do message boxes. I suggest using a VBS ALTERNATIVE. WELL then how can i make it with a vbs script ?One each message box coming up:

Code: [Select]rc = MsgBox("Do you like cheese?", vbYesNo, "My Message Box")
If rc = 6 Then WScript.Echo "Great !"
If rc = 7 Then WScript.Echo "How could it be?"

Save snippet with a vbs extension and run from the command prompt as cscript scriptname.vbs

The NT msg command only OFFERS an OK button.

Good luck. 

2118.

Solve : How do I select text from text file??

Answer»

Hi there:
I didn't find how POSSIBLE to select text from text-file
for example I have xml-file with string:
<suit:run DATE="Thu 12/21/2012 12:12 PM EST" machine="garg" build="27801" level="alpha" release="7.8" os="Windows XP">

I need select only build number <<27801>> not all string, such as FIND works.

FIND works:

>find "build" suite.xml

---------- SUITE.XML
    <suit:run date=" Thu 12/21/2012 12:12 PM EST" machine="garg" build="27801" level="alpha" release="7.8" os="Windows XP">


 you are going to use better tools than that. Download sed from GNU win32, and then do this one LINER

Code: [Select]C:\test>sed -n "/build/s/\(.*build=\"\)\([0-9]\+\)\(.*\)/\2/p" file
27801

2119.

Solve : Help with Batch Command File?

Answer»

Hey guys just a beginner here and trying to simply my life and few others.

I have succesfully made a install batch file and now im working on the Uninstall portion to help make things easier.

I have most of this complete and im stuck on just the ONE portion. Im stuck on the portion where the uninstall string has to be made from a CMD prompt. Im not sure how to make that call. To open the prompt to type in the command etc.

Here is what i have so far and to give you a idea of what im trying to do

Code: [Select]Echo ***************************************************************
Echo * *** Custom Uninstall Menu for IT Only ***           
Echo *
Echo * To Uninstall McAfee Site Advisor, Choose A
Echo *
Echo * To Uninstall Host Intrusion Protection Services, Choose B
Echo *
Echo * To Uninstall McAfee Anti SPYWARE, Choose C
Echo *
Echo * To Uninstall McAfee Virus Scan Enterprise, Choose D
Echo *
Echo * To Uninstall McAfee File Folder Encryption,choose E
Echo *
Echo * To Uninstall McAfee ePO Frame Package, Choose F
Echo *
Echo * To Exit, Choose X            
Echo *
Echo ****************************************************************
Echo:
choice /C abcdefx /m "Please Make your Selection from the Above Options"

IF ERRORLEVEL 7 goto x
IF ERRORLEVEL 6 goto F
IF ERRORLEVEL 5 goto E
IF ERRORLEVEL 4 goto D
IF ERRORLEVEL 3 goto c
IF ERRORLEVEL 2 goto B
IF ERRORLEVEL 1 goto A

:A
call MsiExec.exe /X{00FC3F65-86EB-475E-881F-A5B1CF731320} REMOVE=ALL
cls
goto menu

:B
call MsiExec.exe /X{B332732A-4958-41DD-B439-DDA2D32753C5} REMOVE=ALL
cls
goto menu

:C
call C:\Program Files\McAfee\VirusScan Enterprise\scan32.exe /UninstallMAS
cls
goto menu

:D
call msiexec /x {147BCE03-C0F1-4C9F-8157-6A89B6D2D973} REMOVE=ALL
cls
goto menu
:E
call C:\Program Files\McAfee\Endpoint Encryption for Files and Folders\SbCeSetup -Uninstall -Confirm "-AppName:McAfee Endpoint Encryption for Files and Folders"
cls
goto menu

:F
call MsiExec.exe /X{362678B4-6ED5-46E9-A6B2-53EF22159151} REMOVE=ALL
cls
goto menu

:X
:exit
cls
echo This Utility will now exit
pauseREM cmd will open a new command window
Rem or  "start  program"  will open a new command window provided
Rem the path to program is correct


C:\batch>type neo.bat
echo off

:menu
Echo * *** Custom Uninstall Menu for IT Only ***

Echo A) To Uninstall McAfee Site Advisor

Echo B) To Uninstall Host Intrusion Protection Services

Echo C) To Uninstall McAfee Anti Spyware

Echo D) To Uninstall McAfee Virus Scan Enterprise

Echo E) To Uninstall McAfee File Folder Encryption

Echo F) To Uninstall McAfee ePO Frame Package

Echo X) To Exit


Echo :choice /C abcdefx
SET /p Option=Choice:
echo Option =%Option%
pause

if %Option%==A   goto A
if %Option%==B GOTO B
if %Option%==C GOTO C
if %Option%==D GOTO D
if %Option%==E GOTO E
if %Option%==F GOTO F
if %Option%==X GOTO X
Goto menu

rem IF ERRORLEVEL 7 goto x
rem IF ERRORLEVEL 6 goto F
rem IF ERRORLEVEL 5 goto E
rem IF ERRORLEVEL 4 goto D
rem IF ERRORLEVEL 3 goto C
rem IF ERRORLEVEL 2 goto B
rem IF ERRORLEVEL 1 goto A

:A
C:\WINDOWS\system32\MsiExec.exe /X{00FC3F65-86EB-475E-881F-A5B1CF731320} REMOVE=
ALL
echo inside A
pause
cls
goto menu

:B
C:\WINDOWS\system32\MsiExec.exe /X{B332732A-4958-41DD-B439-DDA2D32753C5} REMOVE=
ALL
echo inside B
pause
cls
goto menu

:C
echo inside C
"C:\Program Files\McAfee\VirusScan Enterprise\scan32.exe" /UninstallMAS
echo inside C
pause
cls
goto menu



C:\WINDOWS\system32\MsiExec.exe /x {147BCE03-C0F1-4C9F-8157-6A89B6D2D973} REMOVE
=ALL
echo inside D
pause
cls
goto menu
:E
"C:\Program Files\McAfee\Endpoint Encryption for Files and Folders\SbCeSetup" -U
ninstall -Confirm "-AppName:McAfee Endpoint Encryption for Files and Folders"
echo inside E
pause
cls
goto menu

:F
C:\WINDOWS\system32\MsiExec.exe /X{362678B4-6ED5-46E9-A6B2-53EF22159151} REMOVE=
ALL
echo inside F
pause
cls
goto menu

:X
echo inside X
echo Bye
pause
:exit
pause
echo inside exit
echo This Utility will now exit
pause

Output:


C:\batch>neo.bat
* *** Custom Uninstall Menu for IT Only ***
A) To Uninstall McAfee Site Advisor
B) To Uninstall Host Intrusion Protection Services
C) To Uninstall McAfee Anti Spyware
D) To Uninstall McAfee Virus Scan Enterprise
E) To Uninstall McAfee File Folder Encryption
F) To Uninstall McAfee ePO Frame Package
X) To Exit
:choice  abcdefx
Choice:

2120.

Solve : script to copy a section of .xml file?

Answer»

now thats what I THOUGHT OUGHT to have been to achieveable
thanks again Sidewinder WORKED PERFECT.

2121.

Solve : "Invalid command line arguments" please read this first..?????

Answer»

This is command i am trying to execute from command prompt

D:\softwares\setup\setup.exe -sa -ver isolated -path "C:\tsdct\ETAS\ASCET-DIFF\V6_1_0_BETA2","C:\TSDE_Workarea\ETASData\ASCET-DIFF\V6_1_0_BETA2" -
title "ASCET-DIFF V6.1.0_CS_Alpha_1_RC1" -reg 6_1_0BETA -isolated 6_1_0 -silent

after executing this command we are getting an error MESSAGE SAYING "INVALID command line argument please see windows installer for more HELP"..??

As i am new to windows installer i doesnt know what is the problem..so please help me..all help would be appreciated.a windows installer is a windows PROGRAM .. precede the commands with the START keyword

2122.

Solve : DOS Printing problem?

Answer»

Dear All,
my users were using FoxPro system on Win98 OS. in win98 OS there is provision of LPT1 port capturing for DOS printing. as i have now deployed WinXP on many of the users system we USE net use command for the printing. my PROBLEM is that i have to login as a administrator on each system to retype the command. To reduce my daily exercise i created batch file in which i defined all net use credentials and put it startup folder. as the user signin to the computer the batch file RUN itself but it halted and asked for credential which i have already provided in the batch file. if i give that credential again it give me error message "Access denied". if i login with the administrator the batch file run perfectly. can anyone help me what to do. i have also defined administrator username and PASSWORD in batch file but it's not working.

Regards,
Yasir BAIG

2123.

Solve : create file from text file?

Answer»

I'm trying to  create files from a list but it only gets about half done then says con and wont do anything.code
Code: [Select]echo off
setlocal enabledelayedexpansion
for /f "delims= " %%a in (dic.txt) do (
echo %%a > %%a.spl
)
Quote from: mat123 on March 18, 2010, 08:12:23 PM

Create files from a list

C:\>type  matt.bat
Code: [Select]echo off
setlocal enabledelayedexpansion
for /f "delims=" %%i in (dic.txt) do (
echo i = %%~ni
echo %%~ni >> "%%~ni.spl"
)
Output:

C:\>matt.bat
i = abc
i = abc2
i = abc5
i = ans
i = arc
i = battxt
i = bill72
i = CDrive
i = christmas
i = count
i = data06
i = date
i = datfile
i = david
i = db
i = direc_txt
i = dirvar
i = disklog
i = dr
i = File 1 test
i = File 2 test
i = fille
i = final


C:\>dir *.spl
 Volume in drive C has no label.
 Volume Serial NUMBER is F4A3-D6B3

 Directory of C:\

03/18/2010  09:52 PM                 6 abc.spl
03/18/2010  09:52 PM                 7 abc2.spl
03/18/2010  09:52 PM                 7 abc5.spl
03/18/2010  09:52 PM                 6 ans.spl
03/18/2010  09:52 PM                 6 arc.spl
03/18/2010  09:52 PM                 9 battxt.spl
03/18/2010  09:52 PM                 9 bill72.spl
03/18/2010  09:52 PM                 9 CDrive.spl
03/18/2010  09:52 PM                12 christmas.spl
03/18/2010  09:52 PM                 8 count.spl
03/18/2010  09:52 PM                 9 data06.spl
03/18/2010  09:52 PM                 7 date.spl
03/18/2010  09:52 PM                10 datfile.spl
03/18/2010  09:52 PM                 8 david.spl
03/18/2010  09:52 PM                 5 db.spl
03/18/2010  09:52 PM                12 direc_txt.spl
03/18/2010  09:52 PM                 9 dirvar.spl
03/18/2010  09:52 PM                10 disklog.spl
03/18/2010  09:52 PM                 5 dr.spl
03/18/2010  09:52 PM                14 File 1 test.spl
03/18/2010  09:52 PM                15 File 2 test .spl
03/18/2010  09:52 PM                 8 fille.spl
03/18/2010  09:52 PM                 8 final.spl
              23 File(s)            199 BYTES
               0 Dir(s)  297,830,707,200 bytes free

C:\>

Input:

C:\>type dic.txt
abc.txt
abc2.txt
abc5.txt
ans.txt
arc.txt
battxt.txt
bill72.txt
CDrive.txt
christmas.txt
count.txt
data06.txt
date.txt
datfile.txt
david.txt
db.txt
direc_txt.txt
dirvar.txt
disklog.txt
dr.txt
File 1 test.txt
File 2 test .txt
fille.txt
final.txt

C:\>THANKS it worked for all 58,112 words
2124.

Solve : Help required to improve the batchfile.?

Answer»

I have created a schedule task for taking backup of emails from notebook.

I have created a batchfile named: emailfri.bat (execution time: 12.45 pm)
Code: [Select]taskkill /s bkkedia-pc.rsr.hngil.com /im outlook.exe
taskkill /s abanerjee.rsr.hngil.com /im outlook.exe
taskkill /s rlkhandelia.rsr.hngil.com /im outlook.exe
taskkill /s smodak.rsr.hngil.com /im outlook.exe
DEL /F /Q d:\backup\hngrsremail\emailfri.zip
"C:\Program Files (x86)\PKWARE\PKZIPC\pkzipc.exe" -add=update -directories -recurse d:\backup\hngrsremail\emailfri.zip c:\backup\email.txt


In the email.txt I have written the FOLLOWING:
Code: [Select]\\bkkedia-pc\Outlook\*
\\abanerjee\Outlook\*
\\rlkhandelia\Outlook\*
\\smodak\Outlook\*

I have created another batchfile named: notification1240.bat (execution time: 12.40 pm)
Code: [Select]msg proy /server:proy.rsr.hngil.com 'Microsoft Outlook will be shut down at 12.45 hrs for Mail Backup, please SAVE your work till further INFORMATION"
msg jkmalpani /server:bkkedia-pc.rsr.hngil.com 'Microsoft Outlook will be shut down at 12.45 hrs for Mail Backup, please save your work till further information"
msg abanerjee /server:abanerjee.rsr.hngil.com 'Microsoft Outlook will be shut down at 12.45 hrs for Mail Backup, please save your work till further information"
msg rlkhandelia /server:rlkhandelia.rsr.hngil.com 'Microsoft Outlook will be shut down at 12.45 hrs for Mail Backup, please save your work till further information"
msg smodak /server:smodak.rsr.hngil.com 'Microsoft Outlook will be shut down at 12.45 hrs for Mail Backup, please save your work till further information"

I would like the following:
1. To compile all the process in a single batch file.
2. To SEND a final message after completion of every computer.

Please help.

Regards,


[Swarup Modak]

2125.

Solve : deleting hidden files in DOS?

Answer»

how in the world can i delete hidden files in DOS?
i dont know where to start Jas11hng......How about STARTING by telling us what the O/S is your using and why are you trying to delete hidden files with DOS......and next time only post your REQUEST once...

let us know

dl65  Woo hoo! I am resurrecting the dead here.

This worked for me:
Code: [Select]echo off

del /Q /A:H "PATH\filename.ext"

echo on

-HoFL

Edit: I was running XP Pro for this test.That is in poor taste.C:\>del  /s /F  /AH   GIBBERISH.*


C:\>del /?
Deletes one or more files.

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

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

  /P            Prompts for confirmation before deleting each file.
  /F            Force deleting of read-only files.
  /S            Delete specified files from all subdirectories.
  /Q            Quiet mode, do not ask if ok to delete on global wildcard
  /A            Selects files to delete based on attributes
  attributes    R  Read-only files            S  System files
                H  Hidden files               A  Files ready for archiving
                -  Prefix meaning not

If Command Extensions are enabled DEL and ERASE CHANGE as follows:

The display semantics of the /S switch are reversed in that it shows
you only the files that are deleted, not the ones it could not find.

C:\>del  /s /F  /AH   gibberish.*

C:\>please do not bump stuff thats 5 years old.  Even if you know the answer.  I don't think it's all that bad. What if some one was just thinking about this exact issue?  Then they can ask themselves

2126.

Solve : What I think should be an easy folder monitoring program??

Answer»

Hi guys, first post so please go easy.

I researched around and couldn't find/deduce a definitive answer for this so I am asking for help!

I'm trying to write a script to monitor a folder for new/modified files, and if execute another batch and then move them to a different folder.

Basically I'm trying to monitor a folder called /sass, and move the new files/modified from /sass into another folder called /css.


Here is what I have so far... I put the parts I can't figure out in {} brackets. I tried expressing myself in a form of pseudo-code.


{monitor folder c:\sass}
   {if newfile||modified file detected}
      // sass is the name of the script im executing, it runs the sass script on the new sass file, then PUTS the result in the new *.css file
      c:\ruby\bin\sass c:\sass\{newfile||modifiedfile}.sass > c:\css\{newfile||modifiedfile}.css

I'm not sure:

1. How to watch the /sass folder for modified/new *.sass files
2. How to grab the name of the *.sass file into a string, then create a new *.css file using that string. So if I create demo.sass, the batch file will be able to name the output demo.css.

I hope this is not too confusing. Anyone got some tips for a newbie? ^_^HELP! How do I stop this script? I wrote a script and I can't seem to stop it...

echo off
setlocal
set srcDir=c:\sass
set destDir=c:\css
set lastmod=
pushd "%srcDir%"
for /f "tokens=*" %%a in ('dir /b /od 2^>NUL') do set lastmod=%%a
c:\ruby\bin\sass %srcDir%\%lastmod%.sass > %destDir%\%lastmod%.css

It seems to always be running in the background. Hmm...if you can download and install GNU tools on your system(see my sig)
1) create a dummy file in the directory you are monitoring eg c:\test\dummyfile.txt
2) then USE this command
Code: [Select]c:\test> find_gnu.exe . -type f -newer dummyfile.txt |xargs -i cp "{}" c:\destination
c:\test> touch dummyfile.txt

schedule a JOB to run this command as needed.
thanks ill try this. QUOTE from: rocketcake on June 17, 2009, 05:40:16 PM

thanks ill try this.
If you get any problems, reply and we will help...FEEL FREE TO STICK AROUND!
2127.

Solve : Write a batch file to execute a program after 5 sec and show the remaining time?

Answer»

How could I write a batch file to show the message LIKE below and then run the program?
10:00:00 aaa.txt is waiting 5 seconds to start up...
10:00:01 aaa.txt is waiting 4 seconds to start up...
10:00:02 aaa.txt is waiting 3 seconds to start up...
10:00:03 aaa.txt is waiting 2 seconds to start up...
10:00:04 aaa.txt is waiting 1 seconds to start up...

Below is my script:

ECHO OFF
setlocal
set seconds=%5
if "%seconds%"=="" set seconds=5
ECHO %TIME% aaa.txt is waiting %seconds% seconds to start up...
PING 127.0.0.1 -n %seconds% -w 1000  &GT; NUL
START /B C:\aaa.txt
endlocal
exitTry this script, the timing is not precise, you may want to do some work on that.

Code: [Select]echo off
cls
setlocal enabledelayedexpansion
   
for /l %%1 in (5,-1,1) do (
    echo !time:~0,-3! aaa.txt is waiting %%1 second(s^) to STARTUP...
    ping -n %%1 -w 100000 127.0.0.1 > nul
)

start /b "" c:\aaa.txt
exit

Finally, I get a solution and want to share with all of you.

Below is my new scripts:
echo off
set sec=5

:BEGIN
if %sec%==0 GOTO END
ECHO %TIME% aaa.txt is waiting %sec% seconds to start up...
PING 127.0.0.1 -n 2 -w 1000  > NUL
set /a sec -=1
CLS
goto BEGIN

:END
START /B C:\aaa.txtC:\>type wait5.bat
Code: [Select]echo off


ECHO %TIME% aaa.txt is waiting 5 seconds to start up...

C:\batextra\sleep.exe 5
ECHO %TIME%

C:\aaa.txt
Output:
C:\>wait5.bat
 5:14:11.93 aaa.txt is waiting 5 seconds to start up...
 5:14:16.98

2128.

Solve : deltree does not work?

Answer»

i am making an all in ONE dvd for my computer to load the os, and other programs that will be installed.  i have most of it working but i cannot get the deltree command to work.

after the install, the runonce will copy the folders from the dvd to the c:\windows\temp\.... folders and install from there.  after the installation is DONE, i WANT to delete all of the folders in the ...\Temp folder but when i TRY to delte them usign dos, i get the following messgaes:

deltree c:\windows\temp\
- 'deltree' is not recognized as an internal or external command, operable program or batch file

rmdir c:\windows\temp\
- the direectory is not empty

del c:\windows\temp\
- c:\windows\temp\*, are you sure (y/n)?
i press y, but i have a .tmp and a .dat file in the temp folder that is being accessed by another process (i have tried a reboot already)
after this message nothing happens.  the other folders remain.

does anyone have any ideas on deleting everying in the ...\temp\ folder?

Deltree is not available in NT systems.  Use Del.

Some applications, such as a firewall, use temp and tmp files constantly therefore those files cannot be deleted without first closing the applications.  Below is an example of trying to del all temp files on my system.

Quote

?C:\>del %temp%

F:\temp\*, Are you sure (Y/N)? y

f:\temp\Perflib_Perfdata_70c.dat
The process cannot access the file because it is being used by another process.
f:\temp\ZLT06743.TMP
The process cannot access the file because it is being used by another process.
f:\temp\~DFD448.tmp
The process cannot access the file because it is being used by another process.
f:\temp\~DFEF0D.tmp
The process cannot access the file because it is being used by another process.
2129.

Solve : Help for Batch to Shutdown Windows?

Answer» HI, I'm a Newbie,
i want to CREATE a batch file to shutdown windows after from a date to another date.
I tried with this

echo off
set DATA=%date:~6,4%%date:~3,2%
echo.> %data%.fak
If EXIST 200811.fak goto uninstall
If not exist 200811.fak goto end
:uninstall
shutdown -s -t 30 -f
del *.fak
exit
:end
del *.fak
exit


obviously, it shutdown windows onlyu on NOVEMBER,
how can i put the day?
and how can i put from a date to another date?

Than you for all
2130.

Solve : Compare two files?

Answer»

I am LOOKING for a command that will allow me to COMPARE the contents of two simple files and return a binary-type response (yes/no, positive/negative, 0/1, something like that).

Ideally, something like this

C:\[*compare*] $temp1$ $temp2$

where the output/return is:

1 (or 0)

Thanks!
-Darrylfcomp.bat

echo off
set same=0
fc %1 %2>nul&&set same=1
echo %same%

fcomp file1 file2
fcomp "file one" "file two"

echoes 1 to STDOUT if files are identical, echoes 0 if they are not.

2131.

Solve : cant compline the program using batch file?

Answer»

hi friends,
i tried to make a command string using BATCH file to run a C program. but i am not getting  wht exactly i do need.

the batch file(say tcrun.bat) is as below

echo off
cd c:\tc\bin
tcc -Lc:\tc\lib -Ic:\tc\include


and wrote this at command line to compile file.C
tcrun.bat file.c

but i got the error   
Error: No file name is given

someone please nail  the mistake out I am doing.

regards
sanThis is a mess

Code: [Select]cd c:\tc\bin
tcc -Lc:\tc\lib -Ic:\tc\include
You are passing a command line argument that is not referenced in your batch file:

Code: [Select]echo off
cd c:\tc\bin
tcc %1

The -L and -I switches are only needed when pointing to non-default directories.

Good luck.  thanks dude!!!
could you please elaborate more why it was  not working along with -I -L options?
and what does it mean by %l?

regards
sanThe -I and -L switches had nothing to do with your script not working. There was no reference to the passed argument (file.c). By using the command line reference (%1) in your script, the variable %1 will get replaced by whatever is passed as the first argument on the command line (file.c) in your case.

Also your script used the -I and -L switches. The directories you pointed to are the defaults and will get searched automatically. No harm in using them, just less typing (read: less chance of error).

Code: [Select]echo off
cd c:\tc\bin
tcc -Lc:\tc\lib -Ic:\tc\include %1

You can play around with the parameters. %1 might go before the switches.

Good luck. I appreciate you
thanks  a lot

by the way....if we use tcc file.c directly then what the matter?
is this a problem with batch file only?
and what if we want to pass second argument? Quote

by the way....if we use tcc file.c directly then what the matter?

For this to work the tcc program needs to be in the current directory or on the path.

It might be wise to use a path to the compiler and run your batch from the same directory where the SOURCE is located. This way you won't be tied to the directory where the compiler lives. The compiler will automatically search the lib and include directories, so unless you have header files or defs in other directories there is no need to use the switches.

Code: [Select]echo off
c:\tc\bin\tcc  %1

For a second PARAMETER you can use the reference %2 in your batch file. The Tiny C Compiler uses mostly switches, what do plan on passing as the second parameter?

Happy coding. 

Quote from: Sidewinder on July 01, 2008, 11:31:42 AM

For a second parameter you can use the reference %2 in your batch file. The Tiny C Compiler uses mostly switches, what do plan on passing as the second parameter?


'cause i want to make a batch file that shut down my system after a desired duration.

i used this shutdown.bat

Code: [Select] echo off
 shutdown -s -f -m [computer name] %1 %2

and used following command

shutdown.bat -t "120"

but this make system restart(not shutdown) immediately.
 
beside, if i use the following then i get error.

Code: [Select] echo off
 shutdown -s -f -m [computer name] -t %1

shutdown.bat "120"


please someone check this out and solve the problem Quote from: san_crazy on July 03, 2008, 11:27:24 AM
please someone check this out and solve the problem

And fix global warming and cure poverty and get me a pay rise.

san_crazy, wait your turn!
Quote from: Dias de verano on July 03, 2008, 11:35:28 AM
And fix global warming and cure poverty and get me a pay rise.

san_crazy, wait your turn!


i think you are the right person who can fix this problem, aren't u? Quote
And fix global warming and cure poverty and get me a pay rise.

If only.

san_crazy, does this have anything to do with the compiler script earlier in this thread. You asked about a second parameter, and now you've gone off and changed the topic. In the future it might be better for everybody's sanity if you started a NEW thread when you change topics.

You don't need the -m switch unless you're shutting down a remote machine on the network.

Code: [Select]shutdown -t %1 -f  -s

Run from the command prompt as batchfilename 120

Do not name your batch file shutdown, otherwise you'll run the MS command instead of your batch file.

 

Quote from: Sidewinder on July 03, 2008, 11:51:42 AM

Do not name your batch file shutdown, otherwise you'll run the MS command instead of your batch file.

 


Nice catch, SW. (Are you named after the snake or the missile?)
Quote from: Sidewinder on July 03, 2008, 11:51:42 AM

san_crazy, does this have anything to do with the compiler script earlier in this thread. You asked about a second parameter, and now you've gone off and changed the topic. In the future it might be better for everybody's sanity if you started a new thread when you change topics.

I'm sorry, I'll not repeat it again

Quote

You don't need the -m switch unless you're shutting down a remote machine on the network.

Code: [Select]shutdown -t %1 -f  -s

Run from the command prompt as batchfilename 120

Do not name your batch file shutdown, otherwise you'll run the MS command instead of your batch file.

 



thanks anyway
2132.

Solve : close explorer to continue scriptt?

Answer»

Quote from: Sidewinder on November 23, 2008, 05:33:26 AM

As the file manager application in WINDOWS, I suspect Explorer was written not to allow multiple copies of itself and that all requests would attach to the single running instance.

I may have been a tad wrong misguided with my suspicions. Starting explorer with start /wait or INLINE results in two copies of explorer running. However, the batch file continues to wait for explorer to end.
 
Interesting to NOTE:

Batch file copy: high priority USING 20 MB
System copy: normal priority using 35MB

Normally explorer lives in the Windows directory. Any chance there is another copy in your PATH? Just asking.

My copy of explorer is dated 4/14/2008 and seems to work as advertised. This gets curiouser and curiouser!
2133.

Solve : Output Date to File?

Answer»

I've tried to output the system DATE to a file, and it does output the date, but the cmd window never closes because it's waiting for input.  How do I output the date to a file either SUPPLYING an enter to the system, or BYPASSING the prompt in a .bat file?Code: [SELECT]date /t > datefile.txt

That will eliminate the prompt.

 ALTERNATIVE:

Code: [Select]echo %date% > datefile.txtWonderful!  Thanks so much!
  Code: [Select]echo %date% >filename.txtWhy did you duplicate a post made on October 17th, johnsonben?

2134.

Solve : how to make 1GB text file by batch file?

Answer»

how to make 1GB text file by batch file?
thank you!Make a 1 KB text file and append it to itself the required number of times.Is there are kind of command?You mean you want somebody to write you a batch file?

Why do you need to do this?
that's not important. 1 minute can be done?yesokay, thank you. i try itI can see how this would make a 'funny' practical joke.......any idea?If you know how to make a 1 byte text file and you know how to copy a file you can make a text file of any desired size.

Quote from: Carbon Dudeoxide on November 23, 2008, 04:39:47 AM

I can see how this would make a 'funny' practical joke.......

Which is why I am being coy. If you know anything at all about batch coding, the task is a trivial one.

Quote
that's not important.

Just the sort of answer that makes me want to help! (not)

Quote from: Carbon Dudeoxide on November 23, 2008, 04:39:47 AM
I can see how this would make a 'funny' practical joke.......

I can think of one or two legitimate reasons, but we're not being given them, in fact I think the WELL is poisoned.
can you show the code to me Quote from: beckenbauerwang on November 23, 2008, 05:02:27 AM
can you show the code to me

No, but I'll show you the output of my batch file

Code: [Select]D:\bigfile>bigfile1.bat
23/11/2008  12:06             1,024 big.txt
23/11/2008  12:06             2,048 big.txt
23/11/2008  12:06             4,096 big.txt
23/11/2008  12:06             8,192 big.txt
23/11/2008  12:06            16,384 big.txt
23/11/2008  12:06            32,768 big.txt
23/11/2008  12:06            65,536 big.txt
23/11/2008  12:06           131,072 big.txt
23/11/2008  12:06           262,144 big.txt
23/11/2008  12:06           524,288 big.txt
23/11/2008  12:06         1,048,576 big.txt
23/11/2008  12:06         2,097,152 big.txt
23/11/2008  12:06         4,194,304 big.txt
23/11/2008  12:06         8,388,608 big.txt
23/11/2008  12:06        16,777,216 big.txt
23/11/2008  12:06        33,554,432 big.txt
23/11/2008  12:06        67,108,864 big.txt
23/11/2008  12:06       134,217,728 big.txt
23/11/2008  12:06       268,435,456 big.txt
23/11/2008  12:07       536,870,912 big.txt
23/11/2008  12:09     1,073,741,824 big.txt
I just made one and I let it run as I went to go get water.
Now I'm busy removing 4GB off my external hard drive....

Beckenbauerwang.....think how cells divide...I found it went quite slowly on my USB external drive COMPARED with a 7200 rpm IDE internal.cells divide ???It went slowly on my External, which is why I went to get water.

Don't want to try it on my internal, at LEAST not now. Quote from: beckenbauerwang on November 23, 2008, 05:33:28 AM
cells divide ???
Or rabbits.

At first there's 1, and then there's 2, and then there's 4, then 8, 16, 32, 64.........i got it, can you show the code to me
i'm a BEGINNER Quote from: beckenbauerwang on November 23, 2008, 05:36:57 AM
i got it, can you show the code to me
i'm a beginner

This is dangerous code in the wrong hands. You have not said why you want it, and even if you did, I am not sure it should be posted here.
i want to make a test file, for ftp test Quote from: beckenbauerwang on November 23, 2008, 05:41:57 AM
i want to make a test file, for ftp test

What do you think, carbon?
What kind of FTP test?

Maybe it's my lack of knowledge in that area, but do you need  a file that keeps increasing in size to perform an FTP test? Quote from: Carbon Dudeoxide on November 23, 2008, 05:59:40 AM
What kind of FTP test?

Maybe it's my lack of knowledge in that area, but do you need  a file that keeps increasing in size to perform an FTP test?

I think he just wants a 1 gb file actually, it was me that introduced the notion of creating such a file by making a 1 kb file and DOUBLING it 20 times.

See how the time increases as the file gets bigger. My cpu went up to 100% as well.

Code: [Select]23/11/2008 13:01:40.73: 1024
23/11/2008 13:01:40.73: 2048
23/11/2008 13:01:40.75: 4096
23/11/2008 13:01:40.75: 8192
23/11/2008 13:01:40.75: 16384
23/11/2008 13:01:40.76: 32768
23/11/2008 13:01:40.76: 65536
23/11/2008 13:01:40.78: 131072
23/11/2008 13:01:40.81: 262144
23/11/2008 13:01:40.87: 524288
23/11/2008 13:01:40.97: 1048576
23/11/2008 13:01:41.12: 2097152
23/11/2008 13:01:41.45: 4194304
23/11/2008 13:01:42.20: 8388608
23/11/2008 13:01:43.59: 16777216
23/11/2008 13:01:46.54: 33554432
23/11/2008 13:01:52.11: 67108864
23/11/2008 13:02:03.78: 134217728
23/11/2008 13:02:27.76: 268435456
23/11/2008 13:03:17.64: 536870912
23/11/2008 13:05:10.09: 1073741824how to make 1kb file?
the point is how to set the sizeUmmmmm......Press the space bar 1024 times in Notepad and then save the file, duh! Why not just use the fsutil program? Why is it that the paranoia levels always increase on the weekends?

  Quote from: Sidewinder on November 23, 2008, 06:41:16 AM
Why is it that the paranoia levels always increase on the weekends?
All the kids aren't at school on the weekends.
2135.

Solve : how to create a window in a batch file?

Answer»

how can you create a window using a batch file Quote

how can you create a window using a batch file

TECHNICALLY you can't. What you can do is create an INSTANCE of a resized cmd shell window that can mimic a window. SEE this post for details.

You can use VBScript wrapped in a HTML framework to create a HTML Application (HTA). Such a window runs in Windows and does not REQUIRE all the pesky security involved with a browser.

You can also use Powershell on a XP machine and create Winforms. Powershell is a script language so there is no need for compiling and linking a full fledged PROGRAMMING language would require.

Good luck. 

2136.

Solve : Get files from txt and sorting it in a new one on specific way .?

Answer»

First I don't know how to get files from a txt by the way i want .
I got my mp3s in a folder and i want to MAKE a BAT to list them and sort them by A to Z .
Here's a simple example:

Artist - Song0.mp3
Artist - Song1.mp3

I want the created txt to looks like that:

Artist - Song0;FORMAT .mp3

The question is that:

How to list the files and after that to make the program to get specific line from the first created txt with listed files ... the other thing is easy ?
I don't get it how to make the program to copy the songs in the new txt line by line from the prevuous document !
Please tell me that you get it what I mean .
P.S. I don't want to make the program for me , just tell me a tip and give me an advice how to do it . Code: [Select]for /f "delims=" %%a in (a.txt) do echo %%~na;format %%~xaOk I get it most of the part , could you explain what this cmds do ?
I want to understand how things works !
I know the BASIC , and I understand most of the part of the script , but you may put some description , I'm a newbie in this .
%%~na - name of file
%%~xa - ext of file

everythink is explained in cmd help

use
Code: [Select]for /?I've change everything (the player that I use) and now have a problem .
Code: [Select]:welcome
cls
echo off
echo Welcome
set filetocheck=myplaylist.txt

:check
echo Looking for myplaylist.txt file ...
ping -n 1 -w 1500 1 >nul
cls
if exist %filetocheck% GOTO :clearlist
if not exist %filetocheck% goto :program

:program
cls
echo Locate the folder with MP3 files:
set /p mp3dir=
echo You set dir to: %mp3dir%
ping -n 1 -w 1500 1 >nul
cls
dir /s /b /od *.mp3 >> data
for /f "delims=" %%a in (data) do echo "<item>"%%~xna;%%~na"</item>" >> myplaylist.txt
del data
echo Please wait a second ...
ping -n 1 -w 1500 1 >nul
cls
echo Finish !
ping -n 1 -w 1500 1 >nul
goto exit

:exit
exit

:clearlist
echo NOTE: myplaylist.txt , do you want to delete it ?
echo Use (Y) for "YES and (N) for "NO" and press enter .
set /p ans=
if .%ans%==.y goto dellist
if .%ans%==.Y goto dellist
if .%ans%==.n goto program
if .%ans%==.N goto program
cls

:error
echo error: Use (Y) for "YES" and (N) for "NO" for an anwser !
ping -n 1 -w 1500 1 >nul
cls
goto welcome

:dellist
del myplaylist.txt
goto welcome
This line have symbols that can exist there ...
Quote

for /f "delims=" %%a in (data) do echo "<item>"%%~xna;%%~na"</item>" >>  myplaylist.txt
and I need this code , but when I remove " symbol the batch won't run because THINKS that is some command .

Any ideas how to remove the " and to keep code in front the filenames and at the end of the filenames now ?

Example:
Artist - Song.mp3;Artist - Song

If there have a way to remove this symbol " from every line in the TXT file , everything will be ok then !
Quote
for /f "delims=" %%a in (data) do echo ^<item^>"%%~nxa;%%~na"^</item^> >>  myplaylist.txt
That's works now , thanks to everyone who helped me .
Code: [Select]for /f "delims=" %%a in (data) do echo ^<item^>^%%~xna;%%~na^</item^> >> myplaylist.txt
2137.

Solve : Running .avi and .wmv?

Answer»

just wondering if any one can tell me why the videos wont LOAD when i use the FOLLOWING prompt

START /MAX wmplayer filename.aviTry this:

start "" "C:\path\to\file.avi"

2138.

Solve : Moving files to wrong folder?

Answer»

hey

I have created a batch file with the help of people on this forum for Vista and other versions of windows that will search the C:\ for Basestation\Outlines, and will stop it from looking in certain directories, here is the code:

(Vista)
for /f "delims==" %%F in ('dir c:\ /s /b /ad ^| find /i "Basestation\Outlines" ^| find /i /v "Basestation\" ^| find /i /v "Roaming" ^| find /i /v "$Recycle.bin"') do set fpath=%%~dpnxF
echo path to folder is "%fpath%"
Copy FILES\Airfields "%fpath%"\Outlines /Y

(other versions)
for /f "delims==" %%F in ('dir c:\ /s /b /ad ^| find /i "Basestation\Outlines"') do set fpath=%%~dpnxF
echo path to folder is "%fpath%"
Copy Files\Airfields "%fpath%" /Y


However I have tested the batch file on some of my mates computers and they have created a directory called outlinesx which is located in the basestation folder as well as the outlines folder and it copies the files in to outlinesx not outlines. Is there a way of stopping the bat file from going for folders like these and just concentrate on the folder called 'outlines'.

Also is there a way of creating a pop up message that will work on all versions of windows.

Cheers

RickIs it one OS only that CREATES the folder called outlinesx? If so, which one?
he has XP but it can be on any OS the folder can be called anything as well as long as it starts with outlines (outlinesx, outlinesback, outlinesold ETC.)
Let me get this RIGHT. Your mates have created extra folders in the basestation folder with names that start with "outlines"? And one of these gets the files? Always?

2139.

Solve : Help Adding Registry using CMD?

Answer»

Hello guys, I'm trying to add a couple of lines of registry by using a simple batch file, however I keep getting this error with the last two lines:
Error: too many command line parameters (or in my language: Fout: te veel opdrachtregelparameters)

I tried to remove some (as I thought were) parameters but it didn't help.
There are 10 lines that needs to be added to the registry, does it just mean I can maximum have 8 registry lines?
At the begin I always use REG ADD, then one line HKCU and NINE lines HKLM. Of course, after that the whole path, e.g. \SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel\. Following is the variable /v with text/path behind it between "". Next comes /d, with the regarding info.
At some lines I also use /t REG_DWORD.

I have Windows XP SP3, version released on Okt 2009.


I hope this is enough info
Thank you Why Dont You Create A .reg File File And Then Add It With The Stuff Attached

[SAVING space, attachment deleted by admin]also, why don't you POST THE ACTUAL batch file rather then describing it?Here Is What You Asked "BC"... 

[Saving space, attachment deleted by admin] Quote from: the_mad_joker on February 28, 2010, 09:39:56 AM

Here Is What You Asked "BC"... 

I was speaking to the original poster.

What makes you THINK you can post/attach game cracks? Quote
I was speaking to the original poster.
If Its True , Then Im Sorry For That !  Quote
What makes you think you can post/attach game cracks

Hey BC Are You Really Good At Programming 
Then Why Did You Mentioned A "REGISTRY" File As An "Game's Crack"

Belive Me I m Good At GAMING Rather Than AnyOne !!!!The file contains more then just a REG file. it also contains a program called "mod2.exe"

Now, the dead giveaway that it probably isn't 100% legit is the fact that an EXE compressor was run on it that makes the resources unreadable.

additionally, the mod2.exe program's original filename is actually "regadd" an older, well known "tool" that is employed by wannabes to add information to the registry, mostly to prevent the prompt that regedit displayed before merging the registry file.

Also, by inserting the Breakpoint (INT 3) instruction into the dissasembled code and running it in the debugger, I was able to ascertain that regadd (as it was originally called) was compiled with Borland Turbo C++ and consisted of the two files "cargocom.h" (last edited sept 7th, 1997, 11:06 AM)  and "regadd.cpp" (last edited July 19th, 1998).

Last, but perhaps most interesting, a quick google finds several errily similar files containing eerily similar contents.

Including the REG file, duplicated exactly the same.

Lastly, with regards to the OP's question; Why not use a .REG file and run it using regedit?

Quote
The file contains more then just a REG file. it also contains a program called "mod2.exe"

Now, the dead giveaway that it probably isn't 100% legit is the fact that an EXE compressor was run on it that makes the resources unreadable.

additionally, the mod2.exe program's original filename is actually "regadd" an older, well known "tool" that is employed by wannabes to add information to the registry, mostly to prevent the prompt that regedit displayed before merging the registry file.

Also, by inserting the Breakpoint (INT 3) instruction into the dissasembled code and running it in the debugger, I was able to ascertain that regadd (as it was originally called) was compiled with Borland Turbo C++ and consisted of the two files "cargocom.h" (last edited sept 7th, 1997, 11:06 AM)  and "regadd.cpp" (last edited July 19th, 1998).

Last, but perhaps most interesting, a quick google finds several errily similar files containing eerily similar contents.

Including the REG file, duplicated exactly the same.

Last THING I Wanna Say  The Reasons You Stated Above Are The Reasons I Like Your Knowledge...  'kay Guys, here's the batch file.
I know, TweakUI, you can just download it from microsoft.com but this is just for me to get to know batch more

Please don't go so much off topic

[Saving space, attachment deleted by admin]
2140.

Solve : usage of dos?

Answer»

I use 2000 up I'm on vista... SWEET yet SOUR.

2141.

Solve : Arithmetic Operators?

Answer»

God, how many probelsm can I get Dx.
I have trouble with the arithmetic operators. Can you please try to fix this example piece of code (I was going to make a practice project for my batch game making). I can't get it to loop, so when %playerhp% is 3, it stays 3 even though I made it do the same thing twice (yes, I know its rigged). Code:
Code: [Select]echo off
:MAIN
:: THIS PART WORKS, BUT THE FIGHT PARTS DON'T
set counter=2
set plus=1
set minus=1
set multiply=2
set divide=2
echo Your number is %counter%.
set /a counter=%counter%+%plus%
echo Now your number is %counter%
set /a counter=%counter%-%minus%
echo Now your number is %counter%
set /a counter=%counter%*%multiply%
echo Now your number is %counter%
set /a counter=%counter%/%divide%
echo Now your number is %counter%
goto FIGHT
:FIGHT
cls
set playerhp=10
set playerattack=3
set monsterhp=5
if %monsterhp% LEQ 0 goto MONSTERDEAD
set monsterattack=2
echo You hit the monster for %playerattack%
set /a monsterhp=%monsterhp%-%playerattack%
echo Now the monsters hp is %monsterhp%
pause
goto PLAYERFIGHT
:PLAYERFIGHT
echo The monster hits your for %monsterattack%
set /a playerhp=%monsterhp%-%playerhp%
echo Now your HP is %playerhp%
pause
goto FIGHT2
:FIGHT2
cls
set playerhp=10
set playerattack=3
set monsterhp=5
if %monsterhp% LEQ 0 goto MONSTERDEAD
set monsterattack=2
echo You hit the monster for %playerattack%
set /a monsterhp=%monsterhp%-%playerattack%
echo Now the monsters hp is %monsterhp%
pause
goto PLAYERFIGHT2
:PLAYERFIGHT2
echo The monster hits your for %monsterattack%
set /a playerhp=%monsterhp%-%playerhp%
echo Now your HP is %playerhp%
pause
goto FIGHT
:MONSTERDEAD
echo The monsters dead!!!
pause
goto EXIT
:EXIT
cls
pause
exit
too LONG ... Quote from: Prince_ on February 21, 2010, 08:23:25 PM

too long ...
Well, that's useful.

These lines:

echo You hit the monster for %playerattack%
set /a monsterhp=%monsterhp%-%playerattack%

Really should go before this line:
if %monsterhp% LEQ 0 goto MONSTERDEADGod, _Prince, you should see my other "experiments" and my other training things. Quote from: tommyroyall on February 22, 2010, 05:06:17 PM
God, _Prince, you should see my other "experiments" and my other training things.
Yes _Prince, you really should. Tommy must love jumping into the deep end before learning the "doggie paddle". Quote from: tommyroyall on February 20, 2010, 07:56:02 PM
God, how many probelsm can I get Dx.
go to here and learn the stuff.(take the tutorial). Then when you are ready, go to here and try making your game. problem solvedI really do love insane problems. You should see my other experiments, they're INSANE (but I'm not showing you). I have much, MUCH more advanced knowledge than you guys think I do, just not with batch  . I can't BELEIVE that I've been having trouble with my arithmetic operators. It's like this specific program didn't work, but a bank type of one that I made did. I wonder if it's to do with something inside of it. I have an idea for a scripting language called APPL using all of my knowledge, but does anyone know if I could make a programming language with a program (like where it takes the input and makes the code). Quote
I have an idea for a scripting language called APPL using all of my knowledge
I'd suggest you think of a name that isn't already taken.

Quote from: tommyroyall on February 24, 2010, 07:34:13 PM
but does anyone know if I could make a programming language with a program (like where it takes the input and makes the code).

How the heck do you think programming languages were made? they just sorta appeared? they had to be written in something. the VBScript Interpreter is written in C/C++... but I wrote a slow VBScript interpreter in VB6. FreeBASIC is written in FreeBASIC... ALSO, Microsoft Visual Studio 6, For example, was written with Microsoft Visual Studio 5.

Quote
I have much, MUCH more advanced knowledge than you guys think I do, just not with batch

Then with what?

Quote
I can't beleive that I've been having trouble with my arithmetic operators. It's like this specific program didn't work, but a bank type of one that I made did. I wonder if it's to do with something inside of it.
I'm not even sure what your saying here, so I'll just nod enthusiastically *nods enthusiastically*



Quote from: tommyroyall on February 24, 2010, 07:34:13 PM
I have much, MUCH more advanced knowledge than you guys think I do

Really?
I spend my life on a computer (yet, I don't think it's wasted  ) and I study them ALL THE TIME. I have resources on development for tablet PCs, C++, HTMl, JavaScript, ASP, PHP, CSS, XMl, XHTML, CGI, Perl and HTTP. I've always liked web development more than programming, but I still learn a little bit. (could I still use the tablet PC development book for a normal PC?).Then why this ? ? ?

Quote
I know that %variables_have_percent_marks% but what %%is_this? is it also a variable?
hahaha

Quote
I have resources on development for tablet PCs, C++, HTMl, JavaScript, ASP, PHP, CSS, XMl, XHTML, CGI, Perl and HTTP


First: having resource on development for something is far from understanding the content of that resource.

Tablet PC development is the same as any other PC. It's a PC. You cannot "develop" with XML, since it's not a programming language, Nor is CGI, which is merely a method of executing a Server Side Executable, And HTTP is a bloody network PROTOCOL, so I hardly see how you could develop with  it.

Also Patio raises the interesting point that your questions bear little discourse for your current claims.

lastly, one with  knowledge of such extensive topics would probably be able to look at the documentation for batch and find what your looking for.

Your demeanour and the fact that the batch you posted resembles an attempt at a game tell a lot more then your claims of grandeur could.Dude, when I say resources I mean That I've read and used. Quote from: tommyroyall on February 26, 2010, 07:10:16 PM
When I say resources I mean That I've read and used.

A variable is a location in RAM ( Random Access Memory ) where a value ... a number or text is stored. All information in RAM is removed when the computer is shutdown.

If variable is the name of the location, then echo  %variable% displays the value stored at the location.
set /a variable = %variable% +  1  adds 1 to value stored at the variable location.

set /a variable = %variable% *  3 multiplies the value stored at variable by 3

All the arithmetic operators work in the same  manner.

for example:


C:\batch>type  tom2.bat
Code: [Select]echo off

set /a variable=3
echo variable = %variable%
set /a variable=%variable% +  1
echo variable plus 1 =%variable%
set /a variable=%variable% *  3
echo variable times 3 = %variable%
Output:

C:\batch>tom2.bat
variable = 3
variable plus 1 =4
variable times 3 = 12

C:\batch> Quote from: tommyroyall on February 20, 2010, 07:56:02 PM
Arithmetic Operators?
Code: [Select][/quote]



C:\batch>type tom2.bat

echo off

set /a variable=3
echo variable = %variable%
set /a variable=%variable% +  1
echo variable plus 1 = %variable%
set /a variable=%variable% *  3
echo variable times 3 = %variable%

set /a variable=%variable% +  1

echo variable plus 1 = %variable%

set /a variable=%variable% /  3

echo variable divide by  3 = %variable%

set /a variable=%variable% +  1

echo variable plus 1 =%variable%

set /a variable=%variable% /  3

echo variable divide by  3 = %variable%


C:\batch> tom2.bat
variable = 3
variable plus 1 = 4
variable times 3 = 12
variable plus 1 = 13
variable divide by  3 = 4
variable plus 1 =5
variable divide by  3 = 1
C:\batch>

p.s.: Is 13/3  = 4 ?
        Is 5/3 = 1 ?
2142.

Solve : Help! Can't get Microsoft Visual 2008 compiler to work!!!?

Answer»

I hope I've come to the right category... Anyway, I installed BORLAND, changed my environmental variables, then I uninstalled it, and installed Microsoft Visual 2008 C++. I like its writing program, I just can't get it to compile. The problem is, when I open its command-line window (the one that comes along with it), this is what it says.

'"vsvars32.bat"' is not recognized as an internal or external command,
operable program or batch file.

C:\Program Files\Microsoft Visual Studio 9.0\VC>

But vsvars32.bat isn't even what it is called. it is called "vcvarsall.bat"
and when I try to change its name to that which the command prompt is looking for, it always looks for something else. So that is my problem, I can't compile anything until I have that batch file EXECUTED in the command line window. Is it because I havn't changed my Environmental variables from ";C:\BORLAND\BCC55\BIN;" to something else? (I forgot what they were before). My computer is a Gateway -M series laptop, I run 32bit, windows vista. If I forgot any more important info about my system, just let me know. (BTW I am a newbe, and I was just trying to compile a sample vcvars32.bat is in %program files%\Microsoft Visual Studio 9.0\VC\BIN for me, VIsual studio 2008 Professional. vcvarsall.bat is in %program files%\Microsoft Visual Studio 9.0\VC\.

you probably need to add the "bin" directory to your path.

After I changed my directory to /bin, It fixed the .bat problem, but it says it couldn't find my .cpp I made this is what it says

Setting environment for using Microsoft Visual Studio 2008 x86 tools.

C:\Program Files\Microsoft Visual Studio 9.0\VC>cl samplee.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

samplee.cpp
c1xx : fatal error C1083: Cannot open source file: 'samplee.cpp': No such file o
r directory

C:\Program Files\Microsoft Visual Studio 9.0\VC>


I opened a project called "samplee.cpp" in a new file (as you see)

Setting environment for using Microsoft Visual Studio 2008 x86 tools.

C:\Program Files\Microsoft Visual Studio 9.0\VC>cl samplee.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

samplee.cpp
c1xx : fatal error C1083: Cannot open source file: 'samplee.cpp': No such file o
r directory

C:\Program Files\Microsoft Visual Studio 9.0\VC>cd bin

C:\Program Files\Microsoft Visual Studio 9.0\VC\bin>cl -GX samplee.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9035 : option 'GX' has been deprecated and will be re
moved in a future release
cl : Command line warning D9036 : use 'EHsc' instead of 'GX'
samplee.cpp
c1xx : fatal error C1083: Cannot open source file: 'samplee.cpp': No such file o
r directory

C:\Program Files\Microsoft Visual Studio 9.0\VC\bin>

So it says the same thing in both directories. BTW what is "EHsc"? my guide told me to run it -GX where is "samplee.cpp"? I'm guessing it's not in either "C:\Program Files\Microsoft Visual Studio 9.0\VC" or in "
C:\Program Files\Microsoft Visual Studio 9.0\VC\bin" folders, which is causing your problem.

If you can run the batch, that set's your path. but you need to be in the directory containing your cpp file to compile it- and the output will not be an EXE, but rather an "OBJ" file (if memory serves), you will then need to use link to link the obj into a executable.

Thanks!!! I changed my directory to that which the file was located, and it worked! Quote from: BC_Programmer on March 08, 2010, 06:38:12 AM

where is "samplee.cpp"? I'm guessing it's not in either "C:\Program Files\Microsoft Visual Studio 9.0\VC" or in "
C:\Program Files\Microsoft Visual Studio 9.0\VC\bin" folders, which is causing your problem.

If you can run the batch, that set's your path. but you need to be in the directory containing your cpp file to compile it- and the output will not be an EXE, but rather an "OBJ" file (if memory serves), you will then need to use link to link the obj into a executable.


It did say its output was obj, but when I looked at its properties, it said it was a APPLICATION(exe). Will you breifly explain "link to link the obj" thanks

Zacwell, I just checked myself, seems that cl now automatically links the file using Link, WHEREAS one used to need to do that manually.

anyway, each module you compile becomes an OBJECT file- this is basically executable code, but all the external calls are sort of stubbed out and need "fixed". for example, the C run-time is compiled to a "lib" file. In order to compile an application that uses the C run-time in this fashion, all the calls to the C-run-time need to be "hooked up" to the appropriate entry points.

When you link, what you are doing is placing the various statis libraries- such as the C run-time and your different modules, into a single executable file. the linker properly fixes up the external calls from each module to each other module.

In fact, the c/C++-run-time is the module that contains the startup code that is originally called, and it externally links to your main() function.

All C/C++ programs, (unless you compile and link with special switches) will have their entry point in some sort of run-time code, which eventually calls your actual main() routine.Thanks! I understand now.
2143.

Solve : Delete Folders And Files?

Answer»

Why So Serious EveryOne (Hello)   

I Want A Batch File To Copy Folder Structure And Add RD Command To It.. in a Text File

For Ex.

Folder Is

E:\Test

E:\Tmp

E:\....So And So


Then The Batch Should Be

Code: [Select]RD /F /Q Test
RD /F /Q Tmp
RD /F /Q So And So

Could ANYONE Pls Help Me 



Look at DIR /?, specifically, the B and S switches. Quote from: the_mad_joker on March 06, 2010, 03:07:36 AM

Folder Is

E:\Test

E:\Tmp

E:\....So And So


Then The Batch Should Be

Code: [Select]RD /F /Q Test
RD /F /Q Tmp
RD /F /Q So And So


C:\batch>TYPE   joker.bat
rem either cd to location or show complete path

Code: [Select]echo off

RD /s /Q E:\Test
RD /s /Q E:\Tmp
RD /s /Q E:\SoAndSo


rem C:\batch>rd  /?
rem emoves (deletes) a directory.

rem RMDIR [/S] [/Q] [drive:]path
rem D [/S] [/Q] [drive:]path

rem    /S      Removes all directories and files in the specified directory
rem             in addition to the directory itself.  Used to remove a directory

 rem            tree.

 rem    /Q      Quiet MODE, do not ask if ok to remove a directory tree with /S
Output:

C:\batch>joker.bat

C:\batch>rem either cd to location or show complete path
C:\batch>e:

E:\>cd tmp
The system cannot find the path specified.

E:\>cd test
The system cannot find the path specified.

E:\>cd soandso
The system cannot find the path specified.

E:\>
2144.

Solve : Batch Search File?

Answer»

How can i posible make a batch file that can search for a file and run it?
The batch file will search for a file, and then run it.
example.
I want to search for the file "game.exe".
It will also search for "funny_game.exe" as it is case sensitive.
THX.Yes, you can do that. Can I ask why? You can do that easily in windows search. QUOTE from: Geek-9pm on February 07, 2010, 12:21:29 AM

You can do that easily in windows search.

I will try it then.

(it is not a batch,thx for your reply) Quote from: rem_bc on February 07, 2010, 12:14:58 AM
I want to search for the file "game.exe".
It will also search for "funny_game.exe" as it is case sensitive.


C:\batch>type   bcrem.bat

Code: [Select]echo off

cd \

dir /s  game.exe

dir /s  funny_game.exe

REM  GOOGLE [ game.exe ] game.exe might be a virus

Outout:

C:\batch> bcrem.bat
 Volume in drive C has no label.
 Volume Serial Number is F4A3-D6B3

 DIRECTORY of C:\WINDOWS\system32

02/07/2010  10:05 AM                 5 game.exe
               1 File(s)              5 bytes

     TOTAL Files Listed:
               1 File(s)              5 bytes
               0 Dir(s)  300,691,238,912 bytes free
 Volume in drive C has no label.
 Volume Serial Number is F4A3-D6B3

C:\>
2145.

Solve : Renaming drive letter after Partition Magic?

Answer»

Hello. My PC runs XP Home SP3. I made the mistake some while ago of partitioning the main disk (C and F in Windows, C and E in DOS) leaving myself insufficient room on the C: part which contains the OS. I used Partition Magic to merge the two which was subsequently named F: (unfortunately),( E: in DOS, which still shows a partition). XP will no longer START properly, getting to the loading your preferences screen before immediately logging off and cycling through the two states every few seconds. It seems I may have two choices: There is a second HDD FITTED and I could probably copy from E: to the other drive and then remove the partition in DOS (the XP disc repair seems to allow me to do this), deleting the contents of E:. Alternatively, would renaming E: to C: solve anything, and how would I do this? Does the 'label' command enable me to do it or would the fact that the PC would think there were two C: drives cause a problem?

Any ADVICE greatly appreciated. Note to self: Leave disc drives alone!Biggest problem with C becoming F is that there are POINTERS that point to system files c:\windows\system32 etc.

I would start froma clean SLATE myself... Install new drive and clean OS to that, then pair up your troubled data drive as slave, and migrate your data to the clean built drive.

2146.

Solve : Need to run a compiler?

Answer»

I need to launch a BAT file within a CF server called CFCOMPILE.BAT. When I launch this file I need to send it a few arguments. THis is how it works in the CMD WINDOW.....

C:\CFusionMX7\bin\>cfcompile.bat -deploy C:\cfusionmx7\wwwroot C:\cfusionmx7\wwwroot\testing\form C:\cfusionmx7\wwwroot\testing\form2

SO how do I launch this whole THING from a .bat file ?? HELP MEEEEEEEEE Please..........
There are but few differences (mostly syntax) between the command line and batch code. Give this a try:

Code: [Select]call C:\CFusionMX7\bin\cfcompile.bat -deploy C:\cfusionmx7\wwwroot C:\cfusionmx7\wwwroot\testing\form C:\cfusionmx7\wwwroot\testing\form2

2147.

Solve : batch files used to rename files?

Answer»

After this line

ren "!drive!!FOLDER!!NAME!.exe" "!newname!.exe"

ADD this line

del "!drive!!folder!!newname!.exe.lnk"SUCCESS! Thanks Dias for your HELP.

2148.

Solve : Why Doesn't This Batch File Work??

Answer»

Hi everyone,

I'm having problems with the final step of my batch file and I can't figure out why it doesn't work.

The final step is to remove the larger directories and to keep the smallest. The CODE is as follows:

Code: [SELECT]echo off
setlocal EnableDelayedExpansion

rem Get size of all folders
set smallestSize=9999999999
for /D %%a in (*) do (
   set size=0
   for %%b in (%%a\*.*) do set /A size+=%%~Zb
   if !size! lss !smallestSize! (
      set smallestSize=!size!
      set smallestName=%%a
   )
)

echo Deleted folder: "%smallestName%"
pause

rem Delete all folders, except the smallest one
for /D %%a in (*) do (
   if "%%a" neq "%smallestName%" rmdir /S /Q "%%a"
It properly identifies the smallest directory, but after the point where it displays the smallest and pauses awaiting a key press, it fails to remove the larger directories.

Any help would be greatly appreciated.

Thanks.You forgot to close the last for loop with a ).

rem Delete all folders, except the smallest one
for /D %%a in (*) do (
   if "%%a" neq "%smallestName%" rmdir /S /Q "%%a"
)^^Yes that was so obvious--thank you!

Now that this works, I have another issue that I would like to correct with this batch program.

I have the following directory structure where this batch file will be executed:

Code: [Select]DIR1
   DIRA
   DIRB
   DIRC
DIR2
   DIRD
   DIRE
   DIRF
   DIRG
DIR3
   DIRH
   DIRI
When RUN, it DELETES DIR1 and DIR3 and only keeps DIR2 because it is the largest directory. What I'd like the result to be is as follows:

Code: [Select]DIR1
   DIRC
DIR2
   DIRE
DIR3
   DIRH[code]

In other words, I want to keep all folders in the root directory where the batch file located and only keep the smallest directory within each of the subdirectories.

Is this possible? If not, then what I'd have to do is copy the batch file into each of the main root folders (DIR1, DIR2, DIR3) and run it each time in each of those folders.

Any further (and final) help would be very helpful. Look at the for /r command, I believe this is what you are looking for.  I'm not very well versed in it's uses, so I can't write you one off the top of my head. Quote from: Lemonilla on November 01, 2014, 11:44:45 PM

Look at the for /r command, I believe this is what you are looking for.  I'm not very well versed in it's uses, so I can't write you one off the top of my head.

It's ok, I appreciate your help.

Maybe someone else knows and can help me out with this one.If no one else replies when I get back on tomorrow I'll start running some tests and see if I can get it for you.  Good luck though.Batch math fails above a number around 2 GB.

An accurate DESCRIPTION of the file size limits would help to provide something that works.



This question has been multiposted:

http://stackoverflow.com/questions/26695993/final-step-of-batch-file-doesnt-work-why
http://stackoverflow.com/questions/26689398/batch-file-commands-to-keep-smallest-directory-and-delete-all-others
Quote from: foxidrive on November 02, 2014, 12:34:30 AM
Batch math fails above a number around 2 GB.

An accurate description of the file size limits would help to provide something that works.



This question has been multiposted:

http://stackoverflow.com/questions/26695993/final-step-of-batch-file-doesnt-work-why
http://stackoverflow.com/questions/26689398/batch-file-commands-to-keep-smallest-directory-and-delete-all-others

Yes, I had posted this question elsewhere. The original problem I had has been resolved. The only thing I need to figure out is what I asked in post #3 of this thread.

The sizes of the directories are not over 2GB. Comparing the sizes and deleting the smallest directories (DIRA, DIRB, DIRC, etc.) is what I am trying to achieve. Comparing the sizes and deleting the smallest directories (DIR1, DIR2, DIR3, etc.) which are in the same folder as the batch file is NOT what I want to achieve but that is what the batch file does now in the way that it's written.Remove the echo keyword after testing - at present it will echo the RD commands to the console.

Code: [Select]    echo off
     :: keeps only the smallest folder, deletes all the largest folders, in all the next level folders below this folder
    setlocal EnableDelayedExpansion
    for /d %%a in (*) do (
      (for /d %%b in ("%%a\*") do (
         for /f "tokens=3" %%c in ('dir "%%b" /s /-c ^|find "File(s)" ') do set "size=000000000000000%%c"
         echo !size:~-15! "%%b"
        )
       )>"%temp%\checksize.bin"
    sort <"%temp%\checksize.bin" >"%temp%\checksize2.bin"
    for /f "usebackq skip=1 tokens=1,*" %%d in ( "%temp%\checksize2.bin") do echo rd /s /q "%%~e"
    del "%temp%\checksize?.bin"
    )
    pause
Quote from: foxidrive on November 02, 2014, 02:58:11 AM
Remove the echo keyword after testing - at present it will echo the RD commands to the console.

Code: [Select]    echo off
     :: keeps only the smallest folder, deletes all the largest folders, in all the next level folders below this folder
    setlocal EnableDelayedExpansion
    for /d %%a in (*) do (
      (for /d %%b in ("%%a\*") do (
         for /f "tokens=3" %%c in ('dir "%%b" /s /-c ^|find "File(s)" ') do set "size=000000000000000%%c"
         echo !size:~-15! "%%b"
        )
       )>"%temp%\checksize.bin"
    sort <"%temp%\checksize.bin" >"%temp%\checksize2.bin"
    for /f "usebackq skip=1 tokens=1,*" %%d in ( "%temp%\checksize2.bin") do echo rd /s /q "%%~e"
    del "%temp%\checksize?.bin"
    )
    pause

Created a new batch file with your code. When executed, the result is line after line of this:

Code: [Select]'find' is not recognized as an internal or external command,
operable program or batch file.Your Windows seems broken for some reason.

A likely reason is when someone uses the PATH variable for some other use, or the path variable has been edited in the Windows GUI and parts removed. Quote from: gmgdr11 on November 02, 2014, 06:13:38 AM
Created a new batch file with your code. When executed, the result is line after line of this:

Code: [Select]'find' is not recognized as an internal or external command,
operable program or batch file.

Do you have a variable called %path% in your script?
Quote from: Salmon Trout on November 02, 2014, 06:30:08 AM
Do you have a variable called %path% in your script?

Well no. What I did to test that and generate that error was to copy the code in the post into a blank Notepad window, save it as "test.bat" in root folder of DIR1, DIR2, DIR3 and executed.

I apologize for my very basic knowledge of batch file writing. Programming, even at the most basic level, is something I am not very familiar with. Quote from: gmgdr11 on November 02, 2014, 06:42:47 AM
Well no. What I did to test that and generate that error was to copy the code in the post into a blank Notepad window, save it as "test.bat" in root folder of DIR1, DIR2, DIR3 and executed.

Open a cmd window and type find /? and sort /?

See if they both give you help. Quote from: foxidrive on November 02, 2014, 07:01:36 AM
Open a cmd window and type find /? and sort /?

See if they both give you help.

Ok! Fixed it. The issue was that I had the PATH environment variable set to C:\Cygwin64\.

It displays the correct folders to be deleted. I get the following:

Code: [Select]rd /s /q "DIR1\DIRA"
rd /s /q "DIR1\DIRC"
rd /s /q "DIR2\DIRG"
rd /s /q "DIR2\DIRF"
rd /s /q "DIR2\DIRE"
rd /s /q "DIR3\DIRH"
How does the batch file need to be modified then to execute those commands rather than display them now that it is confirmed that it accurately finds the proper directories to delete?

Thanks.
2149.

Solve : Corrupted file detection methods thru batch & replace mismatched files etc?

Answer»

So my one computer I thought was protected by a battery backup and the 7 year old battery backup dropped like a stone during a short outage killing the computer mid process of some write processes.

I learned that some data on the C: drive got corrupted in both my personal data that is at C:\DATA\ as well as I ended up having to uninstall and REINSTALL the video game RIFT which got corrupted through this.

Was wondering if anyone knew of any neat batch tricks to test for corrupted files between an internal HDD which has had some files now become unable to open and an external hard drive that was not connected during this outage and is healthy, and if mismatches are found between C:\Data\ and H:\Backup\ to then copy the files from the C:\Data\ to H:\Mightbecorrupt\ and then copy the same file from H:\Backup\    back to C:\Data\

I then can look at the H:\Mightbecorrupt\   files and see if they were picked up as a mismatch because they are newer date/time stamp to that of the last backup same file older/date time stamp and likely binary mismatch or if these are the ones that are corrupt which wont open and so I know what data I lost or need to fix vs having to find out LATER when needing this information that I lost it   

I am thinking that I will need to perform a FC /B through a FOR loop through all files between C:\DATA\ and H:\Backup\ and will need to add an IF statement for mismatches to xcopy those mismatches to H:\Mightbecorrupt\ to retain directory path and file location structure, as well as if there is a mismatch to xcopy the could be older file from the H:\backup\ to C:\Data\ and to increment through all files and folders between C:\Data\ and H:\Backup\ that I will need to use a TREE or DIR output to start at the beginning alphanumerically and get to the end of the file/directory structure to test all, and this has put me at a loss on how to accomplish this.

If I only had a hand full of files I would just take the time to open each one and test to see if they open ok, but because I have many in the thousands, I feel that this calls for a better automated compare method in which most files will be an exact match and only a choice few hopefully are corrupt or newer than the last backup which both newer as well as corrupted would get flagged under the FC /B process as a mismatch.

At a loss on how to achieve this test between the 2 drives and identify the corrupted files because this goes beyond my batch knowledge. Also there may be a better method than that of FC, but I was thinking it is likely needed for testing between files for the slightest differences which means a healthy file, corrupted file, or a newer file than that of the backup data from within 7 days prior. 

Was playing aroudn with FC as seen below... the first test is with 2 files with a D and d difference, the other compare has exact text data in it and so there is no mismatches. I was thinking that maybe anything other than output of "FC: no differences encountered" would cause the batch to go through a xcopy of the C:\Data\potentially_troubled_file.ext to H:\Mightbecorrupt\ and then copy H:\Backup\whatever_the_path_is_to_this_file\known_good_file.ext to C:\Data\same_path_that_was_used\same_file_name_from_external_HDD.ext and then move on to the next file and skip copying any files that areno differences, but go through this process for files with differences detected in which the /B Binary flag is probably best to be used.

Quote

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

C:\Documents and Settings\user1>cd\.

C:\>md TEST2

C:\>cd test2

C:\test2>edit test1.txt

C:\test2>edit test2.txt

C:\test2>fc /b test1.txt test2.txt
Comparing files test1.txt and TEST2.TXT
00000000: 64 44

C:\test2>edit test2.txt

C:\test2>fc /b test1.txt test2.txt
Comparing files test1.txt and TEST2.TXT
FC: no differences encountered


C:\test2>


Just an update... Digging online for methods using FC, I came across Foxidrive's response here    http://www.pcreview.co.uk/forums/fc-exe-return-value-t2441497.html

With this back in 2006 for another person looking for a batch method use of FC for 2 files ...

Code: [Select]echo off
fc /b file1 file2|find /i "no differences">nul
if errorlevel 1 echo miscompare
if not errorlevel 1 echo compared ok
Looks like if I make it like this, but able to test among any number of files in any number of folders between 2 root folder locations, it might work, although I need the checking to be between all files between the C:\Data\ and H:\Backup\


Quote
echo off
fc /b file1 file2|find /i "no differences">nul
if errorlevel 1 echo Mismatch Detected
copy dynamicpath/filename from C:\Data\ to H:\mightbecorrupt\
copy the known good file from H:\Backup\%dyn_path%\%dyn_filename% to C:\Data\%dyn_path%\%dyn_filename%
loop back ( goto loop condition or FOR loop? ) to test next file until all files compared among all files and folders between C:\Data\ and H:\Backup\if not errorlevel 1 echo compared ok ... moving on to next file checkecho Process Complete ... Any mismatched files can be found at H:\mightbecorrupt\


In red....

- I am unsure how to accomplish using the path from that of which the file was found and compared against to have this dynamic path for the fact that I cant think of a better way to explain it, get passed into a variable such as %dyn_path% in which I think I have to use SET %dyn_path% = ( the actual path to file, but not sure how to get this). Above I show %dyn_path% and %dyn_filename% .... this might be able to be passed for say C:\Data\Project1\test1.cpp directly into %dyn_path% without having to have C:\Data\Project1\ passed into %dyn_path% and test1.cpp passed directly into %dyn_filename%

- Not sure also how to start at first file/folder alphanumerically to test all files in all folders between C:\Data\ and H:\Backup\ until End Of Files & Folders is found. Not sure if the best method to test between C:\Data\ and H:\Backup\ would be to create a copy of the entire directory trees between C:\Data\ and H:\Backup\ by use of an XCOPY TRICK where you can actually have it perform an XCOPY without writing files and have this info that is normally displayed written to file and then have a FOR loop that imports each line 1 by 1 which holds the paths to the files, and by use of a counter, can know to read in the path from say line 44 of this XCOPY text file that holds a copy of the directory tree to test against. This XCOPY tree would be generated from that of the C:\Data\ and to trick xcopy into thinking that it would normally need to copy files to say the root of H:\ to avoid error condition of cyclic copy condition, but instead of copying the files and folders list all paths with files would be to use of the /F ( full paths )and /L ( display only )switches and sending the output via > to TreeLayout.txt which is then read by the loop with the FC instructions and IF THEN ELSE logic of true or false for match or mismatch.

Are the trees c:\data and h:\backup the same trees?

Just 7 days different? (plus corrupted files) Quote
Are the trees c:\data and h:\backup the same trees?

Hello foxidrive     Yes they are exactly the same trees and up to 7 days different since the backup is performed weekly. Right now I have held off on the backup to that external until i can get this issue resolved and instead am just saving data to a 32GB flash stick.This is untested:

It will do a fairly swift compare for files that are missing and files that have different sizes
and will create a batch file (which has a .txt extension for you to check first for any obvious errors)

fc_compare.C.bat.txt


The batch file is designed to compare the files with the same filesize and write a report if there is a binary mismatch. 
This will take much longer if there is a lot of GB of data involved.

All log files will be written to the desktop.


Code: [Select]echo off
dir "c:\data" /b /s /a-d >"%userprofile%\desktop\c_data.txt"

for /f "usebackq tokens=1,2,* delims=\" %%a in ("%userprofile%\desktop\c_data.txt") do (
   if not exist "h:\backup\%%c" (>>"%userprofile%\desktop\h_data_missing.txt" echo missing "h:\backup\%%c")
   if     exist "h:\backup\%%c" (
       for %%m in ("c:\data\%%c") do for %%n in ("h:\backup\%%c") do (
         if %%~zn EQU %%~zm (
             >>"%userprofile%\desktop\fc_compare.C.bat.txt" echo fc /b "c:\data\%%c" "h:\backup\%%c" ^>nul ^|^| ^(^>^>"%userprofile%\desktop\fc_compare.result_C.txt" echo data mismatch in "c:\data\%%c" and "h:\backup\%%c"^)
        ) else (
             >>"%userprofile%\desktop\fc_compare.C.size_mismatch.txt" echo size mismatch in "c:\data\%%c" and "h:\backup\%%c"
      )
   )
)


dir "h:\backup" /b /s /a-d >"%userprofile%\desktop\h_data.txt"

for /f "usebackq tokens=1,2,* delims=\" %%a in ("%userprofile%\desktop\h_data.txt") do (
   if not exist "c:\data\%%c" (>>"%userprofile%\desktop\c_data_missing.txt" echo missing "c:\data\%%c")
)
echo see if any errors appear on the console above
pause
hmm... so I am testing this on a Windows 7 64-bit system and it creates a c_data.txt file to desktop, but ends there. I ran this from cmd shell and it runs and exits back to C:\> so it seems to be terminating too early for some reason as for it never gets to the pause. 

The file on the desktop c_data.txt I have the following files in as copy/pasted from this file here.

Quote
c:\data\test1.txt
c:\data\test2.txt
c:\data\test3.txt
c:\data\test4.txt
c:\data\test5.txt
c:\data\test6.txt

It seems as though its carrying out this action and ending here:

Code: [Select]dir "c:\data" /b /s /a-d >"%userprofile%\desktop\c_data.txt"
This is where it leaves me off at after running, back to command prompt. And the directory info is written to file that is passed to desktop.


Quote
C:\batches>run_compare1.bat
C:\batches>
I'd forgotten about that task.  Did it take 2 weeks to run?

It was missing a closing parenthesis IIANM so try this.

Code: [Select]echo off
dir "c:\data" /b /s /a-d >"%userprofile%\desktop\c_data.txt"

for /f "usebackq tokens=1,2,* delims=\" %%a in ("%userprofile%\desktop\c_data.txt") do (
   if not exist "h:\backup\%%c" (>>"%userprofile%\desktop\h_data_missing.txt" echo missing "h:\backup\%%c")
   if     exist "h:\backup\%%c" (
       for %%m in ("c:\data\%%c") do for %%n in ("h:\backup\%%c") do (
         if %%~zn EQU %%~zm (
             >>"%userprofile%\desktop\fc_compare.C.bat.txt" echo fc /b "c:\data\%%c" "h:\backup\%%c" ^>nul ^|^| ^(^>^>"%userprofile%\desktop\fc_compare.result_C.txt" echo data mismatch in "c:\data\%%c" and "h:\backup\%%c"^)
        ) else (
             >>"%userprofile%\desktop\fc_compare.C.size_mismatch.txt" echo size mismatch in "c:\data\%%c" and "h:\backup\%%c"
      )
   )
))

echo stage one hacked&pause

dir "h:\backup" /b /s /a-d >"%userprofile%\desktop\h_data.txt"

for /f "usebackq tokens=1,2,* delims=\" %%a in ("%userprofile%\desktop\h_data.txt") do (
   if not exist "c:\data\%%c" (>>"%userprofile%\desktop\c_data_missing.txt" echo missing "c:\data\%%c")
)
echo see if any errors appear on the console above
pause Quote
I'd forgotten about that task.  Did it take 2 weeks to run?


 Actually I just finally got around to testing it  ... Looking forward to getting back to normal 40 hr work weeks vs these 60s. It wont be another 2 weeks before I test this though. Thanks for your help with this.  Sweet this works perfect.... Thanks for your help with this.
2150.

Solve : Reading a registry?

Answer»

Okay, so I am writing a SCRIPT to INSTALL "local" printers via IP addresses, and have found that I need to make modifications to the registry in order to do so. In Windows 7 HOWEVER, they have introduced a new key into the TCP/IP Port registry keys called "PortMonMibPortIndex" which essentially just tells the registry what order the ports are listed in. This presents a problem for me THOUGH, as I am wanting to write this script to install the port to the next available Index number.

What I am looking for is for a way to tell how many folders(/keys) are within a folder in the registry.



Quote from: hardslate on November 19, 2014, 03:45:05 AM

What I am looking for is for a way to tell how many folders(/keys) are within a folder in the registry.

Output the 'folder' in the registry through the find command using /c and you can get a count.

If you need an exact command, and you can show the registry information that you need to count, then one of use can provide it for you.