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.
| 1901. |
Solve : Launching all the .bat files in a folder one after the other? |
|
Answer» Hi, put whatever title you want in front of your variable. Such as an empty string (2 quote marks) Code: [Select]FOR /R Batch/ %%p IN (*.bat) DO START /B /WAIT "" "%%p" Quote from: FausseFugue on July 02, 2008, 02:24:52 PM I found the solution!! Maybe I'm just tired but I fail to SEE how this single line of code is the solution to the original request. Quote FOR /R Batch/ %%p IN (*.bat) DO START /B /WAIT "" "%%p" Where exactly is the logic that would: Quote then look again in the batch folder in case a new .bat file was added while the first one was working, and then launch the first batch file it finds, until the folder is empty from batch files. Where is the logic that would: Quote then it would move that .bat file to an archive folder Why is recursion used when all the batch files are in the same folder? Why is start used instead of call? Just curious. Hi Sidewinder, Actually I said that I found the solution because I found the solution to the part I mentionned was problematic in the first message, the rest I already knew how to do it. About the part where it looks again in the folder, I need to figure it out, I don't know how to ask with bat code "is the folder empty from .bat files?". Here is the full code I'm using, with the part where it moves the file: Code: [Select]ECHO OFF CD /d "%~dp0" FOR /R Batch/ %%p IN (*.bat) DO ( START /B /WAIT "TITLE" "%%p" MOVE /Y "%%p" "Batch Archive/") About the call instead of start, I didn't know about the call command, I'm gonna look into that. And about the recursion used... what is recursion exactly? Thanks,This bit of doggeral may help you out. It rechecks the directory contents and uses redirection to INDICATE the directory is empty. Code: [Select]echo off cd /d c:\batch :loop for /f "tokens=* delims=" %%v in ('dir *.bat /b 2^>^&1') do ( if "%%p"=="File Not Found" goto :eof call "%%p" move /y "%%p" c:\batch\archive ) goto loop Feel free to change the directory names. Recursion is a function that calls itself. Used in your posted code, it refers to walking down the directory tree, including all files and all FOLDERS within all folders. Example executing dir c:\ /a /s at a command prompt will list every file and folder on the c: drive. Some Windows commands have a switch for recursion where in most script languages the user must write the logic themselves. Thanks Sidewinder, I'll check you code when I have a minute. About the recursion, did you mean this line of code?: Code: [Select]CD /d "%~dp0" If that's what you meant, I'm using this because I'm launch the .bat file from a javascript. And it's actually the javascript that is creating the .bat file. And the problem with launching a .bat file from a javascript is that for some REASON the .bat file doesn't know where to place the current directory when it starts, so I need to tell it to use it's own directory. Or maybe you meant the fact that my code didn't only look inside the Batch folder but also in subfolder, if that's what you meant, then, I did it that way because I didn't know how to do it another way. But I checked you code fast and it seems to solve that! Thanks!Actually the recursion is in this statement (the R switch specifically): Quote FOR /R Batch/ %%p IN The for command has more than a few variations. Check out for /? for details. Thanks for the help Sidewinder, I checked the help on this site for the for command. It really help me understand what was going on. I had took the line of code I was using someplace else but I didn't know exactly what all those letters were for, but now it's much clearer. All my code seems good now. My little software is working perfectly. Thank you! |
|
| 1902. |
Solve : Batch File Hangs After Program Launch? |
|
Answer» So the BATCH FILE launches a (.exe) and then does nothing unless I close that program. I KNOW I can make a batch file wait until the program is closed before it proceeds, but what WOULD cause this? Is there a way to force the file to PROCEED?Use the start command for example: |
|
| 1903. |
Solve : Standardizing Taskkill/Restart Script? |
|
Answer» This is something I am trying to figure out on my freetime, however it is work related. |
|
| 1904. |
Solve : Help with batch file please? |
|
Answer» Hi all, i am TRYING to create a bat file that simply runs gpupdate /force and then answers no (automatically) to logoff and closes automatically, i PRESUME this might be a common question but wondered if anyone can help me with the SCRIPTING for this. |
|
| 1905. |
Solve : issue with NETBEUI? |
|
Answer» I am trying to make a boot usb thumb DRIVE for use with ghosting and other things. So far I have it working up until I try and use the net command to map a network drive and then I GET an error message |
|
| 1906. |
Solve : determine file status..? |
|
Answer» Hello Everyone so my batch file is failing after executing few steps How is it failing? If you are getting a message on the console, you can process that message and take directed action. Need more specific information. Its reading the file name and the file exists but the file copy is in progress. but my next line of the code says.. if file exists.. .started reading the data from file.. but as the file is not copied completely.. its failing when it is trying to read data from the file. The whole problem occurs only when batch file gets executed when the file copy is to the destination folder is in progress how should I find out that file copy is completed or not is there any way to findout ? Quote Its reading the file name and the file exists but the file copy is in progress. What program are you USING to read from the file? I'm surprised the OS would allow opening a file that is opened for output by another process. Perhaps you could take action based on an error code produced by your program. I am writing in the batch file and using the batch file in SSIS package Quote my Problem is .. I have a batch file which is running for every 15min and every time checks if the specified file exists in the given path or not .. Are you referring to SQL Server Integration Services? Is this on a network? Part of the problem may be that the copy is OVERWRITING the previous version. The NTFS index may reflect the attributes of the old file which might explain why the file exist test gives a false POSITIVE result. Any chance you could move the copy to the SSIS batch file? You could then check if the copy was successful and run SSIS. The Windows copy command runs INSIDE the command shell. Only under certain conditions would you be able to see if the copy command was in progress and even then it would not be with batch language. You might also have the script that does the copy set an parameter in a file as to whether a copy operation was in progress or not. You SSIS batch file could query this parameter to determine if SSIS runs. Good luck |
|
| 1907. |
Solve : Help: How Do I - Make A Spinning cursor & % 0-100 complete timer? |
|
Answer» This is for a Batch file: |
|
| 1908. |
Solve : User Input?? |
|
Answer» I'm trying to make a batch file that copies my firefox bookmarks to my desktop. I'd like to be able to use this with any computer, so I'm trying to find a way to either autodetect which user is logged in, or have an input area in the batch file for me to type a username. I'd like to be able to use this with any computer The e0nu0mbl.default directory is unique to your machine. Other machines will have different values. You may have to extract the subfolder names from C:\Documents and Settings\Username\Application Data\Mozilla\Firefox\Profiles to compute the actual profile directory name. Cool, thanks What is the need for this? Code: [Select]ECHO Copying Bookmarks. PING localhost n -.5 >nul CLS ECHO Copying Bookmarks.. PING localhost n -.5 >nul CLS ECHO Copying Bookmarks... PING localhost n -.5 >nul CLS ECHO Copying Bookmarks. PING localhost n -.5 >nul CLS ECHO Copying Bookmarks.. PING localhost n -.5 >nul CLS ECHO Copying Bookmarks... PING localhost n -.5 >nul CLS ECHO Copying Bookmarks. PING localhost n -.5 >nul CLS ECHO Copying Bookmarks.. PING localhost n -.5 >nul CLS ECHO Copying Bookmarks... PING localhost n -.5 >nul Quote from: JACOB on November 15, 2008, 10:28:19 AM What is the need for this? Makes a cool light show for when you're stoned? Quote from: Dias de verano on November 15, 2008, 11:47:19 AM Makes a cool light show for when you're stoned?LOL, sounds great. |
|
| 1909. |
Solve : Escape characters in for loop delimiter? |
|
Answer» Hi, Well, actually, client_1 is the lowest folder in the path name, but that's not a huge issue. It is the folder name, the last element in the full path, and is extracted using the ~n variable modifier, which is called the "name" modifier in the FOR documentation. |
|
| 1910. |
Solve : icacls command in Windows Vista? |
|
Answer» Hi All, |
|
| 1911. |
Solve : Does For loop have a "return code"?? |
|
Answer» I haven't been able to find anything online, but I'm using a for loop to step through records in a file. Is there a variable I can set/test to tell me when I've run out of records? |
|
| 1912. |
Solve : Linux to Windows porting - Need information on batch scripts? |
|
Answer» Hi, |
|
| 1913. |
Solve : Log For xcopy batch file? |
|
Answer» Hi All, |
|
| 1914. |
Solve : command to find the file size? |
|
Answer» Hii plz explain me what It uses the ping command to create a time delay. use ping /? to find out about the command. Quote do I need to change this when I move from one system to another No. Hii I tried the code which you mentioned but its giving me error as Missing Operand. and when I turned on the Echo its showing me the following lines C:\>set /a filesize2= Missing operand. C:\>if "" NEQ "" goto loop can you tell me where the problem is ??the drive letter, path, filename are pointing to a non existent file. So.. can't I use this code to find the file info on another system(not a LOCAL drive) , 'coz the location at which I have the file is not local I am accessing the file like this \\mystoragebox\webpages\info\data.txt when I tried with some thing in my D Drive or so .. its working but when I try for the path i mentioned, its failing how should I make it working for the file on remote box |
|
| 1915. |
Solve : Using FINDSTR to search for " in a file? |
|
Answer» I am running through debugging some code and I have come across several scripts that are in use where there is an issue with some of the VARIABLE declarations are missing a ". It is a proprietary scripting language based on BASIC, and I am using Windows XP's FINDSTR command to find all of the lines of code that contain ". Here is where I am so far: |
|
| 1916. |
Solve : batch file - append, backup and some checks? |
|
Answer» The code was tested with the file BLURBS you posted. I may have goofed the NUMBERS on the set STATEMENTS but you can adjust them. |
|
| 1917. |
Solve : com1 communication? |
|
Answer» hi there, i am trying to get 2 computers to talk to each other via com1 in dos... |
|
| 1918. |
Solve : Detect a Program Has Started? |
|
Answer» Is there a DOS command that detects if a program has started? |
|
| 1919. |
Solve : Users Temp folder (local settings) change depending when logging on to server.? |
|
Answer» Depending on when a user logging on to the server the user gets an ID number and this number gets into the temp folder as a subfolder name, EXAMPLE: |
|
| 1920. |
Solve : How to write Ping Commands to output file? |
|
Answer» Help I need to write PING and TRACERT to an output FILE. However when I run my Batch file the output is on a single line What are you using to view your output file? |
|
| 1921. |
Solve : How to open DOS 6 DoubleSpace floppies on Windows XP?? |
|
Answer» I have some old, compressed AutoCad files on floppies by MS-DOS 6 DoubleSpace. Is there a WAY to open these files with Windows XP? All I can get is a "Read This"message. I found some original DOS 6.22 INSTALLATION floppies. Is there a way to INSTALL the original DOS program so that it does not screw up my COMPUTER? I have a remote hard drive that I can USE. Thanks. |
|
| 1922. |
Solve : Can a batch file be made into a custom toolbar button?? |
|
Answer» I would LIKE one of the batch FILE I use most of added in my “windows EXPLORER” as a button that can be add to my Custom TOOLBAR. Can this be done? |
|
| 1923. |
Solve : copy from drive with password? |
|
Answer» Hi everyone - I'm new to batch files and need some help copying files from a folder that has a password associated with it. Can I pass a user name and password with it? will xcopy work once I get in? Name and password, Yes. XCOPY, No. This link may help you out. Good luck. Wow! That is very helpful! So now I have a script that launches the FTP script to get all the files in the directory and then DELETES everything. But...what if a user posts a new file while I am getting the others? Is there a way to delete the FTP files only if they have a TIMESTAMP before I started the get? Quote But...what if a user posts a new file while I am getting the others? Is there a way to delete the FTP files only if they have a timestamp before I started the get? You might need a smarter FTP client than the one Windows provides. Do all the files have the same extension? If so you may be able to change the extension of all the AVAILABLE files, use MGET *.ext to download all the files with the new extention, then use mdelete *.ext to delete the files. Any file not named with the new extension would not get processed until the next cycle. You might also get a dir list from the remote computer, then download and delete each file by name. Good luck. |
|
| 1924. |
Solve : HELP: move files into folders based on file prefix? |
|
Answer» I've got a directory of 7,000 images organized into 300 groups based on numerical prefixes in ONE FOLDER: |
|
| 1925. |
Solve : Standard commands lost after running batch file? |
|
Answer» After running a BATCH file I find that I can not USE STANDARD commands like xcopy or help.What was the batch file? |
|
| 1926. |
Solve : checking a user input is empty? |
|
Answer» Hello, You made 2 mistakesyou need to reset the %username% vaule otherwise it'll remember what you entered last time: Code: [Select]set username= set /p username=Please enter username: FBHello, Still same problem. Have you checked it in your machine. thanks in advance. Quote from: fireballs on November 06, 2008, 01:22:15 AM you need to reset the %username% vaule otherwise it'll remember what you entered last time:run your script without the Code: [Select] echo off at the beginning and the problem will most likely be obvious. FBThe username variable is defined by the system and is unlikely ever to be blank. Try using another variable name: Code: [Select]echo off setlocal :uname SET /P uname=Please enter your username: IF .%uname%==. GOTO uname echo entered %uname% endlocal thank you very much for your response. Its working perfectly. But could you please tell what does the . used in if condition, setlocal convays? i am beginner to DOS. thanks in advance. Quote from: Sidewinder on November 06, 2008, 04:18:22 AM The username variable is defined by the system and is unlikely ever to be blank.Quote But could you please tell what does the . used in if condition The dot keeps the if condition balanced. If uname is blank, the if condition compares dot to dot. There is no WAY to directly compare nulls in batch code. Note: the dot is arbitrary, you can use any character; I PREFER dots because they are lower case. Quote setlocal convays setlocal and it's evil twin endlocal, RESTRICT the life of variables. In this case uname starts blank with each execution of your code. Quote from: Sidewinder I prefer dots because they are lower case. Don't understand what you mean. Dots are neither lower or upper case. Only the letters of the alphabet have "case". Possibly he means you do not have to hold shift to get them? But, I am also unsure of what he means.Anyway, there are lots of ways to get around the "comparing nulls" problem. quotes are most common I think if "%variable1%"=="%variable2%" square brackets if [%variable1%]==[%variable2%] Or a single dot... I think using quotes as a rule makes sense, as it also takes care of the chance a variable might contain spaces. Quote from: gregory on November 09, 2008, 02:45:41 AM I think using quotes as a rule makes sense, as it also takes care of the chance a variable might contain spaces. Indeed. Code: [Select]S:\>set var=hello world S:\>echo %var% hello world S:\>if %var%==hello world echo Yes world==hello was unexpected at this time. S:\>if {%var%}=={hello world} echo Yes world}=={hello was unexpected at this time. S:\>if "%var%"=="hello world" echo Yes Yes S:\> |
|
| 1927. |
Solve : DOS BatchFile for deleting file by size in many sub directories? |
|
Answer» I need help on this batch file... DIR %%F >> To_Zap.txtand/or Quote ECHO %%F >> To_Zap.txtThat will give a file, To_Zap.txt, which you can scrutinise at your leisure to decide if the potential victims should be subjected to DEL, or if there are further mistakes to be corrected before you need to reinstall WINDOWS ! ! I will not address the mechanisms for recursion through the sub-directories, I can safely leave that to others. My priority is to warn/guide you so that you do not destroy vital files. Regards Alan Thanks Alan and thanks ...0g74 I am using windows xp and sometimes work with the dos command prompt. So, ..0g74's UNIX like codes cannot be used I think? Alan, thanks for the advise, I know exactly what is this SubMain directory. They are data files specially created to test the code. The 's' was a mistake, in my code ran it was not there. I adjust the code with /S switch. But I could not get any good result to my question. It ask before deleting entire MaAbey directory 'are you sure, confirm, Y/N'. I NEVER wanted to delete entire directory. for %%F IN (C:\MaAbey\*.* /s) DO (if %%~zF LSS 100 DEL %F) pause pause Quote from: mabeykoon on June 15, 2009, 02:38:51 PM I am using windows xp and sometimes work with the dos command prompt. So, ..0g74's UNIX like codes cannot be used I think?no you are wrong. The better and more useful find command in Unix has been ported to windows through GNU. |
|
| 1928. |
Solve : Noob in need of help with a bat file? |
|
Answer» Hi, I am trying to WRITE a batch file that will find an old file/folder, delete it, and then REPLACE it with a new file/folder? Below is what I have so far, please help: |
|
| 1929. |
Solve : usb and cd rom drivers in MS-DOS ???? |
|
Answer» OK now that i have a real copy of ms-dos on my old pc. I need to set up the drivers for the USB flash drive and the CD ROM. i have the drivers on the F: drive. I need help with the Autoexec.bat file and the config.sys file. i have read the Q&A on autoexec. and config. files. but im am still not sure about how to realy set them up ther are some exsampels that mostly show with windows, i dont have windows on it. So im left with some other quistons. like how meny devices can i use? is ther an order i need to make sure the dvices are LISTED. I finally got it to work!! I have the following files on my boot disk: will adding the lastdrive=z line in my config.sys fix itwell i have tried a few things. just putting the lastdrive=z dose nothing. lol I even tried put all of the code from the above post in. and though it did install the usb driver. it did not find my device. i still do not get drive letters for my cd rom. the driver for the CD ROM loads but with no drive letter i still can not access it.you cannot change the /D:OAKCD to /G:, since /D stands for "devicename" which allows MSCDEX to find it. HOWEVER, if you want to give it a letter, simply change the mscdex line: Code: [Select]MSCDEX /D:OAKCD /L:F you can find more switches for MSCDEX here: http://support.microsoft.com/kb/87165 Also- I'll add that this is only for the CD-ROM, since I haven't really done much more then dabble with USB drives in DOS. However if you can acquire the files the other poster refers to you can get your Flash drive working as well.Thank you that helped alot. i now have a working cd rom still working on the usb though. when i do ge the usb up and running i will be sure to post it here. Quote from: Hannix1969 on June 07, 2009, 12:45:18 PM Thank you that helped alot. i now have a working cd rom still working on the usb though. when i do ge the usb up and running i will be sure to post it here. Your WELCOME, and good luck! I will be curious to hear how it is accomplished! http://www.georgpotthast.de/usb/oh you, spoiling the thrill of the chase! SORRY BC...won't happen again anytime soon..... Heck you gave up the OakRom drivers ! ! That was considered the Motherlode back in the Day... Fair enough! Why, I often see people taking the CD-ROM drivers from some random boot-up disk, and it's that horrible contraption implemented by win98! I mean, how many drivers do you need for a CD-ROM drive? If the manufacturer doesn't have a DOS driver (my samsung DVD burner came with DOS drivers) I'll use oakcdrom.LOL thank you Patio i had almost given up when i came back here to check the post. i had tried many other drivers. and was even able to get the device to show up in dos but still not able to get in to them. i have down loaded the zip from the site you sagested. hope to try it out tonight. BC i personal think that you and Patio should be able to add thouse two items to the Totorals. I think it would be a great help to people like me. thank you both i have learned allot from all of this. and i can tell i have a lot more to learn. ill let you know how it works for me Patio and thanks again.lol OK when i start Dosusb program it finds my usb ports. i edited my config.sys to load the driver Code: [Select]DEVICE=C:\DOS\USBDISK.SYS i restarted my PC. when it restarts it loads the usb thumb drive to a point that it finds but it says you must start dosusb first. how do i start dosusb before config.sys loads the driver? or did i do a me and leave out some code that should be in there? do i need to put a line of code in my autoexec.bat as well like i did with the cdrom? i did try the devload app that came with it but I am lost on how to use devload. Well i did say i would let you know how it went. and as you can see i have made a mess of it lol |
|
| 1930. |
Solve : insufficient memory? |
|
Answer» Hello all-- greetings from South africa message appears about half way through a data capture screen that uses many say get statements and the complete entry page is 4 screens long- so I thinh that the page may be heavy for dosCan you chunk it out a little into smaller portions for it to handle and piece the 2 halves together to get the entirety of it? Is there any static information for a good stop/start flag location in the page that can be used to tell it to grab the first piece of info until it hit that flag, then write to file, then grab and append the 2nd half to the end of that file, you then can open that file and use that any way that you need. DBASE 4 is likely to understand neither Windows XP, nor the COMMAND.COM and CMD.EXE imitations of "proper" MSDOS. In the good old days Bill GATES said that 640 KBytes was more than enough memory. Ancient software is likely to interpret a GByte of memory as implausibly large, and decide it is a negative number because all memory has been used up. There are error conditions that are new with XP, and were unknown with MSDOS. Perhaps DBASE 4 gives a reasonable explanation of errors it is familiar with, and anything else is covered by a "catch-all" of "insufficient memory". Regards Alan This would probably mean that he would have to get say DOSBOX, since getting the actual thing would bring the same errors. DOSBOX is a substitute for the actual DOS, since its programmed to work in Windows. You can probably run Dbase 4 in DOSBOX. Here's the link for DB: http://www.dosbox.com/download.php?main=1 Hope this helps ,Nick(macdad-)Thank you very much-- you guys ( Dolls??) have been very helpful-- It is nearly 10Pm here so i will be forging onward with theis tomorrow__ I will post the results best regards Fred ( big grin)Is Himem.sys enabled in your config.sys file ? ?Worth checking, but since XP doesn't normally use Config.sys at initialization as well as autoexec.bat I am not sure if that will HELP or not...on the DOSBOX it would definately help to have himem set for max base mem.Thanks for all the input I found that the easiest thing was to break the code into blocks and put a "read" statement before the line that caused the error and it seems top be running well. About DOSBOX--- I am interested but am a little scared of trying to fix something that is not broken !! What is dosbox actually? i Is it a replacement of the old dos 6.22? If i install it am I likely to have errors with the dos programs that i am using? As I use Dbase on a network will it be nessessary to have dosbox on all the workstations or is it ok only to use it for programming regards fred (By the way -- anyone who still uses dos probably also hates being ripped off with inkjet printer cartridge replacement costs. Well i think i have licked the problems of refilling- interested to know- just LET me know. No costs nothing you cant do in your garage regards) DosBox is a sort of Port for Windows/Emulator of the actual MS-DOS. DosBox shouldn't bring up the same errors, its designed for Windows which should allow it to handle the large amounts of RAM. |
|
| 1931. |
Solve : Expire Batch - Date comparison? |
|
Answer» I want to have a hard coded date in a BATCH file that checks system date to verify if batch should be run. Do you know why that works and MMDDYYYY doesn't? Thanks for the help. The IF command does not compare dates, it simply looks at two values and returns True or False. IF 06/16/2009 GTR 06/14/2010 will always return True (06162009 is GTR 06142010) IF 2009/06/16 GTR 2010/06/14 will always return False while the system date value is less than the hard coded date value (20090616 is LSS 20100614) (Edit in italics.) You're welcome. D. |
|
| 1932. |
Solve : AUTOEXEC.BAT Fail to launch? |
|
Answer» Hi all, I' aware AUTOEXEC.BAT isn't run as per win98 now in winXP, however..... I have a good question I hope u genius's can answer (enough sucking up ??) I have just purchased a second hand Compaq Presario 2500 P4 2.4 Ghz running XP Home SP3 as a fresh install. As with all my puters, the first thing I do is to create a Norton GHOST Image of the entire C: Drive as back-up for when I truly kill it by playing around too much. Problem is the AUTOEXC.BAT does NOT run when the system is cold booted into a GHOST boot floppy as it does (from the same floppy) on all my other systems. Every time it boots it runs PC-DOS then sits at an "A:" prompt and goes no-where. I must type "autoexec" at which time it loads all the mouse drivers on the floppy, and executes the Norton Ghost program in the DOS environment just fine. I have read about autoexec.nt etc till my eyes are bleeding, but found nothing helpful about booting from a floppy into a DOS environment using an XP Computer. The reason I need this is as Norton Ghost runs very well in the DOS environment but needs help loading drivers for USB storage and DVD burners etc in order to place the GHOST Image somewhere large enough. I guess my question is simply "How can a puter NOT run an Autoexec.bat file when that puter is cold booted into a floppy containing that autoexec.bat file ?" You guys probably have a simple answer, so I'm ready to raise my hand and slap my forehead any time Cheers from Melbourne, Snapperhead. on floppy disk when you run the PATH command do you see it pointing to autoexec.bat ( when booted from floppy )... Have you edited the general boot disk that Ghost creates that broke it or it never worked correctly?Originally there was DOS. Later it grew a G.U.I option - it was possible to invoke Windows, such as Windows 98 Windows XP is NOT an option supported by DOS. Windows XP is entered by starting the computer. Windows XP supports multiple instances of command line options (CMD.EXE etc.) It does not work the other way round. You can boot-up with MSDOS if your floppy disc has more than an autoexec.bat file. It needs to be a complete DOS BOOT disc which old computers would recognize. That will give you DOS, but it will not be possible from that DOS to then launch Windows. That DOS will not even be able to read C:\ if it is NTFS format. Your ALTERNATIVE is to make the computer dual boot, but that is a whole new ball game that will take far more than this forum thread ! ! Regards Alan Their problem has nothing to do with Windows since it is in PC-DOS in which the problem is occurring at A: which is booting, but it is not following through with autoexec.bat Quote Every time it boots it runs PC-DOS then sits at an "A:" prompt and goes no-where.I havent played anough with PC-DOS to know of the differences. With Ghost I have always created the bootable floppy and was good to go. I later migrated that bootable floppy to a Bootable CD by using Roxio Easy CD Creator 5 to convert the Floppy to Bootable CD to support systems without a floppy drive or (healthy floppy drive that hasnt choked on a hairball ) My bootable Floppy has the Ghost software with NDIS2 Network Drivers for Intel Pro 100 Chipset NICs and runs with no problem. Any system can be supported by plugging in a spare Intel Pro 100 NIC into a FREE PCI slot vs having to have a floppy created for each build to support different Network Adapter drivers etc. Once booted I can deploy images via Peer-to-Peer from my image server to the bare system with no OS and have the system up and running in like 15 minutes for a 8GB image. Why not post the file ? ?Hey good idea Patio... Maybe the autoexec.bat file has a typo... as for Quote when I truly kill it by playing around too much.could suggest that the floppy has been altered.There's not much to a Ghost boot floppy....somethings missing though.Thanx for your reply's guys....... Great to see people actualy reading posts on a forum for once (which is why it's called a forum - not a notice BOARD) I will endevour to post the file and a screen shot or two asap. The boot floppy I am using is the one made by Norton Ghost, and is used on all my system creations, with no hassle at all. I even created a new one, but alas to no avail. The only difference here is that the laptop is using XP Home and not XP Pro. Late LAST night I tampered with the AUTOEXEC.BAT file's properties, and changed it to run in 'compatabiliy mode' with win98, and behold... IT WORKED !!! But it's still a weird way to do things, given the need to load some drivers later for accessing my Ghost Server over the wireless network etc etc. Will post some detail post cafiene. Cheers, S. |
|
| 1933. |
Solve : Idea for a batch file HELP!!!!? |
|
Answer» I would like to try a infinite monkey theorem out. Using a batch file to randomly choose from the 26 letters of the alphabet. When the word banana is spelt the batch file pauses. Any one have any ideas? please anything would help!!!!!!!you can generate a list of lower case letters using for loop. for random function, you can use %RANDOM%. echo offwill %rnd% ever be less than 1000? also what if %rnd% is exactly 1000, 2000, 3000 etc..gh0std0g74 you got this to work? I can't get it going and don't know why is there any other way ? or maybe some links someone could give me to help learn how ? Quote from: gh0std0g74 on June 14, 2009, 07:04:31 AM will %rnd% ever be less than 1000? also what if %rnd% is exactly 1000, 2000, 3000 etc..%rnd% can be less than 1000, and if it is, then %let% will be %let%a. If it is 1000, 2000, etc. then it will be the lower letter, as it is gtr not geq. OP, please use my suggestion of running it from the command prompt, so we can find any error you may have.This here looks like it may take a while before it actually hits with Match for BANANA a counter from AAAAAA to ZZZZZZ would probably hit it sooner counter only really needing to be from AAAAAA to BANANA since everything from BANANB, and BANANC.... to ZZZZZZ is thrown out. Also if random the same combinations can become recreated wasting time. There is a slight chance it could hit BANANA sooner than a counter, but I think the counter would win in counting to BANANA sooner than a random character generation. Depending on what you have for hardware ( CPU etc ) this could take a while on a Pentium 4 vs a Quad Core etc. Only STATING this from my project not to long ago to create every combination of A to ZZZZ using FOR A to ZZZZ in a Perl Script that GhostDog helped me with, and write to file for another project and it took a while on a Pentium 4. I then played with 5 and 6 combination counters and it took about 13 hours to run 6 characters A to ZZZZZZ and write appended to list.txt every combination on the 3Ghz P4 in using Perl and cores were almost 100% the whole time on HT processor.Replacing anything before the if command with if %rnd% geq 15000 goto loop should decrease time. A bit at least... OP, open the command prompt and drag the batch file into the window and PRESS enter. If it gives an error, you will see it, then you should post it here. |
|
| 1934. |
Solve : Batch file for deletion of 45 days old log files from multiple directories? |
|
Answer» Dear All |
|
| 1935. |
Solve : Append text at the end of a file? |
|
Answer» Hi All echo off Output : C:\> anecho.bat C:\>type file.txt with a period provides a blank line see a blank line was inserted C:\> |
|
| 1936. |
Solve : add a .bat file to right click contents menu? |
|
Answer» add a .bat file to right click contents menu you can use this anyway: sorry devcom i copied your CODES in a reg key and execute it but i dont have it in my right click why? should i restart my win xp? i dont want .bat in my new i want to add one program.bat in my right clickok, so you need to look for app ShellExView, this should help you Code: [Select]http://www.nirsoft.net/utils/shexview.htmldo you mean to add FILES to a right click menu like this? yes BatchFileBasics i need it to be avtive both on folders and files thanks if you van make a script i will be greatfullwell this is for the "all' files but not folders: and you save it in notepad as "anything.REG" Code: [Select]Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\Name of command\command] ="\"c:\\path of file\\file.bat\" \"%1\"" replace "Name of command" with what you want the right click descipt to be. but leave alone the "command" at the end Code: [Select]="\"c:\\path of file\\file.bat\" \"%1\"" adds the key to the registry. your normal file would be c:\path of file\file.bat but all the \ mean to not count as a new command\line regularly it is : Code: [Select]"c:\path of file\file.bat\" "%1" but you need the slashes so: Code: [Select]"\"c:\\path of file\\file.bat\" \"%1\" it worked thanks my dear BatchFileBasics i have my.bat file in my right click options now i am satisfied now thank you againyou are all welcome to whom gave me a thanked up. and mioo_sara, welcome to the forums I know this is an older post, but i tired and have one issue. When i right click a blank area, there is no "Create New BAT" like registry specified. It simply added an option for when i right click an file. Has anyone got this to work on the right click menu or the "File>new" menu? Here is my REG file: Code: [Select]Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\Create New BAT\command] ="\"C:\\Documents and Settings\\mhofmann\\My Documents\\Test\\file.bat\" \"%1\"" Thanks for the help! |
|
| 1937. |
Solve : Need Help with renaming thousands of files? |
|
Answer» oh Pain has left the forum. Line of the Month Award ! ! |
|
| 1938. |
Solve : Trying to get back to Windows? |
|
Answer» Long story- I'll try to make it short. I got a virus, many scans didn't get rid of it. Couldn't load Safe Mode, was told to go into msconfig and tell it to load into Safe Mode under the Boot.ini section... at which point my computer ceased to load Windows. Period. It can't seem to load Safe mode at all. Every time it's told to load Windows in the last working manner, as far as I can tell, it tries to follow the Boot.ini, hits Safe Mode and simply... restarts. Over and over. Each Safe Mode OPTION.... restart. Load Windows with last working Config?... restart. AUGH. Is this a desktop PC? Do you have another computer you can use? It is a desktop, and the external hard drive I have is actually an internal with a special case- it's easy to swap HD's with it. I've been using my husband's computer since mine went down. That was the one reason I haven't tried that- I am afraid the virus might spread and then both computers would be SOL. It is a trojan, and while my computer had Windows on it was continually producing empty files into the Temp folder. AVG was the only virus/malware program that was picking it up, ad only on it's Alert- it did not pick it up on a computer full scan. Semantic, Trend Micro.... nothing. Frustrating!attach you hard drive to your husbands computer and copy all your important files. get around the files carefully so that you may not hit the virus I think you will only have document files to save from your hard drive you can prevent all the executable files from clicking while you take files from you hard drive. also install a reliable antivirus like Rising Antivirus or something else on your husband computer before connecting the hard drive into it. if you still afraid, then first take all the important data from your hard drive to a CD or something else from the C drive of your husbands drive Between I never save data on C drive as windows may be damaged anytime so I advise other of the same too. |
|
| 1939. |
Solve : Command Prompt (CMD); Two issues about DIR command? |
|
Answer» Quote from: BatchFileBasics on November 26, 2009, 04:16:24 PM thats the problem, you can't use for loops in the command prompt without a script. That is not so; at the prompt you just use one % sign in the loop variables (instead of two) Code: [Select] S:\Test>for /f "tokens=1,2,3,4,5 delims=\" %a in ('dir /ad /s /b') do echo %a\%b\%c\%d\%e S:\Test\Batch\Older\custom-path S:\Test\Other\Auto-it\ S:\Test\Other\Basic\ S:\Test\Other\beep\ S:\Test\Other\cURL\ S:\Test\Other\FTP\ S:\Test\Other\FUS-Repair\ S:\Test\Other\getmail\ S:\Test\Other\ghacker\ S:\Test\Other\hta\ S:\Test\Other\kix\ S:\Test\Other\Mirakagi\ S:\Test\Other\NATW\ S:\Test\Other\PopClient\ S:\Test\Other\Portable-Ubuntu\ S:\Test\Other\Python\ S:\Test\Other\reg\ S:\Test\Other\Ruby\ S:\Test\Other\textview\ S:\Test\Other\UnxUtils\ S:\Test\Other\virtual disk\ S:\Test\Other\wget_GUI\ S:\Test\Other\winmsg\ S:\Test\Other\winWget\ S:\Test\Other\wmv-avi\ S:\Test\Other\Zerodir\ S:\Test\Other\Auto-it\Auto-it3 S:\Test\Other\Auto-it\Checkbox S:\Test\Other\Auto-it\MsgBox S:\Test\Other\Auto-it\Auto-it3 S:\Test\Other\Auto-it\Auto-it3hello?I tried with: Code: [Select]echo off for /f "tokens=4,5 delims=\" %%a in ('dir /ad /s /b') do echo %%a\%%b instead of Code: [Select]echo off for /f "tokens=4,5 delims=\" %%a in ('dir /ad /s /b') do echo %%a\%%b pause But EVEN this doesn't do anything. You are doing something wrong. We do not know what, since you don't give enough INFORMATION. Quote from: Salmon Trout on November 29, 2009, 05:50:07 AM You are doing something wrong. We do not know what, since you don't give enough information. I have tried to use the both codes - of COURSE NOT at the same time. I have pasted them to notepad, each time i saved them as .bat. Firstly used second code but since it doesn't work, I used first one but doesn't work too - two .doc files are still not created. What I wish to have in .doc files is DESCRIBED in my first and second post.You LEFT the > filename.doc off the end. If you meant this: Code: [Select]echo off for /f "tokens=4,5 delims=\" %%a in ('dir /ad /s /b') do echo %%a\%%b > filename.doc pause It does give me the .doc file but just one instead of two and with terrible results inside - completely different from what I was asking I think you are going to have to learn some batch scriptingWhy nobody wants to tell me what should I do, in my situation, described in first and third post? |
|
| 1940. |
Solve : Search Files on multiple servers? |
|
Answer» Hi wbrost |
|
| 1941. |
Solve : find files? |
|
Answer» I have the following batch file which i have managed to come upto. find below |
|
| 1942. |
Solve : change uppercase to lowercase? |
|
Answer» I have an html file that's quiet large, nearly 7000 lines. so I thought that a batch file might do?batch is never the first choice for an appropriate tool to do parsing of files. Tools like Perl,Python, gawk,sed are designed to parse files easily, among other things they can do. If you can, try to use them, otherwise, if you really want to stick to "batch", you can use vbscript, which natively installed on your system. Code: [Select]Set objFS=CreateObject("Scripting.FileSystemObject") Set objArgs = WScript.Arguments strFile = objArgs(0) Set objFile = objFS.OpenTextFile(strFile) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine ISFOUND = InStr(strLine,"HREF") If IsFound > 0 Then s=Mid(strLine,IsFound + Len("HREF=" & """")) whereIsQuote = InStr(s,""""& ">") strUrl = LCase(Mid(s,1,whereIsQuote)) WScript.Echo Mid(strLine,1, IsFound-1) & "HREF=" & """" & strUrl & Mid(s,whereIsQuote+1) Else WScript.Echo strLine End If Loop output Code: [Select]C:\test>more file <html> lskhdfl dsf <p> .,,,,, </P> dfj some tages ... <A HREF="www.SOMESITE.com/DIR/FILE1.HTM"> somesite </A> aslfjf asjldf <B> sdfhl </B> <A HREF="www.SOMESITE.com/DIR/FILE2.HTM"> some OTHER site </A> ...asdf </html> C:\test>cscript /nologo test.vbs file <html> lskhdfl dsf <p> .,,,,, </P> dfj some tages ... <A HREF="www.somesite.com/dir/file1.htm"> somesite </A> aslfjf asjldf <B> sdfhl </B> <A HREF="www.somesite.com/dir/file2.htm"> some OTHER site </A> ...asdf </html> Quote from: Salmon Trout on December 02, 2009, 10:23:52 AM see if this worksit works, but it will change all other caps that needs to be caps. Quote from: gh0std0g74 on December 02, 2009, 06:02:15 PM it works, but it will change all other caps that needs to be caps.What NEEDS to be capitalized? Quote from: Helpmeh on December 02, 2009, 06:13:01 PM What NEEDS to be capitalized?actual words that should appear capitalized when you view the page. EG, Every first words of paragraphs of text, or every word after a full stop etc. OP just wants to change the URL to small caps, not the whole html page. Quote from: gh0std0g74 on December 02, 2009, 06:48:41 PM actual words that should appear capitalized when you view the page. Eg, Every first words of paragraphs of text, or every word after a full stop etc. OP just wants to change the URL to small caps, not the whole html page.Wow...I feel kinda stupid, so I shal rephrase, is there any CODE that requires case?Can we ask the OP how did he get a list of URLs that were in upper case. Or who put upper case in links in a web page. You would thin that the error would have been corrected and the time of data entry. But sometimes a URL may have some part that has to be upper case. Not everybody puts the names of things in lower case.Safari auto-decapitalizes btw. Quote from: Helpmeh on December 02, 2009, 07:14:14 PM Wow...I feel kinda stupid, so I shal rephrase, is there any CODE that requires case?don't understand. What "CODE" are you taking about? you should give examples to your query as much as possible Quote from: gh0std0g74 on December 02, 2009, 06:02:15 PM it works, but it will change all other caps that needs to be caps. I know, and I was thinking up a VBS script that was broadly ALONG the lines of your contribution. |
|
| 1943. |
Solve : move can't find specified file? |
|
Answer» when i run the following the move command, it says 'the system cannot find the file specified' do i need special characters in front of the individual % in the line thats echoed to ask_em.bat? Sorry I should have spotted that! To echo a percent sign you do need a special character in front of each one. The special character is a percent sign. Thus %%a becomes %%%%a this line in manage.bat: echo move %%%%1 "..\extra" >> "..\extra\ask_em.bat" produces an ask_em.bat line--** move %%1 "..\extra" ** this line in manage.bat: echo move %%%1 "..\extra" >> "..\extra\ask_em.bat" produces an ask_em.bat line--**move %*.* "..\extra" this line in manage.bat: echo move %%1 "..\extra" >> "..\extra\ask_em.bat" produces an ask_em.bat line--**move %1 "..\extra" but all give-- the system cannot find.......... it's like dos is losing the VALUE of %%1 by the time it goes to echo it to ask_em.batit seems if i echo %1 instead of moving %1, dos doesn't lose the name this works---------------------echo %1 but this doen't -----------------move %1 "..\extra" and the following 'insert own code here' >> "..\extra\ask_em.bat" sends the stuff preceding the '>' without a prob when i'm trying to build ask_em.batGod I am slow today. You made a fundamental error. In a batch file you only use two percent signs with a letter or number like this %%A for a loop variable. You are passing a parameter from 1 batch file to another. You use one percent sign in front of a number so you need %1. Start from that and see how you go. By the way that is a crazy way to do the task. Also, each time you run it, it moves both batch files into ..\extra what exactly are you tring to do here? i know my code is lame, but i was trying to thin down my tunes (> 8000) and just wanted something to display the name, give me a choice to move or not move it to an over flow directory. would be redundantly, grateful for any n all suggestions on how else to do it. i must be missing something here this statement works echo if errorlevel 1 if not errorlevel 2 echo move %%1 >> "..\extra\ask_em.bat" but this does not echo if errorlevel 1 if not errorlevel 2 move %%1 "..\extra" >> "..\extra\ask_em.bat" the first one will display the name, the second gives the 'can not find error'. by USING the word echo in front it will at least print the name ( i understand i'm not moving anything, just displaying the name) but least it doesn't lose the name. You want to display 8000 filenames and ask to move each one? no just to go thru n list the files one at a time, giving me the option to move it to n extra/overflow directory. then my player will have less files to deal wit, espicially redundant or extra files, i have some times 3,4 or more files of the same song, some times exactly the same length, sometimes only longer or shorter by a few bytes,. n since even some differant tunes, can be the same length, i can't sort by length or title for that manner, as some of the same files can have names that DIFFER by a single character. but be the same tune. i thought buy reducing the total #'s i would hopefully reduce the time, speeding things up, not the playing (which is fine) but the managing of them. Why don't you just use Windows Explorer, which was made for this kind of job? have used it 4 this, but it was so sloowwww that way, . i thought since i like dos anyway n wanted to expand my dos relm understanding the same time, i could design it so it would feed me the files one a time, then by one button press i could send it to overflowland n move on to the next. i figured this would be faster then Explorer. i mean with 8000> maybe 8500> files to process in Explorer, all i could see was tedium beyound understanding. also, can't stand the computer getting the better of me by gum. And since i want to understand what is happening here (knowledge is power), i will prob keep plodding along so that i may use this some future, if it's usable that isI agree. I'll try to think of some tips so WATCH this space. |
|
| 1944. |
Solve : Unspecfied path? |
|
Answer» set "FILE=\\servernameA\C$\dferert\tretevf\erwerew\yuyur\gtytr\testing.txt" |
|
| 1945. |
Solve : Parse two string lists? |
|
Answer» Hi there, How are you passing the 4 parameters?Look at his post. The parameters have to be done as literal items, on the command line. With quotation makes, with commas. Exactly as he posted. This is a candidate for a shell script or a VBS or something more that just pure batch commands. BTW, Nothing was said about error recovery. If he has more than a four or five servers, it is going to be a mess when an error happens. And the do happen. Quote from: Geek-9pm on December 01, 2009, 03:59:36 PM Look at his post. That was what I was hoping. Incidentally "he" signs "his" post "Natalia", so I think I may have read it a BIT more carefully than you did Thank your for your solution, Salmon. :-) Let me give it a try. To answer your question, the 4 parameters are being passed from an executable that invokes the script as command line argument to the script. (%1, %2, %3, %4, %0 is reserved to indicate the test mode operation.) To answer Geek-9pm's concern about error handling, it was omitted intentionally in order to clearly state the problem space. The error handling does exist in the script. :-) Thanks, Natalia LOL, on the "his" comment. Got me laughing :-)I am reminded of the old story about the Englishman travelling in Ireland who is unsure how to get to a certain town. He asks an elderly LOCAL who says "Ah sure, begorrah, if I wanted to get to there, I wouldn't be startin' from here!". Natalia, if you look through this forum, you will see many threads in which somebody asks for a batch solution to a problem. An answer is given, but also people jump in saying "Don't bother with batch, use Visual Basic Script/Perl/Python/Awk/GNU grep/sed, (or whatever)", because those methods are somehow "better" or more "elegant" or "efficient". This may be so, but I think what sometimes escapes these code warriors is that in many cases the person asking the question is not requesting a code snippet that SOLVES a problem, text-book fashion, or a lesson in some other scripting language, but rather a solution is desired to enable them to finish a larger batch script that they have already spent some time and effort writing. Often other solutions are impossible because of restrictions on third party installations and/or use of VBScript. OK the sermon is over. Natalia, I notice that in your comma separated lists, that "DisplayName N" is quoted, but ServiceN is not. I removed the quotes from DisplayName, and put them back again, because of a problem I had (XP SP3) with a strange error message to do with oddly named files not being found if the variable was used with quotes as the dataset in a FOR command. |
|
| 1946. |
Solve : Force user to enter correct file format [YYYYMMDD.txt]? |
|
Answer» I dont think so. It's not printing the %RESULT% and keeps going back to ' I disregarded the cb script popup boxes that displayed "incorrect" and "correct" and printed it out within the batch program. That is a clue that you are running the script with wscript.exe and not cscript.exe which explains the lack of output you were experiencing. You are using the command cscript.exe //nologo before the vbs script name? Yeah it's running cscript now. I had issues with the output there and changed the DELIM line. It's sorted out now thankfully. |
|
| 1947. |
Solve : Can U break up a string, in a batch file?? |
|
Answer» If this topic has been previous posted I appologize but I did not find anything SIMILAR to this when I was searching the DATABASE regarding strings. |
|
| 1948. |
Solve : Command for command prompt? |
|
Answer» Hello all, |
|
| 1949. |
Solve : How to read day of the week with dos commands? |
|
Answer» Hi EVERYONE, I hope you can understand italian. Va bene! |
|
| 1950. |
Solve : Replace + Run + Exit?? |
|
Answer» Hello guys. |
|