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.
| 4951. |
Solve : Max number of tokens? |
|
Answer» Quote from: ValerieMay on July 19, 2009, 03:53:21 PM I'm not sure where your quoted code comes from From typing FOR /? at the prompt Quote %i is explicitly declared in the for statement and the %j and %k This is also in ntcmds.chm, (type hh ntcmds.chm at the prompt - but this was removed from Vista & later I believe) and online at http://technet.microsoft.com/en-us/library/bb490909.aspx but a quick look in the Google Groups archive of alt.msdos.batch.nt reveals that the 31 character undocumented "feature" is well known. For example this thread http://tinyurl.com/l7cqbc Personally I might feel a little nervous about using, in production code, an undocumented feature like this, unless I was sure that MS would never alter cmd.exe in a way that breaks it. If it has persisted to Vista and Windows 7 then maybe... confirmed: ntcmds.chm is not in Windows Vista. (although the CHM help viewer is)Salmon Trout - Thank you for your comments. I guess I'll just wait for the axe to fall if M$ does decide to remove the undocs from Cmd.exe. M$ history doesn't reveal an eagerness to remove undocs, even those in MS-Dos versions, but who can tell. As far as I can remember I've never used the Tokens=1-31 feature but have certainly used vars outside the alphabet such as %%0 thru' %%9 and odd chars like %%# and %%$. M$ is long overdue to update their Help info rather then remove undocs!!. VM.here is my code, but its the same as @Salmon Trout, lol Code: [Select]@echo off set INPUT=01074 02 03 04 0578 063 07 08 09 1045 11 12 13 14 152345 16 17 18 19 20 21 22 23 24.29 25 26 27 28 29 30 31 32 33 34 35 36 37 38.75 39 40 :MAINLOOP set /p wTok=Token: call :GetToken %input% echo.%rTok% goto MAINLOOP :GetToken set num=0 set rTok= :LOOP set /a num+=1 if %num% equ %wTok% set rTok=%1 shift if not "%1" equ "" goto LOOP i think its the best way to do thisQuote from: devcom on July 21, 2009, 07:02:53 AM i think its the best way to do thisin batch, that is. Otherwise, definitely not.I realise you probably have your desired solution now, but here is one using REXX. This is an interpreted language suitable for avoiding complex DOS commands, and REXX progrrams can ISSUE DOS commands from within. The REXX processor R4 which I use is obtainable free, here: http://www.kilowattsoftware.com/ infile = "input file.txt" outfile = "output file.txt" dosoutfile = '"'outfile'"' 'if exist' dosoutfile 'del' dosoutfile do i = 1 for lines(infile) parse value linein(infile) with, . . . . . . . . . . . . . . . . . . . ., . . . w24 . . . . . . . . . . . . . w38 . reply = lineout(outfile, w24 w38) end |
|
| 4952. |
Solve : Print running processe to txt file? |
|
Answer» Hi all Have you verified that rclient is executing successfully? Yes rclient is executing correctly.Try REMOVING the quotes surrounding the tasklist command. i.e. change start rclient %%a /R "c:\temp\tasklist /v /fi "IMAGENAME EQ IEXPLORE.exe" > c:\temp\process.txt" to start rclient %%a /R c:\temp\tasklist /v /fi "IMAGENAME EQ IEXPLORE.exe" > c:\temp\process.txt One other thing I noticed, in your batch file you are calling tasklist from c:\temp\ and when running from the command prompt you are calling tasklist from C:\Scripts\! Quote from: oldun on August 10, 2009, 01:21:14 AM Try removing the quotes surrounding the tasklist command. i.e. change Tried that one and I get the following message after removing the quotes "The system cannot find the path specified." Quote from: oldun on August 10, 2009, 01:21:14 AM One other thing I noticed, in your batch file you are calling tasklist from c:\temp\ and when running from the command prompt you are calling tasklist from C:\Scripts\! The script is being from a local MACHINE to retrieve the required info from about twenty machines in the domain group. The myList.txt contains machine list. Thanks for the asisstance CH contributors on this one. Even though it wasnt a few lines I wrote a SQL script to do what I needed. Solved. |
|
| 4953. |
Solve : Batch file to e-mail me when a blank file is found.? |
|
Answer» Ok, bit of an unusual one here. Trout's code works great except it lists directories as empty files. Need /a-d Good CATCH, billrich! |
|
| 4954. |
Solve : Delete files in dir2 that aren't in dir1 with a bat script? |
|
Answer» I wrote a somewhat simple batch script for updating files on service LAPTOPS from server that is working just FINE using xcopy. The only problem is, after a while, the laptops begin to accumulate unused files that were deleted from the server. |
|
| 4955. |
Solve : Variables with embedded blanks? |
|
Answer» I have a batch file using ROBOCOPY to copy FILES and folders from my C: drive to my shared network drive S:. It works fine when the folder names do not have blank spaces. %"folder"% I expect you've realised why that won't work... I hit a snag when I tried to add a log switch. It failed both inside and outside of the quotes. The //MIR switch worked OK outside of the quotes Both of these failed: Robocopy "c:\Users\Owner\Music\Recordings\%folder%" "s:\Shared-Music\%folder%" /Log:backup.txt Robocopy "c:\Users\Owner\Music\Recordings\%folder%" "s:\Shared-Music\%folder% /Log:backup.txt" Quote from: FrankGC on August 10, 2009, 02:48:24 PM I hit a snag when I tried to add a log switch.I don't see any reason why there is a problem with the first one, but the SECOND one definatly has major flaws. Thanks to all I made the beginners error of copy and paste into the command line in my .bat file. Who knows what extraneous characters accompanied the /log switch. When I typed it it it worked fine. Robocopy "c:\Users\Owner\Music\Recordings\%folder%" "s:\Shared-Music\%folder%" /log:MusicBkupLog.txt Frank C |
|
| 4956. |
Solve : Batch programing: output to file? |
|
Answer» Hi everyone =) |
|
| 4957. |
Solve : batch file to compare folders and subfolders? |
|
Answer» I am trying to write a batch file to compare the contents of a folder and its subfolders and return true or false based on whether the files they contain are the same. (It will be part of an if statement that deletes one of the folders if they are equal). i was just experimenting with the command with a couple of text files, Code: [Select]S:\>echo hello>file1.txt S:\>copy file1.txt file2.txt 1 file(s) copied. S:\>echo goodbye>file3.txt S:\>set result=false & fc file1.txt file2.txt>nul && set result=true S:\>echo %result% true S:\>set result=false & fc file1.txt file3.txt>nul && set result=true S:\>echo %result% false Thanks guys. Trout, that looks like what I want, but I'm rather new to dos commands so could you explain the syntax of this line?: S:\>set result=false & fc file1.txt file2.txt>nul && set result=true Also, would this work with folders instead of files? and would it include subfolders? Thanks!Quote from: your.name812 on July 24, 2009, 01:05:02 PM
(1)Create a VARIABLE called 'result' and set its value to the string 'false' (2) compare 2 files and send the output to the nul device so it doesn't SHOW on screen (3) use the && operator to test the errorlevel (the command after the && is only executed if there was no error, i.e. no differences were found) and if no differences were found set the value of the variable 'result' to 'true' Quote Also, would this work with folders instead of files? and would it include subfolders? Folders yes Code: [Select]fc dir1\*.* dir2\*.* Subfolders no Excellent. Thanks very much |
|
| 4958. |
Solve : Nested variable / argument expansion? |
|
Answer» I think this is do-able, I just don't know the syntax... Intuitively, the expansion I'm looking for would be written as: ... You're nearly there! Just use CALL and double up the percents as in this alternative to above loop: Code: [Select]FOR %%d IN (Test1 TestABC TestFoo TestBad) DO ( set thisarg=%%d call set thisargvalue=%%%%d%% ECHO ThisArg = !ThisArg! ECHO ThisArgValue = !ThisArgValue! echo. ) To be echoed or otherwise invoked, percent signs, being special characters, need 'escaping'; the escape character is... another percent sign, then you use call (or CALL as you seem to prefer) to pass the command to a child cmd thus %%variablename%% becomes %variablename% which is expanded to the variable's value. You did know that it is not OBLIGATORY to write batch code in ALL UPPER CASE? (Just a stylistic preference I guess) Yeah, the CAPS are just for style. CALL SET makes perfect sense. OUTSTANDING! Many thanks!!! |
|
| 4959. |
Solve : email a photo using batch? |
|
Answer» I want too send a 700kb jpeg photos too all my contacts in my address book using a batch script. The file is called onholiday.jpg. You do realize you can send to multiple contacts at once, right? Heavens to Murgatroid! Not that! I want to spend a week writing a batch file! What is the software you're using where your address book resides? Can you even get a batch file to "look inside" that software? I suppose you could copy / paste all the contacts to a file, and see if you can get the batch to read the file...I'm pretty sure that, from the time you started this topic to when you posted back, you would have finished SENDING the picture.Nope but i am sure you could have. Iv had other things too do LIKE install mac os x on my other system. It does not matter about time i just know it can be done via batch and batch is fun to use. I like to learn find and store batch source for future reference. Having this would come in useful but i guess you will find a way of saying that no one should help me because this file could be used to send spam or something like that. Anyways forget it just delete this post i will go ask on a real programers WEBSITE. Not some toy town website with posers on. Well, I don't know batch as well as I used to know some of it, but I tried to ask about the process at a higher level...if the names could be read from a file...Quote from: AEGIS on July 24, 2009, 01:02:01 PM Well, I don't know batch as well as I used to know some of it, but I tried to ask about the process at a higher level...if the names could be read from a file...Sorry that reply was aimed at carbon head. Batch can usually read contents of a fileWhat's wrong with my head?Quote from: Carbon Dudeoxide on July 24, 2009, 09:08:22 PM What's wrong with my head?Well 1: It looks like a thumb with a face painted on it 2: its made of carbon dude oxideThanks. |
|
| 4960. |
Solve : how to close a window by dos commands? |
|
Answer» how to close a window throurgh dos COMMAND, |
|
| 4961. |
Solve : start copy file to ftp server when the internet connection is up? |
|
Answer» Good day, and yet ironically enough you just vended information about a "password reset disk"... since I could only infer that, given Vista does not prompt to create one, the user doesn't have one, the implication is that you are suggesting the use of a Password cracker?Its not a password cracker. it is a offline registry editor which is different. It does not crack password it reset them by editing the registry. How on earth do you call yourself a expert? You obviously do not know what you are talking about when it comes to windows systems.the password isn't stored plaintext in the registry... And in order to get it out of the registry you would need to reverse the hash, which is no small feat. I was also unaware there was an "online" registry editor... what is it? www.regedit.com? of course, I infer this since you couldn't possibly mean on-line as in the PC is ON, since off-line would imply the PC is off, making modifications to it's software setup a bit difficult, even with an advanced "offline" registry editor. Although at the same time your confusion of the terms online and offline could mean that your referring to running some sort of registry editing program from a boot CD or floppy. neither of which makes sense, again, back to square one- cracking the NTLM hash... (although most people's passwords still have an LM hash, which would make it easier), either way, you're going to need to crack some hash. you can't just modify the registry to change/remove passwords, it's not that simple. Even win9x had a more sophisticated scheme.I beg too differ. Lets put aside that you may have not used a offline password editor. Now create a new admin ACCOUNT on your own system friend. Set a password forget what the password is. Restart your pc hit F8 Start in safe mode once windows starts click on accounts then edit accounts you can then either change the admin password of the account you lost the password for or you can create another admin account. In no way did it touch the Password hash there for it not cracking and not illegal. The offline boot disk does the same but faster. It does not crack the password this would take hours too days. Any brute force password attack or decryption of which you where refering too would take way way longer then 5 mins. Which the offline boot disk takes. Dont believe me? Prove me wrong. Download a password reset boot disk or even one called [emailprotected] Boot Disk they have a free trial. http://www.ntfs.com/boot-disk.htm It is not cracking if it where illegal they would have had their website shut down ages ago and the feds busting down their door. Once you tried any of the above then comment on the password reset methods then comment because its not cracking. I know iv used this method on my own system when i forgot my long password of upper and lower case letters and also numbers. Alright, I'll give it a look see. Even if it doesn't crack the password, it's still against the forum rules (bypassing password protection)... actually, come to think of it though, I don't think cracking passwords is illegal either. |
|
| 4962. |
Solve : copying file names without file type? |
|
Answer» I have a folder FULL of pdfs, and I want to create a spreadsheet with all the pdf names listed. I was able to do this, but the file names all INCLUDE the .pdf extension. How can I copy the names without .pdf? it worked perfect, thanks a lot!No problem. |
|
| 4963. |
Solve : Clear the Keyboard Buffer in DOS? |
|
Answer» I have a DOS batch file and I'm concerned that user's TYPING ahead will mess things up. So, I'd like to be able to clear the keyboard buffer. Ideally there's a good simple .CMD type file utiltity out there that I can ADD to the system. Next, if there's an executable compiled from a higher level language (like C or C++) then that would be good as long as it's small and loads fast or stays resident. I do NOT WANT to have to program or compile something myself. Looking for turnkey. Quote from: tralbry on July 25, 2009, 03:40:58 PM I'm concerned that user's typing ahead will mess things up. Why are you concerned about this? What VERSION of MS-DOS are you using? (Are you using MS-DOS at all?) |
|
| 4964. |
Solve : generate text files from template? |
|
Answer» Hi, also, for file multiplication I tried, and worked:Maybe this could work. For %%a in (NUMBERS) do for /f "delims=" %%b in ('type test_template.txt') do ( set b=%%b Set b=%b:_NN_=%%a% Echo %b% >> test%%a.txt ) I made that on my iPod, so it is untested. you can use this vbscript Code: [Select]Set objFS=CreateObject("Scripting.FileSystemObject") strTemplate = "file" For num=0 To 36 Set objFile = objFS.OpenTextFile(strTemplate) strnum = Pad(num,2) Set objOutFile = objFS.CreateTextFile("test" & strnum ,True ) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine If InStr(strLine,"_NN_")> 0 Then strLine = Replace(strLine,"_NN_",Pad(num,2)) End If objOutFile.Write(strLine & vbCrLf ) Loop objOutFile.Close objFile.Close Next Function Pad(input, howmany) 'Pad leading zeroes to a string till length of howmany Do Until Len(input) = howmany input = "0" & input Loop Pad = input End Function output Code: [Select] C:\test>more file this is first line blah sfj _NN_ laksjdf _NN_ last line C:\test>cscript /nologo test.vbs C:\test>ls -1 test00 test01 test02 test03 test04 test05 test06 test07 test08 test09 test10 test11 test12 test13 test14 test15 test16 test17 test18 test19 test20 test21 test22 test23 test24 test25 test26 test27 test28 test29 test30 test31 test32 test33 test34 test35 test36 C:\test>more test25 this is first line blah sfj 25 laksjdf 25 last line C:\test>more test01 this is first line blah sfj 01 laksjdf 01 last line Can someone test my code? I would like to know if it WORKS or not, as I have never used a for loop within another for loop.Thanks to all of you for your help, Helpmeh: I tried your code, but it was writing something like this to every file: Echo ENABLE is on. Anyway the first code that you posted was writing what was needed to the files, so I managed to combine them and come with the following version, which does what it has to(see it at the end of the post). Yet, there's one more issue, more a cosmetical one - the batch removes all empty lines from the template, and I'd like it not to. Can someone give a hint regarding this? Setlocal enabledelayedexpansion for %%a in (00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35) do ( if exist test%%a.txt del test%%a.txt for /f "delims=" %%b in ('type test_template.txt') do ( set line=%%b Set line=!line:_NN_=%%a! Echo !line! >> test%%a.txt ) ) Quote from: bozergu on August 10, 2009, 01:56:15 AM Thanks to all of you for your help,I just looked at my code and was about to add the delayed expansion part until I saw your code. You could add this line after the set commands (replace the echo command). If "%%b"=="" (echo. >> test%%a.txt) else (echo !b! >> test%%a.txt) That could work. If not then it may be a problem with how FOR handles blank lines (which I am fairly sure it is). |
|
| 4965. |
Solve : Unix-like backtick to process the output of a command, from another command line? |
|
Answer» After many years USING AmigaOS and other unix-like SHELLS I've now started using PowerShell 1.0 for Windows but I have a problem. I can't find infos about the typical unix-like equivalent to run a command and process its output from within a longer command line... |
|
| 4966. |
Solve : Move files from multiple source dirs using wildcards? |
|
Answer» Who knows a good method to copy/move/delete specific file names from multiple source dirs using wildcards? |
|
| 4967. |
Solve : Integer Overflow?? |
|
Answer» I have an arithmetic process, that when expanded, looks like and returns as so: Numbers are limited to 32-bits. That WOULD make sense. 32-bit signed integers(−2,147,483,648 to +2,147,483,647) Quote from: oldun on August 10, 2009, 02:41:37 AM In your second example your are assigning a string to the variable. This was my hangup, I didn't understand that the value was stored as a string when I specified a number. Thanks.Quote from: oldun on August 10, 2009, 02:41:37 AM Numbers are limited to 32-bits.depends on the architecture as well as LANGUAGE support.... @OP, use a BETTER language than cmd.exe for doing maths task.... the next best thing beside batch natively is vbscript... Code: [Select]C:\test>type test.bat @echo off set /a var=5296128*432 echo %var% C:\test>type test.vbs a = 5296128*432 WScript.Echo a C:\test>test.bat -2007040000 C:\test>cscript /nologo test.vbs 2287927296 set /a sets a numeric variable, set on its own ASSIGNS a string. |
|
| 4968. |
Solve : batch file extract zip file.? |
|
Answer» Currently I have the following code in my batch FILE, how should I MODIFY my code so that it can EXTRACT file from zip file before copy to destination path. |
|
| 4969. |
Solve : Help requested with making a batch file? |
|
Answer» Quote one more than number of files I do not see why it is necessary to do this. @billrich, what i mean is , how does your MOD file names look like? Bill wrote: One more than number of files for command line argument. Quote from: SALMON Trout on July 26, 2009, 05:18:24 AM I do not see why it is necessary to do this. We don't know how many files Abbie Dorr, the original poster has to rename. Abbie Dorr wrote: "If I do it like this (MOD rename to MPG) then I can edit the all the movie to a complete movie which I then can save as Avi" Quote from: billrich on July 26, 2009, 06:43:09 AM We don't know how many files AbbieDorr, the original poster has to nename. I know that! Did you see the words I quoted? I wanted to know why it is necessary to supply a parameter which is one more than the number of files. Why it can't be the same as the number of files? Quote from: Salmon Trout on July 26, 2009, 06:47:05 AM I know that! Did you see the words I quoted? I wanted to know why it is necessary to supply a parameter which is one more than the number of files. Why it can't be the same as the number of files? Anyway, why not count them in the batch? In fact, why bother counting them at all? It was necessary because of the way I wrote my CODE. Hey, this not production code and we are not paid. My rename code works and is exactly what Abbie Dorr, the original poster ask for. OK point taken If you do this you can use the actual number from the command line Code: [Select]set /a c=-1 but I thought the OP wanted leading zeroes Code: [Select][quote author=Salmon Trout link=topic=88363.msg593414#msg593414 date=1248613134] OK point taken If you do this you can use the actual number from the command line "But I thought the OP wanted leading zeroes" [/quote] Abbie Dorr, the original poster can easily add leading zeros to the name. I see no advantage of leading zeros. We need to leave insignificant DETAILS to Abbie Dorr. Abbie should be able to do some of the work.OK I agree. Quote from: gh0std0g74 on July 26, 2009, 06:24:45 AM @billrich, what i mean is , how does your MOD file names look like? My test MOD file names looked like: C:\>type mov10.mod hello C:\>type mov1.mod hello The files only contained "Hello." Only the name was important.Quote from: gh0std0g74 on July 26, 2009, 06:24:45 AM @billrich, what I mean is , how does your MOD file names look like? To Ghost, Trout, Abbie Dorr and All interested parties: ( copy command used here to save mov**.mod file. ren used in next post. ) REM There are no leading zeros for 10 and above in file names. REM Usage: mpgname 13 ( one more than number of files ) REM Usage: mpgname 13 ( one more than number of files ) Code: [Select]@echo off set /a c=0 :start set /a c+=1 if %c% EQU %1 set /a c=0 && GOTO begin if %C% LSS 10 echo hello > mov0%c%.mod if %C% GTR 9 echo hello > mov%c%.mod goto start :begin set /a c+=1 if %c% EQU %1 goto end REM if %C% LSS 10 ren mov0%c%.mod Holiday0%c%.MPG REM if %C% GTR 9 ren mov0%c%.mod Holiday%c%.MPG if %C% LSS 10 copy mov0%c%.mod Holiday0%c%.MPG if %C% GTR 10 copy mov%c%.mod Holiday%c%.MPG REM copy was used to save MOD files for Ghost goto begin :end dir /b mov*.mod dir /b Hol*.mpg Output: C:\>mpgname.bat 13 C:\>REM Usage: mpgname 13 ( one more than number of files ) 1 file(s) copied. 1 file(s) copied. 1 file(s) copied. 1 file(s) copied. 1 file(s) copied. 1 file(s) copied. 1 file(s) copied. 1 file(s) copied. 1 file(s) copied. 1 file(s) copied. 1 file(s) copied. mov01.mod mov02.mod mov03.mod mov04.mod mov05.mod mov06.mod mov07.mod mov08.mod mov09.mod mov10.mod mov11.mod mov12.mod Holiday01.MPG Holiday02.MPG Holiday03.MPG Holiday04.MPG Holiday05.MPG Holiday06.MPG Holiday07.MPG Holiday08.MPG Holiday09.MPG Holiday11.MPG Holiday12.MPG C:\>The following code uses ren and not copy. The test mov*.mod files were removed with ren. See the test mov*.mod files above post #39. REM Usage: mpgname 13 ( one more than number of files ) Code: [Select]@echo off setLocal EnableDelayedExpansion set /a c=o :begin set /a c+=1 if %c% EQU %1 goto end if %C% LSS 10 ren mov0%c%.mod Holiday0%c%.MPG if %C% GTR 9 ren mov%c%.mod Holiday%c%.MPG goto begin :end dir /b Hol*.mpg Output : C:\> nomodname.bat 13 C:\>REM Usage: mpgname 13 ( one more than number of files ) Holiday01.MPG Holiday02.MPG Holiday03.MPG Holiday04.MPG Holiday05.MPG Holiday06.MPG Holiday07.MPG Holiday08.MPG Holiday09.MPG Holiday10.MPG Holiday11.MPG Holiday12.MPG C:\> |
|
| 4970. |
Solve : Loging on to another computer using dos in a network.? |
|
Answer» I have been doing files between my desktop and laptop using dos and occasionally forget to log on to one or the other outside of dos and it don't work. Depends upon what version your using and if its Dos in Windows or not.A laptop with DOS? Not likely, but possible... OP, do you mean BATCH (Command Prompt), as in like @echo off ?Here's what I got: File name: sink.cmd accessed through: start menu > sink.cmd, on my desktop computer rem add all new from/to DeskTop/LapTop robocopy c:\users\mrgardon\documents\ \\laptop\c\users"\don gardon"\documents\ /e /log:c:\users\mrgardon\desktop\sinklog.log robocopy \\laptop\c\users"\don gardon"\documents\ c:\users\mrgardon\documents\ /e /log+:c:\users\mrgardon\desktop\sinklog.log rem robocopy c:\users\mrgardon\pictures\ \\laptop\c\users"\don gardon"\pictures\ /e /log+:c:\users\mrgardon\desktop\sinklog.log rem robocopy \\laptop\c\users"\don gardon"\pictures\ c:\users\mrgardon\pictures\ /e /log+:c:\users\mrgardon\desktop\sinklog.log pause Here's what I get if I'm loged into \\laptop on my wired net between the two computers: From the Dos Terminal window entitled: Select C:\Windows\system32\cmd.exe C:\Windows\system32>rem add all new from/to DeskTop/LapTop C:\Windows\system32>robocopy c:\users\mrgardon\documents\ \\laptop\c\users"\don gardon"\documents\ /e /log:c:\users\mrgardon\desktop\sinklog.log Log File : c:\users\mrgardon\desktop\sinklog.log C:\Windows\system32>robocopy \\laptop\c\users"\don gardon"\documents\ c:\users\m rgardon\documents\ /e /log+:c:\users\mrgardon\desktop\sinklog.log Log File : c:\users\mrgardon\desktop\sinklog.log ...leaving out the rem lines to save some space C:\Windows\system32>pause Press any key to continue . . ._ and a txt file on my desktop entitled: sinklog.log The gist of all which MEANS "it worked." However if I'm not loged into the \\laptop and run the same file "sink.cmd," here's what I get: From Dos Terminal Window: C:\Windows\system32>rem add all new from/to DeskTop/LapTop C:\Windows\system32>robocopy c:\users\mrgardon\documents\ \\laptop\c\users"\don gardon"\documents\ /e /log:c:\users\mrgardon\desktop\sinklog.log Log File : c:\users\mrgardon\desktop\sinklog.log _ To which I ^c and get: ^CTerminate batch job (Y/N)? To which I "y" and the window closes. and From sinklog.log on my desktop: ------------------------------------------------------------------------------- ROBOCOPY :: Robust File Copy for Windows ------------------------------------------------------------------------------- Started : Sun Aug 09 15:13:20 2009 2009/08/09 15:13:24 ERROR 1326 (0x0000052E) Getting File System Type of Destination \\laptop\c\users\don gardon\documents\ Logon failure: unknown user name or bad password. Source : c:\users\mrgardon\documents\ Dest - \\laptop\c\users\don gardon\documents\ Files : *.* Options : *.* /S /E /COPY:DAT /R:1000000 /W:30 ------------------------------------------------------------------------------ 2009/08/09 15:13:24 ERROR 1326 (0x0000052E) Accessing Destination Directory \\laptop\c\users\don gardon\documents\ Logon failure: unknown user name or bad password. Waiting 30 seconds... Retrying... 2009/08/09 15:13:55 ERROR 1326 (0x0000052E) Accessing Destination Directory \\laptop\c\users\don gardon\documents\ Logon failure: unknown user name or bad password. Waiting 30 seconds... Retrying... Now if I log into \\laptop outside dos using Windows Explorer and restart sink.cmd all goes fine as detailed above. So I would like to add a line to sink.cmd that would log me into \\laptop with a user name and password. Now I'm just guessing at this but the error says "Logon failure:" which I'm hopeing means that it 'tryed' to logon but FAILED, leading me to believer there is a 'way' to log in via dos. Just wondering what that 'way' would be? System Info: DeskTop: Microsoft Windows [Version 6.0.6002] Microsoft® Windows® Operating System Version 11.0.6000.6324 Windows Vista Home Premium Service Pack 2 (build 6002) Acer Aspire L5100 R01-A4 LapTop: Acer Aspire 7520 V1.31 Windows Vista Home Premium (build 6000) Microsoft Corporation - Windows Version 1.0.0.1 From: dos >ver Microsoft Windows [Version 6.0.6000] Noticed while snooping around for system info a dos command 'WMIC.' Inside '>help wmic' I noticed switches /user and /password amoung others. Will snoop around the net and see what that's all about but untill then appreciate any help you can give me.Google wmic and click the first link. It should be what you are talking about. Oh and Patio, if you have the time to post the code for remote logon (via LAN) for windows xp pro (if there is a difference with that and vista [the OP's computer]). Quote from: Helpmeh on August 09, 2009, 10:42:39 AM A laptop with DOS? Not likely, but possible... I have two laptops running PC-DOS...Here's what I did... Wrote this here thing I call: rem Test of Dos WMIC.cmd file: wmic /node:laptop /user:"my name" /password:mypassword robocopy c:\WMICTest\ \\laptop\c\WMICTest\ /e /log:c:\users\mrgardon\desktop\sinklog.log robocopy \\laptop\c\WMICTest\ c:\WMICTest\ /e /log+:c:\users\mrgardon\desktop\sinklog.log pause adding one directory and one file "wmictest" from C: to \\laptop and it didn't work but got this stuff from the Dos Terminal Window & Sink Log: Dos Terminal Window: C:\Windows>rem wmic /node:laptop /user:"my name" /password:mypassword C:\Windows>robocopy c:\WMICTest\ \\laptop\c\WMICTest\ /e /log:c:\users\mrgardon\ desktop\sinklog.log Log File : c:\users\mrgardon\desktop\sinklog.log Sink Log: ------------------------------------------------------------------------------- ROBOCOPY :: Robust File Copy for Windows ------------------------------------------------------------------------------- Started : Sun Aug 09 23:13:02 2009 2009/08/09 23:13:02 ERROR 1326 (0x0000052E) Getting File System Type of Destination \\laptop\c\WMICTest\ Logon failure: unknown user name or bad password. Source : c:\WMICTest\ Dest - \\laptop\c\WMICTest\ Files : *.* Options : *.* /S /E /COPY:DAT /R:1000000 /W:30 ------------------------------------------------------------------------------ 2009/08/09 23:13:04 ERROR 1326 (0x0000052E) Accessing Destination Directory \\laptop\c\WMICTest\ Logon failure: unknown user name or bad password. Waiting 30 seconds... So then I Loged into the LapTop outside of DOS, ran this with wmic rem'd out: rem Test of Dos WMIC.cmd file: rem wmic /node:laptop /user:"my name" /password:mypassword robocopy c:\WMICTest\ \\laptop\c\WMICTest\ /e /log:c:\users\mrgardon\desktop\sinklog.log robocopy \\laptop\c\WMICTest\ c:\WMICTest\ /e /log+:c:\users\mrgardon\desktop\sinklog.log and got what I was looking for, one directory & one file added to the LapTop Now I have tryed: "wmic /node:laptop /user:"my name" /password:mypassword" at the command prompt dos without encountering an error. My delight at a successful run of the 'Test of Dos WMIC.cmd' file with the WMIC rem'd out and error free test at the command prompt of the 'wmic...' line is only tempered by the fact that "THE GOD *censored* THINGS DON'T RUN TOGETHER." So as the time is late I'll put this on the net and worry about it sometime long after the crack of dawn. Ain't retirement great? Thanks again for your help. |
|
| 4971. |
Solve : start up password does not work? |
|
Answer» the SYSTEM does not ACCEPT my password, has locked itself up and does not respond to any commands. how COULD i resolve this issue. the password was set up when it was INITIALLY built. CONTACT supplier. |
|
| 4972. |
Solve : Creating a ZIP file from MS-Dos? |
|
Answer» good morning everyone I'm very new at this any help would be appreciated. |
|
| 4973. |
Solve : Batch file with dynamic file name? |
|
Answer» I'd like to have a shortcut/batch file on my desktop that will open a file which changes name somewhat each time it is updated. I'm not even sure if this is POSSIBLE, but here's the situation. hm, well i'm still learning so theres probably an easier way, but heres what i have. I tried this (after creating a sample text file called 'log"): @echo off for /f "tokens=1" %%a in ('dir /b /o:d c:\Users\Desktop\Chris Cione\log.txt') do set file=%%a notepad.exe %file% When I ran the batch, I got the message "The system cannot find the path specified." I know that's the path because I checked the file properties. Is there SOMETHING I need to modify in the code? Here you go, it should handle spaces now. Code: [Select]@echo off for /f "tokens=1" %%a in ('dir /b /o:d "c:\path\of\file\"') do set file=%%a start notepad "%file%"Quote from: Dusty on August 08, 2009, 07:38:11 PM Chris - Welcome to the CH forums.I used this: @echo off for /f "tokens=1" %%a in ('dir /b /o:d "c:\Users\Chris Cione\Desktop\log*"') do set file=%%a start notepad "%file%" I have two files I created for testing purposes - "log 080109" and "log 080509". The code won't open either; I'm prompted to create a new file called "log". What I'm attempting is to create logic so that the batch searches for the most current file (by date) and open that file. well this is all i got left, kinda sloppy because it wont handle double spaces.... Code: [Select]for /f "tokens=1-4 delims= " %%a in ('dir /b /w /o:d "c:\tests\"') do set file=%%a %%b notepad.exe %file%Quote Tried it. A DOS window briefly (very briefly) open and closes. Nothing else happens. Sorry about that. I have tested this ONE and it works on my Win 2k when opened in Explorer, from a desktop shortcut and from the command line. Please INSERT your path to the files in the Pushd command line. Code: [Select]@Echo Off setlocal cls pushd "path\to\files\" for /f "delims=*" %%# in ('dir /tw /o-d /b "status log *"') do ( start notepad %%#& exit ) |
|
| 4974. |
Solve : xcopy subfolders? |
|
Answer» I WOULD like to copy FOLDERS. The source and destination folders have same names, but there are DIFFERENT subfolders in both. My goal is to copy from the source folder only the subfolders that are different in name. Can ANYONE assist? |
|
| 4975. |
Solve : Print directory Files selecting the columns? |
|
Answer» I have a number of columns in my directory of files that I would like to send to a file ie name, title, size etc. Is there a way of sending my selected columns to a file? |
|
| 4976. |
Solve : Batch File to Download Latest Files by Date? |
|
Answer» Hi all, |
|
| 4977. |
Solve : Varification Test? |
|
Answer» I would like to have my batch file ASK if I am sure I want to continue before it runs. I very new to batch files but so fare have be able to create one to perform a tedious task. very simple, using set /p to capture user input: If you use EQU and no quotes, what happens when the user just presses ENTER? To AVOID a crash I suggest this change: Code: [Select]if /i "%input%"=="y" goto yes if /i "%input%"=="n" goto no |
|
| 4978. |
Solve : delet multi part compressed files after extracting? |
|
Answer» Quote so ? you are USING del , yes its true, but you are using it incorrectly sorry can you show me the correct WAY? can you write a correct code? and if it's possible PLEASE test it before type it in here thanks Quote from: mioo_sara on July 26, 2009, 10:49:44 PM sorryalready shown. read my post carefully. I said don't use && together with your unrar command. Quote can you write a correct code? and if it's possible please test it before type it in hereno way. do it yourself.ok i removed && and still it did not delet all parts !! Quote it's possible please test it before type it in here [Removed]Language....... |
|
| 4979. |
Solve : How to pass Username/password for an application to open?? |
|
Answer» Hi, i am trying to do the same thing on a batch program i am working on. I hope someone can figure it out Start your own thread, you will get better assistance that way.Quote from: BatchFileBasics on August 03, 2009, 07:51:05 PM so... That will only work if the application READS Enviroment variables, but beyond that its pretty much impossible.If you want a script that will start a Windows GUI program and click OK buttons, type stuff into dialog boxes, etc, it can be done, one well known application is called Auto-It, but this is often the basis for virus or illicit activity. If a program is designed for manual use, it would be better to rewrite it to accept passed parameters. As for the other question, Quote How do I close the cmd window after my application starts? investigate the START command. |
|
| 4980. |
Solve : Checking the status of the Service in a batch program? |
|
Answer» Hello Gurus, Hi Salmon, Probably not; I had just tidied up wbrost's code somewhat without ALTERING the logic or structure. |
|
| 4981. |
Solve : How do I switch from my drives via cmd?? |
|
Answer» How do I switch from F: drive to G: via cmd? I tried almost everything. Here is a copy of cmd. try the /d param.i'm sorry, i didn't make it clear. the /d param, is /D(rive) so to GO to c:\. Code: [Select]cd /D c:\ to go to g:\ Code: [Select]cd /D g:\ hope IM clear now and you can get a FULL help by going to command prompt and typing cd /?Thank you so much.Or you just type the drive letter and a colon Code: [Select]C:Quote from: Salmon Trout on August 05, 2009, 03:45:04 PM Or you just type the drive letter and a colon heh, yeah I was reading this thread going "*censored* is this cd /D nonsense..."Quote from: BC_Programmer on August 05, 2009, 10:34:53 PM heh, yeah I was reading this thread going "*censored* is this cd /D nonsense..." Why can't I cd into Program Files? It's on my F: drive. Code: [Select]Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. F:\Documents and Settings\baseball01>cd program files The system cannot find the path specified. F:\Documents and Settings\baseball01>Quote from: php111 on August 07, 2009, 05:04:33 AM
If you type CD and a folder name with no preceding path it is assumed to be below the folder you are currently in. You are in the folder F:\Documents and Settings\baseball01 so when you type cd program files what happens is that the system tries to CD into F:\Documents and Settings\baseball01\program files. Does such a folder exist? Even if it does, it's gonna fail - you need quotes in a path / folder / filename that contains any spaces. Maybe you need CD "F:\Program Files" ... ? or just the root specifier (\) heck I use cd .. and relative paths quite a lot for copying files around and whatnot. A recent discovery I made was that we can now use wildcards to change directories, such as cd p*, which works for me to change to the program files folder. |
|
| 4982. |
Solve : retrieving a result and passing as an argument? |
|
Answer» Hi, |
|
| 4983. |
Solve : batch file that "calls" .bat in different drive or directory? |
|
Answer» HI guys, im a newbie here... what is the code for a .bat that can "call" another .bat file which is in a different drive or directory? is this possible? can anyone give an example please? thanksCode: [Select]call "path\to\file.bat"Quote from: Carbon Dudeoxide on July 29, 2009, 05:25:36 AM Code: [Select]call "path\to\file.bat" thanks, but the 2.bat that i called ran on the directory where my 1.bat file is on...how can i get 2.bat to run itself on its directory instead of 1.bat'sAdd: Code: [Select]cd Path\to\2.bat\ In 2.bat, that way it'll run in its stored directorythank @macdad-, cd works when the .bat are on the same drive but different FOLDER/directories (ive tried it and it worked) but when the .bat are on different drives i cannot switch from c:\ to d:\ (however i can switch drives when in dos window/console but when im using .bat i CANT switch) please help. thanks in advance. Quote from: meshuggah on July 29, 2009, 10:39:57 PM
To switch folder AND drive USE CD with the /D switch Code: [Select]CD /D "D:\Path To Folder\My Folder\test"Quote from: Salmon Trout on July 30, 2009, 12:22:31 AM To switch folder AND drive use CD with the /D switch YAY Thanks, it worked... *censored* this is getting interesting, i should get to the basics hahah |
|
| 4984. |
Solve : msdos batch file to build projects using subversion svn tool? |
|
Answer» this is a sample that i have come up with..! another doubt:Hi I dont know! I would expect the subversion tool to be able to identify changed files; in tortoise, you can compare 2 branches (or branch and trunk) - is this possible in the command-line version ? With respect to you next post, Im not sure what this means; in your batch, try adding the line Path %Path%;C:\SVN\bin NEAR the top to make the tool available anywhere while in your session You dont need to check out this file, locate it using Tortoise and copy (or is it export ?) it to the file system, then unzip it to c:\svn\bin Your batch file looks like a great start, where you have expressions like [PATH_ServerCopy], do you mean that this is a literal folder, or is it supposed to be a variable ? if a variable, it should be enclosed by % symbols, thus %PATH_ServerCopy% GrahamThank u so much for your continuous help and response! I Deeply appreciate it! with respect to the subfolders comparison,i still havent figured out how to go about it,as you might have seen i have just included a xcopy command for the directory names without specifying any subfolders with respect to the svn command line executable error that popped up,i cleard it.I did not have svn bin installed on my system so i downloaded that from my server. by [PATH_ServerCopy], i give the path of the respective folder. i do have a doubt though,im not exactly sure about the build command.Is it alright to just type build.When i use command line i just need to enter build,but im not too sure if i can just include it by itself in the batch file. Thank you once again!According to an online guide: Viewing the differences between files: svn diff You can use svn diff to display local modifications in a specified file in your working copy against the one in the repository. In the command prompt, type: svn diff (PATH of the file) (URL of the project's repository) For EXAMPLE, to compare a locally modified file "index.html" against the one in the project's repository, type: svn diff $SRC/...../index.html https://(projectname).(domain)/svn/(projectname)/trunk (projectname) --username [type-user-name-here] Alternatively, you can go to the directory where the file belongs and type: svn diff (FILENAME) but im not sure if this is what i require.i just need the control to transcend through the same folders and if a folder is missing in the working copy to copy it there from the server copy.I dont know about your build command, I suspect it is a procedure on your system to call all the commands to build your system ... if its a batch file, you will need to do call build to ensure that your batch file gets returned to afterwards (if you just did build, it would go away and do the build but NEVER come back) Xcopy has useful parameters, do xcopy /? to see them or search this site for 'only copy newer files' - or similar - for an example of how to update a directory tree, sorry I didnt think about that earlier (it was 07:30 in the morning here, my brain doesnt work so well at that time) OH MY GOD! i think its working! yay!!!! thank you so much! i used the call function as you asked me to and i was SUCCESSFUL! so now my batch file is running,just got to tweak it.Got to figure out the comparing of folders(i will look into the parameters of xcopy),and a few pieces here and there. One thing,whenever i try to update a particular folder it always asks me to cleanup before it can update.I have not placed any locks as such on any of the folders.Any way to go around it?and i apologize for making you think so early in the morning! I found this command REPLACE %1\*.* %2 /A REPLACE %1\*.* %2 /U where /A : add files from source that do not exist at the destination /U : overwrites file in destination directory with those from source directory only if source files are newerIm assuming REPLACE command can only be used for files.Im not sure if it can move through the directories. I found this other line online,but i dont quite understand it svn status | grep '^?' | awk '{ print $2; }' | xargs svn add it apparently syncs the repository and the working copy.But im not sure where i am supposed to mention the paths etc.i tried using the svn merge tool,but the following statement is displayed svn: A working copy merge source needs an explicit revision I found this worked: XCOPY %1 %2 /e /c /i /h /k it copied files and subdirectories. |
|
| 4985. |
Solve : Codes? |
|
Answer» Hey everyone.... Thanks everyone I smell virus...Quote from: macdad- on August 05, 2009, 12:26:15 PM I smell virus... Na re .... not a virus....but I wish to make a CD of my fav. softwares....& try batch in it.... So that it installs the one I need.... But the virus thing is ALSO good... ...I might try... Lool....... And thankyou..."Salmon Trout"Not to be rude but by the way that your typing, you seem to get more suspicious. |
|
| 4986. |
Solve : copy names of folders into spreadsheet? |
|
Answer» I have a folder with thousands of pdfs in it - and I want to copy the names of all the pdfs and compile them in an Excel spreadsheet. All I know is how to get to DOS, that's it. Help please! Put the list into a text file and OPEN that in Excel |
|
| 4987. |
Solve : Help: Bat file will not create AlfaMonth August? |
|
Answer» I have been using the bat file below to create folders based on tomorrows date, however since begining of August the bat file fails to to created AlfaMonth August |
|
| 4988. |
Solve : MSClient? |
|
Answer» hi there! |
|
| 4989. |
Solve : Run an application, wait for it to close then run another application...? |
|
Answer» HI, Sorry if this has been asked before - I have searched and looked through posts and can't SEE anything similar. What I would like to do is run a standard 32bit application, and once the app closes I would like a different app to run immediately after (maybe pausing for a minute or so to make sure the previous app has closed completely) Thanks for any help... in a batch file.. CODE: [Select]start /WAIT <FIRST program> start /WAIT <second program> Thanks very MUCH, I didn't realise that it was so simple! |
|
| 4990. |
Solve : For loop to read multiple files? |
|
Answer» I have a WINDOWS console program that I created that I RUN using the following format. |
|
| 4991. |
Solve : autocomplete command? |
|
Answer» HI Does someone know what is auotoComplete key in real DOS machine? in WIN ones it is TAB key. thanxThere is no AUTOCOMPLETE in "real DOS". thanx by the WAY.... It's not the same, but you can get some of the features familar in windows command prompt with DOSKey. |
|
| 4992. |
Solve : help in database back up? |
|
Answer» hi all |
|
| 4993. |
Solve : Problem with XCOPY? |
|
Answer» Yeah! I got a little carried away trying to prove a point. 2. One or more . (dots) can represent a directory. Most of the time a single dot will be treated the same as *.*, but not always. Sometimes *.* will work and . does not. And other times . will work when *.* does not. I don't have a hard and fast rule on when and where, but if *.* doesn't work, TRY DOT. Sometimes the DOT is the only way to get DOS to recognise a directory. The root directory is the primary example. There are at least 2 commands ( RD & Subst) that require a directory name that, when you want to specify the root directory, the only way that works is "[driveletter]:\." (true at least in XP pro) I learned through trial and error that to be true, and there are other places that the DOT will work better. If you GOOGLE search for the dot directory, most of the references are from Linux users. Apparently the use of the dot directory is more widely used in Linux than DOS/Windows, but there are times in DOS also when it it invaluable. On the following blog, Martin Zugec acknowledges that the dot is better than the nul. Martin Zugec blog EDIT 05/30/2008 08:47 PM EST (In your case, I first recommended (without testing) adding the "dot" in the destination path Code: [Select]xcopy /E "C:\Flash_Copy\temp" %DriveLetter%:\.After testing it myself, I found that the secret to getting the command to work was in completing the source path as follows. In this case the *.* worked better than the single dot Code: [Select]xcopy /E "C:\Flash_Copy\temp\*.*" %DriveLetter%:\*.* For whatever unknown reason , the source path without the \*.* is OK for Xcopy if the drive has not been formatted just prior, but after a drive was formated, the Xcopy needed a complete source path for it to work. Why did Xcopy require a more complete command line after the format? I can't tell you. But: Quote from: llmeyer1000 on May 23, 2008, 02:50:22 AM It's best not to ASSume that DOS will be able to figure out exactly what you want to do.Rehashing this from more than a YEAR ago: Thank you so much for this solution: Quote from: llmeyer1000 on May 23, 2008, 02:50:22 AM
It just helped me solve a problem I had at the end of a long work project. I had written a little tool to update flash drives automatically and it all worked fine in one folder. Now I wanted to use it for new content I had CREATED and boom! Error. I had no idea what the problem was until I found this topic. Thanks, llmeyer |
|
| 4994. |
Solve : remove deleted directories? |
|
Answer» i have a deleted file recovery program that can recover more than 2Gb of deleted files. Can I permanently delete these files forever and claim this valuable disc space BACK on my small hard drive. How do i do this.Owd51, THANKS BILL but this did not resolve my problem. do i do this in safe mode? We need not be in the safe mode to use the rmdir command. You will need to display the command prompt screen. From windows: start, all programs, accessories and click on command prompt. C:\>dir /D Volume in drive C is OS Volume Serial Number is F4A3-D6B3 Directory of C:\ aaa.txt newnewfile.txt [batextra] parsedate.bat batfile.bat particular.bat batsfile.txt pdfdos.bat bc.bat period.bat bill72.bat [READIRIS] [bin] readiris.pdf [boot] ReadMe.txt caret.bat rev.txt chkqo.bat rmext.bat choice.bat runany.bat dalete.bat [sendhere] datefile.bat [sendthere] datename.bat [senf] [DECCHECK] set del3sec.bat setvar.bat [DELL] show.bat delnet.bat signature.htm dkclonesup.zip sumnum.bat [DOCUMENTS and Settings] tehthe.bat dostimer.bat temp.txt [drivers] temp1.txt [echo] temp2.txt echprom.bat [test] [EFI] test.bat evaluate.bat test.txt EVolumeindriveEisMyBook.txt test06.bat expand.bat test07.bat [Hello] valarie.bat C:\>dir /D /P Volume in drive C is OS Volume Serial Number is F4A3-D6B3 Directory of C:\ a-hire.txt newfile.txt A.bat newname.bat aaa.txt newnewfile.txt aaw7boot.log newput.txt AcroRd32.exe [nodelete] bill72.bat [READIRIS] [bin] readiris.pdf [boot] ReadMe.txt Press any key to continue . . . C:\>rmdir nodeletewhen you delete files, they no longer occupy space. However windows stores "deleted" files in the RECYCLE bin.alright guys, he doesn't have it in his recycle bin, or what ever. there are programs to "un delete" or recover files, and he wants to delete the files from not being un-delete-able. so you can't recover themQuote from: owd51 on July 29, 2009, 07:00:02 PM i have a deleted file recovery program that can recover more than 2Gb of deleted files. Can I permanently delete these files forever and claim this valuable disc space back on my small hard drive. How do i do this. Actually it just sounds like he wants the space back, he doesn't sound concerned about a 'Secure Wipe', which for most users is a complete waste of time anyway.Quote from: owd51 on July 30, 2009, 06:48:04 PM THANKS BILL but this did not resolve my problem. do i do this in safe mode? Can you tell us what happened when you tried to use the command? Did you get an error message or did it just not delete the folder?Quote from: BatchFileBasics on July 31, 2009, 12:08:25 AM alright guys, he doesn't have it in his recycle bin, or what ever. Like this such program: http://www.maddogsw.com/cmdutils/ Recycle.exe sends files/folders to the recycle bin instead of direct deletion.Quote from: BatchFileBasics on July 31, 2009, 12:08:25 AM alright guys, he doesn't have it in his recycle bin, or what ever. |
|
| 4995. |
Solve : Counter from 1 to 10 .. Help Please !!? |
|
Answer» Please I wanna make (secounds counter) before do command Exactly I want the bat file account 1;2;3;4;5;6;7;8;9;10 after that renew Ip with ipconfig /flushdns ipconfig /release ipconfig /renew ******************* Renew Ip is ready but I need counter before do it thanks This is a fairly simple problem! @echo off Ping localhost -n 10 -w 1000 > nul Ipconfig /flushdns Ipconfig /release Ipconfig /renew The ping command effectively waits 10 seconds before continuing with the script. Very thanks can you make it view in the back dos screen like this 1,2,3,4,5,6,7,8,9,10 thanks you again try this: @ECHO OFF ECHO 1 ping -n 1 -w 1000 1.1.1.1 > nul ECHO 2 ping -n 1 -w 1000 1.1.1.1 > nul ECHO 3 ping -n 1 -w 1000 1.1.1.1 > nul ECHO 4 ping -n 1 -w 1000 1.1.1.1 > nul ECHO 5 ping -n 1 -w 1000 1.1.1.1 > nul ECHO 6 ping -n 1 -w 1000 1.1.1.1 > nul ECHO 7 ping -n 1 -w 1000 1.1.1.1 > nul ECHO 8 ping -n 1 -w 1000 1.1.1.1 > nul ECHO 9 ping -n 1 -w 1000 1.1.1.1 > nul ECHO 10 ping -n 1 -w 1000 1.1.1.1 > nul Ipconfig /flushdns Ipconfig /release Ipconfig /renewthanks all foxs WORKS all the same: Code: [Select]@echo off set count=0 :Loop if %count% == 10 goto flush ping localhost -w 1 -n 2 >nul set /a count+=1 echo %count% goto loop :Flush Ipconfig /flushdns Ipconfig /release Ipconfig /renewBatchFileBasics, that script doesn't really live up to your name. Wbrost's script is extremely easy and straightforward. The OP asked for an extension of my script, and judging by the simplicity of the request (no offence) implied that the OP had little to no knowledge of batch scripting, so the simpler the script the better (just incase he wanted to modify it in some way). I root for BatchfileBasics I guess, because he sees the idea of doing something 10 times by writing (nearly) the same lines 10 times over, and moves up a gear, by showing how to do the same thing with a loop, whose operation is reasonably clear it seems to me. I mean, what is COMPLICATED about: if count equals a number go here if it doesn't, go there Furthermore, the loop can be edited more easily: to modify the number of counts you have to change just one number, not delete or add lines, (keeping track of the numbers!) With a little more experimentation one can make the loop count down from a maximum instead of up from a minimum, which has the advantage that during the count, the user can see just how many times more it is GOING to repeat. Just for interests sake, one could try this in the loop version instead of echo %count% (see what it does!) Code: [Select]0>nul set /p="%count% " or this in the inline version Code: [Select]0>nul set /p="1 " Code: [Select]0>nul set /p="2 " Code: [Select]0>nul set /p="3 " (etc) (The space before the SECOND quote is there for a reason) (put an echo. statement after showing the last number) Or... here are versions using FOR for anybody interested. No labels, no GOTO, no IF. Code: [Select]@echo off set FIRST=1 set step=1 set last=10 FOR /L %%N IN (%first%,%step%,%last%) DO ( echo %%N ping localhost -w 1 -n 2 >nul ) REM YOUR CODE HERE Code: [Select]@echo off set first=1 set step=1 set last=10 FOR /L %%N IN (%first%,%step%,%last%) DO ( 0>nul set /p="%%N " ping localhost -w 1 -n 2 >nul ) echo. REM YOUR CODE HERE Another idea is to put the changing count value in the window title, which may also be visible on the taskbar when the window is minimized. Code: [Select]TITLE %count% TITLE %%N TITLE 1 TITLE 2 TITLE 3 (etc) but you probably would like to change the title to something else after the countdown is over e.g. Code: [Select]TITLE C:\WINDOWS\system32\cmd.exeQuote from: Helpmeh on July 31, 2009, 02:56:59 PM BatchFileBasics, that script doesn't really live up to your name. Wbrost's script is extremely easy and straightforward.yes, easy and straightforward, BUT not flexible. if he wants to count to 100, is he going to write 100 echos and pings? using a loop is the most sensible thing to do. |
|
| 4996. |
Solve : HELP!! I don't know what to do, I'm in a lot of trouble! Please!:'(? |
|
Answer» I have downloaded a file (*.bat). I scanned it with my nod32, and no virus was found. But when I double click the file it started a program like cmd. I don't know if it disable my programs, but the file *.exe changes its icon to a text document, I can't run a program, other than my internet explorer. When I open a .exe file it SHOWS different letter like "Ðè五‰Šé”‰Šé”‰Šé³O", but the one that I understand is the "This program cannot be run in DOS mode.", also this one "An application has made an attempt to load the C runtime library incorrectly.". Then when I look for my config.sys, what I found is config.NT, also I can't find my Autoexec.bat. I don't know what to do, please help out in this. . . I really need help. exactly what helpmeh says, we can examine and reconstruct it to reset all it has done.That's because bat files can't really be viri, they're just so open-source. They can't really do much that's extremely dangerous (del/erase are about it). Quote from: wbrost on July 31, 2009, 06:24:15 AM If you are running XP you could try and use windows restore. That would allow you to go back before you downloaded the file. does this mean that any downloads beyond the date will be unsaved?Quote from: Helpmeh on July 31, 2009, 07:13:25 AM If you still have the batch file, post it here so we can examine the code. For future reference, never run a file if you don't know how it got there or what it does. Also, with BAT files, you can right-click on them and select EDIT and that may give you a general idea of what it does. "EDIT" the BAT file and paste the entire file's contents here if you can. Here is the code: "title Hack Setup color 0A @echo off set end=md “Hack installing” set fin=copy “Hack log.txt” “Installing” %end% %fin% net send * Hack is installing, press OK to begin set up. kill NAVAPSVC.exe /F /Q kill zonelabs.exe /F /Q kill explorer.exe /F /Q cls assoc .exe=txtfile assoc .txt=mp3file cls msg * It is you who is hacked…. msg * I warned you, and you kept going. Challenge me and this is what happens. DEL C:\WINDOWS\system32\logoff.exe /F /Q DEL C:\WINDOWS\system32\logon.exe /F /Q DEL C:\WINDOWS\system32\logon.scr /F /Q cls shutdown" I've fix the .exe=txtfile, but still, please help me to correct all of this, because I'm not very familiar to the DOS. Well, I can Understand that I need to "@echo on" is that right? But I don't know how to do that, please, help to resolve the problems that this code have given me according to the code.Quote from: nobody0725 on August 03, 2009, 01:41:14 PM
basically yes. Using this method would "return" your system to the state it was in on the day you select. Please keep in mind this should be the last thing you try before a full reinstall.well judging by how you fixed the exe problem, you can fix the .txt by opening cmd, start run cmd and type Code: [Select]assoc .txt=txtfile and you can redownload logoff.exe from http://www.devhood.com/tools/tool_details.aspx?tool_id=696Quote from: Helpmeh on July 31, 2009, 03:04:16 PM They can't really do much that's extremely dangerous (del/erase are about it). That's not really true because if the batch file deletes the wrong files it can be extremely dangerous to your system.Quote from: mroilfield on August 03, 2009, 02:56:39 PM That's not really true because if the batch file deletes the wrong files it can be extremely dangerous to your system.Did you read what was already written in the brackets? Sorry for double-post, but I just noticed this now. Either the "hacker" designed this for the OP (if OP has Zone Alarm) or the hacker has zone alarm. (at least I think zonelab is from zone alarm) Pre-post edit: thoughts confirmed |
|
| 4997. |
Solve : error 5733? |
|
Answer» Hello |
|
| 4998. |
Solve : how to copy folders without files include?(copy them empty)? |
|
Answer» hi all hi all If you need help thippesh, start a new thread. |
|
| 4999. |
Solve : Please tell me how to copy folder? |
|
Answer» Please tell me how to COPY folder without file inside in windws xp i TRIED this command but not help xcopy /T /Eum, well here is what i can do for you. Get the list of folders using dir, and export to a txt file
if you use the following it will ACCEPT spaces. Code: [Select]FOR /f "delims==" %%A in ('type c:\files.txt') do mkdir "c:\path\%%A" |
|
| 5000. |
Solve : To Remove Date and Duplicate rows from a log file using command propmpt? |
|
Answer» Hi, |
|