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.

7701.

Solve : Batch file to Copy certian lines in a txt file only?

Answer»

Hello Haven't been on in a while been doing lots of stuff and learning
Im making a mod for fallout new vegas on the 360 and need a batch file that will
1.look at each line in a txt file and IGNORE lines without the prase "WEAP"
2.copy the FIRST 8chars into a new txt file line per line
and the data in the txt file its copying from looks LIKE this:
Code: [Select]01004746 NVDLC03PlayerTrunk CONT Trunk
01009701 NVDLC03WeapProtonAxeInversal WEAP Protonic Inversal Axe
01006DB3 NVDLC03SLVillageBorousBINT CELL Basement
0100A130 NVDLC03WeapGlovesCorrosive WEAP Corrosive GloveI know i will need to use delims and tokens but those are my weak points
so if anyone could help me There would be many thanks
I believe the script would go along the lines of:
Code: [Select]@echo off
for /F "tokens=1" %%i in (file.txt) do echo %%i>output.txtProblem being I don't know how to filter out the unnecessary things@echo off
for /F "tokens=1 delims= " %%G in ('type file.txt ^|findstr /C:"WEAP"') do (
>>output.txt echo %%G
)Thank you doesn't do exactly what i want but makes things so much easier wish i had known about the findstr command soonerWhat do you mean it doesn't do exactly what you want. That is exactly what you asked for!I see now. That is a TAB delimited text file. Just remove the DELIMS option. By default a FOR LOOP will delimit by a tab and a space when you don't specify the delimiter.Quote from: Squashman on July 01, 2012, 08:52:45 PM

What do you mean it doesn't do exactly what you want. That is exactly what you asked for!
Well I wanted one batch file to do all the work but your solution wasnt spot on because my lack of explanation Probably
But I figured it out Thanks to you and made these two batch files That completely solve the Problem
This One Prepares The file for Reading (Basically):
Code: [Select]@echo off
Echo.Catagories
echo.ARMO=Armor MISC=misc ALCH=AID NOTE=notes WEAP=Weapons AMMO=ammo WeaponMods=IMOD
set /p A=Ammout:
set /p C=Catagories:
set /p filename=Filename:
set /p B=OutputFilename:
for /F "tokens=1 delims= " %%I in ('type %filename% ^|findstr "%C%"') do (
>>%B% echo %%I
)
call SortIDs.bat
pause
And this one finished it Up:
Code: [Select]for /F "tokens=1" %%G in (%B%) do (
>>%B% echo player.additem %%G %A%
)
Quote from: millergram on July 04, 2012, 09:52:10 PM
Well I wanted one batch file to do all the work but your solution wasnt spot on because my lack of explanation Probably
My solution was spot on given the information you gave me. You never said anything about that extra code you have for you 2nd batch file.
7702.

Solve : Arrange Windows when opened?

Answer»

Is there a way to arrange the windows started using a batch file? so instead of opening them all on top of each other in a big heap, have them spread out to cover the screen (or make a square) with no overlaying. If so how would you do that?

I am trying to open Resource Monitor, Task MANAGER, and SpeedFan

Code: [Select]cd C:\Program Files\SpeedFan
start speedfan.exe

resmon
taskmgr

exit
This opens them all on top of each other.Try this. The 8 in the ping command is to wait ~8 seconds until all programs are loaded before tiling.

Code: [Select]::TileSideBySide.cmd by Todd Vargo
@echo off
call :Min >"%temp%.\tmp.vbs"
cscript /nologo "%temp%.\tmp.vbs"
start www.google.com
start notepad.exe
start taskmgr
start resmon
ping -n 8 127.0.0.1
call :Tile >"%temp%.\tmp.vbs"
cscript /nologo "%temp%.\tmp.vbs"
del "%temp%.\tmp.vbs"
goto :eof

:Min
echo CreateObject("shell.application").MinimizeAll
goto :eof

:Tile
echo CreateObject("shell.application").TileVertically
goto :eofthe only problem I'm running into is that it's arranging them off screen, so the BOTTOM half of taskmgr is off the bottom of the screen.It doesn't do that here.

Is it only task manager that this happens with?And speedFan, whichever ONE gets the bottom left corner. I think the problem may be that speedFan doesn't support RESIZING.

7703.

Solve : Archiving by Last modified date?

Answer»

So I need to move all the contents of a network drive onto an external drive so that when we go to move the network drive to a new server we are not bringing old, outdated files with it and we can put them to DVD for later if we FIND files are indeed missing.

I want a batch FILE I can run that WOULD move all files from before 2008 onto the drive keeping the file structure even if the directory is empty to this removable drive, it also needs to keep the directory structure on the network drive as well. I am not certain this can be done, I have seom batch file experience but not this much. Any help would be appreciated.Why not just "clone " the drive as is...then WEED out what you want ? ?patio's suggestion makes sense....
Copy over everything and then, on the new PC, do a search of all files older than 2008 and delete the LOT of them.

I would also recommend against storing the old files on a DVD. Get yourself a good external hard drive and copy everything to that. DVDs can be very cumbersome and require more organization, depending on how much data you have. DVDs are also less tolerant to temperature and light than hard drives.

7704.

Solve : Get a batch script to detect the drive letter it is running from??

Answer»

I am working on a batch script that I will be using to keep a folder updated across four computers. This script will be located on a memory stick, and it's function will be to copy modified files from the memory stick to the computer, and to copy modified files from the computer to the memory stick, and that is where I run into issues - At the moment, I have to go and modify the TARGET letter for the USB memory stick each time I move it to a different computer.

What I WOULD like is if someone could help me, by telling me how to make a batch script detect the drive letter.

I am aware of UTILITIES like dropbox, which would do what I ask - keeping things synchronized across four computers, but in this situations, that is not an option.Something like (you can just copy and paste into a DOS prompt - the first line will create the file with the rest of the lines in it, control-Z to save/exit):


copy con: show-current-drive.bat
@echo off
echo.
echo Starting Copies %date% %time%
echo.
for %%F in (%0) do (
echo Current drive is %%~dF
xcopy %%~dF\batchfiles\* G:\batchfiles\* /d /v /-y
xcopy G:\batchfiles\* %%~dF\batchfiles\* /d /v /-y
)
echo.
echo Copies complete %date% %time%
echo.
exit /b

control-Z

The %0 translates to the current FILENAME being executed and the for-loop further parses the name to find the drive letter. %%F (CASE sensitive) is the file name coming out of (into?) the loop and the small d says you just want the drive letter. And as a "bonus" the /d on the XCOPY will only try to update new or newer files - if they have the same time-stamp, it ignores them. The /-y allows YOU to choose when to over-write, but if you want to use / y, it will over-write w/o asking.

I do this a lot, too, but from network drives, etc. I also do file-compares in case I've modified from more than one location.

DaveHey, thanks. That should do the trickYou can use the ~ tilde variable modifiers on the parameters %0 and %1 to %9, as well as the FOR metavariables, so that the drive letter (including colon) on which a batch is running from is simply %~d0 and %~d0\ is the root folder of that drive, with no need for a FOR loop. The other ones - p,n,x,t,z etc all work too.

Yeah, I knew that - I just forget about it sometimes - and I'd never used it on %0...

7705.

Solve : How to prevent variable substitution in SET command?

Answer»

I am trying to do the following:

Code: [Select]SET I=http://www.someURL.com/My%20Webpage%28Version%20B%29.html
in a batch file. However, the second parameter to the file (%2) is being substituted in the above.

How do I prevent variable substitution in the above example?

Thanks in advance for your help,

John L.SET I=http://www.someURL.com/My%%%20Webpage%%%28Version%%%20B%%%29.html

you have to use the escape the %, otherwise it thinks you are referring to a veritable

for most charictors (>, |, &) you need to use ^ but with % you must use another % or surround it with %'sQuote from: Lemonilla on September 04, 2012, 03:11:43 PM

you have to use the escape the %, otherwise it thinks you are referring to a veritable

for most charictors (>, |, &) you need to use ^ but with % you must use another %

That's correct.


Quote from:
or surround it with %'s

That BIT is wrong. Just double the percent signs.


Code: [Select]SET I=http://www.someURL.com/My%%20Webpage%%28Version%%20B%%29.htmlinteresting, triple % has ALWAYS worked for me, but maybe only in certain instances.Quote from: Lemonilla on September 05, 2012, 02:32:04 PM
interesting, triple % has always worked for me, but maybe only in certain instances.

What CIRCUMSTANCES?

Quote from: Salmon Trout on September 06, 2012, 01:43:23 PM
What circumstances?


Everything I've ever WRITTEN, would you LIKE me to post some examples? I'll have to go digging.Quote from: Lemonilla on September 07, 2012, 01:51:18 PM
would you like me to post some examples?

Yes please.
Here, I'll do it for you.

Code: [Select]@echo off
echo Passed parameters:
echo Parameter 1 %1
echo Parameter 2 %2
echo.
echo Attempting to escape percent signs in string:
echo.
echo 1. No escaping
SET I=http://www.someURL.com/My%20Webpage%28Version%20B%29.html
echo %I%
echo.
echo 2. Replace one percent sign with two
SET I=http://www.someURL.com/My%%20Webpage%%28Version%%20B%%29.html
echo %I%
echo.
echo 3. Replace one percent sign with three
SET I=http://www.someURL.com/My%%%20Webpage%%%28Version%%%20B%%%29.html
echo %I%
echo.
echo 4. Replace one percent sign with four
SET I=http://www.someURL.com/My%%%%20Webpage%%%%28Version%%%%20B%%%%29.html
echo %I%
echo.

1. With parameters passed

Code: [Select]Passed parameters:
Parameter 1 cat
Parameter 2 dog

Attempting to escape percent signs in string:

1. No escaping
http://www.someURL.com/Mydog0Webpagedog8Versiondog0Bdog9.html

2. Replace one percent sign with two
http://www.someURL.com/My%20Webpage%28Version%20B%29.html

3. Replace one percent sign with three
http://www.someURL.com/My%dog0Webpage%dog8Version%dog0B%dog9.html

4. Replace one percent sign with four
http://www.someURL.com/My%%20Webpage%%28Version%%20B%%29.html

With no parameters passed

Code: [Select]Passed parameters:
Parameter 1
Parameter 2

Attempting to escape percent signs in string:

1. No escaping
http://www.someURL.com/My0Webpage8Version0B9.html

2. Replace one percent sign with two
http://www.someURL.com/My%20Webpage%28Version%20B%29.html

3. Replace one percent sign with three
http://www.someURL.com/My%0Webpage%8Version%0B%9.html

4. Replace one percent sign with four
http://www.someURL.com/My%%20Webpage%%28Version%%20B%%29.html

If you study the above you will see that to get ONE percent sign in the URL string using SET, you need exactly TWO percent signs in the code.



Put simply, 2N percents in the code are replaced by N percents in the displayed result, and 2N+1 percents are replaced by N+1 percents.



7706.

Solve : %%G help?

Answer»

So The PROGRAM is SUPPOSE to ping each computer on the network and then display the name and the average ping in this format:
Code: [Select]\\Computer1
= 10ms
\\Computer2
= 20ms
\\Computer3
= 312ms
to do this I was using 'net view | FIND "\\" >>network.1' to write a list of the computers to a file, then I planned on using 'for /f %%G IN (network.1) DO ( set /a c+=1 & echo %%G >>net%c%.1).
The problem is, that it is writing the whole network list into net0.1 every time instead of posting \\computer1 into net0.1 and \\computer2 into net1.1 and \\computer3 into net2.1. Any Idea's?

whole code:
Code: [Select]@echo off
set c=0

net view | find "\\" >>network.1

for /f %%G IN (network.1) DO (
set /a c+=1
echo %%G >>net%c%.1
)

set m=%c%
set c=0
pause

:loop.rename
set y=\\
set /p y=<net%c%.1
set y=%y:~2,100%
ping %y% | find "Min" >>ping%c%.1
set /a c+=1
if %c% EQU %m% goto break.rename
goto loop.rename
:break.rename

set c=0

:loop.view
type net%c%.1
set /p a=<ping%c%.1
FOR /F "tokens=4 delims==" %%G IN ("%a%") DO (
echo %%G
)
set /a c+=1
if %c% EQU %m% goto break.view
goto loop.view
:break.view

pause
del /f *.1
pause >nul
Code: [Select]for /f "delims=*" %%G in (network.1) do (set /a c+= 1 & echo %%G >>net%c%.1)


See if that helps. You might need to tweak the delims= value if it doesn't.Nope, still gives net0.1 containing
Code: [Select]\\computer1
\\computer2
Need to use Delayed Expansion. Your inside a FOR LOOP.Quote from: Squashman on July 03, 2012, 06:28:29 AM

Need to use Delayed Expansion. Your inside a FOR LOOP.
Still getting the same error. It's suppose to be Code: [Select]setlocal EnableDelayedExpansioncorrect?Quote from: Lemonilla on July 03, 2012, 07:13:40 AM
Still getting the same error.
You are getting an error now. You didn't say anything about getting an error in your previous posts.

Quote from: Squashman on July 03, 2012, 07:19:17 AM
You are getting an error now. You didn't say anything about getting an error in your previous posts.


My bad, was referring to the BUG as an error. I found the problem though. I was trying to write to net%c%.1, when I changed that to net!1!.1 it worked, so I believe that %c% was not UPDATING with my set /a c+=1.
Final code:
Code: [Select]@echo off
set c=0
if exist *.1 del /f *.1
title Network Pinger
setlocal EnableDelayedExpansion
net view | find "\\" >>network.1

for /f %%G IN (network.1) DO (
set /a c+=1
echo %%G >>net!c!.1
)

set m=%c%
set c=0

:loop.rename
set /a c+=1
set y=\\
set /p y=<net!c!.1
set y=%y:~2,100%
ping %y% | find "Min" >>ping%c%.1
if %c% EQU %m% goto break.rename
goto loop.rename
:break.rename

set c=0

:loop.view
set /a c+=1
type net%c%.1
set /p a=<ping%c%.1
FOR /F "tokens=4 delims==" %%G IN ("%a%") DO (
echo %%G
)
if %c% EQU %m% goto break.view
goto loop.view
:break.view

del /f *.1
pause >nul

Quick question, when pinging a computer name, will it be effected by internet usage? (i.e. If I have 120 pictures loading on the internet and ping myself, will the loading of the pictures slow down the packets?)Quote
I believe that %c% was not updating with my set /a c+=1.

For delayed-expansion to work you need two things

1. Setlocal enabledelayedexpansion

2. The variable name to be expanded is preceded and followed by exclamation marks NOT percent signs.
7707.

Solve : net view | ____?

Answer»

Is there a pipe I can use on net view to show how much bandwidth each computer is PULLING? Or a diffrent (non-installed) command to do this?You want to KNOW how much bandwidth is being pulled by each computer on your network from your computer?
Or do you want to know how much bandwidth they are all pulling from your Internet connection?Each computer, then I can pin the blame on my slow connection on a specific computer and not have to guess who else is doing something.So you have some Network SHARE on your computer that everyone is accessing?At our house, we have ~150-200mbpsec download speed split amoungst whoever is on the internet, I was wondering if there was a way to FIND out which computers in the house (on the network) were taking from that and how much.Quote from: Lemonilla on June 24, 2012, 07:57:10 PM

