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.

7101.

Solve : Batch File to search a word and replace with another in same line?

Answer»

Hi All,

I am looking for a batch file to search a WORD start with abc_ and REPLACE with the whole word with another word in same line.


For Ex:

#define PNG file type icon abc_029_x200_y200 s_pnot0w12h8
#define PNG file type icon msn_549_x547_y540 s_pnot1w12h8
#define PNG file type icon ijk_469_x497_y569 s_pnot2w12h8
#define PNG file type icon rst_712_x492_y478 s_pnot3w12h8


Out put to be:

#define PNG file 029 icon abc_029_x200_y200 s_pnot0w12h8
#define PNG file 549 icon msn_549_x547_y540 s_pnot1w12h8
#define PNG file 469 icon ijk_469_x497_y569 s_pnot2w12h8
#define PNG file 712 icon rst_712_x492_y478 s_pnot3w12h8

In the output, word "type" is replaced with value "abc_029_x200_y200" and removes the character other than 029.


LIKE this i have 100's of textfile with 100s of line. Pls help me to do this task using batch file.
Very similar to your previous request. You should be able to take the examples you were already given and TWEAK them for this example.Quote from: chandru630 on January 25, 2014, 10:26:31 PM

I am looking for a batch file

Is there a reason why you didn't follow up your previous thread?

It's polite to say "yes it worked" or "It didn't work because it did [this] instead"

7102.

Solve : What Switch Prevents Path from showing??

Answer»

Fellow Forum Members,

Using the MSDOS command below:

C:\Root>dir /b /s | more

Produces the LIST below on my monitor screen:
C:\Root>file1.doc
C:\Root>file2.doc
C:\Root>file3.doc
C:\Root>file4.doc

The problem is I don't WANT the "C:\Root" text to appear. I only want the "file#.doc" text to appear on my monitor screen. What switch do I need to use (besides /b & /s) to prevent the "C:\Root" text from appearing. In short, my goal is to only generate a list that creates a filename list without any path information included. I then want to select all the text and copy it so I can paste it into WORD. I told my Boss I need an app called SnagIT but he is too cheap to buy it. Any info will be appreciated. Do you only want the files in the C:\root folder as you have shown?Foxidrive,
Thanks for your post. The end result I want to see on my screen is shown below:

file1.doc
file2.doc
file3.doc
file4.doc

I want to prevent any path related text from showing. What switch do I need to use to make this happen? In addition, I want the results to display on the screen monitor. I don't want a text file generated that contains the text. the "|more" command seems to make this happen. But it would be nice to use a different command that SHOWS the entire results and not on SEPARATE screens. Any help in modifying the command text below will be greatly appreciated. Thanks.

C:\Root>dir /b /s | more


if you dont need to traverse the sub directories then remove the /s option.

If you need to traverse sub directories and only want to display the filename then you need to encapsulate your command inside a for loop.
Code: [Select]for /f "delims=" %%G in ('dir /b /a-d') do echo %%~nxGDoes the OP want a lilts of files with no path?
But he wants to include files from any sub directories.?

We, he might get a list of files that are not unique.
Consider: What if he have 7 files named ''foo" in 7 directories somewhere under the current location. The output would be:
foo
foo
foo
foo
foo
foo
foo
What would he do with that information? He haws no idea whee they are.

7103.

Solve : Net Send Command?!??

Answer»

I am on a network with several computers on a workgroup, that workgroup is in mor than one room. I want to be able to send net messages in only my room. All the computers in my room are TITLES IT(#) # being any number 1-25, if i send the COMMAND net send IT* [message] will it send only to the people in my workgroup with the net name begining with IT? I want to test this theory but i nearly got introuble when i sent the net send * [message]command that sent the message to multiple rooms. Just a yes/no answerThe Syntax is

net send IT1 [message]
net send IT2 [message]
net send IT3 [message]
etc...

DOS cannot merge two different commands together.
the * makes DOS send the message to all users logged onto ALL domains.

i am only 16 so i wouldn't know if you can set it to go to One domain. but if you could i would imagine it would be something like:

NET SEND IT [MESSAGE]

any problems then email me: [emailprotected]I believe you have to send to a specific computer name or user name, or of COURSE everyone (as you FOUND out).

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_send.mspx

You could find out the specific user names or computer names and put those into a batch file to net send each one, with the message as a parameter.

7104.

Solve : NET SEND !!!!!! HELP?

Answer»

Dear SIR,
I have the IP of a Gateway PC, and I have the (3D Party) IPs of the network users, now how can I SEND a (NET SEND) to one of the USERS.
in other words, lets say that the Gateway IP is: 555.555.555.555
The USER IP is: 192.168.666.666
now if I write: net send 555.555.555.555 teste, the MSG will reach the gateway, and if I write: net send 192.168.666.666, it will not reach anywhere, coz I'm not inside that network, so please do write me the command to send a MSG to a user inside the network..
Thank you.
JIINNXXX

i am pretty sure it is:

net send 192.168.666.666 [MESSAGE]

i am only 16 but i am assuming that would send it to the person involved as the IP is significant to that user and it should find it on the network and display the message intended.

good luck Mr_Skullstype net send /? and follow the instructions

net send gateway ip message.

If you know the name of the domain and the computer you can type the name. Its EASIER than typing ip adresses. ;-)

hope this helps

uliThe 192.168 addresses are on a private network and you won't have a way to get to those.

Unless you have some type of VPN or other connection to that network, about your only chance would be to use the route command to add a route through the gateway to one of those IP addresses.
Even then it would still depend on the gateway/router forwarding that type of traffic to that address.

uli_glueck - where do you find that you can supply a gateway address for that command?

7105.

Solve : Batch file to copy an paste text?

Answer»

is there way for a Batch script to paste text stored with the batch script? like a log on id Pretty much give you the same ANSWER for both of your QUESTION and the Same answer they gave you on the DosTips FORUMS. You would need to use a program like AutoIt or AutoHotKey.you could use set /p string=>File2.txt
but his only works for the first line of text.hello bro.
IN your File2.txt , why include Echo is off.

plz explain me.

[recovering disk space, attachment deleted by admin]Quote from: daillest319 on June 15, 2012, 12:39:38 PM

is there way for a Batch script to paste text stored with the batch script? like a log on id
Batch files are used in some cases where you need to send a file to a remote computer that requires a password. Is that what you MEAN?
-OR-
A simple way to tog into a web site, like Facebook, when the user has some handicap that limits his vision or typing skill.
Auto Hot KEY is often used by people with handicaps.
Or people who nae lazy.
Automate your work with Autohotkey (CH Archives)
7106.

Solve : help delete old files?

Answer»

Hi everyone,
I am trying to do SOMETHING simple, but am having a hard time doing it.
I would LIKE to write a batch file that reads a drive and all subdirectories, then deletes all files OLDER than x days.
After the dir /s, what is the syntax for the if else statement?
thanks for the help!
Batch language does not do date CALCULATIONS. Unless you are prepared to write a BOATLOAD of IF statements to account for months of different lengths and of course leap years, you will need a Script for this.

Why did you not think that mentioning your OS would be relevant?

7107.

Solve : Stop Auto Boot in Dos??

Answer»

Guys,
I am running a flight simulator prog in DOS but the program AUTO boots and shuts down the pc on exit.

How do i STOP the auto boot???

cheers

martdpress F8 or F5 when the BIOS is done loading, and the DOS starts to load, if you hit it CORRECTLY, you can either skip you entire config.sys/autoexec.bat or you get the "fun" of answering yes or no to all lines in the two files.

When you are then in the DOS prompt, just edit your autoexec.bat (e.g. edit c:\autoexec.bat) - the gameload and SHUTDOWN commands should be the last two in the autoexec.bat... But that is something you should be able to figure out looking at the commands

7108.

Solve : Batch for for deleting files older than 20 minutes?

Answer»

Back in 2006 this code was post to this forum:

@echo off
setlocal

call :DateToMinutes %date:~-4% %date:~-10,2% %date:~-7,2% %time:~0,2% %time:~3,2% NowMins
for /f "delims=" %%a in ('dir * /a-d /b') do call :CheckMins "%%a" "%%~ta"
goto :EOF

:CheckMins
set File=%1
set TimeStamp=%2

call :DateToMinutes %timestamp:~7,4% %timestamp:~1,2% %timestamp:~4,2% %timestamp:~12,2% %timestamp:~15,2%%timestamp:~18,1% FileMins
set /a MinsOld=%NowMins%-%FileMins%
if %MinsOld% gtr 15 echo del %file%
goto :EOF

:DateToMinutes
setlocal
set yy=%1&set mm=%2&set dd=%3&set hh=%4&set nn=%5
if 1%yy% LSS 200 if 1%yy% LSS 170 (set yy=20%yy%) ELSE (set yy=19%yy%)
set /a dd=100%dd%%%100,mm=100%mm%%%100
set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2
set /a j=j/5+dd+y*365+y/4-y/100+y/400-2472633
if 1%hh% LSS 20 set hh=0%hh%
if /i {%nn:~2,1%} EQU {p} if "%hh%" NEQ "12" set hh=1%hh%&set/a hh-=88
if /i {%nn:~2,1%} EQU {a} if "%hh%" EQU "12" set hh=00
if /i {%nn:~2,1%} GEQ {a} set nn=%nn:~0,2%
set /a hh=100%hh%%%100,nn=100%nn%%%100,j=j*1440+hh*60+nn
endlocal&set %6=%j%&goto :EOF

This is still in "debug" mode, so after you have tested it to be sure it works the way you want it to, take the echo out of the line if %MinsOld% gtr 15 echo del %file%

I have recently just discovered it and wanted it for a bat file I need at work. I have not been able to GET it to work because mostly the "%%~ta variable is not recognized in the program. From a command prompt it works great and pulls the date/time stamp out of the file. Can any one offer some help to try and make this code RUN in a windows 7 environment. XP if that's what it takes. THANKS in advance.


If you provide it then the link may have more info about the formats of %date% and %%~t

It looks like the PC regional settings should have the time format set to 24 hour time.This will work on any pc from XP Pro and later to delete files older than 20 minutes. At the moment it will only echo the del command to the console.

Wmic removes regional differences so it will work in any world region, but it has problems with commas in filenames and will not do anything with such files, except to print an error message.

Code: [Select]@echo off
:: Wmic removes regional differences - it has problems with commas in filenames.
setlocal

for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"

set "stamp=%YYYY% %MM% %DD% %HH% %Min%"

call :DateToMinutes %stamp% NowMins

for /f "delims=" %%a in ('dir * /a-d /b') do call :CheckMins "%%~fa"
pause
goto :EOF

:CheckMins
set "filestamp="
set "filemins="
set "MinsOld="
set "YY=" & set "YYYY=" & set "MM=" & set "DD="
set "HH=" & set "Min=" & set "Sec=" & set "dt="
set "file=%~1"
set "filea=%file:\=\\%"
WMIC DATAFILE WHERE name="%filea%" get lastmodified | find "." >file.tmp
for /f %%a in (file.tmp) do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "filestamp=%YYYY% %MM% %DD% %HH% %Min%"
del file.tmp 2>nul

if not defined yyyy goto :EOF

call :DateToMinutes %filestamp% FileMins

set /a MinsOld=%NowMins%-%FileMins%
:: echo Now:%NowMins% File:%FileMins% Fileage:%minsold% "%~1"
if %MinsOld% gtr 1200 echo del "%file%"
goto :EOF

:DateToMinutes
setlocal
set yy=%1&set mm=%2&set dd=%3&set hh=%4&set nn=%5
if 1%yy% LSS 200 if 1%yy% LSS 170 (set yy=20%yy%) else (set yy=19%yy%)
set /a dd=100%dd%%%100,mm=100%mm%%%100
set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2
set /a j=j/5+dd+y*365+y/4-y/100+y/400-2472633
if 1%hh% LSS 20 set hh=0%hh%
if /i {%nn:~2,1%} EQU {p} if "%hh%" NEQ "12" set hh=1%hh%&set/a hh-=88
if /i {%nn:~2,1%} EQU {a} if "%hh%" EQU "12" set hh=00
if /i {%nn:~2,1%} GEQ {a} set nn=%nn:~0,2%
set /a hh=100%hh%%%100,nn=100%nn%%%100,j=j*1440+hh*60+nn
endlocal&set %6=%j%&goto :EOFI ran the code but I am getting this for this line of code:
----------------------------------------------------------------
WMIC DATAFILE WHERE name="%filea%" get lastmodified | find "." >file.tmp

No instances available
----------------------------------------------------------------

When I add /value and change the | with ^|
I get: Invalid Command

Also, would get creationdate work?

ThanksQuote from: petersoj on January 22, 2014, 10:40:04 PM

I ran the code but I am getting this for this line of code:
----------------------------------------------------------------
WMIC DATAFILE WHERE name="%filea%" get lastmodified | find "." >file.tmp

No instances available
----------------------------------------------------------------

Did you try it without any changes?

Quote from:
Also, would get creationdate work?

Yep.
Well, the file ran correctly without changes. Good call and thanks. I was trying to manipulate the code when it didn't need it. I thought the bat file couldn't reside in the same directory as the files being evaluated/deleted for >20 min.Thanks for testing it as written, and you are right that after 20 minutes the batch file age will include itself if the filespec is * or *.*

Replace this line with the following line to fix that issue.

