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.
| 751. |
Solve : Help in an XCOPY script? |
|
Answer» I am running this code in a batch file every 2 minutes to copy from one server to another. I need to copy specific files to a DESTINATION. The script works fine, but the problem is that it copies over and over the ones it already did. Is there a way to copy the files Im loking for, but exclude any that have all ready been copied? The destination folder is a folder that another program "looks" in constantly. when files land in this folder, the program takes them and then deletes them because they were processed. My script copies the files again, and of course the program reprocesses them because it doesnt know they were done earlier in the day. The source folder will have PDF's and XML's added all day long as patients are seen by the physician. I hope this makes sense. Here is what code I have, but i need it to only copy new files from the source: sorry...i wrote that wrong...month and day are single digits. not sure why I typed it that way.Just wondering because your original script shows a 02 for the month. So when you echo the date variable from the command prompt and lets say it is Thursday February 9th, 2012 does it output like this Thu 2/9/2012 Going to assume so because you are using a FOR Loop to PARSE the date apart. I prefer to use the leading zeros in my Regional Settings. Makes it easy to use the DATE variable in script with string parsing. Plus if you are using the date to name files it makes it real easy to sort the file name by the date when it is 20120208_Myfile.doc. Going to assume you screwed up this example as well. Quote c:\Heartlab\998821 <----patient #1I would assume that a patient should never be directly in the source directory or in a months directory. It should always be in the day directory of the month.ys your riht again. I have so much on my plate, I confuse myself. So all patients for the day go into that days folder. for the feb 10th, they would go into 2\10\xxxx1, then next patient would 2\10\xxxx2 etc. My script right now works perfect as it takes the day and copies every pdf and xml from the subfolders to the destination, then deletes the xxxxx.red.xml. Its just that the script doesnt know if it copied the files already or not. I dont know how to pipe into a file and then read it to see if its been copied. Can you show me an easy example of a script that copies c:\mike\*.pdf to d:\Mike but only copies files it HASNT copied before? The destination folder will not delete any txt documents, so we could parse into a txt and read from that. I appreciate your help. I have cracked my head on the wall with this one....im so frustrated and I know its so easy.I'm getting in on this thread, late in the game, so to SPEAK, but here's what I do. In case of a hard drive crash or Windows boot failure, I don't want to loose any of my files from "My Documents" (MS Office) or "My Files" (Word Perfect) so I wrote a batch file, using XCOPY to copy only new or changed files to my assigned storage area on a separate hard drive. With XCOPY you have a long list of switches that can be applied. One switch, /M copies a file and turns off the Archive bit so that file is NOT copied again, unless it's changed, which will reset the archive bit. Even though I have several thousand files in my source directories, only a very few files get copied on each run of the batch file, keeping my backup time to just a few seconds. Here is a SAMPLE line from my backup batch file: xcopy "C:\Documents and Settings\Alexi\My Documents\*.*" "D:\My Documents\" /s /y /H /R /M I've printed out the entire list of XCOPY switches and I suggest that anyone wanting to use this command, do likewise. If you run this command from a Command Prompt, you will get the switch list as a text file in your root directory, then you can pull it up in Notepad and print it out. XCOPY /? > C:\xcopy.txt I always prefer to use what MS gave us for free in every version of Windows, instead of installing more and more software. Adding more and more programs every time you want to do something can CREATE a real 'Quagmire'. XCOPY is just one DOS program that can save you a lot of time and effort once you learn how to use it. I can send a batch file, using XCOPY to anyone in the world, who used any version of Windows and be assured it will run as intended. Witness the batch files I've placed for download on my own web site. Good Luck, the Shadow B) Good idea Shadow. That will work perfectly. Just so you know Robocopy is native to Vista and Windows 7. XP just required that you download and install the Windows 2003 resource kit to use it. Mike, make sure you use Xcopy's other option EXCLUDE so that you don't copy the .RED.XML file as well. |
|
| 752. |
Solve : help with script running in dos? |
|
Answer» hi there i am running a .ahk file with Autohotkeys .. when i go to run the script .. this is for Vista x64 .. it changes my \ to " .. so my folder would read when you execute the script .. it requires dos to runDo you mean your AHK script launches a btach file?AutoHotKey has a complex system of character replacement in parameter strings, in particular involving quotes and backslashes. From the AutoHotKey documentation: http://www.autohotkey.com/docs/commands/_EscapeChar.htm Quote The default escape character for AutoIt v2 (.aut) scripts is backslash (\). [...] When a .aut script is auto-converted into a .ahk script, the backslash escape character (\) is globally replaced with the accent character (`). I suspect that those characters shown as double quotes by the OP are really accent/backticks. Without seeing the original script, (and maybe not even then) it will be very difficult (for me at least!) to offer much advice. Thus I recommend: 1. A thorough and careful STUDY of the AutoHotkey documentation. http://www.autohotkey.com/docs/ 2. Having done that, (OTHERWISE stand by to be flamed!) ask in one of the AutoHotkey forums, such as this one... http://www.autohotkey.com/forum/ In fact, that forum's "search" facility showed me quite a few promising looking TOPICS. Quote from: Salmon Trout on February 19, 2012, 01:00:19 PM http://www.autohotkey.com/forum/What a novel idea. A support forum for a piece of software. |
|
| 753. |
Solve : How do I write a batch file to use WinRAR to archive? |
|
Answer» Hello everybody , I'm new here I'm looking for the support of the board |
|
| 754. |
Solve : Searching for str of text in files and exportation? |
|
Answer» Greetings everyone, |
|
| 755. |
Solve : Seeking help on DOS command (SET command)? |
|
Answer» Hi All, SET STR== %%a Lose those double equals You could really shorten things up by doing this. Code: [Select]ECHO %%b |FINDSTR "^P" &&SET STR=!STR!;%%bAnother approach would be to not use the set command at all. Clear, concise and about as simple as it gets: Code: [Select]echo off setlocal for /f "tokens=1-4 delims=;" %%i in ('findstr /i "pow" inv.txt') do ( echo %%j | find /i "pow" > nul && echo %%i;%%j echo %%k | find /i "pow" > nul && echo %%i;%%k echo %%l | find /i "pow" > nul && echo %%i;%%l ) Note: Alex has two POW parameters and is therefore listed twice. Good luck. Quote from: Sidewinder on March 01, 2012, 01:03:51 PM Another approach would be to not use the set command at all. Clear, concise and about as simple as it gets:But this doesn't work for the way he wants his output. Quote But this doesn't work for the way he wants his output. Code: [Select]echo off setlocal if exist result.txt del result.txt for /f "tokens=1-4 delims=;" %%i in ('findstr /i "pow" inv.txt') do ( echo %%j | find /i "pow" > nul && echo %%i;%%j >> result.txt echo %%k | find /i "pow" > nul && echo %%i;%%k >> result.txt echo %%l | find /i "pow" > nul && echo %%i;%%l >> result.txt ) Quote from: Squashman on March 01, 2012, 09:51:34 AM You could really shorten things up by doing this. Thanks for this tip, it is sample but powerful!Hi Squashman & Sidewinder; First of all, thanks for your advice! May be I do not make my question clear enough..... I have a CSV file : - contain 100+ lines which have multi tokens (so some times it contains the key word "POW" more than once!) - the first token is an index so it must remind at the beginning of the line! - wants to show each entries like index;POW:XXXXXXXX;POW:XXXXXXXX;POW..... <- if 2rd or 3th or 4th .....found! I try to store/update the new token into the variable so it can ECHO the result at the same line. Also rewrite the code and still the %STR% is not change the way I want ====================================================================== setlocal if exist result.txt del result.txt For /F "tokens=1-8 delims=;" %%a in (inv.txt) Do ( ::Store the first token into the variable SET STR=%%a ::Test each token; if found start with "P" add it into %STR% ECHO %%b |FINDSTR "^P" &&SET STR=!STR!;%%b ECHO %%c |FINDSTR "^P" &&SET STR=!STR!;%%c ECHO %%d |FINDSTR "^P" &&SET STR=!STR!;%%d ECHO %%e |FINDSTR "^P" &&SET STR=!STR!;%%e ECHO %%f |FINDSTR "^P" &&SET STR=!STR!;%%f ECHO %%g |FINDSTR "^P" &&SET STR=!STR!;%%g ECHO %%h |FINDSTR "^P" &&SET STR=!STR!;%%h ::Output the string into the final result ECHO %STR% >> result.txt ) =================================================== After run the batch; the result.txt only contains the index :-( %Peter %Paul %Mary %John %Jerry %Alex %Alice The STR will not update and seem the SET command is not working at all..... Ok....after do some search on the delayedexpansion....all I need is add "Setlocal enabledelayedexpansion" at the beginning, and it work! Quote from: qzero on March 01, 2012, 09:27:52 PM all I need is add "Setlocal enabledelayedexpansion" at the beginning, and it work! Maybe. You need to change %STR% to !STR! everywhere inside the loop. you missed one... Quote ECHO %STR% >> result.txt Also (VERY IMPORTANT) - You must not use double-colons ( to start comments inside a loop. It will break the code. Double colons are broken labels. They are unofficial, undocumented, deprecated, not supported, bad, wrong, etc. (Yes I know they were OK to use in MS-DOS. This is not MS-DOS). Use REM. Quote - the first token is an index so it must remind at the beginning of the line! I realize I'm not smarter then a fifth grader, but I can't seem to locate the index you WROTE about. This second try is not nearly as elegant as my first but is more generic .It will scan each line for all keywords present, filtering out POW for processing. Code: [Select]echo off setlocal enabledelayedexpansion for /f "tokens=1* delims=;" %%i in (inv.txt) do ( set keyword= call :keywords %%j echo %%i!keyword! ) goto :eof :keywords if .%1==. goto :eof echo %1 | find /i "pow" > nul && set keyword=%keyword%;%1 shift goto keywords If you want to push the output into a file, add redirection to the echo STATEMENT in the for loop. Hope this works for you. |
|
| 756. |
Solve : Ping Test Bat? |
|
Answer» Im tring to make a batch file that will run a ping test. Basically, this is what I really have an Im going off memory I wanted to be able to run a batch file that opened a batch file for network testing. Is there a reason to have the batch call another batch? It would seem simpler overall to keep it all within the same file. Currently it pings the loopback address with option 1, pings an entered IP for option 2, and exits for option 3. If you would like to add more functionality to it, it shouldn't be problematic to have it all happen within the construct it is in now. Quote from: Ryuk on January 11, 2012, 10:24:49 AM If its anything other then 3 I wanted it to come back as not a vaild choice. Easy enough. This goes in between the last two lines (notice they are the top and BOTTOM lines in this snippet): Code: [Select]if "%ans%"=="3" (exit) echo Invalid Entry echo. echo Please try again pause goto Menuummm.. No sorry, that was a grammer error on my part. Quote from: Raven19528 on January 08, 2012, 05:43:50 PM What are you trying to accomplish here? You don't have this in any sort of Batch script language. Are you wanting a menu? What do you want the options to do? sadly, it doesnt work. I select each of the three options an it just exits Quote from: Ryuk on January 11, 2012, 11:34:01 AM ummm.. No sorry, that was a grammer error on my part. Quote from: Ryuk on January 21, 2012, 04:10:26 PM sadly, it doesnt work. I select each of the three options an it just exitsMaybe a spelling grammar error. Missing a closing parenthesis.I didnt build this, really I just wondered about how to get user input. Also, what would of been wrong with my code Quote from: Ryuk on January 22, 2012, 10:06:05 AM I didnt build this, really I just wondered about how to get user input. Also, what would of been wrong with my code The code you SAID at the top of the page wouldn't have worked because it isn't properly written, for example "1 Preform a self Ping Test?" would not have been displayed on screen and would have been interpreted as a command, rather than a comment. If you wanted the text to show you need to use the echo command (echo 1 Preform a self Ping Test?) as this tells Ms Dos that the following is not a command, but rather text to be printed on screen. The user input as said by Raven19528 is the "set /p ans=" part where it will set the variable "ans" to whatever the user inputs. Hope this helped.I ment to SAY his code. I can post mine but, I know it wont work an havent done anything with it since. Quote from: Squashman on January 21, 2012, 08:48:05 PM Missing a closing parenthesis. Yes I am, try this on the last few lines: Code: [Select]if "%ans%"=="2" ( set /p ip=IP: ping %ip% pause goto Menu ) if "%ans%"=="3" (exit) goto Menu Notice I missed that final closing parenthesis. Try it now and see what happens.I am able to select know. The issue still remains where it wont allow to do a LOOP back or for entered ip'sYou need to show us the exact code you are using.Im just useing what was posted by Raven |
|
| 757. |
Solve : Reinstalling windows98? |
|
Answer» I have had to format my KIDS hard drive once again!! |
|
| 758. |
Solve : Batch File to access a dbf file and get data from the last record? |
|
Answer» I need to WRITE a batch FILE that can access a .dbf file (???pclk.dbf) and get the date from the PL_Date field in this file where the pl_class='O*'. I then want to use this as a parameter to run another batch file. There will ALWAYS be at last 10 records with pl_class="O*". I need the last occurrance of this. The ???pclk.dbf file only has 3 fields PL_Date, PL_Route,PL_Class |
|
| 759. |
Solve : Simple for loop question? |
|
Answer» Hey all. This one seems like it should be simple... I have a SCRIPT containing for %%X in %COM_LIST% do ( Also that should probably be for %%X in (%COM_LIST%) do ( echo Working on file - %%X... ) |
|
| 760. |
Solve : Need batch file help? |
|
Answer» I want to make a BATCH file. |
|
| 761. |
Solve : Copy registry file to another computer and run it or...? |
|
Answer» Hey guys, I want to know if it is possible to copy a registry file from one machine to another(both with admin RIGHTS) and then run it afterwards. If not, then can you do the REG ADD command from one machine to another? Any response would be nice EVEN if you say I don't know, but thanks anyways. Hey guys, I want to know if it is possible to copy a registry file from one machine to another(both with admin rights) and then run it afterwards. You can just use remote registry: http://www.techrepublic.com/article/remote-registry-administration-in-windows-xp-professional/5173421 You could copy it into the startup folder if it's shared.Thank you for giving me that link, it is not exactly what I am looking for. I would like to use the Command Prompt or a Batch file. Yes, I could copy it to the startup folder, but I would like to run it right away. I guess I was not specific enough, sorry about that. I don't really think that is possible unless you had VNC to that computer or something, the main reason is for security. You could copy to the start-up folder and then do a remote restart. shutdown /r -m \\xxx.xxx.xxx.xxx Replace xxx.xxx.xxx.xxx with the IP address or computer name of the remote machine.Thank you for that response again! I did find an alternative though. Code: [Select]echo off color 0a net view echo. set /p b=Type the computer name you are modifying: echo. set /p c=Type the homepage url you are changing: cls set /p d=Are you sure you want to change %b% homepage? [Y/N]: if /i %d%==n goto a cls regini [-m %b%] REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MAIN" /V "START PAGE" /D "%c%" /F pause >nul goto a |
|
| 762. |
Solve : Check for AVG, if it's not there, then install? |
|
Answer» Trying to create a batch file that will do the following? |
|
| 763. |
Solve : syntax error? |
|
Answer» Hello, D:\bat>if "%red2:~0,1%” =="1" set a=1Code: [Select]if "%red1:~0,1%" =="1" set a=1The above works fine. What are you trying to do? My vision is very poor, but I can see the PROBLEM. Is this a quiz? Quote from: Geek-9pm on March 13, 2012, 12:28:40 AM Isit not obvious? What is difference in the two lines of code?As I said in the PM, you used EXTENDED ASCII code. Quote from: Geek-9pm on March 13, 2012, 12:28:40 AM Isit not obvious?I am writing a questionare to fill out a txt file in a certain format. this line is to make sure that the imput for red2 =## and not a bunch of letters and no, I'm on a FIRST robotics team, and my friend wanted this for his php server. Quote from: Geek-9pm on March 13, 2012, 10:02:34 AM As I said in the PM, you used extended ASCII code.Not sure what you mean by this. Quote Not sure what you mean by this. One of the quotes chars is not the right one. In the first ASCII set there is only one; it looks like this: " Most keyboards will not generate chars beyond code 127. And such chars from 128 up has to come from the on-screen keyboard. Or some word process editors use the emended pair. They look like this: “ ” I can force those codes by holing the alt key and hitting 223 or 224 on the numeric pad. (Hard to do on a laptop, takes 3 fingers.) This link below is for reference for all that wish to dig deeper into what 'extended ASCII' means in the jargon. http://www.ascii-code.com/ Moral: don't use strange chars in a batch file. if "%red2:~0,1%” =="1" set a=1 ^ | don't use smart quotes Quote from: Salmon Trout on March 13, 2012, 12:43:12 PM
MIND = blown thanks guys |
|
| 764. |
Solve : Commands will run in dos window, but not in bat file? |
|
Answer» I'm trying to execute a dos batch file with the following commands: When I put them into a single bat file, however, they don't work. Don't work? How? (In what way don't they work? With what symptoms/messages etc?) I've only put them in batch files with the hyts_std executable by itself in one file and the trajplot and ascii2shp in the other batch file. The hyts_std returns the default request for keyboard input. The other two executables simply flash a dos window open and shut (to quickly to see anything written)Launch the batch file from the command prompt or put a pause in the script. You need to be a little more clear on what you are doing. You need to show us the code that is in the batch file and its output.Timing may be an issue. An new task can start before the output file is closed from an earlier task. If so, there NEEDS to be something that makes sure the file is ready for the next task. You may wish to use a pipe.I suggest you put a pause statement after each command. When the program pauses, open another DOS command and check to see if the files you need have actually been created. Also there is a 'DELAY.COM' command I picked up someplace years ago. Probably Norton Utilities. It will wait for X number of seconds. I us it a lot of TIMES to wait for 2-5 seconds so files will have different time stamps. Maybe the time that is showed, but also the 1/10 of seconds. This way I can enter 'DIR /OD' and I an see exactly the order the fils were created. Hope this helped Thanks very much for all the help! I've got things working now. Quote from: ErikG on February 14, 2012, 04:11:31 PM Thanks very much for all the help! I've got things working now.Would help all that find this thread later on if you would post your final solution.I needed to make sure that I was in the correct directory when running the file so I ADDED: cd c:\hysplit4\exec to the top of the three commands. |
|
| 765. |
Solve : Command prompt not clearing issue and have questions.? |
|
Answer» HELLO everyone...it's been a while since my last visit. I am working on a project and I am having a bit of trouble. I have done quite a bit of reading on line but haven't found anything that works for me so far. I am learning how to set up a flash drive so I can install Windows XP on it if ever I have any issues with my OEM installation disc. Currently I have the files from my Windows XP Home SP2 installation disc loaded to a folder on my C drive. I need to "Integrate" SP3 into my source file, which I have loaded to a folder on my C drive as well. I'm having a problem clearing the command prompt so I can do the integration part. When I bring up the command prompt window... C:\Documents and Settings\my name> is on the screen and I can't clear it. What am I doing wrong here? I keep trying CLR but it doesn't work. I always get 'CLR' is not recognized as an internal or external command, operable program or batch file. I read some HELP post here on this forum and tried the 'CLS' command I found and it only cleared the stuff about Microsoft Version, etc. at the very top of the window but always LEAVES... C:\Documents and Settings\my name> From her experience as a data processor at her job, my wife is telling me something is pointing to that above file but neither one of us can figure out the how's, why's, or what's to get a clean command prompt window. Can anyone tell what is causing this issue? I'm willing to bet it has to do with some sort of setting but I don't EVEN have a clue how to correct it. If there is anything anyone needs to know at my end please let me know and I'll get back to you ASAP. Thanks, GaryThe only way I know of doing this is with regedit.exe. Open run>type regedit>hit enter>go to HKEY_LOCAL_MACHINE>SOFTWARE>Microsoft>Command Processor On the right side, double-click "Autorun" and type this in: echo off&cls Click Ok and you're done. This is the only way I know to do it, I don't know if there are more ways... -Nathansswell® Quote from: Nathansswell on March 12, 2012, 06:22:17 PM The only way I know of doing this is with regedit.exe. Ok I tried it and it WORKED. I have an empty command prompt screen now. What does that command actually do? Should echo be on or off? Being the first time trying this I don't know what to expect. Will everything work right? Thanks Quote from: 69Z28 on March 12, 2012, 06:02:35 PM
1. When opening a fresh command window a Microsoft message is displayed. To clear this the correct command is CLS. 2. When in an interactive session, the default prompt is the name and path of the logged-in folder, followed by the > character. Immediately to the right of that is a cursor, which may or may not be blinking. What exactly do you mean that you are having trouble clearing the prompt? Why do you need to do this anyway? It is there to let you know the console is ready for a command to be entered. |
|
| 766. |
Solve : My batch file work on XP but not on Win7.? |
|
Answer» My script: |
|
| 767. |
Solve : HOW TO TAKE COMPUTER NAME TO A TEXT FILE? |
|
Answer» SIR, how can i take the name of a local MACHINE to a text filein order to take the computer name to a variable you need to use the command in autoexec.bat eg: set computername=edp after booting win98 you can type the following command to get the computer name echo %computername% I got the solution only after WORKING with system at AROUND 3 hoursFor 2K/XP, all you'd have to do is: echo %computername% >c:\name.txt The name for this example ends up in the file C:\NAME.TXT |
|
| 768. |
Solve : Cant find what's going wrong with IF statements? |
|
Answer» Hey guys I'm back a second time with a new and exciting error ^^ *cry's deeply*. Anyway I think the IF statements are running even if the conditions are not met, but cant seem to track down exactly why or where I'm going wrong. The code is a little test for a combat phase in a small RPG game in the making in case anyone is interested . Now I know the code isn't all that efficient as it could be, but that's because I'm still newish to batch files, so if there is any parts that could be made better just say . There is also a small problem when I target the second monster (%MonsterName2% goblin) it seems to take health off %MonsterName% instead of the second target like I wanted. I am really interested in seeing the final product once completed. This really intrigues my interest I'm afraid unless I have a team for this PROJECT, that it would take a very LONG time as at the moment I'm doing this in between university work. Appreciate your interest though and if I do ever get around to completing it ill be sure to send you a copy. I'm aiming for this to be a sort of Final fantasy/Diablo 2 game, text based of course .Have you tried a top-down approach? Like this: Whenever you find some detail you can not handle, you just crate a 'stub' that fakes it. Later, you or someone else can fill in the details. Kinda like an artist doing a sketch before he brings out the paint. Quote from: Geek-9pm on March 18, 2012, 02:06:52 PM Have you tried a top-down approach? Hmm I'm not sure if I would like doing things that way, first off I'm a bit of a perfectionist when it comes to stuff like this and secondly I would have to fix the code at 1 time or another so it seems like I would be just giving myself more work to do, by not only having to scan through the code for 'stub' parts but writing them as well as the correct code later. I can see the reasoning behind that way of doing it though and I'm sure it would have its benefits at some point. Quote from: Risen91 on March 18, 2012, 02:29:16 PM I'm a bit of a perfectionist when it comes to stuff like this If you are a perfectionist, why are you writing a batch game? Unless it's an obsessive hobby thing, like making a model of the Taj Mahal out of matchsticks. Beware. Somebody asked the Duke Of Wellington how he kept beating Napoleon's army, supposedly the best trained and most technically advanced force in Europe at the time. He compared his method of planning and executing a campaign with Napoleon's. He answered something like this: "Compare a miltary plan to a horses harness. Napoleon typical plan is like a very fine hand tooled leather harness, all the pieces very beautifully and precisely made, all fitting together perfectly. It all works well until something snaps and then it is useless. My typical plan is like one made out of assorted bits of string. If a bit breaks I just tie a knot and carry on". Salmon Trout, great come back! Candidate for post of the month.mind = blown And I started writing this batch game ages back to learn, since then its really just about I already have the code, know it well enough and am having fun with it and I think that's the most important thing, don't want to be learning a language I don't like much (E.g. Actionscript) even if batch is very outdated.The general idea now in computer programming is incremental refinement and crated packages.They call it by various names. The concept is no avoid looking at a print out that covers the walls of two rooms. The main part of the code describes the logic of the program. Various packages do the hard work and are hidden from view. Until you want to see them. Just an OBSERVATION. For further reading: http://c2.com/cgi/wiki?StructuredProgramming Quote "Structured programming" is programming that links control flow blocks (a function, an if statement's block, etc.) to the scopes of variables. A variable declared inside such a block is invisible outside it. Three cheers for structured garbage! you lost me at incremental refinement sorry Just been working on my script and come across something I'm struggling to get working right. basically I need a monster to have a random attack sequence, the variable names are %MonsterName% %Monstername1% and so forth up to 4 (giving a total of 5 in the group) ill show you what I have been tinkering around with at the moment to see if I can spur any ideas (not that you need them ) Code: [Select]set /a modifier=%random%%%5 if %modifier%==0 ( set MonSeq="" ) set MonSeq1=%MonsterName%%modifier% ) :resetmon1 set /a modifier=%random%%%5 set MonSeq2=%MonsterName%%modifier% if MonSeq2=%MonSeq% ( goto resetmon1 ) if MonSeq2=%MonSeq1% ( goto resetmon1 ) I was going to have it basically "Re-randomising" every time that %MonsterName% number was taken. This seems a really slow and process sapping way of doing it though, I need all 5 in a set order (don't matter if its pre-set or randomises it after the combat script where last monster has taken its hit) any ideas? Edit: quick change to that script to make it more understandable |
|
| 769. |
Solve : Stuck on batch file creation for user input? |
|
Answer» I'm trying to make a MS-DOS batch file automatically update the firmware on up to 12 HBA cards. (The site has a closet full of HBA's that need updating and this would speed up the process) I've SUCCESSFULLY completed the part to select which model to upgrade, but it's been too long to remember how to set up the part where the user inputs how many cards are in the system. |
|
| 770. |
Solve : Windows Setup batch file? |
|
Answer» When I set up a new computer, I use both batch files and registry scripts to either add to, subtract from or modify things in Windows and in its registry. Without getting too detailed, I have tried to run a .reg script at the end of a batch file and find that the .reg script never runs, even if I preface it with 'Call'. Actually getting too detailed is exactly what's called for here.Please show us the code so we can all understand what is going on. Quote Is this even possible? Likewise combining a VBScript and a batch file together. Possible? If you don't supply the parent PROCESS (ie: regedit for .reg files or cscript for .vbs files) then the file association is used. A VBScript can run a batch file via the Run method. A batch file can run a VBScript the same as any other NT command. If you mean combining both languages in a single file, YES it can be done by writing one of those god-awful hybrid scripts Thank you. Ok, a typical batch file + registry script would go something like this: Echo off cls del /F /S /W "C:\temp\*.*" Rem Put more lines here to CLEAN out more junk. GrantAdminFullControl.reg It's just that simple. I can run a .exe file, or a .com file, or even another .bat file on that last line and they all run OK, but NOT a .reg file. So I guess I'm asking if anyone knows why it won't run and if there is anything I can do to MAKE it run? If not, it ain't no big deal. I can always do what I've been doing for years, first running all my batch files, then run my registry scripts and then run my VBScripts. Thanks again, The Shadow PS: I came here, to this forum, because I've received some great help here in the past.I can't duplicate your problem. Nothing seems particularly wrong but it may be the .reg association is not set. Did you get any runtime errors? You might try this: Code: [Select]Echo off cls del /F /S /W "C:\temp\*.*" Rem Put more lines here to clean out more junk. cscript //nologo myVBScript.vbs regedit GrantAdminFullControl.reg The call statement is only valid for calling batch files and determines whether the called file returns control to the caller or not. Other executable files should always return control to the caller. With any luck, this may help. Quote from: Sidewinder on March 18, 2012, 12:50:56 PM The call statement is only valid for calling batch files and determines whether the called file returns control to the caller or not. Other executable files should always return control to the caller. You can use the call command for any file that is either executable or has an association. Whew! It's been a long day, after a night of St Patrick's Day FESTIVITIES, but with way more Googling than I really wanted to do, I finally just did a search for "Batch File Commands". When I learned DOS and batch file programming back in the early 80's, there were not so many batch file commands available. I was both surprised and pleased to find the "Start" command. All I had to do is precede the name of my registry script with the command "Start" like this: Rem The following line runs the registry script RegTweaks.reg START RegTweaks.reg There are, of course, a bunch of switches that can be used by that command, but they are not necessary for my purpose. As was mentioned, "Call" is primarily for running one batch file from within another batch file. Thank you all again, for your efforts. The Shadow |
|
| 771. |
Solve : For /f Tokens? |
|
Answer» I was reading through one of the questions posted here, and geek's response to it, and it got me thinking. He said you can read at most 52 (he also said it could be 62 or more) variables from a file. Through my really quick and dirty research, I discovered that the number is actually 69 (both alphabet cases, numberic, and 7 mysterious variables). However, I found that the maximum number of tokens you can USE in one for command is 31 (trial and error, any more and the command refuses to run but doesn't give an error). There could also be something after z, but I have no way of testing this. You do have a way to check the "gaps". You have the prompt. You can do it manually or you could write something such as a vbscript that goes through the whole ascii table and CREATES, and shells out to, a command line like below, recording which ones work and which don't. (There are threads in the Google Groups archive of alt.msdos.batch.nt which touch on this topic) C:\>for %{ in (*.txt) do echo %{ 01.txt 1-sfc-problems.txt 1-sfcdetails.txt 1.txt 2.txt 3.txt hello.txt C:\>for %| in (*.txt) do echo %| % was unexpected at this time. C:\>for %~ in (*.txt) do echo %~ 01.txt 1-sfc-problems.txt 1-sfcdetails.txt 1.txt 2.txt 3.txt hello.txt You have two issues here, I think: First, what characters can be used as FOR metavariables (answer: practically every printable character which does not have a special meaning [e.g. % ! < > etc]) Quote there is a 7-variable gap between 9 and A. Does anyone have an idea what would be in that 7-variable gap? It's not numbers >=10. You will see the answer to this when you look at an ASCII chart. Second the maximum number of tokens possible in a FOR construct; clearly this requires an unbroken consecutive run of valid variable characters and this has been well established to be from ASCII 63 '?' to ASCII 93 ']' Quote from: Salmon Trout on March 18, 2012, 01:54:17 AM what characters can be used as FOR metavariables (answer: practically every printable character which does not have a special meaning [e.g. % ! < > etc]) I tested 1 to 255 and these failed, so, at a first glance, maybe you could use some non-printables, although you might have to use tricks to get them in a script. ASCII 9 ASCII 10 ASCII 11 ASCII 12 ASCII 13 ASCII 32 ASCII 34 " ASCII 37 % ASCII 38 & ASCII 44 , ASCII 59 ; ASCII 60 < ASCII 61 = ASCII 62 > ASCII 94 ^ ASCII 124 | ASCII 160 á You can do this for /f "tokens=1-2" %} in ("a b") do echo %} %~ but not above ASCII 127 (the first token works, not the later ones) but this works (☺ is ASCII 1 and ☻ is ASCII 2) (you type them by holding down ALT and typing the number on the keypad) for /f "tokens=1-2" %☺ in ("a b") do echo %☺ %☻ This that I wrote above obviously only applies to one loop; by nesting you can get more simultaneously existing FOR variables. Quote from: Me the maximum number of tokens possible in a FOR construct; clearly this requires an unbroken consecutive run of valid variable characters and this has been well established to be from ASCII 63 '?' to ASCII 93 ']' Quote from: Helpmeh we're dealing with something greater or equal to 75. I managed 81 so far, and I believe I could squeeze a few more out. The essential point is that the command interpreter sees the variable character as an ASCII code, and it is quite happy, with the exceptions already noted, to deal with the codes that aren't letters of the alphabet or numbers, including ones that don't correspond to keys on the keyboard. I imagine that when they wrote the documentation they deliberately kept it simple and only mentioned A-Z and a-z and that's where the figure of 52 comes from. echo off set String1="v1 v2 V3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 v18 v19 v20 v21 v22 v23 v24 v25 v26 v27 v28 v29 v30 v31" set String2="v32 v33 v34 v35 v36 v37 v38 v39 v40 v41 v42 v43 v44 v45 v46 v47 v48 v49 v50 v51 v52 v53 v54 v55 v56 v57 v58 v59 v60" Set String3="v61 v62 v63 v64 v65 v66 v67 v68 v69 v70 v71 v72 v73" Set String4="v74 v75 v76 v77 v78 v79 v80 v81" FOR /F "tokens=1-31" %%? in (%String1%) do ( FOR /F "tokens=1-29" %%_ in (%String2%) do ( FOR /F "tokens=1-14" %%- in (%String3%) do ( REM ASCII 1 to 8 [Won't display in CH] FOR /F "tokens=1-8" %% in (%String4%) do ( Echo %%? %% %%A %%B %%C %%D %%E %%F %%G %%H %%I %%J %%K %%L %%M %%N %%O %%P %%Q %%R %%S %%T %%U %%V %%W %%X %%Y %%Z %%[ %%\ %%] Echo %%_ %%` %%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o %%p %%q %%r %%s %%t %%u %%v %%w %%x %%y %%z %%{ Echo %%- %%. %%/ %%0 %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 %%: Echo %% %% %% %% %% %% %% %% ) ) ) ) Output: v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 v18 v19 v20 v21 v22 v23 v24 v25 v26 v27 v28 v29 v30 v31 v32 v33 v34 v35 v36 v37 v38 v39 v40 v41 v42 v43 v44 v45 v46 v47 v48 v49 v50 v51 v52 v53 v54 v55 v56 v57 v58 v59 v60 v61 v62 v63 v64 v65 v66 v67 v68 v69 v70 v71 v72 v73 v74 v75 v76 v77 v78 v79 v80 v81 Quote from: Helpmeh on March 18, 2012, 12:06:26 AM Weird how I can't edit. You get 1 hour from the time of posting, I believe. Quote FOR /F "tokens=1-14" %%- in (%String3%) do ( The above works, but for the sake of accuracy this should be FOR /F "tokens=1-13" %%- in (%String3%) do ( |
|
| 772. |
Solve : Simple Batch File Help!? |
|
Answer» Hi.. I've created 2 simple batch files that start and stop "windows audio" service (as I often need to stop/start it when I'm working with MUSIC and using different drivers) Code: [Select]echo off Fantastic! Thank you very much for the speedy response, you have made things a lot easier and cleaner for me. |
|
| 773. |
Solve : Getting input from a user in a batch file? |
|
Answer» I'm writing a simple XCOPY batch file and I want the user to input a directory name. I've seen this done quite some time ago (pre Win 95) but just can't remember how it was done. The input would have to RESIDE in a variable within the program. I always used one of the many batch enhancers in the old bare DOS days. Nowadays, I use AutoIt http://www.autoitscript.com/autoit3/ for this kind of task. For a bunch of old-style DOS utilities, try http://garbo.uwasa.fi/pc/ Many thanks, John. I think it was the ask utility that I had seen used before. I'll CHECK out the autoit tools too - I hadn't HEARD of this before. Paul. |
|
| 774. |
Solve : Suppress file name extensions -- MS DOS? |
|
Answer» Hi, |
|
| 775. |
Solve : Telxon running Dos 3.21? |
|
Answer» Hello. My company is using Telxon PTC-710s running Dos 3.21 with a proprietary clipper ORDER entry program. |
|
| 776. |
Solve : Concatenate two variables? |
|
Answer» Hi, |
|
| 777. |
Solve : Extending DOS beyond the 640K limit? |
|
Answer» [glb]PLEASE HELP !!!![/glb] |
|
| 778. |
Solve : Way to Tell if Parameters exist or not?? |
|
Answer» Hello All, |
|
| 779. |
Solve : How to separate a long command to two lines? |
|
Answer» Hi, |
|
| 780. |
Solve : Maintaining a prompt window open? |
|
Answer» HI all. Is it possible to maintain a prompt window opened after executing some COMMANDS from a batch file? I just want to EXEC ipconfig and then keep the window open so I can copy de ip address. Thanks for the helpOpen command from the "Run" box, then type ipconfig. It stays open until you close it.That's what i USUALLY do... I want to run the command from a .bat... i'm lazy Thanks for the HELP anywayIPCONFIG /ALL PAUSE Thanks!!! That's exactly what i wanted! |
|
| 781. |
Solve : Answer in Batch -NET USE? |
|
Answer» Any IDEAS on SENDING a blank answer for a username in a batch file? Is there a command to send the answer as "enter"? |
|
| 782. |
Solve : Internet Relay Chat on DOS? |
|
Answer» There is a way to start an IRC chat on DOS with the PERSONS IP ADDRESS. Would anyone happen to know the command text? |
|
| 783. |
Solve : file renaming? |
|
Answer» Hi, i want to know how i can rename alot of files without giving the previous name, here is what i want to do: |
|
| 784. |
Solve : Partition and format...help...? |
|
Answer» I need to write a batch file that partitions and then FORMATS my drives with out any user INTERACTION when I start up the COMPUTER.... |
|
| 785. |
Solve : shortcut keys - help!!!!!? |
|
Answer» I am using an international KEYBOARD and am having a hard time remembering my English, much less which keys are referred to with "CTRL+BREAK" Can someone please HELP me. I WOULD appreciate it very much! Ctrl is the control key, usually two of them below the shift keys. Break is on the Pause key, upper right on my keyboard. Ctrl-Brk would be holding Ctrl and pressing the Break key. |
|
| 786. |
Solve : Creating a blank file? |
|
Answer» I am looking for a way to create a blank file in dos using a batch file. |
|
| 787. |
Solve : alonso109? |
|
Answer» some BODY how I can SHUTDOWN a service (process) from windows 2000 with a batch FILE? Thank you for your TIME and help. Try PSKILL from http://www.sysinternals.com/ntw2k/freeware/pstools.shtmlThanks a lot !! |
|
| 788. |
Solve : bios guardian? |
| Answer» SOMEBODY HELP ! When I go into my bios,I keep GETTING a page says that I can't change any bios settings until I disable the bios guardian. How do I disable it ? Thanks.what mobo is this...i GUESS you are trying to flash your bios... | |
| 789. |
Solve : writing batch file? |
|
Answer» Hi all, |
|
| 790. |
Solve : windows dosnt start? |
|
Answer» OK i have an old 92 gateway with wut i think is the old version of ms dos n E ways..i was deleting some stuff on it and i think i deleted the wrong thing it was "microsoft publisher" and after i deleted all the files it asked me to restart so i did. when i did windows didnt start so i used my boot disk and it didnt help at all windows still didnt start so i came on this site and i looked for some things and i tryed them like the undelete thng it says that it was a bad command or something like that and so i tryed the GUI=1 thing and it went to te windows 98 loading screen but then it just gos back to the boot disk thing( when i took it out and restarted the comp it dosnt do a thing) it gose to an options screen with the safe mode on it and it says to use the command prompt option and use "scanreg" so i did and it dosent do n e thing and if i use safe mode or normal it gose to the windows 98 loading screen for about 5 mins then it gose back into the ms dos with a message "invalid media type drive C: abort retry,fail" every time. i want to ERASE every thing on my computer and reinstall windows with a fresh start but i dont know how and i dont know if im using the undelete thing right. if u can will u plz help out a guy in needok win98 boot disk load it restart-pc on the a:\ cd windows enter this will take you to c:\>type this command scanreg/restore and chose the last good cab file...try it.i have a dell with HOME xp on it...whenever i turn it on it loads microsoft and restarts..i will put the xp disc in and like he said it willl take me to a safe mode screen and i TRIED all options for it but it didnt work it stopped working when we downloaded some windows updates and it sed to restart for them to work help me every time i try and do something like ur suggestion it always says "invalid media type reading drive C" dose this mean i dont have drive C? plz help |
|
| 791. |
Solve : Getting out of MS-DOS Mode??? |
|
Answer» Okay I dont know if this belongs here or not, but here it is. I have Windows 95 or 98, I dont know which one. But I restarted me computer in MS-DOS Mode, and now I cant get out! Someone said to type exit and press enter, I did, but it just restarts and comes back up in MS-DOS. Anyone know whats going on here? |
|
| 792. |
Solve : .bat send file? |
|
Answer» How can i send a file with .bat to other comp moast easy copy test.txt \\standby\c\test.txt how can i copy 2 txt's in to one? with batch? copy file1+file2 Can be run from the command line or a batch file Quote and how can i use choice?? Choicei've got lots of problems, choise doesnt seem to work on xp, and "can not FIND file C:\text.txt+C:\text2.txt"How can i send a file with .bat to other comp moast easy? - i would recommend ftp or if you're on a network, put it on a share drive(either one can be done throught batch files how can i copy 2 txt's in to one? with batch? -easy, create a batch file and put this command in it "type test.txt >> test2.txt" every time the batch file is run, the contents of test.txt are added to test2.txt |
|
| 793. |
Solve : removing partition(s) with FDisk? |
|
Answer» I am running windows 3.1 and more by (bad) LUCK than by good MANAGEMENT, my hard drive was partitioned. |
|
| 794. |
Solve : Logon batch script trouble? |
|
Answer» Hey all |
|
| 795. |
Solve : how to automate saving file with batch?? |
|
Answer» Can any body please help? does any body have batch file which can automate the saving of a file to a SERVER .It will need to run every night at a set time? http://www.iopus.com/guides/batch.htmKirbyFooty distributes a freeware WINDOWS cron utility KirbyAlarm which will do this - and will even do it when the machine next STARTS up if it was off when the backup would normally be done. You can have KirbyAlarm EITHER copy the file directly to the backup location or access a batch file to do it. |
|
| 796. |
Solve : Batch file hangs if I don't specify output file? |
|
Answer» I have a batch file which runs from a JAVA UI. The batch file calls various commands. I get to a certain point and run the FOLLOWING command (a DB2 command): |
|
| 797. |
Solve : format the hard drive?? |
|
Answer» I'm unable to format my hard drive. A MSG comes up saying that my volume NEEDS to be DISMOUNTED first, but when I try...it's unable to LOCK the drive. Is there a command I can use to fix this???You can't format the boot drive while you're running off of it! Boot from a FLOPPY, then you can format the hard disk, if that's what you're trying to do. |
|
| 798. |
Solve : backup 1x per day with XCOPY? |
|
Answer» Hi there... |
|
| 799. |
Solve : Finding text and inserting variable? |
|
Answer» I have pgp installed and wanted to make a batch file to execute on a directory automatically. Hourly the scripts are being sent with a new file name every hour. I have tried using the c:\* and every other wildcard, but just keep on getting error MESSAGES in pgp with file does not EXISTS. EX: synatx of a good filename c:\test.pgp. How do I get around this. Ultimately I want a script to run hourly that would decrypt the whole directory looking for .pgp FILES. Would I execute a script to look for all files with a .pgp filename, save the filename then put in some static text with the variable filename .pgp. How do I go about doing this. |
|
| 800. |
Solve : Starting Out? |
|
Answer» HI I am 13 and have started using cmd prompt I was just wondering if anyone has any tips on writing .bat FILES that open programs. Any help would be much appreciated as I do not no much about using COMMAND prompt. Thanks.Opening a file from a batch file is as simple as putting the name of the file in the batch file. For instance: NOTEPAD.EXE C:\TEST.TXT ... will invoke notepad and open the file C:\TEST.TXT A copy of the DOS 6.22 HELP.* and QBASIC.* files in your DOS or Windows\Command directory will give you access to a better HELP function than the /? one in DOS 7.x for Winn9x. WinNT/2K and XP trimmed down the AVAILABLE commands too much in the emulator... There are still good 'tutorials' for batch file programming on the Web, use a search tool. |
|