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.
| 8501. |
Solve : Comparing time as a string? |
|
Answer» Hello Experts, If you still need help I'd need to know between what times you'd want it to check. Because it's always before Midnight. Good point Delta. That code must be started manually every day I guess. Well if you're starting it manually it doesn't even need to check the time then, just the existence of the file.Quote from: DeltaSlaya on August 28, 2007, 03:36:21 PM Well if you're starting it manually it doesn't even need to check the time then, just the existence of the file. Yes it does, it has to wait around until the next midnight. Did you read the batch code at all? Oh, I see, so it's SUPPOSED to loop until the file arrives or the time is midnight? Thats easy enough.if that's the case, it would be simpler to just schedule a job at or after 12 midnight to query the existence of the file, instead of looping everytime.As it stands the code decides whether midnight has arrived by looking for "time /t" giving "12:00 AM" as an output. So strictly speaking it is not checking whether midnight has passed, it is checking if it is midnight "now". To be sure of not missing it the code needs to run continuously, which seems a bit inefficient to me. Although once every 30 seconds would still hit the window. More efficient and more elegant to check every once in a while whether midnight has gone past. A challenge might be the time format which depends on locale. (Americans like their AM / PM etc whereas we Euro weenies have our 24 hour format). So I'd store %date% as a string (e.g. set startdate=%date%) and just check every once in a while if it has changed yet (as it does at midnight every day). IF NOT "%startdate%"=="%date%" it's the next day. Quote from: ghostdog74 on August 29, 2007, 12:44:05 AM if that's the case, it would be simpler to just schedule a job at or after 12 midnight to query the existence of the file, instead of looping everytime. Simpler and more logical. |
|
| 8502. |
Solve : Check for document name 1 in %1? |
|
Answer» Hi! IF "%1"=="document name nr 1" goto sameThank you! I will try that right away. /Karen |
|
| 8503. |
Solve : Open and Reading the file? |
|
Answer» HI, I just tried the second line in the batch file. Find the output below: C:\TEMP>sample.bat C:\TEMP>for /F "usebackq tokens=4 delims='" %I in (`findstr /i "reportSearchPath " "test.xml"`) do (set output=%I ) C:\TEMP>echo *actual name found:* %%I *actual name found:* %%I C:\TEMP>pause Press any key to continue . . . C:\TEMP> ... Sorry to confuse you but could you run that batch file with the example xml you supplied in the same folder...I ran the batch file with only the second statement in the same folder as the XML file.With the xml file called test.txt? See I don't know why that's not working sorry, logically it should and it does for me.The xml file is test.xml and not test.txt. It has to be saved as ".xml" Am trying with the same, but no result I meant test.xml, sorry. Looks like you'll have to go with the VBS for now, unless someone more expert than me in Batch can figure it out? Ghostdog, have you tried my script? Does it work for you?Quote from: DeltaSlaya on August 21, 2007, 10:51:46 PM Ghostdog, have you tried my script? Does it work for you?no, have not. can u post your latest version of the batch, and the format of the xml you have.Heres the latest code, I believe: Quote @echo off And the .xml file Quote <?xml version="1.0" encoding="utf-8" ?> You will also need a .pdf file of the same name in the xml's directory. The variables to set are clearly defined. Also could the OP please try that again, I noticed that it wasn't working because it was looking in extension not the file name?well, i think it does work. Code: [Select]C:\temp>dir /B test.pdf test.xml test1.pdf test1.xml C:\temp>cd .. C:\>test.bat 1 file(s) copied. Press any key to continue . . . C:\temp>dir /B PRV-INT-001-Provider NCPDP Interface Error Report 2.pdf test.pdf test.xml test1.pdf test1.xml however, only for 1 file. Needs extra for loops to iterate multiple xml files(or maybe not, by OP's requirements)..however that's another story.Well he said the most recent, thats what it does, yet for some reason does not do anything for them. I still believe on their end they entered something wrong or changed something. They should try the above, by itself with the right things changed and all the correct files and dirs present.Honestly, if the OP hasn't got my code working then there's no real point anyway. They said it would be run after each time the files have been created. Anyway, how I would have done it, using skip=. I'm just wondering why does skip=0 not work? It just skips the 0, I guess if skip is defined then you can't perform a command on the first line..Ghostdog, I ran the script with two files in the src folder. But, its moving only the 1st file and not the second one. Below is the output: C:\vbscript>vb_batch.bat C:\vbscript>CD C:\vbscript C:\vbscript>cscript /nologo vb_script.vbs found PRV-INT-001 PRV-INT-001 The string to replace is PRV-INT-001-Provider NCPDP Interface Error Report PRV-INT-001-Provider NCPDP Interface Error Report.pdf Renaming pdf ... found PRV-INT-002 PRV-INT-002 C:\vbscript> here's a modification Code: [Select]Dim objFSO,objFile,objRE,colMatches,oMatches Dim myFiles, srcFolder, dstFolder,dstFile,line,strToFind,strFileName Dim pdfBase,xmlBase,i,strContents Dim pdfStore(),pdfFullStore() 'define some array to store paths Set objFSO = CreateObject("Scripting.FileSystemObject") srcFolder="c:\temp" 'Server source folder location dstFolder="c:\temp" 'Destination Folder as desired i=0 'array counter For Each myFiles In objFSO.GetFolder(srcFolder).Files If objFSO.GetExtensionName(myFiles) = "pdf" Then pdfBase = objFSO.GetBaseName(myFiles) ReDim Preserve pdfStore(i) ReDim Preserve pdfFullStore(i) pdfStore(i)=pdfBase pdfFullStore(i)=myFiles i=i+1 End If Next For Each myFiles In objFSO.GetFolder(srcFolder).Files If objFSO.GetExtensionName(myFiles) = "xml" Then xmlBase = objFSO.GetBaseName(myFiles) For i=LBound(pdfStore) To UBound(pdfStore) If pdfStore(i) = xmlBase Then WScript.Echo "found " , xmlBase, pdfStore(i) strToFind = getString(myFiles) dstFile = strToFind&".pdf" objFSO.MoveFile pdfFullStore(i),dstFolder&"\"&dstFile End If Next End If Next Function getString(theFile) Set objRE = New RegExp objRE.Global = True objRE.IgnoreCase = False objRE.Pattern = "<reportSearchPath>.*/report\[@name='(.*?)'\]</reportSearchPath>" Set objFile=objFSO.OpenTextFile(theFile,1) strContents=objFile.ReadAll Set Matches = objRE.Execute(strContents) For Each match In Matches For Each smatch In match.Submatches result=Replace(smatch,":"," ") Next Next getString = result End Function output: Code: [Select]C:\vbscript>dir c:\temp /B test.pdf test.xml test1.pdf test1.xml C:\vbscript>cscript /nologo MoveCogNosReports2.vbs found test test found test1 test1 C:\vbscript>dir c:\temp /B PRV-INT-001 Provider NCPDP Interface Error Report.pdf PRV-INT-002 Provider NCPDP Interface Error Report.pdf test.xml test1.xml Hey! Tx... but am able to use the previous script. Vl run this script and let u know in case of NE issues |
|
| 8504. |
Solve : Command Prompt Doesn't Work? |
|
Answer» Quote from: smlh89450 on August 28, 2007, 09:25:33 AM PATH=C:\Program Files\Java\jdk1.6.0_01\bin;C:\Program Files\Java\jdk1.6.0_01\bin I thought as much! I was right! That is why shutdown.exe (and every other external command!!!!) won't work from the command prompt. Somehow your PATH variable has got seriously corrupted! This is a standard PATH as found on a new XP install Quote C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem Additions are SUPPOSED to be tacked on at the end, it looks like yours got nuked by whatever put that Java stuff there. Here's how to put things right 1. Right click My Computer, CHOOSE properties. 2. Choose Advanced tab. 3. Click on Environment Variables button. 4. in the SYSTEM Variables (lower part) Highlight PATH. (You have to scroll down) 5. Click the Edit button. 6. The "Edit System variable" dialog comes up. 7. The whole PATH string will be highlighted. Hit the END key to unhighlight it and position the typing cursor at the end. 8. Type a semicolon ( ; ) at the end so it reads like this C:\Program Files\Java\jdk1.6.0_01\bin;C:\Program Files\Java\jdk1.6.0_01\bin; 9. Copy this whole line to the clipboard C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem 10. Paste it at the end of your PATH so it looks like this C:\Program Files\Java\jdk1.6.0_01\bin;C:\Program Files\Java\jdk1.6.0_01\bin;C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem 11. OK three times to come right out. 12. Reboot 13. CHECK PATH looks like above. Thank you so much. Command Prompt works perfectly now!Nice piece of work contrex ! ! Thank you. |
|
| 8505. |
Solve : accessing properties from dos command line? |
|
Answer» 1. I need to FIGURE out how to access the properties tab from the command line. 1. I need to figure out how to access the properties tab from the command line.you can use vbscript: Code: [Select]Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace("C:\temp") For Each strFileName in objFolder.Items If strFileName = "myVideo.avi" Then For i = 0 to 34 WScript.Echo i, objFolder.GetDetailsOf(strFileName,i) Next Exit For End If Next save as myscript.vbs and on command prompt, type cscript /nologo myscript.vbs output: Code: [Select]Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. 0 myVideo.avi 1 418 KB 2 Video Clip 3 3/19/2002 5:26 AM 4 8/11/2007 11:06 AM 5 8/11/2007 11:06 AM 6 RA 7 Online 8 MYNEWNAME\Administrator 9 10 11 12 13 14 15 16 17 18 19 20 21 0:00:00 22 23 24 25 26 1024 x 768 27 1024 pixels 28 768 pixels 29 30 31 32 33 34 you can see that index 26-28 contains the video information Quote 2. A less important question, and possibly something better answered for python than for dos, but something else I'm trying to figure out: what's the best way to distinguish between directories and files in a folder? I'm looking for something like an "isDirectory()" kind of function. check out the Python docs for os.path module. Basically, to check if its a file, use os.path.isfile(), or directory use os.path.isdir() Thank you! This REPLY is ages late, but it took awhile before it was necessary for me to implement this code. Also, there's one change to make here, at least on my COMPUTER: "myVideo.avi" should be changed to "myVideo" - for whatever reason, you don't include the extension. This wasn't a problem for me (once I figured it out!) but may be a problem for others if they have multiple files with the same name but different extensions. On files with the same name it will pick the avi file though, I guess because it's earlier in the alphabet. |
|
| 8506. |
Solve : writing multiline .txt? |
|
Answer» no,i'm not crazy, i'm just a noobQuote from: Fantini on August 24, 2007, 03:15:50 PM I have this .bat: Open notepad or any editor you like, key in the code above save it as some name you like, and you are ready to go.you can go like this echo %%hello%%>file.txt or echo if '%%choice%%'=='3' goto terrewow >>tarrewow.batHi Fantini! I request you to please TRY to use the COPY CON filename.txt command for storing text in multilines. For e.g. C:\>COPY CON filename.txt write some text here with multilines. When writing of files is over press CTRL+Z button to save the contents of file. You may also press F6 button instead of CTRL+Z. |
|
| 8507. |
Solve : Formating Win 95 PC? |
|
Answer» I am discarding an old PC and TRYING to format the partitioned C and D hardrives. When I put in the DOS command "C: format", I get an error message : "Drive C: is currently in USE by another process aborting format" I don't know what is BLOCKING the format, nor how to clear it. TRAVEL to bootdisk.com and DLoad a Win98 bootdisk with CDRom support. |
|
| 8508. |
Solve : .bat that opens all .bat files in the subfolders of its folder? |
|
Answer» The subject pretty much tells it all I want a master bat to open all of them at once.I got a rough way to do it now but i want a bat file which will find all bat files of a certain name or not in the subfolders of a folder and execute them.Hi, I hope this will help you out. You can USE the ATTRIB command to protect as well as hide all the files inside any directory. you can use this command to hide. ATTRIB +s +r +h *.* In order to run each .bat file you can use CALL batchfilename.bat command in master batch file to run individual batch files. In fact you can also use START batchfilename.bat command to start a new window for running batch files. |
|
| 8509. |
Solve : 20 sec refresh error? |
|
Answer» I have the below code which assists me in running a PLASMA display screen. |
|
| 8510. |
Solve : Edit colon separated text file?? |
|
Answer» You did the slashy thing the wrong way round. / is not the same as \.You know what? You ROCK!!! I got both versions to work now, yay! |
|
| 8511. |
Solve : Mapping drives with a startup batch - Wi-Fi network...? |
|
Answer» Hi, |
|
| 8512. |
Solve : ERASED HARD DRIVE? |
|
Answer» I erased by hard drive due to some problems I was having. I have a boot disk and am trying to get my pc to boot windows so I can go in and restore my machine with the restore cds. I do not know what commands to type. Any and all info is greatly appreciated. Thanks. I erased by hard drive due to some problems I was having. I have a boot disk and am trying to get my pc to boot windows so I can go in and restore my machine with the restore cds. I do not know what commands to type. Any and all info is greatly appreciated. Thanks. By "boot disk", you mean a boot floppy disk - right? (as opposed to a boot CD disc) Not sure about "restore" cds. I've always used a generic, full install, Windows98 CD. 'Restore' sort of implies an OEM disc from a computer manufacturer. It might work the same though.... Boot from the floppy. Assuming it boots all ok, you will be at the command line. It will LOOK like: A:\> Put your Windows98 install CD disc in the CD drive. You need to navigate to that drive at the command line. The CD drive is most likely either D: drive or E: drive. (When I boot with my Win98 boot disk, my CD drive becomes E: ) To navigate to it, type the drive letter followed by a COLON, then HIT the enter key. As in: D: or E: If you chose a letter that is non-existant - i.e. no drive has that letter - you'll get an error message. No harm done, it is just telling you. Try D: If you get no error message, you've successfully changed to the D: drive. To find out if you are on the CD drive, use the dir command. Type dir Look for setup.exe . If you don't see it, try E: drive. Again, use the dir command to view the files. Once you find the setup program, execute it. Type setup followed by the enter key. That should launch the beginning of the install for you. I hope this helps. Thanks, but I am an idot because i still can not get to work. I have a boot floppy that lets me boot up ms dos. Then I have a HP Recovery CD and a Win 98SE boot cd. I can not get out of dos and get windows to load. Any more info would be greatly appreciated. Thanks. There is no setup in the dir.http://www.bootdisk.com/bootdisk.htm copy the OEM disk for Windows 98 and than boot your machine from this disk.... It will get you started. THANK YOU!THANK YOU!THANK YOU!THANK YOU!THANK YOU!THANK YOU! I APPRECIATE THE INFO IT DID THE TRICK, AND NOW I CAN FINISH SETTING UP MY NETWORK. THANKS SPOILER. MARK |
|
| 8513. |
Solve : Math in a batch? |
|
Answer» I havent been able to figure this out, nor have i been able to find anything about it. I was wondering about doing math in a batch. What operations can be done and how do I use the codes?Math in a batch file is very limited. Here are some examples. I havent been able to figure this out, nor have i been able to find anything about it. I was wondering about doing math in a batch. What operations can be done and how do I use the codes? http://www.google.co.uk/search?source=ig&hl=en&q=batch+file+arithmetic&btnG=Google+Search&meta=&aq=t&oq=batch+file+arithm Jesus, I thought you were the top programmer in your grade. Quote from: gamerx365 on 10 July 2007, 11:20:14 i hate my school but i wouldnt wreck the computers. I am in 10th grade now and I am the best programmer in the grade. I WANT to keep learning to keep my STATUS and so people can fear (and nerds to respect) my power and gift. Sure my creations are not the best or the most useful, but I have basically only been experimenting. I have created MANY websites and made games as well. You can see what I have done by going to some- http://freewebs.com/cloneshotel piczo.com/sethfilmfest. I do not want to hurt any computer at all. You have got all things wrong. I want to be a software engineer and someday own a software company. I do NOT want to be a nerd sitting at my computer in my underwear and hacking people or sending viruses. So far my topics are based on tricking my friends or trying to defeat my school computer security system because the moron IT department thinks they need to block everything including my harmless sites. If you were, surely you could simply use Google or type: Code: [Select]SET /? In a command prompt... In a Batch file: Code: [Select]set /a a=1+2 echo %a% pause Or in Command Prompt: Code: [Select]set /a 1+2 Both will give the answer 3 because 1+2=3 + = add - = subtract * = multiply / = divide I think there is more but those are the ones I know...at least all I can remember....Quote from: DeltaSlaya on August 15, 2007, 01:24:38 AM Jesus, I thought you were the top programmer in your grade. you are annoying as *censored* bringing all this back and make me feel like a queer. and I am because nobody in my school does stuff like this. and besides, even if I were a great programmer that doesnt mean I know everything. And how were I to know that set /? would tell me anything about math? I did do that to right before reading your post. No math in there. So why dont you shut up.Quote from: gamerx365 on August 15, 2007, 08:14:56 AM you are annoying as h**l bringing all this back and make me feel like a queer. I don't normally use language like that, but nobody can make you feel like a q***r unless you already are a q***r. If you feel that way, Gamer365, maybe it's nature's way of trying to tell you something? I guess they don't do PC in your trailer park? Quote So why dont you shut up. Or manners either. ---- leave me the h**l alone. ur probably the queer one. thats nasty BRO, nasty.Quote from: gamerx365 on August 15, 2007, 08:21:23 AM ---- leave me the h**l alone. ur probably the queer one. thats nasty bro, nasty. Maybe you should find a forum where people like you are welcome? (Ie not this one) This has degenerated into non-productive banter. Topic Closed.Hmm, I see gamerx365 still isn't making any friends...Oh great. I leave for a couple of months and we have turned into this? |
|
| 8514. |
Solve : starting second batch from 1st not working...? |
|
Answer» hello everyone, |
|
| 8515. |
Solve : cannot format disk? |
|
Answer» while booting up i get the following messages: this drive is not the one that came with it. i purchased it used without a drive, but it's not any different that any other laptop[highlight] and should run with a blank HD[/highlight]. this seems to be a bios or boot error Huh?i GUESS i'm wrong. it will boot and GIVE me an a prompt, anywayGood. You're 1/2 way there...what OS do you plan on installing on this machine ? ?i plan on copying my desktop with ghost. it has xp in it. will that work?Nope.how about i purchase a new HD this one is only 4GB anyway?It doesn't matter which HDD you try this on...you cannot simply copy an operating system from one machine to another and expect it to run...aside from the drivers all being different there are legal ISSUES as well. You need to purchase a Windows OS and go from there or explore the World of Linux free distros... patio. 8-) |
|
| 8516. |
Solve : Changing IP on a new processor.? |
|
Answer» I work on light rail trains and they have an intranet system for the signs, pa etc. Part of the IP address is the actual train number. If we swap out the passenger information processor, we MUST update the IP to match the train number. We had a train wrecked and was being worked on for weeks and it got parts taken. It's number is 116 and the one off the shelf is for 205 so needs to be changed to 116. Can anybody help? |
|
| 8517. |
Solve : batch file to run an application through all files in a folder? |
|
Answer» HI, I am starting my first batch file and I am stuck with the for loop. I am trying to write a batch file to run an audio application that does some statistical analysis through all wave FILES in a folder . I have the syntax of FOR loop but I am not ABLE to figure out how to run an executable through all files in a folder.. Can somebody please help me out ... Thanksfor %a in (*.*) do MyApplicationName %a if you do this in a batch file, you need to double-up the % symbols, thus: for %%a in (*.*) do MyApplicationName %%a Graham Yes or: Quote @echo off That will only work of course if the executable supports being passed a file like that. I used "" incase the filenames have spaces, I THINK that is required? |
|
| 8518. |
Solve : stopping a process? |
|
Answer» hey all,
Quote
type taskkill /? and tasklist /? at the prompt for full details You could also hit and hold down "control, alt, delete" in that order. You will see the Windows Task Manager. Click on the tab "Processes," select the process that you wish to stop, and click the button "End Process" at the bottom right of the window.Quote from: smlh89450 on August 27, 2007, 08:32:00 AM You could also hit and hold down "control, alt, delete" in that order. Very good, except he SPECIFICALLY asked for a command line method. Have you found your shutdown.exe yet? |
|
| 8519. |
Solve : FOR /F in DOS 7.10? |
|
Answer» I have a hard drive setup which is divided into 3 partitions. |
|
| 8520. |
Solve : Help with getting batch to a txt file? |
|
Answer» Hi I want to use a batch script to copy my IP address and SAVE it in a txt file. Is there anyway I could do that through dos? It would really help if somebody could help me. Thank you.Easy here ya go ! |
|
| 8521. |
Solve : Capture the file name as a parameter? |
|
Answer» Thanks :: This line turns echo off, which means only the output of commands is displayed. FOR STATEMENT DESCRIPTION: For /f "usebackq delims=" means that for will use backwards quotes, just a habit ` instead of '. The delims part means that the output should be treated a a whole phrase and not split into sections when a character is reached, not really necessary either. "%%I" defines a temporary variable to use in the for statement body. "in (`dir/b c:\a\*.txt`) do" For each line that the command "dir/b c:\*.txt" returns the following will be performed. "(" indicates start of body. "set name=%%~nI" Sets the variable %name% with the file name only (~N) in the variable %%I, ie no extension. ")" END body NOTE: You didn't mention the file was in a folder called "a". |
|
| 8522. |
Solve : Simple batch file? |
|
Answer» I am a REAL newbie to all this so forgive me if my question is very basic. |
|
| 8523. |
Solve : Weird Batch File Behaviour.? |
|
Answer» Ok, this is an extract of some code I have been writing. It's purpose is to check if there are characters ENTERED, ie not blank or any number of spaces. I tried using `findstr /r "[^a-z,0-9]"` for characters and using || if no characters were found but I couldn't get it to work. Anyway, this really has me CONFUSED... @echo off Now as you can see, the echoed string variable, (which if blank or spaces should return "ECHO is off."), is piped to the findstr command. Which with case-insensitivity and searching for the phrase "ECHO is on." (Does not work with off). Now you'd assume that entering no or only blank characters would make this return nothing, as the string "ECHO is off." should have been found as 'echo' is the same as 'echo '. Quote ECHO is off. Of course if you type "ECHO is on." as the input it is found. Though why is findstr finding echo is on, on blank entries when echo is clearly off? |
|
| 8524. |
Solve : Help with batch file - reg query and errorlevel? |
|
Answer» Hello, |
|
| 8525. |
Solve : Capture a part of the file name, how can i do it ?? |
|
Answer» eg . I have a file call "200907.txt" , I need to CAPTURE a part of the file NAME "07" to the other file. ...Yes, cityjack, ghostdog74 already told you where to look. |
|
| 8526. |
Solve : ad 7 days to a current date? |
|
Answer» Does anyone know how to do, under winxp, add 7 days to a current date. For example:
Since I don't have XP, I can't experiment with its scripting. So I can't tell you how to do it with only the COMMAND line of XP. You'll probably get an answer here soon from someone that can. I've seen a few members post here that appear to be very good with it. If however you don't get an answer soon, let me know. I can do it, under XP, but using a FREE utility program to manipulate the date, do the MATH, and set an environment variable(s), that you can then do with whatever you want. The method and batch files should work under XP just the same as they do under 98, etc. blackberry, Try this: [edit]@echo off CALL:jdate jd "%date%" SET /a jd+=10 CALL:jdate2date jd y m d echo.file.%m%/%d%/%y% pause GOTO:EOF :jdate ... :jdate2date ...[/edit] Get the :jdate function from here http://www.dostips.com/DtCodeCmdLib.php#jdate Get the :jdate2date function from here http://www.dostips.com/DtCodeCmdLib.php#jdate2date DOS IT HELP? |
|
| 8527. |
Solve : Set parameter? |
|
Answer» I would like to set a parameter into a bath FILE |
|
| 8528. |
Solve : File size limit !?? |
|
Answer» Hello contrexQuote from: DeltaSlaya on August 13, 2007, 03:03:23 AM Contrex, you're so leet... [edit] Duh - I see now! What happened to "mentor" Anyway, it's 2337 anyway, not ell ee ee tee. (I mean, come on GUYS!) Yea lol your rank is literally 'leet' and your post count was too. Not your advice lol. I wasn't aware you could do logical comparisons like that in strings.I have seen both "1" and "2" used for "L" in 1337 speak... which to use maybe I should start a thread. As for the strings I found a mistake, it doesn't work properly. Thank you "contrex" The code was very helpfull ... I developed a sql statement that does the same thing like your code and I put them to test ... in a couple of days I will see the results. Thank you very much PS : What means "leet" ... it comes from "elitte"? I didn't understand last 3-4 posts Quote from: victor.marincus on August 13, 2007, 04:00:06 AM PS : What means "leet" ... it comes from "elitte"?yeah. http://en.wikipedia.org/wiki/LeetHere's one way to do the number-as-string thing Quote Thank you contrex for the code ... I made few adjustments hope others need this ... @echo off setlocal enabledelayedexpansion for %%a in (dir "c:\Data\Data.mdf") do set filesize=%%~za set sizelimit=4000000000 set v1=%filesize% set v2=%sizelimit% REM find string lengths REM echo string to temp file REM escape 1st char with a caret in case it's a 1 or 2 REM which mucks up echo redirection, then REM read file bytes & subtract 2 for CR & LF echo ^%v1%> "%temp%\v1.txt" & for %%A in (%temp%\v1.txt) do set len1=%%~zA & set /a len1 -=2 echo ^%v2%> "%temp%\v2.txt" & for %%A in (%temp%\v2.txt) do set len2=%%~zA & set /a len2 -=2 REM compare string lengths and if they differ, REM add leading zeroes to the shorter one REM until it equals the other in length if %len1% GTR %len2% ( set ss=%v2% set /a padlen=%len1% & set /a padlen-=%len2% FOR /L %%z IN (1,1,%padlen%) DO set ss=0!ss! set v2=%ss% & goto end ) if %len1% EQU %len2% goto end if %len1% LSS %len2% ( set ss=%v1% set /a padlen=%len2% & set /a padlen-=%len1% FOR /L %%z IN (1,1,%padlen%) DO set ss=0!ss! set v1=%ss% & goto end ) :end REM do string comparison if "%v1%" GEQ "%v2%" ( echo %filesize% is ^>= limit %sizelimit% start /max backup.bat ) if "%v1%" LSS "%v2%" ( echo %filesize% is ^< limit %sizelimit% exit ) ------------------------------- Make sure, in line 3 ---for %%a in (dir "c:\Data\Data.mdf") do set filesize=%%~za--- NOT TO leave any spaces after ---=%%~za--- it will ruin the test. It took me a wile to figure it out. I forgot one space after and the comparison was always wrong(4Gb v.s. 40G in length). Now it's working well. Be carefull not to make mistakes like me. Thank you again contrex, you are the best... P.S. SQL sucks ... never managed to run a batch file from within .sql script file. |
|
| 8529. |
Solve : *Solved* (CD Rules) Changing the file type of files in subfolders? |
|
Answer» Quote from: Dusty on August 26, 2007, 05:18:11 PM A reason I have all .BAT files in one folder and have that folder in my Path is so that I can Call the files from anywhere in my file system. But that's just the way I prefer to do it, whether it's the most efficient method or would have the approval of the scripting gurus is open to argument Well, it's what I do as well (always have). I have a folder called c:\BATCH which is on my PATH and it has existed since my MS-DOS 3.30 days back in the early 1990s, I have copied it from computer to computer. The oldest file is dated 3rd March 1993. Quote from: DeltaSlaya on August 26, 2007, 02:47:26 AM Using batch in this way to hide files is just stupid. If you really must hide the files then here is a batch that may help: Quote from: NDog on August 26, 2007, 05:21:39 AM I just love it how people say don't do that its stupid, just do something else. It never fails to amaze me. Anyway I see you are writing a batch file because its fun and something you can be proud of thats why you call it a pet project which is just that. Sorry for any confusion, I don't mean to start a flame war here. I was not meaning to imply that the OPS desire to USE a batch script to perform this task was stupid. I meant that the methods they were employing to do so are not necessarily the most practical or effective. The LINK I suggested was simply to showcase other methods that could be used. They could try and figure out how that works, it's a far more effective method of achieving the task at hand. Feel free to use your own methods if you deem them more appropriate, or would like to experiment. It's always YOUR choice, not ours. |
|
| 8530. |
Solve : Another question =) About viewing text files from batch? |
|
Answer» In my batch program I want to be able to view a text file. Is there a way to do that besides edit? (I want to view the file inside the batch file while its RUNNING)Code: [Select]type /? yeah its like this but i need to be able to make more than one variable in the testfileQuote from: gamerx365 on August 22, 2007, 07:17:57 AM yeah its like this but i need to be able to make more than one variable in the testfile type FOR /? at the prompt, and surf through all the many many posts on this forum about processing text files. [sarcasm] Or did you want a batch file written for you? [/sarcasm] YEA use for and a couple of temporary variables, I'll give you a hint, but I'm not WRITING this it's easy enough to do what contrex said and figure it out yourself: Quote
|
|
| 8531. |
Solve : Find and Replace certain text in a REG File..???? |
|
Answer» is there anyway to find CERTAIN text in a reg file and then replace all of them with a variable..?? is there anyway to find certain text in a reg file and then replace all of them with a variable..??yes...search the forum for things like "search and replace". Why not LOAD it into Notepad and do the replacing there? gumbaz, I don't think you should be FOOLING around with your registry. You don't know enough to get out of any trouble you LAND in, and you'll hose your machine. We'll spend from now till Doomsday dealing with your "HELP PLZZZZZZZZZ!!!!!!!!!!" posts. |
|
| 8532. |
Solve : TASKLIST ERROR: Class not registered.??? |
|
Answer» where is the help at.. where is the help at..watch your language. also, we do not have to spoonfeed you every time. you should LEARN how to be more self reliant. As for your problem, i have another QNS to ask, maybe i have missed it or maybe it may sound stupid, but have you updated your virus scanner whatever brand of AV it is?AHH dont get so emo ghostdog74 ... its just letters MAN.. i applicate all your guys help though.. i will probably do a xp repair install soon to see if that fixes it.. yes my AV auto updates every 1 Hr..Quote its just letters man.. This is part of the problem...if you didn't notice we don't really do txspk her... It get's old. |
|
| 8533. |
Solve : any way to auto change the " SET DRIVE= " variable in this code? |
|
Answer» Is there any way to auto change the " SET DRIVE= " VARIABLE in this code to the next DRIVE LETTER in sequential order like: A, B, C, D Ect.. each time the code recycles, and when it reaches Z it starts back at A again.. :TOP Why does it need to keep creating the temp file over and over again? It only needs to make it once, and where is '*censored*.txt' coming from?Here I'll take a shot at making ONE. Quote from: BATCH SCRIPT @echo offmy mistake , typos I need to have more code instructions inside the " Do ( ) brackets " ... but i keep getting error syntaxes n stuff... example code: Code: [Select]:TOP >>"%temp%\letters.txt" echo A >>"%temp%\letters.txt" echo B >>"%temp%\letters.txt" echo C >>"%temp%\letters.txt" echo D >>"%temp%\letters.txt" echo E >>"%temp%\letters.txt" echo F >>"%temp%\letters.txt" echo G >>"%temp%\letters.txt" echo H >>"%temp%\letters.txt" echo I >>"%temp%\letters.txt" echo J >>"%temp%\letters.txt" echo K >>"%temp%\letters.txt" echo L >>"%temp%\letters.txt" echo M >>"%temp%\letters.txt" echo N >>"%temp%\letters.txt" echo O >>"%temp%\letters.txt" echo P >>"%temp%\letters.txt" echo Q >>"%temp%\letters.txt" echo R >>"%temp%\letters.txt" echo S >>"%temp%\letters.txt" echo T >>"%temp%\letters.txt" echo U >>"%temp%\letters.txt" echo V >>"%temp%\letters.txt" echo W >>"%temp%\letters.txt" echo X >>"%temp%\letters.txt" echo Y >>"%temp%\letters.txt" echo Z for /f "usebackq delims=" %%I in ("%temp%\letters.txt") DO ( DIR /B %%I: && GOTO OPEN-DRIVE START CALC && GOTO SKIP :OPEN-DRIVE START %%I: :SKIP ) PING 127.0.0.1 -n 10 GOTO TOP it doesn't seem to see or use the :OPEN-DRIVE or :SKIP Markers...?? what else could i do so i can use :markers inside the " Do ( ) brackets " ..??Well I don't THINK you can do that in a for statement, you can get out of it but to my knowledge you can't jump AROUND inside it. And what the *censored* are you trying to do here? Firstly if you're using '&&' there has to be a 'boolean' output, yes / no question sort of thing. I guess you meant & which is the same as a line-return. What are you trying to check that's true / false and what do you want to happen on each one? It needs to be like this: Quote for /f "usebackq delims=" %%I in ("%temp%\letters.txt") DO ( That should check if the letter drive exists (which I assume is what you are trying to do), then if it does it will open it in explorer and if not it will start Calculator. |
|
| 8534. |
Solve : store a file in a variable? |
|
Answer» I WANT to store a file that has just ONE number in it, in a variable. How can I do that. set /p var=<"filename.txt" |
|
| 8535. |
Solve : Hiding info in a batch file? |
|
Answer» Ok, I am trying to make a Batch file to enter my website. |
|
| 8536. |
Solve : Need batch file to look in correct user folder? |
|
Answer» Hi! I have a batch file that uses an input file located in the user's Documents and SETTINGS directory (C:\Documents and Settings\username\...file.txt). C:\>echo %userprofile%Perfect! Thank you both!! |
|
| 8537. |
Solve : Print out value in %1? |
|
Answer» Hi! echo %1 |
|
| 8538. |
Solve : need help from expert? |
|
Answer» hey |
|
| 8539. |
Solve : Check if a program exists? |
|
Answer» Does anyone know how to check if a progress exists witch DOS? I'd like to do the following Quote from: DeltaSlaya on August 22, 2007, 04:03:55 AM Firstly, I assume you don't mean DOS, you mean a Batch file that the command line will interpret commands from. I mean a batch file, correct. The programm is installed like a normal program with a lot of files and directories. Afcourse there is a difference between a program and a progress. You have for instance notepad, and you can only check if notepad is LAUNCHED if the process notepad.exe exists. The progress itself wouldn't be created by the batch file, it would just LAUNCH the programm by doing "c:/program.exe". Thanks for your help so far OH I see, you mean process... Yea that's easy ENOUGH: Quote How do you get a lists of taskes 'cause tasklist doesn't work here.. Thanks so far for your helpTasklist doesn't do anything at all? What OS?Quote from: DeltaSlaya on August 22, 2007, 04:22:31 PM Tasklist doesn't do anything at all? winxp homeAre you sure tasklist doesn't do anything? It should, shouldn't it ? ? Try the CODE again and tell me the exact output.tasklist doesn't come with XP home. you can download from this site. Here . you can also use pslist and pskill . Otherwise here's a vbscript. Code: [Select]status = 0 Set Processes = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2").ExecQuery("select * from Win32_Process") For each Process in Processes If Process.Description = "the_process_you_want_to_check.exe" Then status=1 End If Next If status = 0 Then Set WshShell = CreateObject("WScript.Shell") WshShell.Exec("program_2") End If |
|
| 8540. |
Solve : make batch go to next line? |
|
Answer» I have a batch file that does a whole lot of file COPYING. Each line is to copy to another server. Thank you for your help, Glenn, you are more than welcome! Have a nice day. Don't forget to come back if you have any more questions. |
|
| 8541. |
Solve : batch script? |
|
Answer» how to hide batch script while RUNNING ?CMDOW What does this script doSometimes, ignorance is bliss... frequently scripts are running on the server desktop, if any one access desktop and by mistakenly close the script window then problem, that is why i want hide the script windows.Oh, good. At least it's not something malicious like deleting files etc. WITHOUT the victim knowing. |
|
| 8542. |
Solve : Make BAT with colours and other language ... how ?? |
|
Answer» I want to make bat with other colour for background , text and other THING , without set the colour every time when i start bat file . |
|
| 8543. |
Solve : Error: Using "CD" Command to get to "Program Files"? |
|
Answer» I am having trouble getting to program files. I haven't got to them yet. But the commands still not working. Please state exactly what you are typing and the messages that you see. |
|
| 8544. |
Solve : Quotes around Directory with Spaces not working? |
|
Answer» I can't get my BATCH to work as needed: rmdir E:\Backup /S/Q MD E:\Backup XCOPY "C:\Documents and Settings\Chris" "E:\Backup" /f/i/r/h/y/s ECHO OFF cls ECHO * * * * * BACK-UP Complete * * * * * ECHO %date% - %time% PAUSE This does work though rmdir E:\Backup /S/Q MD E:\Backup XCOPY "C:\Icons" "E:\Backup" /f/i/r/h/y/s ECHO OFF cls ECHO * * * * * BACK-UP Complete * * * * * ECHO %date% - %time% PAUSE Any help would be great What do you mean when you SAY "doesn't work"? What actually happens? Quote from: contrex on August 26, 2007, 12:51:55 AM What do you mean when you say "doesn't work"? What actually happens?lol..was waiting for someone to ask that..Quote from: ghostdog74 on August 26, 2007, 02:49:22 AM Quote from: contrex on August 26, 2007, 12:51:55 AMWhat do you mean when you say "doesn't work"? What actually happens?lol..was waiting for someone to ask that.. As you will see elsewhere, this is the current "bee in my bonnet". Yes, it's difficult to diagnose a problem when there's not much else to go on besides, "I can't get my batch to work as needed". The more information and error information people give, the more high quality responses they'll get.Quote from: DeltaSlaya on August 26, 2007, 03:19:04 AM Yes, it's difficult to diagnose a problem when there's not much else to go on besides, "I can't get my batch to work as needed". You don't even get that in many cases. You just get "it doesn't work", which makes you wonder if cmd.exe has got corrupted in some weird and wonderful way that you never heard of before. I think many people suppose that computers should be able to do what they want them to do, rather than what they tell them to do. if you are really desperate try use the short name "C:\Docume~1\Chris"Sorry, I've isolated the problem and also changed the syntax a bit rmdir E:\Backup /S/Q MD E:\Backup MD E:\Backup\MyDocuments MD E:\Backup\Desktop XCOPY "C:\Documents and Settings\Chris\My Documents" E:\Backup\MyDocuments" /f/i/r/h/y/s XCOPY "C:\Documents and Settings\Chris\Desktop" E:\Backup\Desktop" /f/i/r/h/y/s ECHO OFF cls ECHO * * * * * BACK-UP Complete * * * * * ECHO %date% - %time% PAUSE the copy function of MyDocuments works FINE the Problem is when i try to copy anything from the desktop folder I get a PARSE Error. Quote from: contrex on August 26, 2007, 03:56:21 AM Quote from: DeltaSlaya on August 26, 2007, 03:19:04 AMi don't even bother thinking too much, after a while....Quote from: cfgcjm on August 26, 2007, 06:17:27 AMYes, it's difficult to diagnose a problem when there's not much else to go on besides, "I can't get my batch to work as needed". XCOPY "C:\Documents and Settings\Chris\Desktop" E:\Backup\Desktop" /f/i/r/h/y/s That's because Xvopy could not "parse" (i.e. interpret) the parameters that you gave it. The most common cause of this error is a missing quote, like in your posted command, at the beginning of the destination folder. |
|
| 8545. |
Solve : *.bat that rewrites a *.bat file? |
|
Answer» can i do that and how? I MEAN, rewrites the bat file with a UPDATED version.do it manually. There's no REASON you need to rewrite .bat files dynamically. if you need to, you have a CODE design problem.Read this thread |
|
| 8546. |
Solve : Writing BAT file to start execs? |
|
Answer» Ok so im trying to write a bacth file in notepad that starts .exe processes.... but I cant get past the spaces in folder names and such, im new to this but cant figure it out. and the "" parameters creates a title... so im lost. @echo off ...should work. It should start the Rulaunch app (IF the path & name are right and IF you have sufficient permissions and IF the file isn't damaged) and wait for you to press a key. After you are happy, you can delete the pause command. If it doesn't, are you sure: (1) you have typed the path and executable name correctly? (2) it is not ALREADY running? Quote from: contrex on August 25, 2007, 01:58:35 PM As so often happens on here, just saying "doesn't work" is not very informative.I think this should be added to the "Please read this" thread ...something like "Please do not say don't work...blah".... however, even so, no one seem to read that thread.You get these people who, after you've typed a 200 word guide to fix their problem, they just answer "Naw, doesn't work", and then expect you to guess what error messages they got. I am sure Coronadesign is not like that though. |
|
| 8547. |
Solve : Can't be KILLED? |
|
Answer» how to make a batchfile that can't be killed by another application or by taskkill /im cmd.exe ?? REGEDIT4 I don't know if you can kill services in normal WAYS, but I don't know if a command prompt window will be displayed either so this would be constantly running and if it's a loop could drain a lot of CPU time.you don't have to manually edit the registry. you can use the sc command. type sc /? to see how it can be used. btw, you can also kill a service. the question i want to ask is, why do you want to make something that can't be killed? Quote from: ghostdog74 on August 17, 2007, 09:01:39 PM you don't have to manually edit the registry. you can use the sc command. I want to make something (batchfile/executablefile) that cannot killed by a virus.. coz, my computer have been infected with a virus that kill all application I'll Run (antivirus ,PROCESS EXPLORER & etc).. i don't thing start as a service would solved my problem... thanks so far for reply.....Quote from: Fen_Li on August 23, 2007, 11:01:25 AM I want to make something (batchfile/executablefile) that cannot killed by a virus..why did you solve the problem the other way round. If you are infected with a virus, then clean the virus and make sure it doesn't happen again. Quote from: ghostdog74 on August 23, 2007, 03:15:46 PM why did you solve the problem the other way round. If you are infected with a virus, then clean the virus and make sure it doesn't happen again. I don't believe the explanation given. Like QUITE a number of "REASONS" given on here for wanting various kinds of help, I suspect the real reason is to make a virus, not fight one. |
|
| 8548. |
Solve : DOS COMMAND - NEED HELP? |
|
Answer» Hi @echo off |
|
| 8549. |
Solve : Timed Launch? |
|
Answer» hi all |
|
| 8550. |
Solve : adding a suffix to a file using batch? |
|
Answer» Quote from: DeltaSlaya on AUGUST 23, 2007, 04:44:49 PM No PING is generally the easiest way, unless you download "Wait" or something, I don't have a link on me. Though I THINK that GIVES you full CPU unfortunately. ftp://ftp.simtel.net/pub/simtelnet/msdos/batchutl/ ftp://ftp.simtel.net/pub/simtelnet/msdos/batchutl/wait.zip |
|