Code: [Select]for /f "delims=" %%a in ('dir * /a-d /b') do call :CheckMins "%%~fa"
Code: [Select]for /f "delims=" %%a in ('dir * /a-d /b ^|find /i /V "%~nx0" ') do call :CheckMins "%%~fa"
7109.

Solve : zipping files with batch file?

Answer»

Hello. I'd like to create a batch file that uses Power Archive to zip 2 .txt files into one archive.
The name of this archive should contain the system date.

Can anyone help me on this issue ?

Thanks
LuisI have done this before, but it is a little involved.

First you should make sure that Power Archive has command line capability.

If that's good, then here is code that I used with pkzip some time ago:


Code: [Select]
@cls
REM @echo off
REM
REM Batch File Name:
REM SCHED_BACK.BAT
REM
REM Description:
REM Compress files and subdirectories on Development
REM into a file to be backed up.
REM
REM Functions:
REM 1) Calls Sched_back_date to set Sched_back_DATE variable
REM 2) Backup files using PKZIP
REM
REM PARAMETERS:
REM 1) Day of Week (Abbreviated - Mon, Tue, etc)
REM
REM
REM Modifications:
REM 16-Oct-1998 R. Willard initial version
REM 13-Aug-1999 R. Willard ADDED backup for Web directories
REM Backup file now contains day of week
REM
REM ========================================

...

CALL Sched_back_date

SET Sched_back_FILE=backup_%Sched_back_DATE%.zip

\Pkzip\pkzip25 -Add -Dir=specify %Sched_back_FILE% "\folders\files.txt"



This is how I set the date, you will want to make sure you have QBASIC to do this.

Code: [Select]
REM Batch File Name:
REM SCHED_BACK_DATE.BAT
REM
REM Description:
REM Sets sched_back_DATE environment variable for use in
REM Sched_back for naming the backup file.
REM
REM Functions:
REM 1) Writes basic COMMANDS to $sbd$.bas
REM 2) Run $sbd$.bas using Qbasic
REM 3) Builds $sbd$.bat which is called to set variable
REM
REM Parameters:
REM 1)
REM
REM Modifications:
REM 4-Nov-1998 R. Willard initial version
REM
========================================
REM
echo>$sbd$.bas open "$sbd$.bat" for output as #1
echo>>$sbd$.bas ? #1, "set Sched_back_DATE=";DATE$
echo>>$sbd$.bas done:close #1:system
qbasic /run $sbd$.bas
call $sbd$.bat
del $sbd$.ba?


Hope that is of some use. Can't believe I found this code on one of my many backup CDs.

7110.

Solve : batch and http?

Answer»

Hey Guys,

Im trying to refine a batch i got that pretty much loops http://192.168.0.%i% so i can see all the switches and firewalls on all my clients sites. its really annoying because you have to syphon through so many pages just to FIND like 3 switches.

what im looking for is a way to read a return status like page not found and autoclose that tab/page so im only left with online resources.

is this even capable with batch? or do i need to use vbs and handles?


help appreciated

Show us your batch file. It's unclear what you are doing.

You can loop through an octet and only open the IPs that RESPOND to a ping.ping wont help because its on a network with workstations so every ip is pretty much taken.

program is basic, heres some pseudocode

variable = 1
loop
http://10.1.1.variable
variable++
if variable = 255 goto end
goto loop

end
exit

if i use a ping and %errorlevel% it will still open webpage IP's that workstations use. its a good idea, im now thinking what about telnet onto port 80 and RESPONSE, ill do some research and see if it will return errorlevel but if you know the answer please post
You could use WGET to download the DEFAULT index.html and FINDSTR to search for a KEYWORD in the HTML file, such as 'Username'

7111.

Solve : How to program/set a certain key to turn on laptop from shut down or hibernate?

Answer»

Hi there,

Is there any way to program/set a certain key on an USB keyboard (BIOS excluded) - e.g Insert key - to turn on my laptop, when it's shut down, or when it's in hibernate state? My laptop operates on Windows 7 x32.

Thank you in advance.Almost certainly not. If it's shutdown/hibernated, the electricity is actually physically off. All that's on is the circuitry to the power button, which does exactly what you're describing -- to turn it on

Why use another key when there already is a key designed for that purpose?As I need more space on my table, because it's not a very large ONE , I thought to save some by placing the laptop under the table on a wooden support - a small improvisation attached to the table's feet, to say so. So, the height between the table and the wooden support assumes that the laptop's lid must stay closed.
If you say the electricity is physically off, I wonder how the power button on media keyboards work? Because, I think, it's not designed only for turning off the machine, am I right?
There's some technology called Wake-On-Lan which you can use to wake your computer over the network but only some network cards support it and you'd need another computer or some way to activate it.Quote from: secondsfromyourtime on October 09, 2012, 12:17:12 AM

If you say the electricity is physically off, I wonder how the power button on media keyboards work? Because, I think, it's not designed only for turning off the machine, am I right?

I've never seen a USB keyboard of any KIND with a power button (except possibly for macs, and who even knows how those work). I've seen them with sleep buttons, but wake-from-sleep happens on key presses with the right power settings anyways. I think you have a catch-22 here -- You need the laptop on for USB devices to work, but you need the USB keyboard to work in order to turn the laptop on.

