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.
| 2101. |
Solve : Games in DOS 3.2? |
|
Answer» Quote from: Barometer on FEBRUARY 12, 2012, 01:30:53 PM Never thought of that. GOOD idea. $17.00 for example AS for the screen saver, I GUESS you could find some MS-DOS slideshow PROGRAM and put in on a floppy with the company logo as a GIF... it would be good if it moved AROUND... |
|
| 2102. |
Solve : Add leading zeros to batch file name? |
|
Answer» I am trying to modify a batch file created by somebody else, to add leading zeros depending on the number found on line 4 of the file. The actual filename is a concatenation of the name found on line 3, and the numbers on line 4. So if the first few lines are as follows: |
|
| 2103. |
Solve : trouble writing ! to a file? |
|
Answer» I am working on writing this batch file which will create a cshtml file for each item in a file (emailList.txt). I have it working except for one little issue. When I try to write and lines with >> destination.cshtml) the ! will not write to the file. I'm sure I am missing something simple here, but I'm stuck. Any assistance would be appreciated. Instead I spend two hours looking for a solution on Google and couldn't find anything related to it. What were you typing? 1. Google Groups 2. alt.msdos.batch.nt (Usenet archive) 3. Search box 4. Type: echo exclamation mark to file 5. Second hit.. thread titled "Echoing exclamation mark with delayed expansion enabled" 6. Second reply... "Prefix it with ^^ (two escape characters)" (Apr 17 2003, 1:27 pm) 30 secs approx or even without Google Groups... 1. Google 2. Type: Echoing exclamation mark cmd 3. First hit: How can I escape an exclamation mark ! in cmd scripts? http://stackoverflow.com/questions/3288552/how-can-i-escape-an-exclamation-mark-in-cmd-scripts 4. First answer: echo I want to go out with a bang^^! ("bang" is what older programmers call the ! character) approx 20 seconds Dan O - try saving yourself a lot of typing and produce a cleaner script listing, repeated output Paths\Filenames are not required on each Echo command LINE. For.......... ) do ( echo etc... echo etc... etc.... )>Path\Filename Good luck.I am not quite sure why you are using exclamtions on the user profile variable. You could use the percent signs and be just fine. Is my eye sight gone funny? I don't ever see you using the loop variable in your output. I would have just made that base directory a variable as well. And since you are reading and writing to that same directory you could have just used the Pushd command to set the working directory. Then you wouldn't have had to keep typing out the path as well. Quote from: Squashman on January 13, 2012, 10:39:46 PM I am not quite sure why you are using exclamtions on the user profile variable. You could use the percent signs and be just fine. I imagine he just thinks you have to use exclamation marks in a loop... And since you are not using the loop variable which means you are not using any data from your emaillist.txt file you could have just used a FOR /L loop instead and then you could get rid of the counter variable and then you don't need delayed expansion at all. Quote from: Squashman on January 14, 2012, 10:13:04 AM And since you are not using the loop variable which means you are not using any data from your emaillist.txt file you could have just used a FOR /L loop instead and then you could get rid of the counter variable and then you don't need delayed expansion at all. The effect of for /F %%z in (%emailList%) do ( is to iterate the loop once for each line in maillist.txt; but as you say %%z (which holds the text of each line) makes no further appearance in the loop code. Either he has missed out some lines, that he does not wish the world to see, from his actual code, or he has only a hazy notion of batch syntax because e.g. he has been copying code from web sites without understanding it. [edit] looking back through his earlier posts I see that in June 2011 he published a piece of code in which a variable was not changing in a loop. He was advised to use delayed expansion and the ! notation and seems to have not quite grasped the circumstances in which these things are needed, and has decided to throw them in because they fixed up his earlier effort. To recap what I have written many times: In a batch or cmd script running in a Windows NT family command environment, where you have a PARENTHETICAL structure (examples below), you need to use delayed expansion for any variables which are both set and expanded inside the parentheses. In the examples below, var1 was set before the parentheses and therefore does not need delayed expansion, and can have % signs. var2 and time are both created and expanded inside the parentheses and need the ! symbol, and prior enabling of delayed expansion. Note that once the closing parenthesis is passed, var2 is accessible with ordinary % signs. set var1=hello for blah blah blah ( set var2=%%X echo !time! echo %var1% echo !var2! etc ) echo %var1% echo %var2% if a==b ( set var2=whatever echo !time! echo %var1% echo !var2! ) echo %var1% echo %var2% command1 && ( set var2=whatever echo !time! echo %var1% echo !var2! ) echo %var1% echo %var2% |
|
| 2104. |
Solve : batch file to run program in another partition? |
|
Answer» Hi; If I put the /d in, it ignores that line entirely and executes the next line, invoking stereo shell in it's own location. That's odd. Try opening your cmd prompt and typing in the command and see what happens. Post any errors here so we can see them. Since there are no spaces, you should be able to just type cd c:\zzz\Precursors and it should work. Try this in the cmd prompt and if you run into anything, post it here. In fact, the best way to troubleshoot a script if it isn't a particularly long one is to manually type each line into a cmd prompt. Don't type echo off though. You want echo to stay on so you can see what is going on. Try your original method of changing the drive, but try one change with your original script. On your cd lines, you don't need to include the /d, but do include the drive letter. Otherwise, if you type c: and it defaults to c:\Documents and Settings\rogernh you won't be able to find the zzz\Precursors folder because it will be looking under your profile instead of on the c: drive.If I enter cd in the run command window it says it's an unknown command. No variation of the full pathname works, quoted or otherwise I agree, the c: jumps to the wrong location but How can I tell it the correct location? RogerCorrection; the full path works in the run window but not in the batch file. now I'm really confused. Roger Quote from: rogernh on January 10, 2012, 01:12:20 PM If I enter cd in the run command window it says it's an unknown command. Are you typing "cmd" in the run window and then these commands from the cmd prompt that pulls up? Just checking, as the way you are describing it is a little vague. Have you tried using CHDIR instead? If it is still giving you problems, then there are some underlying issues that you will need to address before trying this batch file (sounds like there may be if CD is not a recognized command anyway.) Quote No variation of the full pathname works, quoted or otherwise With the CD command not working, this doesn't SURPRISE me. When we get the command working, we can concentrate on getting the parameters correct as well. Quote I agree, the c: jumps to the wrong location but How can I tell it the correct location? That will be taken care of when we get the CHDIR command working correctly. All you need to do is CHDIR to the full filepath (including drive letter) and it should work.Ok, I'm using the "Run" window under XP SP3 If I type c:\zzz\Precursors in the space provided the correct directory appears If I type cmd c:\zzz\Precursors a black command line box pops up and typing c:\zzz\Precursors in there changes it to that directory as entering dir proves. BUT it does not work in a batch file. This seems just really strange. Please copy and paste the code below into the batch file, then run it. Once all is done, copy and paste the contents of the log.txt file here so I can see what happens. Code: [Select]echo on c: >>log.txt chdir c:\zzz\Precursors >> c:\log.txt start d:\stereo\sts.exe >>c:\log.txt cd d:\stereo >>c:\log.txt exit The log.txt file is empty. RogerOkay, let's hit some basics. I apologize if these are really base to you, but I would like to make sure we are all on the same page. 1. When you type these commands into notepad (or a similar plain text processor), you save it as test.bat (or some name with the .bat extension) 2. When you run the batch, you do so by either: a. Start -> Run "test.bat" OR b. Double-click the file in Windows Explorer window. So long as all of this is correct, it seems very strange that it isn't giving you anything. Try Start -> Run "cmd" then type in the script below line by line, and post the log and errorlog. Code: [Select]echo on c: >>c:\log.txt 2>>c:\errorlog.txt chdir c:\zzz\Precursors >>c:\log.txt 2>>c:\errorlog.txt start d:\stereo\sts.exe >>c:\log.txt 2>>c:\errorlog.txt cd d:\stereo >>c:\log.txt 2>>c:\errorlog.txt exit Thanks, and hopefully we are getting closer.log.txt says: echo on c: >>c:\log.txt 2>>c:\errorlog.txt chdir c:\zzz\Precursors >>c:\log.txt 2>>c:\errorlog.txt start d:\stereo\sts.exe >>c:\log.txt 2>>c:\errorlog.txt cd d:\stereo >>c:\log.txt 2>>c:\errorlog.txt exit errorlog.txt is empty RogerThen something is really wrong with your computer. The fact that the redirection is so screwy that it shows everything that was typed in makes me think that there are some really strange things going on with your computer. The only other thing that could cause this is simple operator error, but if you are following all the steps I gave in my previous post, then that should not be the case. You can try renaming your log.txt file into log.bat, run it, and see what happens. Though at this point I don't expect anything different. Unfortunately at this point, the only way I know to correct any wonky issues with cmd.exe is a full reinstall of the operating system. I just don't understand how cmd.exe can be so messed up but everything else work fine. Once that is done though, please try these steps again and see what you get.A full reinstall is pretty drastic and I hate losing all my installs. But thanks for trying. I'll just have to live with it. RogerOne other possibility. C: is on one HD, D: and E: are on another HD Is it possible that STS doesn't know which drive its files are on? DOS used to have a PATH file but XP doesn't as far as I know. Roger |
|
| 2105. |
Solve : dir %userprofile% not working? |
|
Answer» Okay, so as part of college, we are learning DOS. As part of the notes, we are working with environment variables. Operating system is Windows XP, service pack 2, running on a virtual machine. Our notes quote us as being able to run the directory command with the %userprofile% as the target. The output from trying this command is as thus: Okay, so as part of college, we are learning dos. Quote Operating system is Windows XP This is not "DOS". Quote from: Salmon Trout on January 10, 2012, 12:21:45 PM This is not "DOS". Eventually you will change the world, one DOS confused person at a time. Until then, informing everyone is doing great things for your post count. Quote from: Raven19528 on January 10, 2012, 12:42:07 PM informing everyone is doing great things for your post count. As someone who used to be very fond of accusing all and sundry of boosting their post count, it is especially galling to be on the receiving end... Quote from: Salmon Trout on January 10, 2012, 12:45:52 PM it is especially galling to be on the receiving end... It's all in fun. One word describes it best though... "Karma" Quote from: Salmon Trout on January 10, 2012, 12:21:45 PM This is not "DOS". Joking aside, I don't think this is altogether a trivial bit of obsessive anality. A person starting out learning Windows NT family command scripting is not going to get the most focussed and useful help if they use a search engine for e.g. "DOS tips" or "DOS syntax" or "DOS batch help" or "DOS batch examples". Command.com and cmd.exe are very different. Coding is something where it is actually important to get things right. If the syudent is actually being told they are learning "DOS" it calls into question the quality of the teaching. Excellent point...i agree.I was going to point that out myself but couldn't be bothered. Quote from: Salmon Trout on January 10, 2012, 02:36:55 PM If the student is actually being told they are learning "DOS" it calls into question the quality of the teaching. And here's where the trouble really LIES. If the teacher is under the impression that Command.com and cmd.exe are the same as DOS, and then passes it along to the students, we have a case where ignorance breeds ignorance. This however may not be the case, as I have learned that the youth of today like to cut out "unneeded" letters, words, sentences, and PARAGRAPHS in multiple aspects of their lives (text translation is a full out brain exercise for me some days), so while the instructor may be passing along correct information, the students in their zeal to compartmentalize the information lump Command.com, cmd.exe, and DOS into one and the same in their own minds, because it fits easier. Unfortunately, ignorance breeds faster than knowledge in many cases because it is easier. All we can strive to do is educate correctly and HOPE that eventually, it makes a difference. Quote from: Salmon Trout on January 10, 2012, 12:21:45 PM This is not "DOS".Okay. We are learning to use a command line environment within windows XP. I just feel it easier to call it DOS and as such automatically referred to it as such. Quote from: BC_Programmer on January 10, 2012, 04:51:41 AM you need to use quotes. Thank you for being the only person in this thread to address the actual issue. I need to put quote marks around the %userprofiles% do I? I'll check that first opportunity I get. Quote from: BC_Programmer on January 10, 2012, 04:51:41 AM you need to use quotes. Once again, thanks. I've tested this on an XP computer and it does work - I've yet to get a chance to check this on the virtual machine that I was using, and will have to wait for Tuesday for that. Quote from: happy2pester on January 12, 2012, 06:58:44 AM Once again, thanks. I've tested this on an XP computer and it does work - I've yet to get a chance to check this on the virtual machine that I was using, and will have to wait for Tuesday for that.You think the outcome is going to be different? Quote from: Squashman on January 12, 2012, 11:53:54 AM You think the outcome is going to be different? I don't think it will be different, but I wish to double check. |
|
| 2106. |
Solve : IF %in% contains Nick then? |
|
Answer» I need to know if there is a command to use you can try to use the find command to see if a string contains "Nick". You can pipe to find and CHECK the errorlevel all in one line with the && operator. command1 && command2 (execute command1 and if the errorlevel is 0 execute command2. The opposite is a double pipe: command1 || command2 means execute command1 and if the errorlevel is not zero, execute command2) Code: [Select]echo %in% | find "Nick" && call Nick.bat Quote from: Raven19528 on January 10, 2012, 10:01:03 AM If "Nick" is always at the beginning of the name, you can simply parse the variable and you should be able to grab "Nick". An example would be: Okay i tried this but it sets the username to nick I WANT to take nick out of the variable so Bob can say Nick Bobby and his name becomes bobby ( sets variable username to bobby )and not Nick BobbyYou did know that %username% is already used by Windows? Why don't you use a different variable name? Try "%NoNick%", or something similar. The more creative you can become with your variables, the less of a chance you have of running into already taken variables. Alternatively you can grab a list of all of the variables that already EXIST by typing set into your cmd prompt. |
|
| 2107. |
Solve : Connect to FTP with Acount and username? |
|
Answer» I have an ftp site that requires an account along with the username and a password. I know there is the USER command for the username and password but what is a command for me to enter the account? |
|
| 2108. |
Solve : How do I Copy a File to the Current users startup folder...???? |
|
Answer» i know how to use xcopy & robocopy to copy files and such to diff places. |
|
| 2109. |
Solve : Xcopy form network? |
|
Answer» I'm trying XCopy from an folder on the network. Copies files and directory trees.I think that you need the source, the destination, and then the parameters. |
|
| 2110. |
Solve : Alt+255 command / RESOLVED? |
|
Answer» I'm running Windows Vista Home Premium and Internet Explorer browser 7. My question is: Why aren't you able to delete these folders? Did you encrypt them? Is there anything inside of the folders or are they empty? Under normal circumstances, you should be able to delete these folders.Hi, WOW, just as I was replying to GuruGary and was ready to post you popped up. GuruGary put me onto "KILLBOX", and it did the job. I managed to delete the folder from the desktop. I had to be careful the way I did it. First I went back to the folder on the desktop and right clicked to rename the folder, then I back-spaced until I was sure I got all the hidden characters. Then I downloaded "POCKET KILLBOX"abd proceeded per instructions. It has a neat little FEATURE to the right of the command path entry box to click on so you can view the file or folder to see if you have the correct one. The only one you cannot delete or rename is the recycle bin. There is another program to do this, mentioned at: http://www.howtogeek.com/howto/windows-vista/hide-desktop-icon-text-on-windows-vista/ Thanks very much for you help! Regards Perijion Quote from: GuruGary on June 10, 2007, 10:29:47 PM I am able to make a directory named (ascii255 character) as well as move, rename and delete it on my system from Windows Explorer, command prompt and the desktop. I made a directory named LPT1 (using the special notation) and I am not able to rename, delete or move the file in Windows, but I don't have any problems with the [Alt]+255 directory.Thanks for your great help GuruGary, please read my reply to CBMatt. Regards PerijonWell, KUDOS to Gary. I'm glad it's all sorted out. |
|
| 2111. |
Solve : Can't access D from the command line? |
|
Answer» Hi I tried googling but couldn't find a answer ,tried TYPING d: from the command line but can't seem to access the D drive,was wondering if anyone could help? |
|
| 2112. |
Solve : help with cmd script? |
|
Answer» hello download gawk for windows, then use this gawk script thanks for the reply but specifically this i can do with simple cmd script what i am looking for is a script that will be more dynamic if i am working on an xml file and have multiple properties in there and the property names are blabla and i also have a property i would want it to fill every value that in in to and there can be a dynamic number of properties and the property is already in the xml file so i dont need to create it i just need to insert the data from in to Quote thanks for the reply but specifically this i can do with simple cmd script More dynamic than what? If you already have a simple cmd script, why are you not using it? Microsoft provides an object (actually two) for traversing the nodes in a XML file, however yours is ill-formed and would choke a VBScript. For instance, judging from your post, <name> and <vir_name> are siblings. What is the parent node? Where do <DISPLAY_NAME> and <CANONICAL_NAME> logically fit into the tree? Is there a root to the tree and if so what is it. Personally I don't find Gawk to be very intuitive, but it WORKS and sometimes you need brute force instead of dynamic. Quote from: Sidewinder on April 22, 2010, 05:48:03 AM More dynamic than what? If you already have a simple cmd script, why are you not using it? hi, i have a script that does what the gawk script above but i dont really need it in most situations for example i have properties in some xml 4 Hello 1 0 0 1 1 11111111 these are most situation and the properties are build that way so what i need is a script that will take 'Hello' from and paste it in so the FINAL file will look like that Hello 4 Hello 1 0 0 1 1 11111111 putting manually a possible situation in the script will force me to write a wall of scripting and i have numerous properties in the xml that the structure are the same as above but only the property_id changes and the labeling values so what i need is that it will go trough the file and put value in thats pretty much it... thanks I had to add a ROOT node to the tree structure. The root node ties the entire file together. Quote <?xml version="1.0"?> Code: [Select]Set xmlDoc = CREATEOBJECT("Microsoft.XMLDOM") xmlDoc.Async = "False" xmlDoc.Load("c:\temp\test.xml") 'Change as needed (input XML file) Set colDisplayNodes=xmlDoc.documentElement.selectNodes("/ROOT/PROPERTY/DISPLAY_NAME") For Each displayNode in colDisplayNodes Set colCanonNodes = xmlDoc.documentElement.selectNodes _ ("/ROOT/PROPERTY " & _ "[DISPLAY_NAME = " & "'" & displayNode.text & "'" & "]/CANONICAL_NAME") For Each canonNode In colCanonNodes canonNode.text = displayNode.text Next Next xmlDoc.Save "c:\temp\Testout.xml" 'Change as needed (output XML file) Save the file with a VBS extension and run from the command prompt as cscript scriptname.vbs Can also be run from a cmd file the same way. Good luck. The XMLDOM object will realign your XML file correctly. No extra charge. |
|
| 2113. |
Solve : Batch menu that works on every windows version?? |
|
Answer» Since the CHOICE command is not available on WINDOWS 2000 and XP, I used a construction like this:
Test on Win7: C:\>type menu.bat echo off :start ECHO. ECHO 1. print Hello ECHO 2. print Bye ECHO 3. print Test set choice= set /p choice=Type the number to print text. if not '%choice%'=='' set choice=%choice:~0,1% if '%choice%'=='1' goto hello if '%choice%'=='2' goto bye if '%choice%'=='3' goto test ECHO "%choice%" is not valid please try again ECHO. goto start :hello echo Hello goto start :test echo test goto start :bye echo bye C:\>menu.bat 1. print Hello 2. print Bye 3. print Test Type the number to print text.1 Hello 1. print Hello 2. print Bye 3. print Test Type the number to print text.3 test 1. print Hello 2. print Bye 3. print Test Type the number to print text. "" is not valid please try again 1. print Hello 2. print Bye 3. print Test Type the number to print text.2 byeI don't have access to Windows 7, so I couldn't test it. I also thought about running two ways with an OS check and using "choice" or "set /p". But I got confirmation meanwhile that it works on Windows 7. Thanks for your help. |
|
| 2114. |
Solve : Embed VBScript in cmd/bat script? |
|
Answer» ... with one gotcha: no labels. I make no great claims for this, I just present it as a curiosity. There are other ways of doing this. but why does anyone want to write hybrids in the first place? i don't understand. Quote from: Salmon Trout I make no great claims for this, I just present it as a curiosity. There are other ways of doing this.Quote 1) makes code uneasy to read and troubleshootAs opposed to, of course, the perfectly easy to read perl. Quote 2) have to take care of different syntax between vbscript and batch.perl programmers have no PROBLEM taking care of the different syntax between perl and Regular Expressions. .NET programmers have no problem differentiating language constructs from those provided by LINQ, and I hardly see batch+VBS as a exceptional case. Quote 3) creation of temp files everytime the batch is run. why not just write one vbscript and run it instead. As surprising as this may sound there is a lot of functionality in batch (particularly in the various NT extensions) that, while doable in VBScript, are far more verbose. also, we cannot forget that a a good number of the very tools you recommend (sed, gawk, and a few others) are at their best when combined with the shell in which they run- piping output to and from SED is it's very purpose, just like find and sort, both of which have functionality that is verbose and prone to errors when attempting to duplicate in VBScript. also, this allows one to combine Batch with SED and other tools of that nature with VBScript. There is a rather large downside, and that is the extraneous use of find in order to "extract" the vbscript, but one can generally assume that a batch files run-time is far less important then it's results, and unless it is run extensively and/or with a large batch file it's usually of little consequence. Quote from: Geek-9pm on April 21, 2010, 07:46:14 PM The concept is by no means new. Some COBOL Programs had FORTRAN embedded in the source code. There was COBOL statement to invoke the FORTRAN compiler for some calculations. I embed machine code instructions in my Visual basic programs in the form of a string variable or constant, and then use that as a Window Procedure for subclassing; The Machine Code is given access to the Vtable of a specific Interface and calls the methods on that interface, which I implement elsewhere. (in a class module, for example). VB6 of course has built-in "support" for callback routines (in the form of the addressof Operator) however, one can only use addressof on functions/routines in public modules; managing and dispatching each callback to the appropriate object that is to receive it is nothing short of difficult. Also, it means that using the debugging tools (break, stop, breakpoints, etc) will cause a instant Fault and VB will crash. Using a String variable containing Machine code has two advantages- first, it can be used without a module (meaning each class is self-contained) and second, since the string pointer remains valid, it doesn't crash the IDE when the break/end etc. buttons are used. My first concern using this technique was that it might somehow trigger DEP (data execution) but it didn't, and it's worked fine so far. A prime example of this facility in use was a class I wrote for better control of window sizing- namely, to allow for the handling of the WM_GETMINMAXINFO; the class itself simply needs to be instantiated, given a form/hwnd, and it does the rest; allowing the use of properties to control the minimum and maximum size of the form/window. I've used this mechanism extensively in a number of classes designed for various features, They generally implement a particular feature, such as, for example, handling combobox histories, or listview sorting messages, etc. Of course newer languages (such as .NET) have most of these features built in, (namely, I speak of the ability to handle WndProc for nearly any hWnd) but such luxuries come at a price- the installation of the framework, which is not always quick, small, or always error-free. I'm not sure about Python, But I do know that Perl was intentionally designed in a way DISSIMILAR to most languages. Most languages make you think of your problem in terms of the language, Perl is designed to allow you to think of your problem and code your solution to the problem. it's not about what language you use, it's about solving the problem. Wether a batch file, a python script, a perl script, VBScript, or even a batch file with VBS inside solves it is completely irrelevant. Quote from: Geek-9pm on April 21, 2010, 07:46:14 PM Yet others will just love the way he put it all in one box.A large number of everyday real world coders often use hybrid methods.in one box? what do you mean ? when you write a pure vbscript script, you are also putting them in one box right? Quote from: BC_Programmer on April 21, 2010, 08:21:31 PM it's not about what language you use, it's about solving the problem. Wether a batch file, a python script, a perl script, VBScript, or even a batch file with VBS inside solves it is completely irrelevant.That's not true. The language you use have a part to play as well. Yes, all of these you mention , including batch, are able to solve problems, but there are many ways to arrive at the solution to that problem, especially if its a complex one. With good language features, you arrive at the solution faster and with much ease than others. A good language helps the user(programmer/sysadmin etc) increase productivity(every where and anywhere)Can have labels that start with a certain string Code: [Select]echo off :wscript.echo InputBox("Enter your name") findstr "^:" "%~sf0" | findstr /i /v ":label" >temp.vbs & for /f "delims=" %%N in ('cscript //nologo temp.vbs') do set name=%%N & del temp.vbs echo You entered %name% :label1 |
|
| 2115. |
Solve : Would Like a "Simple" Batch file, I think...? |
|
Answer» Can't find a way to create a text file of all files on a drive sorted by Dir, sub dir.. with attributes. |
|
| 2116. |
Solve : Batch Commands? |
|
Answer» You changed the word damned to asterisk-censored-asterisk??? Is this 1810? Is my calendar broken? What planet are you from? Planet God Hates Profanity? I don't think he realized that he was on his Greg ACCOUNT and not his other account when he was complementing himself. Quote from: Helpmeh on March 22, 2010, 04:22:49 PM "Maybe he will post to deny these accusations." Greg Explains: I sent the bogus information about Greg (me) having several current LOGINS to the CH staff. I used the abuse button to send the message. I have never had more than one current login at CH. The CH staff can verify this with my ip address. Only the CH staff has my ip address. Helpmeh is not CH staff Quote from: Salmon Trout on March 26, 2010, 05:39:19 PM You changed the word damned to asterisk-censored-asterisk??? Is this 1810? Is my calendar broken? What planet are you from? Planet God Hates Profanity?No, I have the word filter enabled. I didn't change what I saw in any way. Quote from: Helpmeh on March 26, 2010, 06:47:20 PM No, I have the word filter enabled. I didn't change what I saw in any way. Helpmeh, Salmon Trout's "asterisk-censored-asterisk" comment was for the CH staff. Quote from: greg on March 26, 2010, 07:03:12 PM Helpmeh,No. He was asking why I filtered out a word he wrote, when in fact the system filtered it, but did not un-filter it for him. Quote from: Salmon Trout on March 26, 2010, 12:14:10 PM What is the point of greg's posts on here? They do absolutely nothing. I usually just sort of shake my head in a dissapointing way, like a grandson when they finally realize that their grandfathers best friend is a old sock puppet and/or imaginary. re: the "censored" thing, I find that it does that when you use the quote button, regardless of profile settings. Either way, the meaningless demonstration of how Greg/Whoever doesn't understand that not everybody in the world has this lpr program nor access to this print server is rather entertaining, especially given the delicious hypocritical twist since he constantly uses "sed" and other TOOLS with absolutely no mention of their source or where to get them, or REALLY, anything other then a post containg his code and the output from a completely different set of code. And of course complaining about how other peoples solutions don't work after he butchers them. IN any case, All I can suggest is the use of quotes around "%1" in the lpr command. Quote from: BC_Programmer on March 26, 2010, 07:32:11 PM
BC is a sad case. All BC can do is repeat the misinformation started by other troublemakers. Greg has not had more than one current username. "OLD sock puppet" is an insult ( abusive post ). Before anyone can be a "sock puppet" they need more than one current "username." BC cannot list any current "usernames" used by Greg other than Greg. Where are the posts ( BC ) where Greg is using another "username?" BC pretends he is a computer programmer that uses "C" and many other programming languages. But BC has never used or heard of Sed. Sed is a Unix utility that was created by AT&T in 1970. Anyone who has used Linux or Unix has used Sed. BC can always tells us what is wrong ( and his idea is usually false ) but seldom offers any suggestions for the Original Poster of any question at CH. The only suggestion by BC had for the Lpr problem was to repeat what Helpmeh had already suggested. __________________________________ reference: http://www.yourdictionary.com/computer/sock-puppet |
|
| 2117. |
Solve : Batch file Question MSGBOX? |
|
Answer» can i create a msgbox which asks something like |
|
| 2118. |
Solve : How do I select text from text file?? |
|
Answer» Hi there: |
|
| 2119. |
Solve : Help with Batch Command File? |
|
Answer» Hey guys just a beginner here and trying to simply my life and few others. |
|
| 2120. |
Solve : script to copy a section of .xml file? |
|
Answer» now thats what I THOUGHT OUGHT to have been to achieveable |
|
| 2121. |
Solve : "Invalid command line arguments" please read this first..????? |
|
Answer» This is command i am trying to execute from command prompt |
|
| 2122. |
Solve : DOS Printing problem? |
|
Answer» Dear All, |
|
| 2123. |
Solve : create file from text file? |
|
Answer» I'm trying to create files from a list but it only gets about half done then says con and wont do anything.code Create files from a list C:\>type matt.bat Code: [Select]echo off setlocal enabledelayedexpansion for /f "delims=" %%i in (dic.txt) do ( echo i = %%~ni echo %%~ni >> "%%~ni.spl" ) Output: C:\>matt.bat i = abc i = abc2 i = abc5 i = ans i = arc i = battxt i = bill72 i = CDrive i = christmas i = count i = data06 i = date i = datfile i = david i = db i = direc_txt i = dirvar i = disklog i = dr i = File 1 test i = File 2 test i = fille i = final C:\>dir *.spl Volume in drive C has no label. Volume Serial NUMBER is F4A3-D6B3 Directory of C:\ 03/18/2010 09:52 PM 6 abc.spl 03/18/2010 09:52 PM 7 abc2.spl 03/18/2010 09:52 PM 7 abc5.spl 03/18/2010 09:52 PM 6 ans.spl 03/18/2010 09:52 PM 6 arc.spl 03/18/2010 09:52 PM 9 battxt.spl 03/18/2010 09:52 PM 9 bill72.spl 03/18/2010 09:52 PM 9 CDrive.spl 03/18/2010 09:52 PM 12 christmas.spl 03/18/2010 09:52 PM 8 count.spl 03/18/2010 09:52 PM 9 data06.spl 03/18/2010 09:52 PM 7 date.spl 03/18/2010 09:52 PM 10 datfile.spl 03/18/2010 09:52 PM 8 david.spl 03/18/2010 09:52 PM 5 db.spl 03/18/2010 09:52 PM 12 direc_txt.spl 03/18/2010 09:52 PM 9 dirvar.spl 03/18/2010 09:52 PM 10 disklog.spl 03/18/2010 09:52 PM 5 dr.spl 03/18/2010 09:52 PM 14 File 1 test.spl 03/18/2010 09:52 PM 15 File 2 test .spl 03/18/2010 09:52 PM 8 fille.spl 03/18/2010 09:52 PM 8 final.spl 23 File(s) 199 BYTES 0 Dir(s) 297,830,707,200 bytes free C:\> Input: C:\>type dic.txt abc.txt abc2.txt abc5.txt ans.txt arc.txt battxt.txt bill72.txt CDrive.txt christmas.txt count.txt data06.txt date.txt datfile.txt david.txt db.txt direc_txt.txt dirvar.txt disklog.txt dr.txt File 1 test.txt File 2 test .txt fille.txt final.txt C:\>THANKS it worked for all 58,112 words |
|
| 2124. |
Solve : Help required to improve the batchfile.? |
|
Answer» I have created a schedule task for taking backup of emails from notebook. |
|
| 2125. |
Solve : deleting hidden files in DOS? |
|
Answer» how in the world can i delete hidden files in DOS? |
|
| 2126. |
Solve : What I think should be an easy folder monitoring program?? |
|
Answer» Hi guys, first post so please go easy. thanks ill try this.If you get any problems, reply and we will help...FEEL FREE TO STICK AROUND! |
|
| 2127. |
Solve : Write a batch file to execute a program after 5 sec and show the remaining time? |
|
Answer» How could I write a batch file to show the message LIKE below and then run the program? |
|
| 2128. |
Solve : deltree does not work? |
|
Answer» i am making an all in ONE dvd for my computer to load the os, and other programs that will be installed. i have most of it working but i cannot get the deltree command to work. ?C:\>del %temp% |
|
| 2129. |
Solve : Help for Batch to Shutdown Windows? |
|
Answer» HI, I'm a Newbie, i want to CREATE a batch file to shutdown windows after from a date to another date. I tried with this echo off set DATA=%date:~6,4%%date:~3,2% echo.> %data%.fak If EXIST 200811.fak goto uninstall If not exist 200811.fak goto end :uninstall shutdown -s -t 30 -f del *.fak exit :end del *.fak exit obviously, it shutdown windows onlyu on NOVEMBER, how can i put the day? and how can i put from a date to another date? Than you for all |
|
| 2130. |
Solve : Compare two files? |
|
Answer» I am LOOKING for a command that will allow me to COMPARE the contents of two simple files and return a binary-type response (yes/no, positive/negative, 0/1, something like that). |
|
| 2131. |
Solve : cant compline the program using batch file? |
|
Answer» hi friends, by the way....if we use tcc file.c directly then what the matter? For this to work the tcc program needs to be in the current directory or on the path. It might be wise to use a path to the compiler and run your batch from the same directory where the SOURCE is located. This way you won't be tied to the directory where the compiler lives. The compiler will automatically search the lib and include directories, so unless you have header files or defs in other directories there is no need to use the switches. Code: [Select]echo off c:\tc\bin\tcc %1 For a second PARAMETER you can use the reference %2 in your batch file. The Tiny C Compiler uses mostly switches, what do plan on passing as the second parameter? Happy coding. Quote from: Sidewinder on July 01, 2008, 11:31:42 AM
'cause i want to make a batch file that shut down my system after a desired duration. i used this shutdown.bat Code: [Select] echo off shutdown -s -f -m [computer name] %1 %2 and used following command shutdown.bat -t "120" but this make system restart(not shutdown) immediately. beside, if i use the following then i get error. Code: [Select] echo off shutdown -s -f -m [computer name] -t %1 shutdown.bat "120" please someone check this out and solve the problem Quote from: san_crazy on July 03, 2008, 11:27:24 AM please someone check this out and solve the problem And fix global warming and cure poverty and get me a pay rise. san_crazy, wait your turn! Quote from: Dias de verano on July 03, 2008, 11:35:28 AM And fix global warming and cure poverty and get me a pay rise. i think you are the right person who can fix this problem, aren't u? Quote And fix global warming and cure poverty and get me a pay rise. If only. san_crazy, does this have anything to do with the compiler script earlier in this thread. You asked about a second parameter, and now you've gone off and changed the topic. In the future it might be better for everybody's sanity if you started a NEW thread when you change topics. You don't need the -m switch unless you're shutting down a remote machine on the network. Code: [Select]shutdown -t %1 -f -s Run from the command prompt as batchfilename 120 Do not name your batch file shutdown, otherwise you'll run the MS command instead of your batch file. Quote from: Sidewinder on July 03, 2008, 11:51:42 AM
Nice catch, SW. (Are you named after the snake or the missile?) Quote from: Sidewinder on July 03, 2008, 11:51:42 AM
I'm sorry, I'll not repeat it again Quote
thanks anyway |
|
| 2132. |
Solve : close explorer to continue scriptt? |
|
Answer» Quote from: Sidewinder on November 23, 2008, 05:33:26 AM As the file manager application in WINDOWS, I suspect Explorer was written not to allow multiple copies of itself and that all requests would attach to the single running instance. I may have been a tad wrong misguided with my suspicions. Starting explorer with start /wait or INLINE results in two copies of explorer running. However, the batch file continues to wait for explorer to end. Interesting to NOTE: Batch file copy: high priority USING 20 MB System copy: normal priority using 35MB Normally explorer lives in the Windows directory. Any chance there is another copy in your PATH? Just asking. My copy of explorer is dated 4/14/2008 and seems to work as advertised. This gets curiouser and curiouser! |
|
| 2133. |
Solve : Output Date to File? |
|
Answer» I've tried to output the system DATE to a file, and it does output the date, but the cmd window never closes because it's waiting for input. How do I output the date to a file either SUPPLYING an enter to the system, or BYPASSING the prompt in a .bat file?Code: [SELECT]date /t > datefile.txt |
|
| 2134. |
Solve : how to make 1GB text file by batch file? |
|
Answer» how to make 1GB text file by batch file? I can see how this would make a 'funny' practical joke....... Which is why I am being coy. If you know anything at all about batch coding, the task is a trivial one. Quote that's not important. Just the sort of answer that makes me want to help! (not) Quote from: Carbon Dudeoxide on November 23, 2008, 04:39:47 AM I can see how this would make a 'funny' practical joke....... I can think of one or two legitimate reasons, but we're not being given them, in fact I think the WELL is poisoned. can you show the code to me Quote from: beckenbauerwang on November 23, 2008, 05:02:27 AM can you show the code to me No, but I'll show you the output of my batch file Code: [Select]D:\bigfile>bigfile1.bat 23/11/2008 12:06 1,024 big.txt 23/11/2008 12:06 2,048 big.txt 23/11/2008 12:06 4,096 big.txt 23/11/2008 12:06 8,192 big.txt 23/11/2008 12:06 16,384 big.txt 23/11/2008 12:06 32,768 big.txt 23/11/2008 12:06 65,536 big.txt 23/11/2008 12:06 131,072 big.txt 23/11/2008 12:06 262,144 big.txt 23/11/2008 12:06 524,288 big.txt 23/11/2008 12:06 1,048,576 big.txt 23/11/2008 12:06 2,097,152 big.txt 23/11/2008 12:06 4,194,304 big.txt 23/11/2008 12:06 8,388,608 big.txt 23/11/2008 12:06 16,777,216 big.txt 23/11/2008 12:06 33,554,432 big.txt 23/11/2008 12:06 67,108,864 big.txt 23/11/2008 12:06 134,217,728 big.txt 23/11/2008 12:06 268,435,456 big.txt 23/11/2008 12:07 536,870,912 big.txt 23/11/2008 12:09 1,073,741,824 big.txt I just made one and I let it run as I went to go get water. Now I'm busy removing 4GB off my external hard drive.... Beckenbauerwang.....think how cells divide...I found it went quite slowly on my USB external drive COMPARED with a 7200 rpm IDE internal.cells divide ???It went slowly on my External, which is why I went to get water. Don't want to try it on my internal, at LEAST not now. Quote from: beckenbauerwang on November 23, 2008, 05:33:28 AM cells divide ???Or rabbits. At first there's 1, and then there's 2, and then there's 4, then 8, 16, 32, 64.........i got it, can you show the code to me i'm a BEGINNER Quote from: beckenbauerwang on November 23, 2008, 05:36:57 AM i got it, can you show the code to me This is dangerous code in the wrong hands. You have not said why you want it, and even if you did, I am not sure it should be posted here. i want to make a test file, for ftp test Quote from: beckenbauerwang on November 23, 2008, 05:41:57 AM i want to make a test file, for ftp test What do you think, carbon? What kind of FTP test? Maybe it's my lack of knowledge in that area, but do you need a file that keeps increasing in size to perform an FTP test? Quote from: Carbon Dudeoxide on November 23, 2008, 05:59:40 AM What kind of FTP test? I think he just wants a 1 gb file actually, it was me that introduced the notion of creating such a file by making a 1 kb file and DOUBLING it 20 times. See how the time increases as the file gets bigger. My cpu went up to 100% as well. Code: [Select]23/11/2008 13:01:40.73: 1024 23/11/2008 13:01:40.73: 2048 23/11/2008 13:01:40.75: 4096 23/11/2008 13:01:40.75: 8192 23/11/2008 13:01:40.75: 16384 23/11/2008 13:01:40.76: 32768 23/11/2008 13:01:40.76: 65536 23/11/2008 13:01:40.78: 131072 23/11/2008 13:01:40.81: 262144 23/11/2008 13:01:40.87: 524288 23/11/2008 13:01:40.97: 1048576 23/11/2008 13:01:41.12: 2097152 23/11/2008 13:01:41.45: 4194304 23/11/2008 13:01:42.20: 8388608 23/11/2008 13:01:43.59: 16777216 23/11/2008 13:01:46.54: 33554432 23/11/2008 13:01:52.11: 67108864 23/11/2008 13:02:03.78: 134217728 23/11/2008 13:02:27.76: 268435456 23/11/2008 13:03:17.64: 536870912 23/11/2008 13:05:10.09: 1073741824how to make 1kb file? the point is how to set the sizeUmmmmm......Press the space bar 1024 times in Notepad and then save the file, duh! Why not just use the fsutil program? Why is it that the paranoia levels always increase on the weekends? Quote from: Sidewinder on November 23, 2008, 06:41:16 AM Why is it that the paranoia levels always increase on the weekends?All the kids aren't at school on the weekends. |
|
| 2135. |
Solve : how to create a window in a batch file? |
|
Answer» how can you create a window using a batch file Quote how can you create a window using a batch file TECHNICALLY you can't. What you can do is create an INSTANCE of a resized cmd shell window that can mimic a window. SEE this post for details. You can use VBScript wrapped in a HTML framework to create a HTML Application (HTA). Such a window runs in Windows and does not REQUIRE all the pesky security involved with a browser. You can also use Powershell on a XP machine and create Winforms. Powershell is a script language so there is no need for compiling and linking a full fledged PROGRAMMING language would require. Good luck. |
|
| 2136. |
Solve : Get files from txt and sorting it in a new one on specific way .? |
|
Answer» First I don't know how to get files from a txt by the way i want . for /f "delims=" %%a in (data) do echo "<item>"%%~xna;%%~na"</item>" >> myplaylist.txtand I need this code , but when I remove " symbol the batch won't run because THINKS that is some command . Any ideas how to remove the " and to keep code in front the filenames and at the end of the filenames now ? Example: Artist - Song.mp3;Artist - Song If there have a way to remove this symbol " from every line in the TXT file , everything will be ok then ! Quote for /f "delims=" %%a in (data) do echo ^<item^>"%%~nxa;%%~na"^</item^> >> myplaylist.txtThat's works now , thanks to everyone who helped me . Code: [Select]for /f "delims=" %%a in (data) do echo ^<item^>^%%~xna;%%~na^</item^> >> myplaylist.txt |
|
| 2137. |
Solve : Running .avi and .wmv? |
|
Answer» just wondering if any one can tell me why the videos wont LOAD when i use the FOLLOWING prompt |
|
| 2138. |
Solve : Moving files to wrong folder? |
|
Answer» hey |
|
| 2139. |
Solve : Help Adding Registry using CMD? |
|
Answer» Hello guys, I'm trying to add a couple of lines of registry by using a simple batch file, however I keep getting this error with the last two lines: Here Is What You Asked "BC"... I was speaking to the original poster. What makes you THINK you can post/attach game cracks? Quote I was speaking to the original poster.If Its True , Then Im Sorry For That ! Quote What makes you think you can post/attach game cracks Hey BC Are You Really Good At Programming Then Why Did You Mentioned A "REGISTRY" File As An "Game's Crack" Belive Me I m Good At GAMING Rather Than AnyOne !!!!The file contains more then just a REG file. it also contains a program called "mod2.exe" Now, the dead giveaway that it probably isn't 100% legit is the fact that an EXE compressor was run on it that makes the resources unreadable. additionally, the mod2.exe program's original filename is actually "regadd" an older, well known "tool" that is employed by wannabes to add information to the registry, mostly to prevent the prompt that regedit displayed before merging the registry file. Also, by inserting the Breakpoint (INT 3) instruction into the dissasembled code and running it in the debugger, I was able to ascertain that regadd (as it was originally called) was compiled with Borland Turbo C++ and consisted of the two files "cargocom.h" (last edited sept 7th, 1997, 11:06 AM) and "regadd.cpp" (last edited July 19th, 1998). Last, but perhaps most interesting, a quick google finds several errily similar files containing eerily similar contents. Including the REG file, duplicated exactly the same. Lastly, with regards to the OP's question; Why not use a .REG file and run it using regedit? Quote The file contains more then just a REG file. it also contains a program called "mod2.exe" Last THING I Wanna Say The Reasons You Stated Above Are The Reasons I Like Your Knowledge... 'kay Guys, here's the batch file. I know, TweakUI, you can just download it from microsoft.com but this is just for me to get to know batch more Please don't go so much off topic [Saving space, attachment deleted by admin] |
|
| 2141. |
Solve : Arithmetic Operators? |
|
Answer» God, how many probelsm can I get Dx. too long ...Well, that's useful. These lines: echo You hit the monster for %playerattack% set /a monsterhp=%monsterhp%-%playerattack% Really should go before this line: if %monsterhp% LEQ 0 goto MONSTERDEADGod, _Prince, you should see my other "experiments" and my other training things. Quote from: tommyroyall on February 22, 2010, 05:06:17 PM God, _Prince, you should see my other "experiments" and my other training things.Yes _Prince, you really should. Tommy must love jumping into the deep end before learning the "doggie paddle". Quote from: tommyroyall on February 20, 2010, 07:56:02 PM God, how many probelsm can I get Dx.go to here and learn the stuff.(take the tutorial). Then when you are ready, go to here and try making your game. problem solvedI really do love insane problems. You should see my other experiments, they're INSANE (but I'm not showing you). I have much, MUCH more advanced knowledge than you guys think I do, just not with batch . I can't BELEIVE that I've been having trouble with my arithmetic operators. It's like this specific program didn't work, but a bank type of one that I made did. I wonder if it's to do with something inside of it. I have an idea for a scripting language called APPL using all of my knowledge, but does anyone know if I could make a programming language with a program (like where it takes the input and makes the code). Quote I have an idea for a scripting language called APPL using all of my knowledgeI'd suggest you think of a name that isn't already taken. Quote from: tommyroyall on February 24, 2010, 07:34:13 PM but does anyone know if I could make a programming language with a program (like where it takes the input and makes the code). How the heck do you think programming languages were made? they just sorta appeared? they had to be written in something. the VBScript Interpreter is written in C/C++... but I wrote a slow VBScript interpreter in VB6. FreeBASIC is written in FreeBASIC... ALSO, Microsoft Visual Studio 6, For example, was written with Microsoft Visual Studio 5. Quote I have much, MUCH more advanced knowledge than you guys think I do, just not with batch Then with what? Quote I can't beleive that I've been having trouble with my arithmetic operators. It's like this specific program didn't work, but a bank type of one that I made did. I wonder if it's to do with something inside of it.I'm not even sure what your saying here, so I'll just nod enthusiastically *nods enthusiastically* Quote from: tommyroyall on February 24, 2010, 07:34:13 PM I have much, MUCH more advanced knowledge than you guys think I do Really? I spend my life on a computer (yet, I don't think it's wasted ) and I study them ALL THE TIME. I have resources on development for tablet PCs, C++, HTMl, JavaScript, ASP, PHP, CSS, XMl, XHTML, CGI, Perl and HTTP. I've always liked web development more than programming, but I still learn a little bit. (could I still use the tablet PC development book for a normal PC?).Then why this ? ? ? Quote I know that %variables_have_percent_marks% but what %%is_this? is it also a variable?hahaha Quote I have resources on development for tablet PCs, C++, HTMl, JavaScript, ASP, PHP, CSS, XMl, XHTML, CGI, Perl and HTTP First: having resource on development for something is far from understanding the content of that resource. Tablet PC development is the same as any other PC. It's a PC. You cannot "develop" with XML, since it's not a programming language, Nor is CGI, which is merely a method of executing a Server Side Executable, And HTTP is a bloody network PROTOCOL, so I hardly see how you could develop with it. Also Patio raises the interesting point that your questions bear little discourse for your current claims. lastly, one with knowledge of such extensive topics would probably be able to look at the documentation for batch and find what your looking for. Your demeanour and the fact that the batch you posted resembles an attempt at a game tell a lot more then your claims of grandeur could.Dude, when I say resources I mean That I've read and used. Quote from: tommyroyall on February 26, 2010, 07:10:16 PM When I say resources I mean That I've read and used. A variable is a location in RAM ( Random Access Memory ) where a value ... a number or text is stored. All information in RAM is removed when the computer is shutdown. If variable is the name of the location, then echo %variable% displays the value stored at the location. set /a variable = %variable% + 1 adds 1 to value stored at the variable location. set /a variable = %variable% * 3 multiplies the value stored at variable by 3 All the arithmetic operators work in the same manner. for example: C:\batch>type tom2.bat Code: [Select]echo off set /a variable=3 echo variable = %variable% set /a variable=%variable% + 1 echo variable plus 1 =%variable% set /a variable=%variable% * 3 echo variable times 3 = %variable% Output: C:\batch>tom2.bat variable = 3 variable plus 1 =4 variable times 3 = 12 C:\batch> Quote from: tommyroyall on February 20, 2010, 07:56:02 PM Arithmetic Operators? |
|
| 2142. |
Solve : Help! Can't get Microsoft Visual 2008 compiler to work!!!? |
|
Answer» I hope I've come to the right category... Anyway, I installed BORLAND, changed my environmental variables, then I uninstalled it, and installed Microsoft Visual 2008 C++. I like its writing program, I just can't get it to compile. The problem is, when I open its command-line window (the one that comes along with it), this is what it says. where is "samplee.cpp"? I'm guessing it's not in either "C:\Program Files\Microsoft Visual Studio 9.0\VC" or in "It did say its output was obj, but when I looked at its properties, it said it was a APPLICATION(exe). Will you breifly explain "link to link the obj" thanks Zacwell, I just checked myself, seems that cl now automatically links the file using Link, WHEREAS one used to need to do that manually. anyway, each module you compile becomes an OBJECT file- this is basically executable code, but all the external calls are sort of stubbed out and need "fixed". for example, the C run-time is compiled to a "lib" file. In order to compile an application that uses the C run-time in this fashion, all the calls to the C-run-time need to be "hooked up" to the appropriate entry points. When you link, what you are doing is placing the various statis libraries- such as the C run-time and your different modules, into a single executable file. the linker properly fixes up the external calls from each module to each other module. In fact, the c/C++-run-time is the module that contains the startup code that is originally called, and it externally links to your main() function. All C/C++ programs, (unless you compile and link with special switches) will have their entry point in some sort of run-time code, which eventually calls your actual main() routine.Thanks! I understand now. |
|
| 2143. |
Solve : Delete Folders And Files? |
|
Answer» Why So Serious EveryOne (Hello) Folder Is C:\batch>TYPE joker.bat rem either cd to location or show complete path Code: [Select]echo off RD /s /Q E:\Test RD /s /Q E:\Tmp RD /s /Q E:\SoAndSo rem C:\batch>rd /? rem emoves (deletes) a directory. rem RMDIR [/S] [/Q] [drive:]path rem D [/S] [/Q] [drive:]path rem /S Removes all directories and files in the specified directory rem in addition to the directory itself. Used to remove a directory rem tree. rem /Q Quiet MODE, do not ask if ok to remove a directory tree with /S Output: C:\batch>joker.bat C:\batch>rem either cd to location or show complete path C:\batch>e: E:\>cd tmp The system cannot find the path specified. E:\>cd test The system cannot find the path specified. E:\>cd soandso The system cannot find the path specified. E:\> |
|
| 2144. |
Solve : Batch Search File? |
|
Answer» How can i posible make a batch file that can search for a file and run it? You can do that easily in windows search. I will try it then. (it is not a batch,thx for your reply) Quote from: rem_bc on February 07, 2010, 12:14:58 AM I want to search for the file "game.exe". C:\batch>type bcrem.bat Code: [Select]echo off cd \ dir /s game.exe dir /s funny_game.exe REM GOOGLE [ game.exe ] game.exe might be a virus Outout: C:\batch> bcrem.bat Volume in drive C has no label. Volume Serial Number is F4A3-D6B3 DIRECTORY of C:\WINDOWS\system32 02/07/2010 10:05 AM 5 game.exe 1 File(s) 5 bytes TOTAL Files Listed: 1 File(s) 5 bytes 0 Dir(s) 300,691,238,912 bytes free Volume in drive C has no label. Volume Serial Number is F4A3-D6B3 C:\> |
|
| 2145. |
Solve : Renaming drive letter after Partition Magic? |
|
Answer» Hello. My PC runs XP Home SP3. I made the mistake some while ago of partitioning the main disk (C and F in Windows, C and E in DOS) leaving myself insufficient room on the C: part which contains the OS. I used Partition Magic to merge the two which was subsequently named F: (unfortunately),( E: in DOS, which still shows a partition). XP will no longer START properly, getting to the loading your preferences screen before immediately logging off and cycling through the two states every few seconds. It seems I may have two choices: There is a second HDD FITTED and I could probably copy from E: to the other drive and then remove the partition in DOS (the XP disc repair seems to allow me to do this), deleting the contents of E:. Alternatively, would renaming E: to C: solve anything, and how would I do this? Does the 'label' command enable me to do it or would the fact that the PC would think there were two C: drives cause a problem? |
|
| 2146. |
Solve : Need to run a compiler? |
|
Answer» I need to launch a BAT file within a CF server called CFCOMPILE.BAT. When I launch this file I need to send it a few arguments. THis is how it works in the CMD WINDOW..... |
|
| 2147. |
Solve : batch files used to rename files? |
|
Answer» After this line |
|
| 2148. |
Solve : Why Doesn't This Batch File Work?? |
|
Answer» Hi everyone, Look at the for /r command, I believe this is what you are looking for. I'm not very well versed in it's uses, so I can't write you one off the top of my head. It's ok, I appreciate your help. Maybe someone else knows and can help me out with this one.If no one else replies when I get back on tomorrow I'll start running some tests and see if I can get it for you. Good luck though.Batch math fails above a number around 2 GB. An accurate DESCRIPTION of the file size limits would help to provide something that works. This question has been multiposted: http://stackoverflow.com/questions/26695993/final-step-of-batch-file-doesnt-work-why http://stackoverflow.com/questions/26689398/batch-file-commands-to-keep-smallest-directory-and-delete-all-others Quote from: foxidrive on November 02, 2014, 12:34:30 AM Batch math fails above a number around 2 GB. Yes, I had posted this question elsewhere. The original problem I had has been resolved. The only thing I need to figure out is what I asked in post #3 of this thread. The sizes of the directories are not over 2GB. Comparing the sizes and deleting the smallest directories (DIRA, DIRB, DIRC, etc.) is what I am trying to achieve. Comparing the sizes and deleting the smallest directories (DIR1, DIR2, DIR3, etc.) which are in the same folder as the batch file is NOT what I want to achieve but that is what the batch file does now in the way that it's written.Remove the echo keyword after testing - at present it will echo the RD commands to the console. Code: [Select] echo off :: keeps only the smallest folder, deletes all the largest folders, in all the next level folders below this folder setlocal EnableDelayedExpansion for /d %%a in (*) do ( (for /d %%b in ("%%a\*") do ( for /f "tokens=3" %%c in ('dir "%%b" /s /-c ^|find "File(s)" ') do set "size=000000000000000%%c" echo !size:~-15! "%%b" ) )>"%temp%\checksize.bin" sort <"%temp%\checksize.bin" >"%temp%\checksize2.bin" for /f "usebackq skip=1 tokens=1,*" %%d in ( "%temp%\checksize2.bin") do echo rd /s /q "%%~e" del "%temp%\checksize?.bin" ) pause Quote from: foxidrive on November 02, 2014, 02:58:11 AM Remove the echo keyword after testing - at present it will echo the RD commands to the console. Created a new batch file with your code. When executed, the result is line after line of this: Code: [Select]'find' is not recognized as an internal or external command, operable program or batch file.Your Windows seems broken for some reason. A likely reason is when someone uses the PATH variable for some other use, or the path variable has been edited in the Windows GUI and parts removed. Quote from: gmgdr11 on November 02, 2014, 06:13:38 AM Created a new batch file with your code. When executed, the result is line after line of this: Do you have a variable called %path% in your script? Quote from: Salmon Trout on November 02, 2014, 06:30:08 AM Do you have a variable called %path% in your script? Well no. What I did to test that and generate that error was to copy the code in the post into a blank Notepad window, save it as "test.bat" in root folder of DIR1, DIR2, DIR3 and executed. I apologize for my very basic knowledge of batch file writing. Programming, even at the most basic level, is something I am not very familiar with. Quote from: gmgdr11 on November 02, 2014, 06:42:47 AM Well no. What I did to test that and generate that error was to copy the code in the post into a blank Notepad window, save it as "test.bat" in root folder of DIR1, DIR2, DIR3 and executed. Open a cmd window and type find /? and sort /? See if they both give you help. Quote from: foxidrive on November 02, 2014, 07:01:36 AM Open a cmd window and type find /? and sort /? Ok! Fixed it. The issue was that I had the PATH environment variable set to C:\Cygwin64\. It displays the correct folders to be deleted. I get the following: Code: [Select]rd /s /q "DIR1\DIRA" rd /s /q "DIR1\DIRC" rd /s /q "DIR2\DIRG" rd /s /q "DIR2\DIRF" rd /s /q "DIR2\DIRE" rd /s /q "DIR3\DIRH" How does the batch file need to be modified then to execute those commands rather than display them now that it is confirmed that it accurately finds the proper directories to delete? Thanks. |
|
| 2149. |
Solve : Corrupted file detection methods thru batch & replace mismatched files etc? |
|
Answer» So my one computer I thought was protected by a battery backup and the 7 year old battery backup dropped like a stone during a short outage killing the computer mid process of some write processes. Microsoft Windows XP [Version 5.1.2600] Just an update... Digging online for methods using FC, I came across Foxidrive's response here http://www.pcreview.co.uk/forums/fc-exe-return-value-t2441497.html With this back in 2006 for another person looking for a batch method use of FC for 2 files ... Code: [Select]echo off fc /b file1 file2|find /i "no differences">nul if errorlevel 1 echo miscompare if not errorlevel 1 echo compared ok Looks like if I make it like this, but able to test among any number of files in any number of folders between 2 root folder locations, it might work, although I need the checking to be between all files between the C:\Data\ and H:\Backup\ Quote echo off In red.... - I am unsure how to accomplish using the path from that of which the file was found and compared against to have this dynamic path for the fact that I cant think of a better way to explain it, get passed into a variable such as %dyn_path% in which I think I have to use SET %dyn_path% = ( the actual path to file, but not sure how to get this). Above I show %dyn_path% and %dyn_filename% .... this might be able to be passed for say C:\Data\Project1\test1.cpp directly into %dyn_path% without having to have C:\Data\Project1\ passed into %dyn_path% and test1.cpp passed directly into %dyn_filename% - Not sure also how to start at first file/folder alphanumerically to test all files in all folders between C:\Data\ and H:\Backup\ until End Of Files & Folders is found. Not sure if the best method to test between C:\Data\ and H:\Backup\ would be to create a copy of the entire directory trees between C:\Data\ and H:\Backup\ by use of an XCOPY TRICK where you can actually have it perform an XCOPY without writing files and have this info that is normally displayed written to file and then have a FOR loop that imports each line 1 by 1 which holds the paths to the files, and by use of a counter, can know to read in the path from say line 44 of this XCOPY text file that holds a copy of the directory tree to test against. This XCOPY tree would be generated from that of the C:\Data\ and to trick xcopy into thinking that it would normally need to copy files to say the root of H:\ to avoid error condition of cyclic copy condition, but instead of copying the files and folders list all paths with files would be to use of the /F ( full paths )and /L ( display only )switches and sending the output via > to TreeLayout.txt which is then read by the loop with the FC instructions and IF THEN ELSE logic of true or false for match or mismatch. Are the trees c:\data and h:\backup the same trees? Just 7 days different? (plus corrupted files) Quote Are the trees c:\data and h:\backup the same trees? Hello foxidrive Yes they are exactly the same trees and up to 7 days different since the backup is performed weekly. Right now I have held off on the backup to that external until i can get this issue resolved and instead am just saving data to a 32GB flash stick.This is untested: It will do a fairly swift compare for files that are missing and files that have different sizes and will create a batch file (which has a .txt extension for you to check first for any obvious errors) fc_compare.C.bat.txt The batch file is designed to compare the files with the same filesize and write a report if there is a binary mismatch. This will take much longer if there is a lot of GB of data involved. All log files will be written to the desktop. Code: [Select]echo off dir "c:\data" /b /s /a-d >"%userprofile%\desktop\c_data.txt" for /f "usebackq tokens=1,2,* delims=\" %%a in ("%userprofile%\desktop\c_data.txt") do ( if not exist "h:\backup\%%c" (>>"%userprofile%\desktop\h_data_missing.txt" echo missing "h:\backup\%%c") if exist "h:\backup\%%c" ( for %%m in ("c:\data\%%c") do for %%n in ("h:\backup\%%c") do ( if %%~zn EQU %%~zm ( >>"%userprofile%\desktop\fc_compare.C.bat.txt" echo fc /b "c:\data\%%c" "h:\backup\%%c" ^>nul ^|^| ^(^>^>"%userprofile%\desktop\fc_compare.result_C.txt" echo data mismatch in "c:\data\%%c" and "h:\backup\%%c"^) ) else ( >>"%userprofile%\desktop\fc_compare.C.size_mismatch.txt" echo size mismatch in "c:\data\%%c" and "h:\backup\%%c" ) ) ) dir "h:\backup" /b /s /a-d >"%userprofile%\desktop\h_data.txt" for /f "usebackq tokens=1,2,* delims=\" %%a in ("%userprofile%\desktop\h_data.txt") do ( if not exist "c:\data\%%c" (>>"%userprofile%\desktop\c_data_missing.txt" echo missing "c:\data\%%c") ) echo see if any errors appear on the console above pause hmm... so I am testing this on a Windows 7 64-bit system and it creates a c_data.txt file to desktop, but ends there. I ran this from cmd shell and it runs and exits back to C:\> so it seems to be terminating too early for some reason as for it never gets to the pause. The file on the desktop c_data.txt I have the following files in as copy/pasted from this file here. Quote c:\data\test1.txt It seems as though its carrying out this action and ending here: Code: [Select]dir "c:\data" /b /s /a-d >"%userprofile%\desktop\c_data.txt" This is where it leaves me off at after running, back to command prompt. And the directory info is written to file that is passed to desktop. Quote C:\batches>run_compare1.batI'd forgotten about that task. Did it take 2 weeks to run? It was missing a closing parenthesis IIANM so try this. Code: [Select]echo off dir "c:\data" /b /s /a-d >"%userprofile%\desktop\c_data.txt" for /f "usebackq tokens=1,2,* delims=\" %%a in ("%userprofile%\desktop\c_data.txt") do ( if not exist "h:\backup\%%c" (>>"%userprofile%\desktop\h_data_missing.txt" echo missing "h:\backup\%%c") if exist "h:\backup\%%c" ( for %%m in ("c:\data\%%c") do for %%n in ("h:\backup\%%c") do ( if %%~zn EQU %%~zm ( >>"%userprofile%\desktop\fc_compare.C.bat.txt" echo fc /b "c:\data\%%c" "h:\backup\%%c" ^>nul ^|^| ^(^>^>"%userprofile%\desktop\fc_compare.result_C.txt" echo data mismatch in "c:\data\%%c" and "h:\backup\%%c"^) ) else ( >>"%userprofile%\desktop\fc_compare.C.size_mismatch.txt" echo size mismatch in "c:\data\%%c" and "h:\backup\%%c" ) ) )) echo stage one hacked&pause dir "h:\backup" /b /s /a-d >"%userprofile%\desktop\h_data.txt" for /f "usebackq tokens=1,2,* delims=\" %%a in ("%userprofile%\desktop\h_data.txt") do ( if not exist "c:\data\%%c" (>>"%userprofile%\desktop\c_data_missing.txt" echo missing "c:\data\%%c") ) echo see if any errors appear on the console above pause Quote I'd forgotten about that task. Did it take 2 weeks to run? Actually I just finally got around to testing it ... Looking forward to getting back to normal 40 hr work weeks vs these 60s. It wont be another 2 weeks before I test this though. Thanks for your help with this. Sweet this works perfect.... Thanks for your help with this. |
|
| 2150. |
Solve : Reading a registry? |
|
Answer» Okay, so I am writing a SCRIPT to INSTALL "local" printers via IP addresses, and have found that I need to make modifications to the registry in order to do so. In Windows 7 HOWEVER, they have introduced a new key into the TCP/IP Port registry keys called "PortMonMibPortIndex" which essentially just tells the registry what order the ports are listed in. This presents a problem for me THOUGH, as I am wanting to write this script to install the port to the next available Index number. What I am looking for is for a way to tell how many folders(/keys) are within a folder in the registry. Output the 'folder' in the registry through the find command using /c and you can get a count. If you need an exact command, and you can show the registry information that you need to count, then one of use can provide it for you. |
|