At our house, we have ~150-200mbpsec download speed split amoungst whoever is on the internet, I was wondering if there was a way to find out which computers in the house (on the network) were taking from that and how much.
Why didn't you just say that in your first post.I figured I was, just with different words. Sorry for misleading you.Haven't tested this on a network YET (no one's home), but this (may) work.
Code: [Select]@echo off
net view | find "\\" >>network.1
set c=0
for /f %%G IN (network.1) DO (
echo %%G >>net%c%.1
set /a c+=1
)
set m=%c%
set c=0
:loop.rename
set /p y=<net%c%.1
set y=%y:~2,100%
ping %y% | find "Min" >>ping%c%.1
set /a c+=1
if %c% EQU %m% goto break.rename
goto loop.rename
:break.rename
set c=0
:loop.view
type net%c%.1
set /p a=<ping%c%.1
FOR /F "tokens=4 delims==" %%G IN ("%a%") DO (
echo %%G
)
set /a c+=1
if %c% EQU %m% goto break.view
goto loop.view
:break.view
del /f *.1
pause >nul

7708.

Solve : Load a dll?

Answer»

Load a LIBRARY or function with a bat file

How can i do to load or UNLOAD a dll ?
It's the same REGISTER a dll and load a dll ?

Best Regards
But I would like to kwow how load or register a dll with a bat file.

How can be done ?

Best Regards
You can register a COM Component in a DLL using regsvr32.

You cannot call FUNCTIONS EXPORTED from a DLL using a batch file. You can call some functions using Rundll32, but that services only a subset of available functions.I'll try and comment.

Best Regards

7709.

Solve : Moving many files up one directory level?

Answer»

Hi,

I have about 400 folders with the following directory depth:
Level1\Level2\Level3\*.files

I need to move all of the *.files up one directory so that they are:
Level1\Level2\*.files

It would also be extremely helpful if I could limit the *.files to specific types of files, namely *.MP3 and then if I could delete the "Level3" directories and any remaining junk files they contain.

I'm sure this solution is possible in with a BAT file?

Thank you.
I would not recommend a bat file.
Do you have a backup device?
Do you have lots of free space on your disk?
Rather that move, you should copy.

But if you insist. You are gong to skip over one on folder, the top one.
Level1\Level2\Level3\*.files

The Level1 folder will not be moved.

We shall move the contents of the next folder down to a new, higher location. Later you can rename the folders, if you wish.


Make a new folder. call it Level2New.
This is going to be the target folder. Make it at the highest level.

In windows explore open the the Level2 fonder.
Now look up on the tool bar. See the 'Edit' tab?
Click on Edit, Select all.
Then Click on Move to folder.
Select the Level2New as the target.
If you do it right the contents of Level2 and everything below will be in Level2New.
Level1 will still have its contents.
Practice on some dummy folders first.
the folders aren't being moved... the files are.



Code: [Select]@echo off
for /f %%P in ('dir /b /od') do copy %%P\*.* .
REM for /f %%P in (dir /b /od') do RMDIR /s /q %%P

Run this batch file from within the "level2" folder. what it does is copy all files from the folders within level2 into the level2 folder itself. (as I understand your issue, you have many folders within this level2 folder, and wish to copy the files from each of these folders to the parent folder.

Note that I am using the "copy" command, at this point. the loop that removes the directories is commented out. I recommend making a complete backup, if at all possible, before deleting them. Or, you could change the command to move. a Move is faster then a copy and delete on the same drive. Also, you can easily change the filemask by changing the %%P\*.* to %%P\*.mp3, for example.

also, remember that if any of these folders has filenames that are the same as files in any other folder, you should rename them. the copy command as written will prompt you to overwrite if any names conflict.

Code: [Select]@echo off
cd "C:\Documents and Settings\cameronyoung\Level1\Level2\Level3\"

copy *.mp3 "C:\Documents and Settings\cameronyoung\Level1\Level2\"

delete *.*
Hi, I don't think I explained myself as clearly as I could have. I really need something that will loop through a number of folders, a better explanation of my 400 odd folders would be like this:

Level1\1Level2\Level3\*.files
Level1\2Level2\Level3\*.files
Level1\3Level2\Level3\*.files
Level1\4Level2\Level3\*.files
Level1\5Level2\Level3\*.files
Level1\6Level2\Level3\*.files

What I want to do is to remove all of the "Level 3" folders and move the contents (well, just .MP3 files if possible) back to the "Level 2" folders. It's easy to do it for one folder, but I've got about 400 folders at "Level 2" which each contain an extra, unwanted folder.

Even if the script or whatever doesn't delete the "Level 3" folders in the end, that's not a big deal, as I have a program that could remove them.. though it would be preferable.

Thanks for your help.Ahh, OK, guess I misunderstood

Code: [Select]@echo off
for /f %%P in ('dir /b /od') do copy %%P\level3\*.* .\%%P\
REM for /f %%P in (dir /b /od') do rmdir /s /q %%P\level3

Run this from within your "level1" folder. it will do something similar to the previous batch I provided; this one loops through all the folders ('dir /b /od') and copies the files from within the level3 folder of that folder "out" of the folder into the "level2" folder that it's looping through.

Again, the remarked out rmdir command will remove the level3 folders, as well. the first loop only copies. and change the "%%P\level3\*.*" to "%%P\level3\*.mp3" to only copy mp3 files. (as I'm sure your aware deleting the folder will result in the loss of other files that are not MP3 from within that folder.Now that we have all confused him,
If his file structure is in good shape ...
and if explorer is not bite by bugs.

He can do it in one drop and drag.
Quote from: Geek-9pm on January 11, 2010, 08:42:42 PM

Now that we have all confused him,
If his file structure is in good shape ...
and if explorer is not bite by bugs.

He can do it in one drop and drag.


No. he can't. you might want to read a bit closer.

He wants to move the files in all the DIFFERENT level3 folders beneath the level 2 folders into the respective level 2 folders. THIS CANNOT be done quickly with explorer.Quote from: BC_Programmer on January 11, 2010, 07:50:24 PM
Ahh, OK, guess I misunderstood

Code: [Select]@echo off
for /f %%P in ('dir /b /od') do copy %%P\level3\*.* .\%%P\
REM for /f %%P in (dir /b /od') do rmdir /s /q %%P\level3

Run this from within your "level1" folder. it will do something similar to the previous batch I provided; this one loops through all the folders ('dir /b /od') and copies the files from within the level3 folder of that folder "out" of the folder into the "level2" folder that it's looping through.

Again, the remarked out rmdir command will remove the level3 folders, as well. the first loop only copies. and change the "%%P\level3\*.*" to "%%P\level3\*.mp3" to only copy mp3 files. (as I'm sure your aware deleting the folder will result in the loss of other files that are not MP3 from within that folder.

Hey, I am pretty sure this will work, except I may not have given you all the required info.

"Level 1" is always called "music" but the "Level 2" and "Level 3" directories always have different names. In that BAT file you gave me I noticed that you you have a couple of commands which point specifically to folders called "Level 3": is there a way to just point to directories at this level in the tree rather than folders actually named "Level 3"?

Thanks so much!Quote from: BillRichardson on January 11, 2010, 07:28:18 PM
Code: [Select]@echo off
cd "C:\Documents and Settings\cameronyoung\Level1\Level2\Level3\"

copy *.mp3 "C:\Documents and Settings\cameronyoung\Level1\Level2\"

delete *.*


Quote from: Salmon Trout on January 12, 2010, 12:16:29 AM

SORRY you haven't read my post properly. BC_Programmer could you please check my reply? Thanks heaps.Quote from: cameronyoung on January 12, 2010, 12:18:14 AM
Sorry you haven't read my post properly. BC_Programmer could you please check my reply? Thanks heaps.

I have, somebody else hasn't.
Original code:

Code: [Select]@echo off
for /f %%P in ('dir /b /od') do (
PUSHD %%P
for /f %%I in ('dir /b /od') do (
copy "%%P\%%I\*.*" ".\%%P\"
REM rmdir /s /q "%%P\%%I"
)
popd

)


new code:

Code: [Select]SETLOCAL ENABLEDELAYEDEXPANSION
for /f "usebackq delims=" %%P in (`dir /b /ad`) do (
pushd %%P
for /f "usebackq delims=" %%I in (`dir /b /ad`) do (
copy "%%I\*.*" .\
REM rd /s /q "%%I"
)
popd

)

changed the dir command to what I originally intended; I had /od, but /o and -o are for sorting. changed it to /ad so they would both only enumerate directories.

Given the new requirements, added a nested loop within the original, to account for "level3" folders having different names. In this case, it iterates on ALL folders within each folder; Again, I have the rd command remmed out here; unrem it after you test it for it to delete the folders as you wanted. It worked for my tests (it moved all data in third level folders to their respective second level folders) however, with multiple folders we have the problem of duplicate filenames in these folders; copy will prompt to overwrite in this scenario.Hey BC_Programmer,

I added the below code to a .BAT file but it didn't work.

Quote from: BC_Programmer on January 12, 2010, 01:57:14 AM
Code: [Select]SETLOCAL ENABLEDELAYEDEXPANSION
for /f "usebackq delims=" %%P in (`dir /b /ad`) do (
pushd %%P
for /f "usebackq delims=" %%I in (`dir /b /ad`) do (
copy "%%I\*.*" .\
REM rd /s /q "%%I"
)
popd

)

When I added the code as is, it didn't move any files or delete anything. When I removed the REM it just deleted everything except the parent directories.

Am I doing something wrong? I ran the .BAT file from "S:\MUSIC\test.bat" and these are the exact files I had in the directory:

S:\MUSIC\dalek vs faust\2004 - derbe respect, alder\dalek vs faust v0\01 jhevevevj.mp3
S:\MUSIC\dalek vs faust\2004 - derbe respect, alder\dalek vs faust v0\02 83fjh3v3v.mp3
S:\MUSIC\dalek vs faust\2004 - derbe respect, alder\dalek vs faust v0\03 jeje vv urvfrv.mp3
S:\MUSIC\dalek vs faust\2004 - derbe respect, alder\dalek vs faust v0\folder.jpg
S:\MUSIC\mazzy star\1991 - she hangs brightly\she hangs brightly\01 whh whh whaaamp3
S:\MUSIC\mazzy star\1991 - she hangs brightly\she hangs brightly\02 bleeef dikee aa.mp3
S:\MUSIC\mazzy star\1991 - she hangs brightly\she hangs brightly\03 !.mp3
S:\MUSIC\mazzy star\1991 - she hangs brightly\she hangs brightly\playlist.m3u

I had HOPED that it would produce the following:

S:\MUSIC\dalek vs faust\2004 - derbe respect, alder\01 jhevevevj.mp3
S:\MUSIC\dalek vs faust\2004 - derbe respect, alder\02 83fjh3v3v.mp3
S:\MUSIC\dalek vs faust\2004 - derbe respect, alder\03 jeje vv urvfrv.mp3
S:\MUSIC\mazzy star\1991 - she hangs brightly\01 whh whh whaaamp3
S:\MUSIC\mazzy star\1991 - she hangs brightly\02 bleeef dikee aa.mp3
S:\MUSIC\mazzy star\1991 - she hangs brightly\03 !.mp3

Ideally I would have liked it to move only the .MP3 files and then for it to remove the directories the MP3s were moved from and any non-MP3 files they contain.

It needs to be something GENERIC though, as there are about 2000 more "dalek vs faust" and "mazzy star" level directories with the exact same structure.

Please let me know if this isn't clear. Thank you.Sorry to jump in, but shouldn't this

copy "%%I\*.*" .\

be this

copy "%%I\*.*" ..\

?

(i.e. two dots refer to the next folder up)

7710.

Solve : matrix in batch stop in 3 second?

Answer»

Quote from: tendude on July 01, 2012, 03:05:34 AM

actually i want and like to LEARN how batch COMMAND really works...

what batch can do...and what its can't...

learning something from what i do to MAKE something like i want...

i want to learn and try to push its to the limit...and get realise how the batch limit like...

but i ALSO need guidance from others who know batch...TY to you all who guide and help me in learning batch...

i hope you all will guide, help and teach me what i need to know...ty so much
Great that you want to learn batch but you may want to spend more of your time learning Powershell if you are planning on doing a lot of scripting in the future.
7711.

Solve : replace characters in the file name?

Answer» HI!

I created a batch file that loops through a LIST of files in a folder, strips a part of each one and renames it (see example below)

Batch file:
for %%i in (*.pdf) do (set fName=%%i)
REN %fName% %fName:~-10%

Original list:
John Smith_12_123456.pdf
Brian Smith_10_456789.pdf
Joshua Smith_17_765436.pdf
Kate Noname_09_786526.pdf

Output:
123456.pdf
456789.pdf
765436.pdf
786526.pdf

However, if there is a file with brackets in the folder (ex.: John_(Paul)_Smith_12_123456.pdf , the batch file does not work and throws an error message. How can I fix it?

Is there a way to replace brackets for a different character (UNDERSCORE would be ideal)?

Thank you.This should work (untested):

Code: [Select]@echo off
setlocal EnableDelayedExpansion
for /f "delims=" %%i in (' dir *.pdf /b ') do (
set "fName=%%i"
ren "!fName!" "!fName:~-10!"
)
Quote from: foxidrive on September 06, 2012, 11:17:52 PM
This should work (untested):

Code: [Select]@echo off
setlocal EnableDelayedExpansion
for /f "delims=" %%i in (' dir *.pdf /b ') do (
set "fName=%%i"
ren "!fName!" "!fName:~-10!"
)

Thank you so much mate! This script does exactly what I wanted it to do.
7712.

Solve : new hard drive - d drive not recognised in ms-dos?

Answer»

Hi everyone,
I am pretty much a novice at computing and need help with a problem. I have installed a new hard drive and have got the PC up and running, but I cannot connect to the internet. My network card is installed and detected in device manager, which says it is WORKING properly. However, the lights on the rear card plate are not working. I know my router is ok, as I can access the internet from another computer. I have a cd that came with the card and the manual says it can run diagnostics from ms-dos, but when I try to access "D:" in ms-dos I keep getting "Invalid drive specification". I have read that I should be able to insert a driver for the d drive in ms-dos, but I could not fully understand the instructions given. Could some kind person please provide a "dummy's" guide to this procedure, carefully stating every step very clearly from the very beginning.
Many thanks, Peter.Hi again,
I just restarted the PC and there are now 2 static green lights on the network card rear plate! The manual says 1 of them should be blinking when there is activity. I still cannot connect to the internet, so I assume my problem lies with my internet settings?. I have a D-Link DFE-528TX network adapter and a Netgear DG834G router, which is connected with a cable, rather than wirelessly. Any help would be much appreciated, as I don't have much of a clue in this matter. I have looked in TCP/IP Properties and notice that it is set to automatic and the address boxes are empty. Should I enter any addresses/values manually?
Thanks, Peter.You cannot access NTFS formatted drives in MSDOS. That is likely to be the issue.

Is your router set to defaults where the IP address is negotiated by DHCP? Try another cable? Reboot when router is on and the cable is connected.

You can use this to get diagnostic information in file.txt
ipconfig /all >c:\file.txtThis is the info in the ms-dos window following the ipconfig/all command :-

Description .....................: PPP Adapter
Physical Address ..............: **-**-**-**-00-00 (not sure if it is safe/wise to print all of this?)
DHCP Enabled..................: Yes
IP Address........................: 0.0.0.0
Subnet Mask....................: 0.0.0.0
Default Gateway...............:
DHCP Server....................: 255.255.255.255
Primary Wins Server.........:
Secondary Wins Server.....:
Lease Obtained.................:
Lease Expires....................:

Does this help? Quote from: ward58 on August 25, 2012, 03:43:27 AM

the info in the ms-dos window following the ipconfig/all command

That's not "ms-dos".

Are you sure your cd drive letter is D ?



I went to Start...Run...command - and a black window appeared with white writing- I entered ipconfig/all - and the info I posted appeared. Is that not ms-dos?Quote from: ward58 on August 25, 2012, 04:22:15 AM
I went to Start...Run...command - and a black window appeared with white writing- I entered ipconfig/all - and the info I posted appeared. Is that not ms-dos?

No. It is Windows Command Prompt. MS-DOS was a standalone, single user text-only operating system for PCs first released in the 1980s and used until the 1990s when Windows came along. You did not answer the question about your CD drive letter.
The fellows problem is that he can't get connection in Windows.

I'll just repeat my suggestion that the router is not supplying DHCP information or the cable is fubar.

EDIT: It occurs to me that you may not have ethernet card drivers loaded. If not (check device manager) then download the drivers on the good machine and transfer them by USB stick. Or check the cdrom for the drivers. ...Or is that the problem - you don't have access to your CDROM?

Your IPCONFIG information shows that you aren't getting a DHCP configuration from the modem/router
If the modem is normal then Windows seems upset - at the very least you should have an IP address that Windows gives the adapter even when there is no DHCP and you don't even have that.

What version of Windows is this?

This thread will be moved probably.I seem to have inadvertently caused some confusion. The reason I thought I was in ms-dos is that the title bar of the black box says "MS-DOS Prompt". That aside, I have tried another cable without success. Access to the CD-Rom drive is fine (and it is definitely designated as D). I loaded the ethernet card driver from the cd that came with it. Device manager shows the following info for the driver :-

C:\WINDOWS\SYSTEM\NDIS.VXD
- C:\WINDOWS\SYSTEM\vmm32.vxd(ntkern.vxd)
C:\WINDOWS\SYSTEM\DLKRTL.SYS

The OS is Windows 98se. I noticed that sometimes Device Manager did not display the card details on startup/restart, so I physically removed and re-installed the card, and reloaded the driver. On restart, a message displayed along the lines of "the device installed in port 2 shares IRQ with IDE controller. Ensure the device supports IRQ sharing". I assumed this was ok, as the card was in the machine with the old hard drive and worked perfectly well then. I read something about checking the DHCP, but did not understand how to get into it. There was also mention of checking the Registry and possibly changing that, but I know that the combination of ham-fist and ignorance can do much damage, so I left that well alone!
Any thoughts?
P.S. I don't know what "fubar" means ( or should I not ask?!)Quote from: ward58 on August 25, 2012, 08:44:00 AM
I seem to have inadvertently caused some confusion. The reason I thought I was in ms-dos is that the title bar of the black box says "MS-DOS Prompt".

OK you finally told it was Windows 98. This very old operating system did use a version of MS-DOS as its command prompt.

Hi again,
I think I may have solved the problem (more by luck than skill or judgement!). I found an article on the Netgear website that advised altering the TCP/IP settings. This seems to have worked and I have been able to get ONLINE. Hopefully, it won't all go wrong and reverse itself when I shut down and restart.
Thanks to you both for your attempts to help. As you can tell, I am not very computer savvy and tend to "make it up as I go along"!
Cheers, Peter.

Peter, it's good to know that you fixed it yourself. Well done!
Greetings Peter,
FUBAR=Fouled Up Beyond All Recognition. I've heard that some folks
don't use the word 'Fouled' when defining this acronym.

Best wishes!
7713.

Solve : i want to give command in DOS regard to do reading a dat file and copy line 9 c?

Answer»

please help me...not sure how a .dat file is set up, but try this:


Code: [SELECT]for /f "tokens=9 delims=" %%G in (FILENAME.dat) do set line9=%%G

echo %line9%
pause
sample of .dat file is like this :

diana_w6436 Page 1

ANALYSIS type FLOW
Time 3.000E+02
Step nr. 1
Result TEMPER TOTAL

Nodnr PTE
1575 [ 1.551E+01 ] <<<<<---------------- this values []


Analysis type FLOW
Time 6.000E+02
Step nr. 2
Result TEMPER TOTAL

Nodnr PTE
1575 1.413E+01 <<<<<---------------- this values []



now, for me it is important to select the values from .dat file (for instance the first one placed at line 9 and started from CHARACTER 10 to 14)
and copy this values to excel sheet by using DOS command .

please inform me if you need more information
regards



Lemonilla, I think you mean skip=8, not tokens=9, and also if there are more than 9 lines in the file, %line9% will contain the last line, not the 9th. So you need to jump out of the loop to a label as soon as one line is read - the 9th, because we skipped the first 8 lines.

You should test code first and not post guesswork code that came off the top of your head.

Code: [Select]for /f "skip=8 delims=" %%G in (test.txt) do set line9=%%G & goto jump
:jump
echo %line9%
Code modified to give 2nd space delimited token on line 9

Code: [Select]@echo off
for /f "skip=8 tokens=1,2 delims= " %%G in (test.dat) do set value9=%%H & goto jump
:jump
echo %value%
That'll teach me to lecture people... my code has a typo, here is the corrected version:

Code: [Select]@echo off
for /f "skip=8 tokens=1,2 delims= " %%G in (test.dat) do set value=%%H & goto jump
:jump
echo %value%



This seems to be what the OP REQUIRES:

It creates file.csv from file.dat and includes all the lines you require, according to the sample you provided.

Code: [Select]@echo off
for /f "tokens=2" %%a in ('find "+"^< "file.dat"^|find /v /i "time"') do (
set /p "=%%a,"<nul >>file.csv
)

7714.

Solve : DOS with USB driver on CD?

Answer»

I've ALWAYS had problems with BIOS update utilities that require DOS because most comps don't have floppy drives anymore, so I end up having to burn a one-time use CD. I put DOS on the CD along with the BIOS firmware, update the BIOS, then throw away the CD. A better option would be to boot it from USB flash drive, but I often find BIOSs that don't support it. Can ANYONE help me make a preconfigured DOS CD that automatically mounts a flash drive so I can run the utilities? I know I could probably make it work after getting a driver and editing a BILLION times, but I don't want to use that many CDs. Any ideas?You could also use a CD-RW...xboot is a tool available for Windows to create a bootable USB stick.

You can throw a dozen ISO images at it and it will PROVIDE a menu to boot from any of them. Quite neat.


I note that you are CONCERNED about not being able to boot from USB but if your machine handles it then this would be an option.
I would also recommend a CD-RW though...

7715.

Solve : Remove Windows running in background?

Answer»

I want to run an OLD program that requires windows Dos. I was ABLE to install but was informed that windows running in the background must be closed. How do I REMOVE windows and still have the C:\ prompt?Try DLoading and installing DosBox.He closed his account and LEFT his email address for SPAMMERS to harvest...

That should be good...wonder if he tried the suggestion ? ?

7716.

Solve : How to access PORTABLE MEDIA PLAYER with DOS command lines?

Answer»

Hello,
After plug-in a SAMSUNG Galaxy S or Galaxy S2 (by USB cable), I get a simple removable drive. This VOLUME was accessible by MS-DOS command line or .CMD script. So I was able to use my MS-DOS script to backup/restore some files/settings in my smart-phone.

When I plug-in a SAMSUNG Galaxy S3, I get a PORTABLE MEDIA PLAYER. Inside this one there is a volume named "Phone" that I can access with Windows Explorer. But it doesn't look to be accessible by DOS command lines.

So, how to access "Phone" by DOS command lines?

Thanks and regards.

CONFIG: MS Windows7 SP1 Aero disabled


DOS script to check available volumes:
Code: [Select]@ECHO OFF
@SETLOCAL ENABLEDELAYEDEXPANSION
Call:GetVO "Drve"
REM ECHO.Drives [%Drve%]

FOR %%f in (%Drve%) DO (
ECHO.---------------------------- %%~f
DIR /b/on "%%~f:\*.*"
ECHO.
)
GOTO:FinN


:FinN
ENDLOCAL&ECHO.&ECHO.Press To END ......&Pause>Nul&EXIT::________________________


::********************************************************** Get List Of VOLUMES
:GetVO
SET rv=%~1&::ReturnVAR
SET LiS=
FOR /f "SKIP=1 Delims=" %%e in ('WMIC LOGICALDISK GET NAME') DO (
SET DVN=%%~e
IF /i NOT "%%~e"=="" (
IF /i "!LiS!"=="" (SET LiS=!DVN:~,1!) ELSE (SET LiS=!LiS! !DVN:~,1!)
)
)
SET %rv%=!LiS:~,-2!
GOTO:EOF
[year+ old attachment deleted by admin]If you can browse a file system with Windows Explorer, then it has a drive letter. Right click any file in "Phone" and see if you can see the path in the Properties dialog.
When ICS was developed, android was switched from using UMS to MTP. This means it does not mount as a drive letter anymore. Been a lot of DISCUSSION on the web about this already.I think there is (or used to be) and option in windows media player to ALLOW drive letter access. I know for sure iTunes has it with iPods; I might just be confusing it with that THOUGH .I think to be close to the solution. The goal is to mount the device's storage by UMS method (USB mass storage).

http://www.xda-developers.com/android/usb-mass-storage-for-the-international-galaxy-s-iii/
http://forum.xda-developers.com/showthread.php?t=1711009

http://www.xda-developers.com/android/alt-mounter-simulates-usb-mass-storage-back-on-ice-cream-sandwich/
http://forum.xda-developers.com/showthread.php?t=1626713

Thanks guys

7717.

Solve : How to get the free space available in Disk and mount volumes using a command?

Answer»

Hi There,

I am unable to find a solution to get the free space available on the disk drives and mount volumes (in windows server). i am looking for a command or batch file where i can get output like this. Drive F: has several mount points. How do i get an output like this in MB. This a sample in KB

Name Capacity Free space PercentFree
---- -------- --------- -----------
C:\ 146777567232 101463191552 69.13 %
E:\ 68713955328 67994939392 98.95 %
Q:\ 1069253632 1061010432 99.23 %
O:\ 68713955328 21001535488 30.56 %
P:\ 68713955328 68644261888 99.90 %
F:\ 68713955328 68644233216 99.90 %
F:\D01\ 1642818691072 19775197184 1.20 %
F:\RRep\ 68713955328 68644286464 99.90 %
F:\D033\ 549761228800 21194547200 3.86 %
F:\D02\ 1642818691072 36596097024 2.23 %
F:\Bkup\ 1642818691072 1419910320128 86.43 %
F:\D04\ 1095212449792 4592365568 0.42 %
F:\T01\ 1095212449792 815251521536 74.44 %
F:\TDB\ 1095212449792 56733552640 96.49 %

regards
HelenThis should help you: http://stackoverflow.com/questions/2539262/how-to-find-the-percentage-of-free-space-for-mapped-drivesthanks very much Linux711Hi Linux711,

the solution found in the link does not solve the problem.

for /f "usebackq delims== tokens=2" %%X in (`wmic logicaldisk where "DeviceID='C:'" get FreeSpace /format:value`) do set FreeSpace=%%x
for /f "usebackq delims== tokens=2" %%x in (`wmic logicaldisk where "DeviceID='C:'" get Size /format:value`) do set Size=%%x
set FreeMB=%FreeSpace:~0,-6%
set SizeMB=%Size:~0,-6%
set /a Percentage=100 * FreeMB / SizeMB
echo C: is %Percentage% % free

it only gives me the space avaible on a disk and not on mounted volume. Also you got to pass each drive letter as an argument to the file

Any other help please?


thanks

HelenHey All,

I found out the command that helps me to get volume information

wmic Volume get Name, Capacity, FreeSpace

Can someone help me to format it neatly and get the size in GB and get the % free

thanks
HelenDoes WMIC in that command report your mount points too? Is that an issue?

Batch math can only natively handle 2^31 - 1 so you will have to resort to WSH or Powershell for the math.
Batch code does not support floating point arithmetic and numbers are limited to 32 bit PRECISION. An alternate solution would be VBScript.

Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk where drivetype <> 5")

WScript.Echo "Name Capacity Free Free %"
For each objDisk in colDisks
percentfree = (objdisk.Freespace / objdisk.Size) * 100
With objDisk
WScript.Echo .DeviceId & " " & pad(FormatNumber(.Size/1073741824, 2)) & " " & pad(FormatNumber(.Freespace/1073741824, 2)) & " " & FormatNumber(percentfree, 2)
End With

Next

function pad(strText)
strText = Space(10) + strText
strText = Right(strText, 8)
pad = strText
end function

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

If you have access to Powershell, that would also be a good alternate solution.
Hey foxidrive & sidewinder,
Check out Judago's website for a work around on the batch math limitations.
Judago.webs.comThanks Squashman. What a monster that batch file is! Quote from: Squashman on August 30, 2012, 07:56:21 PM

Hey foxidrive & sidewinder,
Check out Judago's website for a work around on the batch math limitations.
Judago.webs.com

Impressive piece of work. This work around now tops Letterman's Top Ten Reasons To Switch To Powershell. This version has TRIVIAL changes but it handles drive arrays up to 99 TB.

Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk where drivetype <> 5")

WScript.Echo "Name Capacity Free Free %"
For each objDisk in colDisks
percentfree = (objdisk.Freespace / objdisk.Size) * 100
With objDisk
WScript.Echo .DeviceId & " " & pad(FormatNumber(.Size/1073741824, 2)) & " " & pad(FormatNumber(.Freespace/1073741824, 2)) & " " & FormatNumber(percentfree, 2)
End With

Next

function pad(strText)
strText = Space(10) + strText
strText = Right(strText, 9)
pad = strText
end functionthanks All for the answers.

With wmic Volume i can get free space available on mount point's as well. But the issue now is ITERATING through a list of servers across my company's servers from my laptop.

I am trying to combine DOS command and SQL to achieve the result. That eliminates issues with DOS command

thanks
Helen
7718.

Solve : Open then close new sites with time intervals??

Answer»

I want to have a CODE where it Opens a message box you SELECT yes or no then after selecting yes
It opens a new webpage, waits 10 seconds, closes it,
repeat
then at end have a message box saying finished?

I kinda got started but can someone help me




x=msgbox ("BLAH CLICK YES", 4,"blah")
if x=6 then
msgbox "d", 0,"Ve"
Const newTab = &H800
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate "http://www.google.com/1"
objIE.Visible = True
WScript.Sleep 6
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate "http://www.newopen.com"
objIE.Visible = True
WScript.Sleep 6
objIE.Navigate2 "http://www.miniclip.com/games/kung-fu-statesmen/en/", newTab
objIE.Visible = False
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate "http://www.endpage.com"
objIE.Visible = True
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("C:\test.bat"), 0, True
elseif x=7 then
msgbox "Exit ?", 0,"Are you sure?"
end ifHaven't found a way to MAKE a pop-up prompt other than 'start akfh.bat' which you can do, but things get messy quickly. I'll post both methods.

Code: [Select]@echo off
start
cls
echo THIS IS WHERE YOU DISPLAY YOUR QUESTION
choice
if %errorlevel% EQU 1 goto open
if %errorlevel% EQU 2 goto wait

:open
start www.YOURWEBSITE.com
timeout /t 10 /nobreak >nul
REM if you do not have windows 7 you will have to replace the above line with
REM "ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127"
taskkill YOURDEFAULTINTERNETBROWSER.exe
goto end

:wait
timeout /t 10 /nobreak >nul
REM if you do not have windows 7 you will have to replace the above line with
REM "ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127 & ping 1.0.0.127"

:end
echo Finished?
choice
if %errorlevel% EQU 1 goto start
exit


Try this out. If you want a prompt that will pop-up try making a seperate file for :open and have a 'start YOURFILE.bat'


What you started looks to me like java, but I could be wrong.[/code]HEY thanks alot man i really appreciate it

7719.

Solve : Command to create an empty txt file?

Answer»

I would like to know the command line to create an empty txt file : "Nuevo Notepad++ document.txt"

Best Regards
This works:

Code: [Select]type nul &GT; "Nuevo Notepad++ document.txt"

Zero bytes with zero effort. Thanks

I'll try. I want this little to script to modify the contextual windows menu in windows explorer windows.

I will comment.... And perhaps I will need open other post to know how can i modify the contextual menu....

Best Regards
What does creating an empty file have to do with the context menusQuote from: Squashman on June 23, 2012, 01:57:14 PM

What does creating an empty file have to do with the context menus

I am trying to create a new entry in the main contextual menu. The entry exist previosly in the secondary "new" contextual menu.
Under windows xp pro + sp3 , spanish version.

The sreenshots :





I would like a .REG to add the new entry in the contextual menu.
I need to vary the windows registry

Best Regards

And I don't know how

There is already a context menu for creating a new text file. Why do you need another?Quote from: Squashman on June 24, 2012, 08:20:17 PM
There is already a context menu for creating a new text file. Why do you need another?

I need in the main contextual menu. The left menu.....

Speed
Get Context Menu Editor...still Free i believe.
7720.

Solve : help curing run-time error 200?

Answer»

Hi all,
I have a DOS (radio decoder) program which is installable from the floppy disk. I'm using a reasonably modern 1.8 Ghz PC running MS-DOS 6.22(dual booting with Winxp) The installation command returns a "run-time error 200" I believe this is caused by program files compiled under Turbo Pascal which do not like the fast processor, also that a PATCH called tppatch.zip could solve/bypass the problem. Can anyone help me with a practical (step by step) guide to ACHIEVING this. Also I have to unpack the files (on my program floppy) before PATCHING can be done.
I have downloaded tppatch.zip and a recommended unpacker ucfcup34.zip.
I am fairly happy with most DOS commands - though a bit rusty.
Can anyone help me?
Regards,
Peter1066
If you have the source code , rewrite with C and compile with a c complier.Catch-22. The unpacker program is in zip format?

Couple of possibilities:

1. The ucfcup34.zip file MIGHT be in self-extracting format, in which case double clicking the file will extract the executable so you can unzip tppatch.zip.

2. This link might be helpful.

Do all the unzipping from XP before applying the patch in DOS.

Good luck. Thanks for suggestions. YES I'm ok at using pkunzip in DOS. The program has to be installed from the floppy using the "install" command which unpacks at the same time. So not sure of path for using cup384(to unpack) Then I need to patch some of the files unpacked to use the tppatch program on. All taking place on the floppy?
regards,
Peter1066

7721.

Solve : Help with rearranging digits?

Answer»

I read about a math FORMULA and I'm making a batch file to work through it.
This requires a 4 digit number to be rearranged from highest to lowest, for example: it would change 7263 to 7632.
I would also need it to change it to lowest to highest (7263 to 2367.)

So the code would be:
Code: [Select]@echo off
title Kaprekar's Constant
echo.
echo.
echo Enter a 4 digit number
set /p num1=
set num2=6175
echo.
echo You entered %num1%
cls
set num6=0
echo.
:ent
echo.
echo Rearranging DIGITS...

REM This is where it would rearrange the digits in num1 so they are highest to lowest.
REM num3 would equal the above
REM This is where it would rearrange the digits in num1 so they are lowest to highest.
REM num4 would equal the above

echo %num3%-%num4%
set /a num5=%num3%-%num4%
echo =%num5%
set /a num6=%num6%+1
if %num5%==%num2% goto end
goto ent
:end
echo.
echo.
echo %num1% was transformed into %num2%.
echo It took %num6% STEPS to calculate.
echo.
echo Press any key to exit...
pause>nul
if you are only using 4 digits I would first seporate them into their own string using %num1:~0,1% ; %num~:~1,1% ; %num:~2,1% ; %num1:~3,1%

Then you use the if ___ GTR ____ set num#=__________ a BUNCH to find the correct order.And you really only need to get the numbers sorted high to low or low to high. After that you can just use string parsing like you were just shown by lemon to reverse the number.

I suppose you could create your own bubble sort algorithm but we could also K.I.S.S.
As you are parsing the 4 digit number into individual digits you could echo each individual digit to a temp file. Then in a FOR loop you could use the sort command to read back the file in sorted order and assign it to a new variable.

7722.

Solve : Shutdown remote computer if uptime is over a period of time?

Answer»

I need to SHUTDOWN workstations with windows 7 operating system if uptime is over a some period of time. I got uptime remotely with: Code: [Select]systeminfo /s "somecomputer" | find "System Boot Time:". Shutdown computer with: Code: [Select]shutdown /m \\"somecomputer" /s. Idea is to make a batch FILE that will compare the CURRENT time and uptime, calculated the difference and if the difference is more than some time period, turn off workstation. Batch file will be executed from Task Scheduler.
Any help will be appreciatedDunno if this can help you at all. There's a routine to calculate time difference though.

Maybe WMIC can be run on a remote machine, or use PSEXEC to run the WMIC command.

Code: [Select]@echo off
for /f "delims=" %%a in ('wmic OS Get LastBootUpTime ^| find "."') do set up=%%a
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a

set beg=%up:~0,4%-%up:~4,2%-%up:~6,2%T%up:~8,2%-%up:~10,2%-%up:~12,2%-%up:~15,3%
set end=%dt:~0,4%-%dt:~4,2%-%dt:~6,2%T%dt:~8,2%-%dt:~10,2%-%dt:~12,2%-%dt:~15,3%


call :TimeDifference uptime %end% %beg%

echo %beg%
echo %end%
echo Uptime is: %uptime%


pause
goto :eof

:TimeDifference Return_Variable Start_Date_Time Stop_Date_Time
:: Version -0 2009-12-25 Frank P. Westlake
:: Calculate the difference in time between parameter 2 and parameter 3
:: and return the values in the variable named by parameter 1.
::
:: Parameters 2 and 3 are ISO8601 DATE/TIMEs of the format
::
:: YYYY-MM-DDThh-mm-ss
::
:: where '-' may be any of '/:-., '.
::
:: RETURN:
:: The variable named by %1 will be set with a string containing each of
:: the following values seperated by spaces:
::
:: DAYS HOURS MINUTES SECONDS MILLISECONDS
::
:: EXAMPLE: Call :TimeDifference diff "2009-12-01T 1:00:00.00" "2009-11-30T13:00:00.01"
:: Sets variable "DIFF=0 12 0 0 10"
SetLocal EnableExtensions EnableDelayedExpansion
For /F "tokens=1-14 delims=T/:-., " %%a in ("%~2 %~3") Do (
Set "h2=0%%d" & Set "h3=0%%k" & Set "n2=%%g00" & Set "n3=%%n00"
Set /A "y2=%%a, m2=1%%b-100, d2=1%%c-100, h2=1!h2:~-2!-100, i2=1%%e-100, s2=1%%f-100, n2=1!n2:~0,3!-1000"
Set /A "y3=%%h, m3=1%%i-100, d3=1%%j-100, h3=1!h3:~-2!-100, i3=1%%l-100, s3=1%%m-100, n3=1!n3:~0,3!-1000"
)
Set /A "t2=((h2*60+i2)*60+s2)*1000+n2, t3=((h3*60+i3)*60+s3)*1000+n3"
Set /A "a=(14-m2)/12, b=y2-a, j2=(153*(12*a+m2-3)+2)/5+d2+365*b+b/4-b/100+b/400"
Set /A "a=(14-m3)/12, b=y3-a, j3=(153*(12*a+m3-3)+2)/5+d3+365*b+b/4-b/100+b/400"
Set /A "d=j3-j2, t=t3-t2"
If %d% LEQ 0 (If %d% LSS 0 (Set /A "d=j2-j3, t=t2-t3") Else If %t% LSS 0 (Set /A "t=t2-t3"))
If %t% LSS 0 (Set /A "t+=(1000*60*60*24), d-=1")
Set /A "n=t %% 1000, t/=1000, s=t %% 60, t/=60, m=t %% 60, t/=60"
EndLocal & Set "%~1=%d% %t% %m% %s% %n%"
Goto :EOF
:: END SCRIPT ::::::::::::::::::::::::::::::::::::::::
What were you planning on using this for? I can't see much of a practical use other than if someone forgets to turn off the station, but then you'd want to turn them off at a set time (Closing+2h or something).I am an ADMINISTRATOR in the 24-hour active organization, whole year and most computers got same business hours. I wish I had a tool on network that will be started eg. between Saturday and Sunday, when the job INTENSITY is the lowest and restart only computers that need it (usually employed care and reboot them periodically) . Restart for all computers is not acceptable Quote from: foxidrive on September 01, 2012, 08:51:37 AM

Dunno if this can help you at all. There's a routine to calculate time difference though.

Maybe WMIC can be run on a remote machine, or use PSEXEC to run the WMIC command.



Working like charm on local machine. With some customisations shutdown local machine after 7 days look like:

Code: [Select]@echo off
for /f "delims=" %%a in ('wmic OS Get LastBootUpTime ^| find "."') do set up=%%a
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a

set beg=%up:~0,4%-%up:~4,2%-%up:~6,2%T%up:~8,2%-%up:~10,2%-%up:~12,2%-%up:~15,3%
set end=%dt:~0,4%-%dt:~4,2%-%dt:~6,2%T%dt:~8,2%-%dt:~10,2%-%dt:~12,2%-%dt:~15,3%


call :TimeDifference uptime %end% %beg%

if %uptime% gtr 7 shutdown /s /f
goto :eof

:TimeDifference Return_Variable Start_Date_Time Stop_Date_Time
:: Version -0 2009-12-25 Frank P. Westlake
:: Calculate the difference in time between parameter 2 and parameter 3
:: and return the values in the variable named by parameter 1.
::
:: Parameters 2 and 3 are ISO8601 DATE/TIMEs of the format
::
:: YYYY-MM-DDThh-mm-ss
::
:: where '-' may be any of '/:-., '.
::
:: RETURN:
:: The variable named by %1 will be set with a string containing each of
:: the following values seperated by spaces:
::
:: DAYS HOURS MINUTES SECONDS MILLISECONDS
::
:: EXAMPLE: Call :TimeDifference diff "2009-12-01T 1:00:00.00" "2009-11-30T13:00:00.01"
:: Sets variable "DIFF=0 12 0 0 10"
SetLocal EnableExtensions EnableDelayedExpansion
For /F "tokens=1-14 delims=T/:-., " %%a in ("%~2 %~3") Do (
Set "h2=0%%d" & Set "h3=0%%k" & Set "n2=%%g00" & Set "n3=%%n00"
Set /A "y2=%%a, m2=1%%b-100, d2=1%%c-100, h2=1!h2:~-2!-100, i2=1%%e-100, s2=1%%f-100, n2=1!n2:~0,3!-1000"
Set /A "y3=%%h, m3=1%%i-100, d3=1%%j-100, h3=1!h3:~-2!-100, i3=1%%l-100, s3=1%%m-100, n3=1!n3:~0,3!-1000"
)
Set /A "t2=((h2*60+i2)*60+s2)*1000+n2, t3=((h3*60+i3)*60+s3)*1000+n3"
Set /A "a=(14-m2)/12, b=y2-a, j2=(153*(12*a+m2-3)+2)/5+d2+365*b+b/4-b/100+b/400"
Set /A "a=(14-m3)/12, b=y3-a, j3=(153*(12*a+m3-3)+2)/5+d3+365*b+b/4-b/100+b/400"
Set /A "d=j3-j2, t=t3-t2"
If %d% LEQ 0 (If %d% LSS 0 (Set /A "d=j2-j3, t=t2-t3") Else If %t% LSS 0 (Set /A "t=t2-t3"))
If %t% LSS 0 (Set /A "t+=(1000*60*60*24), d-=1")
Set /A "n=t %% 1000, t/=1000, s=t %% 60, t/=60, m=t %% 60, t/=60"
EndLocal & Set "%~1=%d% "
Goto :EOF
:: END SCRIPT ::::::::::::::::::::::::::::::::::::::::Batch file need to run like administrator. I'm not tested this on network, but i think only difference is in:
Code: [Select]for /f "delims=" %%a in ('wmic/ Node:"computername" OS Get LastBootUpTime ^| find "."') do set up=%%a
for /f "delims=" %%a in ('wmic/ Node:"computername" OS Get localdatetime ^| find "."') do set dt=%%a
and
Code: [Select]if %uptime% gtr 5 shutdown /m \\computername /r /f
Thanks, it's very useful
7723.

Solve : Update all drivers on a computer?

Answer»

Is there a way to write a batch file or something that will forcefully search for to update all drivers on the system instead of opening device manager and going one by one? I't doesn't necessarily have to be batch as long as it works.

win7
Try this:

http://www.driverrobot.com

Not a DOS command, but a tool that does the trick.I'd use some caution around drive controller driver replacements. I got bit by this being updated once and breaking our RAID 5, then having to rebuild the array after it broke. BIG MESS! For an average home user its probably no problem, but for corporate use, be careful!

Generally I dont replace drivers unless they are an ISSUE or there is a benefit to updating them. Newer drivers are SUPPOSE to be better than older drivers for many reasons, but they can also create headaches.

The only drivers I update on a regular basis are video card drivers, other than that if all other features work reliably I dont mess with them.+1

If your instant driver update causes problems, you will not know which driver update caused it too.These are very good POINTS. I actually had to just do a system restore to dump some new drivers that were causing issues >.> Thanks.Not SURE what the logic is anyways on having a batch file do this...

7724.

Solve : help needed for using net time and xcopy command?

Answer»

Hi there, please help

I am using win 7 and i need to synchronize my PC to the server (Win server 2008). Central-01 is my server name
first is to syn the time from server. I am using a command net time. below is the command
net time \\central -01 /set /y . the respond i am getting is
Current time at \\central-01 is 8/31/2012 12:53:25 PM

System error 1314 has occurred.

A required PRIVILEGE is not held by the client.

why is that ??

2nd i want to syn my folder, subfolders and files. I use xcopy command
xcopy \\central-01\RPT d:\RPT\ /A /D /Y /R /I /S
the respond i am getting is
Invalid drive SPECIFICATION
0 File(s) copied


please help net time probably requires admin permissions.


Try this for the xcopy, ASSUMING the server and SHARE names are right and you have access.

xcopy "\\central-01\RPT\*.*" "d:\RPT\" /A /D /Y /R /I /SHi foxidrive, THANKS for your reply

On that case my user account is an administrator but it still couldn't let me change the time using net time command

For my other question about xcopy command, if ii use long folder name I.e folder name is Update Program
Is this right?
xcopy "\\Centeral-01\Update Program" "c:\Program Files\Integrity\*.*" /A /D /Y /R /I /S
Or
xcopy \\Centeral-01\Update~1 c:\Progra~1\Integr~1\*.* /A /D /Y /R /I /S

Thank u?Is the computer joined to the domain?No, I only use workgroup.

I tried
xcopy "\\Centeral-01\Update Program" "c:\Program Files\Integrity\*.*" /A /D /Y /R /I /S
Or
xcopy \\Centeral-01\Update~1 c:\Progra~1\Integr~1\*.* /A /D /Y /R /I /S

I save the command as a batch file and put it on the startup in windows so every times the OS start up it is also running. It doesn't work at all then I found out that
Both the commands work when I run the the command as the administrator (right klik option) instead the regular run option (double klik or startup).

7725.

Solve : Processes running under Windows Task Manager??

Answer»

[glb][/glb] how does the DOS command looks like if I were to detect if a particular process is currently RUNNING as shown by the Task Manager?
for eg., if I launch the calculator and SAW calc.exe process running as shown by the Task Manager, but when I run a simple DOS batch file with something like :

if exist calc.exe (
echo Running
)

but it doesn't work...which DOS command should I use then? or, what path should I specify for calc.exe or etc processes seen in the Task Manager??

Any helpful advise? IT IS EASY. IN MS-DOS (COMMAND PROMPT) THERE IS TASK MANAGER COMMAND TASKLIST.
YOU JUST TYPE TASKLIST TO SEE LIST OF RUNNING PROGRAMS.

IF YOU WANT YOUR BATCH FILE TO DETECT IS CALC.EXE RUNNING TRY TYPING THIS. MAYBE WILL HELP.
:START
REM: ADD THIS LINE TO DISABLE SHOWING SOURCE CODE WHILE RUNNING.
@ECHO OFF
REM: ADD THIS LINE TO CREATE LIST OF RUNNING PROGRAMS AND FIND WHAT YOU WANT.
REM: NOTE THAT YOU CAN REPLACE CALC.EXE WITH ANY OTHER PROGRAM TO CHECK IS THAT PROGRAM RUNNING.
REM: ADD REDIRECTION TO FILE TO AVOID DISPLAYING FILE SPECIFICATIONS.
TASKLIST | FIND /I "CALC.EXE" 1>TEMP.DAT
REM: ADD THIS LINE TO PERFORM CHECK OF EXIT CODE FOR FIND.EXE PROGRAM.
IF %ERRORLEVEL% EQU 0 (
REM: ADD THIS LINE TO DISPLAY CHECK RESULT.
ECHO: CALCULATOR IS RUNNING.) ELSE ECHO: CALCULATOR IS NOT RUNNING.
REM: ADD THIS LINE TO DELETE TEMPORARY DATA USED.
DEL %CD%\TEMP.DAT
REM: ADD THIS LINE TO PREVENT ENDING BATCH FILE BEFORE YOU READ THE RESULT AND PRESS ENTER.
SET /P WAITING_FOR_USER_TO_PRESS_ANY_KEY...=
:END

THIS IS THE WAY. I HOPE I WAS USEFUL.
IN YOUR BATCH FILE YOU HAVE SEARCHED IS CALC.EXE FILE PRESENT IN THE CURRENT DIRECTORY, NOT ITS PROCESS.

IF YOU WANT TO KNOW MORE, CALC.EXE IS LOCATED IN SYSTEM32 DIRECTORY OF WINDOWS ROOT FOLDER.

YBYHe hasn't been back for 7 Years,,,Quote from: patio on June 22, 2012, 09:53:57 PM

He hasn't been back for 7 Years,,,

Patio, I don't like the look of this...

Further Posts under Moderation...
7726.

Solve : autorun boot cd - urgent help please!!?

Answer»

Hi, I am trying to update my BIOS version from A05 to A07 on my Dell Diemnsion 8300. I have followed the instructions to create a bootable cd From the following Link:

http://www.bay-wolf.com/bootcd-bios.htm

I run the cd and boots into it on the screen. As per the instructions i am told to switch to the drive Z but i am stuck as to how to do this.

My screen SHOWS the following:

A:\MSCDEX.EXE /D:mscd001 /L:Z

then

A:\>PROMPT $p$g
A:\>PATH A:\
A:\

how do i switch to the letter Z?

my PC wont recognise my hard disk so im trying to update the BIOS and eliminate all possibilities. I have even created my own autorun.inf file and burned it to a bootable CD sing Nero but it wont run on my PC, just hangs and asks me to strike F1 to continue or F2 to enter setup. when i select F1 nothing happens.

I have been working on this for ages and have not got anywhere, I really would appreciate someones help as i need to get this working asap.

thanks.Try CD /d YOUR-DRIVE-HEREQuote from: Helpmeh on December 04, 2009, 04:56:05 AM

Try CD /d YOUR-DRIVE-HERE

Don't know if that cd /d thing will work in MS-DOS. I rather think not. The standard MS-DOS way to change drives is to type the letter followed by a colon thus:

Z:

... and then use cd (no switches) to get to the actual DIRECTORY.

This is one of those boot CDs that use a floppy image, so that when you burn the CD you create 2 parts - one which gets booted as a "fake floppy" with MSCDEX etc for CD support, this has the A: drive letter, and also another part which is the actual CD, which appears at the drive letter shown in the message, so in this case the OP has to switch from the A: prompt to the Z: prompt. By typing Z:

as salmon said, use

Z:

followed by the enter Quote from: Bukhari1986 on December 05, 2009, 08:10:08 AM
as salmon said

Was that post really necessary?


Who's feeding the Parrots again ? ?Quote from: PATIO on December 05, 2009, 09:04:09 AM
Who's feeding the Parrots again ? ?
I thought it was just me. "Yeah, do what he said" posts drive me up a wall.Quote from: Allan on December 05, 2009, 09:06:22 AM
I thought it was just me. "Yeah, do what he said" posts drive me up a wall.

They are a WASTE of bandwidth. Not to say that a post not just agreeing with a previous poster, but adding information or relevant experience, is a bad thing at all.

Quote from: Salmon Trout on December 05, 2009, 09:08:39 AM
They are a waste of bandwidth. Not to say that a post not just agreeing with a previous poster, but adding information or relevant experience, is a bad thing at all.



I agree.


i was making that post for the purpose to tell him to

press enter after typing Z:

ONLY

If I spent some more time, I will get familiar with the seniors over here. and will stay here in that style which please my seniors

or if i can't do that, I will take no time to leave the forum.

But I think all over here are soooo much friendly.

at least I think so.
Quote from: Allan on December 05, 2009, 09:06:22 AM
I thought it was just me. "Yeah, do what he said" posts drive me up a wall.
they're basically saying:
TL;dr Insert-crappy-version-of-information-already-posted-here

(tl;dr means too long; didn't read)
7727.

Solve : batch program expire?

Answer» HELLO everone!

I need HELP to develop a routine bat. I have a program that accesses FTP with many functions and have to send it to other friends. I WISH he ran for four days and then stop working. I looked over 20 pages of the forum and no found something SIMILAR. The problem is I have no way of knowing if the date format is mmddyyyy or ddmmyyyy or yyyymmdd or language the OS the other computer.

Any ideas?

Thanks for the help.
Luis
7728.

Solve : DOS reverse redirection?

Answer»

all,

I need some help on how to write a command to the DOS window using the reverse redirection symbol ( < ).

I have searched the internet for hours on trying to get some information on how to do this, but the only i've found is how to redirect OUTPUT to a text file. I need the opposite. I want to redirect the contents of a text file to the command line so I can execute it. Any ideas? Thanks!It is not clear what you want. The revers direction is for input. A text file does not ask for input. A program asks for input
It is used all the time. It is for programs where you do not want interaction, instead the commands come from some kind of text file.

Do you need some very simple examples?
I can only so simple examples. I have a bird brain.
This will take the first line of file x.txt and store it as a variable named y.

Set /p y=
Then after that, you can manipulate it as much as you want. Geek,

Here is a better explanation:


for example, I have a text file on the c drive that has this path: c:\reDir.txtIn that file I have one line of text: dirI want to execute that command in a DOS command prompt using the redirection. The end result should be just like it were if I typed 'D I R' into the prompt myself and hit enter. Does that make sense?Quote from: ajetrumpet on December 06, 2009, 01:12:37 PM

Geek,

Here is a better explanation:


for example, I have a text file on the c drive that has this path: c:\reDir.txtIn that file I have one line of text: dirI want to execute that command in a DOS command prompt using the redirection. The end result should be just like it were if I typed 'D I R' into the prompt myself and hit enter. Does that make sense?
is that in real time? can I do that from the prompt by typing it in?that can be does as a batch file. Go to start > run (or window key + r) and type in notepad (or open notepad any other way ). For your example enter this code:
Code: [Select]dir

Save it at the location you want using the .bat extension (I believe you need to have extension visible to do this successfully). Double clicking on the batch file will execute the commands there are in the file. If you want to do it for the command prompt, just write the name of the batch file.

Hope this helped

Two-Eyes %

EDIT:
Quote
can I do that from the prompt by typing it in?
Yes you can.i can type this in:Code: [Select]type finished.txtand what that does it PRINT the contents of the txt in the DOS window, but how do I get it to EXECUTE that content as a command?RENAME it to a .bat or .cmd file and then simply use:

Code: [Select]finished.bat
all,

i have gotten it down, but I think the problem is still present. I have this code for shelling an ftp text file:Code: [Select]Dim fso
Dim oFile
'Dim varitem As Variant
Dim CurDir As String
Dim CurRemoteDir As String
Dim vPath As String
Dim vFile As String
Dim vFTPServ As String
Dim fNum As Long

Screen.MousePointer = 11

Set fso = CreateObject("Scripting.FileSystemObject")
Set oFile = fso.createtextfile("c:\inProgress.txt", True)
oFile.writeline "contents"
oFile.Close

vPath = "C:"
vFTPServ = Me.Combo1
CurDir = Me.Text26
CurRemoteDir = Me.Text1
vFile = Me.List27
fNum = FreeFile()

Open vPath & "\FtpComm.txt" For Output As #fNum
Print #1, "USER " & sFtpUserName ' your login
Print #1, sFtpPassword ' your password
'Print #1, "dir > c:\inProgress.txt"

If sFtpHostName <> Me.Combo1 Then
Print #1, "cd " & Left( _
Right(CurRemoteDir, Len(CurRemoteDir) - InStr(CurRemoteDir, "/")), _
(Len(CurRemoteDir) - 1))
End If

Print #1, "put " & """" & CurDir & vFile & """"
'Print #1, "!"
'Print #1, "del c:\inProgress.txt"
'Print #1, "exit"
Print #1, "close" ' close connection
Print #1, "quit" ' Quit ftp program
Close

Shell "ftp -n -i -g -s:" & vPath & "\FtpComm.txt " & vFTPServ, vbMaximizedFocus
what I am trying to accomplish is to get an indication of when the ftp session is over and the DOS window has been closed, thus telling me that all of the commands have been executed.

This is in VBA, so maybe a different forum would be the best now?
C:\batch>type reverse.bat

Quote
@echo off

REM Put 500 in money.txt file

if not exist money.txt echo 500 > money.txt

Rem Put 500 in money variable

set /p money=< money.txt

echo Money = %money%

Output:

C:\batch> reverse.bat
Money = 500

C:\batch>Quote from: ajetrumpet on December 06, 2009, 01:49:41 PM

This is in VBA, so maybe a different forum would be the best now?

well, no reason to move it, I don't think.

I encountered this problem some time ago, and already have something that should help.

I made this module, "modexec" quite recently:

Code: [Select]Option Explicit

Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type

Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type

Private Type STARTUPINFO
cb As Long
lpReserved As Long
lpDesktop As Long
lpTitle As Long
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwflags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type

Private Type OVERLAPPED
internal As Long
internalHigh As Long
offset As Long
OffsetHigh As Long
hEvent As Long
End Type

Private Const STARTF_USESHOWWINDOW = &H1
Private Const STARTF_USESTDHANDLES = &H100
Private Const SW_HIDE = 0
Private Const SW_SHOWDEFAULT As Long = 10

Private Const EM_SETSEL = &HB1
Private Const EM_REPLACESEL = &HC2
Public Declare Function CreatePipe Lib "kernel32" (phReadPipe As Long, phWritePipe As Long, _
lpPipeAttributes As SECURITY_ATTRIBUTES, ByVal nSize As Long) As Long
Private Declare Sub GetStartupInfo Lib "kernel32" Alias "GetStartupInfoA" (lpStartupInfo As STARTUPINFO)
Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, _
ByVal lpCommandLine As String, lpProcessAttributes As Any, lpThreadAttributes As Any, _
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, _
ByVal lpCurrentDriectory As String, lpStartupInfo As _
STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As _
String) As Long
Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As _
Long, lpNumberOfBytesRead As Long, lpOverlapped As Any) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal _
wParam As Long, lParam As Any) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetThreadDesktop Lib "User32.dll" (ByVal dwThread As Long) As Long
Private Declare Function WriteFile Lib "kernel32.dll" (ByVal hFile As Long, ByRef lpBuffer As Any, _
ByVal nNumberOfBytesToWrite As Long, ByRef lpNumberOfBytesWritten As Long, ByRef lpOverlapped As Any) As Long

Private Declare Function WaitForSingleObject Lib "kernel32.dll" (ByVal hHandle As Long, ByVal _
dwMilliseconds As Long) As Long
Private Const WAIT_TIMEOUT As Long = 258&



Public Function Redirect(CMDLINE As String) As String
Dim i%, t$
Dim pa As SECURITY_ATTRIBUTES
Dim pra As SECURITY_ATTRIBUTES
Dim tra As SECURITY_ATTRIBUTES
Dim pi As PROCESS_INFORMATION
Dim sui As STARTUPINFO
Dim hRead As Long
Dim hWrite As Long
Dim bRead As Long
Dim hstdInPipeWrite As Long, hStdInPipeRead As Long
Dim lpBuffer As String, wholestr As String
pa.nLength = Len(pa)
pa.lpSecurityDescriptor = 0
pa.bInheritHandle = True

pra.nLength = Len(pra)
tra.nLength = Len(tra)
CreatePipe hStdInPipeRead, hstdInPipeWrite, pa, 0
WriteFile hstdInPipeWrite, ByVal Chr$(0), 1, 0, ByVal 0
If CreatePipe(hRead, hWrite, pa, 0) <> 0 Then
sui.cb = Len(sui)
GetStartupInfo sui
sui.hStdInput = hStdInPipeRead
sui.hStdOutput = hWrite
sui.hStdError = hWrite
sui.dwflags = STARTF_USESHOWWINDOW Or STARTF_USESTDHANDLES
sui.wShowWindow = SW_HIDE
If CreateProcess(vbNullString, cmdLine, pra, tra, 1, 0, ByVal 0&, vbNullString, sui, pi) <> 0 Then
'SetWindowText objTarget.hwnd, ""
'If Not GetThreadDesktop(pi.hThread) = 0 Then
'insert waitforsingleobject loop here...
Dim rtret As Long
Do
rtret = WaitForSingleObject(pi.hProcess, 100)
If rtret <> WAIT_TIMEOUT Then
Exit Do
End If
DoEvents

Loop
Do
lpBuffer = Space(1024)
If ReadFile(hRead, ByVal lpBuffer, 1023, bRead, ByVal 0&) Then
' SendMessage objTarget.hwnd, EM_SETSEL, -1, 0
' SendMessage objTarget.hwnd, EM_REPLACESEL, False, lpBuffer(0)
wholestr = wholestr & Replace$(Trim$(lpBuffer), vbNullChar, "")
If bRead < 1023 Then
Exit Do
End If
DoEvents
Else
Exit Do
End If

Loop
' Else
' wholestr = "ERROR executing """ & cmdLine & """."
' End If
CloseHandle hWrite
CloseHandle hRead
CloseHandle hStdInPipeRead
CloseHandle hstdInPipeWrite
End If
End If
Redirect = wholestr
End Function

Public Sub ExecWait(cmdLine As String, Optional ByVal WindowShowMode As Long = 10)
Dim i%, t$
Dim pa As SECURITY_ATTRIBUTES
Dim pra As SECURITY_ATTRIBUTES
Dim tra As SECURITY_ATTRIBUTES
Dim pi As PROCESS_INFORMATION
Dim sui As STARTUPINFO
Dim hRead As Long
Dim hWrite As Long
Dim bRead As Long

Dim lpBuffer As String, wholestr As String



sui.cb = Len(sui)
GetStartupInfo sui
sui.dwflags = STARTF_USESHOWWINDOW Or STARTF_USESTDHANDLES
sui.wShowWindow = WindowShowMode
If CreateProcess(vbNullString, cmdLine, pra, tra, 1, 0, ByVal 0&, vbNullString, sui, pi) <> 0 Then
'SetWindowText objTarget.hwnd, ""
'If Not GetThreadDesktop(pi.hThread) = 0 Then
'insert waitforsingleobject loop here...
Dim rtret As Long
Do
rtret = WaitForSingleObject(pi.hProcess, 100)
If rtret <> WAIT_TIMEOUT Then
Exit Do
End If
DoEvents

Loop

End If

End Sub




you should be able to paste it into a new module in your VBA project, and then use the "execwait" function. For example:

Code: [Select]Execwait "notepad C:\newfile.txt",10

the second argument is the "show" mode; you can find these in the MSDN library, things like SW_HIDE, SW_SHOWDEFAULT (which I used here) SW_MAXIMIZED, etc.

the "exec" function is kind of buggy; the original purpose was to redirect all output from the command line program to a pipe and then read that pipe into a string variable... it doesn't seem to work really, I have to terminate the program manually before it works. Oh well. (Execwait seems to work fine, that's the function you need for this purpose).

EDIT: added line continuation characters.BC,

that worked a treat. thank you so much. what a job you did on that module. that's incredible. =)Quote from: ajetrumpet on December 06, 2009, 04:19:55 PM
BC,

that worked a treat. thank you so much. what a job you did on that module. that's incredible. =)

your very welcome, always nice to share some of my code. Sometimes I'll read about something, waiting for a process to finish, sorting algorithms, etc- and just feel compelled to write a module, class module, or a group of modules/class modules to do the job; however far I get working on it, it stays in my module folders, in case I need the functionality in a program later
7729.

Solve : ibm m52 bios?

Answer»

under what FIELD in the BIOS do i change from sata to compatiability modeMine's under Advanced...but if it's an older BIOS you MAY not have the option PRESENT...USER guide

http://download.lenovo.com/ibmdl/pub/pc/pccbbs/thinkcentre_pdf/39j8154.pdf

7730.

Solve : Changing date format?

Answer»

I just started working Batch scripts and I need help with a batch script that shows the OUTPUT of date As: day of the week , day and MONTH

so the output today would be:
Tuesday 8 DECEMBER

I KNOW it uses FOR and CALL but I am lost and I have the two text FILES for months and days of the week all ready

anyhelp?Welcome to the CH forums.

Wahine has posted a solution here

Good luck.

7731.

Solve : Change res batch file?

Answer»

Hey guyz, im trying to change the screen resolution through a batch file,

is there an internal rundll32 command to do this, so far i can get to the page where it needs to be changed but it wont change settings

RUNDLL32.EXE SHELL32.DLL,Control_RunDLL desk.cpl,,3

will open RES page, is there an extra command needed to be put elsewhere?To change the screen resolution in batch is not possible, you will need either a third-party EXECUTABLE (QRes is ONE such that works) - or a 'debug script' that you can RUN using the buit-in debug.exe programhttp://www.entechtaiwan.com/util/multires.shtm

basic SYNTAX is

Code: [Select]multires /width,height,bitdepth
Thanks guyz, now i just need to get an approval for my company to get the licensing i doubt it though, because its not everyday we change monitors

7732.

Solve : [glow=red,2,300]how to make a exe with ms-dos/cmd?[/glow]?

Answer»

Quote from: BatchFileBasics on November 23, 2009, 11:00:32 AM

takes 4 floppys

Does any one make these any more??Quote from: mroilfield on November 25, 2009, 04:34:02 AM
Does any one make these any more??

Of course they do.
thank you salmon trout salmon trout how to draw some spites in quickbasic?Quote from: pds on November 26, 2009, 04:16:56 AM
salmon trout how to draw some spites in quickbasic?

http://www.tedfelix.com/qbasic/sprites.htmlthanks againi've made a game please is the syntax right?
Code: [Select]REM ***Guess The Number***
CLS
PRINT "What is your name"<INPUT nm$
110 RANDOMIZE TIMER
N/INT*RN(;1
PRINT
PRINT nm$<", I)m thinking of a"
PRINT "numand 20."
138 PRINT
PRINT "What is my number"<>input g
F g\|n THEN 300
PRINT
PRINT "Hurray, "<nm$<"!"
PIT You Guessed my NUMBE!"
FOR t/1 to 10000>NEXT t
200 PIT
RNT nm$<", Do you want to"
PRINT "play again"<>INU$
F a$?"Y" R a$?"y" r a$? "YES or a$/"yes" THE1I$\|"N" or a$\|n$\NO" or a$\|"no" THEN 200
PRINT>END
300 PRINT
F gTEN 350
PRINT "Sorry, "<NM$<". Too Small!"
GOTO 138.
350 RINT "Sorry "nm$<". Too Big!"
GOTO 138and can i ADD some sund effects from the internal speaker or SOMETHING like a bleep if you take a item?Thanks, one more thing. If i write a file it isn't a .EXE program but a .NUM file... And when i save it with the EXTENTION the game will fail.:S
7733.

Solve : counting and echo from batch?

Answer»

Hi, i am looking for a batchfile that does the following:

i have a config file that has the following lines:

name001=pc0001
~
name088=pc0029
name089=pc0199

Now i want to be able when running the batch a line wil be added to the config file with name... with one number HIGHER than the last line + the current pc number.
So when running this batch from pc0215 the following line should be added:

name090=pc0215

I know %computername% can be used to print the pc number.

Thanx in advanceare the 4 characters 'name' an example, or are they what actually appear?

Whether the answer is yes or no, is the part before the number always 4 characters long?


vbscript
Code: [Select]Set objFS=CreateObject("Scripting.FileSystemObject")
Set WshNetwork = WScript.CreateObject("WScript.Network")
strComputerName=WshNetwork.ComputerName
Set objArgs = WScript.Arguments
strConfigFile = objArgs(0)
strTemp = "temp"
Set objTemp = objfs.CreateTextFile(strTemp,True)
Set objFile = objFS.OpenTextFile(strConfigFile)
data= Split(objFile.ReadAll,vbCrLf)
s = Split( data( UBound(data) - 1 ) , "=")
s1 = Replace(s(0), "name","")
length = Len(s1)
s1=s1+1
strNewValue = "name" & Pad(s1,length) & "=" & strComputerName
data( UBound(data) ) = strNewValue

For i=LBound(data) To UBound(data)
objTemp.Write(data(i) & vbCrLf )
Next

objTemp.Close
objFile.Close

If objFS.FileExists(strConfigFile) Then
objFS.DeleteFile(strConfigFile)
objFS.MoveFile strTemp,strConfigFile
End If

Function Pad(input, howmany)
'Pad leading zeroes to a string till length of howmany
If Len(input) <= howmany Then
Do Until Len(input) = howmany
input = "0" & input
Loop
Pad = input
End If
End Function

usage
Code: [Select]c:\test> cscript //nologo myscript.vbs configfile
Thanks a *censored* bunch, Ghostdog, I was right in the MIDDLE of a dinky little batch! Nothing like having your motivation taken away to make you feel good. You did see the "from batch" in the title?

Anyhow, ns1207, if you still want a batch solution, say so and also answer my question above and I may continue...




Quote from: Salmon Trout on December 09, 2009, 05:08:33 AM

Thanks a <censored> bunch, Ghostdog, I was right in the middle of a dinky little batch! Nothing like having your motivation taken away to make you feel good. You did see the "from batch" in the title?
Anyhow, ns1207, if you still want a batch solution, say so and also answer my question above and I may continue...

actually, the solution to your problem is very simple, just ignore my posts, because its intended audience is originally for the OP and not anybody else. And please do post your batch version, nobody has the any reasons to stop you, right?

Quote from: Salmon Trout link
You did see the "from batch" in the title?
sometimes title and actual post contents are not synonymous.
put the vbs command in a file, and call it a batch file. And that's a batch !You censored "*censored*"? Quote from: Salmon Trout on December 09, 2009, 07:43:01 AM
You censored "*censored*"?

probably the forum. seems to censor strange things when the quote button is used.Anyhow, the reason I became demotivated was because Ghostdog's solution is so much better. I WONDER if there is an audience for Autoit scripts?
Quote from: Salmon Trout on December 09, 2009, 07:43:01 AM
You censored "<censored>"?
when i click reply with quote, it shows me "censored". I did not do anything though.You must have CENSORING set in your forum preferences, I think.
7734.

Solve : batch file input from file?

Answer»

I have a file 'input.txt' in witch is written 'hello'.
I want to have a batch that write 'hello' on the screen.

This is my solution (doesn't work!!)

batch1.bat:

batch2 &LT; input.txt


batch2.bat:

echo %1
HAY,
TO FIND SPECIFIC WORD IN SPECIFIC FILE WITH BATCH AND TYPE IT WRITE THIS:
BATCH1.BAT:

FIND /I "HELLO" INPUT.TXT

THIS IS ALL. YOU DO NEED TWO BATCHES.

OR TO SIMPLY WRITE HELLO USE "ECHO: HELLO" IN BATCH.1. Why are you REVIVING very OLD threads?
2. Why are you using all capital letters, which is the equivalent of shouting, and is very irritating?

7735.

Solve : create folders based on part of filename?

Answer»

I would appreciate some help on a batch i am trying to make which takes a bulk of files in a folder (ebook/video/music collection) and create folders based on a variable length first part of the filename (i.e. author name).

NAMING convention is basically 2 parts: Author - Title
the separator for the 2 part file name is -

So far i am able to create a folder based on the filename and move all the files with the same name (regardless extension) into that folder.
This works great for video collection which puts the video,subtitle,coverimage etc in the same folder.
However it takes the full filename as a folder name.

Question: How can i name the created folder with only the part before the - ?

i.e.
ebook file:
Tolkien, J.R.R. - Lord of the Rings Part 01 - Fellowship of the Ring.epub

if not EXIST create the folder: Tolkien, J.R.R.
and move the above ebook into that folder.
Do the same for the next file in the directory.

Note: as above there can be more then one - in the filename, but the desired FOLDERNAME will always before the first -

Batch to create folder based on filename:

Code: [Select]@echo off
for /f "delims=" %%a in ('dir /b /a-d') do (
if not "%%~fa"=="%~f0" (
md "%%~na" 2>nul
if exist "%%a" move "%%~na.*" "%%~na"
)
)

Any help will be appreciated !

regards,
Sunrayfor /f "delims=" %%A in ('dir /b /a-d ^| find /v "%~nx0"') do (
for /f "tokens=1* delims=-" %%B in ("%%A") do (
if not exist "%%B" md "%%B"
if not exist "%%B\%%A" move "%%A" "%%B"
)
)

Before the first Hyphen or before the 2nd hyphen?

Do you always have a space before and after each hyphen?Quote from: Salmon Trout on June 22, 2012, 01:22:10 PM

for /f "delims=" %%A in ('dir /b /a-d ^| find /v "%~nx0"') do (
for /f "tokens=1* delims=-" %%B in ("%%A") do (
if not exist "%%B" md "%%B"
if not exist "%%B\%%A" move "%%A" "%%B"
)
)
That works and takes care of not having to WORRY about the spaces.
I was trying to do it all in a single FOR LOOP. But the nested for loop definitely fixes all the concerns I had.Many thanks for the very quick reply and solutions.

I did study an example in a previous topic with a similar question which resulted in a batch file calling a VBScript.
As i recall also provided by Salmon Trout ;-)

Again your solution works like a charm !!
Now for me to break it down and actually learn from it ;-p

Thanks are given to both for your efforts.

You guys are great, keep it up !Quote from: Sunray on June 22, 2012, 02:29:27 PM
Now for me to break it down

REM use dir to GET each full filename, pipe through find to exclude this batch file)
for /f "delims=" %%A in ('dir /b /a-d ^| find /v "%~nx0"') do (
REM break filename into 2 tokens: 1. everything before the first dash 2. everything after it
REM we only need the first one
for /f "tokens=1* delims=-" %%B in ("%%A") do (
REM first token is author name
REM if folder of that name does not exist, create it
if not exist "%%B" md "%%B"
REM if this file is not already in the folder, move it there
if not exist "%%B\%%A" move "%%A" "%%B"
)
)
7736.

Solve : complex batch process or maybe i'm making it harder than it needs to be?

Answer» HI Folks

First time attempt at writing a batch process and hitting a brick wall (MAINLY with my head )
Two parts to it really. Basically I am trying to run a program that will ping SEVERAL ip addresses and return the information to a log file, that much i have managed. The second part is identifying which ip address is timing out. As there is a BIG range of addresses i don't have time to sift through a log file and wondered if any of you knew if there was any way of identifying time outs and writing to a new file the date/time and ip address of each of them.

Does this make any sense? Many thanks for your help on this.
If a ping request times out, there will be a nonzero errorlevel, so after the ping command returns, just test for this and if so, write the ip address and system date & time to the timeout log in append mode. You sound like a sysadmin, or at least a person who is paid to know how to do basic IT stuff, so I am sure I won't need to SPELL out in detail how to do this.


http://ss64.com/nt/ping.html







please search the forum also. there are lots of examples on pinging and getting results back + filtering.
7737.

Solve : Access iTunes Menu Through Command Prompt?

Answer»

I was wondering if it is possible to access a menu item in ANOTHER application through command prompt. Specifically, I would like to be ABLE to create a batch file that would add a folder with music in it into my iTunes library. Then, since I have my iTunes set to copy music into the iTunes music folder, I would like the batch file to automatically DELETE the original files once they have been copied over.
Thanks for Your Help!

IANI dont know of a way to do this via command line because the problem you will face is with iTunes and lack of indexing of the content. Its BEST to import the content via the existing import feature so that all music is correctly indexed.

7738.

Solve : how to check two conditions at a time using IF EXIST?

Answer»

Hi everybody, I am chaitanya, I want the SYNTAX of a particular command. Let me explain my problem.

I have two files located in two different directories. I want to check the existence of those two files. If those two files exist in the specified location "hi" should be echoed else the prompt should echo bye.

It should look some thing like this:

if exist c:\play.wav c:\lyrics\play.txt ( echo hi ) else ( echo bye ). I tried this but failed. I am able to check the existence if one file at a time. I want the command to be executed if those two files exist.

Can ANYBODY PLEASE help me?

Thank you all in advance.CODE: [Select]SET flag=0
if exist c:\play.wav set flag=1
if exist c:\lyrics\play.txt set /a flag +=1
if %flag% equ 2 ( echo hi ) else ( echo bye )
Thank you Salmon.Alternatives:

Code: [Select]set bothexist=no
if exist c:\play.wav if exist c:\lyrics\play.txt set bothexist=yes
if "%bothexist%"=="yes" ( echo hi ) else ( echo bye )


Code: [Select]set bothexist=no

if exist c:\play.wav (
if exist c:\lyrics\play.txt (
set bothexist=yes
)
)

if "%bothexist%"=="yes" (
echo hi
command(s) to execute if both exist
) else (
echo bye
command(s) to execute if both do not exist
)

7739.

Solve : batch command - spaces in path?

Answer»

Hi,

I want to do a command line iike:

for /F "tokens=4" %%F in ('c:\spaces spaces\filever.exe /A /D D:\Spaces Other\a.dll') do ( set VERSION=%%F )

I ENCOUNTER a spaces PROBLEM. How can I write that command with a paths with spaces.

Thanks, Ido
Enable extensions if not already enabled, and then you can use alternative QUOTING STYLE with backquotes - NOTE carefully ALL back and double quotes in script below.


c:\>type backtest.bat
@echo off
setlocal ENABLEEXTENSIONS
for /f "usebackq tokens=4" %%F in (`""C:\PATH With Spaces\filever.exe" /A /D "D:\Another Path With Spaces\ipwssl6.dll""`) do (set version=%%F)
echo Version is: %version%

c:\>backtest.bat
Version is: 6.2.2509.0
c:\>

7740.

Solve : Projekt Backup in betch file?

Answer»

Many thanks for the help can you are to give me,
since made some changes to the betch file code,
referring to the assistance that you gave me
I received the response the following message.
I need to look as Percent from 1% to 100% of material being copied
by the TIME can I executed the file.
Originally if I download a program from internet,and waiting until a 100%.

thank you very mutch.



this mesage:

C:\Documents and Settings\Administrator.IBD\Desktop>set day=13

C:\Documents and Settings\Administrator.IBD\Desktop>set mnth=06

C:\Documents and Settings\Administrator.IBD\Desktop>set yr=12

C:\Documents and Settings\Administrator.IBD\Desktop>if 06 == 01 set mnth=JAN

C:\Documents and Settings\Administrator.IBD\Desktop>if 06 == 02 set mnth=FEB

C:\Documents and Settings\Administrator.IBD\Desktop>if 06 == 03 set mnth=MAR

C:\Documents and Settings\Administrator.IBD\Desktop>if 06 == 04 set mnth=APR

C:\Documents and Settings\Administrator.IBD\Desktop>if 06 == 05 set mnth=MAY

C:\Documents and Settings\Administrator.IBD\Desktop>if 06 == 06 set mnth=JUN

C:\Documents and Settings\Administrator.IBD\Desktop>if JUN == 07 set mnth=JUL

C:\Documents and Settings\Administrator.IBD\Desktop>if JUN == 08 set mnth=AUG

C:\Documents and Settings\Administrator.IBD\Desktop>if JUN == 09 set mnth=SEP

C:\Documents and Settings\Administrator.IBD\Desktop>if JUN == 10 set mnth=OCT

C:\Documents and Settings\Administrator.IBD\Desktop>if JUN == 11 set mnth=NOV

C:\Documents and Settings\Administrator.IBD\Desktop>if JUN == 12 set mnth=DEC

C:\Documents and Settings\Administrator.IBD\Desktop>set dte=13JUN12
Start Time = 22:00:05.09
1 file(s) copied.
sleep
'sleep' is not recognized as an internal or external command,
operable program or batch file.
Stop Time = 22:10:38.60
Total Run Time = 633 seconds
-------------------------------------------------------

this changes to the betch file code,



set day=%date:~-10,2%
set mnth=%date:~-7,2%
set yr=%date:~-2,2%
if %mnth%==01 set mnth=JAN
if %mnth%==02 set mnth=FEB
if %mnth%==03 set mnth=MAR
if %mnth%==04 set mnth=APR
if %mnth%==05 set mnth=MAY
if %mnth%==06 set mnth=JUN
if %mnth%==07 set mnth=JUL
if %mnth%==08 set mnth=AUG
if %mnth%==09 set mnth=SEP
if %mnth%==10 set mnth=OCT
if %mnth%==11 set mnth=NOV
if %mnth%==12 set mnth=DEC
set dte=%day%%mnth%%yr%

@echo off
echo Start Time = %TIME%
set /a HH=0
set /a MM=0
set /a SS=0
set /a HM=0
set /a MS=0
set /a HS=0
set /a SA=0
set HH1=%TIME:~0,2%
set MM1=%TIME:~3,2%
set SS1=%TIME:~6,2%



copy "\\192.168.2.211\f\AutoBackup DSMS\DSMS_BCK.bak" "C:\Documents and Settings\Administrator\Desktop\test\DSMS"\%dte%DSMS_Backup.bak /y
copy "\\192.168.2.211\f\AutoBackup DSMS\Dsms_Exchange.bak" "C:\Documents and Settings\Administrator\Desktop\test\DSMS_Exchange"\%dte%DSMS_Exchange.bak /y



echo sleep %1
sleep %1
echo Stop Time = %TIME%
set SS2=%TIME:~6,2%
set HH2=%TIME:~0,2%
set MM2=%TIME:~3,2%
set /a HH=%HH2%-%HH1%
set /a MM=%MM2%-%MM1%
set /a SS=%SS2%-%SS1%
if %HH%==0 goto alt
if %MM%==0 goto alt1
set /a HM=%HH%*60
set /a MS=%MM%*60
set /a HS=%HM%*60
set /a SA=%HS%+%MS%+%SS%
echo Total Run Time = %SA% seconds
goto END

:alt
if %MM%==0 goto alt1
set /a MS=%MM%*60
set /a SA=%MS%+%SS%
echo Total Run Time = %SA% seconds
goto end

:alt1
set /a SA=%SS%
echo total time: %SA%

:end

echo MSGBOX "Backup of DSMS Databasse have been save sucesfull, Thank You! *Shyqyri Hysesani*." > %temp%\TEMPmessage.vbs
call %temp%\TEMPmessage.vbs
del %temp%\TEMPmessage.vbs /f /q



I deleted your other posts. Please stop posting the same question all over the forum - one post per question is all you need. Also, please do not post your question in other people's threads. Thank you.ok,1. Do you have sleep installed on your computer? that would be the first question I would ask as it says that It doesn't recognize the command.
2. what is %1 in 'sleep %1'?
3. what OS are you using?1)-I use Win XP and Win Server 2003

2)-i wont to create one project in Betch File, can copy this data: Backup.BAK from sorce //192.168.2.211/f/AutoBackup/ to onather server to this destinacione, for example: //192.168.2.10/d/ManualBackup

3)-I need to look as Percent from 1% to 100% of material being copied
by the time can I executed the file.
Originally if I download a program from internet,and waiting until a 100%.

Thenk you
Best Regards
Eng Shyqyri HysesaniBatch really can't do an accurate progress BAR or tell you how long it is going to take to process something.

You may want to look at ROBOCOPY as it has these two switches:
Code: [Select] /NP :: No Progress - don't display % copied.
/ETA :: show Estimated Time of Arrival of copied files.there is any application that when executed to copy the starget path and past in destinacion path, and show me the time of remaining PROCES ore percent of copy.
thanksis through the sql's jobs, how can we realize??I don't know if this will help, but have have an output of "56%" you would "echo 56%%%" or echo %progress%%%%"the second,Quote from: shyqyri on June 16, 2012, 02:02:15 AM

there is any application that when executed to copy the starget path and past in destinacion path, and show me the time of remaining proces ore percent of copy.
thanks

I use TeraCopy - it's free (for non-commercial use) and can be run from the command line. There are other SIMILAR apps, such as SuperCopier.







Although I agree that Microsoft's own Robocopy is very good. It is a console program which shows percentage progress.










hahahaha, thenks but don't me undestand.
i wont to copy some shared backup files (name.BAK), per example 4 shared files in this server://server1/backup/dsms.bak, //server2/backup/exchange.bak, //server3/backup/nav.bak, //server4/backup/domain.bak, to one server per example, //backup-server/DataBackup/2012/
for one click on betch file aplications ore create jobs in sql can copy this shared file from server 1,2,3 to //backup-server/DataBackup/2012/
Terra Copy, Super Copy2 ect don't work for my Plane-Project.
thank you
best regards
Shyqyri Hysesani
7741.

Solve : how to execute ENTER without taping enter button in bat file?

Answer»

hello guys

could somebody tell me please :


how to execute ENTER WITHOUT taping enter button in BAT filePlease give more information about what you are trying to do.
hello thanks for reply

i want to create a bat file for user net changing password

and in the end its asking me to press enter 2 times to create ANOTHER password or leave it BLANCK and for that i dont know how can i write enter in bat file ..

thanks

The short answer is "you can't".

Why do you NEED to do this?



7742.

Solve : Clicking a radiobutton (checkbox) froma program?

Answer»

im trying to automate a program but i get stuck at a check box screen. is there anyway to click a certain button using bat SCRIPT or vbs? dont know if that code below will help but thats what the error file is saying..button 61 is the ONE i want to choose.

Code: [Select]InitApplication: Class Name = src5911
hWnd = 1486
Creating button Run SRC with RadioButton ID 60
Creating button Process Files with RadioButton ID 61
Creating button Exit Program (Return to DOS) with RadioButton ID 62
default case: wParam = 61
RadioButtonClicked = 61
Get_Menu_Sel returning 1
ScriptSelection = 11

Quote from: daillest319 on June 15, 2012, 07:39:19 AM

im trying to automate a program but i get stuck at a check box screen. is there anyway to click a certain button using bat script or vbs? dont know if that code below will help but thats what the error file is saying..button 61 is the one i want to choose.

What program?

For a web based application, you can create an instance of a browser, navigate to the page and script any actions (radio buttons, check boxes, text box input etc) using VBScript. You will need to do some research into the page structure to get the control names to use in your script.

For a local Windows application you can use the VBScript sendkeys method to mimic a user at the keyboard. The script using the sendkeys method runs external to your application but becomes problematic if your application loses FOCUS or is in anyway interrupted.

You might want to try a 3rd party program like AutoIt.

Good luck.
7743.

Solve : I need help with SET and IF commands?

Answer»

I'm making a batch file that requires user input, but I can't get it to work

I'm using WINDOWS XP, but I don't think it makes a difference.

Here's what I have:
CODE: [Select]:MainScreen
echo.
echo Options
echo 1) Kill a task (program)
echo 2) Start a task (program)
echo 3) Restart
echo 4) Shutdown
echo 5) Logoff
echo 6) Open taskmanager
echo 7) Close
echo.
echo Type the number of the options you want to run then hit ENTER.
set /p %MSC% = {
if "%MSC%"=="1" GOTO KillTask
if "%MSC%"=="2" goto StartTask
if "%MSC%"=="3" goto Restart
if "%MSC%"=="4" goto Shutdown
if "%MSC%"=="5" goto Logoff
if "%MSC%"=="6" goto Taskman
if "%MSC%"=="7" goto Close
else goto MainScreen

But when I run it no matter what number I type it sends me to the next section of code.
Can someone please tell me how to fix the IF command?Try this:
Code: [Select]:MainScreen
echo.
echo Options
echo 1) Kill a task (program)
echo 2) Start a task (program)
echo 3) Restart
echo 4) Shutdown
echo 5) Logoff
echo 6) Open taskmanager
echo 7) Close
echo.
echo Type the number of the options you want to run then hit ENTER.
set /p MSC=
if "%MSC%"=="1" goto KillTask
if "%MSC%"=="2" goto StartTask
if "%MSC%"=="3" goto Restart
if "%MSC%"=="4" goto Shutdown
if "%MSC%"=="5" goto Logoff
if "%MSC%"=="6" goto Taskman
if "%MSC%"=="7" goto Close
goto MainScreen
It works, thanks soooooo much In case you didn't pick up on the problem, when you typed 'set /p %MSC% = {' you were trying to refer to a string that didn't exist. If you have used c/c++/etc. you may remember commands like 'int a' or w/e to DECLARE your verable. In DOS, when you surround charictors with % you are telling it to replace that text with whatever the string is equal to. Because you had not set a value to %MSC% it would replace it with nothing, so the program would run 'set /p = {' which does not respond to anything in the rest of your program.

Thank you for listening to the youngman's rant.If you wanted to keep the "{" at the end you just put "^" in front of it.

Code: [Select]:MainScreen
echo.
echo Options
echo 1) Kill a task (program)
echo 2) Start a task (program)
echo 3) Restart
echo 4) Shutdown
echo 5) Logoff
echo 6) Open taskmanager
echo 7) Close
echo.
echo Type the number of the options you want to run then hit ENTER.
set /p %MSC% = ^{
if "%MSC%"=="1" goto KillTask
if "%MSC%"=="2" goto StartTask
if "%MSC%"=="3" goto Restart
if "%MSC%"=="4" goto Shutdown
if "%MSC%"=="5" goto Logoff
if "%MSC%"=="6" goto Taskman
if "%MSC%"=="7" goto Close
else goto MainScreen

7744.

Solve : Eternal Death Slayer?

Answer»

As promised, here is the first BETA of Eternal Death Slayer 2. It's still primative, but the purpose of the beta is to get feedback about UI and the gameplay so far. It's all described in the readme included. Enjoy. I hope to hear lots of feedback i heard a loud beep and my computer turned off...Really? None of the 4 computers I BUILT it on did that. Did it do it more than once? When (if) more people download it I guess I'll see if this is an error...I believe your problem might be the directories and file st up. I have fixed this. The only issue might be you manually have to copy ctext.exe to Eternal Death Slayer 2\Files\ in the root of the drive it is being run from. Please try this and post results.

[Saving space, attachment deleted by admin]Seriously no one is interested in testing anymore? When I was a frequent user here a few months ago a bunch of us were into batch programs and I had at least 3 people wanting to test EDS. What happened? This is my senior project for school (I need it to graduate this year) so I was kind of hoping for a slightly better reaction. Don't do it if you don't want, I'm just wondering what happened?Could it possibly be that this isn't in the MS DOS section anymore ? ?There's a LINK in the batch programs thread, but I guess that could be the problem. Can it be moved please, or no?QUOTE from: gamerx365 on DECEMBER 12, 2009, 10:26:06 AM

Seriously no one is interested in testing anymore? When I was a frequent user here a few months ago a bunch of us were into batch programs and I had at least 3 people wanting to test EDS. What happened? This is my senior project for school (I need it to graduate this year) so I was kind of hoping for a slightly better reaction. Don't do it if you don't want, I'm just wondering what happened?

Haven't seen Devcom or Macdad for quite some TIME, assuming they aren't operating under some alias.
7745.

Solve : Need help with a batch file that can detect if a number is negative?

Answer»

Exactly! The cmd line can only handle numbers 2^31. He is basically trying to create a number larger than the the maximum integer the cmd line can handle. If he would remove the /A like both of us have already told him he wouldn't have this problem.I haven't tried it on Vista, but on Windows 7 attempting to use set /a with a more-than-32 bit number gives an error with a helpful message.

Code: [Select]@echo off
:loop
set rand1=%random%
set rand2=%random%
set num2=
echo attempting to form long number from %rand1% and %rand2%:
set /a num2=%rand1%%rand2%
echo number: %num2%
goto loop

XP

Code: [Select]attempting to form long number from 21161 and 24341:
number: 2116124341
attempting to form long number from 52 and 9566:
number: 529566
attempting to form long number from 18750 and 23734:
number: 1875023734
attempting to form long number from 14704 and 24719:
number: 1470424719
attempting to form long number from 27451 and 25423:
number: -1549841873
attempting to form long number from 5098 and 27609:
number: 509827609
attempting to form long number from 16820 and 7515:
number: 168207515

Windows 7

Code: [Select]attempting to form long number from 5176 and 20064:
number: 517620064
attempting to form long number from 8211 and 24487:
number: 821124487
attempting to form long number from 9043 and 12230:
number: 904312230
attempting to form long number from 10230 and 15103:
number: 1023015103
attempting to form long number from 21127 and 4025:
number: 211274025
attempting to form long number from 11185 and 78:
number: 1118578
attempting to form long number from 24413 and 26665:
Invalid number. Numbers are limited to 32-bits of precision.
number:
attempting to form long number from 6451 and 30459:
number: 645130459
attempting to form long number from 10874 and 13098:
number: 1087413098
Another point for intrepid batch warriors to take note of is that set /a interprets anything starting with a zero as an OCTAL number and tries to evaluate it. Octal numbers can only have the digits 0 to 7. Trying to use 8 or 9 will cause an error. I see that the OP is first concocting a number from %random%%random%, and then in a loop trying out a succession of new numbers created the same way. Using two calls to random is going to generate a string which could be anything from 00 to 3276732767. Feeding this to set /a is all very WELL in XP as long as the first value is not 0 and the second value does not contain any 8s or 9s. In XP an overflow just results in a negative number and if the second random pair is the same as the first then the comparison test will be satisfied. In Windows 7 and maybe Vista overflow causes an error message and the compound number is not evaluated by set /a. However in BOTH XP and Windows 7 an attempt to create an invalid octal number causes an error message. I SUSPECT the OP has not run his "code cracker" script in XP long enough for the invalid-octal message to appear, as it surely would eventually. Or maybe some have scrolled by while his attention was elsewhere. In Win 7 and Xp with in either of these situations, the script will merrily proceed.

As has now been REPEATEDLY said, keep the generated values as STRINGS. I see that the OP uses the word "passcode" in a REMark. Passcodes are not "numbers" (quantities). They are strings of symbols which could just as validly be letters of the alphabet or punctuation or symbols like asterisks and hashes, as well as digits. So drop the /a switch from set.

Both XP and Windows 7:

Code: [Select]c:\>set /a num=01
1
c:\>set /a num=02
2
c:\>set /a num=03
3
c:\>set /a num=04
4
c:\>set /a num=05
5
c:\>set /a num=06
6
c:\>set /a num=07
7
c:\>set /a num=010
8
c:\>set /a num=011
9
c:\>set /a num=01234567
342391
c:\>set /a num=01234568
Invalid number. Numeric constants are either decimal (17),
hexadecimal (0x11), or octal (021).Sorry, I accidentally quoted myself (removed)
Here is a way to get a random key of a set length

Code: [Select]setlocal enabledelayedexpansion
set NumberOfDigits=4

set num1=
FOR /L %%N in (1,1,%NumberOfDigits%) do set /a randigit=!random! %% 10 & set num1=!num1!!randigit!
echo num1=%num1%
Adapting the OP's code slightly

Code: [Select]@echo off
setlocal enabledelayedexpansion
set NumberOfDigits=4

set num1=
FOR /L %%N in (1,1,%NumberOfDigits%) do set /a randigit=!random! %% 10 & set num1=!num1!!randigit!
echo num1=%num1%

mode 100,25
set /a num3=0

set time1=%time%

:rand1
color 0A
set num2=
for /l %%N in (1,1,%NumberOfDigits%) do set /a randigit=!random! %% 10 & set num2=!num2!!randigit!
set /a num3=%num3% + 1
title Searching for codebot... Number is %num1%
echo Scanning codebot %num2% %time%
REM ping localhost -n 2 > nul
if %num2%==%num1% goto rand2
goto rand1

:rand2
set time2=%time%
cls
echo.
title Passcode Found
echo Found in %num3% tries
echo Passcode: %num2%
echo Started at %time1%
echo Found code %time2%
echo.
echo Press any key to exit...
pause > nul

(These 2 screencaps were from DIFFERENT runs, which is why the code is different in each one.)

With the method I have shown, you can have seriously long code keys, by changing NumberOfDigits but of course the longer the key the more time it will take on average to find a match. You can see that with 4 digits the example run took a bit more than 26 seconds (without the ping delay). Each loop took around 10 milliseconds. I guess the ping delay is so you can actually see the numbers as they scroll. As the delay is about 1 second this would have taken around 40 minutes. You can imagine that with a longer key you would get longer processing times (and the increase would not be linear). With numbers (valid ones!) using the %random%%random% method I think the possible time would have been measured in days or weeks.



7746.

Solve : Running Script?

Answer»

I wondered about cygwin too.
ghostdog, i'm actually being a client for this one server.
what i do is to telnet a server, then from there i go into ftp server to do downloading CERTAIN files. in order to go into the ftp server and thus do downloading, i usually RUN a prepared script saved in ftp client. again, my command line is sumthing like below:

telnet XXX.XXXX.XXXX.XXXX [ip ADDRESS of server]
script.sh

usually, files will appear in the ftp client and i can download it into my pc.
but now, what happened was that i COULDNT even run the script as error saying "permission DENIED" appears.
hopefully u can get what i mean.

7747.

Solve : cURL help: need to get page with varying date?

Answer»

I would like to automatically fetch "get" a web page that has the date as part of its path

https://site.gov/blah/blah/decision?process_date=6%2F13%2F2012&v_dispatchid=#######&but=Reports

This is part is my PROBLEM.... 6%2F13%2F2012

As is, I have to login, click various radio buttons and prompts, until I navigate to this page.

Is there a way that cURL can find the page relative to "TODAY's DATE -1DAY"?

I'm open to suggestions... The end goal is to retrieve that web page. Thanks in advance!
-AliIs it possable you could give us the site? I don't know of any site that uses % in the url >.&LT; but I believe all you would have to do is make a file that says:
Code: [Select]start "~\iexplore.exe" "yourURLHere"
But I will be unable to test this until I find a site, sorry.Quote from: Lemonilla on June 14, 2012, 08:08:46 PM

I don't know of any site that uses % in the url >.<
% signs in a URL are used for escaping certain characters. In the given URL, for example, %2F is character code 47 which is the forward slash ("/"). naturally that cannot appear as is since it would be another slash and "break" the url.

This is also part of the problem in the original post. the date is being represented as 6/13/2012, but with the slashes ESCAPED. I guess the problem here is that the % signs have special meaning on the windows command line.

You can escape them by inserting a caret before the percent SIGN.

Quote
https://site.gov/blah/blah/decision?process_date=6^%2F13^%2F2012^&v_dispatchid=#######^&but=Reports
(ampersands have special meaning too, so those need to be escaped).

For getting the proper URL for the previous date, you can probably do some string processing on the output from date /t; though it would likely rely on the date format being used.

Quote from: BC_Programmer on June 14, 2012, 08:33:33 PM
I guess the problem here is that the % signs have special meaning on the windows command line. You can escape them by inserting a caret before the percent sign.

The escape for a percent sign is another percent sign. Thus to achieve % you need %%. (Why don't people just use VBScript?)

7748.

Solve : XCOPY problems with user input?

Answer»

Hi,

I am trying to copy only one file from multiple files with user prompt using XCOPY. If the user chooses 'y' it should copy into a target.txt file.

This is the script I am using

xcopy D:\source\*.*/p D:\Target.txt || goto error
But it asks me a file or directory. So I tried doing this.

echo F | xcopy xcopy D:\source\*.*/p D:\Target.txt || goto error

Now, it is not asking for the user input anymore. How can I prompt for user input by defaulting to a file?
Experts... Please help
Thanks
It would help if you would explain what and why of the project.
Why would you only copy some files? What MAKES them different?
Are they in MANY directories? Why?
Are the files read only?
Do you want a minimal batch file few people can understand ?
Or do you want something that can later be updated by others?
A script file using Vb script would be an good chive.
But it can be done in batch.
One way is ton just divide the project into tasks. That is, a set of batch files that work as part of a whole.
As long as you pipe F to XCOPY, you can use the COPY utility and write out the code in longhand:

Code: [SELECT]@echo off
setlocal enabledelayedexpansion
for /r d:\source %%V in (*.*) do (
set /p prompt=Copy %%v (y/n^):
if /i !prompt! EQU y copy /-Y "%%v" d:\target.txt
)

If you can, replace the SET statement with CHOICE so you can better filter the responses.

7749.

Solve : How to delete the last line of a txt file?

Answer»

I am not saying you should read directly from the environmental variable in your program. I am saying pass it as a COMMAND line argument. This has nothing to do with a graphical interface. If your program was setup correctly to read a variable from input you COULD call your program from your batch file like so.

MSL.exe %model%

I haven't programmed in C++ since I TOOK my class in 1996 so I really can't recall how to do it but just about every Compiled and Interpreted programming Language can accept command line input in some fasion.Quote from: Salmon Trout on June 13, 2012, 12:36:25 PM

avoids trailing space

Code: [Select]set model=blablabla
0>nul set /p=%model%>mdchk.txt
cool, thanksQuote from: Squashman on June 13, 2012, 04:49:15 PM
I am not saying you should read directly from the environmental variable in your program. I am saying pass it as a command line argument. This has nothing to do with a graphical interface. If your program was setup correctly to read a variable from input you could call your program from your batch file like so.

MSL.exe %model%

I haven't programmed in C++ since I took my class in 1996 so I really can't recall how to do it but just about every Compiled and Interpreted programming Language can accept command line input in some fasion.

hum... I see, next time i will try it!!!

Thank you for your help!look for argv, argc, etc
7750.

Solve : what is tasklist command "PID no."?

Answer»

In tasklist command,
we are getting the PID no. against each process, if there is a process called Excel.exe and if i open 5 sessions of excel, tasklist gives me 5 entries of excel.exe with 5 different PID no's,

So the question is Can i make use of PID no's to find out that which one is older or newer process? & Can i correlate that which PID no. is associated with which session?

Thank in advance!PID stands for "Process ID". Use the /v switch with tasklist to get verbose output, which will include window title and user details.

Quote from: Yogesh123 on December 11, 2009, 04:09:14 AM

So the question is Can i make use of PID no's to find out that which one is older or newer process?
NO.

Quote
& Can i correlate that which PID no. is associated with which session?
don't understand

to have better programming control over the things you do, try using vbscript.(natively)
this vbscript terminates the latest (newest process) of the same type
Code: [Select]Set objFS=CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
strProcess = objArgs(0)
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = '"&strProcess&"'")
t=0
For Each objProcess in colProcessList
s = Replace( objProcess.CreationDate ,".","")
s = Replace( objProcess.CreationDate ,"+","")
If s > t Then
t=s
strLatestPid = objProcess.ProcessID
End If
Next
WScript.Echo "latest: " & t , strLatestPid
Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" & strLatestPid)
For Each objProcess in colProcess
objProcess.Terminate()
Next

to use it on the command line type
Code: [Select]c:\test> cscript //nologo killbill.vbs "notepad.exe"
i leave it to you to find the oldest if you are interested.Quote from: Yogesh123 on Today at 04:09:14 AM
"So the question is Can I make use of PID no's to find out that which one is older or newer process?"

Quote from: ghostdog74 on December 11, 2009, 04:37:59 AM
NO, you cannot make use of PID no's to find out that which one is older or newer process?"

How does Casper know: "You cannot make use of PID no's to find out that which one is older or newer process?"

p.s. The smaller the PID number, The older the process?
Quote
p.s. The smaller the PID number, The older the process?

You might think that, but you would be wrong. A simple script that selects all the instances of the svchost along with the PID and the CREATION date will show PID numbers are assigned rather haphazardly.

Quote
==========================================
Computer: LAPTOP
==========================================
CreationDate: 12/11/2009 7:24:55 AM
Name: svchost.exe
ProcessId: 900

CreationDate: 12/11/2009 7:24:56 AM
Name: svchost.exe
ProcessId: 968

CreationDate: 12/11/2009 7:24:56 AM
Name: svchost.exe
ProcessId: 1084

CreationDate: 12/11/2009 7:24:57 AM
Name: svchost.exe
ProcessId: 1136

CreationDate: 12/11/2009 7:24:58 AM
Name: svchost.exe
ProcessId: 1296

CreationDate: 12/11/2009 7:25:03 AM
Name: svchost.exe
ProcessId: 1892

CreationDate: 12/11/2009 7:25:07 AM
Name: svchost.exe
ProcessId: 436

You'll notice that the last instance of svchost which was assigned the lowest PID. I wouldn't count on a correlation between the PID and the age of the process. Better to use the creation date and calculate the age.

Quote from: billrich on December 11, 2009, 11:24:51 AM
How does Casper know: "You cannot make use of PID no's to find out that which one is older or newer process?"

Why does billrich the tosser post RUBBISH?Quote from: billrich on Today at 11:24:51 AM
How does Casper know: "You cannot make use of PID No's to find out that which one is older or newer process?"

Quote from Billrich:
"p.s. The smaller the PID number, The older the process?"

Quote from: Sidewinder on December 11, 2009, 12:15:55 PM
You might think that, but you would be wrong. A simple script that selects all the instances of the svchost along with the PID and the creation date will show PID numbers are assigned rather haphazardly.

Sidewinder:

Thanks for your post and explanation of PIDs. Some of the negative posters are confused and vindictive.
Quote from: billrich on December 11, 2009, 11:24:51 AM
How does Casper know: "You cannot make use of PID no's to find out that which one is older or newer process?"
I know it can't because i have been doing sysadmin + IT security for years and i know how PIDs behave. That's why i say NO. if you do not know or are unconvinced, you can try out for yourself , couldn't you? hahaha

"smaller Pids are older"

hilarious assumption, especially considering the ProcessID and Process Handle are essentially memory POINTERS, and therefore subject to memory allocation rules, which are pretty haphazard in themselves. You cannot, for example, know at any one point where in memory a structure will be allocated any more then you can predict the ordering of the allocations based on the time they are performed. Especially on account of the fact that memory is allocated and reallocated quite often; to say that "the lower Pids are older" is like SAYING that the files at the beginning of a disk are the oldest ones.