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.
| 2851. |
Solve : So im making a game...? |
|
Answer» Quote it won't always be positive either. Because there was an ERROR. Which is what you're testing for.0 means no error. any other values generally means an error. which means that (2000/XP/Vista) programs returning a negative number will be flagged as successful, since they are not greater then zero. so basically, the condition should be: Code: [Select]if not errorlevel EQU 0 goto :fail You mean if not .The original code I gave (if errorlevel 1 goto fail) is backwards compatible to old versions of DOS and works over 99% of the time in my experience. But the discussion is correct that it won't work with CMD and programs that return negative errorlevels. But just to correct a few things: 1) CHECKING for errorlevel 1 is fine, because that will return true if the errorlevel is 1 or 2 or 3 or 4, etc. (anything HIGHER than 0). 2) The "correct" way with CMD needs to address ERRORLEVEL as an environment variable, so it needs % around it, like: Code: [Select]IF %ERRORLEVEL% NEQ 0 goto failQuote from: GURUGARY on February 14, 2009, 09:24:49 PM The original code I gave (if errorlevel 1 goto fail) is backwards compatible to old versions of DOS and works over 99% of the time in my experience. exactly. == with ERRORLEVEL will be execute the command if the value is greater then or equal to the value- additionally the GTR then and so forth are not available in pure DOS which kind of precludes their USE in that context. your correction re Errorlevel as a variable is also 100% accurate as well. Quote from: GuruGary on February 14, 2009, 09:24:49 PM Code: [Select]IF %ERRORLEVEL% NEQ 0 goto fail So this is the best way to do it, rite? thanks again.Yes. Do it that way. |
|
| 2852. |
Solve : Batch File for changing text? |
|
Answer» I NEED to create a batch FILE that will change the time in numerous text files. The time needs to be changed to 10:00. However, all the original times are DIFFERENT in the text files. Here's an example: |
|
| 2853. |
Solve : outlook 2007 connecting to exchange problem? |
|
Answer» Hi Guys, Please could you help out with an outlook problem I am having. |
|
| 2854. |
Solve : Menu? |
|
Answer» and Larssie, BATKIT only makes the kind of menus like in that colortone example. |
|
| 2855. |
Solve : freaking dos!!!!!!!!!!!!!? |
|
Answer» if your refering to me now. The NET was down for a while and I dont have it setup at my new LOCATION. Yes that is correct but I tried to change directories my FATHER says I had to run f-disk since there was an os but I figure it WOULD dual boot then or something. I dont know patio thanks for the insight that may help. I have books that are useing older versions that PROBABLY why. |
|
| 2856. |
Solve : Need help for my Autoexec.bat file for a HDD boot partition? |
|
Answer» I have a 128 Mb pen drive that natively boots MS-DOS 7.10 (from a Windows 98 disk). I have a 128 Mb pen drive that natively boots MS-DOS 7.10 (from a Windows 98 disk). Hey, that may be what he needs. And other curious minds would like to know. How do you get MS-DOS 7 onto a USB thing and have it boot.Quote from: Geek-9pm on February 14, 2009, 03:00:28 PM QuoteI have a 128 Mb pen drive that natively boots MS-DOS 7.10 (from a Windows 98 disk). I USED the HP USB Boot Utility. It's all here http://www.bootdisk.com/pendrive.htm Let's hope his NetBook supports booting from USB devices. So far it doesn't sound like it.I am pretty sure it supports booting to USB devices.Quote from: GURUGARY on February 15, 2009, 09:04:50 AM I am pretty sure it supports booting to USB devices. Source ? ?Quote from: patio on February 15, 2009, 03:48:33 PM Source ? ?Experience. It has been at least 2 years since I have seen a new laptop that does not support booting to USB devices. But here is a link that further supports my guess: http://www.ubuntumini.com/2008/10/installing-ubuntu-on-dell-inspiron-mini.html It includes a video of the BIOS screen changing the boot options, but here text of "Step 2": Quote Step 2. Set your Mini 9 to boot from optical drive or USBGot it. Wonder why this is such a struggle then...Quote from: patio on February 16, 2009, 07:16:11 AM Got it. probably trying to use DOS 6?Should still be a piece of cake... Use Dias' guide to create a bootable flash drive...boot to the flash and RUN the OS install. |
|
| 2857. |
Solve : Help me with a batch file? |
|
Answer» Quote from: BC_Programmer on February 16, 2009, 09:08:41 AM If he's examining windows versions, there is a chance he wants the batch to run on windows 98, in which case SET /P is not available. You right! In other word : I'm attempting to make my batch the more compatible possible If you are making your script backwards compatible with Win9x, then be sure to modify your IPCONFIG commands because the Win9x version of IPCONFIG is very different from the Windows 2000 / Windows XP version of IPCONFIG Code: [Select]C:\Win98>ipconfig /? Windows 98 IP Configuration Command line OPTIONS: /All - Display DETAILED information. /Batch [file] - Write to file or ./WINIPCFG.OUT /renew_all - Renew all adapters. /release_all - Release all adapters. /renew N - Renew adapter N. /release N - Release adapter N. Code: [Select]C:\WindowsXP>ipconfig /? USAGE: ipconfig [/? | /all | /renew [adapter] | /release [adapter] | /flushdns | /displaydns | /registerdns | /showclassid adapter | /setclassid adapter [classid] ] where adapter Connection NAME (wildcard characters * and ? allowed, see examples) Options: /? Display this help message /all Display full configuration information. /release Release the IP address for the specified adapter. /renew Renew the IP address for the specified adapter. /flushdns Purges the DNS Resolver cache. /registerdns Refreshes all DHCP leases and re-registers DNS names /displaydns Display the contents of the DNS Resolver Cache. /showclassid Displays all the dhcp class IDs allowed for adapter. /setclassid Modifies the dhcp class id. The default is to display only the IP address, subnet MASK and default GATEWAY for each adapter bound to TCP/IP. For Release and Renew, if no adapter name is specified, then the IP address leases for all adapters bound to TCP/IP will be released or renewed. For Setclassid, if no ClassId is specified, then the ClassId is removed. Examples: > ipconfig ... Show information. > ipconfig /all ... Show detailed information > ipconfig /renew ... renew all adapters > ipconfig /renew EL* ... renew any connection that has its name starting with EL > ipconfig /release *Con* ... release all matching connections, eg. "Local Area Connection 1" or "Local Area Connection 2"Thx for the notice GuruGary I will make some modification to my script. |
|
| 2858. |
Solve : Can Virtual PC 2007 run MS-DOS?? |
|
Answer» Can Virtual PC 2007 run MS-DOS? when not in use it makes a great end table BC, how tall are you? ok, a short end table. and it only WORKS when I'm lying down. better then putting DRINKS on the floor though, I suppose.Quote from: Dias de verano on February 14, 2009, 02:02:57 AM You can install MS-DOS as a guest OS using Virtual PC 2007. "Although Virtual PC 2007 doesn't officially support MS-DOS, it will work.", it says here... (Also tells how to free up DOS memory for games)Quote from: zuhiab on February 16, 2009, 02:43:38 AM Quote from: Dias de verano on February 14, 2009, 02:02:57 AMWhy the little quote fest ? ?If you just want to run dos game, try dosbox Is the easies way to play you old game. But I manage to run dos 7 on a vmware with windows 3.1 . So i guess is possible to run dos or ms-dos in virtual pc.Quote from: patio on February 16, 2009, 07:11:27 AMYou can install MS-DOS as a guest OS using Virtual PC 2007. "Although Virtual PC 2007 doesn't officially support MS-DOS, it will work.", it says here... (Also tells how to free up DOS memory for games) Why the little quote fest ? ?He started it. Tanks. iIam trying to install virtual PC on my new dell Optipex. SFF (New to me anyway) I am NOT get the thing to work. Or if it is working, I don't know what it is doing. I do not know what it wants. It seems to be asking me yo use my existing OS. If I did that, what is the point? I am missing something. I am getting virtual headache. I need some vertical Gin. On this particular machine there is no easy way to connect a second hard drive. So I grues I will have to try the Virtual PC on a machine that has more options.You shouldn't need a second hard drive for Virtual PC. Once Virtual PC is installed, CREATE a new Virtual Machine with a Virtual Hard Drive, and then start it. Use either the "CD" or "Floppy" (menu at the top) to capture the device (or use virtual image like an ISO or IMG) to install the OS. |
|
| 2859. |
Solve : Search and Copy a particular File? |
|
Answer» Hi all, |
|
| 2860. |
Solve : Quick question: How to make .bat files write txts with seperated lines?? |
|
Answer» Hello. For example, I have this code: To write separate lines you would have to do: I disagree, >> can make files too. But, that's right.Quote from: BatchRocks on February 17, 2009, 08:59:45 AM Quote from: BatchFileCommand on February 17, 2009, 06:20:37 AMTo write separate lines you would have to do: Actually, BFC is correct. > will ALWAYS create a new file- if a file with that NAME EXISTS it is truncated to 0 bytes. >> will always append to the file if it exists, creating a new one of necessary.Sorry, apologies.on the other hand as you say >> will create a file as necessary. But in this CASE that file might balloon to huge sizes, depending of course on how often this batch is run. |
|
| 2861. |
Solve : Calling a batch file from another batch file? |
|
Answer» devcom, I have tried the new codes but not thing happen when it reach the set TIME. I am not sure what is preventing the batch files from running. My PLAN B is to stop the driver, because the original problem was the application will not run after I start it the second time. It show me the error message "driver already in use". So maybe if there is a way for me to stop the driver then hopefully I can start the application again without having to restart the laptop. Is there a way to do this? |
|
| 2862. |
Solve : What's the point of remarks?? |
|
Answer» ASM is source code, machine code very very complex yet very very powerful its not an exeacuteable like EXE. Code: [Select]The REALLY good ones turn it into asm To you it would be, yes. Actually, I looked it up more. Pretty comparable . Dias, you won't be able to go everywhere being the "wise guy" you claim everybody else to be.When there is a great need, somebody will do it. If a compile of a batch file is really needed, it will be done. Somehow. But it is seldom done. Here is why. In very complex operations the higher level of code is in a form the people can modify and use right away. The Edit, Compile, Link, Debug, Verify, Deploy and Revise business can take too long in a real-time process where a revision in the logic, settings or performance has to bee done quickly. IT administrators often use batch files, because batch files are quicker in the over-all process. It is not so much have many milliseconds it takes the batch to run. It is the time it takes to get it up and running from the point where a new task is needed until the user has in on her computer.Quote from: BatchFileCommand on January 19, 2009, 12:24:48 PM Actually, I looked it up more. Pretty comparable . Dias, you won't be able to go everywhere being the BFC, your getting a bit to big for your britches; he's been here longer so he's more experienced than you.Everybody has a "batch to ASM converter". Here's a picture of one I believe there was a Batch to ASM conversion program at some point- but it only worked with Pure DOS (no NT commands). Quote from: BatchFileCommand on January 19, 2009, 12:24:48 PM Actually, I looked it up more. Pretty comparable . what? an straight machine code executable comparable to ASSEMBLY? I suppose somebody could say that... until they realize that it's a bit more difficult to memorize and interpret the meaning of a set of hexadecimal bytes then it is to read a assembly display of those same set of bytes. Quote from: Dias de verano on January 19, 2009, 03:31:46 PM Everybody has a "batch to ASM converter". Here's a picture of one Except some people are missing the ASM module completely.Wait a minute, you people are doing all the work for me. You say that it's harder to convert batch to asm ( a much easier language then exe) But then you say that it's easier to convert batch to exe. There's no logic in that. When you say "experience", there are two and more meanings. 1. you're a smart-*censored* who knows everything 2. you're a real helpful person who knows everybody. 3. you're a lazy "thing" that has been in the forum for years and posts stuff like, cool, and i like that.Quote from: BatchFileCommand on January 19, 2009, 07:38:45 PM Wait a minute, you people are doing all the work for me. You say that it's harder to convert batch to asm ( a much easier language then exe) But then you say that it's easier to convert batch to exe. There's no logic in that. When you say "experience", there are two and more meanings. you obviously don't understand jack-*censored* about what we're saying. It's easier to convert to EXE because one could create a Stub executable in C or C++ for example that loads batch code that is appended to the executable. the C program, upon being run, loads the batch code from the end of itself (argv[0], of course), saves it in a temporary file, shells the batch file, deletes the temporary file, and closes. EXE is machine code. it translates DIRECTLY into assembly. That's why it's called "dissasembly" not "decompiling" to ASM source. The comments are gone, which are kind of important to understanding anything that is happening in a ASM program. Which ironically answers your topics question. conversely- you don't "Compile" an ASM program but rather "assemble" it, which is a fairly simple task at a basic level- strip out comments and right out each ASM instruction as the directly CORRESPONDING piece of machine code. ASM is just a symbolic way of looking at the machine code. This is why, with most "batch compiling" systems (which, as stated before simply prepend some cheap C program to the front of the batch code and call it a day) you can simply open the executable and copy the code- comments and all. More "sophisiticated" batch compiling programs try to further obfuscate the code by performing EXE compression on the resulting executable, appended batch code and all. Of course, this prepends ANOTHER executable to the front of the current one, meaning that the decompression routine needs to save a temporary file containing the original executable, which can be opened and the batch code once again copied out as if the compression algorithm wasn't there (and in fact it's quite transparent)Quote you obviously don't understand It would be easier if you could make it clear what you are saying. Source code translators are available. But they are not used by the average person because they represent a huge amount of research for a taks that a small number of system designers need. Like mega bucks of code that has to be ported onto another system. Some of the major programs we have today stated out as translations of programs written for other CPUs and systems. Then there were later re written in better quality code. If the original code was in C, the process did not need much in the way of an automatic translation. Bur if the program was written in PL/1 or FORTRAN or COBOL, it could be a major job porting it to another platform. Munch of the early work on small personal computers had to be done in Assembler because good C compiles were no available at first. In fact, they were very bad. A early language from Intel was called PL/M and was used to speed up the process and put some structure into our code. And you have to pay big bucks to get a copy. Noways you can get free development tools from Microsoft for your favorite language. (Sorry, no Pascal.) Visual stdio versions of BASIC, C, C++ and J++ plus a Web Builder. But a visual ASM? Foo! That is hard to do. You hive to use MASM32, which is a real pain. look here: http://www.masm32.com/ porting from one architecture to another is only VAGUELY RELATED to the idea of converting from one language to another,but they definitely fall into the same domain. batch, obviously presents a trouble spot since all the various constructs and possible switches and so forth will need to be handled properly; and even so you gain nothing but code obfuscation anyway, since any language it translates too will need to shell to dos to perform the commands such as FIND and MORE and so forth. Quote from: macdad- on January 19, 2009, 09:20:58 AM ASM is source code, machine code very very complex yet very very powerful its not an exeacuteable like EXE. close ! ASM is simply a symbolic form of machine code, and as such it would be foolish to voluntarily select machine code over ASM for programming- as it isn't any more powerful, and much harder to read or interpret; besides- in order to do anything with machine code, one must know (in a way) ASM. As for the second part- not all Executables are machine code, but they almost always have some machine code to get started- for example, some Microsoft C compilers allow the source to be compiled to P-code. the program itself starts with machine code- and the only machine code present is the P-code interpreter. It was similar to the way Java does it, except the program contained the entire JVM for the platform. thats true... ASM would be the more "brushed up" version of Machine code yet ASM is not interchangable with all computers since all computers dont have the same proccessor. which makes it easier to program in higher lvl languages, such as VB and C, they are independent from the proccessor and ASM which makes them interchangeable. |
|
| 2863. |
Solve : Adding text to a file?? |
|
Answer» Is there a code to add text to a file? Liiiike... @Echo off What results are you expecting? Why are you piping the output of the date command into the time command? You might try doing one thing at a time. Code: [Select]echo. | date | find "current" >> Cats.txt echo. | time | find "current" >> Cats.txt Quote And, Is there a way to make this search the whole computer for the file, not just the current..."Folder" or desktop? You computer specs list Win98/ME but I thought set /p was not available until WinNT or even Win2000. In any case I don't see any searching in your posted code. Constructive criticism: Code like this should be bulletproof: Code: [Select]set /p "ans=[ Y / y or N / n] :" if "%ans%"=="Y" goto Y if "%ans%"=="y" goto Y if "%ans%"=="N" goto N if "%ans%"=="n" goto N pause Never assume the user will input one of the suggested options. If they fall into the pause, you might want to re-ask the prompt: Code: [Select]:redo set /p "ans=[ Y / y or N / n] :" if "%ans%"=="Y" goto Y if "%ans%"=="y" goto Y if "%ans%"=="N" goto N if "%ans%"=="n" goto N goto redo or you could try this to, both do the same, but this is smaller Code: [Select]:redo set /p "ans=[ Y / y or N / n] :" if /I "%ans%"=="Y" goto Y if /I "%ans%"=="N" goto N goto redo Quote Copyright 2008 BatchRocks seriously...?? maybe this would be better: Code: [Select]@echo off :R cls set /p OR=what would you like to rename? if "%OR%"=="" exit set /p nom=rename to what? ren %OR% "%nom%" if not %ERRORLEVEL%==0 pause && goto R goto R You don't have to seperate the extension from the file name, you can rename both at the same time. Also you can rename anything from wherever you are at the time, just input the path when inputting the file name. Also to escape from this just press enter when asked what you want to rename. FBBR if you wanted it to be closed source then how about BAT2EXE?Quote from: macdad- on January 17, 2009, 06:44:36 AM BR if you wanted it to be closed source then how about BAT2EXE? If someone WANTS to see the source, then can get a decompiler(haven't found one yet). CONVERTING it to exe doesn't make it impregnable.thats true. wonder about COM EXE2COM since COM is basiclly abandon-extension and is not used as a program file anymore.Quote from: macdad- on January 17, 2009, 09:25:57 AM thats true. Is there EXE2COM, if you have one, please post a link to where I can get it.its pretty old but COULDNT find a good link for it.Ok...but even then, wouldn't someone with enough patience just REVERT it to bat again? Like the BAT2EXE/EXE2BAT things?you don't need a decompiler. somebody posted (quite annoyingly) a simple solution to somebody's problem once, but claimed it was "too complicated" and they "compiled" it. so I ran the program (which had a "pause" in the batch, luckily, and used process explorer. the actual program EXE had spawned a temporary process residing in my temp folder. I opened in notepad... ctrl+pagedown, and boom. the entire batch file sitting there; which I copied and pasted for the fellow who was requesting help. the problem is, there is no "compiler" for batch- they are just obfuscators. EXE2COM only works for programs compiled into the "tiny" memory model- not sure if any of the obfuscators do that. And... it doesn't work for win32 executables either. |
|
| 2864. |
Solve : Help to get position of @ character in a string....? |
|
Answer» Can anyone help me find the position of the @ CHARACTER in the following filename string I really need to get this working ASAP We don't generally guarantee same day service like a laundry, but I was out for a STROLL and stumbled upon this post. Code: [Select]@ECHO off set [emailprotected] Title.mp4 set POS=0 :start call set chr=%%filename:~%pos%,1%% set /a pos+=1 if %chr%[emailprotected] echo Position=%pos% & exit /b goto start We just answered a similar QUESTION. If you're in a hurry, it's better to search the forum. |
|
| 2865. |
Solve : Cartwheel or Blinking Text? |
|
Answer» Anyone know if there is an easy way to show either a cartwheel such as a stationary but transitioning ( / - \ | / - \ | ) in a DOS Shell Window or blinking text like <> in a batch file. I'd suggest ANSI commands, but they don't work with the NT shell. You can do backspaces with gnuecho which comes in the GNU Core Utils For Windows. Cool...thanks everyone for info |
|
| 2866. |
Solve : file extension mso , help? |
|
Answer» i asked this question before in a different form but to-night i think i have found something which may be the answer on an e-mail , so the question is |
|
| 2867. |
Solve : Use an Environment Variable inside another?? |
|
Answer» Win XP Home. I took it on faith that # was a delimiter and not part of the variable. ... you kind of have to do that, don't you? So you can't measure the length of a string that contains the delimiter character. Set a counter to 0. Starting at the first character, create a substring which is composed of the CHARACTERS from the counter position to either the end of the string or 8192 characters along, whichever is the lower. (8192 is the max string length in XP or later cmd. Win2K & NT4 is 2047). Add 1 to the counter. Repeat until the substring is the empty string ("") which MEANS you have run out of characters, i.e. you have reached the end of the string. The counter value is the string length. You have to use call to set the substring because you need to do the variable substitution in a child process. Although this method does not use an added delimiter character which must be absent from the supplied string, it will still break if the supplied string contains control characters especially &, but then so will the previous code. That's a fact of batch life. Code: [Select]@echo off set string=Seems I've got into a bad habit set stringlen=0 :loop call set sstring=%%string:~%stringlen%,8192%% if "%sstring%"=="" goto done set /a stringlen+=1 goto loop :done echo string length=%stringlen% Thanks for that Dias - nice explanation - more for me to puzzle over wow. getting the length of a string is a troublesome task in batch.Quote from: BC_Programmer on January 17, 2009, 02:45:11 AM wow. getting the length of a string is a troublesome task in batch. When you start hitting such problems in batch, often it's a sign that you need to be using another language.Quote from: Dias de verano on January 17, 2009, 04:39:15 AM Quote from: BC_Programmer on January 17, 2009, 02:45:11 AMwow. getting the length of a string is a troublesome task in batch. Like VBScript. Len() Function to the rescue! Quote from: BC_Programmer on January 17, 2009, 04:59:16 AM Like VBScript. Len() Function to the rescue! exactly Code: [Select]@echo off set string=Mary had a little lamb echo Wscript.echo (Len(WScript.Arguments(0)))>stringlength.vbs for /f %%L in ('cscript //nologo stringlength.vbs "%string%"') do set /a slen=%%L del stringlength.vbs echo String length is %slen% Quote from: Dias de verano on January 17, 2009, 04:39:15 AM Quote from: BC_Programmer on January 17, 2009, 02:45:11 AMwow. getting the length of a string is a troublesome task in batch. Hmmm - there's a none too subtle hint |
|
| 2868. |
Solve : Newbie Question about cd? |
|
Answer» Hi, |
|
| 2869. |
Solve : Rename a file per content? |
|
Answer» I have multiple files in a folder and each one needs to be opened; read the first line and determine one of several files to append the entire contents of the opened file to. |
|
| 2870. |
Solve : Delete file and reg key, after killing a task...? |
|
Answer» Quote from: BC_Programmer on JANUARY 17, 2009, 02:39:29 AM then those 2 shouldn't be being helped by you.I will TRY to do that from now on... |
|
| 2871. |
Solve : batch file not taking parameter properly? |
|
Answer» I am passing one parameter to batch file which is date time in following format. Some of the parameters passed to the script appear to be the same PROVIDED with the documentation as placeholders for actual values. If it's the local machine, this should work sufficiently: Code: [Select]eventquery.vbs /fi "Type eq Error" /fi "Datetime eq %1" /l "onlineavl services" >> Eventlogs.log if it isn't the local machine, and/or it requires a password, you'll need to change the placeholder text. |
|
| 2872. |
Solve : Switches - Removing Programs? |
|
Answer» I found the following syntax to REMOVE a program. |
|
| 2873. |
Solve : grouping text in a single line while doing for statement? |
|
Answer» ok. i have a problem. |
|
| 2874. |
Solve : Accommodating the White Spaces in a DOS command? |
|
Answer» hey friends, i want to know how to add white spaces in a DOS command. hey friends, i want to know how to add white spaces in a DOS command. yes. put quotes around the names. Code: [Select]copy "c:\my documents\*.*" "d:\my archives" xcopy "c:\my documents\" "d:\my archives" but why not just use explorer to copy. EDIT: LOL.... beat me to it...thanks BC_programmer. thanks Geek-9pm it worked |
|
| 2875. |
Solve : Echo complex variable? |
|
Answer» Code: [Select]@echo off It looks like you are trying to set a variable for the current directory you are in? Exactly. Quote from: GuruGary on January 15, 2009, 09:03:17 PM I think it is not going to work that way because the %cd% variable is going to have the colon character ( which the SET command will try to use for string substitution. With the output I was receiving, that makes perfect sense. Your code works fantastically for my situation. Thank you for helping, I really appreciate it. |
|
| 2876. |
Solve : CHOICE .V. SET /P? |
|
Answer» Quote from: BatchFileCommand on JANUARY 15, 2009, 05:03:44 PM I LOOKED up Industrial Lathe So then you were the one UNFAMILIAR with what an industrial lathe was. Quote from: BatchFileCommand on January 13, 2009, 05:17:34 PM If you don't KNOW what a industrial lathe is... |
|
| 2877. |
Solve : pause / wait? |
|
Answer» Quote im reinventing the wheel How do you suppose to do that.Quote from: BatchFileCommand on JANUARY 12, 2009, 04:34:22 PM Quoteim reinventing the wheel because it's been done before. i'll see if i cant whip up something, this time it will have a more throurgh debugging to avoid another bug REPORT Quote this time it will have a more throurgh debugging to avoid another bug report I've tried it with pure batch files (78 kb!) I've tried. Even with measly 4 kb, there's always going to spell errors or some kind of problem with administrator access etc. you TALKING about FINFO?Quote from: BatchFileCommand on January 13, 2009, 04:58:04 PM Quotethis time it will have a more throurgh debugging to avoid another bug report If you use a compiled language like VB.NET,VB6, VCPP, or various others... you cannot even compile the program if it has misspellings. Unless of course the typo is still a valid symbol.Quote
That is one thing I don't like about that though. Quote from: BatchFileCommand on January 14, 2009, 04:43:23 PM Quote yeah, it's MUCH better if it crashes with a syntax error on the victim... I mean, clients machine. much more professional. if there are parts of the program that are only executed in extreme conditions, and there is an syntax error... you wouldn't even know until those "extreme conditions" are satisfied. and with 72 PAGES of batch code, there will be a LOT of unexplored code paths just waiting to throw a interpreter error.thats why its smart to seperate the batch programs. |
|
| 2878. |
Solve : Run a program before shutting computer down?? |
|
Answer» I would like to write a batch file that runs an application before shutting the COMPUTER down. The application would take about a minute to complete, then computer can shut itself down. The code is relatively easy to make: That would bring an error(you wouldn't see it because there is no PAUSE). Shutdown /s doesn't exist, it's -s .Quote Shutdown /s doesn't exist That's because you use xp. I use vista. Quote from: BatchFileCommand on January 12, 2009, 04:28:47 PM QuoteShutdown /s doesn't exist and so will everybody that ever uses your program, I take it.If I had a program that was worth giving out to people, I always make an xp version. Locbtran didn't specify EXACTLY what OS he had, so to make sure, you could have had 2 seperate code boxes, one which states it's for vista, the other for XP...(Or any other OS).I have also used a program called Xecutor but it costs money for commercial use. Free for private use. http://english.xecutor.de/It's like my program hyperfolder with a few goodies . I could make a program even better in 15 days.It isn't hard to just make this VBS Quote from: Sidewinder on DECEMBER 27, 2008, 10:06:47 AM QuoteCan VBScript shut down a PC? and then use it in a batch file- run the program, then run the script.Quote from: BC_Programmer on January 13, 2009, 06:14:35 PM It isn't hard to just make this VBS This is how I incorporate VBS into a batch file. echo 'visual basic script' >> script.vbs I need to do this for every SINGLE line of code. Is there a quicker way of doing this? thank youQuote This is how I incorporate VBS into a batch file. I've seen this technique posted on the boards and I'm puzzled why anyone would do this. Using batch code to output a VBScript seems overly complex when the script has characters that are specially used by the batch interpreter. All those pesky escape characters. Why not write the code in an editor, save the script with a vbs extension and then call the script from the batch file? Code: [Select]call cscript drive:\path\scriptname.vbs By creating a separate file for the VBScript, you can call the script from multiple batch files without having to reinvent the wheel. Good luck. |
|
| 2879. |
Solve : Need help with housekeeping of files? |
|
Answer» Hi, You have two different naming conventions in the high level folder. Yeah, I need to modify that. EVENTUALLY, It will only have one naming convention. But yet again, this is exactly what I wanted. works perfect. Everytime I have posted a question, your answer has been perfect, bang on target. You are a guru of batch programming. I am sure you have acquired this knowledge due to years of experience with Batch scripting. I would like to learn batch scripting in detail. Most of the things are quite easy, except for complicated for loops. Could you suggest me some BOOK. Also some best practices, things that should not be missed when coding a Batch program. Maybe Admin's could start a new topic that could be helpful to all.. Thanks once again Sidewinder.. You Rock!!! Back in the day when DOS was an operating system and not some misquoted acronym, both the IBM and Microsoft DOS actually came with manuals. Really! Nowadays, you buy a Windows operating system and Microsoft kicks you in the *censored* and wishes you good luck. Really! This article may be what you're looking for. Be sure to check out the epilog for that wish of good luck. |
|
| 2880. |
Solve : commands are disabled...!!!!? |
|
Answer» whenever i type any command such as help in my dos prompt , i get the following message...Quote 'help' is not recognized as an internal or external command, operable program or batch file.... Seems as if some or more commands are disabled...how can i re-enable them.... plzzz...do help..... my operating system is WINDOWS xp and dos version is 5.1.2600Check your path. Type path at the command prompt then hit ENTER. Check to see if c:\windows\system32 is listed. You may have run a program that overrode the system path. Sometimes closing the command prompt and re-opening it will clear the problem. It intrigues me, what could override the path to system32 . When changing the path it's better to concatenate whatever directory onto the EXISTING path. Code: [Select]SET path=%path%;c:\user If a batch file attempts something like this: Code: [Select]set path=c:\user the path remains in effect until the command window is closed. Batch code cannot make permanent changes to environment variables, so the NEXT time a command window is opened, the system environment is re-established to the default values. PS. Not saying this is the OP problem. Only a possibility. |
|
| 2881. |
Solve : REG ADD question. I'm stumped.? |
|
Answer» Hello, REGEDIT4Dias, I'm not sure what you mean... what I have above is not a valid registry file when saved as .reg? Could you break it down for me a good bit more because I'm unsure where to start from what you posted. Pardon me as I am only a novice. This is how I interpreted your post for me to start... but this didn't add anything to the registry, so I take it this is not what you want me to try: REGEDIT4 [HKLM\SYSTEM\CurrentControlSet\Control\FileSystem] @="NtfsMemoryUsage" I'm using xp home if that matters. I could not get the file starting REGEDIT4 to work! However, Microsoft has a page of useful help at this address http://support.microsoft.com/kb/310516 Which you could have found easily using Google! (Have you heard of Google?) Quote A .reg file has the following syntax: Quote RegistryEditorVersion is either "Windows Registry Editor Version 5.00" for Windows 2000, Windows XP, and Windows Server 2003, or "REGEDIT4" for Windows 98 and Windows NT 4.0. The "REGEDIT4" header also works on Windows 2000-based, Windows XP-based, and Windows Server 2003-based computers. Quote Blank line is a blank line. This identifies the start of a new registry path. Each key or subkey is a new registry path. If you have several keys in your .reg file, blank lines can help you to examine and to troubleshoot the contents. Quote RegistryPathx is the path of the subkey that holds the first value you are importing. Enclose the path in square brackets, and separate each level of the hierarchy by a backslash. For EXAMPLE: Quote DataItemNamex is the name of the data item that you want to import. If a data item in your file does not exist in the registry, the .reg file adds it (with the value of the data item). If a data item does exist, the value in your .reg file overwrites the existing value. Quotation marks enclose the name of the data item. An EQUAL sign (=) immediately follows the name of the data item. Quote DataTypex is the data type for the registry value and immediately follows the equal sign. For all the data types other than REG_SZ (a string value), a colon immediately follows the data type. If the data type is REG_SZ , do not include the data type value or colon. In this case, Regedit.exe assumes REG_SZ for the data type. It appears that you are trying to modify ntfs performance by using a registry tweak. You need to be aware that the tweak you propose to use will only have any useful effect if you have 2 GB or more of RAM. If you have LESS, ntfs performance will be badly REDUCED! However, this would be the reg file format: dword values: 00000001 normal (default) setting 00000002 enhanced (performance) setting if you have > 2 GB RAM Code: [Select]Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem] "NtfsMemoryUsage"=dword:00000002 Of course I have heard of google, Dias and despite what you think I was using it a lot before I resorted to coming here. I didn't come here to get someone else to do all the work for me. Here's what happend... I had success modifying existing dword values and when I needed to create one that wasn't already there I *censored*umed I had to use completely different syntax. I had just figured it out before you layed into me. Thanks for the help Dias... you are kind of on EDGE but your knowledge is extensive and appreciated. Happy New Year. You are right; I had no need to patronise you. I apologise. Blame it on last night's Argentinian Malbec.No problem. |
|
| 2882. |
Solve : Finding text in files? |
|
Answer» The DOS DIR command is great, but it does have its limitations. I'm trying to find a particular word as it occurs in all files. and re-direct the results of the search to a text FILE. I'd also like to be able to exclude some folders (like that with my saved email) which are just going to complicate things. I obviously have done something wrong I told you to drive carefully. Actually you did nothing wrong, it was all my doing. I keep getting carried away, forgetting that batch code is not a programming language. So for my next trick, I went all procedural, which should make it easier to read, if nothing else. Code: [Select]@echo off setlocal enabledelayedexpansion :: :: Exclude array :: set array.1=c:\Paprport set array.2=c:\windows for /f "tokens=* delims=" %%f in ('dir c:\ /a:d /s /b') do ( set count=0 for /l %%i in (1,1,2) do ( if /i !array.%%i! EQU %%f set /a count+=1 ) if !count! EQU 0 call :search %%f ) goto :eof :search for /f "tokens=* delims=" %%d in ('dir %1 /a:-d /b') do ( find /i "standard" %%f\%%d > nul if not errorlevel 1 echo %%f\%%d >> FOUNDIT.TXT ) This code has been tested and appears to meet all your specs. Good luck. Quote from: Sidewinder on December 22, 2008, 03:57:21 PM QuoteI obviously have done something wrong I tried (actually am trying now) your new code, and it seems to be working. It's slow, but I expected that (Good;Fast:Cheap: You can only have 2 of them). Thanks so much for your help. And a Merry Christmas (or whatever you prefer) to you. TomThe code finished running, and it looks like it's back to square 1 now. The program found instances of the text I was looking for, and put the name of the file in the new file I wanted it to. Unfortunately, the instances it found were in a sub-directory of a directory I told it to exclude. It did not find the word in a file in the root directory I ran it from. When run with the /s switch omitted, nothing was found, and no new file was created. It indicated while running that access was denied to the directories I wanted excluded, however. The above was run on a machine using WIN2000. When I tried to run it on a machine with WIN98SE, it wouldn't run at all. It reported problems with the syntax. If I wasn't so stubborn, I'd give up, but there's an answer lurking there somewhere. TomWhile I was hunting down my Santa Claus outfit, I found a script in the snippet closet. With a tweak here and a tweak there, we could be talking about a serious script: Code: [Select]On Error Resume Next Const ForReading = 1 xDir = Array("c:\Paprport", "C:\Windows") 'Exclude array Set fso = CreateObject("Scripting.FileSystemObject") Set LogFile = fso.CreateTextFile("c:\temp\foundit.txt", True) Set dc = fso.Drives For each ds in dc Select Case ds.Driveletter Case "C" 'drive to search Set RootDir = fso.GetFolder(ds & "\") 'directory to start search GetTheFolders(RootDir) End Select Next LogFile.Close Function GetTheFolders(Folder) For Each Subfolder in Folder.SubFolders blnExclude = False For Each item In xDir If InStr(1, SubFolder.Path, item, 1) > 0 Then blnExclude = True Next If blnExclude = False Then GetTheFiles(Subfolder.Path) GetTheFolders Subfolder End If Next End Function Function GetTheFiles(FileFolder) Set f = fso.GetFolder(FileFolder) Set fc = f.Files For Each fs in fc If fso.GetExtensionName(fs) = "txt" Then 'Extension to look at Set k = fso.OpenTextFile(fs, ForReading) strFile = k.ReadAll k.Close If InStr(1, strFile, "standard", 1) > 0 Then LogFile.WriteLine fs End If End If Next End Function Yes I know, this is not batch code. Save the script with a vbs extension and run from the command prompt as cscript scriptname.vbs The script will scan the C drive looking for txt files. The drive can be changed and we can add more extensions, but there really is no point in checking exe files for a string. Happy Christmas to you and a Merry New Year. Quote from: Sidewinder on December 23, 2008, 04:48:49 PM While I was hunting down my Santa Claus outfit, I found a script in the snippet closet. With a tweak here and a tweak there, we could be talking about a serious script: Thanks for the code. It looks like it would find a string in a TXT file, but only there. What I was trying to do is find a particular string in files of any type, and to exclude directories where the string I was looking for couldn't possibly be found; and then to put the results into a file. (A word of explanation for my wanting to do a thing like that might be helpful here. It's for my wife, who is looking for something she stored on her computer, but can't remember the name of the file, nor where she put it; only what it was about.) Windows does the first PART of what I want to do with its Search (Find) function, but won't do the 2nd part. Nor will it put the results into a file. The previous code you sent looked like it would remedy those deficiencies, but it didn't work. I'd like to find out why it wouldn't do what it should have done. I'll understand if you throw up your hands at this point. I know I would if I were in your place. I'll keep plugging away at it, though. I hate not being able to figure things out. As I often say: I wish I understood all I know about computers. Tom Quote The previous code you sent looked like it would remedy those deficiencies, but it didn't work. I'd like to find out why it wouldn't do what it should have done. Which previous code? The VBScript worked fine when it was tested. The previous batch code had it's own set of problems. Anyway I find it easier use a tool that has the functionality I need to reach a solution. Personally I find batch code underpowered and logically exhausting. Quote Thanks for the code. It looks like it would find a string in a file.TXT file, but only there. What I was trying to do is find a particular string in files of any type, and to exclude directories where the string I was looking for couldn't possibly be found; and then to put the results into a file. The excluded directories are in the xDIR array and the file names that contained the search argument were logged to the foundit.txt. I used the temp directory on my system for the log file, you may not have that directory on your system. We can change it to a directory you do have. As mentioned, we can add extensions to include or create extensions to exclude. Did you run the VBScript? Can you document any specific problems? Quote from: Sidewinder on December 24, 2008, 08:51:25 AM QuoteThe previous code you sent looked like it would remedy those deficiencies, but it didn't work. I'd like to find out why it wouldn't do what it should have done. The previous code I referred to was the last batch code you sent. I ran the VBScript code you sent, and didn't get any results. I can't document any specific problems, since the code ran silently, showing nothing on the screen, All I know is that no file called "Foundit.txt" was created, even though I had specifically created a TXT file in the Root directory containing the string I was searching for. I'm not familiar with scripts, so I can't manipulate the code you sent in order to make the results appear on the screen; nor can I, for instance, eliminate sub-directories. It looks like I'm going to have to learn scripting, though, since your code, even though it didn't produce results, ran a lot FASTER than if it were a batch file. I do appreciate your efforts, and am sure that the failure to produce results lies with me, not you. TomQuote All I know is that no file called "Foundit.txt" was created, even though I had specifically created a TXT file in the Root directory containing the string I was searching for. Perfect! Well, you can always have the search script search for it's output file. Code: [Select]On Error Resume Next Const ForReading = 1 xDir = Array("c:\Paprport", "C:\Windows") 'Exclude array Set fso = CreateObject("Scripting.FileSystemObject") Set LogFile = fso.CreateTextFile("c:\temp\foundit.txt", True) Set dc = fso.Drives For each ds in dc Select Case ds.Driveletter Case "C" 'drive to search Set RootDir = fso.GetFolder(ds & "\") 'directory to start search GetTheFolders(RootDir) End Select Next LogFile.Close Function GetTheFolders(Folder) For Each Subfolder in Folder.SubFolders blnExclude = False For Each item In xDir If InStr(1, SubFolder.Path, item, 1) > 0 Then blnExclude = True Next If blnExclude = False Then GetTheFiles(Subfolder.Path) GetTheFolders Subfolder End If Next End Function Function GetTheFiles(FileFolder) Set f = fso.GetFolder(FileFolder) Set fc = f.Files For Each fs in fc If fso.GetExtensionName(fs) = "txt" Then 'Extension to look at Set k = fso.OpenTextFile(fs, ForReading) strFile = k.ReadAll k.Close If InStr(1, strFile, "standard", 1) > 0 Then 'LogFile.WriteLine fs wscript.echo fs End If End If Next End Function As before, save the script with a vbs extension and run from the command prompt as cscript scriptname.vbs Quote I'm not familiar with scripts, so I can't manipulate the code you sent in order to make the results appear on the screen; nor can I, for instance, eliminate sub-directories. I modified the script to display the results on the console. It was the sub-directories that gave me problems with the original batch file. With any luck, those problems have been eliminated with the VBScript. Note: c:\windows is excluded from the search, along with all it's sub-directories. Let me know if this is incorrect. Quote It looks like I'm going to have to learn scripting, though, since your code, even though it didn't produce results, ran a lot faster than if it were a batch file. Did you use Windows Search to look for the foundit.txt file (ironic, huh)? It should be in c:\temp. I can't be certain if the CreateTextFile method would create the directory if it was not found. I'm not suggesting it (I've been putting off downloading to my system), but Windows Desktop Search can be scripted through the Search object. Windows Update has been bugging me for moths to download it. Might be time to check it out. I think next Christmas I'll do without the Santa outfit. Sorry, the new code didn't work, either. As before, nothing showed on the console while it ran. A file called "Foundit.TXT" was created, but it had no contents. TomSUCCESS!! The latest code you sent did work after all. The fault, as I suspected, was mine. The word I had chosen to search for didn't exist in a TXT file, and therefore couldn't be found. When I substituted a word which did exist, the program ran and produced the appropriate result. Thanks. Now I have to figure out how to search in files with other extensions, or perhaps learn to exclude those extensions which won't contain the string (like EXE or COM files, or image files) 'll keep plugging away at it. TomQuote SUCCESS!! Glad it worked. Quote Now I have to figure out how to search in files with other extensions, or perhaps learn to exclude those extensions which won't contain the string (like EXE or COM files, or image files) Try creating an array of the extensions like the excluded directories. arrExt = Array("exe", "com", "jpg", "bmp", "png")....add as many as you need, each extension quoted with a comma separator Code: [Select]Function GetTheFiles(FileFolder) Set f = fso.GetFolder(FileFolder) Set fc = f.Files For Each fs in fc blnExclude = False For Each ext In arrExt If LCase(fso.GetExtensionName(fs)) = ext Then blnExclude = True End If Next If blnExclude = False Then Set k = fso.OpenTextFile(fs, ForReading) strFile = k.ReadAll k.Close If InStr(1, strFile, "standard", 1) > 0 Then 'LogFile.WriteLine fs wscript.echo fs End If End If Next End Function Good luck and Happy New Year! Considering all the file extensions on a PC, this could get interesting. |
|
| 2883. |
Solve : Automate changes - SortIDs? |
|
Answer» This is for work and the code is taken from this site I just tried tweaking and I'm not getting very far. ELSE( The First ELSE STATEMENT is used when it determines that the 5th token has a value and the IF statements are in place to take one ID # and change it to something else. The final ELSE which can't work ... I need a way to Echo the line even if it doesn't match part of the other criteria so I don't remove something that maybe needed as part of the configuration. Ahhh, I see now; you have this part of code in the first else: Code: [Select]If "%%E"=="%CurrIDP%" echo %%A;%%B;%%C;%%D;%newIDP%>>%outputfile% If "%%E"=="%CurrIDD%" echo %%A;%%B;%%C;%%D;%newIDD%>>%outputfile% If "%%E"=="%CurrIDO%" echo %%A;%%B;%%C;%%D;%newIDO%>>%outputfile% and the last else was intended for if none of these conditions are true. (because, as you said, you want to write something even if none of these do. I thought about it for a little bit, and came up with a workable solution: Code: [Select]set %hasoutput%=NO If "%%E"=="%CurrIDP%" ( echo %%A;%%B;%%C;%%D;%newIDP%>>%outputfile% set %hasoutput%=YES } If "%%E"=="%CurrIDD%" ( echo %%A;%%B;%%C;%%D;%newIDD%>>%outputfile% set %hasoutput%=YES ) If "%%E"=="%CurrIDO%" ( echo %%A;%%B;%%C;%%D;%newIDO%>>%outputfile% set %hasoutput%=YES ) if "%hasoutput%"=="NO" then echo %%A;%%B;%%C;%%D;%%E>>%outputfile% and remove the third else that you have there.This is what I came up with ... Thanks BC_Programmer ... Got it working. Code: [Select]for /f "tokens=1,2,3,4,5 delims=;" %%A in (%ivlogin%) do ( set hasoutput=NO Echo A:%%A , B:%%B , C:%%C , D:%%D , E:%%E ^& errorlevel:%Errorlevel%>>%log%\PattIDChg.log If "%%E"=="" ( echo %%A;%%B;%%C;%%D;>>%outputfile% ) ELSE ( If "%%E"=="%CurrIDP%" set hasoutput=YES & echo %%A;%%B;%%C;%%D;%newIDP%>>%outputfile% If "%%E"=="%CurrIDD%" set hasoutput=YES & echo %%A;%%B;%%C;%%D;%newIDD%>>%outputfile% If "%%E"=="%CurrIDO%" set hasoutput=YES & echo %%A;%%B;%%C;%%D;%newIDO%>>%outputfile% If "%hasoutput%"=="NO" echo %%A;%%B;%%C;%%D;%%E>>%outputfile% ) ) pause |
|
| 2884. |
Solve : Please, What does the @ do in the following example?? |
|
Answer» Thanks in advance! fav songs: that's your reward Dias. I'm to scared to click the links myself. My favourite song would be the "ewe overture" or "symphony of the Billy-Goats". I prefer the pictures though.Quote from: BC_Programmer on January 14, 2009, 04:04:15 PM Quote from: vmars on January 14, 2009, 03:39:56 PMfav songs: Cruel. I don't like those songs. I like Queen, Green Day, and Tim Powter.When you start talking with US "old-schoolers" you will hear some funny stories. I was working for ITT Servcom in the early 80's and I was in a bank presidents office one day when I noticed a bright colored DOS menu on his computer screen. I asked "How do you do that" and for the next hour, I sat there getting my first formal training in DOS batch file and menu creation, from a Bank President. A PRACTICAL use of the @ sign would be to blank out just one line, in a batch file where all the other lines are being echoed to the screen. When you start a batch file with Echo OFF, you put the @ sign at the start of the line so the command Echo Off won't be echo'ed to the screen. I was taught to put: @Echo Off cls at the beginning of every batch file. I do that to this very day. It clears the screen ( CLS ) and keeps it clean while the batch file runs, unless you instruct it to echo certain lines to the screen. For batch file testing, you MAY want to disable the @Echo Off command during the testing procedure. Then you can see if there are any error messages to your commands. To disable any line, just put two colons ( :: ) at the beginning of the line and DOS will totally ignore that line. If you use REM, then DOS will continue to read the entire line, even though it will not (usually) execute it. There are a few instances where the line or part of it MAY be executed, that's why I never use REM, but always the double colon. Now it's just a habit. Also, the batch file runs faster if DOS doesn't have to read the remark lines. Cheers Mates, keep up the good work! The Shadow Quote from: BatchFileCommand on January 14, 2009, 04:40:53 PM Quote from: BC_Programmer on January 14, 2009, 04:04:15 PMQuote from: vmars on January 14, 2009, 03:39:56 PMfav songs: I was of course joking Queen is my all time favourite band.Quote from: TheShadow on January 14, 2009, 05:07:59 PM To disable any line, just put two colons ( :: ) at the beginning of the line and DOS will totally ignore that line. If you use REM, then DOS will continue to read the entire line, even though it will not (usually) execute it. There are a few instances where the line or part of it MAY be executed, that's why I never use REM, but always the double colon. Now it's just a habit. I'm an old schooler myself, and I might just add that the undocumented unofficial use of a broken LABEL ( as a comment will break inside a FOR loop, which is why I never use it. |
|
| 2885. |
Solve : What Command that promt to Fill In Text? |
|
Answer» Hi All, :startThanks dude, I appreaciate that.. I will try to use it.. e-BamThanks guys (BatchFileCommand).. Its working.. e-bamContinue from the last question. Now the situation is; You have 1 text file called “data.txt” in 1 folder named “SOURCE”. The data.txt has a numbers of characters as per below: Bam;060180;engineer John;050881;executive Salem;151281;hackers : : When you click the batch file, you will be asking to insert the invoice no. as per yesterday discussion. The question is, how to make output data.txt file as per below? Invoice No: 1234 Bam;060180;engineer John;050881;executive Salem;151281;hackers : : Please advice..So, you want it to display Quote Invoice Number:followed by the invoice number? Simple! Where it says Quote echo "%variable%" > some_filereplace that with Code: [Select]echo Invoice No: "%variable%" > some_file If you want it to display Invoice No at the begining, that gets a bit tricky...But it's still possible! Code: [Select]Echo Invoice No: "%variable%" > some_other_file type data.txt >> some_other_file type some_other_file > data.txt del some_other_file There, that will do it. Here is a step-by-step explanation of the script: 1. Sends "Invoice No: %variable%" to some_other_file which is important. 2. Sends the FULL contents of data.txt to the end of some_other_file. 3. Sends the full contents of some_other_file (part 1 + 2) to data.txt and overrides anything that was previously in data.txt 4. Deletes some_other_file. Understand? I've understand whats u means. Thanks a lot. BTW, yesterday I've BUILD up the command like this: Code: [Select]SET /P VARIABLE=Please Key In DD No. and NAME: ECHO "%VARIABLE%" > C:\HLA\PAGECOUNT\DDNO\DDNo.txt PAUSE REM --- Merge the DDNo.txt with Data file COPY "C:\HLA\PAGECOUNT\DDNO\DDNo.txt"+"C:\HLA\PAGECOUNT\PDFPROCESS\NGC_DAILY.txt" "C:\HLA\PAGECOUNT\PDFPROCESS\SUBMERGING\NGC_DAILY.txt I use MERGING command where, I create 1 file DDNo, then merge with the data text. Then its work. How bout if u want to insert the text line in the middle of data text? e-Bam |
|
| 2886. |
Solve : what are tokens?? |
|
Answer» as said in subject what are tokensUsed with the For /F command, perhaps others. Tokens are segments of text that are separated by delimiters. I think that's an okay explanation? I think it was a very good one. whats the /f comand (im stupid)Quote from: steven32collins on January 14, 2009, 05:32:44 AM whats the /f comand (im stupid) and lazy. Type for /? at the prompt. what does "/?" do? (I'm STUPIDER) This thread is just getting funny'er and funny'er!! Not all, but many DOS commands have options, called switches. They "Switch" the WAY the program works. Lets take a really simple one,,, DIR for Directory. If you'll type "Dir /?" at a command prompt, it will give you a listing of all the switches that can be used with the Directory command. /a show ALL files /w show a WIDE directory /p show the directory, one page at a time. There are more, but that should give you an idea. Type any DOS command and follow it with a space and a /? and it will respond by printing on the screen a listing of all the switches that apply to that command. What " /f " means, depends on what command precedes it. It doesn't necessarily MEAN the same thing for every command. Everything ever printed about DOS, is available somewhere on the internet. Search, search, search and then Read, Read, Read. Some of us have been learning and re-learning this stuff for nearly thirty years. You won't likely get it all over night. A few years ago, many new DOS commands were added and some of the old ones were greatly enhanced. I'm "Old School" and still don't know all the new stuff. I've probably not learned any new DOS commands since the DOS 6.22 days. My use of DOS today, is PRETTY much limited to simple Batch files and menus. Cheers Mates! Keep up the good work! The Shadow aww, shadow, you came and spoiled all the fun and isn't /a used for "attributes"? and then if you don't give it further qualification it will show all files? |
|
| 2887. |
Solve : Copy command - SUB tag?? |
|
Answer» I'm using use the DOS 'copy' statement to link three parts of an xml file together. However the completed file has an additional 'SUB' tag at the end that I didn't expect: |
|
| 2888. |
Solve : help! my MS-DOS is not working! SHUTDOWN ERROR!? |
|
Answer» HELP!! and.. of it does turn out to be a corrupted EXE, they 'll guide through the use of SFC rather then a straight copy to prevent windows file protection from maybe restoring the corrupted file.Exactly. |
|
| 2889. |
Solve : How to send bat session to file?? |
|
Answer» Please, |
|
| 2890. |
Solve : For token(I think)...? |
|
Answer» I'm very new to the whole FOR command, everything in the help just blows me away... I mean, is it more important to understand the FOR command, or is it m,ore important to do a certain thing that improves the computer presentation. Priority: 1. Getting the job done 2. Understanding it more, so I won't be so dependant. I promised my friend that I would do it, but as I said in the first post, I just don't know. |
|
| 2891. |
Solve : Token replacement/removal within delimited string? |
|
Answer» Is token replacement/removal within a delimited string possible within a batch file? What I was hoping to avoid was having to deconstruct the string and rebuild it every time. Why? This is the kind of task that computers are good at. Quote from: Dias de verano on January 13, 2009, 02:50:43 AM
Because I have to write the code for it to work. half of everything is work.Quote from: BC_Programmer on January 13, 2009, 03:10:53 AM half of everything is work. What's the other half?Quote from: gregory on January 13, 2009, 03:13:43 AM Quote from: BC_Programmer on January 13, 2009, 03:10:53 AMhalf of everything is work. Thinking I would have been so tempted to say "fate".I was thinking of the definition of genius, I think, 1% inspiration, 99% perspiration. why not use set ? easier i think Quote from: devcom on January 13, 2009, 12:51:05 PM why not use set ? easier i think read his question again. the item to be replaced is neither at an ABSOLUTE position nor a KNOWN size, so for would be needed. Quote from: devcom on January 13, 2009, 12:51:05 PM why not use set ? easier i think Give US some example code, then... Here's the original question, to refresh your memory. Read it carefully. Quote Is token replacement/removal within a delimited string possible within a batch file? |
|
| 2892. |
Solve : Escape Key symbol? |
|
Answer» Would there be a symbol for the escape KEY. I'm trying to make a batch file, and if you press escape it goes back to the main menu.Use alt-27. Note: the 27 must be typed from the numeric keypad. Every application seems to see escape as a different symbol. One EDITOR I have sees it as a question mark, notepad sees it as a left pointing arrow, and the command line sees it as ^[ But it's not like the persons using the program in notepad . So, what's the symbol in batch files. Or would it be the same as the command line. it won't matter what the symbol is. Most applications, when seeing the escape, with translate it into a upwards arrow, but most translate it into the square "unknown glyph" box, but guess what... it's code changes as well. you would need to edit your batch file via COPY CON or the DOS edit program in order to get the proper codes in. OR- use a real text editor, like EmEditor, PFE, Editpad, UltraEdit...Quote use a real text editor I use a real text editor for programming languages. Notepad ++ is an awesome program.ok, you should be able to insert a symbol somehow. the ASCII code, if memory serves, is 26. Could be wrong, though.Quote from: BC_Programmer on January 12, 2009, 07:48:15 PM ok, you should be able to insert a symbol somehow. the ASCII code, if memory serves, is 26. Could be wrong, though. You are. Escape is 27. Tada! It worked. Problem solved .Quote from: Dias de verano on January 13, 2009, 06:08:40 AM Quote from: BC_Programmer on January 12, 2009, 07:48:15 PMok, you should be able to insert a symbol somehow. the ASCII code, if memory serves, is 26. Could be wrong, though. Awww, So close too! Good thing I added the disclaimer Quote from: BC_Programmer on January 13, 2009, 12:44:21 PM Quote from: Dias de verano on January 13, 2009, 06:08:40 AMQuote from: BC_Programmer on January 12, 2009, 07:48:15 PMok, you should be able to insert a symbol somehow. the ASCII code, if memory serves, is 26. Could be wrong, though. Time was, I knew them all by heart... all way from 0, NUL to 128, these DAYS if I ever need an ASCII code, I just look 'em up. My favourite editor, UltraEdit32, has an ASCII chart in the View menu |
|
| 2893. |
Solve : How to Make the Matrix? |
|
Answer» This is how to make the Matrix in a batch file- looks like a bunch of numbers to me. Although I suppose, since it is a 2-dimensional array, one could call it a matrix. but it is no more a matrix then those used in 3d projection transformations. WELL...I am not impressed by this. Where did I see this before?Quote from: kpac on December 23, 2008, 03:42:50 PM Where did I see this before? perhaps here? Quote from: macdad- on December 23, 2008, 04:58:13 PM Quote from: kpac on December 23, 2008, 03:42:50 PMWhere did I see this before? Nope that version is crapwhat the crap!!!!!!!!!!!!!!!!!!!!!! you stole the signature bar i was using!!! and thanks for your comment. Quote from: DFND-jimjim1 on December 23, 2008, 05:28:45 PM Quote from: macdad- on December 23, 2008, 04:58:13 PMQuote from: kpac on December 23, 2008, 03:42:50 PMWhere did I see this before? excepting of course the fact it does the EXACT same THING yours does, with a more appropriate color, as well as not having spaces. before declaring somebody elses work as crap perhaps you should reevaluate just how similar it is to your own. Quote from: macdad- on December 23, 2008, 05:35:14 PM what the crap!!!!!!!!!!!!!!!!!!!!!! you stole the signature bar i was using!!! it's green, he must have made it from scratch, that is SO NOT just a cosmetic change. And he DECIDED that he's special since one of his threads got enough replies to become a "hot" topic. Of course the issue would have been resolved by simply rebooting the router in the FIRST place, I'm sure, and the constant refusal to enter any configuration pages MAKES any assistance moot.Thanks....*glar*Quote from: DFND-jimjim1 on December 23, 2008, 05:45:17 PM Thanks....*glar* *glare* now explain yourself! Why did you take macdad's sig bar. So glad I removed mine... |
|
| 2894. |
Solve : A reading batch file.? |
|
Answer» Hello all, |
|
| 2895. |
Solve : Batch script to automatically bypass username in firefox?? |
|
Answer» At work I need to enter in my username and password just to open up firefox. I would like to write a batch FILE that can automatically ENTERS in my username and password when I open up firefox. |
|
| 2896. |
Solve : Incrementing a for loop? |
|
Answer» Is it POSSIBLE to increment a for loop counter? |
|
| 2897. |
Solve : Duplicate LPT to COM? |
|
Answer» Does anyone know about the DOS program which can duplicate LPT output to COM? What about using MODE to redirect LPT2 to COM1 and then print to LPT1 and LPT2 I was going to suggest that myself, but they want duplication, not redirection. As geek said, for your exact situation without buying additional hardware, a TSR would probably be needed. It might even be true that one has already been written. but here's the thing, one is SERIAL, the other is PARALLEL. how do you duplicate a parallel output to a serial output properly? It's messy, at the very least; one would literally have to learn the SPECIFICS of how the capture box takes input. If it is simply text, it probably can be sent the exact same thing as the Parallel port is told to send. if it needs the exact same stream, then things could get messy. Another solution is, I believe they have parallel to Serial adapters.If you send the print to a File first... then run the print instruction to LPT1 and LPT2, that will duplicate the output of the initial print due to LPT2 redirect to Com1. If they are unable to print to a file, then yes this wouldnt work for replication, but if they can print to file and then call that file to print to both LPT1 and LPT2 ( redirected port ) then it should work. And if there is any graphics ( logos etc ), yes the setup would likely puke as for this would only work best if all ascii due to printing to a file would likely create a file that cant be printed or it would strip the graphic that is unable to be interpreted. I don't think DOS has a "print to file" feature built in.You are correct, DOS PRINT has no switches available to print to file but... there is a TSR available, although I havent used it to RATE how well it works at http://www.computing.net/answers/dos/dos-print-to-file/9514.html This should allow printing to file....Other issue I just realized with the duplicate print is that its great and all about setting up LPT1 and LPT2 to print through MODE redirection of LPT2 to COM1, printing from file, but this process is not automated. Problem being that a print task would go out to file...then nothing would happen. Some service would have to know that the file has changed etc or been created and then print at both devices at both ports. ... Cant believe I overlooked that detail that is an important detail to make this work... Our setup to print at 2 printers for our Food Store uses a VB Script and Windows, which have so much more potential than just DOS. |
|
| 2898. |
Solve : can i start a new windows os in comand promt?? |
|
Answer» just like the topic but its the same xp im using |
|
| 2899. |
Solve : if statement in a for statement? |
|
Answer» Is is possible to put an if statement in a for statement? Here is the BATCH file... Is is possible to put an if statement in a for statement? Sure is! One problem I see is that the :20 construct either gets executed directly from a goto or ELSE the logic falls into the construct after wsftppro.exe executes. The other problem is that %%f variable is referenced outside the for loop. Code: [Select]for %%f in (%file1% %file2%) do if not exist %source%\%%f goto 20 "C:\Program Files\Ipswitch\WS_FTP Professional\wsftppro.exe" -s local:%source%\%%f -d interfaces!kidneykonditioning:%dest% -quietd If both the if statement and the wsftppro.exe program are part of the for loop, you'll need to use parenthesis: Code: [Select]for %%f in (%file1% %file2%) do ( if not exist %source%\%%f goto 20 "C:\Program Files\Ipswitch\WS_FTP Professional\wsftppro.exe" -s local:%source%\%%f -d interfaces!kidneykonditioning:%dest% -quietd ) You have access to goto :eof which I think should be the last statement in the phase1 construct. Of course you may want to issue a message that all is well. I've modified it as per your suggestion but doesn't seem to get past the first file. What am I missing??? Thanks!!! @echo on SET file1=test1.txt SET file2=test2.txt SET source=U:\gendl SET dest=/home/asolutions/ SET logfile="U:\BatchFiles\IPSwitch Log Files\test.log" :phase1 cd /d %source% for %%f in (%file1% %file2%) do ( if not exist %source%\%%f goto 20 "C:\Program Files\Ipswitch\WS_FTP Professional\wsftppro.exe" -s local:%source%\%%f -d interfaces!kidneykonditioning:%dest% -quiet ) goto end :20 @ECHO ON DATE /t >> %logfile% TIME /t >> %logfile% echo "No file to send!!!" >> %logfile% ECHO =================================================== >> %logfile% :end Quote I've modified it as per your suggestion but doesn't seem to get past the first file. What am I missing??? Probably nothing. Did you try to debug the code? I suspect this line is the problem: Code: [Select]if not exist %source%\%%f goto 20 If expanded, it should look like this: if not exist U:\gendl\test1.txt Does the file exist? If not, the logic goes to :20, never to return to check for file2.txt Consider rewriting the for loop to use an either/or approach. if not exist filename (call :20) else (execute wsftppro.exe) I'll leave it to you to fill in the paths and parameters. That's correct, if expanded that's how it should look. How do I make it return to check for additional files (i.e. file2, file3, etc.) logging each entry for "No file to send" if file does not exist. If files do exist to run the wsftp program? Would if be better to just have multiple if STATEMENTS & not use the for loop? Ex. if exist %file1% do ("C:\Program Files\Ipswitch\WS_FTP Professional\wsftppro.exe" -s local:%source%\%%f -d interfaces!kidneykonditioning:%dest% -quiet) else ( @ECHO ON DATE /t >> %logfile% TIME /t >> %logfile% echo "No %file1% to send!!!" >> %logfile% ECHO =================================================== >> %logfile% ) if exist %file2% do ("C:\Program Files\Ipswitch\WS_FTP Professional\wsftppro.exe" -s local:%source%\%%f -d interfaces!kidneykonditioning:%dest% -quiet) else ( @ECHO ON DATE /t >> %logfile% TIME /t >> %logfile% echo "No %file2% to send!!!" >> %logfile% ECHO =================================================== >> %logfile% ) if exist %file3% do ("C:\Program Files\Ipswitch\WS_FTP Professional\wsftppro.exe" -s local:%source%\%%f -d interfaces!kidneykonditioning:%dest% -quiet) else ( @ECHO ON DATE /t >> %logfile% TIME /t >> %logfile% echo "No %file3% to send!!!" >> %logfile% ECHO =================================================== >> %logfile% ) Quote Would if be better to just have multiple if statements & not use the for loop? You decide. I think this snippet is what you're trying to do: Code: [Select]@echo on SET file1=test1.txt SET file2=test2.txt SET source=U:\gendl SET dest=/home/asolutions/ SET logfile="U:\BatchFiles\IPSwitch Log Files\test.log" :phase1 cd /d %source% for %%f in (%file1% %file2%) do ( if not exist %source%\%%f (call :20) else ( "C:\Program Files\Ipswitch\WS_FTP Professional\wsftppro.exe" -s local:%source%\%%f -d interfaces!kidneykonditioning:%dest% -quiet) ) goto :eof :20 @ECHO ON DATE /t >> %logfile% TIME /t >> %logfile% echo "No %%f to send!!!" >> %logfile% ECHO =================================================== >> %logfile% Quote How do I make it return to check for additional files Use the call statement instead of goto. Try directly NAMING the files in the for statement. This will reduce the number of changes for maintenance: Not this: Code: [Select]SET file1=test1.txt SET file2=test2.txt for %%f in (%file1% %file2%) do ( Try this instead: Code: [Select]for %%f in (test1.txt test2.txt) do ( You can easily add file names in the for list without having to define new variables. Variables are useful, but unless the values are generated at run time, there is little reason not to hardcode them. Good luck. Thank you for all your guidance. I finally got it to work. |
|
| 2900. |
Solve : Free Dos or Dos 6.22? |
|
Answer» Which one is easier to network? well wat version of Dos are you refrering to besides 6.22? |
|