Since this is a laptop, I'm guessing you're probably using wireless, and would you really want to have your wireless always-on so you could wake it up from another computer? Not to put ninjatex down or anything but it sounds a bit silly. (I CHECKED my computer and I can't enable wake-on-lan on my wireless adapter anyway)

Even if you can get the keyboard to work in some way, when the computer is off, the BIOS is the closest thing to software running, and it's not sophisticated enough to figure out which key you're pressing to turn the computer on.Use the Power switch...
Makes no sense you would need a keyboard switch for this...It would seem that you are using the laptop on mains power so battery life isn't an issue, and Windows can be set to leave a USB device powered permanently (instead of putting the ports to sleep) and in this case you can set the USB port/keyboard to be powered and should be able to resume from sleep or hibernation modes... maybe.Quote from: foxidrive on October 09, 2012, 08:35:24 AM
It would seem that you are using the laptop on mains power so battery life isn't an issue, and Windows can be set to leave a USB device powered permanently (instead of putting the ports to sleep) and in this case you can set the USB port/keyboard to be powered and should be able to resume from sleep or hibernation modes... maybe.

That's fine if he's in sleep (and maybe in hibernate, but i kindof doubt that one), but when he shuts down his computer? Maybe it's best if the OP just leaves the computer on and goes to sleep, but never as far as hibernate.Quote from: patio on October 09, 2012, 07:50:33 AM
Use the Power switch...
Makes no sense you would need a keyboard switch for this...
Quote from: patio on October 09, 2012, 07:50:33 AM
Use the Power switch...
Makes no sense you would need a keyboard switch for this...

He wants to leave the laptop closed and under the DESK, so he won't have access to the power switch; that's why he wants to do it with a USB keyboard. I think it's quite ridiculous myself...There is Wireless Wake-on-LAN (see http://technet.microsoft.com/en-us/library/ee851581%28v=ws.10%29.aspx) but yeah, it's for a pretty specific use case.There is a mode called hybrid sleep which acts like hibernation but will wake up as if sleep was used. I assume that a key press will wake it up from hybrid sleep if the BIOS options are set appropriately also, maybe after setting the USB KB to be permanently powered.

Quote

Sleep is a power-saving state that allows a computer to quickly resume full-power operation (typically within several seconds) when you want to start working again. Putting your computer into the sleep state is like pausing a DVD player—the computer immediately stops what it’s doing and is ready to start again when you want to resume working.

Hibernation is a power-saving state designed primarily for laptops. While sleep puts your work and settings in memory and draws a small amount of power, hibernation puts your open documents and programs on your hard disk, and then turns off your computer. Of all the power-saving states in Windows, hibernation uses the least amount of power. On a laptop, use hibernation when you KNOW that you won't use your laptop for an extended period and won't have an opportunity to charge the battery during that time.

Hybrid sleep is designed primarily for desktop computers. Hybrid sleep is a combination of sleep and hibernate—it puts any open documents and programs in memory and on your hard disk, and then puts your computer into a low-power state so that you can quickly resume your work. That way, if a power failure occurs, Windows can restore your work from your hard disk. When hybrid sleep is turned on, putting your computer into sleep automatically puts your computer into hybrid sleep. Hybrid sleep is typically turned on by default on desktop computers.
None of all you've said here didn't work, except one thing that I didn't knew to give it a go, it's what foxidrive said:

Quote from: foxidrive on October 10, 2012, 03:11:47 AM
There is a mode called hybrid sleep which acts like hibernation but will wake up as if sleep was used. I assume that a key press will wake it up from hybrid sleep if the BIOS options are set appropriately also, maybe after setting the USB KB to be permanently powered.


I've looked into BIOS too, but there weren't any settings to help, and that's because, I think, it's mainly a laptop, actually ASUS X50GL.Go into Win7 control panel > Power options
and used the advanced settings to ensure that hybrid sleep is enabled, and try it.It worked, so... thank you all, especially foxidrive. Have a nice day.
7112.

Solve : For loop with xcopy?

Answer»

I've got a directory with sub directories like this:
--1001
--1001
-----Bunches of files and dirs
--1002
--1002
-----Bunches of files and dirs
I want to MOVE the contents of sub-directory 1002 up one level, then delete the 1002 sub-directory folder.

Here's what I'm trying to do (pseudo code)

for each %VAR% in (or a text file with these dir's listed){
xcopy %var\%var %var /s /E
del %var/%var/*
}

This is the COMMAND that works:
xcopy 7614\7614 7614 /s /ce
The delete didn't work.

Your help is much appreciated.

Jake BTry using:

del /q %var%\%var%
rd /q %var%\%var%


Or better YET (delede the whole folder and content together):
rd /q /s %var%\%var%

Good luckThanks!

7113.

Solve : Batch asking for drive letter,...?

Answer»

Hi, hope someone can help me with this problem: which batch command must I USE so the program asks for input (I want to type in the letter of the mapped drive) and uses it to copy files to the specified location - e.g.: I plug in an USB stick (drive is mapped and provided with a drive letter), run the batch file, give input about the drive letter, program uses the correct path.
Thanks for any help - zast
It would have been helpful had you mentioned your OS. In general, for Win9x machines, use CHOICE. For NT machines, use set /p var=prompt. There are also 3RD party utilities (INPUT or ANSWER) that you might find on the Net.

Hope this helps. Sorry about the poor information - I'll TRY harder next time. But still I've managed
Thanx a lot - zast

7114.

Solve : bat scipt to input text from another file?

Answer»

im not very GOOD with this but can SOMEONE help me with the following. i'm trying to do something with mame arcade driver files. i have a text file names drivers.txt with words listed like below...

SNES_ClassicKong
C64_Artillery
C64_BadStreetBrawler
etc.

i need a batch script that would take these words and make another txt file outputting them like below...

ROM_START( SNES_ClassicKong )
ROM_END

ROM_START( C64_Artillery )
ROM_END

ROM_START( C64_BadStreetBrawler )
ROM_END


try
Code: [Select]for /f "delims=" %%A in (drivers.txt) do (
echo ROM_START( %%A ^) >>OutputFile.txt
echo ROM_END >>OutputFile.txt
echo. >>OutputFile.txt
)
worked pperfect thank you so MUCH. if dont MIND me asking what is everything in the first line doing. and thank you again

for /f "delims=" %%A in (drivers.txt) do (Quote from: daillest319 on October 09, 2012, 10:40:49 AM

worked pperfect thank you so much. if dont mind me asking what is everything in the first line doing. and thank you again

for /f "delims=" %%A in (drivers.txt) do (
From the FOR help.
Code: [Select]FOR /F ["OPTIONS"] %variable IN (file-set) DO command [command-parameters]

filenameset is one or more file names. Each file is opened, read
and processed before going on to the next file in filenameset.
Processing consists of reading in the file, breaking it up into
individual lines of text and then parsing each line into zero or
more tokens.If you need more info on for loops, type 'for /?' in cmd, to get a 3 page explanation on the different types and how they work.
7115.

Solve : Batch Script to Delete The Oldest Folder With a Specifc Name?

Answer»

I spent a little time on this one a can't seem to find exactly what I need. I don't have anything to OFFER because I'm truly stumped. I have 3 folders named like this:

Rox
Rox07122011
Rox09302012

These folders reside in a directory with many other folders. Via a batch script I want to be able to delete the "Rox" folder (and only the "Rox" folder) in this directory with the oldest Modified date but I don't know how to do it.

Please tell me how to do this.

Thank you,

MJ(untested) This will set folder to each rox* directory name in sequence from newest to oldest, and remember the oldest. Then the RD command is echoed to the screen

If it's right then remove the echo keyword.


Code: [Select]@echo off
for /f "delims=" %%a in ('dir "rox*" /a:d /o:-d /B') do set "folder=%%a"
echo rd /s /q "%folder%"
pauseFoxidrive.
/O:D is oldest FIRST. (So the newest will be the LAST out of the for loop)
/O-D is the newest first. (So the oldest will be the last out of the for loop)It would be great if people will realize that naming their folders with a date it is always best to use YYYYMMDD.
Not sure if we can guarantee that the date in folder name is actually the same as the modified date in the file attributes.
We could manipulate the folder names to a temp file and then sort it.Quote from: Squashman on October 12, 2012, 06:21:03 AM

Foxidrive.
/O:D is oldest first. (So the newest will be the last out of the for loop)
/O-D is the newest first. (So the oldest will be the last out of the for loop)

Thanks, I modified it to -d

It's not creation date though, and that could be what the OP wants.
This is the same thing but sorted by creation date.

Code: [Select]@echo off
for /f "delims=" %%a in ('dir "rox*" /t:c /a:d /o:-d /b') do set "folder=%%a"
echo rd /s /q "%folder%"
pause


And yes, foldernames with ROX-YYYYMMDD are certainly preferable to sort by.Thank you! Works like a charm. I appreciate it. It's inspired me to take it a step further. How can I run the loop against a text file that contains a list of servers?

Text file will include computer names:

Computer1
Computer2
Computer3
etc. . . .

Do I SIMPLY place the path to the text file in the parenthesis ("" ' dir "Rox*" . . . )?

Thanks again,

MJPerhaps I can nest the for loops like this:

Code: [Select]For /F "Tokens=*" %%I IN (textfile.txt) DO (
for /f "delims=" %%a in ('dir "\\<path-to-\Rox*" /t:c /a:d /o:-d /b') do set "folder=%%a"
rd /s /q "%folder%"

Will that work?
7116.

Solve : Need to echo two inputs to a batch program?

Answer»

Hi All,

i have a perl script which will prompt for two user inputs.. Y and Y..

if it is ONE Y then i can run using below command.

ECHO Y|perl test.plx

but as it prompts for twice i need your help finding out how to input those using echo or any other command..

i tried the following as well but no luck..

@echo off
>input.txt echo Y
>>input.txt echo Y
type input.txt|perl test.plx

But this does not work too.. It takes for the first input but for the second it runs into INFINITE loop. Please help

i am doing this in DOS prompt..

Thanks,
You might try
Code: [Select]@echo off
>input.txt echo Y
>>input.txt echo Y
<input.txt perl test.plx
This uses the input redirection operator, but if the script needs any other input, it definitely wont work

just thinking, does the script stop to prompt you to enter, then you press return or do you just press Y
if just Y, then
Code: [Select]echo YY|perl test.plxshould workI tried the first option.. it dint work

Script stops to take the input.. I will type Y and enter then it continues.. see below..


blah blah
do you want to upgrade(Y/N)?
blah blah
blah blah
do u want to continue(Y/N)?
blah blah


From your first code it takes Y for the upgrade and it continues.. when it ask for NEXT Y it goes into infinite loop.. Its not a code issue as i have removed the upgrade part and tried it and it works fine with one Y
2nd input its not recognising or taking it but runs into infinte loop like below..

do u want to continue(Y/N)?
do u want to continue(Y/N)?
do u want to continue(Y/N)?
.
.
.


Please help
Thanks,
Arun
It SEEMS that perl.exe does accept piped and redirected input.

The problem now is: why doesn't the script act on the subsequent characters?

To figure that out we'd need to see the relevant portions of the perl script.Quote from: foxidrive on October 12, 2012, 04:54:53 AM

we'd need to see the relevant portions of the perl script.

Agreed. Here is a simple perl script that accepts 2 inputs from STDIN (the keyboard) waiting each time for ENTER.

$userinput1 = <STDIN>;
$userinput2 = <STDIN>;
print "User input 1 $userinput1\n";
print "User input 2 $userinput2\n";
print "OK\n";

if I do this...

@echo off
echo X> test.txt
echo Y>> test.txt
<test.txt C:\Perl64\bin\perl.exe test.pl

I get this...

User input 1 X

User input 2 Y

OK

Noting that the .plx extension is commonly used on Windows systems to associate Perl files with the Perl interpreter so, if the association exists, we can actually do this

<test.txt test.plx






7117.

Solve : The handle could not be duplicated during redirection of handle 1?

Answer»

So i'm trying to WRITE a batch file that will write "0| | |#start" into a file called &%plist%.list where %plist% is a previous input.

here is what i have so far:
Code: [Select]setlocal EnableDelayedExpansion
set pg=1
set plnum=1

echo 0 ^| ^| ^|#start >>^&%plist%.list

pause

:loop
cls
title Lemomusic :: Make Playlistpg %pg%
echo q Back Page
echo.
set a=1


for /f "tokens=1-2 delims=|" %%A in ($mp3lib.txt) do (
if %%A EQU %pg%!a! echo !a! %%B
if %%A EQU %pg%!a! set /a a+=1
)
echo.
echo p Next Page
echo m Done
echo.
echo.
echo.

pause
...

I am getting an error when I get to the line 'echo 0 ^| ^| ^|#start >>^&%plist%.list' where it says 'The handle could not be duplicated during redirection of handle 1'.
I tried changing the redirect value to 2 as well as 0, but they both gave the same error. Did I miss an escape character or do I need a DIFFERENT type of redirect? Thanks in advance.Why do you want to use an ampersand for the beginning of the file name?Here is a WORKAROUND - add a leading character and then rename it after the echo statement.

Code: [Select]@echo off
set plist=abc
>>"a&%plist%.list" echo 0 ^| ^| ^|#start

ren "a&%plist%.list" "&%plist%.list"
Quote from: Squashman on OCTOBER 13, 2012, 10:42:49 PM

Why do you want to use an ampersand for the beginning of the file name?

Indeed. The ampersand is not called a "poison character" for nothing. Filenames with an ampersand (or a caret) are parsed OK when typed from the command prompt but if you try to drag-and-drop such files they need at least one space, otherwise you will find out about a long-standing bug in Windows drag and drop functionality. If a file path contains at least one space, then Windows automatically encloses the path in quotes so that it gets parsed properly. Windows should do the same thing if the file path contains & or ^, but it does not. This is true up to and including Windows 8. Also such filenames make batch processing more COMPLICATED and are usually avoided by experienced batch script writers.



I was using it for a sorting mechanistic, instead of jumping in and out of folders all the time, but any character past $ on the number line will do. ($ are my batch files.) Btw: I didn't know about the & and the command line stuff, Thanks.Quote from: Lemonilla on October 14, 2012, 08:23:59 AM
any character past $ on the number line will do. ($ are my batch files.)

A lot of people use the underscore character _

7118.

Solve : Is it possible??

Answer»

Hello guys, i just JOINED this site a few minutes but i have something bothering me; I would like to know if it is possible to create a chat on command prompts via internet. Thanks for your replyCommand Prompt does not support very MUCH networking.
It may be passable if you were to write a program (in a DIFFERENT language) that would retrieve the data from the internet and store it in a text based file for your batch SCRIPT to READ.

7119.

Solve : Small hard drive cloning?

Answer»

Not to clone, just to copy.

Is the syntax alright, then?

Just curious.

Quote from: rogerk8 on October 17, 2012, 10:21:03 AM

Is the syntax alright, then?

No-

from xcopy /?:

Quote
/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string
should be in a separate line in the files.
When any of the
strings match any part of the absolute path of the file to be
copied, that file will be excluded from being copied. For
example, specifying a string like \obj\ or .obj will exclude
all files underneath the directory obj or all files with the
.obj extension respectively.

So if you wanted to exclude the windows directory, you would need to put \windows\ in a separate text file, and specify that text file to xcopy.


FWIW this probably wouldn't work. Many files in the User profile are opened exclusively by windows (such as the registry data files), in addition to programs themselves having locked files*, as well as things such as the "System Volume Information", which will cause a permission error when xcopy tries to inspect it. Possibly the same story with the pagefile (which would be pointless to copy anyway). You can probably make a good sized text file, just with the list if necessary exclusions.


*It is a common misunderstanding that a program having a file open prevents it from being copied. It is fully possible for programs to open files in a shareable manner, but some programs are written lazily; essentially when opening the file the program has to say what other programs can do with it (read, write, delete, etc). If the program doesn't say anything about it, Windows takes the safe route and locks the file for the duration of the time the program has it open, and prevents other programs from accessing it.


From typing "help xcopy" in the XP-DOS prompt I got the same result (lazy of me).

But I like your answer.

And if I understand it correctly, the syntax (i.e order of switches) is still correct except for the specification of the excluded files.

But why would I need to put \windows\ in a separate text file? I don't even understand what you mean by this.

Reading the xcopy help tells me that it is actually possible to run:

xcopy c: e: /s /exclude \windows\

Because windows already is a root directory.

Best regards, Roger
PS
While I was testing and LEARNING about xcopy I discovered a fantastic thing. You were actually able to copy an open file! And windows sucks when it comes to that kind of SIMPLE and good features. When I discovered this I naively thought that it also could copy itself

Quote from: rogerk8 on October 17, 2012, 11:30:53 AM
And if I understand it correctly, the syntax (i.e order of switches) is still correct except for the specification of the excluded files.

But why would I need to put \windows\ in a separate text file? I don't even understand what you mean by this.
the /EXCLUDE switch is documented in /?- it specifies a list of files containing strings. The rest of the paragraph describes the format of the text file as well as how the strings within the file will be parsed and compared with each filename. eg. "When any of the
strings match any part of the absolute path of the file to be
copied, that file will be excluded from being copied. For
example, specifying a string like \obj\ or .obj will exclude
all files underneath the directory obj or all files with the
.obj extension respectively." is referring not to the strings provided on the command line, but rather how strings should appear in the text files specified in the /exclude switch.




Quote
Reading the xcopy help tells me that it is actually possible to run:
xcopy c: e: /s /exclude \windows\
Because windows already is a root directory.
/exclude is documented as accepting text files that contain strings, not the strings themselves. using the above will likely give you a message of the sort

Code: [Select]Can't read file, \windows\

0 File(s) copied

Quote
And windows sucks when it comes to that kind of simple and good features.
It has nothing to do with Windows itself. When an application opens a file, it is supposed to specify a "Share mode"; that is, how other programs can use that file while it's open. (whether other files can read, write, or delete it are separate, so a program could lock file writes but allow other programs to read the file while it has it open). If the program opens a file but doesn't specify a share mode, Windows decides that caution is the better part of valour and prevents Reads, Writes, and Deletes, effectively locking the file until the application closes it.

Another interesting point: some people occasionally have issues where Explorer.exe keeps a file open. This is not, however, Windows Explorer that is keeping the file open, but rather "Shell EXTENSIONS" which explorer loads. The result is that the shell extension, usually installed as part of a third party program, will open the file, but not specify a share mode, so the file get's locked; and then it never closes it. The result is that Explorer (which is the associated process) get's blamed. It's not really a bug in explorer, but a bug in an extension.

Quote
When I discovered this I naively thought that it also could copy itself

It works for me:

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

C:\Windows\system32>xcopy xcopy.exe C:\xcopy.exe
Does C:\xcopy.exe specify a file name
or directory name on the target
(F = file, D = directory)? F
C:xcopy.exe
1 File(s) copied

C:\Windows\system32>
My absolute favorite Quote of this entire 2 page Topic is from the topic starter...

Quote
I rest my case
Quote from: patio on October 17, 2012, 04:40:44 PM
My absolute favorite Quote of this entire 2 page Topic is from the topic starter...
resting one's case before putting forth the arguments that make it is an effective debate strategy. As long as nobody notices, I suppose.His quote...not mine.
But point well taken.Quote from: patio on October 17, 2012, 06:22:57 PM
His quote...not mine.
But point well taken.

Sorry, I was referring to it's use elsewhere.Have I understood you correcly BC_Programmer that if I just put the actual expression

\windows\

in a text file f.i called

excluded.txt

and store this in the root

I could run

xcopy c: e: /s /exclude \excluded.txt\

?

Actually, the number of folders in the root seldom are that many so you can actually copy them manually without that much of an effort

Take care!

Best regards, Roger
PS
Thanks for "I rest my case" (if I understand english correctly...)Quote from: rogerk8 on October 18, 2012, 01:35:52 PM
Have I understood you correcly BC_Programmer that if I just put the actual expression

\windows\

in a text file f.i called

excluded.txt

and store this in the root

I could run

xcopy c: e: /s /exclude \excluded.txt\


xcopy C:\*.* E:\ /exclude:\excluded.txt would likely be what you want.One final time.

While you indirectly have told me that the syntax in excluded.txt is right I could actually run:

xcopy C:\*.* E:\ /exclude: \excluded.txt

This is amazing!

Thank you very much!

Best regards, Roger
PS
The above command will then actually give me a simple backup. Without the commonly believed necessity of cloning.

The fun thing now is that you are still able to "clone" if this is what you prefere.

In that case, you should however make use of your (windows) istallation CD BEFORE the above.

Please tell me that I have understood this correctly.
Quote from: rogerk8 on October 18, 2012, 02:24:04 PM
The above command will then actually give me a simple backup. Without the commonly believed necessity of cloning.

I already mentioned some reasons this wouldn't work. It won't copy any hidden or system files (though that probably isn't desired) and it will encounter Permission errors trying to copy the registry data files in the active user profile. ANother common XCOPY problem when copying lots of files is that it encounters a Insufficient Memory error, which may be in part traced to longer file names (or possibly it creating lists of files to copy, or something to that effect).

Another option worth considering, if you insist on this methodology of using a batch file, might be Robocopy. I don't think it comes with XP, but if memory serves it is available through the windows Resource Kit.Please excuse me for being so stubborn

This is nowadays almost academic, but I am still curious.

If I use XP-DOS and have enabled all hidden files to be visible the above command will work, or will it not?

You don't have to answer this. It has no relevance anymore. People could just copy their visible root-folders by hand.

But it would be nice with a simple command to do that for you.

Thank you anyway for answering!

Best regards, RogerQuote from: rogerk8 on October 18, 2012, 03:32:13 PM
Please excuse me for being so stubborn

If I use XP-DOS and have enabled all hidden files to be visible the above command will work, or will it not?

No.

type this in a CMD prompt to find out why:

xcopy /?

7120.

Solve : I need to find a part of a text-file and displa...?

Answer»

I've WRITTEN a batch-file that PING a certain IP, and dump it to a textfile: "PINGRESULT.txt"
Now I WANT to make my batch-file continue, by finding the ping-result and displaying it in the same batchfile. (Right after it pinged the IP-adress)

I'm not very experienced with WRITING batch-files though, so does anyone have any ideas on how I could do this?

Thanks for replies What is your batch file?
Just ping ip >pingresult.txt or is ist in a for loop?

If you just want to display it:

ping ip >pingresult.txt & type pingresult.txt

uli

7121.

Solve : copy files from FTP path using windows scripting?

Answer»

Hi All

How can i COPY FILES from FTP to my local drive using windows scripting?

Regards
Deepa

7122.

Solve : How Do I Run CMD Hidden..???

Answer»

when you call "CMD.EXE /C CALC.EXE" is there any way to hide the CMD window without use of shortcut files ect.?

is there a switch to use CMD.EXE in silent/Hidden mode or something..??Why do you ASK?
Often this question is asked by evil hackers who want to pull a bad joke on SOMEBODY. instead of running cmd hidden...

why not- not use cmd at all, and just run calc directly?can cmd.exe be ran hidden or not..??Quote from: gumbaz on May 18, 2010, 02:40:15 AM

can cmd.exe be ran hidden or not..??

well, aren't we snappy.meh, just want an answer, not the 3RD degree questionings..Quote from: gumbaz on May 18, 2010, 02:43:56 AM
meh, just want an answer, not the 3rd degree questionings..
Yes it is possible.and you wouldn't mind sharing that precious knowledge with me would you, good ol buddy ol pal..I have crossed swords with gumaz before, when I was Dias de Verano. He has no idea of courtesy.

gumbaz, this is the way to get no answers:

Quote
can cmd.exe be ran hidden or not..??
Quote from: gumbaz on May 18, 2010, 02:50:27 AM
and you wouldn't mind sharing that precious knowledge with me would you, good ol buddy ol pal..
In fact, I'd rather not share that knowledge, and I have a good idea that neither will BC.Yes bro it is possible to run cmd in hidden use "QUICK BATCH FILE COMPILER"

in this compiler u find a ghost run option in option. so just click there a compile and En JOY !

I HOPE U NOT MAKE ANY BAD USE !!!!!!>....Use a .vbs file to run your batch file. Example:

HideBat.vbs
Code: [Select]CreateObject("Wscript.Shell").Run "FILE_1.bat",0,True
"FILE_1" change to name of your .bat file, that you wish to run hidden.




*************************
or
http://www.ntwind.com/software/hstart.html
http://gallery.technet.microsoft.com/ScriptCenter/8bbed56f-a7aa-491f-a296-687dd96098a3/The vbs isn't hidden, however.
Graveyard post. The OP might be dead by now.


cmdow can run a task silently - some AV programs flag it as a threat because of that.
7123.

Solve : File Size Handling in Dos?

Answer»

Need Dos Batch script code for handling file size. Need way to obtain file size compare it and then goto copy mode 2 different directories.Why is it that poster's refuse to disclose their OS? Is it some kind of state secret?

Code: [Select]
for /f "tokens=1-4" %%a in ('dir /-c ^| find /i "filename.ext"') do (
if %%d GEQ nnnn (copy A B) else (copy A C)
)


nnnn = file size
filename.ext = file you're checking
A = source file
B = target file
C = different target

Good luck. Windows 2000 v.5.25 OS
Have the following code
that does return the file size but it is not EVALUATING to continue on to the copyNIS part

it is only supposed to continue if value is not null
want process to stop and not copy if file size is zero
===================================
SET HZmw_DATA=F:\INETPUB\FTPROOT\FTPmw\
SET HZmw_SCRIPTS=e:\SOFTWARE\PEPSI\MW\SCRIPTS\
SET HZmw_LOG=F:\DATA\PEPSI\mw\LOGS\
SET HZmw_BACKUP=F:\DATA\PEPSI\MW\BACKUP\


Echo Copy %HZmw_Log%HZmw.LOG to %HZmw_BACKUP%HZmw.log >> %HZmw_Log%HZmw.LOG
Echo. >> %HZmw_Log%HZmw.LOG
Copy %HZmw_Log%HZmw.LOG %HZmw_BACKUP%HZmw.log
Echo Copy %HZmw_Log%mwcalc.LOG to %HZmw_BACKUP%mwcalc.log >> %HZmw_Log%HZmw.LOG
Echo. >> %HZmw_Log%HZmw.LOG

Copy %HZmw_Log%mwcalc.LOG %HZmw_BACKUP%mwcalc.log

IF EXIST %HZmw_Log%HZmwBAT.ERR GOTO Failure

:CKNIS

ECHO Performing CkNIS in Horizon MW >> %HZmw_Log%HZmw.LOG

ECHO Checking for NISHMWP file and size >> %HZmw_Log%HZmw.LOG

SET local=size
call :getsize "F:\inetpub\ftproot\ftpmw\nishmwp.txt"

goto :EOF

:getsize
Setlocal
set /size=%~z1
echo %/size% >testNIS.txt


if (%size% == NULL) echo an error has occurred with the filesize %HZmw_DATA%NISHMWP.TXT to %HZmw_BACKUP%NISHMWP.TXT >> %HZmw_log%HZmw.LOG
rem mem /d | find "nishmwp.txt" == NULL
if errorlevel 1 GOTO CopyNIS

rem mem /d | find "nishmwp.txt" > null
rem if errorlevel 1 GOTO CopyNIS

ECHO Exiting out of cknis >> %HZmw_log%HZmw.LOG
ECHO. >> %HZmw_log%HZmw.LOG


===============================================================

:CopyNIS
Echo ATTEMPTING to Copy %HZmw_DATA%NISHMWP.TXT to %HZmw_BACKUP%NISHMWP.TXT >> %HZmw_log%HZmw.LOG
Copy %HZmw_DATA%NISHMWP.TXT %HZmw_BACKUP%NISHMWP.TXT
If Errorlevel 1 echo an error has occurred in copying %HZmw_DATA%NISHMWP.TXT to %HZmw_BACKUP%NISHMWP.TXT >> %HZmw_log%HZmw.LOG
ECHO successful copy >> %HZmw_log%HZmw.LOG
ECHO. >> %HZmw_log%HZmw.LOG

:EOF




=================
Quote

Why is it that poster's refuse to disclose their OS? Is it some kind of state secret?

Code: [Select]for /f "tokens=1-4" %%a in ('dir /-c ^| find /i "filename.ext"') do (
if %%d GEQ nnnn (copy A B) else (copy A C)
)

nnnn = file size
filename.ext = file you're checking
A = source file
B = target file
C = different target

Good luck.

NULL is not a CMD processor keyword. CMD will SEE NULL as a literal and %~z1 will presumbably resolve to a numeric value. The chance of a equal compare are pretty slim.

You MAY want to add a not exist test for %1 in the getsize routine to error out; otherwise any subsequent compare with %/size% will fail.

Note: One line SETS the /size variable, but another checks the size variable. They are not one and the same.


Hope this helps.
7124.

Solve : How to do BATCH FTP?

Answer»

Please Help Me... I am a newbie. I have two windows servers, and I want to transfer files automatically from server 1 to server 2. Which server will I install the IIS? What script can I use to transfer files? Which server will I run the script? Please help me,You don't need IIS or ftp to trasfer files between servers if they are on the same network. You can use any of the copy commands builtin to windows to do that. Copy, Xcopy or Robocopy.I'm so sorry, I am really new to this things, can you please let me know how to do any of those, thanks so much.Here is an example:

Code: [Select]copy /b "\\server1\share\*.MP3" "\\server2\share\"
where server1 is the computername.

in place of \\server1\share you can use the servers IP address such as "\\192.168.1.10\share"Thanks so much, it really works great.
I have one more question please, Can I pass through a firewall switch (CISCO), and at the other end is another server but in DIFFERENT DOMAIN?
Please let me know, thanks so much...Quote from: ismael on October 20, 2012, 05:58:07 PM

Thanks so much, it really works great.
I have one more question please, Can I pass through a firewall switch (CISCO), and at the other end is another server but in different domain?
Please let me know, thanks so much...
That is BEYOND the scope of this FORUM category.
7125.

Solve : Numerical Overlay?

Answer»

Good Afternoon,

Is there a way I can use a batch file to project our gaming clan's logo (Transparent png file called "deadicated.png") to the screen on top of any and every THING that is displayed. We are all going to a lan competition and thought it would be cool if we all had our logo on our screens. It would need to toggle on and off so we can get rid of it if it interferes in a game or match. The people hosting the lan said it is ok as long as we provide the source code to them for examination.

Thank you in advance.

ChadNot with a pure native batch file. You would need some 3rd party utility to do that or write your own program.Thank you Squashman.

My programming skills outside of VBA are pretty pathetic. However I did manage to make a program to project my png file to the screen always on top using C++.

my program for this is called deadicated.exe

Is there a way I can program a batch file to activate and suspends that executable upon a CERTAIN keystroke rather than using a start/taskkill approach?
Toggling on and off using C++ didn't agree with my novice nature.

Here is what I am thinking for a finished PRODUCT. It doesn't need to be fancy it is just going to be used when we are a Lan events to look cool.

Step 1. run deadicated.exe to project clan logo onto screen.
Step 2. Using a batch file that is compiled into an exe to pause/resume or start/kill deadicated.exe at keystroke "x"
step 3. Because the batch file is compiled into an executable we can ADD that executable to our Nostromos (gaming control pad) profile and set a button to x.
In this way we can easily turn our logo off when competing or if it gets in the way during our idle time.

This is my first go at it but it doesn't work yet.

Code: [Select]@echo off
set /P dest="Enter URL:"
if %dest% EQU x (
TASKKILL /F /IM deadicated.exe /FI STATUS ne RUNNING
exit
) else (
start deadicated.exe param1
exit
Thanks for any help,

Chad


Thanks,

Chadbatch cannot do real time anything really but if you are binding the file to a gamepad button, why do you need to have the batch file read the keystroke?

'Choice' and 'set /p' are your only choices here, and you have to have the batch file selected for either to work.Lemonilla,

Thank you for your reply. I think you may be right. My hope was that after I compiled the batch into an executable I would be able to make a real time function.

Ultimately I think that my love of computers now exceeds my actual capabilities with them.

I thought that if I tinker a lot I would pick the skills up but I am beginning to realize that I will need to start from Falken's Maze.
I am going lock myself in my room for a year and curl up some "how to" programming books. It looks like for my needs Autoit would be a good choice. Hopefully with it's basic like syntax some of my meager VBA skills will cross over.

Thanks,

Chad

7126.

Solve : error 35 general protection?

Answer»

Hello everyone, I just REGISTERED, I hope to post in the right place So I start a setup.exe file that tells me erroe [35] general protection FAULT in setup.exe 0097:4 C58 code 0000 SS 0087 ds 0087 as 0107
Ax bx cx dx 9050 9050 0117 1301 sp 136c is 137 bp 0117-0156 in DOS 6.22

Is there a way to fix this?

thanksRun Memtest from a BOOTABLE cdrom/usb/floppy and see if your RAM passes.

7127.

Solve : run two programs?

Answer» HI i want to RUN TWO PROGRAMS the problem that the second programn ot start until i CLOSE the first one

bat file:
--------------
prog1.exe
prog2.exe

-------------
i need to close first , and what if i want to run in more tiomes simultnniosly
7128.

Solve : changing multiple filenames in DOS??

Answer»

Hello,

I’ve got a directory of files with timestamps, which I need to erase the timestamp (I will need this putting in a BATCH file as I generate over 1000 of these files a day because of a TEST driver I’m using)

Examples of these files are:
2014-01-20-Testing_1_200.txt
2014-01-20-Testing_2_400.txt
2014-01-20-Testing_3_400.txt
2014-01-20-Testing_4_200.txt
2014-01-20-Testing_5_200.txt

Can anyone specify some DOS code I can put into a batch which would get rid of the timestamp and leave the file like: Testing_1_200.txt? Erasing the timestamp?

Thanks,
The Test this:

Code: [Select]@echo off
for /f "delims=" %%a in ('dir *.txt /b /a-d ') do (
for /f "tokens=1,2,3,* delims=-" %%b in ("%%a") do (
ren "%%a" "%%e"
)
)Hello,

Thanks for that reply,

But please could you explain how i can modify that so it will WORK with my files? I've put an example of the folder below:
. 2014-20-01-Testresults_1.txt
. 2014-20-01-Testresults_2.txt
. 2014-20-01-Testresults_3.txt
. 2014-20-01-Testresults_4.txt
. 2014-20-01-Testresults_5.txt

Thanks, The code Foxidrive GAVE you should work just fine.

Code: [Select]H:\temp>dir /b *.txt
2014-20-01-Testresults_1.txt
2014-20-01-Testresults_2.txt
2014-20-01-Testresults_3.txt
2014-20-01-Testresults_4.txt
2014-20-01-Testresults_5.txt

H:\temp>Multirename.bat

H:\temp>dir /b *.txt
Testresults_1.txt
Testresults_2.txt
Testresults_3.txt
Testresults_4.txt
Testresults_5.txt

H:\temp>Thanks very much - I look FORWARD to trying this out tomorrow.

I'm fairly new to DOS and working with Batch files, I look forward however to increasing my knowledge!

7129.

Solve : Using if statement in batch file?

Answer»

Hi!
I need to add if statement in my batch file so that it checks for the file first. if it exists then it should LAUNCH it if it does not exists then it should launch another application.

How would I go about writing the code for this? The following represents what i want but don't know how to do this in the batch file

if (check for the A.txt)
{
launch A.txt
}
else
{
launch B.txt
}

Any help would do it.
PLEASE REPLY ASAPI FIGURED it out.

Sorry for the trouble
Hi, I need to do the same thing how did you do it?IF NOT EXIST A.txt GOTO LAUNCH B
launch A.txt
GOTO END

:LAUNCH B
launch B.txt
GOTO END

:END
echo FINISHED.

7130.

Solve : DOS command to connect a given adapter to a specific wireless network?

Answer»

Is there one or more DOS-level command(s) to switch from one wireless network to another?

The SSID of the target network is predefined. I'd like to duplicate the pop-up menu item function "VIEW available wireless networks" when clicking on the connection icon in the system tray. (without requiring user interaction).

Thanks in ADVANCE for your time and consideration,Can you clarify the task?

Do you WANT to present a list of the available wireless networks and have a keyboard entry to select one?For my purposes, a list would be "above and beyond". For now, the command(s) (given the network desired) would be sufficient.

7131.

Solve : Need a batch script to find and replace values in all files in folder/sub-folder?

Answer»

Hello,
I am new to batch scripting. I need a complete batch script to find (set of given values) and REPLACE them with new values in all the files in the folder and sub folder. PLEASE help .

The files might not be .txt always.

Sample file content:

./adt_btth/cfg/wf_btth.cfg:$BadFile_1=/atadata/ipm/adt_btth/badfiles/VSYM_PROD.bad
./adt_btth/cfg/wf_btth.cfg:$PMSessionLogFile=/export/home/ipm/adt_btth/logs/sessions/s_concate_usoc.log

(STRING in bold above needs to be replaced with new path.

New Value will look like:

./adt_btth/cfg/wf_btth.cfg:$BadFile_1=/Info_new/Info/NDW/badfiles/VSYM_PROD.bad
./adt_btth/cfg/wf_btth.cfg:$PMSessionLogFile=/home/logs/info/NDW/logs/sessions/s_concate_usoc.log

There will be many such lines in one file and then many files in a folder and subfolders.

Please help. Please let me know if i should give more information here.
You said please help.
When I have had to replace text in a set of files. I use a tool that does well with string manipulation. Yes, you could do it it batch, but fif batch is hard for you, pick another tool.
Consider this outline.
----
For every file, DO this ---
replace every INSTANCE of A$ in the file with B$
until done.
----
where A$ represent s group of letters in the file and B$ is the replacement value.


Batch files are good for making jobs for other programs. Such as making a list of files. However, if you really want it all in batch, just wait here. An expert will show up soon.


JFTR The QUESTION is multi-posted

http://www.dostips.com/forum/viewtopic.php?f=3&t=5308Thanks for your reply but i need to use a batch script (.bat) and not any tool.

7132.

Solve : Adding a counter to FOR loop?

Answer»

I am TRYING to make a script to update a mac address for a device, i used the following

SET /A n=1
FOR /F "delims=" %%G in (mac.txt) do (
set /A n=n+1
Echo the value of n is: %n%
plink.exe -ssh [emailprotected] -pw password ethtool -E eth0 offset %n% value 0x%%G
)


this FOR loop run for 6 times to taking the value of TH emac address from a file mac.txt and put it in the Plink command, this is working fine.

My problem is i cannot figure out how to change the value of n to increment from 1 to 6, the value of n is always set to one, during running this script only the first byte of the mac address change 6 times because n value stay 1.

Another question, is there a way to put the mac address in the FOR loop instead of taking it from the text file?

Thanks,You need to use delayed expansion and the !VARIABLE! syntax instead of %variable%Thanks for the quick respond, but I am not sure what do you mean?
I am new in Patch file and do not know what "Delay Expansion" mean?Code: [Select]setlocal enabledelayedexpansion
set /A n=1
FOR /F "delims=" %%G in (mac.txt) do (
set /A n=n+1
Echo the value of n is: !n!
plink.exe -ssh [emailprotected] -pw password ethtool -E eth0 offset !n! value 0x%%G
)It work the way I want.
This is a new piece of information fro me.

Thank you.

7133.

Solve : Batch file error?

Answer»

OMG! I have seen some pretty poorly written batch files but this just became #1 on my list of worst batch code I have ever seen.Here's a version of your batch file which is EASIER to debug, while still allowing individual shutdown and offline messages.

There is only one section at the bottom which does the actual work - and that section is called with the individual settings and messages.

[recovering disk space, attachment deleted by admin]Quote from: Salmon Trout on January 17, 2014, 09:46:37 AM

Round about line 17,795 the label names and workstation numbers seem to get out of step....

There is a set of stations which are processed as a set, and several of those.

Quote from:
Nobody is going to be able to debug this.

I had a go. Using a sed tool and extracting the essential bits and reformatting it, adding some IFs to the working bit. Foxidrive I commend you for tackling this, especially since the mood you have been in lately. Did you win the lottery down there.Quote from: Squashman on January 18, 2014, 06:55:16 PM
Foxidrive I commend you for tackling this, especially since the mood you have been in lately. Did you win the lottery down there.

YES!!! Last night. $18.85

The code could be simplified further - there are settings for times that could probably be all using one figure, but I left the operation mostly alone.

In the stations that are processed as one set, each subsequent PC in the set gets an extra second delay to shutdown, for no good reason that I can see.
PC one gets 10 seconds delay and PC ten gets 20 seconds delay.$18.85 ! ! !

Dinner's on foxidrive !

And Kudo's to you guys and the work you do here in the batch section...lemonilla you squash Salmon etc. etc....I agree with you on the shutdown time. I see no reason for that.Thank you all Dear brothers, that' is not about the employer,
but about me where I want to Make a better place for myself among my colleagues and I'm trying to make a program abbreviated time and effort to gain access to network devices and deal with them instead of dealing with the ready-made programs that make us, we look for every time device computer and then press right click then CHOOSE connect then restart
i want to do this in one step, It's write their hostname, and then press Enter
And as you said Squashman my way in write this batch file is pretty poorly i'm just beginner but i will try and try many times till be my batch is the best in use
Moreover,you should help and teach me better than laughing of me.

thanks for all
special thank for foxidrive for your best;

And if any one has any soft COPY information about Batch's learning PLEASE, send it to me and i'll try to do all my best
Quote from: Abo-Zead
And if any one has any soft copy information about Batch's learning please, send it to me and i'll try to do all my best

Try looking at: http://ss64.com/nt/
That's the site I used to learn batch.

Quote from: patio on January 19, 2014, 07:18:55 AM
And Kudo's to you guys and the work you do here in the batch section...lemonilla you squash Salmon etc. etc....
It took me over 15 minutes to figure out you didn't mean that I was squishing Salmon with something...

Quote from: Lemonilla on January 19, 2014, 02:42:18 PM
It took me over 15 minutes to figure out you didn't mean that I was squishing Salmon with something...

With what might you have been squishing me? (Do I want to know?)
You can learn a lot by participating in forums like these. Read the threads and learn from them and eventually you will be answering questions instead of asking questions. Dostips.com also has plenty of tutorials as well.
7134.

Solve : DATA TRANSFER PROBLEM?

Answer»

I have an old computer whith a floppy and a HD 20MB, running MsDos 3.30.
And i also have a P3 1GHz running Windows XP.

The problem is that when i write any files on a 3.5" disk with my XP PC, and then try to read these files with my old pc, i get an "error reading drive a".

But when i format the same disk whith my old pc, then i can write and read to/from the disk everything ok.

And then when i PUT the disk to my XP pc, the drive after a long time of trying stopes and i get the window : "disk in drive a: is not formated. Format it now. y,n".
Why is this happening?
Why isn't there any compatibility?
How can i TRANSFER some files srom my XP pc to the old one?
Thanks!Is it possible your elderly system is formatting 720kb size rather than 1.4mb. Your Dos.3.3 machine possibly has a real old floppy drive.

I don't have Dos.3.3 so can't fire it up to try but here's an extract from http://www.cknow.com/tutorcom/dos07_format.htm

"""With the introduction of 3.5" drives, higher versions of DOS are required to correctly support the new formats. The 3.5" drives come in two sizes: 720K and 1.4MB.

Unlike the 1.2MB/360K drives disks, it is possible to format to 720K in a 1.4MB 3.5" drive. All you have to do is tell the FORMAT command the track/sector combination you need:

FORMAT A: /F:720 (this tells DOS to format the disk in drive A: to 720K)

Not all versions of DOS support higher capacity disks. For example, DOS 3.2 introduced support for 3.5-inch disks, but only at 720K format. In order to format a 3.5-inch disk at 1.44MB you will need DOS 3.3 or later."""

Can't suggest any method of transferring files from XP to Dos 3.3 except that Dos 3.3 might support a 1.4mb floppy drive if you have a spare handy, then at least the drives will be compatible.

Good luckThank you for the answer and those realy useful info!

Well... i found out that using a floppy disk that i have been keeping all those yaers, made that possible!
My xp pc reads it ok and i can also write on the disk and read the files ok from the old pc.

Yes, that old pc of mine has a really old floppy drive.
The floppy drive doesn't EVEN have a power supply cable! It takes the power it needs from the communication cable!

Also comparing the old floppy communication cable with the new on my XP pc, i found that the new one has more 4 PAIRS of pins! So i've been wondering.. would it be possible to replace that old drive with a new one?And how?

Also, the old hard disc's IDE communication cable differs from the new one's, as it doesn't have that "blind" pin somewhere in the midle so it doesn't fit. What can i do to INSTALL a new hard disk drive?
Also an ms-dos upgrade to a newer version is really needed.
Thank you!Whew, wot a task you have set yourself!!

Your very last point is easiest to answer although you haven't mentioned which processor you are using in the older pc or how much ram is installed. You might be able to upgrade to MSDos 6.22 or even 7.10 and I better mention FreeDos - all are available on the WWW - but you will have to ensure that your can go back to 3.3 if the install turns to custard.

As for the pinning & power supply - I am told that connecters are available (can't find out where). I would have to actually inspect the drives to advise on that.

Sorry - I can't be of more help - perhaps if you browse the Internet for a while some ideas might jump out at you

Good luckHi-- I have data on an old 5.25" floppy (DOS, Norton Textra) which I want to transfer to a 3.5" disk(Windows XP, Microsoft Word). Could you recommend an outfit that could do this for meor how I might proceed? I can still read and write on the floppy with the ancient computer. Thanks for any help or suggestions. --Jim

7135.

Solve : Set Path from cmd line?

Answer»

Hello ,
i want to set a path by using the set command in winxp from commandline, say i want a folder named uha in c drive: something like this c:\uha. How should i do it. Also few questions, like whether it is permanent or temporary, and if permanent how can i remove it from the path.Please help..

Thank you. You can add a folder to the %PATH% environment variable like this

set path=%PATH%;c:\uha

or if you prefer

set path=c:\uha;%PATH%

It will only be temporary, until the command session is ended. Other command sessions opened separately will not see the change.


If you want to completely replace the %PATH% variable you WOULD do this

set path=c:\uha

but be prepared for many commands and utitlities to not work.

If the folder has one or more spaces surround it in quotes.




Quote from: Salmon Trout on October 19, 2012, 01:09:56 PM

You can add a folder to the %PATH% environment variable like this

set path=%PATH%;c:\uha

or if you prefer

set path=c:\uha;%PATH%

It will only be temporary, until the command session is ended. Other command sessions opened separately will not see the change.


If you want to completely replace the %PATH% variable you would do this

set path=c:\uha

but be prepared for many commands and utitlities to not work.

If the folder has one or more spaces surround it in quotes.

Thank you Salmon, that was great, now i can set path to any folder from the cmdline.Too bad its not permanent.Quote from: Floppyman on October 20, 2012, 12:43:04 PM
Too bad its not permanent.

In XP you can do that like this

Right-click My Computer, and then click PROPERTIES.
Click the ADVANCED tab.
Click Environment variables.
Click the Path variable
Click Edit to change its value, adding your folder to the start or end, using a semicolon as separator as I showed above.
Then keep clicking OK buttons to go right back out









For Win 7 and Vista?, and when using the resource kit in XP there is a command called SETX which will set a variable in the master environment from the command LINE, too.Thank you Salmon, but i know the second way i.e., from My Computer and then properties, i just wanted to know from the command line . Any ways this site is great, great place to share knowledge.

Thanks once again.Quote from: Floppyman on October 21, 2012, 12:23:58 PM
i just wanted to know from the command line

As foxi said, setx.exe is the command line tool

Windows XP Service Pack 2 Support Tools

http://www.microsoft.com/en-us/download/details.aspx?id=18546

7136.

Solve : Change my MAC address via batch file...?

Answer»

I want to do this every 30 minutes or so.
Create a mac address random and disable the network adapter and then enable the network adapter for the mac address change to take.
Any ideas?
Thanks. Why do you need to do this?
I change it now freq.
Manual is a pain if I can make it auto.

I used to buy network CARDS monthly, SWAP them out with the new and throw the old ones out.
I run a game server.
Uncomplicates my life.Try this

You need to change a registry key like so

reg add HKLM SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0001] /v NetworkAddress /d 0123456789AB

Replace 0001 with your interface number and 0123456789AB with desired network address.

Next, disable and enable the network card

Subsitute the actual network connection name if it isn't Local Area Connection.

netsh interface set interface "Local Area Connection" DISABLED
netsh interface set interface "Local Area Connection" ENABLED

You didn't say what Windows you are using. I think the netsh part may not work on XP and earlier.

win 7.
Thank you.You really must be sure you know what you are doing before you mess with the registry. It sounds like a working network connection is important to you (as it is to most PC users these days) so give yourself a route back - backup registry, take a note of the subkeys under that registry key etc.

7137.

Solve : Copy Doc files from Documents and Settings folder !!!?

Answer»

Hello agian,
i want to MAKE two batch file to copy all the doc files from my Documents and Settings folder, thier are many doc file i usually make and some materials from the net i download: they are scattered haphazardly in My Document folders sometimes in my download folder within My Document folder and sometimes i usually paste or save them in C: root directory.
So i want to make two batch file that will copy the doc file from the Documents and Settings folder to say F: and the second batch file to copy from C: to F:
Hope it is uderstood. I am assuming the second one would be difficult since C: also contains a huge collection from other program folder as WELL , i wouldn't mind if the doc file of other programs folder are also copied.


Thank you in advance. I believe this will work:

Code: [Select]CD C:\Documents and Settings\
XCOPY *.doc F:\ /S
CD C:\
XCOPY *.doc F:\
Quote from: John_L. on October 21, 2012, 07:28:41 PM

I believe this will work:

Code: [Select]CD C:\Documents and Settings\
XCOPY *.doc F:\ /S
CD C:\
XCOPY *.doc F:\

Hello John, i did as you did and gave the path right except i wanted the doc files in c:\Document and Settings\My Documents\ and c:\Document and Settings\My Documents\downloads to copied on f: it didn't work. Sadly, however i came up with a solution and gave this command:
Code: [Select]@ECHO off
xcopy /y "%userprofile%\Desktop\*.doc" f:
xcopy /y "%userprofile%\My Documents\*.doc" f:
xcopy /y "%userprofile%\My Documents\Downloads\*.doc" f:This worked like a charm every doc file containing in My document and Download folder as well as the Desktop got copied in F:

To go a step further i went and gave the same command and replaced the *.doc with *.txt in another line and it copied the txt file as well.
Code: [Select]@echo off
xcopy /y "%userprofile%\Desktop\*.doc" f:
xcopy /y "%userprofile%\My Documents\*.doc" f:
xcopy /y "%userprofile%\My Documents\Downloads\*.doc" f:

xcopy /y "%userprofile%\Desktop\*.txt" f:
xcopy /y "%userprofile%\My Documents\*.txt" f:
xcopy /y "%userprofile%\My Documents\Downloads\*.txt" f:
Anyways John thanks for trying to HELP, i just saw the environment variable that was set for Document and Settings folder along with the user. From their it was all good.

p.s: PATTING myself. Good work. You can use a for in do loop to copy multiple filespecs, like so:

Code: [Select]@echo off

for %%a in ( doc txt swf ini avi mp3 ) do (

xcopy /y "%userprofile%\Desktop\*.%%a" f:
xcopy /y "%userprofile%\My Documents\*.%%a" f:
xcopy /y "%userprofile%\My Documents\Downloads\*.%%a" f:
)
7138.

Solve : saving?

Answer»

My windows ME won't boot.
Can i save my important files from DOS? if so, how?
Thanks!more info on pc used.What kind of info do you need?What have you TRIED so far?

Safe Mode? Dos BOOTDISK? Reinstall ME?? The only thing that got me to boot in DOS was using the Dell Dimension Resource CD.
It has a system diagnostic tool and that got me to DOS.
I have tried lots of things to attempt to get the system to boot.
But now i'm just TRYING to save the info and then I can MAYBE reformat.

7139.

Solve : Batch File save?

Answer»

I am looking for HELP in CREATING a batch file that will save a single file to multiple folders.

For example I WANT to work on a SPREADSHEET, save it in a location and then have that spreadsheet copied out to multiple folders.

Can anyone help me?
::when the batch is CALLED save.
save spreadsheet

xcopy %1 folder1
xcopy %1 folder2
...


When you want it copied when you use the save button in your application you need a macro, not a batch file.

hope this helps
uli

7140.

Solve : Compare Lines Within a Text File?

Answer»

Hello,

I'm needing some help constructing a batch file which compares some preexisting hashes.

The hashes are in a text file, ONE per line, with the hash first, followed by a single space, followed by the filename. e.g. 7CD182468A6D54348C212231F27E997D file.ext
The filenames are enumerated, starting at 0. e.g. 0.ext 554.ext 3251235.ext
Inside the text file there are 3 hashes with the same number. Their filenames are prefixed with an A, B, or C. e.g. A3251235.ext B3251235.ext C3251235.ext

Is it possible to use a batch file to compare each set of 3 hashes?

I have one other option in how these hashes can be stored. Instead of having the same number 3 times in a single file(prefixed as in the example above)--I have the means to have 3 separate text files. If I use this METHOD, the prefixes would not need to be used.

Any insight into how to get started with this would be appreciated.
Thank you.Do you mean that you have a bunch of hashes + filename in a text file, and mixed in with them at any three line numbers are three filenames which are the same, except for a leading A/B/C in the filename.

You want to extract these three and compare the hash value to see if they are the same? Is that it?


Or are there only three hashes in the text file?That's it.

Well, every hash+filename is part of a group of 3. I need all of them to be compared within their group.Does each set of three appear one after the other, then another set of three, and another set of three, etc?They are in alphabetic > numerical order. So, A0 through A???, then B0 through B???, etc.You mean they are ordered by hash?

Does each group of three follow the next one, or are the filenames ordered by the hash value?

So if one file has a different hash it COULD be anywhere in the file and not adjacent to the other two with the same hash value?Sorry for any confusion. The individual lines of the text file are ordered by the filename, not the hash. The filenames prefixed with an 'A' will be first, followed by 'B', and finished with 'C'.

If there were 9 hashes it would look like this:

7CD182468A6D54348C212231F27E997D A0.ext
0DDA55ED49858ADB143B8A86DA49AE17 A1.ext
3079A8613600B43A53B8B5E3907692DE A2.ext
7CD182468A6D54348C212231F27E997D B0.ext
0DDA55ED49858ADB143B8A86DA49AE17 B1.ext
3079A8613600B43A53B8B5E3907692DE B2.ext
7CD182468A6D54348C212231F27E997D C0.ext
0DDA55ED49858ADB143B8A86DA49AE17 C1.ext
3079A8613600B43A53B8B5E3907692DE C2.ext

I also have the ability to have these be in 3 separate text files, instead of together in 1 file with prefixes.This works in my tests. INPUT file is file.txt.
Error file is "result.compare.txt" if MISMATCHES are found.

It will report the filename alone, if any mismatch is found between the three versions of the filename.

Code: [Select]@echo off
set "file=file.txt"
del "result.compare.txt" 2>nul
setlocal enabledelayedexpansion
for /f "tokens=1,*" %%a in ('type "%file%"') do (
set "a=%%a"
set "char=%%b"
set "name=!char:~1!"
set "char=!char:~0,1!"
if /i "!char!"=="A" (
for /f "tokens=1,*" %%c in ('findstr /i /c:" B!name!" "%file%"') do set "b=%%c"
for /f "tokens=1,*" %%e in ('findstr /i /c:" C!name!" "%file%"') do set "c=%%e"

if "!a!!b!!c!"=="!c!!a!!b!" (
echo "!name!" passed
) else (
echo "!name!" failed compare
>> "result.compare.txt" echo "!name!" failed compare
)
)
)
pause

7141.

Solve : Read file name create folder and move file to folder.?

Answer»

I want the batch file to delete it's after wards.
I havent figured out how to make it do a sub folder work either.
Any ideas?
THANKS

Here is a copy

@echo off
for %%a in (*.*) do (
md "%%~na" 2>nul
move "%%a" "%%~na"
)This seems to work:

Code: [Select]@echo off
for %%a in (*.*) do (
if %%~a NEQ %0 (
md "%%~na" 2>nul
move "%%a" "%%~na\"
)
)Quote from: twinkie on October 21, 2012, 12:05:09 PM

I want the batch file to delete it's SELF after the job is completed.
I haven't figured out how to make it copy sub folder work either.
Any ideas?
Thanks

Here is a copy

@echo off
for %%a in (*.*) do (
md "%%~na" 2>nul
move "%%a" "%%~na"
)
At the end of the batch file add:

Code: [Select]del "%~F0" 2>nul
See if that works to delete the batch file.


Don't be a prat and play tricks on someone with it though - otherwise Satan will hunt you down and play the bongos on your balls.Nothing foolish... To old for that crap...
Thank you!
7142.

Solve : Move a file that begins with A or a, to a subfolder?

Answer»

I would like to know how to Move all folders in a subfolder that start with an "A or a" to ANOTHER folder found in a subfolder called A.
I would like to do the whole alphabet if possible.

Any assistance would be greatly appreciated.

Thank you
EDIT: The subject says files but your description says folders. Make up your mind.

Try this on some sample folders.

Code: [Select]@echo off
for %%z in (a b c d e f g h i j K l m n o p q r s t u V w x y z) do (
for /f "delims=" %%a in ('dir "%%z*" /b /ad 2^&GT;NUL') do (
md "!Folder %%z" 2>nul
move "%%a" "!Folder %%z" >nul
)
)
pause
This works for files - but don't put the batch file in the same folder, set the folder path in the second line.

There could be issues because the DIR command searches both the short and long filename so you can get false matches. I can't think of any way around that, matching on only one character.

Code: [Select]@echo off
pushd "c:\folder\to check"
for %%z in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
for /f "delims=" %%a in ('dir "%%z*" /b /a-d 2^>nul') do (
md "%%z" 2>nul
move "%%a" "%%z" >nul
)
)
popd
pause
Quote from: foxidrive on October 21, 2012, 10:14:44 PM

EDIT: The subject says files but your description says folders. Make up your mind.

Try this on some sample folders.

Code: [Select]@echo off
for %%z in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
for /f "delims=" %%a in ('dir "%%z*" /b /ad 2^>nul') do (
md "!Folder %%z" 2>nul
move "%%a" "!Folder %%z" >nul
)
)
pause

Sorry for the confusion.
Should have been folders Not Files...
Mind moving a mile a minute...
Thank you for the response!
Quote from: foxidrive on October 21, 2012, 10:14:44 PM
EDIT: The subject says files but your description says folders. Make up your mind.

Try this on some sample folders.

Code: [Select]@echo off
for %%z in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
for /f "delims=" %%a in ('dir "%%z*" /b /ad 2^>nul') do (
md "!Folder %%z" 2>nul
move "%%a" "!Folder %%z" >nul
)
)
pause

Parent Directory folder containing subfolders folders that begin with letters. Move the sub folders to matching first letter folders located in a sub folder on the hard drive.
Again sorry for the confusion. I will be well thought out before I post again.Try that batch file in your reply then.

It will move all the folders into one set of folders in the same directory. They will be called
"!folder a"
"!folder b"
"!folder c"
"!folder d"
etc.I already have existing folders lettered from a-z.
I just am trying to copy folders to those in a different location that already exist.
Code: [Select]@echo off
for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do move "%%a" "d:\backup\folder\"
7143.

Solve : copy by date time stamp?

Answer»

Stumped and here for ASSISTANCE... Trying to figure out a way to just copy files of a specific date no matter the time stamp, and I am thinking I can do this through parsing a DIR output for files of the specific date no matter the time stamp, write this to a file, and then import line for line which ones to copy although I am stumped in making this happen in batch without resorting to a programming language.

So can this be done in batch and if so, how can I accomplish this by example to learn from?

I was thinking of using SET to set the date in the batch for it to target, and then use a FOR statement to parse through the DIR output.

Thanks for the help in advance Quote from: DaveLembke on January 16, 2014, 03:40:20 PM

I am stumped in making this happen in batch without resorting to a programming language.
Often this is a policy issue. What is your workplace policy ? Does your workplace prohibit using programming languages to do the job? And if you really want to solve this real world problem its still more appropriate to sell the idea of using a programming language (benefits vs costs) to the management. Or is this just some "pet hobbyists" task that you just thought of doing with just using batch? Programming languages does provide convenient apis for stat-ing files and getting the date of files. If you really wish to do it natively, the DIR command can display creation/modified times but you will have to spend more time parsing out the date portion. vbscript (powershell) may lighten the task for you.Look at 'xcopy'.

Or you could loop through 'dir', but that would take a while if you had more than a hand full of files.

Not tested: (will not work if you're files have spaces in the name)
Code: [Select]
:: This is your destination folder's pathway
set "copy_destination=myDestination"

:: This is the date it will look for (formatted just like in 'dir')
set "copy_date=myDate"

:: Loops through the output of 'dir' while ignoring directories until the date equals %copy_date%
:: Then it copies the 5th segment to %copy_destination%
for /f "delims= " %%A in ('dir /a:-d') do (
if "%%A"=="%copy_date%" do copy "%%E" "%copy_destination%\%%E"
)
EDIT: I posted the info below based on only SEEING a response initially of

Quote
Look at 'xcopy'

After I posted this response below I saw you added more info to above post.

Hello Lemonilla ... I looked at xcopy before posting for assistance, and the problem with it is that the only switch that is close to what I want to do that I know of is /D:m-d-y , but this switch does not just copy the files on that date that is entered but it completes the following process: Copies files changed on or after the specified date. And I just need to fetch the files for a specific date instead of all files from that date onwards.


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

Code: [Select]C:\Users\dave>xcopy/?
Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
[/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/B]
[/EXCLUDE:file1[+file2][+file3]...]

source Specifies the file(s) to copy.
destination Specifies the location and/or name of new files.
/A Copies only files with the archive attribute set,
doesn't change the attribute.
/M Copies only files with the archive attribute set,
turns off the archive attribute.
[b] /D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.[/b]
/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string
should be in a separate line in the files. When any of the
strings match any part of the absolute path of the file to be
copied, that file will be excluded from being copied. For
example, specifying a string like \obj\ or .obj will exclude
all files underneath the directory obj or all files with the
.obj extension respectively.
/P Prompts you before creating each destination file.
/S Copies directories and subdirectories except empty ones.
/E Copies directories and subdirectories, including empty ones.
Same as /S /E. May be used to modify /T.
/V Verifies the size of each new file.
/W Prompts you to press a key before copying.
/C Continues copying even if errors occur.
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.
/Q Does not display file names while copying.
/F Displays full source and destination file names while copying.
/L Displays files that would be copied.
/G Allows the copying of encrypted files to destination that does
not support encryption.
/H Copies hidden and system files also.
/R Overwrites read-only files.
/T Creates directory structure, but does not copy files. Does not
include empty directories or subdirectories. /T /E includes
empty directories and subdirectories.
/U Copies only files that already exist in destination.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/N Copies using the generated short names.
/O Copies file ownership and ACL information.
/X Copies file audit settings (implies /O).
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
/Z Copies networked files in restartable mode.
/B Copies the Symbolic Link itself versus the target of the link.
/J Copies using unbuffered I/O. Recommended for very large files.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.

C:\Users\dave>Thanks Lemonilla for showing a potential method to use. I will give that a try and report back.

I am guessing that:

Quote
:: Loops through the output of 'dir' while ignoring directories until the date equals %copy_date%

...means that it will continue to loop after the files matching the date are copied from the specific date requested until DIR is exhausted of all files which the others would be a date not equal to the date to fetch, and if that is the case then this is a perfect solution to making this happen in batch without over complicating it by using a language to interface with command shell/DOS.

I was starting to think that I was going to have to echo out the DIR and > to file, and then use C++ or Perl to then read in the DIR output file and look line for line for files of that specific date and build a list of files to copy in another file. And then process the list of files that were generated to complete the copying process until EOF.

Your method as it is appears to be the best method without over complicating it as I would have ended up doing without your help... THANKS SO MUCH !!!! The format of the last modified timestamp varies from region to region but forfiles is one way to do it.

This copies *.txt files in the current folder to "d:\target folder\" if the modified date is today (it just echoes the copy commands atm)

Put an echo before the if command to see what format the date is in for your region.

Code: [Select]@echo off
FORFILES /M *.txt /c "cmd /c if "@fdate"=="17/01/2014" echo copy @file 0x22d:\target folder\0x22" 2>nul
Code: [Select]@echo off
FORFILES /M *.txt /c "cmd /c if "@fdate"=="17/01/2014" echo copy @file [b]0x22[/b]d:\target folder\[b]0x22[/b]" 2>nul
Curious as to what 0x22 is? Is this a misinterpreted character or is 0x22 intentional? Found the answer to this looking at forfiles/? as seen below.

Quote
To include special characters in the command
line, use the hexadecimal code for the character
in 0xHH format (ex. 0x09 for tab).


Never worked with forfiles command before. Very Interesting!!!

My date format is MM/DD/YYYY so I am assuming that "@fdate"=="17/01/2014" is just set to 01/17/2014 if I wanted files last edited on today to be copied for example.


Code: [Select]C:\Users\dave>forfiles/?

FORFILES [/P pathname] [/M searchmask] [/S]
[/C command] [/D [+ | -] {MM/dd/yyyy | dd}]

Description:
Selects a file (or set of files) and executes a
command on that file. This is helpful for batch jobs.

Parameter List:
/P pathname Indicates the path to start searching.
The default folder is the current working
directory (.).

/M searchmask SEARCHES files according to a searchmask.
The default searchmask is '*' .

/S Instructs forfiles to recurse into
subdirectories. Like "DIR /S".

/C command Indicates the command to execute for each file.
Command strings should be wrapped in double
quotes.

The default command is "cmd /c echo @file".

The following variables can be used in the
command string:
@file - returns the name of the file.
@fname - returns the file name without
extension.
@ext - returns only the extension of the
file.
@path - returns the full path of the file.
@relpath - returns the relative path of the
file.
@isdir - returns "TRUE" if a file type is
a directory, and "FALSE" for files.
@fsize - returns the size of the file in
bytes.
@fdate - returns the last modified date of the
file.
@ftime - returns the last modified time of the
file.

To include special characters in the command
line, use the hexadecimal code for the character
in 0xHH format (ex. 0x09 for tab). Internal
CMD.exe commands should be preceded with
"cmd /c".

/D date Selects files with a last modified date greater
than or equal to (+), or less than or equal to
(-), the specified date using the
"MM/dd/yyyy" format; or selects files with a
last modified date greater than or equal to (+)
the current date plus "dd" days, or less than or
equal to (-) the current date minus "dd" days. A
valid "dd" number of days can be any number in
the range of 0 - 32768.
"+" is taken as default sign if not specified.

/? Displays this help message.

Examples:
FORFILES /?
FORFILES
FORFILES /P C:\WINDOWS /S /M DNS*.*
FORFILES /S /M *.txt /C "cmd /c type @file | more"
FORFILES /P C:\ /S /M *.bat
FORFILES /D -30 /M *.exe
/C "cmd /c echo @path 0x09 was changed 30 days ago"
FORFILES /D 01/01/2001
/C "cmd /c echo @fname is new since Jan 1st 2001"
FORFILES /D +1/16/2014 /C "cmd /c echo @fname is new today"
FORFILES /M *.exe /D +1
FORFILES /S /M *.doc /C "cmd /c echo @fsize"
FORFILES /M *.txt /C "cmd /c if @isdir==FALSE notepad.exe @file"

C:\Users\dave>Quote from: DaveLembke on January 16, 2014, 08:01:14 PM
Never worked with forfiles command before. Very Interesting!!!

My date format is MM/DD/YYYY so I am assuming that "@fdate"=="17/01/2014" is just set to 01/17/2014 if I wanted files last edited on today to be copied for example.

It's a useful utility, but a bit slow to TRADE off it's usefulness.

Put echo before the if and run it, you will see the strings echoed to the console.

The funny part is that I used 0x22 because of the quotes, but totally missed the fact that I'd used normal quotes for the string compare - and it works.
I didn't know I could embed quotes inside the cmd tail - but now that I tested further if I put quotes where 0x22 are then it doesn't work. bizarre.In reference to Lemonilla's batch:
Code: [Select]:: This is your destination folder's pathway
set "copy_destination=myDestination"

:: This is the date it will look for (formatted just like in 'dir')
set "copy_date=myDate"

:: Loops through the output of 'dir' while ignoring directories until the date equals %copy_date%
:: Then it copies the 5th segment to %copy_destination%
for /f "delims= " %%A in ('dir /a:-d') do (
if "%%A"=="%copy_date%" do copy "%%E" "%copy_destination%\%%E"
)

I edited it as:
Code: [Select]@echo off
:: This is your destination folder's pathway
set copy_destination=c:\test123

:: This is the date it will look for (formatted just like in 'dir')
set copy_date=01/01/2013

:: Loops through the output of 'dir' while ignoring directories until the date equals %copy_date%
:: Then it copies the 5th segment to %copy_destination%
for /f "delims= " %%A in ('dir /a:-d') do (if "%%A"=="%copy_date%" do copy "%%E""%copy_destination%\%%E")

And I get the following error?


Quote
C:\test321>copytest
'do' is not recognized as an internal or external command,
operable program or batch file.
'do' is not recognized as an internal or external command,
operable program or batch file.


C:\test321>

Googled this error and nothing on this problem with 'do' just other stuff following same error BTW I am using Windows XP Home SP3 for OS.


Also tried out foxidrives solution and got a SIMILAR internal/external command problem for 'forfiles' similar to 'do'problem with:

Code: [Select]FORFILES /M *.* /c "cmd /c if "@fdate"=="01/01/2013" echo copy @file 0x22C:\test123\0x22">nul



Quote
C:\test321>forfiletest3.bat

C:\test321>FORFILES /M *.* /c "cmd /c if "@fdate"=="01/01/2013" echo copy @file
0x22C:\test123\0x22" 1>nul
'FORFILES' is not recognized as an internal or external command,
operable program or batch file.

C:\test321>

Attached pic shows source of C:\test321 attempting to copy 2 files with same date as 01/01/2013 to C:\test123. Both of these batches have been run from the C:\test321 location where the files exist to be copied from.


[recovering disk space, attachment deleted by admin]Quote from: DaveLembke on January 18, 2014, 12:59:50 PM
'FORFILES' is not recognized as an internal or external command,
operable program or batch file.

Forfiles is not a native command in Windows XP - but is a free download from Microsoft.Ok cool. I will download it then. The other day when I looked at it I was on Windows 7 Pro, and today I am on Windows XP Home system, so I assume its bundled with Windows 7 Pro maybe but not XP. The "DO" error is because the IF command does not require a "DO".Removed 'do' and its not happy


Code: [Select]C:\test321>test10.bat
%Ec:\test123\%E
The filename, directory name, or volume label syntax is incorrect.
0 file(s) copied.
%Ec:\test123\%E
The filename, directory name, or volume label syntax is incorrect.
0 file(s) copied.

C:\test321>
with using this:

Quote
@echo off
:: This is your destination folder's pathway
set "copy_destination=c:\test123"

:: This is the date it will look for (formatted just like in 'dir')
set "copy_date=01/01/2013"

:: Loops through the output of 'dir' while ignoring directories until the date equals %copy_date%
:: Then it copies the 5th segment to %copy_destination%
for /f "delims= " %%A in ('dir /a:-d') do (if "%%A"=="%copy_date%" copy"%%E""%copy_destination%\%%E")


Also tried rev 11 on this with :

Quote
@echo off
:: This is your destination folder's pathway
set copy_destination=c:\test123

:: This is the date it will look for (formatted just like in 'dir')
set copy_date=01/01/2013

:: Loops through the output of 'dir' while ignoring directories until the date equals %copy_date%
:: Then it copies the 5th segment to %copy_destination%
for /f "delims= " %%A in ('dir /a:-d') do (if "%%A"=="%copy_date%" copy"%%E""%copy_destination%\%%E")

and got this error:

Code: [Select]C:\test321>test11.bat
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.

C:\test321>Missing the Tokens option with the for command.
7144.

Solve : fdisk?

Answer»

fdsk error ,error reading FIXED DISK, trying to FORMAT but can't,helpok.Try running scandisk to fix any BAD sectors.

7145.

Solve : DOS hidden FTP?

Answer»

Hello,
I have a question about DOS and FTP. Years ago I was talking with a Cisco consultant and at one point in the conversation he had me hook up a phone line to my DOS laptop and he typed in a command that brought up a WINDOW that looked almost like interlnk but this one MS uses for FTP to their site. But you could type in any FTP site and it would dial out and go to it with almost no setup save user ID and password.
Does this sound at all familiar? I could not tell you the exact version of DOS (6,6.2, 6.22) I don’t think I had DOS 5.
I lost contact with the tech who showed me and I was NEVER able to find the command anywhere.
It does exist , we USED it and connected to an FTP site without installing an FTP app.
If this at all sounds familiar to you I would deeply appreciate some insight to this MYSTERIOUS lost DOS command.

Thanks,

Windows has a native FTP app from the cmd line. Just type FTP at a cmd prompt.Windows 9x had Hyperterminal which may be what was used.

Time dulls the sense of RECALL - you may not have been using MSDOS.

7146.

Solve : invailid what ??

Answer»

what does invalid setting in the ms-dos.sys FILE: org_drag _bootmeunu= mean and how do I fix it i have windows 98?!LOOKS like a spurious entry in msdos.sys - MAKE a copy of the entire msdos.sys file for backup, edit your msdos.sys file & delete the entry, save the file and reboot.

See here for a very GOOD write-up of the permitted msdos.sys ENTRIES and their format

http://www.mdgx.com/msdos.htm#TAB

Good luck

7147.

Solve : Installing local printer from network using command line with a silent installer?

Answer»

I am primarily a hardware guy but now been faced with having to change our printing from the server to local printing due to a new application we are using.

I am writing a script to load the ini/inf files on the computers. I have pretty much resolved this issue.

I have downloaded the version 8 dymo printer DRIVER and can use the silent install which I prefer. I have the dymo.exe file in the path as listed below.

T:\RPM\printer_drivers\Other\dymo\Dymo XP-7-8 8.5\DLS8Setup.8.5.0.exe

I can run the silent installer locally C:\Dymo>DLS8Setup.8.5.0 /s with no issues.

I need assistance with the correct command line info such a net use install runas what ever to NAVIGATE to the mapped drive and kick off the silent installer as works from the local machine. I have searched the WORLD over and have not found my answer. I hope someone can point me in the right direction.

Any help will be greatly appreciated.

Thanks in advance,

NetcruznMaybe I am not understanding you but the syntax should be no different running the installer from your hard drive or from a network drive.

Network drive
"T:\RPM\printer_drivers\Other\dymo\Dymo XP-7-8 8.5\DLS8Setup.8.5.0.exe" /S
Local Drive
"C:\Dymo\DLS8Setup.8.5.0.exe" /sThank you and you are correct. I am a moron....... I had my head so wrapped around this rundll32 printui.dll, printuientry stuff for a script I was working on, I was making it more than what it was. THANK You for the slap in the face. Sometimes I guess we all need it from TIME to time. And yes that got me what I needed.

Quote from: Netcruzn on January 15, 2014, 12:09:19 PM

Thank you and you are correct. I am a moron....... I had my head so wrapped around this rundll32 printui.dll, printuientry stuff for a script I was working on, I was making it more than what it was. Thank You for the slap in the face. Sometimes I guess we all need it from time to time. And yes that got me what I needed.
I had a moment with an FTP script yesterday. Couldn't figure out why it wouldn't automate. Helps if you use the correct options. I do it all the time every day but yesterday that brain cell must have gotten stuck in the off position. Happens to all of us.BTW Squash didn't slap you...he simply tapped you on the shoulder...

7148.

Solve : invalid setting in the ms-dos.sys file: org_drag _?

Answer»

what does INVALID setting in the ms-dos.sys FILE: org_drag _bootmeunu= mean and how do i fix it and how do i GET out of safe mode when WINDOWS does START?

7149.

Solve : Time for a new OS!?

Answer»

Microsoft sucks!

Microsoft has designed only three good programs according to me:

1) MS-DOS (simple, compact sizewhise and makes you feel like the hacker you aren't)
2) MS Excel (amazing program even though they did not invent the concept)
3) MS Paint (a FANTASTIC simple and flexible program which you can use even for electronic CAD. I love it!)

The rest of Microsoft products sucks!

It is time for a change!

The only good thing with Windows is that it has driven the HW-development forward.

Let's stay there for a while.

My computer/processor runs at the AMAZING frequency of some 3GHz. GHz!!

Let's assume that each instruction takes an average of three clock cycles. This would mean that the processor is actually processing 1 BILLION instructions every second!

I repeat,

1 billion instructions each second!!

Yet, it takes my poor computer several MINUTES to start windows...

Hello, there's got to be something wrong here.

Minutes to start windows is NOT acceptable!

And my guess is that Microsoft is using too much automaticly generated code (fundamentally incompetent programmers that is).

Because let's face it, almost noone these days programs in the most code effective language there is, i.e assembler.

I think there is lot's to do here.

I only wish the code was open source.

I LOVE open source (like Linux)!

I just can't make up my mind if I should abandon XP or not. I know you can have two OSes but I'm still allergic to the change.

One reason is that I have a real naive dream of designing my own OS.

I am actually right now on the verge of getting my homebrew CPU to work.

The sport is to begin from scratch

Tace care!

Best regards, Roger
PS
Attaching a picture of my homebrew CPU (using a CPLD).


[year+ old attachment deleted by admin]I do believe you may be in the wrong section. And a few minutes is a decent loading time for windows. Unless you have a new computer, a couple minutes is not ridiculous.Quote from: rogerk8 on October 17, 2012, 12:44:09 PM

Let's assume that each instruction takes an average of three clock cycles. This would mean that the processor is actually processing 1 BILLION instructions every second!



I repeat,

1 billion instructions each second!!

Yet, it takes my poor computer several MINUTES to start windows...
Much of the time required to boot Windows (or any modern OS) is due to I/O wait states. It doesn't matter if your CPU can process 1 million or 20 billion instructions a second if the data required for those instructions is sitting on a hard disk; and memory is still only a fraction of the speed of the CPU itself.

Quote
Hello, there's got to be something wrong here.

Minutes to start windows is NOT acceptable!
It doesn't take several minutes for my computer to start. Many of the systems I've seen using SSDs start from a cold boot in only a few seconds (counting from button press to either desktop or login screen). Of course we didn't have a stopwatch, but there wasn't enough time to grab a beverage.

Quote
And my guess is that Microsoft is using too much automaticly generated code (fundamentally incompetent programmers that is).
Not sure I understand. Macro's are one of the most powerful language features available in any language. Though I'm not really sure what you are referring to here. ("automatically generated code" makes me think you think they use some sort of Wizard...)

Quote
Because let's face it, almost noone these days programs in the most code effective language there is, i.e assembler.
Windows is written in C and Assembly, with time critical portions- such as those that are more prevalent in the kernel- being written in Assembly.



Here's the issue with such a language debate. Surely, as you are evidently aware, it all started with machine language. All programs had to be written as sequences of machine language instructions (which were fed in various ways, punch cards, tapes, etc). Soon after of course people started to use a slightly more convenient form of representing machine code, Assembly language. The list of COMMANDS available is the same as machine code, of course, but instead og referring to the add instruction as 11001101

In assembly language the list of commands is
the same, but you get to use more programmer-friendly names.
Instead of referring to the add instruction as 11001101, or CD (in hex), you get the privilege of calling it add.

The problem with machine and assembly language is triplefold- first, they can only do, fundamentally, very simple things. If you wanted to tell a computer to beep 10 times, there is not likely to be a machine instruction to do something n times, So of you want to tell it to do something 10 times using machine instructions, you might have to do something equivalent to:

Code: [Select]put the number 10 in memory location 0
a if location 0 is negative, go to line b
beep
subtract 1 from the number in location 0
go to line a
(Obviously this isn't really machine code, but the point is that assembly/machine language works at a very base level of instructions.).

Also remember I said triple fold- second, we have the issue of code readability and discovering bugs. The above psuedo-representation has a bug, for example. Third, the problem is that today not only are processors extremely fast, but they also have multiple cores of execution; in order for a program to be written to be as fast as possible on a modern Quad-core (or more) machine, for example, it would have to exploit all the cores so they were doing as much of the work as possible. Assembly language, however, being an imperative language by design, focuses on sequences of instructions; having more than one thing occur at a time is something handled by the hardware pipeline itself (eg the Pentium processor) but actually exploiting multiple cores (each of which have their own pipelines) is up to the programmer, and doing so properly is practically out of the scope of any reasonable Assembly programmer. Additionally, the actual mechanics of parallelizing a piece of sequential code could easily be said to follow a pattern; this is something embraced by concurrent languages such as Erlang, which focus on tasks, rather than on a single sequence of instructions. These concepts, which are fundamentally a functional construct and follow in the footsteps of Lisp, are something that are practically required to properly exploit today's processors.

Actually, now that I think about it, I know what you mean by Machine-generated- you are referring to compiler generated code.

Higher-level languages, such as C, expand your toolbox; they let you use more powerful abstractions, such as "do this N times" rather than wimpy ones like "Add the values in these two registers" or "jump to this memory address if the previous comparison wasn't equal". The advantage here is that being able to build software out of more powerful abstractions means you have to use fewer of them. The above psuedo-machine code written in C might look like this:

Code: [Select]for(int i=0;i=<10;i++) beep();
Which is easier to read, easier to edit, and has the advantage of making the bug in the previous version more clear. When you get to build your programs out of bigger concepts, you don’t need to use as many of them.

Another gigantic advantage to high-level languages is that they make a program more portable. For example, if you have a program written in x86 assembly, it's going to be useless for an ARM processor or for a Motorola Processor or what-have-you. Even a language like C mitigates this because the same source can be fed into compilers for different architectures. For Windows, this meant that the codebase only needed revisions to move from 16-bit x86 to protected mode x86, and from there to 64-bit, rather than having to be rewritten entirely for each specific set of instructions (the available instructions in each mode differs). Instead, the logic about what instructions are available are simply GIVEN to the compiler and the compiler learns how to best use them; fundamentally, the act of "optimizing" assembly code is more machinations than an art; fact is that in order to properly "tune" assembly language to the point where you exceed the speed of a modern compiler, you will need to know the processor in question- how every single instruction is executed, what fiobles it has- etc. as well as spend countless hours putting that knowledge to use. The end result is that you might end up with a program that is 10% faster for 100 times the investment of man hours- repeated for the number of architectures your product is going to TARGET. And that isn't even counting the additional time required to track down bugs in such a situation.



Quote
I only wish the code was open source.
it's Open to some people, through an NDA. It's not that INTERESTING. It definitely didn't use a wizard, though. I hope saying it's not interesting doesn't violate the source license NDA...

Quote
One reason is that I have a real naive dream of designing my own OS.

I am actually right now on the verge of getting my homebrew CPU to work.
Cool... good luck! Why would Windows being Open Source help you with a homebrew CPU, though?You are amazing BC_Programmer! Putting so much time and effort into replying to me. I am honored!

I wish I had SSD-disks. These kind of disks makes my point less obvious.

I know from a friend that the reason for multiple cores actually are current consumption. I was amazed to hear that but it makes sense. He said that current consumption isn't linear. It is exponential (with regard to clock frequency)

The thought about this is however still the actual need for multiple cores in smartphones etc.

Isn't this something like "giving up"?

I can't see the development in mutiple cores. I just see the unneccesary complication.

This is because I still think that the software engineers and their compilers simply generates too much irrelevant code.

I think we should revert to single cored processors and make use of the one and only good designing language, assembly.

I understand that it is more easily readable when stuff are written in higher languages but I can't see the user benefits.

Now you have the problem with slow downloads on smartphones for instance.

And what do we use there? Am I wrong if I say some rediculous 24-bit resolution for each pixel. WHY?

When I attended Chalmers, I for instance had the opportunity to experiment with the bit-resolution of an audio file. CD uses 16 bits (some 65000 levels). I needed no more than 5 bits (32 levels) before I thought it sounded ok (I am not kidding).

I do however think this is a "workaround" of the problem. And I think we do not need 24-bit resolution on our pictures.

Maybe I'm wrong but my point is that we are sending and receiving more data than is neccesary (for a nice experience).

I have f.i not understood the point of HD. Is that really neccesary? Maybe for really big screens.

The point I am trying to make is that we are using too much unneccesary data at the same time as we (read Microsoft) designs programs in a not so efficient way.

Maybe the programs are easy to read but you can bet that they are not optimized with regard to efficiency.

They are optimized with regard to maximum shortest development time and profit.

I rest my case :-)

Best regards, Roger
PS
Thank you for your comment on my CPU project. Open souce will of cource not affect that :-) I just like open source. This is because I think information should be free. Free for anyone to use, free for anyone to start a company (with their own design).

I am attaching yet another fun picture of my project (which I have been developing for 1,5 years now)





[year+ old attachment deleted by admin]1) Buy a MAC

2) Switch to Linux.

3) Topic Closed.Hi!

What is Alpha? Intensity, or? I thought only RGB was needed.

It seems that I know less about computers than I thought. And this kind of explains it all.

I do however still think that:

1) We do not need all the features a program nowadays provide (this will just make it load/start more slow than neccesary)
2) We do not need the hysterical resolution that nowadays are common (but the long-term use is hard to predict...)
3) I am not certain anymore but it seems like we could write more code-effective programs (using single cores and assembly)
4) Multiple cores are not the future in the long run (because there's a limit on how many cores you can actually use)
5) Maybe the problem (read slow computers) isn't the high-level language. Maybe the problem is badly designed compilers.

I know I am being stubborn but this is what I think.

My next generation of CPU (using a FPGA instead of a CPLD) I think will have a 32-bit wide address bus and 16-bit wide data bus.

But if I fail at this (or maybe both) I would like to buy a similar CPU on the (second hand) market.

What kind of CPU should I look for?

486?

It doesn't matter if both the address bus and the data bus is 32-bit wide. But I kind of like the asymmetry because this is how my first CPU will work (if I ever get it to work, that is).

Finally, you have taught me that assembly do not work so well with multiple cores. So that is another reason why I stick to my belief.

I think I have said all I wanted to say.

Take care!

Best regards, Roger
PS
Attaching the schematic of my CPU. And yes, the other one above was more of a block-diagram than a picture of the actual architecture.

Because I'm so bad at computers but at same time very interested (especially in hardware), could you please recommend a book I should read? It need perhaps not be for dummies but approximatelly at that level. I am very interested in hardware protocols (like the formatting of an hard drive f.i) and the way a (modern) computer actually work. All hardware considered. And drive routines (freely translated from swedish)

If it isn't you Mr G, then it's got to be you Mr B!

[year+ old attachment deleted by admin]The Alpha value represents the transparency of whatever colour the RGB value has returned.

As for the other questions...I'll leave that to the experts.Quote from: Helpmeh on October 24, 2012, 08:27:57 PM
The Alpha value represents the transparency of whatever colour the RGB value has returned.

As for the other questions...I'll leave that to the experts.

FWIW, this topic was locked and (apparently) unlocked and now he's responded to the post I made in his double-post on the same subject in this one, too (for some reason...).
7150.

Solve : is there any socket library for MS-DOS??

Answer»

is there any SOCKET library for C PROGRAMMING in MS-DOS that is indepentant of packet driver. PLEASE get me solutions