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.
| 101. |
Solve : how to execute this command through batch file..???? |
|
Answer» "setup.exe -sa -VER isolated -path "C:\tsdct\ETAS\ASCET-DIFF\V6_1_0_BETA2","C:\TSDE_Workarea\ETASData\ASCET-DIFF\V6_1_0_BETA2" -title "ASCET-DIFF V6.1.0_CS_Alpha_1_RC1" -reg 6_1_0BETA -isolated 6_1_0 -silent" |
|
| 102. |
Solve : Do we have limitation on the length of the command line arguments..??? |
|
Answer» Do we have limitation on the LENGTH of the command line arguments..or what would be the maximum no of characters does a command line supports..?? |
|
| 103. |
Solve : simple batch file needs little modding? |
|
Answer» Hi there I need to create a batch file that will read a text document and create a file for each line of text I have one that almost works but the trouble is the lines of texts have spaces in them and it is creating a file for each section of text so if i have a line of text that reads 'I want only one file' it will create files called I, want, only, one and file the script I am using is Try:HEY! That was my 3000th post!!! Anyway, BC, wouldn't "tokens=*" and "delims=" pretty much do the same thing?C:\batch>TYPE wonker.bat Code: [Select]echo off setlocal enabledelayedexpansion for /f "delims=" %%i in (file.txt) do ( echo %%i set newf=%%i echo Turn off > "!newf!.txt" dir "!newf!.txt" ) Output: C:\batch> wonker.bat wonker Volume in drive C has no label. Volume Serial Number is F4A3-D6B3 Directory of C:\batch 03/10/2010 05:28 PM 11 wonker.txt 1 File(s) 11 bytes 0 Dir(s) 298,567,569,408 bytes free hope Volume in drive C has no label. Volume Serial Number is F4A3-D6B3 Directory of C:\batch 03/10/2010 05:28 PM 11 hope.txt 1 File(s) 11 bytes 0 Dir(s) 298,567,569,408 bytes free works Volume in drive C has no label. Volume Serial Number is F4A3-D6B3 Directory of C:\batch 03/10/2010 05:28 PM 11 works.txt 1 File(s) 11 bytes 0 Dir(s) 298,567,569,408 bytes free C:\batch> Input: C:\batch>type file.txt wonker hope works C:\batch>thanks to all who replied from all your suggestions I tried the easiest looking one first and with a little modding got it working perfect I ended up using for /f "tokens=*" %%i in (file.txt) do echo off> %%i not that its that important for me at the moment but I have in past wanted to do same thing but to MAKE folders instead of files but used to have same problem with it creating new folder for each word so thought Id SEE if this would now work same for folders so I tried for /f "tokens=*" %%i in (file.txt) do mkdir %%i but this still made the folders for each word any ideas why that is? Wrap it in quotes. Like this: "%%i"brilliant had tried similar when trying to mod my original script for making files which DIDNT work so didnt try doing same again, but it worked on that one thanks so much for all your help this forum is great, get plenty of quick succesful responses. I'm just beginning with trying to learn some basics with making scripts and have got a few ideas of scripts I would like to create so no doubt you will here from me again within the next few days. thanks again, James. |
|
| 104. |
Solve : what is wrong with this? |
|
Answer» what is wrong with this code |
|
| 105. |
Solve : how to implement int 27h or the function 31h of int 21h?? |
|
Answer» hello everyone, INT 27h http://www.delorie.com/djgpp/doc/dpmi/api/310c01.html Hope you know what your are doing. This is like going into a very high class restaurant and you don't see the prices. If you have to ask you can't afford it. Before you try and use these low level functions your should already have a full understanding of what they do. Otherwise you computer will crash and burn.it sounds a little crazy,but I will try.Thank you.Well, here are some samples written in C. http://www.freshersworld.com/Directory/codes.asp?cat=C&subcat=Terminate%20but%20Stay%20Resident%20%28TSR%29 |
|
| 106. |
Solve : Need to merge .xls files into one file? |
|
Answer» Have MULTIPLE .xls files - need to merge into ONE file for upload for processing. Have multiple .xls files - need to merge into one file for upload for processing. The FOLLOWING example is for .txt files: Code: [Select]echo off dir /b a*.txt > all_a.txt echo HELLO merge > merge.txt for /f "delims=" %%i in (all_a.txt) do ( echo %%i type "%%i" >> merge.txt ) type merge.txt Quote from: greg on March 12, 2010, 06:53:37 PM The following example is for .txt files:have you tried doing that way for .xls files? Quote from: ghostdog74 on March 12, 2010, 07:05:22 PM have you tried doing that way for .xls files? I don't have any .xls files on my machine. Will the the Ghostdog demostrate how to merge the .xlm files? Thanks for you help Ghostdog. http://software.informer.com/getfree-view-xls-data-in-notepad/ http://www.monkeyjob.com/FileMonk/FAQ/Join-Merge-XLS-Files-Excel.htm Quote from: greg on March 12, 2010, 11:06:20 PM I don't have any .xls files on my machine. xls/xlm(whatever it is) are binary files. you can't just concat the files like that. the best/correct way is to use the application( in this case, excel) to join them together, either by hand, or by use of vbscripting. Quote from: ghostdog74 on March 12, 2010, 11:20:58 PM xls/xlm(whatever it is) are binary files. you can't just concat the files like that. the best/correct way is to use the application( in this case, excel) to join them together, either by hand, or by use of vbscripting. Please, give us an example. |
|
| 107. |
Solve : Dos command to get file from url? |
|
Answer» I am a beginner.I want to know that can we use any dos command to download some file from a url LIKE htm ,jpg file and had a speed result ?If write a batch file ,how can i do that wget, curl.Code: [Select]C:\>wget http://iso.linuxquestions.org/download/290/2792/http/distro.ibiblio.org/tinycore_2.9.iso |
|
| 108. |
Solve : "Bad command or file name" during system restore? |
|
Answer» I have an Emachine T2542 Desktop. I'm trying to do a complete restore using the Restore CD's that came with the computer. After inserting the disk, I reboot the computer and get the FOLLOWING: that error message sounds like a missing command interpreter Well it's not. Windows NT doesn't have a command interpreter that is required for boot-up. Quote from: tom97531 on March 07, 2010, 09:19:56 AM Whenever I type something in the provided space, I get the same message. Please help. type "dir" and report what it says.After typing "dir" I get a very long list "country, bug, display, etc." followed by 27 files 1,422,108 bytes 0 dirs 28,672 bytes free Do I scrap mat123's idea about the floppy? Finally got a hold of one today but seems to be a bad disk. I can get more tomorrow.Try it again. Do NOT use the number pad. Use the numbers at the top of the keyboard. "Use the numbers at the top of the keyboard." Already tried that and just tried it again. Still get "Bad command or file name".I was guessing. Bad guess. You said you can do the 'DIR' command, so the system is there and reads your keyboard OK. Is there an AUTOEXEC.BAT file present?' If so, Do this: (the purple letters.) A:>type autoexec.bat Also: A:>type config.sys Maybe that will provide a clue. dir with the P switch lets you use the spacebar to scroll thru all the info... Usage : dir /p Enter... Following "type autoexec.bat": (Missing some info off top of screen), then :Restore echo off ghost -clone,mode=load,src=R:\T2542.gho,dst=1 -sure -ntil cls ECHO. WINDOWS XP RESTORE COMPLETE THE HARD DISK CONTENTS HAVE BEEN RESTORED. ** STORE THIS CD-ROM IN A SAFE LOCATION! ** ECHO REMOVE THIS CD ROM FROM THE TRAY AND PRESS ANY KEY TO REBOOT THE SYSTEM.. a:\EJECTCD.exe r: pause a:\Reboot.exe goto exit :exit A:\> Pressing any key does nothing Following "type config.sys": BUFFERS=20 FILES=60 DOS=HIGH,UMB stacks=9,256 lastdrive=z shell=a:\command.com a:\ /p devicehigh=ansi.sys devicehigh=oakcdrom.sys /D:GEMCD001 REM Uncomment4UK rem devicehigh=display.sys con=(ega,,1) rem country=044,850,country.sys A:\> Following "dir /p": ANSI SYS 9,719 AUTOEXEC BAT 2,134 CHKDSK EXE 27,968 CHOICE COM 1,754 COMMAND COM 93,040 CONFIG SYS 242 COUNTRY SYS 30,722 DEBUG EXE 20,490 DISPLAY SYS 13,207 DOSKEY COM 15,495 EDIT COM 69,854 EGA CPI 58,870 EJECTCD EXE 8,603 EM_LOCK EXE 7,729 FDISK EXE 66,060 FORMAT COM 64,247 GHOST EXE 644,976 HIMEM SYS 4,768 IO SYS 116,736 KEYB COM 12,187 KEYBOARD SYS 34,566 MODE COM 29,239 MSCDEX EXE 25,473 MSDOS SYS 9 OAKCDROM SYS 41,302 REBOOT EXE 755 SYS COM 21,943 27 FILES 1,422,108 BYTES 0 DIRS 28,672 BYTES FREETry: A:/>TYPE AUTOEXEC.BAT|MORE This will show contents of AUTOEXEC.BAT file in the MORE utility, press spacebar to advance a screen's information, and enter to advance a line. Quote from: Veltas on March 11, 2010, 03:53:49 AM Try: Says: Write protect error writing drive A |
|
| 109. |
Solve : Help me in my Batch Script? |
|
Answer» I have a batch script which copies the targeted files from drives, for example if I want all .doc to be copied from C Drive it copies all, the THING is I need it to copy 20, or 10 files not full .doc from C drive. . . . for example if I want all .doc to be copied from C Drive it copies all, the thing is I need it to copy 20, or 10 files not full .doc from C drive. C:\batch>type akki.bat Code: [Select]echo off setLocal EnableDelayedExpansion set /a c=0 set destfolder=E:\copydoc\ for /f "delims==" %%i in ('dir c:\*.doc /s /b') do ( echo %%~nxi set /a c+=1 echo c=!c! if !c! GTR 9 goto end copy "%%i" %destfolder% ) :end Output: C:\batch>akki.bat longshot.doc c=1 1 file(s) copied. longshot.doc c=2 1 file(s) copied. ls.doc c=3 1 file(s) copied. winword.doc c=4 1 file(s) copied. winword2.doc c=5 1 file(s) copied. fractions.doc c=6 1 file(s) copied. third.doc c=7 1 file(s) copied. twothird.doc c=8 1 file(s) copied. What is My IP Address.doc c=9 1 file(s) copied. aarp081009.doc c=10 C:\batch> E:\copydoc>dir Directory of E:\copydoc 03/12/2010 06:18 PM . 03/12/2010 06:18 PM .. 10/23/2009 09:25 PM 20,480 fractions.doc 03/06/2005 09:59 PM 4,195 longshot.doc 03/06/2005 09:59 PM 4,195 ls.doc 10/23/2009 08:44 PM 24,576 third.doc 10/23/2009 08:45 PM 24,576 twothird.doc 10/20/2009 11:27 AM 24,064 What is My IP Address.doc 04/14/2008 06:00 AM 4,608 winword.doc 04/14/2008 06:00 AM 1,769 winword2.doc 8 File(s) 108,463 bytes 2 Dir(s) 139,440,300,032 bytes free E:\copydoc> Quote from: greg on March 12, 2010, 05:24:21 PM
Thanks Greg, you saved my day. |
|
| 110. |
Solve : How to change Start type in services using batch file.? |
|
Answer» Hi Everyone: |
|
| 111. |
Solve : BIOS/DPMS DOS and bootable disk not working ???? |
|
Answer» Ok so today i downloaded LINUX, trying to install it on my pc. I burned it to a cd and ran it on my COMPUTER, i thought it was WORKING but DPMS DOS popped up.... |
|
| 112. |
Solve : getting dos to read firewire device? |
|
Answer» Hi I've not made any progress with this endeavor. I am trying to get dos to run firewire 1394b devices. Here are the codes I have tried so far and the error messages when they load at the startup. See The 3rd Post Here...The drivers shown in the 6th Post are the only ones that work for me. Sometimes it doesn't find the drive the 1st time, so I just reboot and it will find it the 2nd time.I have temporarily suspended the firewire-dos project because of unresolved issues with those drivers. I am now trying to use dos-usb configurations. I got the Panasonic drivers USBASPI.SYS and DI1000DD.SYS in the configuration menu. It detects my usb flash drive device as EHCI, but how do I assign it a drive letter so I can get DOS to access it? I tried DI1000DD.SYS /dh but it just said 'invalid drive specification.' I want to be able to use DOS to copy my external IDE hard drive to the partition on my pc that dos doesn't reside in. When I am done, I want it to look like C:\DOS and D:\Win2K on the internal scsi drive. Of course it will have to be formatted with Fat32 as DOS won't read NTFS. I changed the bios reading from legacy floppy to FDD but it really didn't change anything. Help, cause I am stymied again. Here is the configuration I am using presently. Device=C:\Dos\usbaspi.sys e/ w/ Devicehigh=C:\Dos\DI1000DD.SYS /df Do I need a specific line in the autoexe.bat so it will provide a drive letter?config.sys [Menu] menuitem=1394, 1394 Firewire Mass Storage menuitem=usbaspi, ASPI USB Mass Storage menudefault=usbaspi, 30 [1394] devicehigh=\DOS\himem.sys devicehigh=\Drivers\aspi1394.sys /int /all devicehigh=\Drivers\di1000dd.sys [usbaspi] devicehigh=\DOS\himem.sys devicehigh=\Drivers\usbaspi0.sys /norst /v /w devicehigh=\Drivers\di1000dd.sys [common] dos=high,umb lastdrive=Z _______________________________________ ______________________________ autoexec.bat not necessary. "di1000dd.sys" provides the drive letter. Well after some research, I made some useful discoveries. First, I was invited to include in a batch file various usb drivers. USBASPI0.SYS; USBASPI1.SYS; USBASPI2.SYS; USBASPI3.SYS; USBASPI4.SYS so DOS can cycle through each one and use the one it chooses. The second revalation comes in the knowledge that DOS will not open any drives that are larger than 2gig. Since my cloned hard drive is over 10gig, that option is dead. Maybe I'll just end up putting LinuxMint on the extended drive instead. Quote from: PunkA on March 06, 2010, 02:21:29 PM ...DOS will not open any drives that are larger than 2gig....I don't know where you got that "fact", but it's not true. I have a 60GB USB drive and it works just fine with DOS 7 (Win98SE). I also have a USB/1394 120GB combo drive using the same DOS version.Alright, I've been wrong before. So I decided to scrap MSDOS6.22 and install 8.0 that I found on the web in winimage. I guess I am just stubborn. If anyone wants the link, just let me know. I didn't realize that your hard drive size should not be larger than 2gig to load it. DOS 6.22 is FAT16, DOS 7.1 is FAT32; that explains it. DOS 8 is from WinME, DOS7.1 is from Win95B, Win98, Win98SE I wouldn't use anything from WinME. WinME didn't use DOS. http://www.ntfs.com/ntfs_vs_fat.htm http://en.wikipedia.org/wiki/Comparison_of_x86_DOS_operating_systemsI suffer from the same affliction as Oscar Wilde. I can resist anything except temptation. I went copied the DOS 8.0 files to my C: drive. I would still like to be allowed to access my external hard drive with its fw interface. It gives me a choice of cd rom support at the start up. But no choice for a mouse pointer. C:\Autoexec.bat echo off path=C:\Windows;C:\windows\command \hibinv.exe call \checksr.bat IF "%config%"=="QUICK" Go To Quick set EXPAND=Yes set DIRCMD=/O:N set Lg l Drv=27* 26 Z 25 Y 24 X 23 W 22 V 21 U 20 T 19 S 18 R 17 Q 16 P 15 set Lg l Drv=%Lg l Drv % O 14 N 13 M 12 L 11 K 10 J 9 I 8 H 7 G 6 F 5 E 4 D 3 C cls call setramd.bat %Lg l Drv% set temp=C:\ set tmp=C:\ path %RAMD%:\;a:\;%path%;%CDROM%:\ copy command.com %RAMD%:\ >NUL set comspec=%RAMD%:\command.com copy extract.exe %RAMD%:\ >NUL copy readme.txt %RAMD%:\ >NUL :EXT %RAMD%:\extract /y /1 %RAMD%: ebd.cab >NUL echo The diagnostic tools were successfully loaded to drive %RAMD%. echo, IF "%config%"=="NOCD+ GOTO QUIT IF "%config%"=="Help" GOTO HELP LH %RAMD%"\::IF MSCDEX doesn't find a drive... IF ERRORLEVEL 1 SET CDPROB=1 cls call help.bat :: GOTO QUIT :QUIT call fixit.bat rem clean up environment variables set CDPROB= set CDROM= set Lg l Drv= GOTO QUICK :QUICK C:\Config.sys [Menu] menuitem=HELP, Help menuitem=CD, Start computer with CD support. menuitem=NOCD, Start computer without CD rom support. menuitem=QUICK, Minimal boot. menudefault=Help,30 menucolor=7,0 [HELP] device=Oakcdrom.sys /D:mscd001 device=btdosm.sys device=flashpt.sys device=aspi2dos.sys device=aspi8dos.sys device=aspi4dos.sys device=aspi8u2.sys device=aspicd.sys \D:mscd001 devicehigh=ramdrive.sys /E 2048 [CD] device=oakcdrom.sys /D:mscd001 device=btdosm.sys device=flashpt.sys device=btcdrom.sys device=aspi2dos.sys device=aspi4dos.sys device=aspi8dos.sys device=aspi8u2.sys device=aspicd.sys /D:mscd001 devicehigh=ramdrive.sys /E 2048 [NOCD] devicehigh=ramdrive.sys /E 2048 [QUICK] [COMMON] files=10 buffer=10 dos=high,umb stacks=9,256 lastdrive=z device=display.sys con=(ega ,,1) country=044,850, country.sys install=mode.com con cp prepare=((850)ega.cpi) install=mode.com con cp select=850 There was not a mouse driver included with the copied boot disk files to the C: drive so is it possible to import a driver to have mouse support? Also DOS 8.0 created a D:\ drive for diagnostic tools called D:\ MS-RAMDRIVE. These are the files it displays in D: ATTRIB.EXE CHKDSK.EXE COMMAND.COM DEBUG.EXE EDIT.COM EXT.EXE EXTRACT.EXE FORMAT.COM HELP.BAT MSCDEX.EXE README.TXT SCANDISK.EXE SCANDISK.INI SYS.COM And what about the matter of getting usb and firewire detection and assigning drive letters? Will aspi1394.sys, di1000dd.sys and usbaspi.sys, still do the trick here? At least now I have FAT32 interface going. Quote from: Computer_Commando on March 07, 2010, 03:43:11 PM WinME didn't use DOS. Windows ME is still based on a DOS core exactly like windows 95, 98, and 98SE. MS just hid the option to boot into MS-DOS mode. PunkA: Um, and what exactly would you use mouse support for... you cannot use the mouse at the prompt, just within other programs. I have no IDEA with regards to mouse drivers; I always use mouse.com included with DOS, but since MS never ACTUALLY released any version of DOS beyond 6.22 and they are in fact hacked versions of the boot disks that are created by windows I don't know what would be included with them.Ok, so Mr. Billy Boy decided to X the bootable version. Does that mean a hack doesn't exit to override it so that it will boot from the hdd? I checked the format and somehow it was still formatted for FAT16. Don't know how that occurred but now I will use the system bios to change it to FAT32. Quote from: PunkA on March 09, 2010, 04:27:24 PM Ok, so Mr. Billy Boy decided to X the bootable version. Does that mean a hack doesn't exit to override it so that it will boot from the hdd?it's not a "hack"... it's two commands- boot to the floppy and use: Code: [Select]format C: /s sys C: Additionally what I was saying had nothing to do with legal issues or anything like that, necessarily- I was just pointing out the fact that what you are using is a boot disk, and only includes the "bare necessity" external commands- no surprise that mouse.com is not considered a necessity. Quote from: PunkA on March 09, 2010, 04:27:24 PM Don't know how that occurred but now I will use the system bios to change it to FAT32. no you won't. |
|
| 113. |
Solve : errorlevel->help for batch file? |
|
Answer» I'm new to adding errorlevel logic into a BATCH file and looking for some help. |
|
| 114. |
Solve : Batch file needed? |
|
Answer» Hi
What building Tool? Post the batch file you have created. The OS automatically tracks the file's name, size and creation date when a file is placed in a folder. Use the dir command to display the information. C:\>dir Volume in drive C has no label. Volume Serial Number is 0652-E41D Directory of C:\ 04/16/2010 05:05 PM 1100 06/10/2009 04:42 PM 24 autoexec.bat 06/10/2009 04:42 PM 10 config.sys 04/16/2010 08:59 PM LaserJet517 04/17/2010 07:17 AM Office2003SP3Changes 07/13/2009 09:37 PM PerfLogs 04/24/2010 05:30 AM Program Files 04/16/2010 04:19 PM Users 04/23/2010 06:41 PM Windows 2 File(s) 34 bytes 7 Dir(s) 300,943,646,720 bytes free C:\> Quote from: mukku on April 22, 2010, 03:48:17 AM Now I need a batch file that recognises latest binaries and triggers the build. C:\test>type buildlog.bat Code: [Select]echo off if EXIST timefile*.txt del timefile*.txt dir > folderlog.txt rem for four times add dir info to log each time interval ( command line arg %1 ) set /a c=0 :timer if %c%==4 goto end set /a c=%c% + 1 time /t > timefile%c%.txt sleep.exe %1 time /t >> timefile%c%.txt dir >> folderlog.txt type folderlog.txt goto timer :end C:\test>type timefile*.txt timefile1.txt 02:42 PM 02:43 PM timefile2.txt 02:43 PM 02:44 PM timefile3.txt 02:44 PM 02:45 PM timefile4.txt 02:45 PM 02:46 PM C:\test> Hi, Greg! Quote from: Salmon Trout on April 24, 2010, 02:09:04 PM Hi, Greg!Not again...so bill, what PROXY are you using, SINCE you can't use your ISP to get on?I voted... Quote from: patio on April 24, 2010, 03:16:34 PM I voted... It's our duty!why is there a poll for this topic?I wanted to vote, but I had a problem. Two problems. There were not enough choices. The choices available were hard to discriminate. Quote from: Geek-9pm on April 24, 2010, 07:05:06 PM The choices available were hard to discriminate[/i]. I'm not helping you find your glasses this time, Mr. Magoo. |
|
| 115. |
Solve : Storing current directory into a variable? |
|
Answer» I'm WORKING on a concept script that requires me to save the current directory that the script is being run from in a varible to be used later: if you need the current directory then use the CD variable.Why do that when you can just use %CD%? Quote from: Helpmeh on April 23, 2010, 04:18:00 AM Why do that when you can just use %CD%? because they want to use the current directory at the time they retrieve it later on when it MAY no longer actually be the current directory? gpl caught ONTO the possible requirement the OP was after- pushd and popd. |
|
| 116. |
Solve : find and findstr help? |
|
Answer» "find" does partly what I want, and "findstr" does partly what I want. But neither one separately provides fully what I want to accomplish. I want to count the occurrences of string1 in a text file output.txt, only if the string is at the beginning of the line. I do not want to see the lines scroll on the screen, only the number of occurrences. Then I want to count the occurrences of string2 in the same file output.txt, again only at the beginning of the line and displaying only the count. Then I want to compare the two counts, either with a visual check on the screen or with the comp command if I chose to send the results to two text FILES. If the two counts are the same, I am okay; if not, echo an error message. Is there a WAY to pipe find and findstr together in one statement? I can solve the problem with the following steps, but this seems like double work for each search: findstr/b "string1" output.txt > count1.txt findstr/b "string2" output.txt > count2.txt find/c "string1" count1.txt find/c "string2" count2.txt Thanks in advance. Code: [Select]echo off echo cat dog horse>output.txt echo cat dog horse>>output.txt echo cat dog horse>>output.txt echo cat dog horse>>output.txt echo man girl boy>>output.txt echo man girl boy>>output.txt echo man girl boy>>output.txt echo man girl boy>>output.txt echo dog man cat>>output.txt set string1=cat set string2=man setlocal enabledelayedexpansion set count1=0 set count2=0 for /f "delims=" %%L in (output.txt) do ( echo %%L | findstr /b "%string1%">nul && set /a count1+=1 echo %%L | findstr /b "%string2%">nul && set /a count2+=1 ) if %count1% equ %count2% ( echo Counts are equal ) else ( echo Counts are not equal ) echo Occurrences of %string1% at start of line = %count1% echo Occurrences of %string2% at start of line = %count2% Code: [Select]Counts are equal Occurrences of cat at start of line = 4 Occurrences of man at start of line = 4Thanks a lot.download grep for windows and then do this Code: [Select]C:\test>TYPE file cat dog horse cat dog horse cat dog horse cat dog horse man girl boy man girl boy man girl boy man girl boy dog man cat if you want to display strings "cat" or "man" (data stolen from ST), Code: [Select]C:\test>grep -E "^[[:SPACE:]]*(cat|man)" file cat dog horse cat dog horse cat dog horse cat dog horse man girl boy man girl boy man girl boy man girl boy to search "cat" or "man" at beginning and display count Code: [Select]C:\test>grep -Ec "^[[:space:]]*cat" file 4 C:\test>grep -Ec "^[[:space:]]*man" file 4 to get total count Code: [Select]C:\test>grep -Ec "^[[:space:]]*(cat|man)" file 8 Quote from: ghostdog74 on April 22, 2010, 05:34:24 PM download grep for windows and then do this . . . Or use wc -l. C:\>type output.txt cat dog horse cat dog horse cat dog horse cat dog horse man girl boy man girl boy man girl boy man girl boy dog man cat C:\>findstr "^cat" output.txt | E:\bin\wc -l 4 C:\>findstr "^man" output.txt | E:\bin\wc -l 4 C:\> |
|
| 117. |
Solve : Batch to rename multiple files...? |
|
Answer» I have a number of folders named USING a yyyymmdd format, i.e., 20100419. I have a number of folders named using a yyyymmdd format, i.e., 20100419. dir /b > oldname.txt C:\20100419>type newname.bat Code: [Select]echo off set /p fold=%1 for /f "delims=" %%i in (oldname.txt) do ( copy %%i %fold%%%i ) rem rename %%i %fold%%%i rem del %%i ) C:\20100419>newname.bat 20100419 20100419 1 file(s) copied. 1 file(s) copied. 1 file(s) copied. 1 file(s) copied. 1 file(s) copied. C:\20100419>dir Volume in drive C has no label. Volume Serial Number is 0652-E41D Directory of C:\20100419 04/24/2010 04:32 PM . 04/24/2010 04:32 PM .. 04/24/2010 04:06 PM 9 20100419file1.txt 04/24/2010 04:06 PM 9 20100419file2.txt 04/24/2010 04:06 PM 9 20100419file3.txt 04/24/2010 04:06 PM 9 20100419file4.txt 04/24/2010 04:07 PM 9 20100419file5.txt 04/24/2010 04:06 PM 9 file1.txt 04/24/2010 04:06 PM 9 file2.txt 04/24/2010 04:06 PM 9 file3.txt 04/24/2010 04:06 PM 9 file4.txt 04/24/2010 04:07 PM 9 file5.txt 04/24/2010 04:31 PM 139 newname.bat 04/24/2010 04:29 PM 55 oldname.txt 12 File(s) 284 bytes 2 Dir(s) 300,677,402,624 bytes free C:\20100419>1. Hi Greg! 2. I think you need to READ the question again. Thanks for the responses, but I got the job done with an inexpensive app called Rename Maestro. |
|
| 118. |
Solve : Question about error handling in bat or command files? |
|
Answer» I have a PROBLEM with 1 of the command file but I don’t know how to fix it yet.
if you want to come BACK after DoA.cmd use CALL. |
|
| 119. |
Solve : Command freeze?? |
|
Answer» HI all, so windows 7 killed itself for the first time on my computer to the point where windows fails to start. After LOOKING around in the recovery options I was ABLE to get a command prompt up and running so Hi all, windows 7 killed itself for the first time on my computer to the point where windows fails to start. After looking around in the recovery options I was able to get a command prompt up and running and began to copy my files to an external drive. The problem I'm having is that the command prompt will copy all of the files till it gets to a big file (around 123mb) where it will the freeze. It'll show the file it had attempted to copy and viewing the drive the file will actually be there, but after that it does nothing and doesn't allow input. I really have no idea what would cause this. I've switched out external drives and nothing changed. Here's the code: Xcopy documents h:\backup /s any HELP would be awesome!! Thanks!!! --Chris any help would be awesome!! Thanks!!! If your goal is trying to recover files, Why don't you do it an easier way. Boot the computer to another (GOOD) operating system, and use the other OP to copy your data. One of the easiest is Barts PE. http://www.nu2.nu/pebuilder/ Quote from: Orangedog22 on April 19, 2010, 12:40:03 PM
Check your RAM. Shutdown all startup programs not needed. ( start ,run [ msconfig ], click startup and disable all programs not needed. Buy more Ram? |
|
| 120. |
Solve : DOS login scripts for Windows XP? |
|
Answer» What I'm trying to do is use a .bat file to add or remove a LOGIN script to a local user account on WINDOWS XP. I'm looking for SOMETHING I can use to display a system warning message when a specific user logs into the local computer without having to go to Local Security Settings > Security Options > Interactive login: Message TEXT for users attempting to login. This option will display the same message for all users. Is there a way to CREATE a specific message as a .bat file and use another batch file to add and remove it from a local users account login script and not have it effect all users with the same message?? |
|
| 121. |
Solve : Another thing.? |
|
Answer» Well, I have another question (and it might be to hard for examples). I meant with a chat program in batch, I know, I probably should have written that -_-.I designed a chat program which works over the internet, although there are not many features, you can send messages to anyone. Try using FTP...it works (depending on the host) quite well (as well as a batch file can be, that is). Quote from: Helpmeh on April 25, 2010, 02:51:12 PM I designed a chat program which works over the internet, although there are not many features, you can send messages to anyone. Try using FTP...it works (depending on the host) quite well (as well as a batch file can be, that is). So did I. (about 5/6 years ago) but mine used TCP/IP and worked LIKE an actual chat program by SENDING packets back and forth. It only works on windows 9x and I'm too lazy to find out why. Or release it either. I don't even know if I still have it... |
|
| 122. |
Solve : my for command is not working? |
|
Answer» could someone please tell why this does not work Geek, did you see my post? Did you bother to read it?Sorry I was typing when you posted . Why does it need the single quote? What error message do you get? Code: [Select]the system cannot find the file regCan you explain what this does? Code: [Select]writes the version number to ver.txtOrr what you expect it to do? Code: [Select]create a txt file called ver.txt with the windows version numberCode: Have you already tried it with echo on to see what is happening? this Code: [Select]C:\Documents and Settings\admin-matthew\Desktop>setlocal enabledelayedexpansion C:\Documents and Settings\admin-matthew\Desktop>for /F "tokens=1-3 delims=" %a i n (REG QUERY "hklm\software\microsoft\windows nt\currentversion" /v CurrentVersi on) do ( if !%c == ! goto A echo %c 1>ver.txt ) The system cannot find the file REG. C:\Documents and Settings\admin-matthew\Desktop>echo teste teste C:\Documents and Settings\admin-matthew\Desktop>pause Press any key to continue . . .aahhhh! THIS IS WAY OVER MY HEAD! Code: [Select]Examples: REG QUERY HKLM\Software\Microsoft\ResKit /v Version Displays the value of the registry value Version REG QUERY HKLM\Software\Microsoft\ResKit\Nt\Setup /s Displays all subkeys and values under the registry key Setup Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\>REG QUERY HKLM\Software\Microsoft\ResKit\Nt\Setup /s Error: The system was unable to find the specified registry key or val C:\> Code: [Select]echo off setlocal enabledelayedexpansion for /f "skip=4 tokens=1-3" %%a in ('REG QUERY "hklm\software\microsoft\windows nt\currentversion" /v currentversion') do ( if !%%c==! goto:eof echo %%c >> ver.txt ) A few notes: The default delimiter is a space which is how the output is delimited. Overriding it with no delimiters defeats the purpose of the delims= parameter. You need single quotes around a command in the for statement, and double quotes around parameters with embedded spaces (ie: windows nt). Reg Query outputs lines which are not needed, easiest to skip over. Good luck. Quote from: Geek-9pm on April 24, 2010, 06:21:36 PM aahhhh!That's not the issue. The issue is that in a FOR LOOP, to get the output of a command, you WRAP it in ', to use a string you use " and to get the output from a file you don't use any quotes. An example of each: Code: [Select]rem Command for /f "tokens=3" %%c in ('findstr /c:price^: item.txt') do ( commands commands ) Code: [Select]rem String for /f "tokens=1,3-5" %%A in (this sentence is very long and will not have many parts displayed after) do echo %%A %%B %%C %%D Code: [Select]rem File rem The for loop will preform each task for as many lines are in the file, just like any rem other type of output. for /f "delims=," %%b in (filename.ext) do ( echo %%b )thank you SIDEWINDER Quote from: Sidewinder on April 24, 2010, 06:40:51 PM Code: [Select]echo off I cannot get the above code to run correctly. I'm using windows 7. C:\test>type matt2.bat echo off setlocal enabledelayedexpansion for /f "skip=4 tokens=1-3" %%a in ('REG QUERY "hklm\software\microsoft\windows n t\currentversion" /v currentversion') do ( if !%%c==! goto:eof echo %%c >> ver.txt ) C:\test>matt2.bat C:\test>type ver.txt The system cannot find the file specified. C:\test> What file cannot be found? I tested the code as given. Please help.The original code is so amazingly, awfully, ridiculously, mind-boggingly wrong that I grow suspicious. It reads like code that was designed by somebody who thinks that keywords and commands are like Lego bricks that can be snapped together to produce something that works, without the snapper having to do any thinking or learning. Alternatively it reads like a piece of working batch code that somebody has deliberately edited to introduce as many glaring errors as possible. Who would do that? Somebody who starts threads as one person as then jumps in as another with an "answer". A pathetic individual like Greg/Marvin/Bill? echo off setlocal enabledelayedexpansion for /f "tokens=1-3 delims=" %%a in (REG QUERY "hklm\software\microsoft\windows nt\currentversion" /v CurrentVersion) do ( ^ ^ nonsense; 3 tokens when commands here need single quotes the delims are the start and end of the line? if !%%c==! goto:eof ^ Mad IF test and strange mishmash of loop metavariable and delayed ordinary variable that does not even make sense and a crazy goto echo %%c >>ver.txt ^ and APPEND the (never to appear) result to poor little ver.txt? ) I presume the idea is to extract the NT major and minor version numbers. Maybe running the REG command at the prompt would have been a good starting point? Anyhow, it's all nonsense anyhow, I reckon. (See above) Salmon Trout I just can't make for loops. marvinengland the batch file takes a second to make the file also it is going to say 6.1 not 7 Code: [Select]echo off set commandstring='REG QUERY "hklm\software\microsoft\windows nt\currentversion" /v currentversion' for /f "skip=2 tokens=1-3" %%a in (%commandstring%) do set versionstring=%%c echo %versionstring% if "%versionstring%"=="6.1" echo Windows 7 Quote from: mat123 on April 24, 2010, 04:44:20 PM Would someone please tell why this does not work. C:\test>type ver617.bat Code: [Select]echo off for /f "skip=1 tokens=1-4" %%i in ('ver') do ( echo %%k %%l set ver61=%%i %%j %%k %%l ) echo %ver61% if "%ver61%"=="Microsoft Windows [Version 6.1.7600]" echo Windows 7 OUTPUT: C:\test>ver617.bat [Version 6.1.7600] Microsoft Windows [Version 6.1.7600] Windows 7 C:\test> |
|
| 123. |
Solve : Program Rescue? |
|
Answer» Program Rescue |
|
| 124. |
Solve : MS DOS...? |
|
Answer» MS Dos means Microsoft disk operating system. it was developed by microsoft IBM.It was standed operating system.DOS is still a 16-bit operating system.in markets a VERSION of DOS CALLED DR-OpenDOS that extends MS-DOS in significant ways... MS Dos means Microsoft disk operating system. it was developed by microsoft IBM.It was standed operating system.DOS is still a 16-bit operating system.in markets a version of DOS called DR-OpenDOS that extends MS-DOS in significant ways... After MS DOS, Windows was invented and MS DOS is not used by most people. There is a subset of the DOS commands available under the COMMAND prompt (CMD) of windows. The old MS Dos is not used. And few people drive a Model-T ford. Only nerds continue to use the old dos commands. Quote from: frankken2 on May 21, 2010, 12:51:34 AM MS Dos means Microsoft disk operating system. it was developed by microsoft IBM.It was standed operating system.DOS is still a 16-bit operating system.in markets a version of DOS called DR-OpenDOS that extends MS-DOS in significant ways... More news from frankken2... the sky is blue, and when it is not "night", contains a flaming orb called "the sun", and also (when it is "night") a gentler more silvery light called luna. Another interesting fact is that bears or orsos crap in the woods! The more discreet ones do their "business" behind a tree (or in front of it, depending on your point of view) Plus a load of crap (not from bears or woods however) from Marvin LUNATIC. Is frankken2 Marvin? Quote from: frankken2 on May 21, 2010, 12:51:34 AM thanks....Say What? Windows wasn't "Invented" either. it was written.What was the point to this thread? If the OP had said something like how MS DOS was developed from QDOS (quick and dirty operating system) it might have added something than not everyone knows. Otherwise, I agree with ST. Quote from: rthompson80819 on May 24, 2010, 04:57:37 PM What was the point to this thread? Good question..I BELIEVE frankken is asking for clarification of his statement...sounds like a homework question. But to clarify: MS-DOS(all the versions) were 16-Bit OSs. Windows X.X, 95, 98, ME were 16-Bit/32-Bit Hybrids(Still based upon MS-DOS) Windows NT, 2000, XP were pure 32-Bit OSs Windows XP(64 Bit), Vista, 7 are pure 64-Bit OSs. Frankken: "Windows wasn't "Invented" either. it was written." The point is it does not matter whether Windows was written, created or invented. The point is Windows replaced DOS as an improved Operating System. |
|
| 125. |
Solve : Need Help reading a date? |
|
Answer» Hi, Choose which snippet meets your needs. The today variable is set to the current date. You didn't post your batch file so I can't assist there but there may be problems with the FTP environment "seeing" the cmd shell environment variables. Can you give me a hand with this? I posted what I am using now but it sounds like you have a better way to do things. Thanks Quote from: Spoiler on June 21, 2010, 12:06:25 PM Can you give me a hand with this? I posted what I am using now but it sounds like you have a better way to do things. You give me way too much credit. If what you're are using works, then it's a success story. An alternative way would be to create the dataxfer.txt file on the fly. Code: [Select]echo off for /f "tokens=1-4 delims=/ " %%i in ("%date%") do ( set today=%%l%%j%%k ) > E:\ctftp\dataxfer.txt echo username password >> E:\ctftp\dataxfer.txt echo put E:\ctftp\%today%ABCD.txt >> E:\ctftp\dataxfer.txt echo ren E:\ctftp\%today%ABCD.txt ack >> E:\ctftp\dataxfer.txt echo bye ftp -n -s:E:\ctftp\dataxfer.txt xxx.xxx.xxx.xxx del E:\ctftp\dataxfer.txt pause I couldn't determine if the ABCD part of the file name was static or CHANGED from day to day. The snippet may need further tweaks. Good luck. Howdy, Thanks I will give it a try and see if it works out ok. The ABCD.TXT part of the file name stays the same. The only part of the file name that changes is the date. Thanks again. Quote > E:\ctftp\dataxfer.txt echo username password I had to make a small change so it read echo user username password Things work great now. Thanks again for your help! |
|
| 126. |
Solve : Running shortcut with target? |
|
Answer» I need to run a shortcut or program to load so I don't have to manually access it. The file I am using is a batch file to load all my start programs in the morning. I use /pause between each program to give each one time to load so I can easily show in what ORDER I open my programs if a issue arises. It helps to be consistent.
I have not tested the following: ( Try a different placement to the quote symbols. ) 1) "C:\Program Files\program1.exe /launch Program 2" or 2) Use Call instead of Start. You might call a Label and not another batch. Good Luck :label "C:\Program Files\program1.exe /launch Program 2" I tried them both. It didnt seem to work. The program 1 is softgrid. The program 2 is software that LOADS from it. cd C:\Program Files\Microsoft Application Virtualization Client\ call "sfttray.exe" "Program 2" pause This solved issue. The call feature HELPED. |
|
| 127. |
Solve : Batch help: search for file in profiles, then delete? |
|
Answer» Hey there team...Newb to the forum...from my searching around it looks like a QUITE knowledgeable group...i've got 10+ yrs in the IT/IS field, but have never really had to script anything until now (except for back in college...i know i know...don't use it you lose it) if any line in oldappgate.txt has a space or spaces then for /f will stop at the first one (since it is one of the default token delimiters) so you need to force the delimiters to be the start and end of the line with a "delims=" block. So try this...awesome...that did the trick! thanks a ton! Quote from: gpl on June 23, 2010, 09:09:33 AM dohno biggie! i haven't used For /F that much so i had been scratching my head all day on that one...i felt like i was going crazy...thanks for the help just the same!so i put this script out on a network drive and i had one of the users run it...but it gives an error that it doesn't like being run from a network drive...i don't get it...i tell it to start in C:\...what i'm eventually going to do is have this batch file run when someone logs in so that its done for everyone...is there something i need to call out so that it will run over the network? or is this going to pose a problem for me?ok...so i ran this from my PC and it worked...yet the only difference is that i have it saved in a network drive that is actually MAPPED on my PC (but not mapped on the user's PCs, yet it is a shared folder on the server) in order for this to work, does this batch file have to be in a mapped network drive instead of a shared folder on the network? if i just copy/paste this directly into their logon script will i have the same problems and will their lack of admin/pwer user rights cause any problems for my script? |
|
| 128. |
Solve : are batch file writing different in windows xp and dos 7.1? |
|
Answer» when i run this BAT file in windows command prompt it works fine when i run it from dos 7.1 prompt i get syntex errors when i run this bat file in windows command prompt it works fine when i run it from dos 7.1 prompt i get syntex errors Because it uses the NT command extensions, namely, those allowing string manipulation.is there a way for a batch file to tell the difference between windows command and older dos versions? yes, in your batch script, you make a MANUAL effort to check the operating system the batch file is on. EG using ver etc. But i will tell you a BETTER way to do things. Use a PROGRAMMING language like Perl or Python (or vbscript if you are a native guy) to do your scripting stuffs. Their syntax seldom change (much) across different platforms and software version. |
|
| 129. |
Solve : .bat tracking program!? |
|
Answer» hello again!!! any suggestion??? Please avoid using multiple exclamation and question marks. sorry! oic! then what will be the code then for vbs? Quote from: night-rider link=topic=106393.msg718370#msg718370 [img [/img]date=1277250711]I am confused with that. Quote from: night-rider on June 26, 2010, 12:07:03 AM
Code: [Select]strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colMonitoredEvents = objWMIService.ExecNotificationQuery _ ("SELECT * FROM __InstanceOperationEvent WITHIN 3 WHERE " _ & "Targetinstance ISA 'CIM_Datafile' and " _ & "TargetInstance.DRIVE = 'c:' And "_ & "TargetInstance.Path= '\\temp\\'") Do Set objLatestEvent = colMonitoredEvents.NextEvent() 'WScript.Echo objLatestEvent.Path_.Class & " " & objLatestEvent.TargetInstance.Name Select Case objLatestEvent.Path_.Class Case "__InstanceCreationEvent" WScript.Echo "File Created: " & objLatestEvent.TargetInstance.Name Case "__InstanceDeletionEvent" WScript.Echo "File Deleted: " & objLatestEvent.TargetInstance.Name Case "__InstanceModificationEvent" WScript.Echo "File Modified: " & objLatestEvent.TargetInstance.Name End Select Loop You can change the drive and path as required. Use double backslashes. The WITHIN clause defines the time interval between snapshots. Make it too small and the script will run too often. Make it too big and you may miss some events. For example if you set it to 20 and a file creation event and file deletion event for the same file occurs within the 20 seconds, the script will not notice any change between snapshots and will not report either of the events. Save the script with a VBS extension. Run from the command prompt as cscript scriptname.vbs. Best to run with cscript; wscript will produce popup windows which can be very annoying. Script RUNS in a loop waiting for events to happen in the directory defined in the script. If using cscript, use CTL-C to terminate the script. If using wscript, use the task manager to terminate the script. Good luck. |
|
| 130. |
Solve : Write a BATCH file to open a SSH Client? |
|
Answer» Hello Everyone! |
|
| 131. |
Solve : Shortcut creator? |
|
Answer» Shortcut creator. and this relates to cmd how? Ouwww. I understand. It's not POSSIBLE with a cmd. I abandon. Best Regards What about right click - DRAG to desktop (or other place) - release right mouse button - choose "create shortcut here" from the menu that will appear? Quote from: Salmon Trout on June 26, 2010, 12:23:31 AM What about right click - drag to desktop (or other place) - release right mouse button - choose "create shortcut here" from the menu that will appear? Salmon. Ewemoa from donationcoder.com have made a marvellous script. I am trying to learn autohotkey (and a little batch too). As you know I am always in the best forum like Compute Hope. A script to recognized windows open and create shortkeys for that windows. A predefined set of path where to create the selected icons in a window and other options additonally. Additionally definible hotkeys for fastest creation. CreateShortCutsIn from Ewemoa. Best Regards |
|
| 132. |
Solve : script runs every x hours everyday? |
|
Answer» Hi, |
|
| 133. |
Solve : Change size of command prompt window? |
|
Answer» through batch program, How do i change / reduce the size of running command PROMPT WINDOW? |
|
| 134. |
Solve : cursor help!? |
|
Answer» is it possible to change the cursor everytime I run my .bat file? what if the image of the cursor is the that will change? Please write that in English Quote from: Salmon Trout on June 23, 2010, 12:05:33 AM Please write that in EnglishI am GUESSING this is what he wants: "What if I want the image of the cursor to change?"The DOS cursor is just another text character; usually a block or an underscore; it possible to configure how many PIXELS are lit on a row-byrow basis. There is no "image". oopzzz! sorry for the wrong gramming^^ what if the image of the cursor is the one that will change? sorry again!!! I was mistakened. I THOUGHT CURSOR IS THE MOUSE POINTER??? commonly a ARROW image Quote from: night-rider on June 24, 2010, 03:24:07 AM oopzzz! sorry for the wrong gramming^^Quote from: Salmon Trout on June 19, 2010, 12:43:47 AM Do you mean real MS-DOS or a Windows command window?any suggestion pls...You want to change the DEFAULT Windows cursor from an arrow to something else? Why? to add unique feature everytime I run my system.Then get and install a cursor editor program, or look at the cursor options in Control Panel. so there's no possibility to change it through a .bat code? RUNS ONLY WHEN I RUN MY .EXE |
|
| 135. |
Solve : HELP Batch File? |
|
Answer» Hello everybody, if /i %date%==Tue 06/29/2010 md folderFirst off, that won't work, guaranteed. Improper syntax. Secondly, tendencia, we need to know what is printed EXACTLY on the SCREEN when you run echo %date% at the command prompt (cmd.exe). Quote from: tendencia on June 28, 2010, 06:17:37 PM
C:\test>type tend.bat Code: [Select]echo off if "%date%"=="Mon 06/28/2010" echo folder if "%date%"=="Mon 06/28/2010" md folder date /t rem Mon 06/28/2010 DIR folder Output: C:\test>tend.bat folder Mon 06/28/2010 Directory of C:\test\folder 06/28/2010 07:55 PM . 06/28/2010 07:55 PM .. 0 File(s) 0 bytes 2 Dir(s) 294,527,905,792 bytes free C:\test> |
|
| 136. |
Solve : change size of Notepad window? |
|
Answer» I am opening a notepad file from my batch file program, I am opening a notepad file from my batch file program, Open only the notepad window, right click on open spot of the taskbar and choose "Tile Windows VERTICALLY" ( Make sure only one window is open when you do the above.) Windows will remember the window size your prefer for notepad. Dear marvinengland, the question is, How do i restrict the size or set to the required size only? Quote from: Yogesh123 on June 25, 2010, 07:20:42 AM Dear marvinengland, Control the Window -------------------------------------------------------------------------------- <<<"You can control the location and size of a window with the Title bar buttons, (Win98, WinXP) or (Vista) and by dragging with your mouse. The shape of the mouse pointer tells you what action will take place when you drag. We have already used the Vertical Resize on the taskbar. Here is a list to remind you of the possible shapes when resizing or moving.">>> http://www.jegsworks.com/Lessons/win/basics/step-controlwindow.htm how to control this notepad window size using batch scripting, Using command lineSet size and position with mouse, close Notepad. Open Notepad It remembers size and position Dear Salmon Trout, How to set the notepad window to the required size using command line/ batch scripting, like setting the command prompt window using, mode con lines=1 mode con cols=56Google for cmdow.exe with start you can include mode so you can do just this, you shouldnt have to google a third party prog , I'm Unsure of the PROPER syntax but you can experiment with mode try typing mode 120,30 Quote from: dnthns87 on June 29, 2010, 07:31:08 AM with start you can include mode so you can do just this, you shouldnt have to google a third party prog , I'm Unsure of the proper syntax but you can experiment with mode try typing mode 120,30 Mode can set the size of a command window, but how does that help you set the size of a Notepad window? Quote I'm Unsure of the proper syntax Maybe you should have waited until you were sure? yes, I checked it, MODE doesn't work to set notepad window size, any other alternate pls... Quote from: Yogesh123 on July 02, 2010, 01:31:18 AM yes, Why does it matter? You have been given several solutions. Click the middle ICON at the top right to control window size. One click and the size is CHANGED. Drag the the top left corner of the window to the size you need. All the suggestions given in this thread solve the window size problem. Again, why does it matter? Quote from: marvinengland on July 02, 2010, 06:49:17 AM Again, why does it matter? He wants to set the size directly from the batch file when notepad starts. Quote from: BC_Programmer on July 02, 2010, 10:26:45 AM "He wants to set the size directly from the batch file when notepad starts." So, how does Yogesh123 set the notepad window size from a batch file? Quote from: marvinengland on July 02, 2010, 11:26:56 AM So, how does Yogesh123 set the notepad window size from a batch file? Quote from: Salmon Trout on June 29, 2010, 06:01:22 AM Google for cmdow.exe |
|
| 137. |
Solve : Creating a password protect batch file with a batch file? |
|
Answer» Hey everyone, I'm fairly new at programming at everything, but I'm trying to learn, so bear with me. What do you mean a prank? A prank is where you put a script on somebody elses computer for a joke to see their alarm and surprise. So that you pwn them. (Your name tells me a lot) Way to help a prankster mat123. but, it would show them how to stop it... I created this to test my knowledge as i said before, and now i am trying to find a wait for it to start automatically after 10 minutes or something. Ill probably put a new batch file into the startup folder, and run wait command of some SORT then open this one. Again bro, it's just for fun and personal USE. |
|
| 138. |
Solve : rename directory with wildcards? |
|
Answer» hi,
C:\>rd /? Removes (deletes) a directory. RMDIR [/S] [/Q] [drive:]path RD [/S] [/Q] [drive:]path /S Removes all directories and files in the specified directory in addition to the directory itself. Used to remove a directory tree. /Q Quiet mode, do not ask if ok to remove a directory tree with /S C:\>dir /AD /s Hello* C:\>rd /S Hello*hey Salmon Trout, im sorry, my bad. i actually wanted to delete those files. but i assume deleting/rename or moving would be using similar approach. one reason is because i wanted to rename the directory (hello world_1 to hello_world_1) before deleting. i thought it would be easier if i can delete a directory where the name has no spaces hi marvinengland, i tried rd /S hello* but it returns "The filename, directory name, or volume label syntax is incorrect." remembering that the directory name has a space in between (hello world_1, hello world_2...) i did a search that it says ms dos do not accept wildcard. Quote from: nuttynibbles on July 01, 2010, 07:13:53 PM hi marvinengland, Use the dir command and find the files and then rd. cd to root ( cd \ ) C:\test>cd \ C:\> C:\>dir /AD /s Ho* Volume in drive C has no label. Volume Serial Number is 0652-E41D Directory of C:\06-07-2010\JoanPic 01/02/2009 05:15 PM HOLLEN Trip 2005 01/02/2009 05:15 PM Hollen Trip 6 Mos 0 File(s) 0 bytes C:\>rd /s "hello world" hello world, Are you sure (Y/N)? y The system cannot find the file specified.im sorry marvinengland but i dun quite UNDERSTAND your latest reply Hi all, i managed to delete the directories using a bat file with the following script: Code: [Select]echo off setlocal enableextensions enabledelayedexpansion set /a "x = 1" :while1 if %x% leq 331253 ( echo %x% rmdir "E:\hello world_%x%" set /a "x = x + 1" goto :while1 ) endlocal Quote from: nuttynibbles on July 02, 2010, 04:08:32 AM Hi all, excellent code. Looks like code written by Sidewinder. If you wrote the code, you did not need help. Quote from: nuttynibbles on July 02, 2010, 04:08:32 AM C:\test>dir /AD /b hello* hello world1 hello world2 hello world3 hello world4 C:\test>type nib.bat echo off set /a x=1 :while1 rem echo "hello world%x%" dir "hello world%x%" | findstr "hello" rem rd "hello world%x%" set /a x=%x% + 1 if %x% LEQ 4 goto :while1 Output: C:\test>nib.bat Directory of C:\test\hello world1 Directory of C:\test\hello world2 Directory of C:\test\hello world3 Directory of C:\test\hello world4 C:\test>type nib.bat echo off set /a x=1 :while1 rem echo "hello world%x%" rem dir "hello world%x%" | findstr "hello" rd "hello world%x%" set /a x=%x% + 1 if %x% LEQ 4 goto :while1 Output: C:\test> nib.bat C:\test>dir hello* Volume in drive C has no label. Volume Serial Number is 0652-E41D Directory of C:\test Directory Not Found C:\test>that seems to work but it takes almost ten minutes this stops it after numeric folders no longer exist echo off setlocal enableextensions enabledelayedexpansion set /a "x = 1" :while1 if %x% leq 331253 ( echo %x% if not exist "E:\hello world_%x%\nul" goto exit rmdir "E:\hello world_%x%" set /a "x = x + 1" goto :while1 ) :exit endlocalOne LINE of code. Code: [Select]for /f "delims=" %%D in ('dir /b /ad "hello world_*"') do rd /s /q "%%D" |
|
| 139. |
Solve : for loop deliminator question? |
|
Answer» can i have a for loop so every character is assigned a diffrent %%X can i have a for loop so every character is assigned a diffrent %%X as i have always suggested, if you want to do various programming tasks easily and productively, such as this one you mentioned, use a good programming language. Example in Python Code: [Select]# python Python 2.6.2 (r262:71600, Aug 21 2009) Type "help", "copyright", "credits" or "license" for more information. >>> my_string="abcdefg" >>> list(my_string) ['a', 'b', 'c', 'd', 'e', 'f', 'g'] >>> Now you have all your individual characters separated. Easy isn't it? |
|
| 140. |
Solve : decompressed files automation? |
|
Answer» I have a huge amount of zip and rar files I need to reorganize. |
|
| 141. |
Solve : no boot drive? |
|
Answer» Hello everyone, I just bought a dell 8300 from some one off the INTERNET and the computer was working fine when they showed it to me but when I got it home I tried to defragment the hard drive and it started so I leftr it alone when I came back to it it had a black screen and said no boot drive, it also said press f1 for help and f2 to view system, I kept trying to re-boot with no sucess Please HelpPossibly the hard drive has failed. I hope you didn't pay a LOT for it? |
|
| 142. |
Solve : For Loop + Set Command need helps? |
|
Answer» Hi All, |
|
| 143. |
Solve : batch file editing itself help.? |
|
Answer» Ok so I want to have a batch file on my computer that when run it copies all the files from one location to another as a form of backup. Then what do I do to write/get the file? I do not know what your local date format is, but basically you can do it like this Code: [Select]echo off REM write set today=%date% echo %today%>old-date.txt REM read set /p olddate=<old-date.txt echo the old date was %olddate% Yeah...I'm not that fantastic at batch files...never DONE more than the basic stuff with them. What I want is a batch file to do this: It will be in local disk C: named backup.bat Then... Code: [Select]xcopy C:\ D:\ /D:06-25-2010/K/H/R/Y/E/V/S/Exclude:C:\Windows\ And that will be run every friday by task schedular. The problem is, I don't want it to waste time copying files that have already been copied and have not been changed since the last backup. This is why I want the batch file (or something else) to keep track of the date (which is in MM-DD-YYYY format) but I don't know how to go about doing this...I kind of understand what you said, can you explain it a little clearer in terms of my batch file? Thanks a lot, sharfthis should work (note i have not tested this ) Code: [Select]echo off if not exist lastrun.txt goto copy for /f "tokens=1-3" %%a in (lastrun.txt) do ( set OMM=%%a set ODD=%%b set OYY=%%c ) set DD=%date:~7,2% set MM=%date:~4,2% set YY=%date:~10,4% if %YY% LSS %OYY% goto exit if %MM% LSS %OMM% if %YY% GTR %OYY% goto copy if %MM% GTR %OMM% goto copy if %MM% EQU %OMM% if %DD% GTR %ODD% goto copy goto exit :copy echo.%MM% %DD% %YY% > lastrun.txt xcopy C:\ D:\ /D:%MM%-%DD%-%YY% /K /H /R /Y /E /V /S /Exclude:C:\Windows\ :exit exitlol it just tries to start and shuts down (after creating lastrun.text) which is blank.On its first run lastrun.txt won't exist so it will go to the :copy label, but it won't know the values of %MM% %DD% %YY% which are defined after the goto, so the /D: parameter wiull be blank so the xcopy command will crash Quote note i have not tested this Indeed. Does it every time though.Please show what you get when you type this at the command prompt Code: [Select]echo %date%fixed it Code: [Select]echo off if not exist lastrun.txt goto copy for /f "tokens=1-3" %%a in (lastrun.txt) do ( set OMM=%%a set ODD=%%b set OYY=%%c ) set DD=%date:~7,2% set MM=%date:~4,2% set YY=%date:~10,4% if %YY% LSS %OYY% goto exit if %MM% LSS %OMM% if %YY% GTR %OYY% goto copy if %MM% GTR %OMM% goto copy if %MM% EQU %OMM% if %DD% GTR %ODD% goto copy goto exit :copy set DD=%date:~7,2% set MM=%date:~4,2% set YY=%date:~10,4% echo.%MM% %DD% %YY% > lastrun.txt xcopy C:\ D:\ /D:%MM%-%DD%-%YY%/K/H/R/Y/E/V/S/Exclude:C:\windows\ pause :exit exit Even "fixed" it still does the same thing. When I echo date I get "Sun 06/27/2010"I am not SURE why you need all this stuff. I don't think it does anything USEFUL. In any case the %OMM% %ODD% %OYY% variables aren't actually used for anything. Code: [Select]if %YY% LSS %OYY% goto exit if %MM% LSS %OMM% if %YY% GTR %OYY% goto copy if %MM% GTR %OMM% goto copy if %MM% EQU %OMM% if %DD% GTR %ODD% goto copy As the script stands, the first time it is run, lastrun.txt does not exist, so the batch writes todays' month, day and year values into lastrun.txt. Then it uses those same values (!) for xcopy's "copy files newer than" date. When it is run later, the lastrun.txt exists, and the earlier date is read, but is not used for anything. Why don't you just create a starter lastrun.txt in Notepad, with a suitable date earlier than now, e.g. 06-25-2010 and save it in the folder where the batch script is then just use this Code: [Select]echo off for /f "tokens=1-3 delims=" %%a in (lastrun.txt) do set lastdate=%%a xcopy C:\ D:\ /D:%lastdate%/K/H/R/Y/E/V/S/Exclude:C:\windows\ set DD=%date:~7,2% set MM=%date:~4,2% set YY=%date:~10,4% echo %MM%-%DD%-%YY%>lastrun.txt |
|
| 144. |
Solve : vbscript or powershell?? |
|
Answer» HI all, HI all, For me, Powershell is a lot easier to understand than VBScript. Plus, powershell is PROBABLY looking to replace a lot of the functions that batch/vbs stand for so newer technology is always good to learn.thanks for all responses guys |
|
| 145. |
Solve : Create a PDF File in FileMaker? |
|
Answer» I'm looking for DOS code to create a PDF in FileMaker I'm looking for DOS code to create a PDF in FileMaker C:\test>type ab.bat Code: [Select]echo off "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe" C:\test>ab.bat C:\test> marvin/bill/greg, OP says "create", not read. ACROBAT reader, does not create PDF. it just enable you to read PDFS.marvin I appreciated your help, but as ghostdog74 said I need to "create" a PDF based on a FileMaker record. Quote from: macdad- on June 25, 2010, 05:55:06 AM What version of FileMaker are you running? macdad- I am using FileMaker11, Apparently there's a bug and you cannot create PDFs in FileMaker11 to be saved on a Network server.I found out that it isn't possible to create a PDF in FileMaker from command-line.Thanks macdad- |
|
| 146. |
Solve : batch file best for repeated text entry?? |
|
Answer» I would like to use a hot key to ENTER the FOLLOWING code into a forum post message box. Would a batch file be the way to do it? If so, what is the code? |
|
| 147. |
Solve : Organizing files by filename into separate folders? |
|
Answer» Any help on this issue would be greatly appreciated. I have been running 100s of tests on a PRODUCT and the results end up in one folder. |
|
| 148. |
Solve : Any Real Tutorial for DOS/BATCH? |
|
Answer» Hello, |
|
| 149. |
Solve : Dos Print? |
|
Answer» Hi All, Why are you trying to print in DOS? Do you have custom software? True their are USB drivers for DOS that can ALLOW for Printing over USB. And I have found a DOS utility that can redirect the DOS printing from LPT to USB: http://www.dos2usb.com/ Abbarla, Is the printer you are printing to use a USB port or LPT port?Is the printer you are printing to use a USB port or LPT port? Hi I am using USB Port.. |
|
| 150. |
Solve : command prompt in WinfowsCE? |
|
Answer» how do you get a command prompt (or "DOS" window) in Windows CE 4.2, 5, and 6? |
|