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.
| 3451. |
Solve : .bat To .exe? |
Answer» QUOTEwhy? That MAKES no sense Dude I Cant Install Two Antivirus At A Time I Had Avast 4.8 , HENCE I Wanted The Other ONE To Check With QuickHeal For The Above Mentioned Reasons Quote from: BC_Programmer on May 09, 2010, 08:47:45 AM Yes, look at the exciting source. You Forgot The Exit Command At The Last LineQuote from: the_mad_joker on May 11, 2010, 02:25:40 AM You Forgot The Exit Command At The Last Line No I didn't.Quote No I didn'tAs You Wish ! Who Will Argue With You |
|
| 3452. |
Solve : Deltree a folder by creation date in a .bat file? |
|
Answer» So I had to create a batch file that RAN a build script and created a unique directory then copied files to that directory during each run. What I need to do now is add to the script so that it looks for all the directories in that are more that 4 days old and delete them. How would I go about doing this? http://www.raymond.cc/blog/archives/2007/09/24/deltree-command-replacement-in-windows-2000-or-windows-xp/ You can see how long it's been since i last played with DOS commands then hmm, that code wouldn't work for me. The batch will be an automated batch file so it needs to calculate the date on it's own to determine if a folder needs to be deleted or not. So regardless of what date the batch runs, it will always delete any folder that is more than 4 days old. The script above asks the user for a date value to determine what files it will delete.Hmm.... Can the forfiles command be used? I was thinking something like this, but I'm not sure if i have the rd part right or not: forfiles /m *.* /d -4 /c "cmd /c echo @file is at least 4 days old." forfiles /m *.* /d -4 /c "cmd /c rd @file" is the forfiles command an external command that I can bring over to my xp box so i can test? Or can it only be run on a win server? I created this little bit of code; evaluate.vbs contains the following code... Code: [Select]Wscript.echo eval(WScript.Arguments(0)) main batch file contains... Code: [Select]@echo off del output.txt del output2.txt del output3.txt del output4.txt rem ** set to the root folder, code will check folders inside this one set FOLDERCHK=c:\test2 rem ** get the date from 4 days ago for /f "tokens=*" %%i in (' cscript //nologo c:\test\evaluate.vbs "date -4" ' ) do set DELDIR=%%i rem ** export DIR result in folder for /f "tokens=*" %%i in ('dir /A:D %FOLDERCHK%') do echo %%i >>output.txt rem ** List folder list that contain the required date findstr %DELDIR% < output.txt >>output2.txt rem ** Output only the name of the folders for /f "tokens=4 delims= " %%i in (output2.txt) do echo %FOLDERCHK%\%%i >>output3.txt rem ** Filter out the "." & ".." lines findstr /V /C:"." < output3.txt >>output4.txt echo Folders to be deleted... type output4.txt set /P CONFIRM=Type 'y' to confirm... if '%CONFIRM%=='y goto delfolders goto end :delfolders rem ** Confirming the commands to be executed...remove "ECHO" to actually delete the folders... for /f "tokens=*" %%i in (output4.txt) do echo rd /S /Q %FOLDERCHK%\%%i :end It's a little messy, but it works... I've never heard of the forfiles command before, but it's available on my Win7 PC and MAKES my code redundant lol...Quote from: ShadyDave on May 07, 2010, 04:42:25 PM I created this little bit of code; Actually, I created evaluate.vbs. Just saying. Apologies, I added that VBS code details after I posted it, and should put the "I created..." line after the VBS code and acknowledged you for the VBS code... After all your help with me creating my DR check script I don't want to take any credit away from you.Got it, this is what I used: Code: [Select]forfiles /m * /d -4 /c "cmd /c if @isdir==TRUE rd /s /q @file" So this will look at the current directory I am in when the command is called and it will check all directories (and only directories) for the folder date and determine if it's more than 4 days old, if so, it will delete that folder. Quote from: Panthers_Den on May 10, 2010, 01:18:50 PM Got it, this is what I used: Great "forfiles" is versatile and powerful. Here is another example passing the date as a command line argument. C:\test>type den.bat Code: [Select]@echo off forfiles /m *.txt /D %1 /c "cmd /c dir @file" | findstr ".txt" Output: C:\test>den.bat 05/08/2010 05/10/2010 05:04 PM 74 5810.txt 05/09/2010 12:56 PM 9 BATCH116-20100508-1701.txt 05/09/2010 12:56 PM 9 DATA256.txt 05/08/2010 05:01 PM 7 seq.txt C:\test>den.bat 05/06/2010 05/10/2010 05:04 PM 74 5810.txt 05/09/2010 12:56 PM 9 BATCH116-20100508-1701.txt 05/09/2010 12:56 PM 9 DATA256.txt 05/08/2010 05:01 PM 7 seq.txt 05/07/2010 02:12 PM 9 test.txt C:\test>den.bat 05/01/2010 05/10/2010 05:04 PM 74 5810.txt 05/09/2010 12:56 PM 9 BATCH116-20100508-1701.txt 05/09/2010 12:56 PM 9 DATA256.txt 05/08/2010 05:01 PM 7 seq.txt 05/07/2010 02:12 PM 9 test.txt 05/01/2010 09:11 AM 17 today.txt C:\test> p.s. It is a good idea to get a list before you deleteyea, i actually had an "echo" before the rd, but removed it when I posted the cmd on here. |
|
| 3453. |
Solve : copying file? |
|
Answer» Code: [Select]@ECHO off |
|
| 3454. |
Solve : help to improve simplea batch job application? |
|
Answer» Hi All |
|
| 3455. |
Solve : Batch to automatically determine available drives to write to? |
|
Answer» I have a script that I've written where I have hard coded an output to a PCMCIA card on a non-networked machine. |
|
| 3456. |
Solve : Use batch code or installer for custom configuration of 'virgin' software? |
|
Answer» Thanks to the great help I received in this forum previously with a batch script, I figured I'd pop back in and ask for advice once again. |
|
| 3457. |
Solve : path substitution?? |
|
Answer» Hi there, |
|
| 3458. |
Solve : How can i scan my computer for viruses using cmd.exe?? |
|
Answer» thanksWhat anti-virus software do you RUN normally? Some come with command-line scanners.For example(again depending UPON whatever Anti-virus your using you can modify the code to run at startup, different intervals, etc.) thanks C:\Program Files\Malwarebytes' Anti-Malware>dir mb*.* VOLUME in drive C has no label. Volume Serial Number is 304E-C1B1 Directory of C:\Program Files\Malwarebytes' Anti-Malware 01/07/2010 03:57 PM 59,241 mbam.chm 01/07/2010 05:07 PM 167,760 mbam.dll 01/07/2010 05:07 PM 1,394,000 mbam.exe 01/07/2010 05:07 PM 84,816 mbamext.dll 01/07/2010 05:07 PM 429,392 mbamgui.exe 01/07/2010 05:07 PM 236,368 mbamservice.exe 6 File(s) 2,371,577 bytes 0 Dir(s) 6,751,793,152 bytes free C:\Program Files\Malwarebytes' Anti-Malware>mbam.exe C:\Program Files\Malwarebytes' Anti-Malware>Hmmmm....Why'd you DIR your MBAM folder?Quote from: Carbon Dudeoxide on May 30, 2010, 09:21:03 AM Hmmmm....Why'd you DIR your MBAM folder? To clarify the procedure for people new to CMD. How would Carbon suggest showing how to run mbam.exe from the command prompt? Updates mbam, runs a quickscan, and only shows the results if something is found. Code: [Select]%programfiles%\Malwarebytes' Anti-Malware /runupdate /quickscanterminate /fullauto Quote from: BC_Programmer on May 30, 2010, 03:11:38 PM Updates mbam, runs a quickscan, and only shows the results if something is found.Wouldn't you NEED to enclose the path with quotes?Quote from: marvinengland on May 30, 2010, 10:28:50 AM To clarify the procedure for people new to CMD. Buffalo BillQuote from: Helpmeh on May 30, 2010, 06:54:18 PM Wouldn't you need to enclose the path with quotes? It would be a good measure on older OS's, but It's usually not required.Quote from: Helpmeh on May 30, 2010, 06:54:18 PM Wouldn't you need to enclose the path with quotes?crap, and include the exe name Code: [Select]"%programfiles%\Malwarebytes' Anti-Malware\mbam.exe" /runupdate /quickscanterminate /fullauto |
|
| 3459. |
Solve : Move command? |
|
Answer» Hello everyone. This is my first post on these forums. I have just started a networking certification program, and we are learning the command prompt system. I am having a difficult time with one of the assignments. I am being asked to copy and rename a file to a subdirectory all in 1 step. The syntax of the MOVE command is throwing me off here. Finishing the destination folder name with a \ was throwing me off You need to study path and folder naming. Ignoring switches, the syntax for just moving a file, while preserving the name is this move (where the file is now) (where you want the file to go) example move "C:\A folder\A subfolder\example file.txt" "D:\New Folder\Sub folder" The syntax for moving and renaming is essentially this... move (what the file is now) (what you want the file to become) example move "C:\A folder\A subfolder\example file.txt" "D:\New Folder\Sub folder\different name.txt" If you specify paths or folders then there will be a slash or slashes. Use the copy command. When you sure you have the correct files, "del" the source files.Quote from: marvinengland on May 30, 2010, 08:30:26 AM Use the copy command. When you sure you have the correct files, "del" the source files. Actually, Marvin, you have a point there. The OP wrote this Quote I am being asked to copy and rename a file to a subdirectory all in 1 step Copying and moving are different things. psufan14, which is it? Quote from: psufan14 on May 29, 2010, 12:59:50 PM
We should always offer an example with the output of the example. C:\test>copy zee.bat c:\test\sub\zoe.bat 1 file(s) copied. C:\test>cd sub C:\test\sub>dir Volume in drive C has no label. Volume Serial Number is 0652-E41D Directory of C:\test\sub 05/30/2010 10:35 AM . 05/30/2010 10:35 AM .. 05/13/2010 10:56 AM 87 zoe.bat 1 File(s) 87 bytes 2 Dir(s) 295,696,343,040 bytes free C:\test\sub> The above will copy zee.bat to a subdirectory ( called sub ) and will change the name of the file from zee.bat to zoe.bat. The instructions said to copy the file and in the process rename the file in the new folder. The only command I knew that COULD rename a filewhile moving it was the move command, but I tried a copy command to copy the contents of a directory to another directory and changing the name and that worked as well. I do need to LOOK at the directory and file switching commands I am very new to that. |
|
| 3460. |
Solve : my computer does not boot from my dvd? |
|
Answer» I've been trying to INSTALL windows 98 on my father in-laws computer which is a intel-700MHz processor but for some reason it will not BOOT from the dvd and so i formatted it with ms-dos 6.0 but now the ms-dos does not detect my dvd rom i have also tried to change the auto.bat file and the config.sys file but nothing seems to work. So i formatted it again and tried to install windows xp but now it won't boot the cd.You need to change the boot order in bios so the cd / dvd drive is the first boot device.I tried that and it still dos'nt work the problem is that the computer had windows xp on it and it kept and freezing up so I throught that it WOULD run better with windows 98 so I tried to install it but the windows xp sent a message that i had to install the windows 98 through ms-dos but the problem is windows xp dos'nt have dos so i restarted the computer with a setup disk from ms-dos 6.0 everything got formatted and i put the cd in from windows 98 but dos would not recognize the d: so i know with dos you need a driver for the cd/dvd drive but i don't have a driver on the floppy disk so I throught i would put the windows xp back in the computer but now it dos'nt boot any more from the cd/dvd drive and i changed the boot sequence in bios I am kinda stuck now do you have any ideas. Get a legit Win98 CD...they're all bootable. Only the windows 98 SE discs are. a good portion of the "first" edition discs are not bootable- legit or otherwise. |
|
| 3461. |
Solve : Search for permissions .sql files from all subdirectories? |
|
Answer» I'm working on a script that will find all .sql files in all subdirectories and find the permissions for a specific group. I have a BATCH that will CURRENTLY check all files in the CURRENT directory, but I need it to be able to search all subdirectories as well. |
|
| 3462. |
Solve : s bos dir? |
| Answer» HI i have a dos question. i have been USING windows so long i DONT remember anything.. i am booted in dos A:\ and see what i wnat in the dir [ncsmal~1] How do i OPEN it up? thanks pillsnpwd CD\ ncsmal~1 | |
| 3463. |
Solve : Many Questions on Copy/Replacing Files? |
|
Answer» Before I post, I just want to say I'm NEW here. I've made some EXTREMELY BASIC batch files a long time ago, so it's safe to say that I'm practically completely new at this. Please be extremely specific with me as I'll have difficulty understanding short forms. |
|
| 3464. |
Solve : Batch Animation!!!? |
|
Answer» Hi Dudes, |
|
| 3465. |
Solve : Promt for user input in autoexec.bat? |
|
Answer» Hello! maybe the fact of this Sorry I probably forgot to mention that it isnt in Windows XP i want to run this, but when booting up the computer... Didnt know by the time I was writing this thread that the "set /p" command only works in windows but not in DOS. So the last code example is not usable. The code part using the "choice" command is for DOS and that is the code im having problem with.try it without (1, 2)%1 replace IF ERRORLEVEL == 2 ERRORLEVEL 2 etc.Quote from: mat123 on May 20, 2010, 07:55:20 AM try it without Ok thanks I will trymat123 means IF ERRORLEVEL 2 goto quit IF ERRORLEVEL 1 goto install etc Quote from: Salmon Trout on May 20, 2010, 12:34:36 PM mat123 means Tried it and it didnt work. :/ Okay, So now I´ve tried all of the possibilities I know of regarding this so I´ve have started on a new idea which I would like to hear thoughts about this idea of mine. What about if I in "autoexec.bat" write a command which executes another program on the CD which then writes out the warning about reinstalling the computer with this ghost cd and promt the user for an input? If the user answers that it wants to run the ghost installation it executes the ghost installation from that program INSTEAD? Is it possible to do so and if it is, which programming language is the easiest to learn to write such program? Best regards/ PeterIn my opinion, VB6 is a viable option(Although you ought to look around to C++ and other programming languages for your "Programming-Style") But before you goto that, Can you give us details about Autoexec:
Thanks, Nick(macdad-) |
|
| 3466. |
Solve : simple batch question? |
|
Answer» a simple question about batch: |
|
| 3467. |
Solve : set /p with a timer ?? |
|
Answer» How can i do this? , I understand using choice.com can do this but its not what im looking for Set /P will wait until the return key is pressed - what did you want it to do ? That very long row of question marks looks really stupid.he is Free in the way of expression Quote from: dnthns87 on May 11, 2010, 10:45:21 AM Sorry, What i ment to ask was how can i use set /p to create a pause with a timer like choice.com has is there anyway of doing this or possibly a third party program that does this ? http://www.westmesatech.com/editv.html choose.exe, COMES in MS-DOS, Win32 and Win64 flavours. Code: [Select]C:\>choose64 /? Choose64 2.0 - (C) 2006-2009 by Bill Stewart ([emailprotected]) Allows selection of a choice from a LIST of choices. Usage: Choose64 [-c choices] [-d x] [-l] [-n] [-p prompt] [-q] [-s] [-t x,n] -c choices Specifies valid choices (default is 'YN'). -d x Choose 'x' if Enter is pressed. -l Use line input mode (must press Enter after MAKING a choice). -n Do not display the list of choices. -p prompt Prompt the user with 'prompt' (enclose in quotes if it has spaces). -q Do not display the choice that was selected (ignored with -l). -s Choices are case sensitive. -t x,n Choose 'x' automatically if no choice made within 'n' seconds. Without -c, the default choices are 'YN' (or 'yn' with -s). The program's exit code will be the position of the choice in the list. If Ctrl-C is pressed, the exit code will be 255.Quote from: on May 11, 2010, 11:40:32 AM , what did that post contribute to answering the OP's question? Thanks, But let me be more clear on what i need.. choose.exe isnt what im looking for because its to similar to choice.com , sleep.exe isnt what i need because im not looking to just create a pause, Im looking for set /p with a timeout , for example: :TOP set an=&echo Whats your name?&set /p /TIME:XX an=-&IF NOT"%an%"=="%an%" (Goto loop) ELSE Goto TOP Quote from: dnthns87 on May 11, 2010, 12:47:46 PM :TOPThere is no time switch, also, you have the set syntax wrong. :top cls echo What's your name? Set /p name= If not "%name%"=="something else" (goto loop) else (goto top) Just saying, the following will always do the else command, so I don't know why you put it in your code: IF NOT"%an%"=="%an%" (Goto loop) ELSE Goto TOP i didnt really look at it, i just WROTE it quickly.. i understand that there is no time switch but set /p /time:xx is exactly what im looking for so a way to do that or a third party program that could do that would be awesomeQuote from: dnthns87 on May 11, 2010, 01:09:42 PM i didnt really look at it, i just wrote it quickly.. i understand that there is no time switch but set /p /time:xx is exactly what im looking for so a way to do that or a third party program that could do that would be awesome Look again on that page I linked to, at the features of Editvar. In particular, the timeout. |
|
| 3468. |
Solve : Help with Batch to generate an email? |
|
Answer» Hello, Try: If the "maillto:" command is included in a batch file that is a scheduled task to run at 2AM, how will the email be SENT automatically without interaction with the user? Quote from: marvinengland on May 21, 2010, 07:34:07 AM
The same way it was with the Original POST, where the only problem was the body was blank. I imagine they must be using a real E-mail client to handle the Mailto: protocol. |
|
| 3469. |
Solve : Takeown Fails with Access Denied? |
|
Answer» Hi, Thanks for the reply Marvinengland, http://support.microsoft.com/kb/304040 http://support.microsoft.com/contactus/default.aspx?ws=support ( all the following information from the above site. ) "To turn Simple File Sharing on or off in Windows, follow these steps: Double-click My Computer on the desktop. On the Tools menu, click Folder Options. Click the View tab, and then select the Use Simple File Sharing (Recommended) check box to turn on Simple File Sharing. (Clear this check box to turn off this feature.) To view a video about how to turn Simple File Sharing on or off, click the Play button (Collapse this imageExpand this IMAGE) on the following Windows Media Player viewer:" Thanks for the reply marvinengland, I have Vista Ultimate 64 bit SP2. I don't have :"Use Simple File Sharing (Recommended) check box to turn on Simple File Sharing" Instead I have "Use Sharing Wizard (recommended" Should I deselect it (untick)? Your response seems to indicate that my DIFFICULTY arises from the FACT that my network drive an it's folders and files are SHARED. This is true. I recently tried to run takeown from a command prompt at boot time. This also failed with could not find the path. Thanks Frank Camp |
|
| 3470. |
Solve : Can a prompt for set /p be placed at the end of a line of text?? |
|
Answer» In XP, the CHOICE COMMAND no longer exists. I have set /P. |
|
| 3471. |
Solve : compare two folders and find which files are not in both folders? |
|
Answer» Hi, so if the files do not compare would it allow me to make them equal? yesQuote from: marvinengland on May 17, 2010, 03:53:57 AM yes how? Quote from: Khasiar on May 17, 2010, 02:57:16 AM so if the files do not compare would it allow me to make them equal? The comp command will not help you to make the files and folders equal You will manually need to modify the files. C:\test>comp /? Compares the contents of two files or sets of files. COMP [data1] [DATA2] [/D] [/A] [/L] [/N=NUMBER] [/C] [/OFF[LINE]] data1 Specifies location and name(s) of first file(s) to compare. data2 Specifies location and name(s) of second files to compare. /D Displays differences in decimal format. /A Displays differences in ASCII characters. /L Displays line numbers for differences. /N=number Compares only the first specified number of lines in each file. /C Disregards case of ASCII letters when comparing files. /OFF[liNE] Do not skip files with offline attribute set. To compare sets of files, use wildcards in data1 and data2 parameters. C:\test>so why did you write "yes"? Quote from: Khasiar on May 12, 2010, 05:53:18 PM I am trying to find a way to compare two folders I'm sorry we have received no further suggestions of how to compare files and folders with batch commands or other methods. Good LuckOK don't answer. I am sorry the OP got such bad advice. Quote from: marvinengland on May 17, 2010, 01:05:54 PM I'm sorry we have received no further suggestions of how to compare files and folders with batch commands or other methods. Khasiar , Are no suggestions better than the suggestions I offered? My suggestions hurt no one. And many readers benefited from this thread. Khasiar , Thanks for your questions. Please don't allow negative comments from members who have no suggestions discourage questions in the future.Quote members who have no suggestions Ouch! Code: [Select]@echo off for /f "delims=" %%F in ( ' dir /b "folder1" ' ) do ( if not exist "folder2\%%F" copy "folder1\%%F" "folder2" && echo COPIED %%F ) Quote from: Khasiar on May 12, 2010, 05:53:18 PM Hi, I think you want both folders to have the same content. You can do that in a rather complicated batch file. Or just use some utilities that just do that. One of many is the Sync Toy from Microsoft. Or study how the XCOPY command works. Do XCOPY /? at the command prompt.Quote from: Geek-9pm on May 17, 2010, 07:30:51 PM I think you want both folders to have the same content. The comp command shows where the problem is and xcopy will correct the problem. C:\>comp /? Compares the contents of two files or sets of files. COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C] [/OFF[liNE]] data1 Specifies location and name(s) of first file(s) to compare. data2 Specifies location and name(s) of second files to compare. /D Displays differences in decimal format. /A Displays differences in ASCII characters. /L Displays line numbers for differences. /N=number Compares only the first specified number of lines in each file. /C Disregards case of ASCII letters when comparing files. /OFF[liNE] Do not skip files with offline attribute set. To compare sets of files, use wildcards in data1 and data2 parameters. C:\> Thanks marvinengland and Salmon Trout, Both your ways work but Marvinengland, Salmon Trouts way is much easier so ill stick with that thanks again guys.Quote from: marvinengland on May 17, 2010, 09:09:06 PM The comp command shows where the problem is and xcopy will correct the problem. And how would you use them together, exactly? and why use comp instead of fc? |
|
| 3472. |
Solve : Command to count number of files in directory called %username% to variable? |
|
Answer» Hi,
______________________________ c:\temp\logs>TYPE sk.bat @echo off Code: [Select]forfiles /p c:\temp\logs /m %username%* | FIND /c /v "" > filecount.txt echo type filecount.txt type filecount.txt Output:c:\temp\logs>sk.bat type filecount.txt 3 c:\temp\logs>Quote from: skhudy on May 24, 2010, 07:16:20 AM if I use forfiles.exe and forfiles -pc:\temp\logs -d+1 -m*%username% I get a list of files for a user in the last day. The above post did not assign the count to a variable. Also, the count was 3 and should be 2. c:\test>type sk.bat @echo off forfiles /p c:\temp\logs /m %username%* | find /c /v "" > filecount.txt set /p var=set /a var=%var% - 1 echo var=%var% Output: c:\test> sk.bat var=2 c:\test>Quote from: skhudy on May 24, 2010, 07:16:20 AM
c:\test>type sk2.bat @echo off forfiles /p c:\temp\logs /m %username%* forfiles /p c:\temp\logs /m %username%* | wc -l > filecount.txt set /p var=set /a var=%var% - 1 echo var=%var% Output: c:\test>sk2.bat "marvin.txt" "marvin.txt" var=2 c:\test>Quote from: skhudy on May 24, 2010, 07:16:20 AM
c:\test>type sk3.bat Code: [Select]@echo off forfiles /p c:\temp\logs /m %username%* forfiles /p c:\temp\logs /m %username%* | wc -l > filecount.txt set /p var=<filecount.txt set /a var=%var% - 1 echo var=%var% cd c:\temp\logs dir /OD /A-D %username%* dir /OD /A-D %username%* | findstr %username% | wc -l > count2.txt set /p var2=<count2.txt echo var2=%var2% cd c:\test\ Output: c:\test>sk3.bat "marvin1.txt" "marvin2.txt" var=2 Volume in DRIVE C has no label. Volume Serial Number is 0652-E41D Directory of c:\temp\logs 05/24/2010 01:09 PM 8 marvin2.txt 05/24/2010 01:09 PM 8 marvin1.txt 2 File(s) 16 bytes 0 Dir(s) 295,916,421,120 bytes free var2=2 c:\test> |
|
| 3473. |
Solve : I need help creating a batch file!? |
|
Answer» I'm new here but ANYWAY, I need help creating a batch file that creates a folder in the root of the C drive with the same This was given to me as a H/W assignment at my school lol but I seriously need some help. When you turn in WORK done by someone else your tutor may believe that you UNDERSTOOD the assignment and do not need any further assistance. This won't be good when you come to an exam environment when there's no-one to do your work for you. Any assistance with homework should come from your tutor. Welcome to the CHope forums where an unwritten rule is that we may ADVISE where to get the required information but we shy away from doing homework for anyone. Quote from: marvinengland on May 11, 2010, 11:08:35 PM C:\>type winturbo.bat Wow thank you sir for your kind help much appreciated! |
|
| 3474. |
Solve : How to capture batch file error msg's?? |
|
Answer» So in my batch file, I can capture the errorlevel (the error number), but the system is also outputting it's own error msg to the user, how do I capture that msg? yes, it is more than possible, it is easy! Yea, I had tried Code: [Select]net use Z: \\a_drive\a_directory /USER:username password>>logfile which didn't work. I didn't think about trying 2>> (actually didn't even know what 2> did until now), so I just did that one and it worked, even with >> :-) Code: [Select]net use Z: \\a_drive\a_directory /USER:username password 2>>logfile Thank you! :-) Glad it was an easy change. Thanks for the link too, that'll come in handy for sure.Thank you for the confirmation of 2>> - I thought it might work but had had no reason to try it before. That site has many very useful examples of batch usageBy default, batch sees > (or >>) as 1> (or 1>>). That is what you see on screen as normal messages, 2> or 2>> will output error messages.Quote from: Helpmeh on May 11, 2010, 12:57:46 PM By default, batch sees > (or >>) as 1> (or 1>>). That is what you see on screen as normal messages, 2> or 2>> will output error messages.1 is the standard output stream. 2 is the standard error stream. >,>> , <, and | can have a stream number prefixed to them. for example, if you use: program.exe 2>&1 | program2.exe then the standard error and standard output of program.exewill both be piped to program2 as it's standard input. Quote from: BC_Programmer on May 11, 2010, 08:24:32 PM program.exe 2>&1 | program2.exe Why the &1, what does that do?Quote from: Panthers_Den on May 12, 2010, 05:40:15 AM Why the &1, what does that do? For the answer to that and any other questions about redirection, check out this article Quote from: Sidewinder on May 12, 2010, 10:30:41 AM For the answer to that and any other questions about redirection, check out this article oh that's a helpful article, thanks |
|
| 3475. |
Solve : Shift command? |
|
Answer» Win XP SP.3 ....I'd like to Shift the variables.... Quote from: Mat123 shift replaces %1 with %2 etc not varibles Correct Mat123, I should have said "I'd like to change the position of command line parameters....". I hope others are not confused by my misuse of terminology. Geek-9pm - Thank you for the demo. V. |
|
| 3476. |
Solve : endless loop? |
|
Answer» how to create an ENDLESS loop @echo offeven the variable j does not seem to be incrementing @echo off set j=2 for /L %%i IN ( 1,1,%j% ) DO ( echo %%i %j% set /A j = !j!+1 ) Try replacing the % with ! where noted.I think there is a BIT of confusion here... 1. If you want to CHANGE a variable in a loop, yes, you have to use exclamation marks ("exclamation points" in some places) but first you have switch on delayed expansion with this line setlocal enabledelayed expansion 2. In any case both of you have misunderstood an important point. At run time, when cmd.exe processes the FOR line, it expands the %j% variable into its value at that time, that is, the line is expanded to for /L %%i IN ( 1,1,2 ) DO etc and the value 2 is STORED in memory as the loop count limit. Whatever you do later to the variable j in the loop will not affect this. The FOR command does not check the value of %j% (or even !j!) each time round the loop. Therefore the loop will run exactly 2 times. %%A will successively store 1 and then 2 and then the loop will finish. %j% will always be 2. In this code... @echo off set j=2 for /L %%i IN ( 1,1,%j% ) DO ( echo %%i %j% set /A j = !j!+1 ) ...the variable %j% uses percent signs, there is no delayed expansion, the set /a command has no effect, and therefore %j% stays at 2 in this code... @echo off setlocal enabledelayedexpansion set j=2 for /L %%i IN ( 1,1,%j% ) DO ( echo %%i !j! set /A j = !j!+1 ) ...the variable !j! is an exclamation-mark variable, delayed expansion is enabled, so that the set /a command is able to add 1, so the first time around the loop, !j! equals 2, and the second time around the loop, !j! equals 3, and as I showed above, FOR does not care what you do to !j! in the loop. If you want an infinite loop, you can use a label and GOTO LIKE this... set j=2 :loop echo j=%j% set /a j=%j%+1 goto loop Terminate with CTRL-C Quote from: Bukhari1986 on May 23, 2010, 03:42:01 AM how to create an endless loop C:\test>type buk3.bat Code: [Select]@echo off setlocal enabledelayedexpansion :begin set /a j=2 for /L %%i IN ( 1,1,%1 ) DO ( echo i=%%i set /A j=!j! + 1 echo j=!j! ) goto begin Output: C:\test>buk3.bat 10 i=1 j=3 i=2 j=4 i=3 j=5 i=4 j=6 i=5 j=7 i=6 j=8 i=7 j=9 i=8 j=10 i=9 j=11 i=10 j=12 i=1 j=3 i=2 j=4 i=3 j=5 i=4 j=6 i=5 j=7 i=6 j=8 i=7 j=9 i=8 j=10 i=9 j=11 i=10 j=12 i=1 j=3 ^Ci=2 j=4 Terminate batch job (Y/N)? y C:\test> Thanks Salmon Trout Thanks marvinengland THANKS A LOT . |
|
| 3477. |
Solve : Move files recursively from source to destination that are older than 15 days? |
|
Answer» Hi -
The following code is only a start. I have tried to list the files that are older than 15 days with the forfiles command. The code needs a lot of work but might help to get you started. Good Luck _______________________________________ __ C:\test>type mira.bat Code: [SELECT]@echo off FORFILES /D -15 /M *.* > old15.txt echo. > old15days.txt for /f "delims=" %%i in (old15.txt) do echo %%~i >> old15days.txt for /f "delims=" %%i in (old15days.txt) do echo %%i Output: C:\test>mira.bat buildlog.bat chtoE.bat cmpfil.bat cmplist.bat evaluate.vbs fil.bat helpme.bat matt.bat matt2.bat matt3.bat matt4.bat matt5.bat ver6.txt ver61.bat ver612.bat x.bat yesterday.bat C:\test> type count.txt 03/04/2009 12:26 PM 41 evaluate.vbs 01/01/2010 11:33 AM 187 yesterday.bat 04/24/2010 02:39 PM 1,018 buildlog.bat 04/24/2010 02:39 PM 1,018 x.bat 04/24/2010 06:37 PM 199 matt.bat 04/25/2010 11:27 AM 260 matt2.bat 04/25/2010 11:27 AM 260 matt5.bat 04/25/2010 11:34 AM 307 matt3.bat 04/25/2010 11:41 AM 224 matt4.bat 04/25/2010 02:07 PM 38 ver6.txt 04/25/2010 02:17 PM 125 ver61.bat 04/25/2010 02:33 PM 190 ver612.bat 04/25/2010 05:14 PM 235 helpme.bat 04/27/2010 12:06 PM 32 chtoE.bat 04/27/2010 07:33 PM 89 fil.bat 04/27/2010 09:52 PM 631 cmpfil.bat 04/27/2010 10:18 PM 698 cmplist.bat C:\test> |
|
| 3478. |
Solve : Stylish Name In Batch? |
|
Answer» See This After Replacing 1.1.1.1 To 127.0.0.1 Its Not Working One Question Reply My This Post To Put An Solution To This TopicI've used the ping in the original samples for the last 8 years. I've never had any problems with it. I'm connected to a network now running XP Pro - SP-3. However, with all of the Anti-VIRUS programs and the newer versions of windows constantly trying to police the internet, it could cause a problem. You could use the original and if it didn't work for everyone, then look for a solution.Quote it could cause a problem 1] In What Manner ? Means What Type Of Problem Virus Or Something Like That And U Didnt Answer My Question 2] If The Batch Containing IP As 1.1.1.1 Is Executed On A PC Without Internet , Will The Batch Run ? Will It Cause Any Problem IF : Yes It Will Run Without Any Problem - Than Thats The Solution IF No : Then Please Give Any Other IP That Will Not Go Out Of NetworkQuote 1] In What Manner ? I didn't answer with a yes or no because it isn't that simple. Everyone has different versions of windows with different versions of AV software. Some settings may TAKE it as a virus. (It is called a false postive). What I wrote for you is not a virus, the application you intend to run with it, I can't say. Quote 2] If The Batch Containing IP As 1.1.1.1 Is Executed On A PC Without Internet , Will The Batch Run ? Will It Cause Any Problem Of course it will, without problems.Thanx For The Help All Of You Who Tried To Solve (Special Thanx To Salmon , Hope You're Reading It ) |
|
| 3479. |
Solve : Delete File With Ping Command ?? |
|
Answer» Hi Friends doesn't cause files to be deleted Let Me Give An Example BC If Some1 Had Downloaded Bioshock 2 rip by Freeman g ripper :Ive Downloaded It For Educational Purposes (The Batch File In Rip > It Contains A Lot Of Knowledge ) It Also Had Uninstaller.bat Which Contained These Commands , I Ran Them And It Uninstalled The Game Files And Erased It From Registry I Still Dont Remember Its Command Line But It Was Still Like "ping -127.1....." Something Like That We don't assist with Warez here... This has been mentioned to you before. Topic Closed. |
|
| 3480. |
Solve : Capturing TIMEIT.EXE Output To A Text File? |
|
Answer» I know this sounds relatively simple but it turns out it isn’t for me. This worked for me... Seems that the timeit.exe uses the normal error level 2 to output it's results. Rog, Thanks for reviving good questions and solutions from the archive. Many new members and readers have not used timeit.exe before now. ____________________ p.s. Some ideas are always relevant. We still read and agree with what Jesus said many years ago.Quote from: rogs on May 21, 2010, 01:40:04 PM This worked for me... Seems that the timeit.exe uses the normal error level 2 to output it's results. By the way, I know "2>" redirection works in this case. But I thought "2>" was for standard error? Redirection works nearly the same for Unix. I'm not perfectly CLEAR on how and when to use the different symbols of redirection. Please enlighten. Thanksstreams: 1. STDOUT > on its own is the short way of redirecting stream 1 these are equivalent: command >file.txt command 1>file.txt 2 STDERR command 2>file.txt to combine both streams command>file.txt 2>&1 so to get both the standard output of DIR (the file listing) and also any error message ("file not found") dir >file.txt 2&>1 Quote from: rogs on May 21, 2010, 01:40:04 PM This worked for me... Seems that the timeit.exe uses the normal error level 2 to output it's results. There must a bug with timeit.exe since timeit.exe requires "2>" to redirect regular output ( standard Out ) to a file. For other programs only ">" is required. Quote from: marvinengland on May 22, 2010, 06:49:54 PM There must a bug with timeit.exe since timeit.exe requires "2>" to redirect regular output ( standard Out ) to a file. For other programs only ">" is required. Not a bug necessarily; some programs are deliberately designed that way. I expect in this case it is done so that the output of the program to be timed can be kept separate from the output of timeit. Or some such reason. |
|
| 3481. |
Solve : Drive A error. System halt **URGENT****? |
|
Answer» I cant. I dont GO to the boot screen, I cant get to the Bios Screen or anything else. I Just SEE the ERROR. Nothing else.Are you saying the error comes up before you have the OPPORTUNITY to press the key(s) required to enter the bios? If so, the only other suggestion I can make is to replace the existing ram. But keep in mind there's no way we can be 100% certain the ram is the problem without testing it. Sorry - I'm not sure what else to suggest.Thanks for the help. |
|
| 3482. |
Solve : Next sequence variable in DOS? |
|
Answer» Need to rename data FILE DATA256 after processing data. Need to rename data file DATA256 after processing data. The for loop in post one is not needed. Reference: http://www.dostips.com/DtTipsStringManipulation.php C:\test>type wain.bat Code: [Select]@echo off set M1=%date:~4,2% set DD=%date:~7,2% set YYYY=%date:~10,4% echo M1=%M1% echo DD=%DD% echo YYYY=%YYYY% pause set HH=%TIME:~0,2% set MM=%TIME:~3,2% echo HH=%HH% echo MM=%MM% pause set /p seq=<seq.txt set /a seq=%seq% + 1 echo %seq% > seq.txt type seq.txt echo date = %DATE% copy DATA256.txt BATCH%seq%-%YYYY%%M1%%DD%-%HH%%MM%.txt dir BATCH*.txt rem del DATA256.txt rem del BATCH*.txt Output: C:\test>wain.bat M1=05 DD=08 YYYY=2010 Press any key to continue . . . HH=17 MM=01 Press any key to continue . . . 116 date = Sat 05/08/2010 1 file(s) copied. Volume in drive C has no label. Volume Serial Number is 0652-E41D Directory of C:\test 05/09/2010 12:56 PM 9 BATCH116-20100508-1701.txt 1 File(s) 9 bytes 0 Dir(s) 296,159,543,296 bytes free C:\test>Works great. Thanks for your support Marvin. lswain |
|
| 3483. |
Solve : dir command? |
|
Answer» the following command finds the file provided name provided by %1 |
|
| 3484. |
Solve : visual/office? |
|
Answer» i WANT to know more about the VISUALS/ office under the FORUM or MICROSOFT link on DOS.Quote from: katzo on May 12, 2010, 05:37:06 AM i want to know more about the visuals office under the forum or microsoft link on DOS. http://www.visualsteps.com/index.php http://www.visualsteps.com/contact.php |
|
| 3485. |
Solve : Resizing Command Window? |
|
Answer» Hi Every 1, Thanx Sidewinder You were given TWO examples. You can write the mode command either at the command prompt to change the existing window, within a batch file to change the existing window, or with the start command to change the dimensions of a new window. The numbers (dimensions) I used are arbitrary. Within physical limitations, you can SET them as needed. You can get further details by typing mode /? at the command prompt. The mode command can configure other system devices besides the CONSOLE. With a little imagination you can even mimic an input BOX for your batch files. You Are Amazing Dude Thanxxxxxxxxxxxxxxx |
|
| 3486. |
Solve : How to FORMAT !!! under BIOS? |
|
Answer» guys HELP how the f..k can i format my hard drive under BIOS . i want to install Win 7 but i cant DELETE my old version And watch your mouth. That's no way to introduce yourself to the forum. Agreed. If you can't delete your old version from your current Win7 DVD you may want to considering purchasing it... |
|
| 3487. |
Solve : How to start and then later kill an exe from a .bat file??? |
|
Answer» I've an .exe which i need to call through an .BAT file and then i need to kill this .exe at a later stage. I've an .exe which I need to call through an .bat file and then I need to kill this .exe at a later stage. E:\>type killnote.bat Code: [Select]@echo off start notepad joe.txt sleep 60 tasklist | findstr "%1" > notepid.txt for /f "tokens=1,2 delims= " %%i in (notepid.txt) do ( echo PID=%%j taskkill /pid %%j ) OUTPUT: E:\>killnote.bat note pid=3056 SUCCESS: Sent TERMINATION signal to the process with PID 3056. E:\> |
|
| 3488. |
Solve : Variable in a variable? |
|
Answer» Hi ppl, I just joined the forum because I'm a bit stuck. I'm running Win Vista Home Premium (I know it's lame :/) and I thought to make something like a quick file browser, I have made most of it but what I want to be able to do is allow the user to go to complex folder trees without me having to write a couple of lines for each sub-folder. Quick file browser. C:\test>type meit2.bat Code: [SELECT]@echo off dir /B /s *.txt echo bye Output: C:\test>meit2.bat C:\test\5810.txt C:\test\BATCH116-20100508-1701.txt C:\test\compare.txt C:\test\count.txt C:\test\count2.txt C:\test\DATA256.txt C:\test\folderlog.txt C:\test\nc.txt C:\test\old15.txt C:\test\old15days.txt C:\test\seq.txt C:\test\test.txt C:\test\timefile1.txt C:\test\timefile2.txt C:\test\timefile3.txt C:\test\timefile4.txt C:\test\today.txt C:\test\var.txt C:\test\ver6.txt C:\test\folderA\a.txt C:\test\folderA\b.txt C:\test\folderA\c.txt C:\test\folderB\a.txt C:\test\folderB\c.txt C:\test\space name\test.txt bye C:\test>Wow, thaks... It's quiet impressive however I wanted to keep all stuff in 1 file.... anyway thanks for that I wish you good luck and thanks againQuote from: Meitnerium on May 13, 2010, 02:02:59 PM I wanted to keep all stuff in 1 file.... C:\test>type meit2.bat Code: [Select]@echo off dir /B /s *.txt > onefile.txt type onefile.txt Output: C:\test>meit2.bat C:\test\5810.txt C:\test\BATCH116-20100508-1701.txt C:\test\compare.txt C:\test\count.txt C:\test\count2.txt C:\test\DATA256.txt C:\test\folderlog.txt C:\test\nc.txt C:\test\old15.txt C:\test\old15days.txt C:\test\onefile.txt C:\test\seq.txt C:\test\test.txt C:\test\timefile1.txt C:\test\timefile2.txt C:\test\timefile3.txt C:\test\timefile4.txt C:\test\today.txt C:\test\var.txt C:\test\ver6.txt C:\test\folderA\a.txt C:\test\folderA\b.txt C:\test\folderA\c.txt C:\test\folderB\a.txt C:\test\folderB\c.txt C:\test\space name\test.txt C:\test> |
|
| 3489. |
Solve : Deleting Profiles with exceptions in a Batch File.? |
|
Answer» Hello!
http://www.dabcc.com/article.aspx?id=9369 ( All the following information from the above site. ) <<<<<<< "Deleting Profiles Manually: •Open the control panel applet "System Properties" and navigate to the tab "Advanced". I know of the following shortcuts for this often needed dialog box: ◦Press Win+Break ◦Press Win+R to open the run dialog box. TYPE in control sysdm.cpl,,3 and press enter. Note there must not be entered a SPACE in front of the commas. •Click on the settings button in the user profiles section. •In the dialog that appears, CHOOSE the appropriate user profile and click on delete. Note: you must be an administrator for the delete button to even show up. And: you cannot delete your own profile. Deleting Profiles Automatically To learn more and to read the entire article at its source, please refer to the following page, Deleting User Profiles - Correctly at Helge Klein" >>>>> |
|
| 3490. |
Solve : How To Extract The Figures Using DOS? |
|
Answer» Hi ;
If RuZee needs only the last six numbers from each input line, then we were able to use the gpl code with a slight midification: C:\test>type gpl.bat Code: [Select]@echo off setlocal enabledelayedexpansion for /f "delims=*" %%a in (test.txt) do ( set aa=%%a rem echo aa = !aa! rem echo %%a echo !aa:~-6! ) Output: C:\test>gpl.bat 269338 263941 266663 265108 268421 269602 266973 266477 270655 266822 268137 267681 266535 C:\test>Quote from: RuZee on May 13, 2010, 08:09:35 AM
Zee, Your code is correct except you asked for a display of token 7 and then tried to use token one. C:\test>type zee4.bat Code: [Select]@echo off echo > tgk.txt for /f "tokens=7 delims=,=" %%g in (test.txt) Do ( Echo %%g >> tgk.txt ) type tgk.txt Output: C:\test>zee4.bat 269338 263941 266663 265108 268421 269602 266973 266477 270655 266822 268137 267681 266535 C:\test>Quote from: marvinengland on May 15, 2010, 03:02:35 AM Zee, |
|
| 3491. |
Solve : user creation from text file? |
|
Answer» I want a batch file which will create users. the user names and passwords should be taken from the file. @echo off |
|
| 3492. |
Solve : Is it possible to have a batch file copy files from a cd to the C Drive ?? |
|
Answer» Guys, |
|
| 3493. |
Solve : how can one get the timezone with a DOS command?? |
|
Answer» All -- Please help. I am on Windows XP and I need to know-- how can one get the timezone (time zone) with a DOS command? I tried this... C:\Documents and Settings\mkamoski>timezone /g Current Timezone is : Daylight Saving Time begins at 02:0:2:03 Daylight Saving Time ENDS at 02:0:1:11 ...but that is not what I need... ...I also can run the "systeminfo" command and what I need is buried in there but there is no way that I can see to get JUST the timezone from that DATA... ...RATHER, I need something like this... -04:00 ...but I cannot see how that can be done... ...so what do you think? Please advise. Thank you. -- Mark Kamoski Code: [Select]C:\>systeminfo | find "Time Zone" Time Zone: (UTC) Dublin, Edinburgh, Lisbon, LondonIt WORKS! How did you know that? Quote from: Geek-9pm on May 18, 2010, 01:15:02 PM It Works! How did you know that? Isn't it obvious? |
|
| 3494. |
Solve : Count files and email ---Batch file? |
|
Answer» Hello All,
C:\test>type Abhi.bat CODE: [Select]@echo off for /f "delims=" %%i in ('cscript //nologo c:\test\evaluate.vbs "date -1"' ) do ( set yesterday=%%i echo yesterday=%yesterday% ) set Today=%DATE:~4,10% echo Today=%Today% dir /OD /A-D | findstr "%yesterday% %Today%" dir /OD /A-D | findstr "%yesterday% %Today%" | find /c /v "" > filecount.txt echo type filecount.txt type filecount.txt rem evaluate.vbs rem Wscript.echo eval(WScript.Arguments(0)) rem Thank Salmon Trout for evaluate.vbs Output: C:\test>Abhi.bat yesterday=5/15/2010 Today=05/16/2010 05/15/2010 03:57 AM 14 trk.txt 05/15/2010 04:43 AM 129 gpl77.bat 05/15/2010 09:56 PM 138 zee4.bat 05/15/2010 09:57 PM 150 tgk.txt 05/16/2010 04:19 AM 361 st0510.bat 05/16/2010 01:20 PM 92 teststr.txt 05/16/2010 09:37 PM 135 yesterday.bat 05/16/2010 10:29 PM 3 filecount.txt 05/16/2010 10:32 PM 466 Abhi.bat type filecount.txt 9 C:\test> Hi marvin, Thanks for the quick reply, question since i am new to writing batch files, where do i give the path to the folder i want a count of, and you have used a .vbs file? Also i do not want a listing of the files, just a count as there could be over 100 files. And how should i go about setting up the email?Quote from: TechAbhi on May 16, 2010, 11:57:45 AM "" Point to filecount.txt, right click and choose send to mail recipient. [recovering disk space - old attachment deleted by admin]Hi Marvin, I will be putting this up on a task scheduler to run every night. How do i set up the email so it sends an email automatically. Did a test run and got a file count of 8, but when i opened the folder saw the file count was much higher for yesterday. [recovering disk space - old attachment deleted by admin]Quote from: TechAbhi on May 17, 2010, 08:36:28 AM Did a test run and got a file count of 8, but when i opened the folder saw the file count was much higher for yesterday.You must create and INSTALL "evaluate.vbs" and in the code show the complete path to evaluate.vbs The batch is run inside the photo folder or show a cd to the photo folder in the code before dir command is run 'cscript //nologo c:\test\evaluate.vbs "date -1"' What did the variable yesterday show at the top of the output? 05/16/2010 ? Do not schedule the batch file until it runs correctly for you. I don't know how to email from batch. Quote from: TechAbhi on May 17, 2010, 08:36:28 AM Did a test run and got a file count of 8, but when i opened the folder saw the file count was much higher for yesterday. It appears the path to the folder on your machine where we need to count new files from yesterday and today is: c:\netpub\ftproot\photos\ Also, the evaluate.vbs does not work on your machine. The batch file will run on a schedule at 2AM ( or so) and we cannot prompt a user for yesterday's date. The batch must run automatically and yesterday's date must be currently assigned to yesterday's variable. All values assigned to ram variables disappear when the batch file is no longer in RAM. I shall modify the original code so we can assign yesterday's date to the RAM variable without using evaluate.vbs or interactive input. I shall post the code today 05/17/2010. Thank you Marvin, appreciate your help.Quote from: TechAbhi on May 17, 2010, 11:07:58 AM Thank you Marvin, appreciate your help. Please try the following code: C:\test>type abhi2.bat Code: [Select]@echo off Rem USE the following code only one time echo 05/16/2010 > yesterday.txt rem erase the above line after 23:50 today set /p yesterday=<yesterday.txt echo yesterday=%yesterday% ) set Today=%DATE% set Today=%DATE:~4,10% echo Today=%Today% cd c:\netpub\ftproot\photos\ rem the above folder is where we count files? dir /OD /A-D | findstr "%yesterday% %Today%" dir /OD /A-D | findstr "%yesterday% %Today%" | find /c /v "" > filecount.txt echo type filecount.txt type filecount.txt echo %Today% > yesterday.txt The following Output is for c:\test\ on my computer C:\test>abhi2.bat yesterday=05/16/2010 Today=05/17/2010 05/16/2010 04:19 AM 361 st0510.bat 05/16/2010 01:20 PM 92 teststr.txt 05/16/2010 09:37 PM 135 yesterday.bat 05/16/2010 10:32 PM 466 Abhi.bat 05/16/2010 10:32 PM 3 filecount.txt 05/17/2010 12:26 PM 483 abhi2.bat 05/17/2010 12:27 PM 14 yesterday.txt type filecount.txt 7 Quote from: TechAbhi on May 16, 2010, 11:57:45 AM How to email from commamd prompt the count. "You can use blat (www.blat.net) to send the email" I have not used www.blat.net Let us know how you send email from the command prompt? |
|
| 3495. |
Solve : Batch script for/if not looping? |
|
Answer» Win XP SP.3 |
|
| 3496. |
Solve : Creating batch file to count number of files in a directory? |
|
Answer» I would like to do the above and then if the number of files is larger then what I specify, have it email me and tell me that the number of files has been exceeded. Any advice on this would be great.I don't THINK MS-DOS can email, if anyone knows different, tell please. I am like 90% sure I'm RIGHT on this.there are probably programs that could be invoked from the command-line to E-mail. BC programmer, you're batch file counted the files. But then it just exited out. ahh yes, just add "Pause" right before the ":showfiles" line. It still doesn't seem to work, it pauses in the beginning before it counts the file. I need it to pause after it's counted all the files.don't put pause at the end of the batch, but rather in the same area that Tan_Za has placed their pause, which is right before the subroutine. here, I also fixed a bug involving a forgotten GOTO :EOF, not sure if it was affecting the program or not, though. Code: [Select]@echo off title File Counter batch. :recurse set I=1 echo "files in folder" cd REM view all files, EXCEPT directories. FOR /f "tokens=*" %%P IN ('dir /A-d /b') do (call :showfiles "%%P") echo Filecount: %I% REM now call on all subfolders... PAUSE goto :eof :showfiles echo %1 set /a I+=1 goto :eof What's wrong with: dir /b /s /A-d c:\temp | find "" /v /n /c You can use blat (www.blat.net) to send the email Quote from: rbird on February 11, 2009, 03:18:57 AM What's wrong with: why, it's too easy, of course! redirect that to a variable and he'd be good to go bit of a topic bump, but for a good reason from somebody who knows their switches . EDIT: welcome to CH!Hello All, I would like to count the number of files from a folder and only count the files from yesterday. And email the count to a specific email address. I would set this on a Task Scheduler to daily to get a count and see how many files are added to the folder. I tried creating a batch file dir /a "C:xx\" |find /c /v "" But this gives me a count of everything in the folder, i just need a count from yesterday and also i dont know how to email the count. Please help!Quote from: TechAbhi on May 16, 2010, 11:55:42 AM Hello All,Please make your own thread instead of bumping one from last year. |
|
| 3497. |
Solve : Need help with the 'Wait' or 'Sleep' command in a batch file? |
|
Answer» I am trying to run the following simple batch file: [I am using the pauses just to step through the file] use : er, no. Quote from: mdprator I need to wait until the first operation has completed.You might want to throw in the /b switch to PREVENT a secondary window. Code: [Select]start /wait /b "" C:\DXR\PROGRAM\Dxr32 /si /pn1-5000 /pfc:\temp\Test-5.pdf Sidewinder, Thank you so much for your suggestion [ start /wait /b "" ] it worked like a champ......... Thanks again.............. Another satisfied customer... Nice catch, SW, with the /b switch. Just to explain... The start command needs to have a string supplied to it CALLED the "title". This can be a blank string, just 2 quote marks, but it cannot be left out. start "title" program.exe param1 param2 param3 |
|
| 3498. |
Solve : Read and Write to a value? |
|
Answer» Hi, Can I place the file.txt in a different location. not in the same location with the Test.bat This is the type of question you could answer by TRYING the code. In fact the answer is yes. You can never go wrong using the PATH of a file, provided of course the path is correct. Thanks! |
|
| 3499. |
Solve : Text Search and Bat file? |
|
Answer» HI every body!! I have program Text Search (TS.exe) and use one bath file use it search some code from file This is bat file: @echo off rem :ikot rem cls rem if %1 errorlevel -- 0 GOTO tapos ts /s %1 "$$" ts /s ...... ts /s %1 " t H " rem shift rem goto ikot rem :tapos exit Any thing i want find between "" How I can use bat file find Some special Character Example: "%", "LR" or Quotation mark Help me if i want find percent SIGHT or other only start Line, "space Quotation space" , ETC.. in file Text ThanksSorry all Quote I have program Text Search (TS.exe)It is program create by some body in my country and it have same name with some program. But I want know, how I can search text and special Character. Example: $Zasd "dasd$Z dsad $I asd $Idasd$Z" dsad dsad $Zdafh " asdfgf "asd adsd $Z asdfsd" $Zasdas% How I can find only $Z Start Line, $I End Line or %, " (space Quotation mark space), etc... in DOS |
|
| 3500. |
Solve : How to split any line(path) throught command line (for batch file)?? |
|
Answer» Quote from: Sidewinder on September 12, 2008, 08:16:46 AM Code: [Select]if .%%G==. goto getout That's a new one on me. I am used to doing it this way Code: [Select]if "%%G"=="" goto getout hi side winder i used the code send by you and after that code i have to set some enviorment but after that it doesnot set any enviorment varible, can u tell me why this happens? i think because of setlocal enabledelayedexpansionQuote i think because of setlocal enabledelayedexpansion Indeed it is. Usually I try not to use setlocal for this very reason. The call instruction can be put to good use in this context. Code: [Select]@echo off for /F "tokens=* delims=\" %%a in ('cd') do ( set parse=%%a call set new=%%parse:\= %% ) for %%G in (%new%) do ( if .%%G==. goto getout if %%G==test goto getout call set p=%%p%%\%%G ) :getout set p=%p:~1% echo %p% After the batch file executes, the variable p will CONTAIN the directory name. Good luck. i used following code setlocal enabledelayedexpansion set DIR= for /f "tokens=* delims=\" %%P in ('cd') do ( set mypath=%%P set array=!mypath:\= ! ) for %%E in (%array%) do ( if .%%E==. goto getout if %%E==test goto getout call set DIR=%%DIR%%\%%E ) :getout set TOP_DIR=%DIR%//test1 and if i removed setlocal enabledelayedexpansion and prints valuse of TOP_DIR = \!mypath:\\!\\test1 and if print the value of TOP_DIR with enabledelayedexpansion it is TOP_DIR = %TOP_DIR% that is no value is set so now what should doneIf you remove the setlocal statement, you must also remove any references to delayed expansion: Code: [Select]set DIR= for /f "tokens=* delims=\" %%P in ('cd') do ( set mypath=%%P call set array=%%mypath:\= %% ) for %%E in (%array%) do ( if .%%E==. goto getout if %%E==test goto getout call set DIR=%%DIR%%\%%E ) :getout set TOP_DIR=%DIR%//test1 Why are you using both FORWARD and BACKWARD slashes? They are not interchangeable. Why keep changing the variable (both declared and generated) names? Many people read these posts; let's try and keep it simple. I thought you were trying to find the parents of the test directory on the path. Now I see you're appending test1 to the generated path. Any more surprises first of all sorry for changing variables . now let me explain you what i was doing i find out the the parents of the test directory, which i FOUND with the hlep of ur code. After then i want to set some eviorment variables using this DIR(perent directory ) path. and that variables value should be fixed till that command prompt is open or setup is runs again. so finally The thing is done . No more surprisess. and thanks for that much support. |
|