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.
| 601. |
Solve : copy from within batch file to a text file ERROR!? |
|
Answer» i am trying to copy the line below to a new text file using batch file. The line is given below |
|
| 602. |
Solve : Updateing quicken 4? |
|
Answer» HI, |
|
| 603. |
Solve : Launch a new script within a .cmd file?? |
|
Answer» Hopefully a easy question for you guys, |
|
| 604. |
Solve : Reading from a txt file - spaces? |
|
Answer» Hi, FOR /F %1 IN (\\vfile1\cfp\ICT_Only_Templates\All_Scripts\Schemes.txt) do MD "\\vfile1\cfp\Housing Management\Housing Schemes\"%1 You just need to specify delimiters as carraige returns. FOR /F "delims=" %1 IN (\\vfile1\cfp\ICT_Only_Templates\All_Scripts\Schemes.txt) do MD "\\vfile1\cfp\Housing Management\Housing Schemes\"%1 Check out this post for a more detailed explaination. Quote from: Raven19528 on October 25, 2011, 09:48:34 AM You just need to specify delimiters as carraige returns. Hi - thanks for that, I tried this code but it did exactly the same thing i.e. as soon as it encountered a space it went to the next line - any thoughts?Sorry should give some more info - I get the following error when running your code but the error says these folders already exist but the folder is empty before running the code. I have blanked out some of the code as it has my name: [regaining space - attachment deleted by admin]If you are using these commands from a batch script you need to double up on the % e.g. %%1 The directories being created MAY have spaces in the name so you must include the trailing %%1 inside the " like so: Code: [Select]FOR /F "delims=" %%1 IN (\\vfile1\cfp\ICT_Only_Templates\All_Scripts\Schemes.txt) do MD "\\vfile1\cfp\Housing Management\Housing Schemes\%%1" Quote from: Dusty on October 26, 2011, 03:00:44 AM If you are using these commands from a batch script you need to double up on the % e.g. %%1 Thanks - I'm just running this directly from a command prompt. When I run the above code I get the attached message?? [regaining space - attachment deleted by admin]OK, thanks for the clarification, now REVERT to single % Quote from: Dusty on October 26, 2011, 03:17:06 AM OK, thanks for the clarification, now revert to single % Whoohoo - that works great, big thanks for that and to everyone who HELPED me get there.Thanks for coming back to REPORT your success. Good luck. |
|
| 605. |
Solve : Help with cd and mkdir (I think)? |
|
Answer» My computer is a gateway using win7 with AMD Dual Core II X2 240 ~2.8 ghz, 4 gigs of ram, DX11, 500 gig hdd (can't find the manufacturer). The whole computer is a touch screen bought from bestbuy. I use the computer for home and work. My question is about installing python (from learnpythonthehardway.org). Capitalization matters? Not where Windows filenames and paths are concerned. Please explain more. |
|
| 606. |
Solve : A program to...? |
|
Answer» So I'm designing a program to take over the world... Anyone want to help? (I'm bored today and thought I would entertain myself) So I'm designing a program to take over the world... Anyone want to help? That sounds like a GENIUS plan brain. . . Reminds me of watching that show when I was a kid.POIT ! ! Quote from: patio on October 26, 2011, 02:39:33 PM POIT ! !Quote Poit 128 up, 15 downUrban Dictionary. Quote from: Geek-9pm on October 26, 2011, 04:20:28 PM Dextor's Lab shows "->poit<-" when Dextor teleports. I loved that show too! So ideas...Dextor vs. Brain...who wins? I vote Dextor, he was able to keep a 3,000 acre labratory (not sure exact size, but it was big) hidden from his parents through the entire length of the show and Brain was never actually able to take over the world. So Dextor definetly gets a POINT for achieving goals. Quote from: Raven19528 on October 26, 2011, 04:44:42 PM So ideas...Dextor vs. Brain...who wins?Twilight Sparkle. |
|
| 607. |
Solve : Checking File Size? |
|
Answer» I need to write a batch file that goes out, checks the size of a file (ie asjob.txt) and DETERMINES whether or not this is a 0k file or not, If the file is 0k it should goto the next check, if it is 1k or more it should execute a psservice/stop COMMAND. |
|
| 608. |
Solve : PRIMARY AND LOGICAL DRIVES? |
|
Answer» :'(I KEEP TRYING TO REINSTALL WIN98 AFTER FOLLOWING INSTRUCTIONS ON CH000569 AND GET THE MESSAGE WINDOWS SET UP REQUIRER 7340032 BYTES AVAILAIBLE AND THEN JUST STOPSAll Caps is SHOUTING. No need to shout, we HEAR you. Message you are getting means: "hard drive is full". |
|
| 609. |
Solve : Print and save log of activity of computer.? |
|
Answer» Hi, |
|
| 610. |
Solve : Spinning / when running a file in a batch? |
|
Answer» when I START a XP Hotfix in a batch, how do I GET a line to SPIN showing that the machine is WORKING? |
|
| 611. |
Solve : Batch file to copy from local drive to net share.? |
|
Answer» I have the following batch file that I would like to MODIFY too copy the FILES that it lists in the Allfiles.txt file to the U:\. Can anyone assist with the proper syntax. |
|
| 612. |
Solve : Clear a file?? |
|
Answer» Okay, this is a very nooby question, but I'm no expert. |
|
| 613. |
Solve : Batch file Var output help needed? |
|
Answer» I need a few things echo. this is a test 1. pass literal strings Code: [Select]echo. this is a test call :test test1 call :test test2 call :test test3 :end 2. pass variables Code: [Select]echo. this is a test call :test %test1% call :test %test2% call :test %test3% :end Either case, subroutine shows what is passed: Code: [Select]:test1 echo. This is %1 goto :eofThanks for your help. That work like i needed. now another question about var's im doing the following subroutine: Code: [Select] call :s1ofc "Server 1" PING 192.168.1.110 -n 1| FIND "bytes=" > NUL call :s2ofc "Server 1" XCOPY *.* "\\192.168.1.110\C$\Test Folder" /EXCLUDE:copyfiles.cfg /s/y/z/v/k call :s3ofc "Server 1" GOTO :EOF ::===========================:: :: Screen1 ouput for copying :: ::===========================:: :s1ofc echo. echo. ----------------------------------------------- echo. echo. Copying files to %1 echo. echo. Connecting to %1... GOTO :EOF ::===========================:: :: Screen2 ouput for copying :: ::===========================:: :s2ofc IF ERRORLEVEL 1 ECHO. Connection failed... && ECHO. Skipping %1...&& echo %date% %time% Connecting to %1 failed>> .\LOG.TXT && ECHO. && GOTO :EOF echo. Connection established... echo. echo. Copying STARTED... echo. pause GOTO :EOF ::===========================:: :: Screen3 ouput for copying :: ::===========================:: :s3ofc echo. if errorlevel 4 echo "An error has be found" && echo. Please check the log.txt file. && echo %date% %time% Insufficient disk access, space, on %1>> .\LOG.TXT if errorlevel 5 echo echo %date% %time% Disk write error occur99red on %1>> .\LOG.TXT echo. echo. Copying files to %1 Complete... PING 1.0.0.0 -n 1 -w 2000 >NUL GOTO :EOF I need help with my if errorlevel's I want that If the errorlevel is true that on that line i can enter in a var and pass it back to the original routine to run an if STATEMENT. Code: [Select]call :s1ofc "Server 1" PING 192.168.1.110 -n 1| FIND "bytes=" > NUL IF erq1=1 goto: eof call :s2ofc "Server 1" XCOPY *.* "\\192.168.1.110\C$\Test Folder" /EXCLUDE:copyfiles.cfg /s/y/z/v/k call :s3ofc "Server 1" GOTO :EOF ::===========================:: :: Screen2 ouput for copying :: ::===========================:: :s2ofc set erq1=0 IF ERRORLEVEL 1 ECHO. Connection failed... && ECHO. Skipping %1...&& echo %date% %time% Connecting to %1 failed>> .\LOG.TXT && ECHO. && erq1=1 && GOTO :EOF echo. Connection established... echo. echo. Copying started... echo. pause GOTO :EOF but for some reason erq1 always equals 0 Thoughts?if you use the archaic obsolete MS-DOS method in this format: (N is a number) IF ERRORLEVEL N action You need to understand that the test is passed if the errorlevel is N or greater. Thus if you are testing for different errorlevels you have to do the tests in descending order. The action is usually GOTO a label because otherwise every level below the one you want will be executed also. (do you understand why?) if errorlevel 5 action if errorlevel 4 action if errorlevel 3 action if errorlevel 2 action if errorlevel 1 action Better to use the (since Windows 2000) NT type errorlevel variable where the order does not matter and you can specify more tests and the test can be exactly what you want e.g. if %errorlevel% equ 4 action if %errorlevel% gtr 0 action Also, in Windows, && does not mean what you think it does. ok i see why i would want to use %errorlevel% how would i fix this line if i should not use &&? Code: [Select]if %errorlevel% 5 echo echo %date% %time% Disk write error occurred on %1>> .\LOG.TXT if %errorlevel% 4 echo "An error has be found" && echo. Please check the log.txt file. && echo %date% %time% Insufficient disk access, space, on %1>> .\LOG.TXT Now is there anyway to output a list of files that have an error? Currently it will only tell me that there was an error but not what files were the cause. Is there something better to use than xcopy? (FREE for commercial use) Running on XP win7 server2003 & server2008 Quote how would i fix this line if i should not use &&? Just use one ampersand (&) if you merely want to join commands in one line In Unix and Windows & is the command separator command1 & command2 means "execute command1 and then execute command2" && is a conditional EXECUTION operator command1 && command2 means "execute command1 and if command1 returns a zero errorlevel then execute command2" The opposite is || command1 || command2 means "execute command1 and if command1 returns a non-zero errorlevel then execute command2" Quote Is there something better to use than xcopy? (Free for commercial use) Many people like Robocopy Thanks |
|
| 614. |
Solve : Batch keypress help? |
|
Answer» Ok so i have a program that closes every 30 minutes and i wanted it to loop so it goes infinity. first my thought camed to that i could make it loop every 30 min but then i remembered that i have to set it up after every startup so now i wonder if any of u experienced bat coders could make me a bat code or say the commands to make it happen This would be a lot more easily done in a VBScript. I'm currently getting my feet wet with VB, so I do not know all of the nuances about the coding, but as a rough go at it, try:Quote from: sobbo90 on November 03, 2011, 01:36:50 PM wont work ?= :S any help please :S You need quotation marks and a file extension, I think. Like: Code: [Select]WshShell.Run "C:\blah\blah\blah\blah.exe", 1Syntax error, line 3 of the script. Ah I see Cheezey beat me to it. The shell object expects a string. Strings have quotes. If the program you want to run is not on the PATH then you need the full path, filename and extension. Quote from: Cheezey on November 03, 2011, 02:00:31 PM You need quotation marks and a file extension, I think.Ok fixed that and now i did put it in the same directory did fix quotes and get full location but it says it cant find the file This is error picture : Uploaded with ImageShack.us The Fel:(Error) means that it cannot find the file This is the code Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell") Do WshShell.Run "C:\Users\Linus\Desktop\wowrob\WowRobot Evolution", 1 WshShell.Sleep 60 WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}" WshShell.Sleep 1000 WshShell.SendKeys "{TAB}{TAB}{ENTER}" WshShell.Sleep 1000 WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}" WshShell.Sleep 1860000 LoopIs WowRobot Evolution a program file? Quote from: Salmon Trout on November 03, 2011, 02:04:16 PM Syntax error, line 3 of the script. Ah I see Cheezey beat me to it. The shell object expects a string. Strings have quotes. If the program you want to run is not on the PATH then you need the full path, filename and extension. OKEY tried to fix this but now i get error where it says that it cant find it even thoe i did put the script in same directory and did full path length this is code Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell") Do WshShell.Run "C:\Users\Linus\Desktop\wowrob\WowRobot Evolution", 1 WshShell.Sleep 60 WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}" WshShell.Sleep 1000 WshShell.SendKeys "{TAB}{TAB}{ENTER}" WshShell.Sleep 1000 WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}" WshShell.Sleep 1860000 Loop Uploaded with ImageShack.us At the "Fel" (ErroR) it says cannot find the file. Quote from: Salmon Trout on November 03, 2011, 02:26:33 PM Is WowRobot Evolution a program file?Quote from: Salmon Trout on November 03, 2011, 02:26:33 PM Is WowRobot Evolution a program file?Filetype is Program.exetestet to add .exe on the end of the file path. no success Quote from: Salmon Trout on November 03, 2011, 02:29:42 PM Okey i changed some directory names and file names etc... do u see anything in this script that should't work? Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell") Do WshShell.Run "C:\Users\Linus\Desktop\wowrob\hejsan\Enkel.exe", 1 WshShell.Sleep 60 WshShell.SendKeys "{TAB}{ENTER}" WshShell.Sleep 1000 WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}" WshShell.Sleep 1000 WshShell.SendKeys "{TAB}{TAB}{ENTER}" WshShell.Sleep 1000 WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}" WshShell.Sleep 1860000 Loopdoes this file and path exist exactly as SHOWN? "C:\Users\Linus\Desktop\wowrob\hejsan\Enkel.exe" Don't PM for special help. You should wait for Raven to answer, it's his script. Shouldn't it be Wscript.sleep? Quote from: Salmon Trout on November 03, 2011, 02:55:21 PM does this file and path exist exactly as shown? Thanks now its no error and yes it did i dont know if i did get dot or something in it cause now it launches and same with sleep command. i only have one problem left after i started the program i need it to get "TARGETED" as the window that i am on so that the tab and enter have any effect cause now it only starts and then it presses tab and enter in the same folder as the script Yeah sorry for that wont do that again |
|
| 615. |
Solve : xcopy error report to txt file help.? |
|
Answer» I am copying large amounts of files to different servers using the following command |
|
| 616. |
Solve : How to delay the execution of a file?? |
|
Answer» I want to know how to delay the execution of a batch file for some hours |
|
| 617. |
Solve : getting a file's directory? |
|
Answer» Hi all, |
|
| 618. |
Solve : Extract network alias in batch file? |
|
Answer» I am trying to use the hostname as a conditional in a batch file. I would like to use the alias (not %COMPUTERNAME% mind you) I added to the hosts file and have to make no other CHANGES (i.e. set an env var at startup). This would be equivalent to doing a "hostname -a" in UNIX and greping for the alias name. I haven't found any EVIDENCE that parsing exists using batch so I guess I just need a command that will return that alias. Is it out there or any nifty WORK arounds? |
|
| 619. |
Solve : How do u use EDLIN i a batch file?? |
|
Answer» If i use edlin in a batch file it loses control because of the * prompt that appears after the edlin execution. Is there anyway to over come this???Is there any other command that can SEARCH and replace stringsyou might be ABLE to use the expanded dos options to do the JOB.. Look for info on the SET command in its expanded form. It allows for string replacements and other features. |
|
| 620. |
Solve : BAT file to copy a file to a different name every time? |
|
Answer» I would like to be able to do the following in a bat file , if possible , Tomorrow, the code! Code: [SELECT]echo off set maxnum=5 set filenum=1 :loop if exist chauffeur%filenum%.accdb set /a filenum +=1 & goto loop ren chauffeur.accdb chauffeur%filenum%.accdb if %filenum% leq %maxnum% goto end set /a oldnum=1 set /a stopnum=%maxnum%+1 :renum set /a newnum=%oldnum%-1 ren chauffeur%oldnum%.accdb chauffeur%newnum%.accdb set /a oldnum+=1 if %oldnum% leq %stopnum% goto renum del chauffeur0.accdb :endHi Salmon Trout Your code works well but what it doesn't do is retain the original chauffeu.accdb therefore I would have to change my desktop SHORTCUT everytime I ran my DB best regards Ian Quote from: ian1956 on November 05, 2011, 07:28:24 AM what it doesn't do is retain the original chauffeu.accdb therefore I would have to change my desktop shortcut everytime I ran my DB Answered via PM but we might as well let the whole world see... Code: [Select]echo off set maxnum=5 set filenum=1 :loop if exist chauffeur%filenum%.accdb set /a filenum +=1 & goto loop REM uncomment the next line if you want to RENAME chauffeur.accdb to the next available number (1-5) REM ren chauffeur.accdb chauffeur%filenum%.accdb > nul REM uncomment the next line if you want to COPY chauffeur.accdb to the next available number (1-5) REM copy chauffeur.accdb chauffeur%filenum%.accdb > nul if %filenum% leq %maxnum% goto end set /a oldnum=1 set /a stopnum=%maxnum%+1 :renum set /a newnum=%oldnum%-1 ren chauffeur%oldnum%.accdb chauffeur%newnum%.accdb set /a oldnum+=1 if %oldnum% leq %stopnum% goto renum del chauffeur0.accdb :end Note: chauffeur0.accdb is the oldest file that has dropped off the bottom of the list; instead of simply deleting it you could move it somewhere else to archive it if you wanted to. Hi Salmon Trout Much appreciated works well Best regards Ian |
|
| 621. |
Solve : How to make a batch file full screen without making a shortcut?? |
|
Answer» Does anyone here know how to make a batch file full screen without making a shortcut?This question was answered before by SlayerOf. |
|
| 622. |
Solve : renaming multiple files in a different directory? |
|
Answer» Hi all, |
|
| 623. |
Solve : [Tutorial] Manually Encrypting Batch Files [Easy]? |
|
Answer» Ok, this is my first official tutorial. Here we go! Where would someone on here find it? in the bin? Quote from: BC_Programmer on November 05, 2011, 10:05:04 PM in the bin?Well said BC, well said. Quote from: lmsmi1 on November 05, 2011, 07:06:58 PM this is my first official tutorial What is "official" about it? It is your very far from first piece of useless nonsense. Why should anybody accept a "tutorial" from an idiot? Or rather a bumptious kid who has LEARNED a few basic commands, but not how to use them for anything anybody would want. By now you should have got the hint, but it seems not... Quote from: BC_Programmer on November 05, 2011, 10:05:04 PM in the bin? *Facepalm* How old are you?Tutorial: In Windows 7 environment (not sure about other OS's): 1. Right-click on batch file; Select Properties 2. Click Advanced button in General Tab 3. Check mark "Encrypt contents to secure data" It's manual because it involves the user doing something. It's encryption because it is ACTUALLY encrypting the file. Wow. That seems a LOT easier than the originally proposed method. Maybe I should get into this official tutorial business. Quote from: Raven19528 on November 08, 2011, 11:58:05 AM Tutorial: In Windows 7 environment (not sure about other OS's):Yes! Go for it! Your first Official Tutoriall! |
|
| 624. |
Solve : how to bypass the no valid cd rom device selected? |
|
Answer» Hi everyone. I am new to this board and hope someone can help me. My husband just brought home and old Dell 486/33 that has been upgraded to a 486/66. The cd rome has been taken out and I just keep getting the message Device driver not found, No valid cd rom device selected. (1) How do I bypass this? and is a cd rom actually needed to run ms dos on this computer ? (2) and can I install windows 98 on this computer? I have a windows setup hard disc and a windows startup hard disc. (3) Do I need to install a cd rom and get a cd with windows on it to do this? Hope you all can help I am learning little by little about computers. ...Dell 486/33 that has been upgraded to a 486/66. The cd rome has been taken out and I just keep getting the message Device driver not found, No valid cd rom device selected. (1) How do I bypass this? and is a cd rom actually needed to run ms dos on this computer ? (2) and can I install windows 98 on this computer? I have a windows setup hard disc and a windows startup hard disc. (3) Do I need to install a cd rom and get a cd with windows on it to do this? ... Dell 486/66 PROBABLY has DOS 6.22 and Win3.1. (1) Ignore it. CDROM not required for DOS. (2) Win98 requires the following: http://support.microsoft.com/default.aspx?scid=kb;en-us;182751 486/66 w/16MB is minimum. It might work but, it's gonna be slow. You said you "...have a windows setup hard disc and a windows startup hard disc. .." You mean CD, not disc? (3) Install of Win98 requires CDROM, unless you have Win98 on floppy disks. Thanks for answering _commando. I meant to say I have windows 98 setup and windows 98 startup on a floppy disc. Do I have what I need or do I need windows 98 on cd? I tried these floppy disc and kept getting an a:> prompt and I don't know what to put in the prompt. Thanks Ronda Quote ...I meant to say I have windows 98 setup and windows 98 startup on a floppy disc. ... Not ENOUGH. You need the installation CD. Win98 CD is bootable. Floppy disk is for computers that don't support booting from CD's. Yours probably won't boot from CD. Dell 486/66 was manufactured around 1992. You can look it up on Dell's website. Look for service tag number on the back of the computer. Okay, now that I know what I need to get windows installed. Can you tell me what to do now when I boot up this computer and it has a C:/ prompt. You said I can ignore the cd rjom part. But it won't go pass the C:/ prompt. Thanks again Computer_Commando RondaType "win" (without the quotes). If Windows is there it's probably Win3.1. More info on Win3.1: http://www.wown.com/j_helmig/win31.htm That was it! It worked! Thanks. I see something called Microsoft Mail and I don't have a password for this. Could this computer be stripped of everything but this? Thanks Ronda Quote ... (1) Probably an old version. Ignore it...for now. (2) You could...but I wouldn't recommend it. I have a 486/66 notebook...tried to put Win98, then Win95...no luck. Almost booted, but couldn't completely plug and play all the old hardware. It has no CDROM and no FDD. WENT back to MSDOS6.22/Win3.1. I still use DOS for image backups on my WinXP/Win2k/Win98 computer. Keep what you got and learn DOS. Many DOS commands still work at the Command Prompt. Once you use DOS and Win3.1, you may find WinXP easier to use and understand. Much of the "source code" has not changed. okay computer_commando, Thanks a lot you were a lot of help. Nice to have people like you online that can help people. I guess it's up to my husband and whatever he wants to do next. Thanks Again. Bye. Ronda Hunt |
|
| 625. |
Solve : FTP - Capture Success messages? |
|
Answer» Hi all. |
|
| 626. |
Solve : input paramatertar? |
|
Answer» Hi, can anyone hellp me please.....? |
|
| 627. |
Solve : Batch file to pre-pend text to multiple filenames? |
|
Answer» Hi folks, from the Windows7 command line, the following command prepends "text_" to all csv files in the current directory |
|
| 628. |
Solve : File and directory names? |
|
Answer» Running XP Home. |
|
| 629. |
Solve : batch file in two parts? |
|
Answer» I have been asked t help write a BATCH FILE. |
|
| 630. |
Solve : Mind is blown, should be easiest batch file ever, but stumped.? |
|
Answer» Hello Everyone, thanks for your help in advanced. If you don't need this to be self contained in a batch, here is how I would do it: GREAT IDEA, the only problem is, this drive is almost full and its 6 tb. I just started at this job as the FIRST IT person and no one has gone through these files in almost 8 years. So that would be a ton of copying. Quote i cant find ANYTHING on google How hard did you look? I Googled "list files older than date". This told me about the forfiles command. I next Googled for "forfiles" which got me the MICROSOFT documentation page. Included in the examples is this one liner. Total TIME 2 minutes approx. Code: [Select]forfiles /s /m *.* /d -365 /c "cmd /c echo path is at LEAST one year old." |
|
| 631. |
Solve : variable increment? |
|
Answer» Hello! |
|
| 632. |
Solve : String Replace with Wildcard? |
|
Answer» This question is regarding modifying text files |
|
| 633. |
Solve : delete first character of all lines in a text file.? |
|
Answer» Here is a sample of the text file: |
|
| 634. |
Solve : delete all zero byte files in a folder . . .? |
|
Answer» I know everyone is saying this, but I REALLY am new at attempting batch files, so please forgive any stupid QUESTIONS. |
|
| 635. |
Solve : how can i count number of lines of text files in one folder into one test file u? |
|
Answer» Dear All, |
|
| 636. |
Solve : Remake a config file? |
|
Answer» Sorry for the weak subject. I didn't come up with a better one since English isn't my spoken language Code: [Select]GstAudio.AudioQuality 1GstAudio.CarRadio 0GstAudio.DialogueVolume 0.700000GstAudio.MusicVolume 0.700000GstAudio.SoundSystemSize 20GstAudio.StereoMode 1GstAudio.VOLanguage 0GstAudio.Volume 1.000000GstAudio.YourSoundSystem 2GstRender.AmbientOcclusion 0GstRender.AnisotropicFilter 2GstRender.AntiAliasingDeferred 0GstRender.AntiAliasingPost 0GstRender.Brightness 0.779070GstRender.Contrast 0.500000GstRender.EffectsQuality 1GstRender.Enlighten 1GstRender.FieldOfView 80.000000GstRender.FullscreenEnabled 1 Is this all on one single line? If this is a 1-off job, then use an editor replace Gst with {cr}Gst where {cr} is a lineend Quote from: Salmon TROUT on November 25, 2011, 03:07:38 AM Is this all on one single line? Hmm it's like 60 lines totaly. Quote from: Apexi on November 25, 2011, 03:19:36 AM Yes, exactly as i posted in the first code tag. hard to tell because it is wrapped Quote from: Salmon Trout on November 25, 2011, 03:20:59 AM hard to tell because it is wrapped Sorry my missunderstanding. I edited my post.please post whole of the file you wish to convert. Is it 1 line or 60 lines? Lol that was easy. Just opended up the file with MS Office and it manage to break the lines right. But still to learn something new i want to know how to make the batch file. But i cant paste the whole config since would fill up the entire site, as i said, it's huge. To explain the problem in details. I want a linebreak before every "Gst"Hard to do in batch, easy to do in VBscript. Set oFSO = CreateObject("Scripting.FileSystemObject") sFile = wscript.arguments(0) sdelm = wscript.arguments(1) Set oFile = oFSO.OpenTextFile(sFile, 1) sMyString = oFile.ReadLine oFile.Close aSplitstring=Split(sMyString, sDelm, -1, 1) For j = 1 To UBound(aSplitstring) wscript.echo sDelm & aSplitstring(j) Next Save script as (for example) convert.vbs This is PROF_SAVE_profile GstAudio.AudioQuality 1GstAudio.CarRadio 0GstAudio.DialogueVolume 0.700000GstAudio.MusicVolume 0.700000GstAudio.SoundSystemSize 20GstAudio.StereoMode 1GstAudio.VOLanguage 0GstAudio.Volume 1.000000GstAudio.YourSoundSystem 2GstRender.AmbientOcclusion 0GstRender.AnisotropicFilter 2GstRender.AntiAliasingDeferred 0GstRender.AntiAliasingPost 0GstRender.Brightness 0.779070GstRender.Contrast 0.500000GstRender.EffectsQuality 1GstRender.Enlighten 1GstRender.FieldOfView 80.000000GstRender.FullscreenEnabled 1 at the command line, or in a batch: cscript //nologo convert.vbs "PROF_SAVE_profile" "Gst" > "PROF_SAVE_profile.new" This is PROF_SAVE_profile.new GstAudio.AudioQuality 1 GstAudio.CarRadio 0 GstAudio.DialogueVolume 0.700000 GstAudio.MusicVolume 0.700000 GstAudio.SoundSystemSize 20 GstAudio.StereoMode 1 GstAudio.VOLanguage 0 GstAudio.Volume 1.000000 GstAudio.YourSoundSystem 2 GstRender.AmbientOcclusion 0 GstRender.AnisotropicFilter 2 GstRender.AntiAliasingDeferred 0 GstRender.AntiAliasingPost 0 GstRender.Brightness 0.779070 GstRender.Contrast 0.500000 GstRender.EffectsQuality 1 GstRender.Enlighten 1 GstRender.FieldOfView 80.000000 GstRender.FullscreenEnabled 1 How long before the "After I've made edits, how do I join them all back together?" question... ? Quote from: Salmon Trout on November 25, 2011, 04:37:40 AM How long before the "After I've made edits, how do I join them all back together?" question... ? Sorry dont understand what you are meaning, but thanks for the explanation on the script. I've never try VBscript before so it's just funny to learn something new. Cheers Quote from: Apexi on November 25, 2011, 08:23:13 AM Sorry dont understand what you are meaning The game REQUIRES this Code: [Select]GstAudio.AudioQuality 1GstAudio.CarRadio 0GstAudio.DialogueVolume 0.700000GstAudio.MusicVolume 0.700000GstAudio.SoundSystemSize 20... You wanted to GET this Code: [Select]GstAudio.AudioQuality 1GstAudio.CarRadio 0 GstAudio.DialogueVolume 0.700000 GstAudio.MusicVolume 0.700000 GstAudio.SoundSystemSize 20 ... Why? What is it for? The game cannot read the new format, can it? I thought you might want to edit the VALUES. Quote from: Salmon Trout Why? What is it for? The game cannot read the new format, can it? I thought you might want to edit the values. Ah now i undestand. It belongs to Battlefield 3, and as usally i always check the config file on all games a play since some developer doesn't show all options under settings ingame. This way make it just easier to read and change. Later on when you start up the game it automatically change back to the old layout, but the settings you change remains.I don't know what editor or viewing method you you are using where you see all the entries mashed up against each other; they should be one to a line I think (see link below, scroll down for raw data) have you tried Wordpad? http://pastebin.com/jKGBnbPq |
|
| 637. |
Solve : Program Trouble? |
|
Answer» So I have the following program that I am trying to run. I've managed to take a screenshot of the program before it dies (it dies quickly) and it says "( was unexpected at this time". I have combed over the entire code, and even the input files, but I can't find any "("s that are out of PLACE or not needed. I am using this program to combine two fairly extensive lists of people into one. I just can't see what is causing that error. Also, what format could I use to write it all in one line? Would this do the same thing? Nearly - you only need one ampersand ("&"). In Unix and Windows, the ampersand syntax is as follows: command1 & command2 - execute command1 and then execute command2 command1 && command2 - execute command1 and only if command1 exits with no error, execute command2 note also command1 || command2 - execute command1 and only if command1 exits with an error, execute command2 |
|
| 638. |
Solve : DOS to Monitor? |
|
Answer» Hi it can show the command lines used to start a program, allowing otherwise IDENTICAL processes to be distinguished.Thanks Quote from: keirjohnharry on November 11, 2011, 01:28:44 PM E.G- I presume when I sync my iPhone in iTunes it runs thousands of horribly long lines of dos and these are presented in a nice GUI . your presumption is wrong. |
|
| 639. |
Solve : Changing file extension case? |
|
Answer» From a batch script, how do I change all specific file extension combinations to all lower case The OP is trying to avoid changing the .CSV2 extension. I suppose a little modification can take care of that: No modification needed. The OP's requirement is catered for. The *.csv filespec will only find files with the extension (any case, upper lower or a mixture) ".csv" that is, a dot and the three characters (only) c , s and v - to include .csv2 it would have to be *.csv* or *.csv? Before: Code: [Select]C:\Users\Test>dir *.csv* Volume in drive C is Win07 Volume Serial Number is E4DB-A92A Directory of C:\Users\Test 15/11/2011 18:30 16 animals.CsV 12/11/2011 10:05 44 Myquotes.cSv 11/11/2011 06:59 23 quotes.cSV 12/11/2011 10:01 525 test.CSV 15/11/2011 19:01 12 test.CSV2 15/11/2011 19:01 12 testxxx.CSV2 6 File(s) 632 bytes 0 Dir(s) 26,632,110,080 bytes free After: Code: [Select]C:\Users\Test>dir *.cs* Volume in drive C is Win07 Volume Serial Number is E4DB-A92A Directory of C:\Users\Test 15/11/2011 18:30 16 animals.csv 12/11/2011 10:05 44 Myquotes.csv 11/11/2011 06:59 23 quotes.csv 12/11/2011 10:01 525 test.csv 15/11/2011 19:01 12 test.CSV2 15/11/2011 19:01 12 testxxx.CSV2 6 File(s) 632 bytes 0 Dir(s) 26,632,110,080 bytes free Hmmm... Maybe my cmd prompt is different than yours. When I run dir *.csv I get all of the .csv2 extensions as well. Code: [Select]Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\Raven\Desktop\Code\Batch\Test>dir *.csv Volume in drive C is OSDisk Volume Serial Number is 008C-D47E Directory of C:\Users\Raven\Desktop\Code\Batch\Test 11/15/2011 10:18 AM 0 New.csv 11/15/2011 10:18 AM 0 New2.csv2 11/15/2011 10:18 AM 0 New3.csv2 11/15/2011 10:18 AM 0 New4.csV 4 File(s) 0 bytes 0 Dir(s) 193,769,201,664 bytes free odd... Windows 7 SP1 (64 bit, 64 bit command prompt) (Edit - the result is the same with 32 bit command prompt) 64 bit command prompt: %windir%\System32\cmd.exe 32 bit command prompt: %windir%\SysWoW64\cmd.exe Code: [Select]Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. c:\Users\test>dir *.csv Volume in drive C is Win07 Volume Serial Number is E4DB-A92A Directory of c:\Users\test 15/11/2011 18:30 16 animals.csv 12/11/2011 10:05 44 Myquotes.csv 11/11/2011 06:59 23 quotes.csv 12/11/2011 10:01 525 test.csv 4 File(s) 608 bytes 0 Dir(s) 26,631,081,984 bytes free c:\Users\test>dir *.csv* Volume in drive C is Win07 Volume Serial Number is E4DB-A92A Directory of c:\Users\test 15/11/2011 18:30 16 animals.csv 12/11/2011 10:05 44 Myquotes.csv 11/11/2011 06:59 23 quotes.csv 12/11/2011 10:01 525 test.csv 15/11/2011 19:01 12 test.CSV2 15/11/2011 19:01 12 testxxx.CSV2 6 File(s) 632 bytes 0 Dir(s) 26,631,081,984 bytes free Is your Windows 7 32 or 64 bit? Very weird. I run a 32-bit Win7 environment. That may need to be researched as to why that little anomoly is happening. To et_phonehome_2: The solution to your exact issue may vary depending on the OS you are running. I suggest opening your cmd prompt and going to the directory these files are in and typing dir *.csv If you see .csv2 extensions, use my code, if not, use Salmon Trout's.I thought it might be to do with the filesystem having short-filename creation enabled on your system and disabled on mine, but I checked and it is enabled on mine. This is going to BUG me until I find out what is going on... [Update] I have done a bit of Googling, and it seems that there is a bug in Win32 wildcard expansion, when the wildcard has exactly 3 chars e.g. *.csv - it finds all the .csv and then all the csv2 csvNNNN etc. I am going to do some checking in XP 32 bit. [Edit] There ya go... Code: [Select]Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\Administrator\test>dir *.csv Volume in drive C has no label. Volume Serial Number is 24FE-A31E Directory of C:\Documents and Settings\Administrator\test 15/11/2011 09:16 PM 8 test.CSV 15/11/2011 09:17 PM 8 test.csv2 15/11/2011 09:17 PM 8 test1.CSV 15/11/2011 09:17 PM 8 test1.csv2 15/11/2011 09:20 PM 8 test1.csvN1 15/11/2011 09:20 PM 8 test1.csvN2 15/11/2011 09:20 PM 8 test1.csvN3 15/11/2011 09:20 PM 8 test1.csvN4 15/11/2011 09:17 PM 8 test2.CSV 15/11/2011 09:18 PM 8 test2.csv2 15/11/2011 09:17 PM 8 test3.CSV 15/11/2011 09:18 PM 8 test3.csv2 12 File(s) 96 bytes 0 Dir(s) 132,692,742,144 bytes free C:\Documents and Settings\Administrator\test>dir *.csvN* Volume in drive C has no label. Volume Serial Number is 24FE-A31E Directory of C:\Documents and Settings\Administrator\test 15/11/2011 09:20 PM 8 test1.csvN1 15/11/2011 09:20 PM 8 test1.csvN2 15/11/2011 09:20 PM 8 test1.csvN3 15/11/2011 09:20 PM 8 test1.csvN4 4 File(s) 32 bytes 0 Dir(s) 132,692,742,144 bytes free So I believe your check (that the extension is just ".csv" and no longer) is vital for compatibility with all Windows versions. dir /x shows short filenames generated for non- 8-dot-3 compatible filenames. They have .csv extensions thus win32 finds them and matches the wildcard. Code: [Select]C:\Documents and Settings\Administrator\test>dir /x Volume in drive C has no label. Volume Serial Number is 24FE-A31E Directory of C:\Documents and Settings\Administrator\test 15/11/2011 09:20 PM <DIR> . 15/11/2011 09:20 PM <DIR> .. 15/11/2011 09:16 PM 8 test.CSV 15/11/2011 09:17 PM 8 TEST~1.CSV test.csv2 15/11/2011 09:17 PM 8 test1.CSV 15/11/2011 09:17 PM 8 TEST1~1.CSV test1.csv2 15/11/2011 09:20 PM 8 TEST1~2.CSV test1.csvN1 15/11/2011 09:20 PM 8 TEST1~3.CSV test1.csvN2 15/11/2011 09:20 PM 8 TEST1~4.CSV test1.csvN3 15/11/2011 09:20 PM 8 TE3013~1.CSV test1.csvN4 15/11/2011 09:17 PM 8 test2.CSV 15/11/2011 09:18 PM 8 TEST2~1.CSV test2.csv2 15/11/2011 09:17 PM 8 test3.CSV 15/11/2011 09:18 PM 8 TEST3~1.CSV test3.csv2So more than likely, my system is searching the 8-dot-3 filenames in which case any extension starting with .csv shows up. That's a weird bug. Wonder if they are planning to patch that, or if I'm just out of date with the updates and patches. |
|
| 640. |
Solve : regrouping . . . need help with finding specific string(s) . . .? |
|
Answer» within a text file, then using those strings to rename the file. I am sure the provided solutions work fine, but it seems like the problem you are trying to solve is beginning to look like something that could be done more effectively in a real programming language. Your post is really off-topic for this thread, so I will keep my answer short. People using a computer at work often are not able to install anything extra at all. They have to work with what is actually on the computer that their employer has provided for them, and they have to work within the RESTRICTIONS that their employer's IT department lays down. So no downloads. No fancy programming languages. The supplied Microsoft scripting tools such as Powershell, Visual Basic Script and the NT family command environment (which is not "DOS" as many people think) are all that they can use. And they can do a lot, particularly in a fairly simple text processing scenario like this one, which is what they were designed for. So any considerations of elegance of code etc are misplaced in such a situation. If you look at the original post you will see many clues that the person is working is a commercial corporate environment. (i.e. he's got a "job".) In any case, the code supplied (partly by me admittedly) does the job, so the problem is, in essence, solved. (Pending the OP's return, if that ever happens). Good Morning! Just got to work and saw these awesome responses! Thank you sooo much! Salmon Trout is correct. I am at work, and usually, the only time we have to use batch files is when we have to rename a translated file to a specific format for our customers that are going to be picking up the file, via ftp. Unfortunately, our translation software does not allow us to specify the file name upon translation, so we have to manipulate the file name after translation. Our translation software has a job scheduler that will call a batch file, so that's what calls the batch file after translation. It's rather a pain, but it is what it is. I am going to try both of these wonderful pieces of code and I'll post back after I test them here. Hopefully, I won't have any more questions! Again, thanks so much!Ok, I was overly optimistic that I might not have any questions . . . I started with the more simple looking code and I STILL have questions. Believe me, I KNOW these are embarrassingly simplistic questions, but I'm not familiar with Batch syntax and have just started using it. BTW . . . if anyone knows of a link to something that would show and explain what all the different characters and commands mean, that would be awesome. Anyway . . . for this code . . . T.C., Could you possibly add some rem to explain each command and maybe what some of the characters do? Like what does it mean when you have an "!" before and after a variable? Was it implied that I was supposed to set a value to %temp% ? and was I also supposed to set a value to "iidiocy" ? Again, I apologize for the simplistic questions. echo off cls setlocal enabledelayedexpansion set zeros=00000 for /f "tokens=*" %%A in ('dir /b /a-d I*.*') do ( more +6 %%A > %temp%\iidiocy set toks=2 call :loop set Customer=!output! more +9 %%A > %temp%\iidiocy set toks=8 call :loop set Order=!zeros!!output! set order=!Order:~-6! echo Customer=!customer! Order=!order! ) exit /b :loop set /p input=<%temp%\iidiocy for /f "tokens=%toks%" %%1 in ("!input!") do ( set output=%%1 ) I've done some commenting on the script but somewhere along the line the script has been compromised. Please don't run this version For a fairly comprehensive list of Commands and their syntaxes please go here.. But you don't show your OS so it might not be spot-on specific. Salmon Trout posted a spiel on environment Variable expansion, perhaps he will post a link to it. Hope this helps. Code: [Select]echo off & REM Turn the echo command to Off so that command lines are not displayed during execution cls & REM Clear the display screen setlocal enabledelayedexpansion REM Set the environment to Local i.e. any Set value applied REM is valid only within the script and lost when an Endlocal REM command is encountered or the script runs to completion or REM crashes. Environment variables are expanded when the REM script commences, if the environment variable is to be REM expanded during some processing, especially within parenthesis, REM then delayed expansion must be invoked. The environment REM variable must be REM enclosed in !..! when this is so. set zeros=00000 & REM Set the environment variable Zeros REM Standard For loop, for info on FOR at the Command Prompt enter For /? REM More COPIES the file(s) listed in the Dir listing to a temporary file REM iidiocy in the %temp% directory skipping the lines shown by +6 and +9. REM To see where your temporary directory is located at the Command Prompt REM enter SET T You should not need to change this in the script, it REM should already be set. REM The temporary filename need not be changed but you can so do if you wish. for /f "tokens=*" %%A in ('dir /b /a-d I*.*') do ( more +6 %%A > %temp%\iidiocy set toks=2 call :loop set Customer=!output! more +9 %%A > %temp%\iidiocy set toks=8 call :loop set Order=!zeros!!output! set order=!Order:~-6! echo Customer=!customer! Order=!order! ) exit /b :loop REM set the first line in %temp%\iidiocy as Input. set /p input=<%temp%\iidiocy REM Another standard For loop which parses the first line in the file and REM extracts the customer number on the first call and the OW order number REM on the second call. for /f "tokens=%toks%" %%1 in ("!input!") do ( set output=%%1 ) T.C. Thank you so much, this helped tremendously. It assigns 'output' perfectly, but I've been trying all morning to get it so that I can actually use the variables 'Customer' and 'Orders' to rename the file to: confirm.!Customer!.!Order!.!Dattim!.cnf rem do I use the ! around the variables here? Here's the code that is working to get the specific data for the variables: echo on rem the only way I know how to debug and watch what gets processed cls setlocal enabledelayedexpansion Set d_qdbconf=\\sourdough\crossdata\ftp\qdoba\test\out\conf_temp rem the name of the file in here is: I799126_tlrt_20111114_164903.1 Set tloc_qdbconf=\\sourdough\crossdata\ftp\qdoba\test\out\temp for /f "tokens=*" %%A in (' dir /b "%d_qdbconf%\I*" ') do ( more +7 %d_qdbconf%\%%A > %tloc_qdbconf%\iidiocy set toks=2 call :loop set Customer=!output! more +9 %d_qdbconf%\%%A > %tloc_qdbconf%\iidiocy set toks=8 call :loop set order=!output! set Order=!order:~-6! for /F "tokens=2,3,4 delims=/ " %%i in ('date/t') do set dat=%%k%%i%%j for /F "tokens=5-8 delims=:. " %%i in ('echo.^| time ^| find "current" ') do set tim=%%i%%j%%k set Dat=!dat:~-6! ) exit /b :loop set /p input=<%tloc_qdbconf%\iidiocy for /f "tokens=%toks%" %%1 in ("!input!") do ( set output=%%1 pause[loop] ) :finish Quote from: jpilch on November 15, 2011, 01:21:17 PM It assigns 'output' perfectly, but I've been trying all morning to get it so that I can actually use the variables 'Customer' and 'Orders' to rename the file to: confirm.!Customer!.!Order!.!Dattim!.cnf rem do I use the ! around the variables here? Before the end parenthesis, try adding this: Code: [Select]set newname=confirm.!Customer!.!Order!.!Dat!!tim!.cnf echo ren %%A !newname! Be sure the echo command shows you what you want to see, then remove the echo and watch it roll. (you may want to add a pause after the echo so you can verify what you are looking at and Ctrl+C to change the code back. Quote from: Original post by jpilch I can get the date/time part, but I need to get the "057687" and "000417" Raven has possibly answered your queries but hey, you wanted 000417 not 417. Are you changing the spec for the script without advising? Chaos could ensue if you are working from a different spec from us mere mortals. Quote from: T.C. on November 15, 2011, 01:58:18 PM Raven has possibly answered your queries but hey, you wanted 000417 not 417. Are you changing the spec for the script without advising? Chaos could ensue if you are working from a different spec from us mere mortals. He clearly showed he wanted 000417 in the very first post, and this has been addressed in the answers. Did you read them? Sorry if I confused anyone, but I don't think I changed anything?? This is getting sooo close! FYI . . . I had to add some code to 'trim' the 'Customer' and 'Order' variables. I don't know the code well enough to know why they had trailing spaces, but they did. So, I looked up how to 'right trim' them and now it looks good . . . I think. This is the code I'm running, and I can see the 'move' command and it looks correct now, but it's not doing the 'move'. Am I missing something? I tried the 'ren' command, too and it didn't work either. echo on cls setlocal enabledelayedexpansion Set d_qdbconf=\\sourdough\crossdata\ftp\qdoba\test\out\conf_temp Set tloc_qdbconf=\\sourdough\crossdata\ftp\qdoba\test\out\temp for /f "tokens=*" %%A in (' dir /b "%d_qdbconf%\I*" ') do ( more +7 %d_qdbconf%\%%A > %tloc_qdbconf%\iidiocy set toks=2 call :loop set customer=!output! echo."!customer!" for /l %%a in (1,1,15) do if "!customer:~-1!"==" " set customer=!customer:~0,-1! echo."!customer!" set Customer=!customer:~-6! echo."!Customer!" pause[trimcustomer] more +9 %d_qdbconf%\%%A > %tloc_qdbconf%\iidiocy set toks=8 call :loop set order=!output! echo."!order!" for /l %%a in (1,1,15) do if "!order:~-1!"==" " set order=!order:~0,-1! echo."!order!" set Order=!order:~-6! echo."!Order!" pause[trimorder] for /F "tokens=2,3,4 delims=/ " %%i in ('date/t') do set dat=%%k%%i%%j for /F "tokens=5-8 delims=:. " %%i in ('echo.^| time ^| find "current" ') do set tim=%%i%%j%%k set Dat=!dat:~-6! set newname=confirm.!Customer!.!Order!.!Dat!.!tim!.cnf echo move %d_qdbconf%\%%A %tloc_qdbconf%\!newname! pause ) exit /b :loop set /p input=<%tloc_qdbconf%\iidiocy for /f "tokens=%toks%" %%1 in ("!input!") do ( set output=%%1 pause[loop] ) |
|
| 641. |
Solve : DOS Wildcard or ....? |
|
Answer» DOS supports the use of wildcards using a ? [question mark]. I have files of all different names, but I am looking for files that meet a specific criteria: |
|
| 642. |
Solve : Bat file for chkdsk for other logical drives !!!? |
|
Answer» Hello FOLKS i want to make a batch file that would Check the Disk of my other partition irrespective if they are scheduled for the chkdsk and that provide a report.log of the event of the chkdsk. Without testing, why wouldn't this work? Almost promising but it didn't work my friend, it didn't even start the chkdsk process.Okay, try this ONE then: Code: [Select]echo y>confirm.txt ( chkdsk /r <confirm.txt ) > output.txt shutdown /r Quote from: Raven19528 on November 07, 2011, 09:27:55 AM Okay, try this one then: Sorry mate that didn't work too, it restarted after 30 sec, but didn't do the chkdsk, too bad. It created log file CALLED confirm.txt and output.txt. What does you're original code show you when the chkdsk STARTS running? I'll need to do a little tinkering to see what's going on with everything, but that information will help. Quote from: Raven19528 on November 08, 2011, 11:47:21 AM What does you're original code show you when the chkdsk starts running? Code: [Select]echo y> confirm.txt chkdsk /r <confirm.txt shutdown -r| This is the code , it actually starts the countdown to 30 sec, and then reboots and does the chkdsk, but it doesn't produce an output report or log, that is what i want.By running CHKDSK at boot, all the Windows services are not available. GO to Control Panel and double click Administrative Tools Double click Event Viewer Double click Application log Look down the Source column and double click the first Winlogon entry you find. The CHKDSK log should be there. Quote from: Sidewinder on November 09, 2011, 07:02:47 AM By running CHKDSK at boot, all the Windows services are not available. Nope that too doesn't work , as you mentioned the i.e., Code: [Select]Go to Control Panel and double click Administrative Tools Double click Event Viewer Double click Application logYou may have omitted a step: Quote Look down the Source column and double click the first Winlogon entry you find. The CHKDSK log should be there. If not, what didn't work? Did you not find admin tools in the control panel? Did you not find the event viewer? Did you not find the Application log? The procedure is best followed immediately after CHKDSK is run during the boot process. Otherwise you may have to look deeper into the log for a Winlogon entry. |
|
| 643. |
Solve : Continuously ping script? |
|
Answer» To mention it, i'm not looking for an DDOS script. i'm not looking for an DDOS script((Your not looking for a script???)) yet what I have below is the best method I can come up with, and it requires a batch script unless of course you want to hand key it to execute it manually, but the goto routine I dont think you could run unless you create a single lined concatenated batch file...lol Best solution I can suggest is a goto loop in a batch file that writes the output to a text file. I would also add Date/Time Stamp to it in between each write of ping results so that when you have issues, you will have a somewhat good idea as to when it happened and for how long. Code: [Select]echo OFF :REPEAT echo. %date% at %time% >>PingLog.txt ping www.google.com >>PingLog.txt goto REPEAT I used a batch similar to this a while back for issues, but got further info from traceroutes where my ISP had a bad DNS path due to them buying up cheap and not so reliable taps to the Internet Backbone. The engineer at my ISP who took quite a few on hold phone hops to get to found it rather embarrasing that a home user was able to find this issue through a batch file and traceroutes, while most people would just accept poor performance or blame their home hardware. If you are having strange issues with DNS being resolved, manually change your DNS to an IP from another DNS provider like OpenDNS and see if you get different results. Maybe you too will find out your ISP has JUNKY DNS paths to the Internet. *Also this batch is very crude, in that you could make it better to strip it of everything but the ping results to be written to file if you want something clean with date/time and ping response times. Also you can change your ping path etc. I used Google since it is usually the best indicator of ISP issues since you should have pings less than 80ms, with 30-40ms being the best I have seen from my location. Also you may see the IP's change from where Google resolves as it is handled by the many Points of Presence that Google has for their search engine. Last time I checked I think the count was like 14 different IPs that www.google.com resolves at. Also you can alter the ping www.google.com to ping www.google.com -n 60 >>PingLog.txt if you want say 60 pings per date/time stamped interval, using the -n followed by the ping-count of times to ping as shown.Thanks. It looks so simple when someone else write it Dont know if i had brainfreeze yesterday. I added -t after ping and now it works as i wanted. Quote from: DaveLembke on October 31, 2011, 06:40:56 PM ((Your not looking for a script???)) He wrote "I'm not looking for a DDOS script" (note the 2 D's) A DDOS attack is a distributed denial of service attack, where many thousands of computers (usually in a botnet) ping the same host and effectively shut it down becaue it can't respond to legitimate traffic. It is worth noting that some hosts do not service ICMP requests (that is, they silently swallow ping requests and the remote (your) ping command times out) Code: [Select]C:\>ping www.microsoft.com Pinging lb1.www.ms.akadns.net [207.46.131.43] with 32 bytes of data: Request timed out. Request timed out. Request timed out. Request timed out. Ping statistics for 207.46.131.43: Packets: Sent = 4, Received = 0, Lost = 4 (100% loss), If you go persistent with -T, you can run it as a single LINE such as: Code: [Select]ping www.google.com -t >PingLog.txt or if you want to APPEND to end when restarted replace > with >> in that instruction. Guessing you will want to use > to overwrite the old data when run again since with -T you wont be getting date/time stamps to know when it cuts out. Also Salmon had a good point in regards that many shut off the ping responses and thanks for picking up on the DDOS while I took it as a typo..lol As of writing this google still echos back ping results.Been looking for a way to ping internal network devices by running a batch file. I need to keep an eye on 15 different network sites and have been pinging them by opening up the cmd prompt and pinging each site continuously. My problem is that I will have to open up 15 different cmd prompts and manually type in the ping command as well as the address that I want to ping. My questions is how do I write a batch file to open cmd prompts, enter the address I want to ping, then open a new cmd prompt, enter the next address i want to ping, etc...Then I would like it to tile the boxes horizontally so I can keep an eye on all of them. I got this far but do not know how to enter the text into the cmd prompt to start the ping. I am very skilled in hardware troubleshooting/replacement but not so much in programming. echo start c:/windows/system32/cmd.exe Any HELP is greatly appreciated. I have searched some more and what I am trying to accomplish is probably very easy. He is what I have so far: start cmd.exe ping xxx.xx.xx.xxx -t start cmd.exe ping xxx.xxx.xxx.xxx -t The first cmd prompt opens and pings the first address, however the second cmd prompt opens but does not ping the second address. The problem I had was the batch file would not execute the next line of code after the ping -t command because that would not stop. Ended up writing 14 batch files, each one opening the next batch file before executing the ping -t command. I am SURE there was a easier way to do it but it works for me.zuc, you are not supposed to hijack another person's thread, you should have started a new one. You need to use start like this start "window title" "command" start "" "command" window title can be blank, just 2 quotes but you must not omit it. Example: Script will start each command in separate window. To terminate each click on title bar or in box and type CTRL + C or click window close icon. Code: [Select]start "yahoo" "cmd /c ping www.yahoo.com -t" start "google" "cmd /c ping www.google.com -t" |
|
| 644. |
Solve : For Loop Token - How to use as variable? |
|
Answer» Hello, If I remember correctly, I think you need SetLocal enabledelayedexpansion on the first line. Then you access the vars with !G! instead of %%G or something. I haven't used batch in a while so I may be wrong.You'd still use %%G with delayed expansion enabled, but you'd use !newname! instead of %newname%.Thanks Linux711 and Helpmeh, though still need more help. I added the setlocal enabledelayedexpansion and changed % to !. Now the echo commands show the variable name, not it's value. I've tried this with many variation, but no luck. I finally tried to save the prefix and suffix to individual variables and then concatenate them. Still no go. Would you have any other ideas on where my error is? I've searched looking for clues but have found none. Thanks a lot. Diane CURRENT CODE: set outputfile=PharmElog.csv set count=pharme if exist %outputfile% del %outputfile% setlocal enabledelayedexpansion FOR /F "tokens=1,2,3 delims=," %%G IN (spectrumnoformat.txt) DO If "%count%"=="pharme" ( set prefix=%%G set suffix=%%H echo !prefix! echo !suffix! set NewName=!prefix! !suffix! echo !NewName! [regaining space - attachment deleted by admin]Why are you setting %count% equal to "pharme" and then testing if %count% is equal to "pharme"? And why are you doing that weird DO IF? And where is the final parenthesis? Quote Now the echo commands show the variable name, not it's value. It looks OK from here... you might see this better by putting ECHO OFF at the top of your file. Your screenshot shows Code: [SELECT]1 ".pdf" 1 ".pdf" These are the values of prefix, suffix, and newname when your echo commands run. Just because it shows "ECHO !prefix!" in the output doesn't make it incorrect, that's just the way delayed expansion works. I would however suggest removing the double quotes in your suffix, and removing the space in your NewName. The first is accomplished by Code: [Select]set suffix=%%~H And the second by simply removing the space Code: [Select]set NewName=!prefix!!suffix!SalmonTrout, I agree the count is weird. I just started working with DOS and really want to have a record count and test the value of the string %%G but didn't know how do it (at least yet). Would appreciate a tip on that. Sort of ditto for the For command. Going through forums that's method that was presented for reading a text file. Are there other methods? My previous DOS experience is just a few system commands, so this is proving to be a good learning experience. Thanks for your comments and would appreciate alternatives. DianeYou didn't answer my question. I don't see why you are setting x=y and then straight away checking if x=y? Did you think it might have changed? Quote from: DianeM on November 09, 2011, 06:32:47 PM I would also appreciate help understanding how to use the For loop tokens. I understand they are only "valid" in the loop itself but - are they always prefixed with two %% when using them, can they be assigned to variables? Check out this post for a good explanation from Salmon Trout on the use of tokens in a FOR loop. I don't understand exactly on the count either. Are you hoping to have numbered lines that you are going through and want to ensure that the lines match up correctly? I guess the whole thing is that if you have no immediate need for the count variable now, lets dismiss it and concentrate on exactly what you are needing help with. Then later we can help explain some other things as you get a better understanding how all of the commands work.I was looking for a way to read a .txt file and then complete several steps - download a file and write a log to excel. I understood the FOR statement allowed one command after the DO. In looking for a way to have multiple steps I found the current method of FOR DO IF. I couldn't figure out how to deal with the field (via my prior response on testing the value) so I put in something that would be "true" to enable me to test the following steps and come back to that later. Given how things have progressed, I don't need that IF statement and would prefer to just have multiple steps after the DO including a record count. Prior to adding the DO IF, I tried using the DO with a call to a label but could not get the %%G, etc. values to be present in the subroutine. Does that help explain? It's been a crooked learning path. DianeNow that we've figured that out, let's move on to solving this problem. Quickly, yes, the FOR loop can perform multiple commands, it does not require a DO IF to do so, only an open parenthesis at the end of the same line as the FOR command. If you think your subroutine will work, you can call the routine after setting some of the variables in the FOR loop. Example: Code: [Select]for /f "tokens=1,2* delims=," %%G in (spectrumnoformat.txt) do ( set prefix=%%G set suffix=%%H call :subroutine ) I would really only suggest a subroutine if you are trying to setup a loop within the FOR command. There are a few times this is legitimately the case (many times when errorchecking, for example) but in this case, if you think the subroutine will work, go ahead and use it. To add a record count, simply add set /a count+=1 somewhere in the for loop (be sure to set count to a number somewhere before the for loop starts though.) Please post if you are needing further explanation of things. Try to be as specific as you can, so that we can answer the correct question.Thanks a lot for clarifying the FOR statement. I'll probably end up simplifying a lot when I get a better understanding of how they actually work. Another gentleman pointed out I was missing an end bracket via email, so I'll spend some time going back over this routine to clean it up. I really appreciate your help and interest. I'll post back hopefully with news of success. Thanks to all DianeYes! The routine is now humming along. I had to put my concatention in quotes as NewName only contained the suffix - set "NewName=!prefix! !suffix!" Raven19528, I did not use a subroutine as it was not needed to accomplish the task. I also checked on the post you suggested by SalmonTrout but did not see any entries by him. Is there another entry? Thank you for getting me on the right track. Diane Quote from: DianeM on November 10, 2011, 06:18:36 PM I also checked on the post you suggested by SalmonTrout but did not see any entries by him. Is there another entry? I think he means Sidewinder. Quote from: Salmon Trout on November 10, 2011, 11:55:06 PM I think he means Sidewinder. I did. It was late. It was my Friday. Both your names start with "S". I'm too poor to pay attention. (I've got plenty of excuses... ) In any case, sorry for confusion, and sorry to Sidewinder and Salmon Trout for the mix up. |
|
| 645. |
Solve : How to check if a program is running in cmd?? |
|
Answer» So I'm writing some python and I want to make an if statement that checks if a program is RUNNING I figured the simplest way would be to use subprocess and check with cmd if the program is running. Since the program needs to be running at all times, it would also be ideal to have it start the program if it is not running. So I'm writing some python and I want to make an if statement that checks if a program is running I figured the simplest way would be to use subprocess and check with cmd if the program is running. I found this python code that uses WMI to get a list of processes on Win32. Code: [Select]import win32com.client strComputer = "." objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator") objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2") colItems = objSWbemServices.ExecQuery("Select * from Win32_Process") for objItem in colItems: PRINT "NAME: ", objItem.Name print "File location: ", objItem.ExecutablePath |
|
| 646. |
Solve : Need help with symbolic links!? |
|
Answer» Okay, so in a nutshell, I made a batch file that would rename .minecraft(minecraft's directory) to minecraft(3), then it would rename minecraft(2) to .minecraft, before renaming minecraft(3) to minecraft(2). This effectively allows me to, by the click of a mouse, switch between a modded game directory, and the regular version of the game. The modded directory is also a game version that has support for specific MODS, while the regular directory is the up to date version. But I have one remaining problem. Whichever directory I am playing with at the time of a save, holds the save files in a folder titled "saves", which it must be titled to in order for minecraft to find the saves. This means that the other directory will not have the world saved at the spot I left off in the current directory, so if I switch directories I'd have to copy the saves to the new one, which is about 90% of the space in the whole directory. This would make the batch file - which is basically just for convenience, sense I wouldn't have to copy files - pointless. So sense minecraft can't read a shortcut file(I tried putting a shortcut to one directories saves to the other, and retitled it from "saves - shortcut" to simply "saves"), I'm resorting to symbolic links. I'm trying to use a command line with the MKLINK command. But everytime I type in the link and the target, it tells me "Cannot create a file when that file already exists." I've never used this before, and seeing how the first time it was used it gave me this error, I obviously can't actually have the file. So I'm assuming there's something wrong with my command line, which is where I need some help. Here's my command line: C:\Users\Noah>MKLINK /J C:\Users\Noah\AppData\Roaming\minecraft(… C:\Users\Noah\AppData\Roaming\.minecraft… Legit is a folder, titled by minecraft when you create a world. So in other words, I have a world on minecraft named Legit, and in my saves folder, one of the folders is called Legit, and it contains the world's files. In case this is part of the problem, there IS another folder inside of the folder aswell. It is titled region, and contains more files(no folders). The folder in it's entirety contains 2 .dat files, a .lock file, a .settings file, and a folder containing 9 .mcr files. and as I said before, I'm GETTING the error, "Cannot create a file when that file already exists." Thanks for any help.Bump(not sure if I can bump my own thread) Quote from: Noahmcdx on November 21, 2011, 01:56:51 PM Bump(not sure if I can bump my own thread) You can, in the trivial sense that it is possible to for you to bump your own thread, but if you meant you weren't sure if it was good forum etiquette, the answer is "no it isn't". It really isn't. Bumping to raise your thread to the top of the recent posts list is seen as screaming for attention, and can DETER PEOPLE from answering, except in the MANNER of this post. If anyone (a) knows how to help you and (b) wants to, they will. using multiple MC versions in this manner only requires you to rename the minecraft.jar file. I've been doing that since around Beta 1.3 when I need to. Basically, I'd have a batch file for each version, which first copies minecraft.jar and VERSION files to backups, then renames a given file (like say Minecraft121.jar for Minecraft Beta 1.2_01, or Minecraft13.jar for 1.3, etc. to minecraft.jar, and another VERSION file to VERSION. Then it executes nlauncher (the new Minecraft Launcher) (using /wait if necessary) and afterwards it copies the backup files back. You could give this jar switcher a whirl, instead. http://www.minecraftforum.net/topic/514289-tool-minecraft-jar-switcher-and-backup-tool-v10/ |
|
| 647. |
Solve : If Filename contains...? |
|
Answer» I want to make a batch file where I can drag-drop a number of DIFFERENT FILES into it. Then it NEEDS to check if the filename is similar to ONE of the predefined filenames and if so, execute a function to copy that file to the same directory with another filename. |
|
| 648. |
Solve : skip last line using a for loop? |
|
Answer» using sqlcmd option in sql server, i generated a text file |
|
| 649. |
Solve : Complex batch file help? |
|
Answer» I know little about batch scripting so I am in NEED of some help. This script is a compilation of research and then left to gather dust. I really want it to work but it SEEMS like it skips some of the commands. My goal with the script is to do each section 1 at a time and then wait for an exe to close and then close different things 1 at a time. |
|
| 650. |
Solve : Need help with finding a string in a file and then . . .? |
|
Answer» Our translation software translates a file and then writes it to a specific folder. The batch file I'm writing needs to rename the file, but first, needs to determine if the file translation is finished before I try to do anything else, so, I need to first loop through the first file in a folder, look for the string 'end of file'. The translation software should have the file "open" and therefore unable to edit when it is writing to it. Is this statement not true in this case? If so, why?Whether a file is open has no bearing whatsoever on whether the file can be CHANGED. That depends on the dwShareMode parameter that was used when the file was opened, which is usually as lax as possible. In this case the ShareMode would have to include FILE_SHARE_DELETE to allow renaming the file. In any case, my point is that whether a file is open is entirely separate from whether it can be opened, read, written, renamed, or deleted. Quote from: BC_Programmer on November 23, 2011, 02:04:15 PM In any case, my point is that whether a file is open is entirely separate from whether it can be opened, read, written, renamed, or deleted. Right. Again, BRAIN too involved with visions of turkey INDUCED coma in very near future. In any case, this post shows how to use the tasklist command to see if a program is running. It may provide a more accurate assessment of whether the translator program is running or not. |
|