

InterviewSolution
Saved Bookmarks
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your Microsoft knowledge and support exam preparation. Choose a topic below to get started.
201. |
Solve : Complicated batch for statement help? |
Answer» <html><body><p>doing a rework of some files and <a href="https://interviewquestions.tuteehub.com/tag/updating-250800" style="font-weight:bold;" target="_blank" title="Click to know more about UPDATING">UPDATING</a> alot of utilities, <br/>helping a friend redo his class scheduling to incorporate some swf and pdf items into a <a href="https://interviewquestions.tuteehub.com/tag/daily-245095" style="font-weight:bold;" target="_blank" title="Click to know more about DAILY">DAILY</a> feed for each student..<br/><br/>here's the "structure"<br/>text file say Mon.txt has the directories to loop thru... for that given day..<br/>text file 2.. student file.. has the results..if none the file is blank.....<br/><br/>batch should look at student file.. see the last doc read... then goback and get the next item in that folder.. refereed to in the Dayfile.. the files in the <a href="https://interviewquestions.tuteehub.com/tag/folders-994110" style="font-weight:bold;" target="_blank" title="Click to know more about FOLDERS">FOLDERS</a> begin with 01, 02, 03... to maintain a order to the presentations.. so the whole file name isn't important.<br/><br/>i've been craming a bunch of batch work in due to a move.. in 2 weeks.. and loosin my patience :-D I get the directories to spit, but it does them all.. but I know i've got the counter messed up because I can't get it to just move one file upIf you don't post your code, that means you are expecting us to perform a nasty combination of mindreading and guesswork, which we don't like.<br/>for /F "delims=" %%b in (%MASTERSRV%\Server\Class\%%a.txt) do ( <br/>forfiles -p "%%b" -s -m *.* /C "cmd /c echo path">>%MASTERSRV%\Server\Class\%%a-tmp.txt<br/>)<br/>)<br/><br/><br/>I'm just going with a simpler code, this will output the directories for the student, dump it on the term and I'll use a for loop <a href="https://interviewquestions.tuteehub.com/tag/script-345000" style="font-weight:bold;" target="_blank" title="Click to know more about SCRIPT">SCRIPT</a> on the PC to allow them to keep pace.. much thanksI think you need to lose that <a href="https://interviewquestions.tuteehub.com/tag/second-238031" style="font-weight:bold;" target="_blank" title="Click to know more about SECOND">SECOND</a> closing parenthesis.<br/></p></body></html> | |
202. |
Solve : Turn off laptop monitor? |
Answer» <html><body><p>Hi folks,<br/><br/>I want to turn off laptop monitor <a href="https://interviewquestions.tuteehub.com/tag/using-1441597" style="font-weight:bold;" target="_blank" title="Click to know more about USING">USING</a> dos command.<br/>Is there any command or bat I can make?Download nircmd: <a href="https://www.nirsoft.net/utils/nircmd.html">http://www.nirsoft.net/utils/nircmd.html</a><br/><br/>Put it in system32<br/><br/>Enter this into command prompt: nircmd.exe monitor off<br/><br/>You can of course also put this in a batch if needed.I do not want to use others <a href="https://interviewquestions.tuteehub.com/tag/software-25575" style="font-weight:bold;" target="_blank" title="Click to know more about SOFTWARE">SOFTWARE</a>. So, thought there must me something in windows.<br/><br/>Like shutdown.exe, logon.exe, there should be something sleep.exe, standby.exe<br/><br/>Regards<br/>vishu Quote from: vishuvishal on July 24, 2010, 01:15:20 PM</p><blockquote>I do not want to use others software. So, thought there must me something in windows.<br/><br/>Like shutdown.exe, logon.exe, there should be something sleep.exe, standby.exe<br/><br/>Regards<br/>vishu<br/></blockquote> <br/>There is.<br/><br/>Shutdown.exe<br/><br/><br/>C:>shutdown /?<br/>Usage: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e] [/f]<br/> [/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]<br/><br/> No args Display help. This is the same as typing /?.<br/> /? Display help. This is the same as not typing any options.<br/> /i Display the graphical user interface (GUI).<br/> This must be the first option.<br/> /l Log off. This cannot be used with /m or /d options.<br/> /s Shutdown the computer.<br/> /r Shutdown and restart the computer.<br/> /g Shutdown and restart the computer. After the system is<br/> rebooted, restart any registered applications.<br/> /a Abort a system shutdown.<br/> This can only be used during the time-out period.<br/> /p Turn off the local computer with no time-out or warning.<br/> Can be used with /d and /f options.<br/> <strong> /h Hibernate the local computer.</strong><br/> Can be used with the /f option.<br/> /e Document the reason for an unexpected shutdown of a computer.<br/> /m \\computer Specify the target computer.<br/> /t xxx Set the time-out period before shutdown to xxx seconds.<br/> The valid range is 0-315360000 (10 <a href="https://interviewquestions.tuteehub.com/tag/years-239545" style="font-weight:bold;" target="_blank" title="Click to know more about YEARS">YEARS</a>), with a default of <a href="https://interviewquestions.tuteehub.com/tag/30-238183" style="font-weight:bold;" target="_blank" title="Click to know more about 30">30</a>.<br/> If the timeout period is greater than 0, the /f parameter is<br/> implied.<br/> /c "comment" Comment on the reason for the restart or shutdown.<br/> Maximum of 512 characters allowed.<br/> /f Force running applications to close without forewarning users.<br/> The /f parameter is implied when a value greater than 0 is<br/> specified for the /t parameter.<br/> /d [p|u:]xx:yy Provide the reason for the restart or shutdown.<br/> p indicates that the restart or shutdown is planned.<br/> u indicates that the reason is user defined.<br/> If neither p nor u is specified the restart or shutdown is<br/> unplanned.<br/> xx is the major reason number (positive integer less than 256).<br/> yy is the minor reason number (positive integer less than 65536).<br/><br/><br/><br/>Can you give any command to turn off computer display?<a href="http://www.raymond.cc/blog/archives/2008/07/20/how-to-manually-turn-off-notebook-or-laptop-lcd-screen/">http://www.raymond.cc/blog/archives/2008/07/20/how-to-manually-turn-off-notebook-or-laptop-lcd-screen/</a>As Salmon Trout said,<br/><br/>Shutdown /hMy guess is he wants to turn off the display of his rival's laptop so he can win a bet.<br/>But yes, it can be done without extra software and not putting it into hi berate. Quote from: MattPwns on July 25, 2010, 01:51:52 PM<blockquote>As Salmon Trout said,<br/><br/>Shutdown /h<br/></blockquote> <br/>That actually shuts down the computer. If he wants to blank the display but keep the computer running then this is no use! <br/><br/>Anyhow, another link<br/><br/>Turn Off LCD.exe is in this archive; can call from batch; works on <a href="https://interviewquestions.tuteehub.com/tag/32-243836" style="font-weight:bold;" target="_blank" title="Click to know more about 32">32</a> & 64 bit Windows<br/><br/><a href="http://www.redmondpie.com/downloadscenter/TurnOffLCDv101.zip">http://www.redmondpie.com/downloadscenter/TurnOffLCDv101.zip</a><br/><br/><br/><br/>Thank you for the replies.<br/><br/>I have seen that softwares already.<br/><br/>I would like to turn off the monitor of my laptop.<br/><br/>I am not right now on my desk.<br/><br/>So, I would like to type command on Dos and turn off the display.<br/><br/>Setting the Hz rate more will turn off the display but that is not the way. Cause that will try to increase the hardware functionality beyond it's limitation.<br/><br/>I just need to know if there is some kind on command on Dos to do it.<br/><br/><br/>Like we do have screensaver blank.<br/><br/>If we could do something to run the blank screensaver immediately.<br/><br/>But, That is not what I am trying to do.<br/>Just turn off the montor of laptop.<br/><br/><br/>Thanks and regards<br/><br/>Vish<br/><br/>That will ultimately die and give you the error. Quote<blockquote>If we could do something to run the blank screensaver immediately.</blockquote> Yes, that works.<br/>Find or make a SCR file that does a blank screen. It would normally be in the WINDOWS32 area. Create a shortcut to it, a LINK file.<br/>In this example I will use s<em>s3dfo.scr</em><br/>I will make a shortcut <strong>Shortcut to ss3dfo.scr</strong><br/>I will place the shortcut in a place I like.<br/>D:\BAT and rename it to a shorter name :<strong> s3dfo.lnk</strong><br/>On the local machine the command is <strong>START s3dfo</strong><br/> Code: <a>[Select]</a><br/>D:\BAT>ver<br/><br/>Microsoft Windows XP [Version 5.1.2600]<br/><br/>D:\BAT>start s3dfo<br/><br/>D:\BAT><br/><br/><br/>That DIR will have to be shared on the network.<br/>I would have to issue a command for remote execution.<br/>But let let somebody else tell you how to do remote execution over a local network.<br/>I am getting tired and need more Coffee.He he he <br/><br/><br/>I already had that.<br/>Already done with it.<br/><br/>I want to let you know that there is no screensaver for blank. <br/>However, I tried to workaround on it. <br/><br/>by using "ssmarque.scr" <br/>config it to blank and background as black.<br/><br/>But still your monitor will remain in use. Even if there is black display or say no display.<br/><br/>Even if you use black image things will be same.<br/><br/><br/>So, may I take it as "no command for in dos to turn off display"<br/><br/><br/>Cause if window can turn off the display. Then dos must be having this command somewhere hidden in his heart.<br/><br/><br/>if you can perform detail check.<br/><br/>Please read under power usage.<br/>I hope we can find something there.<br/><br/>Let's hope for best.<br/><br/>Thanks and regards <br/><br/>VishuYou are right. <br/><br/>It does not turn off the power to the screen...<br/> just makes it black. <br/><br/>But might be enough to...<br/> win a bet with your fellow workers in the office!<br/> Quote<blockquote>I hope we can find something there.</blockquote> Without other software, you cannot force a monitor shut-off.<br/><br/>Sorry to disappoint.Note a problem.<br/><br/>You really rock!<br/><br/>You have a good name as well I really liked it<br/><br/>Carbondudeoxide<br/><br/>I have seen many of your replies that are really good.<br/><br/>I do respect your comments. <br/><br/>Thanks</body></html> | |
203. |
Solve : Dos String Search & Replace Columns? |
Answer» <html><body><p>HI <br/><a href="https://interviewquestions.tuteehub.com/tag/question-25051" style="font-weight:bold;" target="_blank" title="Click to know more about QUESTION">QUESTION</a>, is it possible to do the following example with batch file commands?<br/><br/>Replace all lines that start with GOTO in a file starting with column 43 to 71 that <a href="https://interviewquestions.tuteehub.com/tag/contains-11473" style="font-weight:bold;" target="_blank" title="Click to know more about CONTAINS">CONTAINS</a> spaces with three variables %%u %%v %%w <br/>(-0.7478, 0.0141, 0.6638) then add <a href="https://interviewquestions.tuteehub.com/tag/balance-238529" style="font-weight:bold;" target="_blank" title="Click to know more about BALANCE">BALANCE</a> of line (PT 7) for example below!<br/><br/><br/>Example;<br/><br/> FROM<br/>PPRINT Vue : second<br/>GOTO / 409.33480, -18.96415, 7.79821 PT 7<br/>GOTO / 419.47490, -24.89781, 19.34762 PT 8<br/><br/> TO<br/>PPRINT Vue : second<br/>GOTO / 409.33480, -18.96415, 7.79821 -0.7478, 0.0141, 0.6638 PT 7<br/>GOTO / 419.47490, -24.89781, 19.34762 -0.7478, 0.0141, 0.6638 PT 8you can download <a href="http://gnuwin32.sourceforge.net/packages/sed.htm">sed </a>or <a href="http://gnuwin32.sourceforge.net/packages/gawk.htm">gawk f</a>or windows, then use these one liners<br/> Code: <a>[Select]</a>C:\test>sed -i.bak "/^GOTO/s/PT/-0.7478, 0.0141, 0.6638 PT/" file<br/>PPRINT Vue : second<br/>GOTO / 409.33480, -18.96415, 7.79821 -0.7478, 0.0141, 0.6638 PT 7<br/>GOTO / 419.47490, -24.89781, 19.34762 -0.7478, 0.0141, 0.6638 PT 8<br/><br/>or <br/><br/> Code: <a>[Select]</a>C:\test>gawk "/GOTO/{$5=\"-0.7478, 0.0141, 0.6638 \"$5}1" file<br/>PPRINT Vue : second <br/>GOTO / 409.33480, -18.96415, -0.7478, 0.0141, 0.6638 7.79821 PT 7<br/>GOTO / 419.47490, -24.89781, -0.7478, 0.0141, 0.6638 19.34762 PT 8<br/>Thanks! But that one of my problems! I'm coverting my old Unix Script to DOS! (32bit & 64bit issues) and would like current program to be DOS only! Quote from: graymj on July 31, 2010, 09:22:36 PM</p><blockquote>Thanks! But that one of my problems! I'm coverting my old Unix Script to DOS! (32bit & 64bit issues) and would like current program to be DOS only!<br/></blockquote> <br/>what problem is that ? Most unix tools are <a href="https://interviewquestions.tuteehub.com/tag/already-1974237" style="font-weight:bold;" target="_blank" title="Click to know more about ALREADY">ALREADY</a> ported to <a href="http://gnuwin32.sourceforge.net/packages.html"> GNU win32 packages </a>. you can download them and use it. At least, you don't have to reinvent most of the wheels... 1. Will lines starting PPRINT always have 4 space delimited tokens?<br/><br/> Code: <a>[Select]</a><br/> 1 2 3 4<br/>PPRINT Vue : second<br/><br/><br/><br/>2. Where are you getting those 3 variables to insert? In what form will they be? Do they change each line?<br/><br/>Example of source file below, I extract the variables i want to insert with the<br/>cammand:<br/><br/>FINDSTR /B /N /I /C:"TLAXIS/" %DOSPATH%\%FILE% > vec.txt<br/> for /f "tokens=1-5 <a href="https://interviewquestions.tuteehub.com/tag/delims" style="font-weight:bold;" target="_blank" title="Click to know more about DELIMS">DELIMS</a>= " %%t in (%DOSPATH%\vec.txt) do (<br/> set Y=%%t<br/> echo. Located Vector Value %%u %%v %%w <br/> )<br/><br/>And I only need to insert %%u %%v %%w on lines that start with goto!<br/><br/><br/>PPRINT Vue :<br/>PPRINT MAX FILE SIZE = 90 MEG<br/>PPRINT<br/>PPRINT TLAXIS = AX= -0.7478 AY= 0.0141 AZ= 0.6638<br/>PPRINT TOOL 226109<br/>PPRINT<br/>HEAD/ONE<br/>LOADTL/ 226109<br/>SPINDL/ 800<br/>TLAXIS/ -0.7478, 0.0141, 0.6638<br/>FROM/ .00000, .00000, 1100.00000<br/>RAPID<br/>GOTO / -476.19460, -2.27892, 793.84030 PT 5<br/>RAPID<br/>GOTO / 390.63990, -18.61189, 24.39274 PT 6<br/>FEDRAT/500<br/>GOTO / 409.33480, -18.96415, 7.79821 PT 7<br/>GOTO / 419.47490, -24.89781, 19.34762 PT 8<br/>GOTO / 420.12290, -24.80300, 20.07566 PT 9<br/>GOTO / 420.75380, -24.55062, 20.78100 PT 10Final text file should look like below!<br/>also lines should not exceed 80 char!<br/><br/>PPRINT Vue :<br/>PPRINT MAX FILE SIZE = 90 MEG<br/>PPRINT<br/>PPRINT TLAXIS = AX= -0.7478 AY= 0.0141 AZ= 0.6638<br/>PPRINT TOOL 226109<br/>PPRINT<br/>HEAD/ONE <br/>LOADTL/ 226109<br/>SPINDL/ 800<br/>TLAXIS/ -0.7478, 0.0141, 0.6638<br/>FROM/ .00000, .00000, 1100.00000<br/>RAPID<br/>GOTO / -476.19460, -2.27892, 793.84030 -0.7478, 0.0141, 0.6638 PT 5<br/>RAPID<br/>GOTO / 390.63990, -18.61189, 24.39274 -0.7478, 0.0141, 0.6638 PT 6<br/>FEDRAT/500<br/>GOTO / 409.33480, -18.96415, 7.79821 -0.7478, 0.0141, 0.6638 PT 7<br/>GOTO / 419.47490, -24.89781, 19.34762 -0.7478, 0.0141, 0.6638 PT 8<br/>GOTO / 420.12290, -24.80300, 20.07566 -0.7478, 0.0141, 0.6638 PT 9<br/>GOTO / 420.75380, -24.55062, 20.78100 -0.7478, 0.0141, 0.6638 PT 10</body></html> | |
204. |
Solve : backup command cannot copy huge files?? |
Answer» <html><body><p>it stop half way. and return insufficient memory error..<br/>i use it to copy files to external <a href="https://interviewquestions.tuteehub.com/tag/hard-1015537" style="font-weight:bold;" target="_blank" title="Click to know more about HARD">HARD</a> disk...<br/><br/> Code: <a>[Select]</a>echo off<br/>:: variables<br/><a href="https://interviewquestions.tuteehub.com/tag/set-11758" style="font-weight:bold;" target="_blank" title="Click to know more about SET">SET</a> <a href="https://interviewquestions.tuteehub.com/tag/drive-959713" style="font-weight:bold;" target="_blank" title="Click to know more about DRIVE">DRIVE</a>=D:\2<br/>SET date="%date:~6,4%-%date:~0,2%-%date:~3,2%"<br/><br/>set backupcmd=xcopy /s /c /d /e /h /i /r /k /y<br/><br/>echo ### Backing up your Sites directory...<br/>%backupcmd% "C:\1" "%drive%\%date%"<br/><br/>echo <a href="https://interviewquestions.tuteehub.com/tag/backup-18158" style="font-weight:bold;" target="_blank" title="Click to know more about BACKUP">BACKUP</a> Complete - Your Backup is located at %drive%<br/>pause<br/>if <a href="https://interviewquestions.tuteehub.com/tag/target-25812" style="font-weight:bold;" target="_blank" title="Click to know more about TARGET">TARGET</a> medium has FAT file system max file size is (4 GB minus 1 byte)<br/><br/>If it says that there is insufficient space on the disk, then there is your problem. Your external hard drive is too small. Quote</p><blockquote>backup command cannot copy huge files?</blockquote> <br/>... the topic title is possibly ambiguous? Huge files or huge number of files?<br/>huge files and also huge number of files and with many directories....<br/>my ext hdd is enough, i tried windows copy method, successfully....<br/>or maybe i need to separate copy by using more batch file?what filesystem does it have?<br/></body></html> | |
205. |
Solve : Cleaning up the output of ping? |
Answer» <html><body><p>I need a batch file that takes the output of ping and strips out the summary info and blank <a href="https://interviewquestions.tuteehub.com/tag/lines-240113" style="font-weight:bold;" target="_blank" title="Click to know more about LINES">LINES</a>, leaving just the individual times captured in a file. For example, I want to turn this:<br/><br/>Pinging yahoo.com [69.147.125.65] with 32 bytes of data:<br/><br/>Reply from 69.147.125.65: bytes=32 time=100ms TTL=53<br/>Reply from 69.147.125.65: bytes=32 time=101ms TTL=53<br/>Reply from 69.147.125.65: bytes=32 time=101ms TTL=53<br/>Reply from 69.147.125.65: bytes=32 time=101ms TTL=53<br/><br/>Ping statistics for 69.147.125.65:<br/> <a href="https://interviewquestions.tuteehub.com/tag/packets-770940" style="font-weight:bold;" target="_blank" title="Click to know more about PACKETS">PACKETS</a>: Sent = 4, Received = 4, Lost = 0 (0% loss),<br/>Approximate round trip times in milli-seconds:<br/> <a href="https://interviewquestions.tuteehub.com/tag/minimum-561095" style="font-weight:bold;" target="_blank" title="Click to know more about MINIMUM">MINIMUM</a> = 100ms, Maximum = 101ms, Average = 100ms<br/><br/>Into this:<br/><br/>Pinging yahoo.com [69.147.125.65] with 32 bytes of data:<br/>Reply from 69.147.125.65: bytes=32 time=100ms TTL=53<br/>Reply from 69.147.125.65: bytes=32 time=101ms TTL=53<br/>Reply from 69.147.125.65: bytes=32 time=101ms TTL=53<br/>Reply from 69.147.125.65: bytes=32 time=101ms TTL=53<br/><br/>Any ideas? Code: <a>[Select]</a> findstr /C:"Pinging" /C:"Reply" or using <a href="http://gnuwin32.sourceforge.net/packages/gawk.htm"> gawk for windows</a><br/> Code: <a>[Select]</a>C:\test&<a href="https://interviewquestions.tuteehub.com/tag/gt-249387" style="font-weight:bold;" target="_blank" title="Click to know more about GT">GT</a>;ping localhost | gawk "/Pinging/||/Reply/"<br/> Quote from: ghostdog74 on July 31, 2010, 11:52:47 PM</p><blockquote> Code: <a>[Select]</a> findstr /C:"Pinging" /C:"Reply" </blockquote> <br/>Thanks! The findstr method is perfect, since I don't want to rely on gawk being installed.</body></html> | |
206. |
Solve : Inserting Blank Lines in a set of text files? |
Answer» <html><body><p>Hi,<br/><br/>This being my first ever post, i would want to ask for some help with Dos/Batch file.<br/><br/>I have a set of 20 files in a Folder in my C Drive.<br/>these files are plain text files, i want to add a Blank line at the end of these files.<br/><br/>I want to create a Bath file that can open these files and insert the Blank line at the end n save the file.<br/><br/>Is it possible? please help me out.. im a total newbie in this field..<br/><br/>Thanks alot for your help.can someone please help me out.. i really need to get this working <br/><br/><a href="https://interviewquestions.tuteehub.com/tag/daily-245095" style="font-weight:bold;" target="_blank" title="Click to know more about DAILY">DAILY</a> i have to edit 20 files or more.. If all you need is a blank line on the end of all files in a folder then type this in at the command line<br/><br/> Code: <a>[Select]</a>For %A in ("*.*") do Echo. &<a href="https://interviewquestions.tuteehub.com/tag/gt-249387" style="font-weight:bold;" target="_blank" title="Click to know more about GT">GT</a>;> %A<br/>explanation available on request! Quote from: gpl on August 03, 2010, 05:01:01 AM</p><blockquote>If all you need is a blank line on the end of all files in a folder then type this in at the command line<br/><br/> Code: <a>[Select]</a>For %A in ("*.*") do Echo. >> %A<br/>explanation available on request!<br/></blockquote> <br/>Hi, thanks alot for ur reply.. yes for sure i would want an explanation as im not much into scri[pting so i really dont knw how to go about doin this.<br/>please assist me.I get the impression that you are not sure even how to get to the command prompt ?<br/><br/>In the start menu, click on Run and then enter cmd and press return. If you find yourself using the command prompt a lot, then there is a useful microsoft tool that adds a new option to the right-click contect menu in windows explorer called 'Command Prompt Here' which opens up a command window in the selected folder <a href="https://gallery.technet.microsoft.com/ScriptCenter/en-us/d50e36fd-0454-4df1-aa35-3416f44789cc">http://gallery.technet.microsoft.com/ScriptCenter/en-us/d50e36fd-0454-4df1-aa35-3416f44789cc</a> however as even microsoft do not guarantee this for <a href="https://interviewquestions.tuteehub.com/tag/vista-728089" style="font-weight:bold;" target="_blank" title="Click to know more about VISTA">VISTA</a> or win 7, I would hold off for now.<br/><br/>When the command window opens, you need to go to the folder that you wish to process the files in:<br/><br/> Code: <a>[Select]</a>cd /d "x:\<a href="https://interviewquestions.tuteehub.com/tag/path-11833" style="font-weight:bold;" target="_blank" title="Click to know more about PATH">PATH</a>\to my files"the x: refers to the disk drive the files are on (if a network drive, it needs to be mapped to a drive letter) and \path\to my files refers to the folder on the drive that contains the files. the quotes around the drive and folder name are important if the path might contain spaces, it doesnt hurt to include them. CD is the command to change directory (folder) the /d parameter tells it to change the drive too.<br/><br/>Now for the command I told you to type in ....<br/>the first <a href="https://interviewquestions.tuteehub.com/tag/part-238139" style="font-weight:bold;" target="_blank" title="Click to know more about PART">PART</a><br/> Code: <a>[Select]</a>For %A in ("*.*") dosets up a loop to look at all of the files in the current folder (thats the *.* part). The %A is a variable that for each iteration will hold the filename.<br/>The last part is what we do with each file<br/> Code: <a>[Select]</a>Echo. >> %AEcho is used to send a message to the screen, however you can send the message to a file (or the printer or comm port) by using the > and >> 'redirection' symbols. <br/>> will replace the file, while >> tacks the message on to the end.<br/>Echo on its own give the (not very) useful message 'Echo is on' - or off. Adding the dot to the end makes it send a blank line<br/>And thats all there is to it. I recommend that you try stuff out, read the various help guides on this site and others and come back when you are stuck.<br/><br/>Good luck<br/>Graham<br/>Thanks alot gpl<br/><br/>It has solved my problem!To follow up my previous post, I have stumbled across this with regasrd to opening a command window in Vista and I assume Win 7 also<br/>"Open Command Window Here" in Vista<br/>It is now easy to open a command prompt referenced to a folder of your choice in Vista. If the Shift key is held down while right-clicking a folder, the context menu will contain an entry, "Open Command Window Here". Selecting this entry will open a command prompt with the chosen folder as the reference point for commands.<br/><br/>You live and learn!!</body></html> | |
207. |
Solve : Random number 40-90? |
Answer» <html><body><p>I have been looking for a batch who random chose a number 40-90, but I can't find any command who can specify a certain number. Why I want 40-90 is because I <a href="https://interviewquestions.tuteehub.com/tag/use-241643" style="font-weight:bold;" target="_blank" title="Click to know more about USE">USE</a> 1-25 already and the 25-39 I made <a href="https://interviewquestions.tuteehub.com/tag/space-239477" style="font-weight:bold;" target="_blank" title="Click to know more about SPACE">SPACE</a> if I'm going to use more numbers later.<br/><br/>Here is how I was thinking it should look like<br/><br/> Code: <a>[Select]</a>echo off<br/>cls<br/><br/>Echo Text<br/><br/>//The random number goes here.<br/><br/>If '40' Goto '40'<br/>If '41' Goto '41'<br/><br/>//Here would the random number from 40-90 go.<br/>:40<br/>echo Text<br/>GOTO start<br/><br/>:41<br/>echo Text<br/>GOTO start<br/><br/>:start<br/>set /p var=<br/><br/>I'm still learning how to use all batch commands, I just know the basics of it, but I would be grateful if anyone have the knowledge how can help me.I found this in the snippet closet. Just a few tweaks and it is made to order:<br/><br/> Code: <a>[Select]</a>echo off<br/>setlocal<br/><br/>set intLowNumber=40<br/>set intHighNumber=90<br/><br/>set /a rnd=%random% %% (%intHighNumber% - %intLowNumber% + 1) + %intLowNumber%<br/>echo Random number between %intLowNumber% and %intHighNumber% is %rnd% <br/><br/>FYI: use <strong>rem</strong> statements for comments; // are <a href="https://interviewquestions.tuteehub.com/tag/used-763273" style="font-weight:bold;" target="_blank" title="Click to know more about USED">USED</a> in other languages, not batch<br/><br/>Good luck. <br/>Thanks for the help, but I got to a other bummer I'm trying to get that the random number it create it then will go to a number,<br/><br/> Code: <a>[Select]</a>echo off<br/>cls<br/>setlocal<br/><br/>set intLowNumber=40<br/>set intHighNumber=90<br/><br/>set /a rnd=%random% %% (%intHighNumber% - %intLowNumber% + 1) + %intLowNumber%<br/>%rnd% ((<=If that number is 40 then)) GOTO 40<br/>%rnd% ((<=If that number is 41 then)) GOTO 41<br/><br/>But every time I try to do that I get "GOTO was unaccepted at this time" and then it kill it self, I have tried different commands but it still wont work...have you created the <a href="https://interviewquestions.tuteehub.com/tag/labels-239710" style="font-weight:bold;" target="_blank" title="Click to know more about LABELS">LABELS</a> :40 and :41 for it to jump to ? Quote from: gpl on August 04, 2010, 04:12:19 AM</p><blockquote>have you created the labels :40 and :41 for it to jump to ?<br/></blockquote> <br/>yes, I also have 40-90 Code: <a>[Select]</a>%rnd% ((<=If that number is 40 then)) GOTO 40<br/>%rnd% ((<=If that number is 41 then)) GOTO 41<br/><br/>Is this really part of your "code", Frejoh466? If so, I believe I know why your script keeps crashing.<br/> Quote from: Frejoh466 on August 03, 2010, 01:51:22 PM<blockquote>I'm still learning how to use all batch commands, I just know the basics of it, but I would be grateful if anyone have the knowledge how can help me.<br/></blockquote> <br/>since you have only just started, why not learn a programming language? A good programming language such as Python (and others) provides you programming concepts and constructs, such as arrays, hashes, dictionaries that every programmer should know and many more. Plus, it comes with modules/libraries that make programming easier and fun. Here's one way<br/>to get random number in <a href="https://docs.python.org">Python</a>.<br/><br/> Code: <a>[Select]</a>import random<br/>random_number=random.randrange(100)<br/>if random_number < 40:<br/> print "do something"<br/>elif random_number<90:<br/> print "do something" <br/><br/><br/> Quote from: Salmon <a href="https://interviewquestions.tuteehub.com/tag/trout-661901" style="font-weight:bold;" target="_blank" title="Click to know more about TROUT">TROUT</a> on August 04, 2010, 04:46:41 AM<blockquote> Code: <a>[Select]</a>%rnd% ((<=If that number is 40 then)) GOTO 40<br/>%rnd% ((<=If that number is 41 then)) GOTO 41<br/><br/>Is this really part of your "code", Frejoh466? If so, I believe I know why your script keeps crashing.<br/><br/></blockquote> <br/>That is not what my code look like, my code is kinda long so I only use the part that don't work so it wont be that long...<br/><br/>I'm trying to use that code in this part,<br/><br/> Code: <a>[Select]</a>if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto unlock<br/>if NOT EXIST Hide goto create<br/>:lock<br/>ren Hide "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"<br/>attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"<br/>goto End<br/>:unlock<br/>echo Enter password to Unlock folder<br/>set /p "pass=>"<br/>if NOT %pass%==lol goto exit<br/>attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"<br/>ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Hide<br/>goto exit<br/>:create<br/>md Hide<br/>goto exit<br/><br/>:exit<br/>exit<br/><br/>note quote marks<br/><br/> Code: <a>[Select]</a>if NOT "%pass%"=="lol" goto exit Quote from: Salmon Trout on August 04, 2010, 05:22:48 AM<blockquote>note quote marks<br/><br/> Code: <a>[Select]</a>if NOT "%pass%"=="lol" goto exit</blockquote> <br/>But it work without the quotes. Quote from: Frejoh466 on August 04, 2010, 06:40:44 AM<blockquote>But it work without the quotes.<br/></blockquote> <br/>Try pressing ENTER when it asks for the password.<br/>Frejoh466, you changed scripts! First it was all that "goto 40" stuff, then all of a sudden you're trying to hide Control Panel! What's going on?<br/>What do you think this line is going to do? (Line 6)<br/><br/> Code: <a>[Select]</a>goto End Quote from: Salmon Trout on August 04, 2010, 07:18:42 AM<blockquote>Frejoh466, you changed scripts! First it was all that "goto 40" stuff, then all of a sudden you're trying to hide Control Panel! What's going on?<br/><br/></blockquote> <br/>And this is why I only post the part that don't work... Ok forget my last post, I'm trying to use that random number the %rnd% create to go to the :40 or :41 etc. <br/><br/>so the number that %rnd% create it will goto<br/><br/>Hope this get through...Whatever it is you are trying to do, I am quite sure that there is a better way. Probably involving fewer lines! The computed goto is heavily frowned upon by programming experts. However if that is what you want...<br/><br/>(You can change intHighNumber and put in the label sections from 51 to 90 yourself. Notice that you do not need goto end after the last number because you are going there anyway.)<br/><br/> Code: <a>[Select]</a>echo off<br/>set intLowNumber=40<br/>set intHighNumber=50<br/>set /a rnd=%random% %% (%intHighNumber% - %intLowNumber% + 1) + %intLowNumber%<br/>goto %rnd%<br/><br/>:40<br/>echo number=40<br/>goto end<br/>:41<br/>echo number=41<br/>goto end<br/>:42<br/>echo number=42<br/>goto end<br/>:43<br/>echo number=43<br/>goto end<br/>:44<br/>echo number=44<br/>goto end<br/>:45<br/>echo number=45<br/>goto end<br/>:46<br/>echo number=46<br/>goto end<br/>:47<br/>echo number=47<br/>goto end<br/>:48<br/>echo number=48<br/>goto end<br/>:49<br/>echo number=49<br/>goto end<br/>:50<br/>echo number=50<br/><br/>:end<br/></body></html> | |
208. |
Solve : need some help ..thx for sample !Z? |
Answer» <html><body><p>hi guy!how i can create a batch file unhide items inside a specified drive...can give me some examples ?like if i <a href="https://interviewquestions.tuteehub.com/tag/type-238192" style="font-weight:bold;" target="_blank" title="Click to know more about TYPE">TYPE</a> String like unhide foldername <br/><br/><br/><br/>why do you need this?<br/>You can use following command.<br/><br/><br/>If it is a doc file<br/><br/><br/> Code: <a>[Select]</a>attrib -h c:\path\file name<br/><br/><br/>or <br/><br/><br/>attrib -h c:\path\*.doc<br/><br/>it will work for sure.<br/>if you want to unhide all <a href="https://interviewquestions.tuteehub.com/tag/hidden-2109891" style="font-weight:bold;" target="_blank" title="Click to know more about HIDDEN">HIDDEN</a> files within folder.<br/><br/><br/> Code: <a>[Select]</a>attrib -h c:\path\*.*<br/><br/>You can use any drive just <a href="https://interviewquestions.tuteehub.com/tag/change-238106" style="font-weight:bold;" target="_blank" title="Click to know more about CHANGE">CHANGE</a> C:<br/>give it any drive name.<br/><br/><br/>Give me raise for thanks.<br/>It will work<br/><br/>Regards<br/><br/>vishu Quote from: <a href="https://interviewquestions.tuteehub.com/tag/salmon-1193794" style="font-weight:bold;" target="_blank" title="Click to know more about SALMON">SALMON</a> Trout on <a href="https://interviewquestions.tuteehub.com/tag/august-385421" style="font-weight:bold;" target="_blank" title="Click to know more about AUGUST">AUGUST</a> 03, 2010, 03:25:17 PM</p><blockquote>why do you need this?<br/><br/></blockquote> <br/>doing so experiment .. Reply for your question.<br/><br/>Last on for unhiding all hidden files.</body></html> | |
209. |
Solve : Can a batchfile make another file to remember something?? |
Answer» <html><body><p>Hey guys, I was wondering if it's possible to make another <a href="https://interviewquestions.tuteehub.com/tag/file-11330" style="font-weight:bold;" target="_blank" title="Click to know more about FILE">FILE</a> which stores something from the original batchfile so you can skip a part of the batch file? I think it's kinda annoying if you'd have to do that.<br/>Lol I hope you understand...<br/><br/><br/>Here's the code<br/><br/> Code: <a>[Select]</a>:1<br/>IF EXIST "" "Save" GOTO 2<br/>ECHO What Torrent Downloader are you using?<br/>ECHO 1: µTorrent<br/>ECHO 2: BitTorrent<br/>ECHO 3: Vuze<br/>ECHO 4: BitComet<br/>ECHO.<br/>ECHO If there is any other Client you are using, notify me<br/>ECHO and I'll add it to the list ;)<br/>ECHO.<br/>SET /P L=Type your desired number and press ENTER: <br/>IF %L%==1 SET TORRENT=%HOMEDRIVE%\Program Files\uTorrent\uTorrent.exe<br/>IF %L%==2 SET TORRENT=%HOMEDRIVE%\Program Files\BitTorrent\bittorrent.exe<br/>IF %L%==3 SET TORRENT=%HOMEDRIVE%\Program Files\Vuze\Azureus.exe<br/>IF %L%==4 SET TORRENT=%HOMEDRIVE%\Program Files\BitComet\bitcomet.exe<br/>---------------------<br/>--------------------- < Other part of the file, not necessary<br/>---------------------<br/>ECHO Start %TORRENT%?<br/>SET /P N=Type y [yes] or n [no], then press ENTER. <br/>IF %N%==y GOTO SBIT<br/>IF %N%==n GOTO FOX<br/>GOTO BIT<br/>:SBIT<br/>ECHO.<br/>Start "" /min "%TORRENT%"<br/>ECHO.<br/>ECHO %TORRENT% started minimized.<br/>Yeah so what I'm trying to do is making this "Save" file <em>somehow</em> lol<br/>Without it, this code is useless and I have to put the number each time I start the batch file... This is what I'm trying to avoid. Code: <a>[Select]</a>IF EXIST "" "Save" GOTO 2This is also not for one-time usage as you might understand. I'll also use this for other programs I want to start with this batch file and for future batch files also <br/><br/>I've also thought about doing IF EXIST but there is a possibility the user has multiple of these programs...<br/><br/>I really hope you guys can help <br/><br/>PS: Anyone has another torrent client I need to add? In a batch you can create a variable.<br/>If you do not release the variable, it lives forever.<br/><br/>As I dimly recall, there was a Broadway show ...<br/>where the programmer sang:<br/><br/> "In a clear Batch.....<br/> ..variables forever..."<br/><br/> Quote from: Geek-9pm on August 05, 2010, 10:21:47 AM</p><blockquote>In a batch you can create a variable.<br/>If you do not release the variable, it lives forever.<br/><br/>As I dimly recall, there was a Broadway show ...<br/>where the programmer sang:<br/><br/> "In a clear Batch.....<br/> ..variables forever..."<br/><br/><br/></blockquote> Can you put an <a href="https://interviewquestions.tuteehub.com/tag/example-239971" style="font-weight:bold;" target="_blank" title="Click to know more about EXAMPLE">EXAMPLE</a> please?<br/><br/>Thanks Code: <a>[Select]</a>:1<br/>IF EXIST TorrentClientChoice.txt (<br/> set /p L=<TorrentClientChoice.txt<br/> GOTO loaded<br/> )<br/>ECHO What Torrent Downloader are you using?<br/>ECHO 1: µTorrent<br/>ECHO 2: BitTorrent<br/>ECHO 3: Vuze<br/>ECHO 4: BitComet<br/>ECHO.<br/>ECHO If there is any other Client you are using, notify me<br/>ECHO and I'll add it to the list ;)<br/>ECHO.<br/>SET /P L=Type your desired number and press ENTER: <br/>>TorrentClientChoice.txt echo %L%<br/>echo Preference %L% saved<br/>:loaded<br/>IF %L%==1 SET TORRENT=%HOMEDRIVE%\Program Files\uTorrent\uTorrent.exe<br/>IF %L%==2 SET TORRENT=%HOMEDRIVE%\Program Files\BitTorrent\bittorrent.exe<br/>IF %L%==3 SET TORRENT=%HOMEDRIVE%\Program Files\Vuze\Azureus.exe<br/>IF %L%==4 SET TORRENT=%HOMEDRIVE%\Program Files\BitComet\bitcomet.exe<br/>---------------------<br/>--------------------- < Other part of the file, not necessary<br/>---------------------<br/>ECHO Start %TORRENT%?<br/>SET /P N=Type y [yes] or n [no], then press ENTER. <br/>IF %N%==y GOTO SBIT<br/>IF %N%==n GOTO FOX<br/>GOTO BIT<br/>:SBIT<br/>ECHO.<br/>Start "" /min "%TORRENT%"<br/>ECHO.<br/>ECHO %TORRENT% started minimized. Quote from: Ghosty on August 05, 2010, 10:24:34 AM<blockquote>Can you put an example please?<br/><br/>Thanks<br/></blockquote> <br/>He is joking.<br/> Quote from: Salmon Trout on August 05, 2010, 10:36:50 AM<blockquote>He is joking.<br/><br/></blockquote> Lol...<br/>No<br/>To be honest not xD<br/>I never learned this part of batch (until now)<br/>I'm sorry<br/><br/>And thanks a lot for helping <br/><br/>PS: what was the double post for? Quote from: Ghosty on August 05, 2010, 11:23:52 AM<blockquote>PS: what was the double post for?</blockquote> <br/>What double post?<br/> Quote from: Salmon Trout on August 05, 2010, 11:27:02 AM<blockquote>What double post?<br/><br/></blockquote> <br/>Lol<br/>First I asked for an example. Then you posted the code which helped me <br/>Then you posted that I was joking (which I wasn't) Quote from: Ghosty on August 05, 2010, 12:37:45 PM<blockquote> <br/>Lol<br/>First I asked for an example. Then you posted the code which helped me <br/>Then you posted that I was joking (which I wasn't)<br/></blockquote> <br/>Do you have trouble understanding how quoting works in forums? I'll try to put it simply for you.<br/><br/>1. Geek-9pm posted in that "batch variables live forever". This is (obviously) not true, and I think he meant it as a joke. (not very funny in my opinion.)<br/>2. You (Ghosty) quoted Geek-9pm saying that, and underneath asked for an example, and from that it seemed that you thought he was serious (now that <em>is</em> funny.)<br/>3. I (Salmon Trout) quoted you (Ghosty) asking for an example, and wrote underneath that he (Geek-9pm) was joking.<br/><br/><br/><br/> Quote from: Salmon Trout on August 05, 2010, 12:55:34 PM<blockquote>Do you have trouble understanding how quoting works in forums? I'll try to put it simply for you.<br/><br/>1. Geek-9pm posted in that "batch variables live forever". This is (obviously) not true, and I think he meant it as a joke. (not very funny in my opinion.)<br/>2. You (Ghosty) quoted Geek-9pm saying that, and underneath asked for an example, and from that it seemed that you thought he was serious (now that <em>is</em> funny.)<br/>3. I (Salmon Trout) quoted you (Ghosty) asking for an example, and wrote underneath that he (Geek-9pm) was joking.</blockquote> Lol...<br/>Oops<br/><br/>Oversaw that it was him and not you lol<br/>SORRY MY FAULT I <a href="https://interviewquestions.tuteehub.com/tag/went-734459" style="font-weight:bold;" target="_blank" title="Click to know more about WENT">WENT</a> through it too quickly<br/><br/>HOWEVER<br/>You DID double post <br/>Your first post was "He is joking." The post after that you made was the code Quote from: Ghosty on August 05, 2010, 01:08:29 PM<blockquote>You DID double post </blockquote> <br/>You don't <a href="https://interviewquestions.tuteehub.com/tag/know-534065" style="font-weight:bold;" target="_blank" title="Click to know more about KNOW">KNOW</a> what "double posting" is. It is when somebody makes the same post twice, sometimes in the same <a href="https://interviewquestions.tuteehub.com/tag/thread-771901" style="font-weight:bold;" target="_blank" title="Click to know more about THREAD">THREAD</a>, by accident, or sometimes when they start two threads with the same first post. What I did was make two separate posts, which were different from each other. <br/><br/> Quote<blockquote>Your first post was "He is joking." The post after that you made was the code </blockquote> <br/>Actually, it was the other way around.<br/> Quote from: Salmon Trout on August 05, 2010, 01:19:33 PM<blockquote>You don't know what "double posting" is. It is when somebody makes the same post twice, sometimes in the same thread, by accident, or sometimes when they start two threads with the same first post. What I did was make two separate posts, which were different from each other.</blockquote> <br/>Maybe in the forums where you post, but not in mine. When I post two different posts after each other in the same topic, they count it as double post.<br/><br/><br/> Quote from: Salmon Trout on August 05, 2010, 01:19:33 PM<blockquote>Actually, it was the other way around.</blockquote> <br/> True about that one lol... I was editing my post and it looked the other way around, I got somewhat confused (chatting with four people at the same time ) Quote from: Ghosty on August 05, 2010, 01:22:42 PM<blockquote>Maybe in the forums where you post, but not in mine.</blockquote> <br/>This is a "forum where I post", in case you hadn't noticed.<br/><br/><br/> Quote from: Salmon Trout on August 05, 2010, 01:29:36 PM<blockquote>This is a "forum where I post", in case you hadn't noticed.</blockquote> It would be dumb from me not to notice that you posted here.<br/>The point is that I'm used to the situation I wrote about the double post.<br/><br/>ANYWAY let's stop this crap this is entirely off-topic<br/><br/><br/>I assume that there's a way to make more than one command in a single line.<br/>For example Code: <a>[Select]</a>IF this=that, then do this AND this instead of putting the commands in multiple lines.You can use the ampersand & symbol to link multiple commands on the same line<br/><br/> Code: <a>[Select]</a>if "%var%"=="egg" echo yolk & echo white</body></html> | |
210. |
Solve : Looping in a PC .bat file:? |
Answer» <html><body><p>Can any kind fellow help me write the Loop in my PC .bat file?<br/><br/>echo off<br/>change user /install<br/>pushd \\servername\installlib\<br/>Set Environment=<br/>Set /P Environment=Environment Name DV DX PY PD PZ or PY: %=%<br/><br/>Set NumberOfUpdates=<br/>Set /P NumberOfUpdates=Number of package updates ( Where A=1 and Z=26 ): %=%<br/><br/>Echo Updating %Environment%7333 Environment with %NumberOfUpdates% update packages:<br/>Pause<br/><br/>Set Update1=%Environment%7333UGA<br/>Set Update2=%Environment%7333UGB<br/>.<br/>.<br/>.<br/>Set Update26=%Environment%7333UGZ<br/><br/><strong><em>For X = 1 to %NumberOfUpdates%<br/> Echo Now applying update: %UpdateX%<br/> C:\Setup.exe –s –p %UpdateX% -D d:\b7<br/><a href="https://interviewquestions.tuteehub.com/tag/next-578185" style="font-weight:bold;" target="_blank" title="Click to know more about NEXT">NEXT</a> X</em></strong><br/><br/>change user /execute<br/>PAUSE<br/><br/><br/><em>My Scenario: I got to rollout 6 Environments across 4 servers each with between 10-20 updates. That’s about 300 updates, luckily I found out how to do it from the command line and not go through the silly GUI Click/Point/Browse path/<a href="https://interviewquestions.tuteehub.com/tag/select-630282" style="font-weight:bold;" target="_blank" title="Click to know more about SELECT">SELECT</a>/ double-click etc etc for each update. Now I want to write a .BAT to make it even easier for next time.</em><br/><br/>Batch loop syntax<br/><br/>FOR %I in (start,stop,<a href="https://interviewquestions.tuteehub.com/tag/step-25533" style="font-weight:bold;" target="_blank" title="Click to know more about STEP">STEP</a>) DO command<br/><br/>I usually put the loop commands themselves in their own batch file<br/><br/>FOR %I in (1,1,%NumberofUpdates%) DO UpdateMachine %I<br/><br/>One litlle 'gotcha' is then when using a FOR Loop IN the batch file, you put %I, but if exec from the command prompt directly you put %%I so that the "%I" get's passed to the 'FOR' and not the value of I<br/><br/>Clear as mud :-) Quote from: BradDet on August 02, 2010, 02:40:32 PM</p><blockquote>Batch loop syntax<br/><br/>FOR %I in (start,stop,step) DO command<br/><br/>I usually put the loop commands themselves in their own batch file<br/><br/>FOR %I in (1,1,%NumberofUpdates%) DO UpdateMachine %I<br/><br/>One litlle 'gotcha' is then when using a FOR Loop IN the batch file, you put %I, but if exec from the command prompt directly you put %%I so that the "%I" get's passed to the 'FOR' and not the value of I<br/><br/>Clear as mud :-)<br/></blockquote> <br/>Yeah, that won't work...<br/><br/>Here, NewCNCguy, this code will do what you want:<br/><br/>For /l %%A in (1,1,%numberofupdates%) do (<br/> Echo Now applying update: %UpdateX%<br/> C:\Setup.exe –s –p %UpdateX% -D d:\b7<br/>)<br/> Quote from: BradDet on August 02, 2010, 02:40:32 PM<blockquote>Batch loop syntax<br/><br/>FOR %I in (start,stop,step) DO command<br/><br/></blockquote> <br/>BradDet, you are quite a new member. You need to be aware that posting like that is going to cause you to get posts like this that I am writing here now. You should check what you are posting, as that way you don't post stuff which is wrong and which does the opposite of helping. With command line keywords you can just type the command followed by a space and then a slash and a question mark. Here is an example<br/><br/> Code: <a>[Select]</a>FOR /?<br/>You get several screens of help including this<br/><br/> Code: <a>[Select]</a>FOR /L %<a href="https://interviewquestions.tuteehub.com/tag/variable-772077" style="font-weight:bold;" target="_blank" title="Click to know more about VARIABLE">VARIABLE</a> IN (start,step,end) DO command [command-parameters]<br/><br/> The set is a sequence of numbers from start to end, by step amount.<br/> So (1,1,5) would generate the sequence 1 2 3 4 5 and (5,-1,1) would<br/> generate the sequence (5 4 3 2 1)<br/>As you will note, this is a lot different from what you posted. To summarise: don't post off the top of your head, check it first, preferably running any code you are going to suggest. This should the minimum standard for posting help on CH. Anything less is low quality.<br/><br/>Why exactly is it "a lot different?"<br/><br/>I admit I left out the "/L" by mistake,<br/><br/>and technically if I run a batch in the command I should put "call program.bat" by after the do, but I wouldn't say it was "a lot different", just a typo.<br/><br/>I make typo's quite frequently actually, sorry if this causes too much confusion Quote from: BradDet on August 02, 2010, 04:45:49 PM<blockquote>Why exactly is it "a lot different?"<br/><br/>I admit I left out the "/L" by mistake,<br/><br/>and technically if I run a batch in the command I should put "call program.bat" by after the do, but I wouldn't say it was "a lot different", just a typo.<br/><br/>I make typo's quite frequently actually, sorry if this causes too much confusion<br/></blockquote> <br/>It's a "lot different" in the sense that unlike a post that includes the /L it doesn't help the OP in their question, and is more likely to cause more issues and confusion. Without the /L, the standard for command is:<br/><br/> Code: <a>[Select]</a>for %%var in (set) do command<br/><br/>which is clearly quite a bit different from yours. therefore, if somebody tried your Speshul version that accidentally omitted the switch, they would not have a loop going from start to end by step, but rather a 3 item loop that executes with start, step, and then end. For example:<br/><br/> Code: <a>[Select]</a>for %P in (1,1,5) do echo %P<br/><br/><br/>this gives us:<br/><br/> Code: <a>[Select]</a>C:\>for %P in (1,1,%numberofupdates%) do echo %P<br/><br/>C:\>echo 1<br/>1<br/><br/>C:\>echo 1<br/>1<br/><br/>C:\>echo 5<br/>5<br/><br/>C:\><br/><br/><br/>Which is clearly "a lot different" then what was intended. The OP might then assume that they made a mistake of their own- or, in the worst case, not notice that only three of their 26 updates ran through and accept the solution. Then, later down the road, much to their chagrin they discover that for every update they performed, the first update was performed twice and the last update was performed once and all the others were ignored. <br/><br/> Quote from: BC_Programmer on August 02, 2010, 11:23:11 PM<blockquote>It's a "lot different" in the sense that unlike a post that includes the /L it doesn't help the OP in their question</blockquote> <br/>There is that, which is bad enough, but another thing just as bad in its way is this <br/><br/> Quote<blockquote>(start,stop,step)</blockquote> <br/>We would have to guess that he meant "(start, step, end)". Assuming when he wrote "stop" he meant "end", that's a completely different order. <br/><br/>It seems clear from his reply that he still does not see what is wrong with his attitude.<br/><br/><br/><br/><br/><br/>, and is more likely to cause more issues and confusion. Without the /L, the standard for command is:<br/><br/> Code: <a>[Select]</a>for %%var in (set) do command<br/><br/>which is clearly quite a bit different from yours. therefore, if somebody tried your Speshul version that accidentally omitted the switch, they would not have a loop going from start to end by step, but rather a 3 item loop that executes with start, step, and then end. For example:<br/><br/> Code: <a>[Select]</a>for %P in (1,1,5) do echo %P<br/><br/><br/>this gives us:<br/><br/> Code: <a>[Select]</a>C:\>for %P in (1,1,%numberofupdates%) do echo %P<br/><br/>C:\>echo 1<br/>1<br/><br/>C:\>echo 1<br/>1<br/><br/>C:\>echo 5<br/>5<br/><br/>C:\><br/><br/><br/>Which is clearly "a lot different" then what was intended. The OP might then assume that they made a mistake of their own- or, in the worst case, not notice that only three of their 26 updates ran through and accept the solution. Then, later down the road, much to their chagrin they discover that for every update they performed, the first update was performed twice and the last update was performed once and all the others were ignored. <br/><br/><br/>[/quote]Ah... My misunderstanding,<br/><br/>You meant that the functional execution of was a lot different, which I agree with. I had thought you meant literally the statement itself was a lot different.<br/><br/>This is indeed a very beginner mistake on my part!<br/><br/>Computers will ALWAYS do you tell them to do, not necessarily what you WANT them to do It might be worth noting that <br/><br/>for /L %%N in (1,1,5) do something <br/><br/>is functionally equivalent to<br/><br/>for %%N in (1 2 3 4 5) do something <br/><br/>the difference being that if you explicitly list every item you can do stuff like this<br/><br/>for %%N in (1 2 2a 3 4 5 7 99 cat dog) do something <br/><br/><br/><br/><br/></body></html> | |
211. |
Solve : How to send details of a file into excel sheet.? |
Answer» <html><body><p>Hi All, <br/><br/>I have a file <a href="https://interviewquestions.tuteehub.com/tag/called-907796" style="font-weight:bold;" target="_blank" title="Click to know more about CALLED">CALLED</a> Myfile.mdl. This file is located in some <a href="https://interviewquestions.tuteehub.com/tag/like-537196" style="font-weight:bold;" target="_blank" title="Click to know more about LIKE">LIKE</a> D:\Folder_Name1\Folder_Name2\Myfile.mdl.<br/><br/>When we see the the details of this file We find out <a href="https://interviewquestions.tuteehub.com/tag/nmae-2197082" style="font-weight:bold;" target="_blank" title="Click to know more about NMAE">NMAE</a>, Size, Type, Date Modified etc...<br/><br/>I want to extract only that date into one Excel file called Myexcel.xls.<br/><br/>I have tried with some code but its giving all the details of all directories and <a href="https://interviewquestions.tuteehub.com/tag/sub-250109" style="font-weight:bold;" target="_blank" title="Click to know more about SUB">SUB</a> directories, but I need only that file date in the excel sheet which is located in main directory.<br/><br/>Your help will be appriciated more.<br/><br/><br/>Thanks in advance<br/>SarayuThis question was asked and answered yesterday. Perhaps you missed it. Click<br/><br/> Quote</p><blockquote>I have tried with some code but its giving all the details of all directories and sub directories, but I need only that file date in the excel sheet which is located in main directory.<br/></blockquote> <br/>If you want to help your own cause, you might consider posting your code. It wouldn't be very much help if I told you I wrote some code for your solution and then didn't post it.<br/><br/>As was previously mentioned you cannot update an Excel <a href="https://interviewquestions.tuteehub.com/tag/spreadsheet-1222930" style="font-weight:bold;" target="_blank" title="Click to know more about SPREADSHEET">SPREADSHEET</a> with batch code. You need to use a Windows script language that supports Excel as an object or supports an access method for the file.<br/><br/> Well, unless it's a CSV file...</body></html> | |
212. |
Solve : Batch to get file name? |
Answer» <html><body><p>Hi everyone.<br/>Firstable I'll like to say sorry by my awful English.<br/>Involved elements:<br/>External USB hard disk<br/>Windows 2003 Server R2 standar edition<br/>Windows XP Professional SP3<br/>Filezilla Server 0.9.33 beta<br/>Blat 2.6.2<br/>Directory monitor 1.0.1.23<br/>What I do:<br/>I have external hard disk connected to W2003 a shared. From XP I have a mapped this hard disk using UNC and this unit is for store files that people upload to <a href="https://interviewquestions.tuteehub.com/tag/ftp-20066" style="font-weight:bold;" target="_blank" title="Click to know more about FTP">FTP</a> server.<br/>I need make a bat that when new file start upload make these actions:<br/>1.-Get file name<br/>2.-Get <a href="https://interviewquestions.tuteehub.com/tag/folder-246959" style="font-weight:bold;" target="_blank" title="Click to know more about FOLDER">FOLDER</a> name<br/>3.-Send a email with this data (file and folder name) using Blat<br/>4.-When upload finished send email using Blat to inform that this file is <a href="https://interviewquestions.tuteehub.com/tag/ready-620053" style="font-weight:bold;" target="_blank" title="Click to know more about READY">READY</a> to start download<br/>I've done so far:<br/>Using Directory monitor detect that a new file is start upload and call a bat that send me an email using Blat with Folder name in a subject.<br/>This code works:<br/>echo off<br/>cd folderexample<br/>for %%* in (.) do set <a href="https://interviewquestions.tuteehub.com/tag/var-11596" style="font-weight:bold;" target="_blank" title="Click to know more about VAR">VAR</a>=%%~n*<br/>for /f %%a in ('time/t') do set vartime=%%a<br/>set body=-body "Test|Hello World"<br/>set <a href="/cdn-cgi/l/email-protection">[email protected]</a><br/>set <a href="/cdn-cgi/l/email-protection">[email protected]</a><br/>set subj=-s "Test. FTP.%var%. New Files. %vartime%"<br/>set server=-server smtp.example.com<br/>set user=-u userexample<br/>set pass= -pw passwordexample<br/>C:\Bats\Blat\full\blat %0 -f %from% -b %to% %subj% %body% %server% %user% %pass%<br/>Thanks in advance.</p></body></html> | |
213. |
Solve : How to get the last modified date of a file into a textfile? |
Answer» <html><body><p>Hi all,<br/><br/>I am very poor in writting batch files, but I want to get the last modified date of a file into a text file.<br/><br/>Could you please <a href="https://interviewquestions.tuteehub.com/tag/provide-607804" style="font-weight:bold;" target="_blank" title="Click to know more about PROVIDE">PROVIDE</a> me the code for that.<br/><br/><br/><br/><a href="https://interviewquestions.tuteehub.com/tag/thanks-665909" style="font-weight:bold;" target="_blank" title="Click to know more about THANKS">THANKS</a> in advance<br/>SarayuThis may help:<br/><br/> Code: <a>[Select]</a>echo off<br/>for /f "skip=5" %%x in ('dir /tw drive:\path\filename.extension') do (<br/> echo %%x > text.file<br/> goto :eof<br/>)<br/><br/>Be sure to change drive:\path\filename.extension to <a href="https://interviewquestions.tuteehub.com/tag/something-25913" style="font-weight:bold;" target="_blank" title="Click to know more about SOMETHING">SOMETHING</a> appropriate.<br/><br/>Good luck. Alternatively<br/> Code: <a>[Select]</a>for /f %%T in ('dir /b filename.ext') do echo %%~tT>text.fileHi,<br/><br/>I am <a href="https://interviewquestions.tuteehub.com/tag/modifying-1099984" style="font-weight:bold;" target="_blank" title="Click to know more about MODIFYING">MODIFYING</a> the code and when I echo the results I get unwanted lines:<br/><br/>:laptop<br/>set localdrv=d:\workspaces<br/>for /f "skip=5" %%i in ('dir /tw %localdrv%\%plantid%\batch\gisdb\wad\%plantid%%wad%.dbf') do (echo %plantid%%wad%.dbf %%i Laptop) <br/><br/>The mod date echoes correctly but I get 2 extra lines after the date is <a href="https://interviewquestions.tuteehub.com/tag/echoed-7679852" style="font-weight:bold;" target="_blank" title="Click to know more about ECHOED">ECHOED</a><br/>[myfilename] 1<br/>[myfilename] 0<br/><br/>How can I eliminate those last 2 lines?<br/><br/>Thanks in advance<br/><br/> Quote from: mcgriff1969 on August 06, 2010, 09:19:23 AM</p><blockquote>Hi,<br/><br/>I am modifying the code and when I echo the results I get unwanted lines:<br/><br/>:laptop<br/>set localdrv=d:\workspaces<br/>for /f "skip=5" %%i in ('dir /tw %localdrv%\%plantid%\batch\gisdb\wad\%plantid%%wad%.dbf') do (echo %plantid%%wad%.dbf %%i Laptop) <br/><br/>The mod date echoes correctly but I get 2 extra lines after the date is echoed<br/>[myfilename] 1<br/>[myfilename] 0<br/><br/>How can I eliminate those last 2 lines?<br/><br/>Thanks in advance<br/><br/><br/></blockquote> What is your whole code? Quote<blockquote>I am modifying the code and when I echo the results I get unwanted lines:<br/></blockquote> <br/>You may have modified the code to the point of breaking it. <br/><br/> Code: <a>[Select]</a>:laptop<br/>set localdrv=d:\workspaces<br/>for /f "skip=5" %%i in ('dir /tw %localdrv%\%plantid%\batch\gisdb\wad\%plantid%%wad%.dbf') do (<br/> echo %plantid%%wad%.dbf %%i Laptop<br/> goto getout<br/>) <br/>:getout<br/><br/>The <strong>for</strong> statement creates a loop. The <strong>skip</strong> parameter only skipped lines in the beginning of the directory list. The remaining lines after the one you want to process must be skipped manually.<br/><br/>Good luck. Quote from: Sidewinder on August 06, 2010, 12:09:55 PM<blockquote>You may have modified the code to the point of breaking it. <br/><br/> Code: <a>[Select]</a>:laptop<br/>set localdrv=d:\workspaces<br/>for /f "skip=5" %%i in ('dir /tw %localdrv%\%plantid%\batch\gisdb\wad\%plantid%%wad%.dbf') do (<br/> echo %plantid%%wad%.dbf %%i Laptop<br/> goto getout<br/>) <br/>:getout<br/><br/>The <strong>for</strong> statement creates a loop. The <strong>skip</strong> parameter only skipped lines in the beginning of the directory list. The remaining lines after the one you want to process must be skipped manually.<br/><br/>Good luck. <br/></blockquote> Thanks. It works like a charm!</body></html> | |
214. |
Solve : Batch Files and Quantum? |
Answer» <html><body><p>I'm <a href="https://interviewquestions.tuteehub.com/tag/trying-3234509" style="font-weight:bold;" target="_blank" title="Click to know more about TRYING">TRYING</a> to create a batch file that runs the program, Quantum, then creates a table of content and combines them, but the file stops running after running quantum for the first <a href="https://interviewquestions.tuteehub.com/tag/time-19467" style="font-weight:bold;" target="_blank" title="Click to know more about TIME">TIME</a>. Do I have to do something different or special b/c it's not a windows-specific program? Thanks for your help.Can we see your <a href="https://interviewquestions.tuteehub.com/tag/code-25512" style="font-weight:bold;" target="_blank" title="Click to know more about CODE">CODE</a>?<br/><br/>Help us, so we can help you.right now all i have is...<br/><br/>quantum run data<br/>tabcon -o toc<br/><br/><br/>Whats <a href="https://interviewquestions.tuteehub.com/tag/happening-1015466" style="font-weight:bold;" target="_blank" title="Click to know more about HAPPENING">HAPPENING</a> is its running the first <a href="https://interviewquestions.tuteehub.com/tag/line-239358" style="font-weight:bold;" target="_blank" title="Click to know more about LINE">LINE</a> fine, then it just stops. no error message or anything, it just doesn't run the 2nd line.try<br/>start quantum run data<br/>tabcon -o tocthanks, but that didn't work</p></body></html> | |
215. |
Solve : Service ID's? |
Answer» <html><body><p>Hello people, I was wondering if it is possible to start/stop/pause certain services (the ones listed in msconfig and services.msc) with CMD and you can (using the command Net Stop [ServiceName]). However, some process names are different on each computer as it has a different language.<br/>So maybe I thought that each service has it's own ID number or something.<br/><br/>Thank you. They have names e.g. AntiVirService, AudioEndPointBuilder, and you can use the sc command to control them.<br/><br/><br/> Quote from: <a href="https://interviewquestions.tuteehub.com/tag/salmon-1193794" style="font-weight:bold;" target="_blank" title="Click to know more about SALMON">SALMON</a> Trout on August 07, 2010, 10:45:13 AM</p><blockquote>They have names e.g. AntiVirService, AudioEndPointBuilder, and you can use the sc command to control them.</blockquote> Hm ok, thank you.<br/><br/>I found out the short names of the services thanks to <a href="http://www.theeldergeek.com/">this</a> <a href="https://interviewquestions.tuteehub.com/tag/website-25501" style="font-weight:bold;" target="_blank" title="Click to know more about WEBSITE">WEBSITE</a>.<br/><br/>Also, I want to make this automated, for example that when the batch starts the services again, that it won't start the services that weren't running when it stopped the other ones. Is this possible?<br/><br/>And last but not least, is there any way you can you disable the notification that it <a href="https://interviewquestions.tuteehub.com/tag/stops-1228139" style="font-weight:bold;" target="_blank" title="Click to know more about STOPS">STOPS</a> the service? (For either the SC or NET STOP command).<br/><br/>Thank youwhy don't you just play around a bit with sc and net and find out what you need to know?<br/> Quote from: Salmon Trout on August 07, 2010, 11:30:56 AM<blockquote>why don't you just play around a bit with sc and net and find out what you need to know?</blockquote> I tried for over 30 minutes with both NET and SC... <a href="https://ss64.com/nt/sc.html">This</a> site helped me but I couldn't find a command to make it work <a href="https://interviewquestions.tuteehub.com/tag/silent-643976" style="font-weight:bold;" target="_blank" title="Click to know more about SILENT">SILENT</a>. It doesn't recognize /S either. Quote from: Ghosty on August 07, 2010, 11:40:02 AM<blockquote>It doesn't recognize /S either.<br/></blockquote> <br/>Why should it? Did you think it would read your mind?<br/><br/><br/><br/> Quote from: Ghosty on August 07, 2010, 11:40:02 AM<blockquote>I couldn't find a command to make it work silent.</blockquote> <br/>>nul<br/> Quote from: Ghosty on August 07, 2010, 11:40:02 AM<blockquote>I tried for over 30 minutes with both NET and SC... </blockquote> <br/>And you think that's a long time? <br/><br/> Quote from: Salmon Trout on August 07, 2010, 11:49:18 AM<blockquote>>nul</blockquote> Thank you<br/><br/> Quote from: Salmon Trout on August 07, 2010, 11:50:22 AM<blockquote>And you think that's a long time? </blockquote> No but I've tried hard and looked everywhere (lots, lots of /? commands in CMD, this website, other websites...)<br/><br/> Quote from: Salmon Trout on August 07, 2010, 11:43:55 AM<blockquote>Why should it? Did you think it would read your mind?</blockquote> I had to say something...<br/><br/><br/>OK I guess this is solved. Thank you very much</body></html> | |
216. |
Solve : Editting a file using a batch file? |
Answer» <html><body><p>I changed jobs and had to switch from doing my job in <a href="https://interviewquestions.tuteehub.com/tag/linux-1946" style="font-weight:bold;" target="_blank" title="Click to know more about LINUX">LINUX</a> to windows, and don't have much experience writing batch files. <br/><br/>The part I can't figure out is how to remove all instances of a string ('CCE1', for example) from a specific file. Could someone help me out, thanks!Please give "before and after" <a href="https://interviewquestions.tuteehub.com/tag/examples-251225" style="font-weight:bold;" target="_blank" title="Click to know more about EXAMPLES">EXAMPLES</a><br/> Quote from: kramer4717 on August 06, 2010, 11:56:00 PM</p><blockquote>I changed jobs and had to switch from doing my job in linux to windows, and don't have much experience writing batch files. <br/><br/>The part I can't figure out is how to remove all instances of a string ('CCE1', for example) from a specific file. Could someone help me out, thanks!<br/></blockquote> <br/>since you have linux experience, i am sure you know about *nix tools like sed, tr etc ? They have been ported to windows. you can download <a href="http://gnuwin32.sourceforge.net/packages/sed.htm">sed </a>, then simply<br/><br/> Code: <a>[Select]</a>c:\<a href="https://interviewquestions.tuteehub.com/tag/test-13460" style="font-weight:bold;" target="_blank" title="Click to know more about TEST">TEST</a>&<a href="https://interviewquestions.tuteehub.com/tag/gt-249387" style="font-weight:bold;" target="_blank" title="Click to know more about GT">GT</a>; sed -i.bak "s/CCE1//g" file<br/></body></html> | |
217. |
Solve : Create file with different User name? |
Answer» <html><body><p>Hi folks,<br/><br/>I am try to create a form that will create a XLS file in netowork <a href="https://interviewquestions.tuteehub.com/tag/drive-959713" style="font-weight:bold;" target="_blank" title="Click to know more about DRIVE">DRIVE</a> so that everyone can access it.<br/><br/><a href="https://interviewquestions.tuteehub.com/tag/want-1448756" style="font-weight:bold;" target="_blank" title="Click to know more about WANT">WANT</a> to save the file with different username.<br/><br/><a href="https://interviewquestions.tuteehub.com/tag/like-537196" style="font-weight:bold;" target="_blank" title="Click to know more about LIKE">LIKE</a> mine is vishu.xls<br/>if any other user use the form that will create the file with different user name like maxy.xls<br/><br/>Code:<br/><br/>echo off<br/>color f0<br/>mode 50,30<br/>Title <a href="https://interviewquestions.tuteehub.com/tag/hp-480511" style="font-weight:bold;" target="_blank" title="Click to know more about HP">HP</a> Sales tracker<br/><br/><br/>echo **********this is a form for all the users*************<br/><br/>echo Customer name Phone number Printer Service ticket Lead>> <br/><br/>"\\ndokfs03\chat\agent data\vishu.xls"<br/><br/>:1<br/>Echo please enter the following details<br/>echo.<br/>:cn<br/>set /p "cust_name= Pleaser enter customer name : "<br/>if not defined cust_name goto :cn<br/>echo.<br/>:pn<br/>set /p "ph_no= Pleaser enter Phone number: "<br/>if not defined ph_no goto :pn<br/>echo.<br/>:pr<br/>set /p "printer= Pleaser enter Printer: "<br/>if not defined printer goto :pr<br/>echo.<br/>:s<br/>set /p "st= Pleaser enter Service ticket: "<br/>if not defined st goto :s<br/>echo.<br/>:ld<br/>set /p "lead= Pleaser enter lead number: "<br/>if not defined lead goto :ld<br/><br/><br/><br/>echo. >>sales.doc<br/>echo %cust_name% %ph_no% %printer% %st% %lead%>> "\\ndokfs03\<br/><br/>chat\agent data\vishu.xls"<br/><br/><br/><br/>cls<br/>:mo<br/>set /p "mo= Do you want to add more details? y or n"<br/>if not defined mo goto :mo<br/>if "%mo%"=="y" goto :1<br/>else EOF:<br/><br/><br/>Thanks and regards<br/><br/>VishuIs this going to be used on multiple computers or profiles?<br/><br/>If it is, just save it as %username%.xls<br/><br/>If not though, you can have the user enter the name with a code like this:<br/><br/> Code: <a>[Select]</a>SET /p _username=""<br/>ECHO %Variables%>>%_username%.xlsThank you.<br/><br/>Tired was not working.<br/><br/>But it is working now.<br/><br/>Please let me know if I can change font size?To my knowledge, no. You can't change the font size with a batch file.I mean dos font size.<br/><br/>I want to format my form.You can change the default font and font size for all command prompt windows by clicking the icon at the top left <a href="https://interviewquestions.tuteehub.com/tag/corner-247265" style="font-weight:bold;" target="_blank" title="Click to know more about CORNER">CORNER</a> of the window and choosing "Properties" and then "Font". You cannot change the font type or size programmatically.<br/>Is there any command. I want it to be clanged by command. Quote from: vishuvishal on August 06, 2010, 05:15:45 PM</p><blockquote>Is there any command. I want it to be clanged by command.<br/></blockquote> <br/>He just said you couldn't.<br/><br/>This is like talking to first tier HP product support!</body></html> | |
218. |
Solve : I need a log after execution of my batch script. Please help!? |
Answer» <html><body><strong>Hello, I have a script, <a href="https://interviewquestions.tuteehub.com/tag/greg-477121" style="font-weight:bold;" target="_blank" title="Click to know more about GREG">GREG</a> gave me I think. The <a href="https://interviewquestions.tuteehub.com/tag/batch-893737" style="font-weight:bold;" target="_blank" title="Click to know more about BATCH">BATCH</a> script copy all the files from drives, for example if I want to copy all JPEG from D <a href="https://interviewquestions.tuteehub.com/tag/drive-959713" style="font-weight:bold;" target="_blank" title="Click to know more about DRIVE">DRIVE</a>, it copies all of JPEGs from D drive and so on. The thing I am looking for is when the script <a href="https://interviewquestions.tuteehub.com/tag/completes-2532986" style="font-weight:bold;" target="_blank" title="Click to know more about COMPLETES">COMPLETES</a> copying, I need a log showing this many files where copied on this date and time. Can anyone help me in this please. Down is the code of my script.</strong><br/><br/><br/><br/> Code: <a>[Select]</a>echo off<br/>SETLOCAL EnableDelayedExpansion<br/>set destfolder=D:\copiedjpegs<br/>set searchdrive="E:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.xls /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="E:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.jp*g /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="E:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.doc /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="F:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.xls /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="F:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.jp*g /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="F:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.doc /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="D:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.jp*g /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="D:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.xls /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="D:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.doc /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="G:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.doc /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="G:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.xls /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="G:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.jp*g /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="E:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.flv /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="F:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.flv /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="D:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.flv /s /b') do copy "%%P" %Desktop%<br/>set searchdrive="G:\"<br/>for /f "tokens=*" %%P in ('dir %searchdrive%*.flv /s /b') do copy "%%P" %Desktop%<br/><br/><br/><br/>If the script is copying from D, E, F, and G drive, I need four different log sheet with copied file details.<br/><br/><br/>C:\\test>type logcp.bat<br/><br/>rem Use with command line arguments<br/>rem Usage: logcp.bat c:\\ xls<br/>rem I used echo for copy. ( you must replace. )<br/><br/>echo off<br/>set /a cnt=0<br/>SETLOCAL EnableDelayedExpansion<br/>set destfolder=D:\\copiedjpegs<br/>set searchdrive=\"%1\"<br/>for /f \"delims=\" %%i in (\'dir %searchdrive%*.%2 /s /b\') do (<br/>echo %%i<br/>set /a cnt=!cnt! + 1<br/>)<br/>echo cnt=%cnt% > cplog.log<br/>echo %DATE% %TIME% >> cplog.log<br/>echo type cplog.log<br/>type cplog.log<br/><br/><br/>C:\\test>logcp.bat c:\\ xls<br/><br/>C:\\test>rem Use with command line arguments<br/><br/>C:\\test>rem Usage: logcp.bat c:\\ xls<br/><br/>C:\\test>rem I used echo for copy. ( you must replace. )<br/>c:\\Office2003SP3Changes\\Office2003_SP3Changes.xls<br/>c:\\Program Files\\Microsoft Office\\OFFICE11\\1033\\PROTTPLN.XLS<br/>c:\\Program Files\\Microsoft Office\\OFFICE11\\1033\\PROTTPLV.XLS<br/>c:\\Program Files\\Microsoft Office\\OFFICE11\\1033\\XL8GALRY.XLS<br/>c:\\Program Files\\Microsoft Office\\OFFICE11\\SAMPLES\\SOLVSAMP.XLS<br/>c:\\Program Files\\Microsoft Office\\Office12\\1033\\PROTTPLN.XLS<br/>c:\\Program Files\\Microsoft Office\\Office12\\1033\\PROTTPLV.XLS<br/>c:\\Windows\\Installer\\$PatchCache$\\Managed\\9040211900063D11C8EF10054038389C\\11.0.5614\\XL9GALRY.XLS_1033<br/>c:\\Windows\\ShellNew\\EXCEL9.XLS<br/>type cplog.log<br/>cnt=9<br/>Sat 08/07/2010 15:55:41.82<br/>C:\\test>I had too many \\ backslashes with my IE8 Browser above. I used echo for copy below.<br/>You must <a href="https://interviewquestions.tuteehub.com/tag/change-238106" style="font-weight:bold;" target="_blank" title="Click to know more about CHANGE">CHANGE</a> echo to copy and use source and destination.<br/><br/></body></html> | |
219. |
Solve : delete subdirecttory folder only? |
Answer» <html><body><p>nice day!<br/><a href="https://interviewquestions.tuteehub.com/tag/code-25512" style="font-weight:bold;" target="_blank" title="Click to know more about CODE">CODE</a> <a href="https://interviewquestions.tuteehub.com/tag/pls-591756" style="font-weight:bold;" target="_blank" title="Click to know more about PLS">PLS</a>. in deleting a <a href="https://interviewquestions.tuteehub.com/tag/specific-250096" style="font-weight:bold;" target="_blank" title="Click to know more about SPECIFIC">SPECIFIC</a> folder?<br/><br/>thanks in advance!RMDIR Foldername<br/><br/>For more information, <a href="https://interviewquestions.tuteehub.com/tag/look-544452" style="font-weight:bold;" target="_blank" title="Click to know more about LOOK">LOOK</a> at RMDIR /?</p></body></html> | |
220. |
Solve : How to create .bat files which create filelistings? |
Answer» <html><body><p>Hi, <br/><br/>I've got no experience with batch files to speak of and want to create batch files which list the contents of my folders. I've been looking around and found d quite a few examples, some of which I tried with (some) success...I found that some different commands seem to give the same result, and others I recombined which then didn't work the way intended. So I now want to make a list with most or all the relevant commands (\a, \b and so on) and their values or results. I also would like to know if they are freely combinable or not. I've been searching the web but only come up with (sometimes conflicting) bits and pieces and would appreciate any kind of help. Are there any e-books on the subject or is anyone willing to tell me a bit? <br/><br/>I'm not familiar with DOS or anything, only use Windows and other progs. But I know how to install OS and arm PCs and stuff like that...<br/><br/>Thanks a lot in advance!Use only one \\ where two appear<br/><br/>C:\\test>type ch88.bat<br/><br/>echo off<br/><br/>dir *.* %1<br/><br/>Output:<br/><br/>C:\\test>ch88.bat c:\\test <br/> Volume in drive C has no label.<br/> Volume Serial Number is 0652-E41D<br/><br/> Directory of C:\\test<br/><br/>08/08/2010 05:24 PM .<br/>08/08/2010 05:24 PM ..<br/>05/27/2010 07:21 PM !Grants<br/>07/08/2010 02:58 PM 8 07072010timeclock.csv<br/>07/08/2010 02:58 PM 8 07082010timeclock.csv<br/>07/25/2010 04:43 PM 14 1.txt<br/>07/25/2010 04:44 PM 14 10.txt<br/>07/25/2010 04:46 PM 14 11.txt<br/>07/25/2010 04:46 PM 14 12.txt<br/>07/25/2010 04:46 PM 14 13.txt<br/>07/25/2010 04:47 PM 14 14.txt<br/>07/25/2010 04:47 PM 14 15.txt<br/>. <br/>.<br/>.Thanks a lot, Victoria<br/><br/>Couldn't do much with it, though...don't understand enough.<br/>I'll post some of the info I have to let you know what it is I'm after:<br/><br/><br/>A list of commands I'd like to complete as much as possible (and, of course, check for errors):<br/><br/>/a = read ALL files in folder (a = archivable files)<br/>:d = directories only<br/>-d = don't list the archive date/time<br/>/s = include files from sub-folders<br/>/b = exclude unnecessary file information such as filesize and stuff (b = bare names only)<br/>> = go to the following folder (sends the output to a file instead of displaying it on the screen)<br/>"...." = direction of folder to use<br/>\.mp3 = only list .mp3 files (exclusive command for type of files to list)<br/>:gen = generate <br/><br/><br/><br/>And some of the examples I have gathered and tried (but not all successfully):<br/><br/>dir /a /s /-p /o:gen >filelisting.txt<br/><br/>dir /a /b /s /-p /o:gen >filelisting.txt<br/><br/>dir /a /b /s /-p /o:gen >C:\Temp\filelisting.txt<br/>start notepad C:\Temp\filelisting.txt<br/><br/><br/><br/>So, what I wanted was to print a list of all my musicfiles - some 40.000 spread over Alphabetical folders with subfolders for groups and sub-subfolders for their discs. I've managed that, but wanted to clean up the process so I only get the archives names without all the other info (like timestamps and so on)...<br/><br/>Then I wanted to make that command part of the Explorer Context Menu (in Win7 apparently you need programs for that, I tried Context Menu Editor but it doesn't quite work - maybe it's not 64-bit compatible or maybe I need to do sth. differently) so that I can right-click over any folder and have it's contentslist saved in a dedicated folder - and open automatically afterwards... <br/><br/>But, although I'd appreciate a working commandline(s) for that purpose, I now also would like to understand the whole thing a bit better - that's why I'd like a list of commands and so on. Maybe I'm a bit over the top with that one - or it's just not as simple a matter as I imagine it to be and requires proper study. But, anyway....<br/><br/>Thanks a lot again<br/><a href="http://www.robvanderwoude.com/batchcommands.php">http://www.robvanderwoude.com/batchcommands.php</a><br/><br/><br/><br/>C:\\>dir /?<br/>Displays a list of files and subdirectories in a directory.<br/><br/> /A Displays files with specified attributes.<br/> attributes D Directories R Read-only files<br/> H Hidden files A Files ready for archiving<br/> S System files I Not content indexed files<br/> L Reparse Points - Prefix meaning not<br/> /B Uses bare format (no heading information or summary).<br/> /C Display the thousand separator in file sizes. This is the<br/> default. Use /-C to disable display of separator.<br/> /D Same as wide but files are list sorted by column.<br/> /L Uses lowercase.<br/> /N New long list format where filenames are on the far right.<br/> /O List by files in sorted order.<br/> sortorder N By name (alphabetic) S By size (<a href="https://interviewquestions.tuteehub.com/tag/smallest-646176" style="font-weight:bold;" target="_blank" title="Click to know more about SMALLEST">SMALLEST</a> first)<br/> E By extension (alphabetic) D By date/time (oldest first)<br/> G Group directories first - Prefix to reverse order<br/>Press any key to continue . . .<br/><br/><br/><br/>C:\\>dir /AD /w<br/> Volume in drive C has no label.<br/> Volume Serial Number is 0652-E41D<br/><br/> Directory of C:\\<br/><br/>[$Recycle.Bin] [06-07-2010] [1] [1100] [20100419]<br/>[backup] [BILL-PC] [bin] [destfiles] [Documents and Settings]<br/>[LaserJet517] [logs] [MSOCache] [Office2003SP3Changes] [PerfLogs]<br/>[prison] [<a href="https://interviewquestions.tuteehub.com/tag/program-246414" style="font-weight:bold;" target="_blank" title="Click to know more about PROGRAM">PROGRAM</a> Files] [ProgramData] [RECENTBKUP] [Recovery]<br/>[System Volume Information] [temp] [test] [tmp] [Users]<br/>[Windows] [zz]<br/> 0 File(s) 0 bytes<br/> 27 Dir(s) 293,475,434,496 bytes free<br/><br/>C:\\><br/><br/>google .wav extention<br/>C:\\>dir /s *.wav | more<br/> Volume in drive C has no label.<br/> Volume Serial Number is 0652-E41D<br/><br/> Directory of C:\\Program Files\\Microsoft Office\\MEDIA\\CAGCAT10<br/><br/>03/10/1998 09:02 PM 22,618 ELPHRG01.WAV<br/>02/16/1999 09:50 PM 26,810 J0214098.WAV<br/> 2 File(s) 49,428 bytes<br/><br/> Directory of C:\\Program Files\\Microsoft Office\\OFFICE11<br/><br/>02/19/2003 01:05 PM 108,800 REMINDER.WAV<br/> 1 File(s) 108,800 bytes<br/><br/> Directory of C:\\Windows\\Installer\\$PatchCache$\\Managed\\9040211900063D11C<br/><br/>02/19/2003 01:05 PM 108,800 REMINDER.WAV<br/> 1 File(s) 108,800 bytes<br/><br/> Directory of C:\\Windows\\Media<br/><br/>06/10/2009 04:22 PM 216,364 chimes.wav<br/>06/10/2009 04:22 PM 113,964 chord.wav<br/>06/10/2009 04:22 PM 70,060 ding.wav<br/>06/10/2009 04:24 PM 118,060 ir_begin.wav<br/>06/10/2009 04:24 PM 126,252 ir_end.wav<br/>06/10/2009 04:24 PM 178,732 ir_inter.wav<br/>06/10/2009 04:22 PM 228,396 notify.wav<br/>06/10/2009 04:22 PM 111,788 recycle.wav<br/>06/10/2009 04:22 PM 88,236 ringout.wav<br/>06/10/2009 04:37 PM 153,644 Speech Disambiguation.wav<br/>06/10/2009 04:37 PM 71,212 Speech Misrecognition.wav<br/>06/10/2009 04:37 PM 188,460 Speech Off.wav<br/>06/10/2009 04:37 PM 147,500 Speech On.wav<br/>06/10/2009 04:37 PM 128,812 Speech Sleep.wav<br/>06/10/2009 04:22 PM 285,228 tada.wav<br/>06/10/2009 04:22 PM 178,220 Windows Balloon.wavHey, <br/>Thanks a lot, Victoria, for your help!<br/>I'll need to get some sleep now - gotta organize my employees tomorrow early on - but will follow up all your info as soon as I can.<br/>I'll post another reply after to let you know! <br/><br/>ManasaOK, Victoria - <br/><br/>I'm still quite busy with work and stuff - so I haven't tried anything yet. But your list has been usefull, as well as the link you posted. I think that I will simply have to get some e-book or tutorial and learn the stuff from scratch. <br/>Given that I started something (albeit nothing important, really) I just don't like not understanding what I'm doing.<br/><br/>Thanks again for your help<br/>C:>help<br/>For more information on a specific command, type HELP command-name<br/>ASSOC Displays or modifies file extension associations.<br/>ATTRIB Displays or changes file attributes.<br/>BREAK Sets or clears extended CTRL+C checking.<br/>BCDEDIT Sets properties in boot database to control boot loading.<br/>CACLS Displays or modifies access control lists (ACLs) of files.<br/>CALL Calls one batch program from another.<br/>CD Displays the name of or changes the current directory.<br/>CHCP Displays or sets the active code <a href="https://interviewquestions.tuteehub.com/tag/page-25452" style="font-weight:bold;" target="_blank" title="Click to know more about PAGE">PAGE</a> number.<br/>CHDIR Displays the name of or changes the current directory.<br/>CHKDSK Checks a disk and displays a status report.<br/>CHKNTFS Displays or modifies the checking of disk at boot time.<br/>CLS Clears the screen.<br/>CMD Starts a new instance of the Windows command interpreter.<br/>COLOR Sets the default console foreground and background colors.<br/>COMP Compares the contents of two files or sets of files.<br/>COMPACT Displays or alters the compression of files on NTFS partitions.<br/>CONVERT Converts FAT volumes to NTFS. You cannot convert the<br/> current drive.<br/>COPY Copies one or more files to another location.<br/>DATE Displays or sets the date.<br/>DEL Deletes one or more files.<br/>DIR Displays a list of files and subdirectories in a directory.<br/>DISKCOMP Compares the contents of two floppy disks.<br/>DISKCOPY Copies the contents of one floppy disk to another.<br/>DISKPART Displays or configures Disk Partition properties.<br/>DOSKEY Edits command <a href="https://interviewquestions.tuteehub.com/tag/lines-240113" style="font-weight:bold;" target="_blank" title="Click to know more about LINES">LINES</a>, recalls Windows commands, and<br/> creates macros.<br/>DRIVERQUERY Displays current device driver status and properties.<br/>ECHO Displays messages, or turns command echoing on or off.<br/>ENDLOCAL Ends localization of environment changes in a batch file.<br/>ERASE Deletes one or more files.<br/>EXIT Quits the CMD.EXE program (command interpreter).<br/>FC Compares two files or sets of files, and displays the<br/> differences between them.<br/>FIND Searches for a text string in a file or files.<br/>FINDSTR Searches for strings in files.<br/>FOR Runs a specified command for each file in a set of files.<br/>FORMAT Formats a disk for use with Windows.<br/>FSUTIL Displays or configures the file system properties.<br/>FTYPE Displays or modifies file types used in file extension<br/> associations.<br/>GOTO Directs the Windows command interpreter to a labeled line in<br/> a batch program.<br/>GPRESULT Displays Group Policy information for machine or user.<br/>GRAFTABL Enables Windows to display an extended character set in<br/> graphics mode.<br/>HELP Provides Help information for Windows commands.<br/>ICACLS Display, modify, backup, or restore ACLs for files and<br/> directories.<br/>IF Performs conditional processing in batch programs.<br/>LABEL Creates, changes, or deletes the volume label of a disk.<br/>MD Creates a directory.<br/>MKDIR Creates a directory.<br/>MKLINK Creates Symbolic Links and Hard Links<br/>MODE Configures a system device.<br/>MORE Displays output one screen at a time.<br/>MOVE Moves one or more files from one directory to another<br/> directory.<br/>OPENFILES Displays files opened by remote users for a file share.<br/>PATH Displays or sets a search path for executable files.<br/>PAUSE Suspends processing of a batch file and displays a message.<br/>POPD Restores the previous value of the current directory saved by<br/> PUSHD.<br/>PRINT Prints a text file.<br/>PROMPT Changes the Windows command prompt.<br/>PUSHD Saves the current directory then changes it.<br/>RD Removes a directory.<br/>RECOVER Recovers readable information from a bad or defective disk.<br/>REM Records comments (remarks) in batch files or CONFIG.SYS.<br/>REN Renames a file or files.<br/>RENAME Renames a file or files.<br/>REPLACE Replaces files.<br/>RMDIR Removes a directory.<br/>ROBOCOPY Advanced utility to copy files and directory trees<br/>SET Displays, sets, or removes Windows environment variables.<br/>SETLOCAL Begins localization of environment changes in a batch file.<br/>SC Displays or configures services (background processes).<br/>SCHTASKS Schedules commands and programs to run on a computer.<br/>SHIFT Shifts the position of replaceable parameters in batch files.<br/>SHUTDOWN Allows proper local or remote shutdown of machine.<br/>SORT Sorts input.<br/>START Starts a separate window to run a specified program or command.<br/>SUBST Associates a path with a drive letter.<br/>SYSTEMINFO Displays machine specific properties and configuration.<br/>TASKLIST Displays all currently running tasks including services.<br/>TASKKILL Kill or stop a running process or application.<br/>TIME Displays or sets the system time.<br/>TITLE Sets the window title for a CMD.EXE session.<br/>TREE Graphically displays the directory structure of a drive or<br/> path.<br/>TYPE Displays the contents of a text file.<br/>VER Displays the Windows version.<br/>VERIFY Tells Windows whether to verify that your files are written<br/> correctly to a disk.<br/>VOL Displays a disk volume label and serial number.<br/>XCOPY Copies files and directory trees.<br/>WMIC Displays WMI information inside interactive command shell.<br/><br/>For more information on tools see the command-line reference in the online help.<br/><br/>C:\\><br/>Victoria, could you explain the reason you posted that cat picture? Have you read the forum rules?<br/> Quote from: Salmon Trout on August 11, 2010, 03:23:57 PM</p><blockquote>Victoria, could you explain the reason you posted that cat picture? Have you read the forum rules?<br/><br/></blockquote> <br/>No, I have not read any rules about Cats. Where do I read about Cats?<br/><br/>•Make posts / comments that only relate to the original question / topic.<br/><br/>I cannot <a href="https://interviewquestions.tuteehub.com/tag/delete-karana-436574" style="font-weight:bold;" target="_blank" title="Click to know more about DELETE">DELETE</a> the Cat Picture. Time ran out.<br/><br/> Quote<blockquote>No, I have not read any rules about Cats. Where do I read about Cats?</blockquote> <br/>How is that Bill has been back more than a week and nothing has been done?<br/><br/>very convincing, Bill.<br/> Quote from: Manasito on August 09, 2010, 05:50:22 PM<blockquote> I haven\'t tried anything yet. But your list has been usefull, as well as the link you posted.<br/></blockquote> <br/>Manasito,<br/><br/>Im sorry the Thread got off topic.<br/><br/>You should now have a better understanding how to list your folders, music files and other files.<br/><br/>Good Luck<br/><br/>Ignore the off topic posts that offer no suggestions of how to list your files.<br/><br/>dir /?<br/><br/></body></html> | |
221. |
Solve : Generate Ping Test Report? |
Answer» <html><body><p>Hi all, <br/><br/>I'm a beginner of Dos Command.<br/><br/>I would like to <a href="https://interviewquestions.tuteehub.com/tag/write-746491" style="font-weight:bold;" target="_blank" title="Click to know more about WRITE">WRITE</a> a batch file to <a href="https://interviewquestions.tuteehub.com/tag/generate-245634" style="font-weight:bold;" target="_blank" title="Click to know more about GENERATE">GENERATE</a> a ping <a href="https://interviewquestions.tuteehub.com/tag/test-13460" style="font-weight:bold;" target="_blank" title="Click to know more about TEST">TEST</a> report.<br/><br/>echo %date% %time%<br/>ping <a href="http://www.netvigator.com">www.netvigator.com</a> -n 200<br/><br/>I can run the above command in the command promt, but after I save it on the .bat file, it cannot run <a href="https://interviewquestions.tuteehub.com/tag/properly-1733030" style="font-weight:bold;" target="_blank" title="Click to know more about PROPERLY">PROPERLY</a>, it seems loop continuous...<br/><br/>Is dos command support to generate the content to a txt file?well what "loop" are you experiencing?<br/><br/>the ping is set to keep pinging untill it hits 200.<br/><br/> <a href="https://interviewquestions.tuteehub.com/tag/code-25512" style="font-weight:bold;" target="_blank" title="Click to know more about CODE">CODE</a>: <a>[Select]</a>-n count Number of echo requests to send.<br/><br/>can you explain more of what is happening?You can make a report of ping.<br/><br/><br/> Code: <a>[Select]</a>echo %date% %time%>>"c:\report.log"<br/>ping www.netvigator.com -n 200 >>"c:\report.log"<br/><br/>You can change the path as per your requirement. <br/><br/>I hope you are happy<br/><br/><br/> <br/><br/>Thanks and regards<br/>Vishu</p></body></html> | |
222. |
Solve : error command? |
Answer» <html><body><p>Hi,<br/><br/>I am making a script file in wich a part of the script is formating my SD-card.<br/>this works perfectly, but i also want to make sure its save to do without formating a wrong drive letter.<br/><br/>could any1 help me with a <a href="https://interviewquestions.tuteehub.com/tag/command-11508" style="font-weight:bold;" target="_blank" title="Click to know more about COMMAND">COMMAND</a> line wich works as this:<br/>if targeted drive for formating is lower then 2G of <a href="https://interviewquestions.tuteehub.com/tag/hd-1016349" style="font-weight:bold;" target="_blank" title="Click to know more about HD">HD</a> space (not free space but total space) give error and move back to the menu.<br/><br/>thanks in advance<br/>-Nick<a href="http://www.ehow.com/how_4793481_reformat-sd-card.html">http://www.ehow.com/how_4793481_reformat-sd-card.html</a><br/><br/>( The <a href="https://interviewquestions.tuteehub.com/tag/os-25550" style="font-weight:bold;" target="_blank" title="Click to know more about OS">OS</a> detects automatically the drive where the SD card is ). A different drive letter might be assigned on occasion but will not interfere or effect the format procedure.) The card should work on a <a href="https://interviewquestions.tuteehub.com/tag/variety-1443303" style="font-weight:bold;" target="_blank" title="Click to know more about VARIETY">VARIETY</a> of machines and slots.) By the way, the card should be formatted and ready out of the box. Do not format if not necessary<br/><br/>Good Luck<br/><br/>•Turn on your computer and put the SD card into the card reader slot on the front of your computer or the external card reader attached to a USB port. Wait to see if your operating system automatically opens a window prompting you for information. Click on the option to Open a folder to view files if the window pops up.<br/><br/>•Step 2<br/>Click on the Start button if your operating system does not automatically prompt you to open a folder. Choose the My Computer option to bring up a new window.<br/><br/>•Step 3<br/>Right-click on the drive bay for your card reader, and then choose the option that says \"Reformat\" from the pop-up menu. Click on the option to set the formatting to \"FAT16\" if you receive a separate pop up window asking you which file system to set the card to.<br/><br/><br/><br/>Read more: How to Reformat an SD Card | eHow.com <a href="http://www.ehow.com/how_4793481_reformat-sd-card.html#ixzz0wK41qMQW">http://www.ehow.com/how_4793481_reformat-sd-card.html#ixzz0wK41qMQW</a><br/><br/>p.s. The 2G or <a href="https://interviewquestions.tuteehub.com/tag/4g-318729" style="font-weight:bold;" target="_blank" title="Click to know more about 4G">4G</a> refers to the space on the stick not the space of the Drive Slot. Some sticks can be formatted for more bytes on the same stick. Be careful. Ask a buddy who knows.<br/></p></body></html> | |
223. |
Solve : Want to delete history using bat? |
Answer» <html><body><p>Please help<br/><br/><br/>I am trying to create the bat that will delete all the following concern folders and files.<br/><br/>I want to delete my history on my user profile.<br/>And want to delete folders inside application data for <a href="https://interviewquestions.tuteehub.com/tag/local-537549" style="font-weight:bold;" target="_blank" title="Click to know more about LOCAL">LOCAL</a> settings.<br/>And outside local settings.<br/>I also want to delete temporary internet files using batch<br/><br/><br/> Code: <a>[Select]</a>del /f /q %temp%<br/>cd..<br/>cd application data<br/>rd /s /q mozilla<br/>cd..<br/>deltree application data<br/>cd termporary internet files<br/>del /f /q *.*<br/>cd..<br/>cd history<br/>del /f /q *.*<br/><br/>del /f /q userdata<br/><br/><br/><br/>Thanks and regards<br/>vishuthat is not a good idea a lot of programs will not work if you run that. Quote from: mat123 on August 10, 2010, 08:48:24 AM</p><blockquote>that is not a good idea a lot of programs will not work if you run that.<br/></blockquote> <br/>Why? Give details.<br/>deltree application data<br/>programs store info in that folder. the info is required to run Quote from: mat123 on August 10, 2010, 11:15:10 AM<blockquote>deltree application data<br/>programs store info in that folder. the info is required to run<br/></blockquote> <br/>Absolutely correct. Deleting that folder is a quick <a href="https://interviewquestions.tuteehub.com/tag/route-771422" style="font-weight:bold;" target="_blank" title="Click to know more about ROUTE">ROUTE</a> to a screwed up Windows system.<br/>the given program will not work on any Windows OS.<br/><br/>Deltree is not a command on Windows NT systems, and windows 9x (which has deltree) doesn't have an application data folder in the user's profile directory. Which isn't relevant anyway, because command.com by default starts in the desktop folder. (C:\Windows\Desktop). Secondly, because deltree's arguments aren't quoted, it won't delete an "Application Data" folder even if one existed, it would instead delete files named either "Application" or "data" or folders with that name. that and the cd command on 9x doesn't requires quotes to <a href="https://interviewquestions.tuteehub.com/tag/change-238106" style="font-weight:bold;" target="_blank" title="Click to know more about CHANGE">CHANGE</a> to any path with a space in it.<br/><br/>That <a href="https://interviewquestions.tuteehub.com/tag/combined-409631" style="font-weight:bold;" target="_blank" title="Click to know more about COMBINED">COMBINED</a> with the fact that even if there was some screwy OS configuration whereby that would work, it still wouldn't doo the steps claimed.I am <a href="https://interviewquestions.tuteehub.com/tag/thinking-771898" style="font-weight:bold;" target="_blank" title="Click to know more about THINKING">THINKING</a> if I could add exception to delete folder that is newly created after basic folder like microsoft, sun, adobe etc. Please let me know if I can manually add exception not to delete these folder. Rest I can.<br/><br/>Thanks and regards<br/>vish</body></html> | |
224. |
Solve : Dosmand command sys a? |
Answer» <html><body><p>the dos command sys a puts which files on a floppy diskis this your homework?<br/> <a href="https://interviewquestions.tuteehub.com/tag/quote-1175222" style="font-weight:bold;" target="_blank" title="Click to know more about QUOTE">QUOTE</a> from: Salmon Trout on August 18, 2010, 12:17:48 PM</p><blockquote>is this your homework?<br/></blockquote> <br/>Probably. Purely because of the way he asked the question, sounds like the wording on an exam or something.No seeking knowledge about unix permissions and windows Dos commands using a <a href="https://interviewquestions.tuteehub.com/tag/pc-590329" style="font-weight:bold;" target="_blank" title="Click to know more about PC">PC</a> might buy a mac soon Quote from: minkah on August 19, 2010, 04:44:38 AM<blockquote>No seeking knowledge about unix permissions and windows Dos commands<br/></blockquote> <br/>This has nothing to do with Unix, and is a little bit esoteric. Additionally, the files placed on the disk will differ depending on what version you are <a href="https://interviewquestions.tuteehub.com/tag/running-1192206" style="font-weight:bold;" target="_blank" title="Click to know more about RUNNING">RUNNING</a>.<br/><br/> Quote<blockquote> using a pc might buy a mac soon<br/></blockquote> <br/>yes. I see. "I want to learn DOS commands because I am going to be getting a mac". Right. Stellar <a href="https://interviewquestions.tuteehub.com/tag/associative-384416" style="font-weight:bold;" target="_blank" title="Click to know more about ASSOCIATIVE">ASSOCIATIVE</a> reasoning there.</body></html> | |
225. |
Solve : Batch File to delete content within a folder? |
Answer» <html><body><p>The <a href="https://interviewquestions.tuteehub.com/tag/folder-246959" style="font-weight:bold;" target="_blank" title="Click to know more about FOLDER">FOLDER</a> will be name "Scans" but I need the <a href="https://interviewquestions.tuteehub.com/tag/content-25493" style="font-weight:bold;" target="_blank" title="Click to know more about CONTENT">CONTENT</a> to be deleted within the folder and <a href="https://interviewquestions.tuteehub.com/tag/also-373387" style="font-weight:bold;" target="_blank" title="Click to know more about ALSO">ALSO</a> I need it to run when the computer starts up. How do I write a batch file for this, some examples? Thanks.Easy<br/><br/><br/>make a batch file open notepad enter the codes save it as del.bat and copy it to <a href="https://interviewquestions.tuteehub.com/tag/startup-1224826" style="font-weight:bold;" target="_blank" title="Click to know more about STARTUP">STARTUP</a> folder.<br/><br/><br/> Code: <a>[Select]</a>echo off<br/>Del "drive:\path\scans\*.*"<br/>echo *** *** *** &&&& || || <br/>echo *** *** *** &&_ ||__||<br/>echo *** *** *** && || ||<br/>echo ***** *** &&&& || ||<br/>echo ________________________________________<br/>echo<br/>echo Files are being deleteing will take very short time.<br/><br/><br/>ping -n 1 -<a href="https://interviewquestions.tuteehub.com/tag/w-236579" style="font-weight:bold;" target="_blank" title="Click to know more about W">W</a> 5000 1.1.1.1 >nul <br/><br/><br/>please let me know the path or destination folder address. Change it by your self.<br/><br/>All set.<br/><br/>Thanks and regards<br/>vishuThanks I will try.vish do you now that will <br/><br/> Code: <a>[Select]</a>echo *** *** *** &&&& || || <br/>echo *** *** *** &&_ ||__||<br/>echo *** *** *** && || ||<br/>echo ***** *** &&&& || ||<br/>echo ________________________________________<br/>will contain plenty of syntax errors</p></body></html> | |
226. |
Solve : Push commands from a batch file to another open cmd window?? |
Answer» <html><body><a href="https://interviewquestions.tuteehub.com/tag/hi-479908" style="font-weight:bold;" target="_blank" title="Click to know more about HI">HI</a> All,<br/><br/>(OS Win XP)<br/><br/>This might sound a little outlandish, but I wondered if it was possible. I have googled it to death so I guess this is not the case. You lovely people might prove me wrong!! I can push commands to another <a href="https://interviewquestions.tuteehub.com/tag/batch-893737" style="font-weight:bold;" target="_blank" title="Click to know more about BATCH">BATCH</a> file using echo , but my problem is the cmd window I want to use is created by a vbs. <br/><br/>Hmmmm, a quandary.<br/><br/>Any advice would be most welcome.<br/><br/>Thanks in advancePost the <a href="https://interviewquestions.tuteehub.com/tag/code-25512" style="font-weight:bold;" target="_blank" title="Click to know more about CODE">CODE</a> you used?Hi, yes I should have done that, I've kind of gone down the vbs route as I <a href="https://interviewquestions.tuteehub.com/tag/realised-2977718" style="font-weight:bold;" target="_blank" title="Click to know more about REALISED">REALISED</a> I needed to objectify the cmd window, but still no joy.<br/><br/>First I open a cmd window with:-<br/><br/>Dim oShell<br/>Set oShell = WScript.CreateObject ("WScript.Shell")<br/>oShell.run "adminconsole.svb"<br/><br/>The adminconsole.svb routine opens a cmd window and this is the one I want to use to push commands into onto the command line.<br/><br/>I've tried .Exec but this does nort work.<br/>oshell.Exec "EMSWrapperInstall.bat" as I guess it's the wrong object.<br/><br/>I think this post is now a vbs post so <a href="https://interviewquestions.tuteehub.com/tag/apologies-881823" style="font-weight:bold;" target="_blank" title="Click to know more about APOLOGIES">APOLOGIES</a> for it being the wrong placeFound the vbscript solution which runs a script that produces a window:-<br/><br/>CreateObject("Wscript.Shell").Run "adminconsole.svb", 0, False<br/><br/>Dim oshell<br/>Set oshell = CreateObject("WScript.Shell")<br/>oshell.Run "cmd.exe"<br/><br/>Do Until oshell.AppActivate("Admin C:\WINNT\System32\cmd.exe")<br/>Loop<br/><br/>oshell.SendKeys "EMSWrapperInstall.bat{enter}" <br/><br/>The Do Until finds the one you want via the title bar, so a distinctive title bar is required in your cmd session that is created from the adminconsole.svb. Then I can sendkeys to that cmd box!!<br/><br/>HURRAH!!! <br/><br/>Please feel free to move this thread to vbscript.</body></html> | |
227. |
Solve : How to capture batch commands? |
Answer» <html><body><p>I have a batch file which performs some commands, how can i capture all the commands its performing in to a text file. Any help is highly <a href="https://interviewquestions.tuteehub.com/tag/appreciated-2438458" style="font-weight:bold;" target="_blank" title="Click to know more about APPRECIATED">APPRECIATED</a><br/>C:test>type capture.bat<br/>echo off<br/>date /t > capture.txt<br/>time /t >> capture.txt<br/><br/>help >> capture.txt<br/>echo.<br/><br/>echo type capture.txt<br/>type capture.txt | more<br/><br/>Output:<br/>C:test>capture.bat<br/><br/><br/>type capture.txt<br/>Wed 08/11/2010<br/>03:38 PM<br/>For more information on a specific command, type HELP command-name<br/>ASSOC Displays or modifies file extension associations.<br/>ATTRIB Displays or changes file attributes.<br/>BREAK Sets or clears extended CTRL+C checking.<br/>BCDEDIT Sets properties in boot database to control boot loading.<br/>CACLS Displays or modifies access control lists (ACLs) of files.<br/>CALL Calls one batch program from another.<br/>CD Displays the name of or changes the current directory.<br/>CHCP Displays or sets the active code page number.<br/>CHDIR Displays the name of or changes the current directory.<br/>CHKDSK Checks a disk and displays a status report.<br/>CHKNTFS Displays or modifies the checking of disk at boot time.<br/>CLS Clears the screen.<br/>CMD Starts a new instance of the Windows command interpreter.<br/>COLOR Sets the default console foreground and background colors.<br/>COMP Compares the contents of two files or sets of files.<br/>COMPACT Displays or alters the compression of files on NTFS partitions.<br/>CONVERT Converts FAT volumes to NTFS. You cannot convert the<br/> current drive.<br/>COPY Copies one or more files to another location.<br/>DATE Displays or sets the date.<br/>DEL Deletes one or more files.<br/><strong>OR</strong> you can do it the easy way and use redirection on the command line when you launch the file:<br/><br/> Code: <a>[Select]</a>batfile.bat > capture.txt<br/><br/>batfile.bat >> capture.txt<br/><br/>Using a single redirection symbol will create a new file or overwrite an existing file.<br/>Using a double redirection symbol will create a new file if it does not exist or append to an existing file.<br/><br/><strong>FYI:</strong> If the batch file contains prompt(s), they will be unseen by the user but there will still be a wait for input on the console. This may lead to laughable unpredictable results.<br/><br/><a href="https://interviewquestions.tuteehub.com/tag/good-1009017" style="font-weight:bold;" target="_blank" title="Click to know more about GOOD">GOOD</a> luck. Thank you sidewinder and victoria for both of your replies.<br/><br/>I used the single pipe batfile > capture.txt<br/><br/>However something strange is happening here. I am executing ftp commands in my bat file. the last but one is the <a href="https://interviewquestions.tuteehub.com/tag/supposed-1235466" style="font-weight:bold;" target="_blank" title="Click to know more about SUPPOSED">SUPPOSED</a> to download a file. Now when I run the bat file directly i see something like this<br/><br/>ftp> 20mb file transferred in 20.68 seconds 876.877kbytes/sec<br/>ftp> quit<br/><br/>but when the output is written in to the text file i see<br/><br/>ftp> 20mb file transferred in seconds kbytes/sec<br/>ftp> 20.68876.877 quit<br/><br/>Both the seconds and kbps are written on the quit command line. Which i dont understand why. Any input is highly appreciated.<br/>Not really sure, but the FTP command places you in another environment. I'm surprised you <a href="https://interviewquestions.tuteehub.com/tag/got-23540" style="font-weight:bold;" target="_blank" title="Click to know more about GOT">GOT</a> any output from the FTP commands. In any case it seems like the carriage return/line feed characters are not being written properly which may have to do with the media (console vs. disk)<br/><br/>Try redirecting the FTP command output from within the batch file in addition to the redirection at the command line. Sometimes you just have to tweak the code until it works. <br/><br/>Good luck. Quote from: dmog on August 11, 2010, 03:26:05 PM</p><blockquote>I used the single redirect batfile > capture.txt<br/><br/>ftp> 20mb file transferred in seconds kbytes/sec<br/>ftp> 20.68876.877 quit<br/><br/>Both the seconds and kbps are written on the quit command line. Which i dont understand why. Any input is highly appreciated.<br/><br/></blockquote> <br/>ftp> transfer <br/>ftp>echo.<br/><br/><br/>ftp>echo quit<br/><br/>Rem Between the command that does the transfer and the command to quit<br/><br/>Rem Use echo. echo. places a blank line<br/><br/>( also a redirect > of each command <a href="https://interviewquestions.tuteehub.com/tag/might-560522" style="font-weight:bold;" target="_blank" title="Click to know more about MIGHT">MIGHT</a> fix the problem. )<br/><br/>p.s. a pipe | and a redirect >> are two different procedures. A pipe | sends<br/>the output to another program as the input. Redirect >> goes to a text file.</body></html> | |
228. |
Solve : Need Help Debugging DOS Script? |
Answer» <html><body><p>I have the batch file below. Basically, if I login the batch file should do nothing, and if <br/>someone else logs in it should log the date, time, and user ID. We have some people who like <br/>to play practical jokes when others go on vacation, and this is just a little thing I came up <br/>with to help me figure out who messed with my machine. It works, but with one annoyance that I <br/>cannot seem to solve. It will log my user ID *every* time. What happens is that it skips <br/>capturing the date and time, but it will always log my user ID to the output file. How can I <br/>change the script so that no action is taken when I login?<br/><br/><br/>Echo Off<br/><br/>::Detect an anomalous <a href="https://interviewquestions.tuteehub.com/tag/logon-2798979" style="font-weight:bold;" target="_blank" title="Click to know more about LOGON">LOGON</a>. If none detected file takes no action.<br/>If %Username% neq Tom (<br/><br/> ::Get the time and date<br/> FOR /F "tokens=5 delims=. " %%a IN ('ECHO ^| TIME ^| FIND "current"') do set Trun=%%a<br/> FOR /F "tokens=6" %%a IN ('ECHO ^| DATE ^| FIND "current"') do set Drun=%%a<br/><br/> ::Build the log file--if necessary--then log the data<br/> if not exist "C:\Output\Logons.txt" (<br/> echo Date Time User Name >> "C:\Output\Logons.txt"<br/> echo ---- ---- --------- >> "C:\Output\Logons.txt"<br/> )<br/><br/> ::Write the date, time, and user name to the output file.<br/> echo %Drun% %Trun% %username% >> "C:\Output\Logons.txt"<br/><br/> ::Create the Anomalous Logon notification message.<br/> echo Anomalous logon detected. <a href="https://interviewquestions.tuteehub.com/tag/check-25817" style="font-weight:bold;" target="_blank" title="Click to know more about CHECK">CHECK</a> C:\Output\Logons.txt for more information. >> <br/>"C:\Documents and Settings\Tom\Start Menu\Programs\Startup\AnomalousLogons.txt"<br/>)My inclination would be to fix the symptoms rather than spend time working out the issue, as this is not a major piece of development<br/><br/>Why not just bomb out if it is your name:<br/> Code: <a>[Select]</a>If %Username% eq Tom GoTo :EOFInsert backslashes where needed<br/><br/>C:test>type thom2.bat<br/><br/><br/>Echo Off<br/>rem set USERNAME=Joe<br/>rem echo USERNAME=%USERNAME%<br/>set USERNAME=You<br/>echo USERNAME=%USERNAME%<br/>echo Date Time User Name >> C:testLogons.txt<br/> Rem need quotes around %USERNAME% and You<br/>if %USERNAME%==You (<br/>echo %USERNAME%<br/>goto :END<br/>)<br/><br/> echo ---- ---- --------- >> C:testLogons.txt<br/><br/><br/>echo %DATE% %TIME% %USERNAME% >> C:testLogons.txt<br/><br/><br/>echo Anomalous logon detected. >> C:testLogons.txt<br/><br/>echo type logons.txt<br/>type logons.txt<br/>goto :stop<br/><br/>:END<br/>echo %USERNAME% is only user >> C:testLogons.txt<br/><br/>echo type logons.txt<br/>type logons.txt<br/>:stop<br/>C:test> Quote from: victoria on August 09, 2010, 01:26:09 PM</p><blockquote>Insert backslashes where needed<br/><br/>C:test>type thom2.bat<br/><br/><br/>Echo Off<br/>rem set USERNAME=Joe<br/>rem echo USERNAME=%USERNAME%<br/>set USERNAME=You<br/>echo USERNAME=%USERNAME%<br/>echo Date Time User Name >> C:testLogons.txt<br/> Rem need quotes around %USERNAME% and You<br/>if %USERNAME%==You (<br/>echo %USERNAME%<br/>goto :END<br/>)<br/><br/> echo ---- ---- --------- >> C:testLogons.txt<br/><br/><br/>echo %DATE% %TIME% %USERNAME% >> C:testLogons.txt<br/><br/><br/>echo Anomalous logon detected. >> C:testLogons.txt<br/><br/>echo type logons.txt<br/>type logons.txt<br/>goto :stop<br/><br/>:END<br/>echo %USERNAME% is only user >> C:testLogons.txt<br/><br/>echo type logons.txt<br/>type logons.txt<br/>:stop<br/>C:test><br/></blockquote> <br/><br/>But, will this work?<br/><br/><br/>It seems to be complicated command line.<br/><br/>However, yours is clear and pretty.<br/><br/><br/><br/><br/>Echo Off<br/><br/>::Detect an anomalous logon. If none detected file takes no action.<br/>If %Username% neq Tom (<br/><br/> ::Get the time and date<br/> FOR /F "tokens=5 delims=. " %%a IN ('ECHO ^| TIME ^| FIND "current"') do set Trun=%%a<br/> FOR /F "tokens=6" %%a IN ('ECHO ^| DATE ^| FIND "current"') do set Drun=%%a<br/><br/> ::Build the log file--if necessary--then log the data<br/> if not exist "C:\Output\Logons.txt" (<br/> echo Date Time User Name >> "C:\Output\Logons.txt"<br/> echo ---- ---- --------- >> "C:\Output\Logons.txt"<br/> )<br/><br/> ::Write the date, time, and user name to the output file.<br/> echo %Drun% %Trun% %username% >> "C:\Output\Logons.txt"<br/><br/> ::Create the Anomalous Logon notification message.<br/> echo Anomalous logon detected. Check C:\Output\Logons.txt for more information. >><br/>"C:\Documents and Settings\Tom\Start Menu\Programs\Startup\AnomalousLogons.txt"<br/>)vishuvishal,<br/><br/>We do not need a for loop to record and save %DATE% and %TIME% in a log file.<br/><br/><br/>But I will test the for loop code and post back the results.<br/><br/>The editor here or with the Proxy Server is not working for me correctly. <br/><br/>I might need to take a picture of the code while on my machine. It is pretty but we cannot copy and paste from the picture.<br/><br/>What happened when you tested the for loop code? <br/><br/>Post your results.He he didn't work <br/><br/>Actually I was trying to figure out the procedure happened on this code.<br/>But found myself dumb.<br/>So, I think I am just beginner.<br/>However, your code are awesome so simple. Quote from: vishuvishal on August 09, 2010, 02:49:44 PM<blockquote><br/>But, will this work?<br/><br/>It seems to be a complicated for loop.<br/><br/></blockquote> <br/>Yes, the For loop by the Original Poster worked.<br/><br/> Quote from: vishuvishal on August 09, 2010, 04:46:43 PM<blockquote><br/> I am a beginner.<br/><br/></blockquote> <br/>The following code was mangled by my Poxy Editor. Look at the above <a href="https://interviewquestions.tuteehub.com/tag/screen-25632" style="font-weight:bold;" target="_blank" title="Click to know more about SCREEN">SCREEN</a> shot for a clear picture of the code.<br/><br/><br/>C:\\\\test>type vis89.bat<br/>Echo Off<br/>set USERNAME=%1<br/>echo USERNAME=%USERNAME%<br/>SETLOCAL EnableDelayedExpansion<br/>echo. > C:\\\\test\\\\Logons.log<br/>If \\\"%USERNAME%\\\" EQU \\\"Tom\\\" goto :end<br/>FOR /F \\\"tokens=5 delims=. \\\" %%a IN (\\\'ECHO ^| TIME ^| FIND \\\"current\\\"\\\') do (<br/>set Trun=%%a )<br/>FOR /F \\\"tokens=6\\\" %%a IN (\\\'ECHO ^| DATE ^| FIND \\\"current\\\"\\\') do set Drun=%%a<br/>echo Date Time User Name >> C:\\\\test\\\\Logons.log<br/>echo ---- ---- --------- >> C:\\\\test\\\\Logons.log<br/>echo !Drun! !Trun! !USERNAME! >> C:\\\\test\\\\Logons.log<br/>echo Anomalous logon detected. >> C:\\\\test\\\\Logons.log<br/>goto :secondend<br/>:end<br/>echo %1 was the only User<br/>exit /b<br/>:secondend<br/>echo %1 was a Bogus User >> C:\\\\test\\\\Logons.log<br/>echo Type logons.log<br/>Type logons.log<br/><br/>Output:<br/><br/>C:\\\\test> vis89.bat Tom<br/>USERNAME=Tom<br/>Tom was the only User<br/><br/>C:\\\\test> vis89.bat vis<br/>USERNAME=vis<br/>Type logons.log<br/><br/>Date Time User Name<br/>---- ---- ---------<br/>08/09/2010 18:23:30 vis<br/>Anomalous logon detected.<br/>vis was a Bogus User<br/>C:\\\\test> <br/>I should say your bat is worth than this.<br/>Cause ur's simple and good.<br/><br/>Thanks and regards<br/>VishuVis,<br/>The for loop is not necessary.<br/><br/></body></html> | |
229. |
Solve : need to when child batch file execution is over? |
Answer» <html><body><p>Hi<br/>I am calling one batch (child batch file) from from parent batch file. <br/>Now i need to invoke another child batch file from parent once currently running child batch file <a href="https://interviewquestions.tuteehub.com/tag/execution-979196" style="font-weight:bold;" target="_blank" title="Click to know more about EXECUTION">EXECUTION</a> is over.<br/><br/>any help in this regard will be highly appreciated.<br/><br/>Thanks<br/>Amit <a href="https://interviewquestions.tuteehub.com/tag/code-25512" style="font-weight:bold;" target="_blank" title="Click to know more about CODE">CODE</a>: <a>[Select]</a>Call Bat1.bat<br/>Call <a href="https://interviewquestions.tuteehub.com/tag/bat2-394563" style="font-weight:bold;" target="_blank" title="Click to know more about BAT2">BAT2</a>.bat<br/>Bat2 will not execute until Bat1 has finished<br/>Graham Quote from: amitkumar.verma on August 17, 2010, 12:16:58 AM</p><blockquote><br/>I am calling one batch (child batch file) from from parent batch file. <br/>Now i need to invoke another child batch file from parent once currently running child batch file execution is over.<br/>Any help in this regard will be highly appreciated.<br/><br/>Thanks<br/>Amit<br/></blockquote> <br/><br/>C:test>type main.bat<br/>echo off<br/>echo main<br/>call bat1.bat<br/>echo <a href="https://interviewquestions.tuteehub.com/tag/return-238023" style="font-weight:bold;" target="_blank" title="Click to know more about RETURN">RETURN</a> from bat2<br/>echo %TIME%<br/>call bat2.bat<br/>echo return from bat<br/>echo %TIME%<br/>echo Bye<br/>C:test>type bat1.bat<br/>echo off<br/>echo bat1<br/>sleep.exe 60<br/>echo %TIME%<br/>exit /b<br/>C:test>type bat2.bat<br/>echo off<br/>echo bat2<br/>sleep.exe 60<br/>echo %TIME%<br/>exit /b<br/>C:test><br/><br/>Output:<br/><br/>C:test>main.bat<br/>main<br/>bat1<br/> 3:37:24.95<br/>return from bat1<br/> 3:37:24.95<br/>bat2<br/> 3:38:24.97<br/>return from bat2<br/> 3:38:24.97<br/>Bye<br/><br/>C:test></body></html> | |
230. |
Solve : Background Music? |
Answer» <html><body><p>Hi Guys <br/><br/>I Am Making An "Command <a href="https://interviewquestions.tuteehub.com/tag/prompt-592976" style="font-weight:bold;" target="_blank" title="Click to know more about PROMPT">PROMPT</a>" Project On Maruti Suzuki Cars<br/><br/>I Needed A Batch File to play a song silently without showing up any Music Player<br/><br/>can It be possible ?? <br/><br/>My song is in B:\Project_MSC\redemptation.mp3Im not sure that you can do this -- exactly, see <a href="https://msdn.microsoft.com/en-us/library/dd562624(VS.85).aspx">http://msdn.microsoft.com/en-us/library/dd562624(VS.85).aspx</a><br/><br/>One option might be to embed a media player component in an html page and open the page with the browser minimised<br/><br/><br/>to play a song silently <br/>Well, you can run a music player minimized.<br/><br/>Start "" /min MPLAY32 /play /close "C:\Documents and Settings\user\My Documents\filename.mp3"<br/><br/>Just use that (change the path to <a href="https://interviewquestions.tuteehub.com/tag/suit-1233889" style="font-weight:bold;" target="_blank" title="Click to know more about SUIT">SUIT</a> your needs).I Appreciate helpmeh but any example of music player which can b ran silently during the show Quote from: The Italian Stallion on August 10, 2010, 10:25:59 AM</p><blockquote>I Appreciate helpmeh but any example of music player which can b ran silently during the show<br/></blockquote> <br/>I think silence and playing music are sort of conflicting requirements here. Quote from: The Italian Stallion on August 10, 2010, 10:25:59 AM<blockquote>I Appreciate helpmeh but any example of music player which can b ran silently during the show<br/></blockquote> Code: <a>[Select]</a><a href="https://interviewquestions.tuteehub.com/tag/set-11758" style="font-weight:bold;" target="_blank" title="Click to know more about SET">SET</a> wshShell=wscript.CreateObject("WScript.Shell")<br/>wshshell.run "MPLAY32 /play /close PATHTOMP3\file.mp3", 0i made this program that does that(with special thanks to helpmeh for the vbs script)<br/><br/>music.exe C:\test.mp3<br/><br/>[recovering <a href="https://interviewquestions.tuteehub.com/tag/disk-244471" style="font-weight:bold;" target="_blank" title="Click to know more about DISK">DISK</a> space - old attachment deleted by admin]First: Why do people insist on compiling batch files?<br/><br/><br/>Original batch for "music.exe":<br/> Code: <a>[Select]</a>echo off<br/>echo Set wshShell=Wscript.CreateObject("WScript.Shell")>temp.vbs<br/>echo wshshell.run "MPLAY32 /play /close "%1"",0>>temp.vbs<br/>cscript //nologo temp.vbs<br/>del temp.vbs<br/><br/>Second: MPLAY32 is the windows 95 media player. It can be found on Windows XP,Windows 2000, 98, 95, and ME.<br/><br/>Now, let's look at The_Mad_Joker's OS:<br/><br/>"Windows 7".<br/><br/>Now, allow me to tell you, that mplay32 is not present on Vista or 7. therefore that solution will not work.<br/><br/>third: it doesn't solve the problem anyway, since the windows is simply minimized.<br/><br/> Quote from: BC_Programmer on August 10, 2010, 05:43:40 PM<blockquote>First: Why do people insist on compiling batch files?<br/><br/><br/>Original batch for "music.exe":<br/> Code: <a>[Select]</a>echo off<br/>echo Set wshShell=Wscript.CreateObject("WScript.Shell")>temp.vbs<br/>echo wshshell.run "MPLAY32 /play /close "%1"",0>>temp.vbs<br/>cscript //nologo temp.vbs<br/>del temp.vbs<br/><br/>Second: MPLAY32 is the windows 95 media player. It can be found on Windows XP,Windows 2000, 98, 95, and ME.<br/><br/>Now, let's look at The_Mad_Joker's OS:<br/><br/>"Windows 7".<br/><br/>Now, allow me to tell you, that mplay32 is not present on Vista or 7. therefore that solution will not work.<br/><br/>third: it doesn't solve the problem anyway, since the windows is simply minimized.<br/><br/><br/></blockquote> <br/>#1 Insecurities?<br/>#2 Mplay2 then?<br/>#2.5 Not again...why does he return?<br/>#3 No...<br/><br/>Also, the quotes need to be escaped somehow, because Wscript is expecting an end of statement at L:2 C:37 (when run straight from VBS).i complied it so it would be hidden so there is less confusion <a href="https://interviewquestions.tuteehub.com/tag/ie-496825" style="font-weight:bold;" target="_blank" title="Click to know more about IE">IE</a> no popupsOr use JUST a vbs file, that way there is no need to compile anything, nor are there any popups.Batch file too doesnt give any pop ups, and yes that music.exe is not workingIs there a preferred option? Quote from: The Italian Stallion on August 11, 2010, 12:36:05 AM<blockquote>Batch file too doesnt give any pop ups, and yes that music.exe is not working<br/></blockquote> Ok, then just use the batch file. Quote<blockquote>Ok, then just use the batch file.</blockquote> Okies thank u all 4 your help<br/></body></html> | |
231. |
Solve : Registry edit using Dos? |
Answer» <html><body><p>I want to create a read error of a registry key file using MS Dos <br/><br/>The key file and all its bionary , string , DWORD etc value will work perfect.<br/>so give me a best solution with Dos Code.<br/><br/>thanks &<a href="https://interviewquestions.tuteehub.com/tag/amp-363144" style="font-weight:bold;" target="_blank" title="Click to know more about AMP">AMP</a>; regards<br/>Sohom<a href="https://support.microsoft.com/kb/131352">http://support.microsoft.com/kb/131352</a><br/><br/><br/>MS-DOS doesn't have a "registry".<br/>Sohom,<br/><br/><br/><a href="http://articles.techrepublic.com.com/5100-10878_11-1032874.html">http://articles.techrepublic.com.com/5100-10878_11-1032874.html</a><br/><br/>Using REGEDIT in DOS<br/>The utility we are going to use is REGEDIT.EXE—the same REGEDIT that we use in Windows also <a href="https://interviewquestions.tuteehub.com/tag/runs-246860" style="font-weight:bold;" target="_blank" title="Click to know more about RUNS">RUNS</a> as a DOS <a href="https://interviewquestions.tuteehub.com/tag/program-246414" style="font-weight:bold;" target="_blank" title="Click to know more about PROGRAM">PROGRAM</a>. REGEDIT.EXE supports command line arguments that allow us to do a complete registry rebuild, while leaving the dirt and empty spaces behind. We will eliminate the need to repetitively type commands by creating four batch files that you can carry with you and run from a floppy.<br/>For the sake of simplicity, we will assume that SYSTEM.DAT, USER.DAT, and REGEDIT.EXE reside in the <a href="https://interviewquestions.tuteehub.com/tag/c-3540" style="font-weight:bold;" target="_blank" title="Click to know more about C">C</a>:WINDOWS directory.<br/>You mean "Win32 command line", not "DOS".<br/><br/>Regedit is an interactive utility. <br/><br/>You can use the <a href="https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/reg.mspx?mfr=true">reg</a> command which can be used from the "Win32 Command Line" or from a batch file. If you prefer another language you can use the <a href="http://www.robvanderwoude.com/vbstech_registry_stdregprov.php">StdRegProv</a> object.<br/><br/>Good luck. There is a very simple way to edit/import/export the registry via the command line. It has always been there in Windows (maybe some earlier versions of Windows required the resource kit to be installed, but there has always been a possibility to do that) <br/><br/>The command is called REG.EXE and since Windows 7 and I think Windows 2003 it has always been there.<br/>To explore the command, simply time REG /?, you will get something like this:<br/>REG Operation [Parameter List]<br/> Operation [ QUERY | ADD | DELETE | COPY | SAVE | LOAD | UNLOAD | RESTORE | COMPARE | EXPORT | IMPORT | FLAGS ]<br/>Return Code: (Except for REG COMPARE)<br/> 0 - Successful<br/> 1 - Failed<br/>For help on a specific operation type:<br/> REG Operation /?<br/>Examples<br/><br/> REG QUERY /?<br/> REG ADD /?<br/> REG DELETE /?<br/> REG COPY /?<br/> REG SAVE /?<br/> REG RESTORE /?<br/> REG LOAD /?<br/> REG UNLOAD /?<br/> REG COMPARE /?<br/> REG EXPORT /?<br/> REG IMPORT /?<br/> REG FLAGS /?<br/><br/>What <a href="https://interviewquestions.tuteehub.com/tag/exactly-977868" style="font-weight:bold;" target="_blank" title="Click to know more about EXACTLY">EXACTLY</a> are you trying to do?</p></body></html> | |
232. |
Solve : net use /delete in script - do not work? |
Answer» <html><body><p>Hi All<br/><br/>can anybody help.<br/><br/>I have <a href="https://interviewquestions.tuteehub.com/tag/script-345000" style="font-weight:bold;" target="_blank" title="Click to know more about SCRIPT">SCRIPT</a>:<br/> Code: <a>[Select]</a>echo Y|net use p: /delete<br/><br/>START /wait NET USE p: \\server1\MDPRD\distributions\Inbound\70\70_Customer_flat\Archive<br/>call e:\batchfile.bat<br/>echo Y|net use p: /delete<br/><br/>echo Y|net use p: /delete<br/>START /wait NET USE p: \\server1\MDPRD\distributions\P31\BW__RACUGRP\Archive<br/>call e:\batchfile.bat<br/>echo Y|net use p: /delete<br/><br/>START /wait NET USE p: \\server1\MDPRD\distributions\Archive<br/>call e:\batchfile.bat<br/>echo Y|net use p: /delete<br/>however after calling e:\batchfile.bat <br/>echo Y|net use p: /delete<br/>do not work<br/><br/>can anobydy advice how to solve that error?<br/><br/> Code: <a>[Select]</a>E:\>echo Y | net use y: /delete<br/>y: was deleted successfully.<br/><br/>E:\>START /wait NET USE y: \\server1\MDPRD\distributions\Inbound\70\70_Customer_flat\Archive<br/><br/><br/>E:\>call e:\batchfile.bat<br/>The device is being accessed by an active process. <---- here net use delete is failing<br/><br/>More help is available by typing NET HELPMSG 2404. <br/><br/>Press any key to continue . . <br/>Please advice <br/><br/>Thank you very much.<br/><br/>BR<br/>Michal Quote</p><blockquote>however after calling e:\batchfile.bat<br/>echo Y|net use p: /delete<br/>do not work<br/></blockquote> <br/>It would help if you posted the contents of batchfile.bat. It appears some process has an open handle to the P drive.<br/><br/>Any reason why you are using <em>start</em> with the <strong>net use</strong> command? There is no reason to run it in a separate window and running it inline produces the same result as the /wait switch would.<br/><br/> hi Sidewinder<br/><br/>Thank you for replay, here is full batchfile.bat:<br/><br/><br/> Code: <a>[Select]</a>echo off<br/>CD /d p:\<br/><br/>REM grab todays date into variables<br/>set MM=%Date:~3,2%<br/>set DD=%Date:~0,2%<br/>set YYYY=%Date:~6,4%<br/><br/>REM Add the date variables to the log name<br/>REM putting the date in this <a href="https://interviewquestions.tuteehub.com/tag/order-238912" style="font-weight:bold;" target="_blank" title="Click to know more about ORDER">ORDER</a> will sort the files sensibly<br/>Set LogFile="e:\NewFiles_%YYYY%-%MM%-%DD%.Log"<br/><br/>REM create the vb script<br/>>c:\evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))<br/><br/>REM extract todays date less 7 days<br/>set OldestDate=<br/>for /f "delims=" %%A in ( ' cscript //nologo c:\evaluate.vbs "Date -7" ' ) do set OldestDate=%%A<br/><br/>REM tidy<br/>del c:\evaluate.vbs<br/><br/>REM break up the date into constituent parts<br/>REM Note - the date is parsing YYYY-MM-DD format dates,<br/><br/>set MM=<br/>set DD=<br/>set YYYY=<br/><br/>set MM=%OldestDate:~5,2%<br/>set DD=%OldestDate:~8,2%<br/>set YYYY=%OldestDate:~0,4%<br/><br/>REM reconstruct <a href="https://interviewquestions.tuteehub.com/tag/us-243201" style="font-weight:bold;" target="_blank" title="Click to know more about US">US</a> format with '-' separators<br/>set OldestDate=%MM%-%DD%-%YYYY%<br/><br/>REM add the new entry to the log<br/>>> %LogFile% Echo %DATE% %TIME%<br/>>> %LogFile% Echo Since : %OldestDate%<br/>net use p:|find "Remote name">> %LogFile% <br/><br/>REM list the files that would be copied if we really were doing a copy<br/>REM force it to believe that the target NonExistentDirectory is a directory<br/>REM and echo the name & time for each<br/><br/>for /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do call :ProcessEach "%%A"<br/><br/>REM tidy up the log<br/>>> %LogFile% Echo ========================================<br/><br/>goto :EOF<br/><br/>:ProcessEach<br/><br/>>> %LogFile% echo %~f1 %~t1<br/><br/>goto :EOF<br/><br/><br/><br/>Thank you for help <br/><br/>BR<br/>MichalThe second line in batchfile.bat <a href="https://interviewquestions.tuteehub.com/tag/logs-1077946" style="font-weight:bold;" target="_blank" title="Click to know more about LOGS">LOGS</a> you on to the P drive. There is no other CD instruction in the file (that I could find), so when batchfile.bat ends, you are still logged into the P drive.<br/><br/>Batchfile.bat needs to be changed to log off the P drive before the calling file attempts to delete the mapping (net use p: /delete)<br/><br/> Michal <br/>I knew it would be something easy !<br/>Sorry I couldnt finish this off without Sidewinder's help (cheers SW)<br/>Graham<br/><br/>Try this<br/> Code: <a>[Select]</a>echo off<br/>CD /d p:\<br/><br/>REM grab todays date into variables<br/>set MM=%Date:~3,2%<br/>set DD=%Date:~0,2%<br/>set YYYY=%Date:~6,4%<br/><br/>REM Add the date variables to the log name<br/>REM putting the date in this order will sort the files sensibly<br/>Set LogFile="e:\NewFiles_%YYYY%-%MM%-%DD%.Log"<br/><br/>REM create the vb script<br/>>c:\evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))<br/><br/>REM extract todays date less 7 days<br/>set OldestDate=<br/>for /f "delims=" %%A in ( ' cscript //nologo c:\evaluate.vbs "Date -7" ' ) do set OldestDate=%%A<br/><br/>REM tidy<br/>del c:\evaluate.vbs<br/><br/>REM break up the date into constituent parts<br/>REM Note - the date is parsing YYYY-MM-DD format dates,<br/><br/>set MM=<br/>set DD=<br/>set YYYY=<br/><br/>set MM=%OldestDate:~5,2%<br/>set DD=%OldestDate:~8,2%<br/>set YYYY=%OldestDate:~0,4%<br/><br/>REM reconstruct US format with '-' separators<br/>set OldestDate=%MM%-%DD%-%YYYY%<br/><br/>REM add the new entry to the log<br/>>> %LogFile% Echo %DATE% %TIME%<br/>>> %LogFile% Echo Since : %OldestDate%<br/>net use p:|find "Remote name">> %LogFile% <br/><br/>REM list the files that would be copied if we really were doing a copy<br/>REM force it to believe that the target NonExistentDirectory is a directory<br/>REM and echo the name & time for each<br/><br/>for /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do call :ProcessEach "%%A"<br/><br/>REM tidy up the log<br/>>> %LogFile% Echo ========================================<br/><br/>REM ----------------------------<br/>REM Release mapped drive<br/>REM ----------------------------<br/><br/>E:<br/><br/>goto :EOF<br/><br/>:ProcessEach<br/><br/>>> %LogFile% echo %~f1 %~t1<br/><br/>goto :EOF<br/>Hi <br/><br/>Now it looks to work with deleting p: drive when script is finished<br/><br/>It seems to be working as expected <br/><br/>Thank you very very very much <br/><br/>BR<br/>MichalHi <br/><br/>I encouriage strange problem. Mentioned above script works fine on one computer, but on all others is failing.<br/><br/>I have that error message:<br/><br/>C:\MDM_Monitoring>echo Y | net use p: /delete<br/>p: was deleted successfully.<br/><br/><br/>C:\MDM_Monitoring>START /wait NET USE p: \\server1\P_Customer\Inbound\70\70_Customer_flat\Archive<br/><br/>C:\MDM_Monitoring>call e:\bathfile.bat<br/>The system cannot find the drive specified.<br/>The device is being accessed by an active process.<br/><br/>More help is available by typing NET HELPMSG 2404.<br/><br/>Press any key to continue . . .<br/><br/><br/>Can you please help, I have no clue why that error occour. Special that it works on once computer only. On all other computers I have mentioned above error.<br/><br/>Thank you in advance.<br/><br/>BR<br/>Michal Quote<blockquote>REM ----------------------------<br/>REM Release mapped drive<br/>REM ----------------------------<br/><br/>E:<br/></blockquote> <br/>I see remarks for deleting the mapped drive but no actual <a href="https://interviewquestions.tuteehub.com/tag/instructions-1046362" style="font-weight:bold;" target="_blank" title="Click to know more about INSTRUCTIONS">INSTRUCTIONS</a>. It may be time to rethink your design. Batchfile should contain all the instructions it needs to run whether from the command line or as a called file. By this I mean batchfile should map the drive, access the drive and release the drive; it should not rely on some caller batch file to supply these instructions.<br/><br/>Be aware that in a caller/calling sequence, that if any module fails to complete properly, your session status may be corrupt.<br/><br/>Why are you using <em>start /wait</em> with the net use command? Why are you <em>piping</em> Y to the net use command? <br/><br/> Quote<blockquote>Special that it works on once computer only. On all other computers I have mentioned above error.<br/></blockquote> <br/>Let us know. <br/><br/>Are all the computers running the same OS. Are they on the same network?<br/><br/>Hi All<br/><br/>Sorry I messed up, all works fine.<br/><br/>note. Always connect to disks mapped to your computer <br/><br/>BR<br/>Silberzin</body></html> | |
233. |
Solve : how to get the Count of string in file? |
Answer» <html><body><a href="https://interviewquestions.tuteehub.com/tag/hi-479908" style="font-weight:bold;" target="_blank" title="Click to know more about HI">HI</a>,<br/><br/>Am having a <a href="https://interviewquestions.tuteehub.com/tag/file-11330" style="font-weight:bold;" target="_blank" title="Click to know more about FILE">FILE</a> with 1 line having a file size of 35MB.<br/><br/><br/>Eg:- <br/>arun*America*MSC~INS*dfffs*Sdfsd*sdfsd~ssfsd*sdfsd~INS*dfffs*sdfsdf*sdfs~<br/><br/>I need to get a count of INS* in the above file. Am new to DOS Commands. <br/><br/>Please help me.<br/><br/>Thanks in Advance.<br/><br/>Regards,<br/>Arun S. Quote from: arunavlp on August 03, 2010, 04:43:17 AM<blockquote>hi,<br/><br/>Am having a file with 1 line having a file size of 35MB.<br/><br/><br/>Eg:- <br/>arun*America*MSC~INS*dfffs*Sdfsd*sdfsd~ssfsd*sdfsd~INS*dfffs*sdfsdf*sdfs~<br/><br/>I need to get a count of INS* in the above file. Am new to DOS Commands. <br/><br/>Please help me.<br/><br/>Thanks in Advance.<br/><br/>Regards,<br/>Arun S.<br/></blockquote> <br/>download <a href="http://gnuwin32.sourceforge.net/packages/gawk.htm">gawk f</a>or windows,<br/>then <br/> Code: <a>[Select]</a>c:\test> gawk "{m=gsub("INS",""); total+=m}END{print "total:" total}" file<br/>hi ,<br/><br/>Thanks for suggestion. but i got an error message like this <br/><br/>30.834<br/>gawk: {m=gsub(INS,");<br/>gawk: ^ unterminated string<br/><br/>i dont know wht this error means. Please help me on this.<br/><br/><br/>Regards,<br/>Arun S.Escape your double quotes<br/><br/> Code: <a>[Select]</a>c:\test> gawk "{m=gsub(\"INS\",\"\"); total+=m}END{print \"total:\" total}" file<br/>hi,<br/><br/>Thanks It works.. but please let me know if we can do it in Find Command.... <br/><br/>Regards,<br/>Arun S. Quote from: arunavlp on August 05, 2010, 12:34:57 AM<blockquote>hi,<br/><br/>Thanks It works.. but please let me know if we can do it in Find Command.... <br/><br/>Regards,<br/>Arun S.<br/></blockquote> i personally wouldn't bother. find (or findstr) just find the string on a line for you. It won't count how many there are. More involved <a href="https://interviewquestions.tuteehub.com/tag/programming-1806" style="font-weight:bold;" target="_blank" title="Click to know more about PROGRAMMING">PROGRAMMING</a> is needed. ( that i will leave it someone else who has the expertise and time to show you, )<br/>When parsing files and doing string manipulation, use a good tool for the job.The <strong>find</strong> command will count the lines with the search argument. If a line has more than one occurrence of the search argument, it still counts for one. <strong>Findstr</strong> does not do counting but allows for multiple search arguments and a limited form of regular expressions.<br/><br/>You can use VBScript which came with your Windows machine. The little demo script will prompt the user for the file name and the search argument. It can be tweaked to remove the prompts (which will probably gut the majority of the script). <br/><br/> Code: <a>[Select]</a>Const ForReading = 1<br/><br/>Set fso = CreateObject("Scripting.FileSystemObject")<br/><br/>Do<br/> WScript.StdOut.Write "Please enter file name: "<br/> strFile = WScript.StdIn.ReadLine<br/> If fso.FileExists(strFile) Then<br/> Set objFile = fso.OpenTextFile(strFile, ForReading)<br/> strCharacters = objFile.ReadAll<br/> Exit Do<br/> Else<br/> WScript.StdOut.Write "Invalid file name ... Try Again" & vbCrLf<br/> End If<br/>Loop<br/><br/>Do<br/> WScript.StdOut.Write "Please enter character string: "<br/> strToCount = WScript.StdIn.ReadLine<br/> If strToCount <> "" Then Exit Do <br/>Loop<br/><br/>strTemp = Replace(LCase(strCharacters), LCase(strToCount), "") <br/>WScript.Echo "Occurences of:", strToCount, "=", (Len(strCharacters) - Len(strTemp)) / Len(strToCount) <br/><br/>objFile.Close<br/><br/>Save the script with a <strong>vbs</strong> extension and run only from the command prompt as: <strong>cscript <em>scriptname.vbs</em></strong><br/><br/>Good luck. <br/>I can give you Idea what it should like to be:<br/><br/>set /p pass= echo %pass%<br/>call set new=%%pass:~%a%,1%%<br/>set /a a=%a% + 1<br/> set key=%key%%new%<br/>echo %new%<br/><br/>This new will give you the number of string.<br/>However, I am going will give you further details tommorrow<br/><br/>Thanks and regard <br/>vishu Code: <a>[Select]</a>set /p pass=<string.txt<br/>echo %pass%<br/>:st<br/>call set new=%%pass:~%a%,1%%<br/>echo a=%a% + 1<br/>echo %a%<br/>set key=%key%%new%<br/>echo %new%<br/>echo %key%<br/>pause<br/>::if %new% ==; goto :EOF<br/><br/>pause<br/>goto :st<br/><br/><br/>All we need to fix is loop.<br/>Change the string.txt to your file drive:path\file name<br/>Gave you a best option<br/><br/>echo off<br/><br/>sed s/the/the\\n/g yz.txt | egrep -c the<br/><br/><br/><br/>counthe.bat<br/>10<br/>type yz.txt<br/>the<br/>the<br/>the<br/>the<br/>the the the<br/>the the the<br/>Two \\ should be one<br/><br/>C:\\test>type cntstr.bat<br/><a href="https://interviewquestions.tuteehub.com/tag/rem-613824" style="font-weight:bold;" target="_blank" title="Click to know more about REM">REM</a> echo off<br/>sed s/%1/%1\\n/g %2 | egrep -c %1<br/><br/>C:\\test>cntstr.bat the yz.txt<br/><br/>C:\\test>rem echo off<br/><br/>C:\\test>sed s/the/the\\n/g yz.txt | egrep -c the<br/>10<br/><br/>C:\\test>type yz.txt<br/>the<br/>the<br/>the<br/>the<br/>the the the<br/>the the the<br/>Only one \\ backslash each time<br/><br/>type cntstr.bat<br/>rem echo off<br/>sed s/%1/%1\\n/g %2 | egrep -c %1<br/><br/>cntstr.bat 22 yr2010.doc<br/><br/>rem echo off<br/><br/>sed s/22/22\\n/g yr2010.doc | egrep -c 22<br/>12<br/><br/>Output for <a href="https://interviewquestions.tuteehub.com/tag/reply-1185278" style="font-weight:bold;" target="_blank" title="Click to know more about REPLY">REPLY</a> #6 by sidewinder<br/><br/><br/>cscript swcnt.vbs<br/>Microsoft (R) Windows Script Host Version 5.8<br/>Copyright (C) Microsoft Corporation. All rights reserved.<br/><br/>Please enter file name: yr2010.doc<br/>Please enter character string: 22<br/>Occurences of: 22 = 12<br/><br/>Victoria, I really understand wht these commands will do.<br/><br/>Seems like not a proper bat file</body></html> | |
234. |
Solve : Help creating files? |
Answer» <html><body><p>I'm writing a messenger for me and my brother to use at our house. I'm Just having a little trouble with it.<br/><br/>Here's what I have so far,<br/><br/> Code: <a>[Select]</a>ECHO OFF<br/><br/>IF EXIST Writer.bat (<br/> IF EXIST <a href="https://interviewquestions.tuteehub.com/tag/reader-771315" style="font-weight:bold;" target="_blank" title="Click to know more about READER">READER</a>.bat (GOTO <a href="https://interviewquestions.tuteehub.com/tag/done-958312" style="font-weight:bold;" target="_blank" title="Click to know more about DONE">DONE</a><br/> ) ELSE (<br/> GOTO Reader<br/> )<br/> ) ELSE (<br/> GOTO Writer<br/>)<br/><br/>:Reader<br/><br/>ECHO ECHO OFF>Reader.bat<br/>ECHO.>>Reader.bat<br/>ECHO :Loop>>Reader.bat<br/>ECHO.>>Reader.bat<br/>ECHO CLS>>Reader.bat<br/>ECHO <a href="https://interviewquestions.tuteehub.com/tag/type-238192" style="font-weight:bold;" target="_blank" title="Click to know more about TYPE">TYPE</a> Messages.txt>>Reader.bat<br/>>>Reader.bat ECHO TIMEOUT /t 2<br/>ECHO GOTO Loop>>Reader.bat<br/><br/>ATTRIB +H Reader.bat<br/><br/>ECHO Reader Successfully Created.<br/><br/>IF EXIST Writer.bat (GOTO Done<br/> ) ELSE (<br/> GOTO Writer<br/>)<br/><br/>:Writer<br/><br/>ECHO ECHO OFF>Writer.bat<br/>ECHO.>>Writer.bat<br/>ECHO ECHO Enter your name:>>Writer.bat<br/>ECHO SET /p User="">>Writer.bat<br/>ECHO.>>Writer.bat<br/>ECHO :Loop>>Writer.bat<br/>ECHO.>>Writer.bat<br/>ECHO CLS>>Writer.bat<br/>ECHO ECHO Enter your message:>>Writer.bat<br/>ECHO SET /p Message="">>Writer.bat<br/>>>Messages.txt ECHO ECHO %%User%% - %%Message%%>>Writer.bat<br/>>>Messages.txt ECHO ECHO.>>Writer.bat<br/>ECHO GOTO Loop>>Writer.bat<br/><br/>ATTRIB +H Writer.bat<br/><br/>ECHO Writer Successfully Created.<br/><br/>IF EXIST Reader.bat (GOTO Done<br/> ) ELSE (<br/> GOTO Reader<br/>)<br/><br/>:Done<br/><br/>PAUSE<br/>START Reader.bat<br/>START Writer.bat<br/>EXIT<br/>The parts I'm having troubles with is:<br/><br/> Code: <a>[Select]</a>>>Writer.bat ECHo ECHO %%User%% - %%Message%%>>Messages.txt<br/>>>Writer.bat ECHO.>>Messages.txt<br/>And:<br/><br/> Code: <a>[Select]</a>>>Reader.bat ECHO TIMEOUT /t 2<br/>The first one I really wasn't expecting to work, does anybody know a way around it?<br/><br/>And the second, I really don't know why it's not working. Any Ideas?<strong>>>Reader.bat ECHO TIMEOUT /t 2</strong> No problems with this line, it appears it will be written to Reader.bat but does Timeout have a /t switch?<br/><br/> Code: <a>[Select]</a>>>Writer.bat ECHO ECHO %%User%% - %%Message%%>>Messages.txt<br/>>>Writer.bat ECHO.>>Messages.txt<br/>Escape the second >> using the caret like<br/> Code: <a>[Select]</a>>>Writer.bat ECHO ECHO %%User%% - %%Message%%^>^>Messages.txt<br/>>>Writer.bat ECHO ECHO.^>^>Messages.txt<br/>This doesn't mean your script will run, I think there are other problems for you to sort out..<br/><br/>FYI to save a lot of repetitive typing you could use<br/><br/>(<br/>ECHO ECHO OFF<br/>ECHO ECHO.<br/>ECHO SET /p User=Enter your name: <br/>ECHO ECHO.<br/>etc...<br/>.<br/>.<br/>etc...<br/>)>writer.bat<br/><br/>Good luck.Ahh, thank you very much!<br/><br/>I am aware of the bugs, and am still working on them. These two were the ones stumping me.<br/><br/>And by the way:<br/><br/> Code: <a>[Select]</a>C:\>timeout /?<br/><br/>TIMEOUT [/T] timeout [/NOBREAK]<br/><br/>Description:<br/> This utility accepts a timeout parameter to wait for the specified<br/> time period (in seconds) or until any key is pressed. It also<br/> accepts a parameter to ignore the key press.<br/><br/>Parameter List:<br/> /T timeout Specifies the number of seconds to wait.<br/> Valid range is -1 to 99999 seconds.<br/><br/> /NOBREAK Ignore key presses and wait specified time.<br/><br/> /? Displays this help message.<br/><br/>NOTE: A timeout value of -1 means to wait indefinitely for a key press.<br/><br/>Examples:<br/> TIMEOUT /?<br/> TIMEOUT /T 10<br/> TIMEOUT /T 300 /NOBREAK<br/> TIMEOUT /T -1<br/><br/>C:\><br/>Thanks for the suggestions!<strong>Timeout /t</strong> <a href="https://interviewquestions.tuteehub.com/tag/sorry-648642" style="font-weight:bold;" target="_blank" title="Click to know more about SORRY">SORRY</a> about that, it's your Win 7 vs my Win XP. LOL Haha yeah, not a problem! Thanks again. Quote from: Dusty on <a href="https://interviewquestions.tuteehub.com/tag/august-385421" style="font-weight:bold;" target="_blank" title="Click to know more about AUGUST">AUGUST</a> 17, 2010, 09:28:32 PM</p><blockquote>FYI to save a lot of repetitive typing you could use<br/><br/>(<br/>ECHO ECHO OFF<br/>ECHO ECHO.<br/>ECHO SET /p User=Enter your name: <br/>ECHO ECHO.<br/>etc...<br/>.<br/>.<br/>etc...<br/>)>writer.bat<br/><br/>Good luck.<br/></blockquote> WOW! You can actually do that? Dang...that could have saved tonnes of time! Quote from: helpmeh<blockquote>WOW! You can actually do that?</blockquote> <br/>Yep, try it out.<br/><br/></body></html> | |
235. |
Solve : Help with script involving dates and days of week? |
Answer» <html><body><p>Hi,<br/><br/>I use a batch program to download files from a server. The files are named [name]_[date in yyymmdd format].<br/>I wrote the program to download files for the last 7 days starting with today. I have two problems:<br/>1. When the program counts backwards I loose the leading zero so 20100804 becomes 201084 which doesn't work.<br/>2. When I back up against another month it fails also.<br/><br/>Can this be fixed. Also can the day of the week that corresponds to the date be <a href="https://interviewquestions.tuteehub.com/tag/returned-1187971" style="font-weight:bold;" target="_blank" title="Click to know more about RETURNED">RETURNED</a> as a variable?<br/><br/>Here is the code:<br/><br/>SET dwMONTH=%DATE:~4,2%<br/>SET dwDAY=%DATE:~7,2%<br/>SET dwYEAR=%DATE:~10,4%<br/>SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%<br/><br/>:gs01<br/>set localroot=[server]<br/>set localdrv=d:<br/>copy %localroot%\FL_%plantid%_*%datenow%.txt %localdrv%\rs_input\FL_%plantid%_%datenow%.txt<br/>copy %localroot%\D1_%plantid%_*%datenow%.txt %localdrv%\rs_input\D1_%plantid%_%datenow%.txt<br/><br/><br/>SET dwMONTH=%DATE:~4,2%<br/>SET /A dwDAY=%DATE:~7,2%-1<br/>SET dwYEAR=%DATE:~10,4%<br/>SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%<br/><br/>copy %localroot%\FL_%plantid%_*%datenow%.txt %localdrv%\rs_input\FL_%plantid%_%datenow%.txt<br/>copy %localroot%\D1_%plantid%_*%datenow%.txt %localdrv%\rs_input\D1_%plantid%_%datenow%.txt<br/><br/>An help is appreciatedHere is the solution. There was small defect.<br/><br/><br/> Code: <a>[Select]</a>SET dwMONTH=%DATE:~4,2%<br/>SET dwDAY=%DATE:~7,2%<br/>SET dwYEAR=%DATE:~10,4%<br/>SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%<br/><br/>:gs01<br/>set localroot=[server]<br/>set localdrv=d:<br/>copy "%localroot%\FL_%plantid%_*%datenow%.txt" %localdrv%\rs_input\FL_%plantid%_%datenow%.txt<br/>copy "%localroot%\D1_%plantid%_*%datenow%.txt" %localdrv%\rs_input\D1_%plantid%_%datenow%.txt<br/><br/><br/>SET dwMONTH=%DATE:~4,2%<br/>SET /A dwDAY=%DATE:~7,2%<br/>SET dwYEAR=%DATE:~10,4%<br/>SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%<br/><br/>copy "%localroot%\FL_%plantid%_*%datenow%.txt" %localdrv%\rs_input\FL_%plantid%_%datenow%.txt<br/>copy "%localroot%\D1_%plantid%_*%datenow%.txt" %localdrv%\rs_input\D1_%plantid%_%datenow%.txt<br/><br/><br/><br/>Checked and <a href="https://interviewquestions.tuteehub.com/tag/verified-2320336" style="font-weight:bold;" target="_blank" title="Click to know more about VERIFIED">VERIFIED</a>. This will work<br/><br/>Please let me know if it all set.<br/><br/>Thanks will do it.<br/><br/><br/>Thanks and regards<br/>vishuHi Vishu,<br/><br/>I apologize for my lack of clarity the line: SET /A dwDAY=%DATE:~7,2%-1 is not really a defect. It subtracts 1 day from the date. the program counts <a href="https://interviewquestions.tuteehub.com/tag/backward-391901" style="font-weight:bold;" target="_blank" title="Click to know more about BACKWARD">BACKWARD</a> for 6 days to copy files dated as I stated in the original post. The subsequent groups of code have: SET /A dwDAY=%DATE:~7,2%-2, SET /A dwDAY=%DATE:~7,2%-1-3, etc. to SET /A dwDAY=%DATE:~7,2%-6.<br/><br/>In the end I want 7 sets of files including the current day. Quote from: vishuvishal on August 15, 2010, 06:10:44 PM</p><blockquote>Here is the solution. There was small defect.<br/><br/><br/> Code: <a>[Select]</a>SET dwMONTH=%DATE:~4,2%<br/>SET dwDAY=%DATE:~7,2%<br/>SET dwYEAR=%DATE:~10,4%<br/>SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%<br/><br/>:gs01<br/>set localroot=[server]<br/>set localdrv=d:<br/>copy "%localroot%\FL_%plantid%_*%datenow%.txt" %localdrv%\rs_input\FL_%plantid%_%datenow%.txt<br/>copy "%localroot%\D1_%plantid%_*%datenow%.txt" %localdrv%\rs_input\D1_%plantid%_%datenow%.txt<br/><br/><br/>SET dwMONTH=%DATE:~4,2%<br/>SET /A dwDAY=%DATE:~7,2%-1<br/>IF /i %dwDAY% LSS 10 set dwday=0%dwDAY%<br/>SET dwday=%0%%dwday%<br/>SET dwYEAR=%DATE:~10,4%<br/>SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%<br/><br/>copy "%localroot%\FL_%plantid%_*%datenow%.txt" %localdrv%\rs_input\FL_%plantid%_%datenow%.txt<br/>copy "%localroot%\D1_%plantid%_*%datenow%.txt" %localdrv%\rs_input\D1_%plantid%_%datenow%.txt<br/><br/><br/><br/>Checked and verified. This will work<br/><br/>Please let me know if it all set.<br/><br/>Thanks will do it.<br/><br/><br/>Thanks and regards<br/>vishu<br/></blockquote> Batch scripting is all but useless in manipulating dates.<br/><br/>What happens if the day is 01? The result of <strong>SET /A dwDAY=%DATE:~7,2%-1</strong> is that dwDAY will return zero , and if the day is 02 and you "count backwards" for six days, dwDay will return -4.<br/><br/>Also, if the day is 08 or 09 Set /a will treat the values as Octal and throw up the usual error message because 08 and 09 are invalid in octal.<br/><br/>If the script is run near the beginning of the month, month and day must be decremented. If you run the script in early January the day, month and year must be decremented.<br/><br/>Best have a look at date manipulation using VB scripting.<br/><br/>Good luck.C:test>type griff816.bat<br/>echo off<br/>set /a c=0<br/>:start<br/>SET dwMONTH=%DATE:~4,2%<br/>echo dwMONTH=%dwMONTH%<br/>SET /A dwDAY=%DATE:~7,2% -%c%<br/>echo dwDAY=%dwDAY%<br/>SET dwDAY=%DATE:~7,2%<br/>SET dwYEAR=%DATE:~10,4%<br/>SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%<br/><br/><br/>set localroot=c:test<br/>set localdrv=c:tmp<br/>copy %localroot%\\%datenow%.txt %localdrv%\\%datenow%.txt<br/>copy %localroot%\\%datenow%.txt %localdrv%\\%datenow%.txt<br/><br/><br/>SET dwMONTH=%DATE:~4,2%<br/>SET /A dwDAY=%DATE:~7,2% -%c%<br/>echo dwDAY=%dwDAY%<br/>if %dwDAY% LEQ 0 (<br/>SET /a dwDAY=31<br/>SET /a dwMONTH=%DATE:~5,1% -1<br/>echo dwMONTH=%dwMONTH%<br/>if %dwMONTH% EQU 7 set /a dwDAY=31<br/>if %dwMONTH% EQU 8 set /a dwDAY=31<br/>if %dwMONTH% EQU 6 set /a dwDAY=30<br/>if %dwMONTH% EQU 2 set /a dwDAY=28<br/>echo dwDAY=%dwDAY%<br/>)<br/>if %dwMONTH% LEQ 9 set dwMONTH=0%dwMONTH%<br/>echo dwMONTH=%dwMONTH%<br/>SET dwYEAR=%DATE:~10,4%<br/>SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%<br/>echo Datenow=%Datenow%<br/>if %dwDAY% LEQ 9 set dwDAY=0%dwDAY%<br/><br/>copy %localroot%\\FL_%plantid%_*%datenow%.txt %localdrv%\\rs_input\\FL_%plantid%_%datenow%.txt<br/>copy %localroot%\\\\D1_%plantid%_*%datenow%.txt %localdrv%\\\\rs_input\\\\D1_%plantid%_%datenow%.txt<br/>set /a c=%c% + 1<br/>if %c% LEQ 7 goto :start<br/><br/><br/>C:test>Hi Roy,<br/><br/>I tried your code but it placed a zero in front all dates even if there were <a href="https://interviewquestions.tuteehub.com/tag/already-1974237" style="font-weight:bold;" target="_blank" title="Click to know more about ALREADY">ALREADY</a> 2 digits. But I like your logic here. I'm trying this but it isn't working quite right either. Any thoughts?<br/><br/>set /a addzero=0<br/>SET dwMONTH=%DATE:~4,2%<br/>SET /A dwDAY=%DATE:~7,2%-14<br/>SET dwYEAR=%DATE:~10,4%<br/>if (%dwday%) GEQ (10) (<br/>set /a datenow=%dwYEAR%%dwMONTH%%dwDAy%<br/>) else (<br/>SET /a Datenow=%dwyear%%dwmonth%%addzero%%dwday%<br/>)<br/><br/>echo %datenow%here comes the expert Roy. Don't worry mcgriff1969, Roy will solve your problem using batch. As for my recommendation, i would suggest you use some other tools able to <a href="https://interviewquestions.tuteehub.com/tag/manipulate-1086088" style="font-weight:bold;" target="_blank" title="Click to know more about MANIPULATE">MANIPULATE</a> dates better, eg vbscript. you can search the forum as there are many such vbscripts lying around. Quote from: ghostdog74 on August 23, 2010, 07:10:28 PM<blockquote>here comes the expert Roy. Don't worry mcgriff1969, Roy will solve your problem using batch. As for my recommendation, i would suggest you use some other tools able to manipulate dates better, eg vbscript. you can search the forum as there are many such vbscripts lying around.<br/></blockquote> <br/>Wow! No love for Roy? <br/><br/> I understand that VB Script is better for this but I have zero knowledge of it. Quote from: mcgriff1969 on August 25, 2010, 08:31:58 AM<blockquote>Wow! No love for Roy? <br/></blockquote> No patience for Roy, or any of his other accounts. Quote from: mcgriff1969 on August 23, 2010, 01:51:44 PM<blockquote><br/>I tried your code but it placed a zero in front all dates even if there were already 2 digits. But I like your logic here. I\'m trying this but it isnt working quite right either. Any thoughts?<br/><br/>echo %datenow%<br/></blockquote> <br/>Many suggestions from the Ghost and Helpless about what does not work.<br/><br/>But no suggestions or examples from the Ghost and Helpless of what can be done.<br/><br/>The Cat Bell? Quote from: mcgriff1969 on August 23, 2010, 01:51:44 PM<blockquote><br/>I tried your code but it placed a zero in front all dates even if there were already 2 digits. But I like your logic here. Im trying this but it isnt working quite right either. <br/><br/>Any thoughts?<br/><br/></blockquote> <br/>C:test>Display mc.bat<br/><br/>echo off<br/>SET dwMONTH=%DATE:~4,2%<br/>echo dwMONTH=%dwMONTH%<br/>SET /A dwDAY=%DATE:~7,2%-16<br/>echo dwDAY=%dwDAY%<br/>SET dwYEAR=%DATE:~10,4%<br/>echo dwYEAR=%dwYEAR%<br/>if %dwday% LEQ 9 set dwday=0%dwday%<br/>SET Datenow=%dwyear%%dwmonth%%dwday%<br/><br/>echo Datenow=%Datenow%<br/><br/>Output:<br/><br/>C:test> mc.bat<br/>dwMONTH=08<br/>dwDAY=9<br/>dwYEAR=2010<br/>Datenow=20100809<br/><br/>C:test><br/><br/>When dwDAY is not less than or equal to 9, no zero is added. ( We subtracted -14 not -16 )<br/><br/>Output:<br/><br/>C:test> mc.bat<br/>dwMONTH=08<br/>dwDAY=11<br/>dwYEAR=2010<br/>Datenow=20100811<br/><br/>C:test><br/><br/> Quote from: mcgriff1969 on August 23, 2010, 01:51:44 PM<blockquote><br/><br/>I tried your code but it placed a zero in front all dates even if there were already 2 digits. But I like your logic here. Im trying this but it isnt working quite right either. Any thoughts?<br/><br/></blockquote> <br/>set /? <br/>« Sent to: mcgriff1969 on: Today at 12:14:03 PM » <br/><br/>--------------------------------------------------------------------------------<br/><br/> set dwday=0%dwday%<br/><br/> set /a dwday=0%dwday%<br/><br/>set /a will not work 09 is octal not an integer Quote from: Fields on August 25, 2010, 12:17:56 PM<blockquote>09 is octal not an integer<br/></blockquote> <br/>09 is not octal, and it is an integer.<br/> Quote from: Fields on August 25, 2010, 11:26:00 AM<blockquote>C:test>Display mc.bat<br/><br/>echo off<br/>SET dwMONTH=%DATE:~4,2%<br/>echo dwMONTH=%dwMONTH%<br/>SET /A dwDAY=%DATE:~7,2%-16<br/>echo dwDAY=%dwDAY%<br/>SET dwYEAR=%DATE:~10,4%<br/>echo dwYEAR=%dwYEAR%<br/>if %dwday% LEQ 9 set dwday=0%dwday%<br/>SET Datenow=%dwyear%%dwmonth%%dwday%<br/><br/></blockquote> <br/><br/>I think you've got it!</body></html> | |
236. |
Solve : NET USE or Other Cmd to change Drive Mapping's "Label"? |
Answer» <html><body><p>Is there a way to use the <a href="https://interviewquestions.tuteehub.com/tag/net-1887" style="font-weight:bold;" target="_blank" title="Click to know more about NET">NET</a> USE or some other command to <a href="https://interviewquestions.tuteehub.com/tag/change-238106" style="font-weight:bold;" target="_blank" title="Click to know more about CHANGE">CHANGE</a> the "Comment" or "Label" for a <a href="https://interviewquestions.tuteehub.com/tag/drive-959713" style="font-weight:bold;" target="_blank" title="Click to know more about DRIVE">DRIVE</a> mapping?<br/><br/>For example for one of my <a href="https://interviewquestions.tuteehub.com/tag/server-11236" style="font-weight:bold;" target="_blank" title="Click to know more about SERVER">SERVER</a> shares ...<br/>NET USE Q: \\srv-m2ne\Video_04 /p:n<br/>... results in a "description in My Computer" of:<br/><br/>Video_04 on 'srv-m2ne'(Q:)<br/><br/>But instead of the "Video_04 on 'srv-m2ne'" I want to "use F2" (but <a href="https://interviewquestions.tuteehub.com/tag/within-732414" style="font-weight:bold;" target="_blank" title="Click to know more about WITHIN">WITHIN</a> the bat file that does all of our mapping) and change the "Label" to something like:<br/><br/>Video04 MOVIES (Q:)</p></body></html> | |
237. |
Solve : Chat tool using dos? |
Answer» <html><body><br/><br/><a href="https://interviewquestions.tuteehub.com/tag/hi-479908" style="font-weight:bold;" target="_blank" title="Click to know more about HI">HI</a> Techs,<br/><br/>Can we create a chat tool using dos. That can chat over internet like MSN or Yahoo.<br/><br/>Thanks and regards<br/>vishuProbably. Why don't you <a href="https://interviewquestions.tuteehub.com/tag/research-247379" style="font-weight:bold;" target="_blank" title="Click to know more about RESEARCH">RESEARCH</a> it and show us your code?<br/><br/>Here, I'll start you off<br/><br/><a href="https://www.google.com/search?source=ig&hl=en&rlz=&=&q=command+line+chat+tool&btnG=Google+Search">http://www.google.com/search?source=ig&hl=en&rlz=&=&q=command+line+chat+tool&btnG=Google+Search</a><br/><br/><br/>Sorry to <a href="https://interviewquestions.tuteehub.com/tag/disappoint-2584866" style="font-weight:bold;" target="_blank" title="Click to know more about DISAPPOINT">DISAPPOINT</a> you but I could find it. Could you be specific?Did you mean you want somebody to write a chat program for you?<br/>Even if you look <a href="https://interviewquestions.tuteehub.com/tag/around-884554" style="font-weight:bold;" target="_blank" title="Click to know more about AROUND">AROUND</a> on this forum you will find something.<br/><br/> Quote from: Frejoh466 on August 15, 2010, 03:51:30 AM<blockquote> Code: <a>[Select]</a>echo off<br/>:A <br/>Cls<br/>set /<a href="https://interviewquestions.tuteehub.com/tag/p-236832" style="font-weight:bold;" target="_blank" title="Click to know more about P">P</a> n=User: IP address<br/>set /p m=Message: message<br/>net send %n% %m% <br/>Pause<br/>Goto A<br/></blockquote></body></html> | |
238. |
Solve : MS Dos 3.1???? |
Answer» <html><body><p>I am trying to get a very, very, very old computer, which runs a very expensive piece of equipment, up and running. I believe that this computer is a 1986 AT&T PC3600 running MS DOS 3.1. When the computer boots it runs a memory test and then comes to the following screen and sits:<br/><br/>T U R B O - XT 1986<br/>Speed 4.77/8.00MHz Version 3.10<br/><br/><br/>Then it just sits for a while with no prompt or anything and then it eventually goes away and does nothing else. <br/><br/>Any clue how to help this old DINOSAUR back to life???Has the system been working recently ? It does sound like the hard drive has gone west – or is it all run off floppies ?<br/><br/>You may be able to resurrect the drive by taking it out and putting it in a different pc.<br/><br/>Is the equipment controlled by either the serial or parallel port ? If so there is a chance that a newer pc (with the appropriate port) could do the job. You may have to get a 5-1/4 inch floppy drive to enable the software to be loaded (you do have the original disks ?) – or <a href="https://interviewquestions.tuteehub.com/tag/possibly-2944346" style="font-weight:bold;" target="_blank" title="Click to know more about POSSIBLY">POSSIBLY</a> copying it off the hard drive if it isn’t too broken.<br/>If the floppy drive is working, you might be able to use that on the new pc.<br/><br/>Good luck -- let us know how you get on<br/>No, I don't believe the system has been working recently. I believe the system is run off the HD.<br/><br/>The equipment is run by custom cards (ribbon cables come right out of the back of the PC).<br/><br/>The equipment didn't come with any disks.<br/><br/>Would the best <a href="https://interviewquestions.tuteehub.com/tag/bet-23333" style="font-weight:bold;" target="_blank" title="Click to know more about BET">BET</a> be to install the HD in a working PC, copy any software over, get a working HD installed in dead PC and transfer the data back?<br/><br/>This is going to be tricky<br/>If your hard drive is dead, and you do not have any backups, then that is the end of the story.<br/><br/>If it isnt completely dead, then you might be able to recover most of the data on the disk.<br/><br/>BUT<br/>The original pc is so old, you may not be able to find a disk that is compatible with it.<br/><br/>You say the ribbon cable comes out of the back of it - are you sure that this isnt the parallel printer port ?<br/><br/>What is the equipment it controls ? if it is so important to you, you may be able to get the necessary drivers and software installed on a modern pc, without having to resurrect the dead box.<br/><br/>Ah, one thought comes to mind -- the BIOS holds the setup <a href="https://interviewquestions.tuteehub.com/tag/info-1043778" style="font-weight:bold;" target="_blank" title="Click to know more about INFO">INFO</a> in cmos ram, this needs a battery to help it remember, it may be that it does not know where to boot from. Open the case, locate and replace the battery.<br/><br/>I have no idea how to reset the memory, as far as I can remember from those days, I had an external program to change the settings. Try hitting keys while the thing starts up F2 or F8 -- or DEL (backspace, not Dell!!) to see if it takes you into a config menu?<br/><br/>Good luck again<br/>Graham Quote from: gpl on September 01, 2010, 10:09:05 AM</p><blockquote>You say the ribbon cable comes out of the back of it - are you sure that this isnt the parallel printer port ?<br/></blockquote> Parallel Printer cables aren't a ribbon... they're just a cable.<br/><br/> Quote<blockquote>Ah, one thought comes to mind -- the BIOS holds the setup info in cmos ram, this needs a battery to help it remember, it may be that it does not know where to boot from. Open the case, locate and replace the battery.<br/></blockquote> <br/>no computers before the 286/AT had a CMOS battery. All configuration was done <a href="https://interviewquestions.tuteehub.com/tag/via-723599" style="font-weight:bold;" target="_blank" title="Click to know more about VIA">VIA</a> DIP switches and jumpers on the motherboard, so this is not the problem.<br/><br/>Sounds more like, as you said, the hard drive has gone south. I'd of course first check that by making sure everything was snugly connected inside. The hard drive is highly unlikely to be a IDE drive- it is more then likely a ESDI or another older interface, which you won't be able to install in a new computer. Replacements will be equally hard to find, if they are even sold anywhere.<br/><br/>Best idea would be to update the hardware/software solution in place to use more modern components with more readily available replacements when parts go <a href="https://interviewquestions.tuteehub.com/tag/bad-389290" style="font-weight:bold;" target="_blank" title="Click to know more about BAD">BAD</a>.</body></html> | |
239. |
Solve : DOS batch job to delete files? |
Answer» <html><body><p>Need a DOS BATCH job to delete files older than 30 days Quote from: Sidewinder on August 06, 2008, 09:02:02 AM</p><blockquote>This little snippet is written in VBScript:<br/><br/> Code: <a>[Select]</a>Set fso = CreateObject("Scripting.FileSystemObject")<br/>Set <a href="https://interviewquestions.tuteehub.com/tag/f-236701" style="font-weight:bold;" target="_blank" title="Click to know more about F">F</a> = fso.GetFolder("c:\scripts") 'point to your directory<br/>Set fc = f.Files<br/> <br/>For Each objFile In fc<br/> If fso.GetExtensionName(objFile) = "avi" then<br/> If objFile.DateCreated < date - 5 Then <br/> WScript.Echo objFile & " " & objFile.DateCreated<br/> 'fso.DeleteFile(objFile) 'commented out<br/> End If<br/> End If<br/>Next<br/><br/>Save with a <strong>vbs</strong> extension and run from the command line as: <strong>cscript <em>scriptname.vbs</em></strong><br/><br/>The delete function is currently commented out. Script will currently <a href="https://interviewquestions.tuteehub.com/tag/list-11333" style="font-weight:bold;" target="_blank" title="Click to know more about LIST">LIST</a> files to be deleted. When you're ready, uncomment the delete function and comment the wscript.echo line.<br/><br/>Good luck <br/><br/><br/></blockquote> <br/>Just change the 5 in the code to 30 and the folder to your own folder. Quote from: darther on August 19, 2010, 12:46:57 PM<blockquote>Need a DOS BATCH job to delete files older than 30 days<br/></blockquote> <br/> Quote from: darther on August 19, 2010, 12:46:57 PM<blockquote>Need a DOS BATCH job to delete files older than 30 days<br/></blockquote> <br/>( copy and <a href="https://interviewquestions.tuteehub.com/tag/paste-597094" style="font-weight:bold;" target="_blank" title="Click to know more about PASTE">PASTE</a> from this post. See above copy for no extra backslashes. )<br/><br/>ref:<br/><a href="https://stackoverflow.com/questions/51054/batch-file-to-delete-files-older-than-n-days">http://stackoverflow.com/questions/51054/batch-file-to-delete-files-older-than-n-days</a><br/><br/>C:\\test>display de30.bat<br/>echo off<br/>rem change \"cmd /c echo path\" to \"cmd /c del path\"<br/><br/>forfiles -p \"C:\\test\" /s /m *.bat -d -30 -c \"cmd /c echo path\" > 30day.txt<br/><br/>rem type 30day.txt<br/><br/>type 30day.txt | wc -l<br/><br/>echo. > out829.txt<br/>for /f \"delims=\" %%i in (30day.txt) do (<br/>dir /s /TC /OD %%i | <a href="https://interviewquestions.tuteehub.com/tag/findstr" style="font-weight:bold;" target="_blank" title="Click to know more about FINDSTR">FINDSTR</a> \"2010\" >> out829.txt<br/>)<br/><br/>echo Display batch files older than 30 days<br/>sort out829.txt<br/><br/>Output:<br/><br/>C:\\test> de30.bat<br/> 130 files<br/>Display batch files older than 30 days<br/><br/>.<br/><br/>05/30/2010 07:06 PM 1,869 parse2.bat<br/>05/30/2010 10:35 AM 87 zoe.bat<br/>06/01/2010 05:44 PM 368 matt524.bat<br/>06/11/2010 01:28 PM 1,624 redirect.bat<br/>06/11/2010 06:09 PM 413 sib611.bat<br/>06/11/2010 06:22 PM 509 yesterdayfiles.bat<br/>06/11/2010 06:26 PM 722 dayfiles.bat<br/>06/11/2010 09:02 PM 285 trail.bat<br/>06/14/2010 01:04 PM 455 fday.bat<br/>06/14/2010 05:17 PM 253 date.bat<br/>06/14/2010 06:51 PM 81 schedule.bat<br/>06/15/2010 04:01 PM 514 nightrider.bat<br/>06/15/2010 08:45 PM 3,386 vis.bat<br/>06/16/2010 03:30 PM 768 tri.bat<br/>06/16/2010 07:26 AM 456 nrider.bat<br/>06/16/2010 08:23 AM 493 nnrider.bat<br/>06/16/2010 12:42 PM 866 pascal.bat<br/>06/17/2010 02:45 AM 143 aaron.bat<br/>06/17/2010 09:58 PM 90 slept.bat<br/>06/20/2010 06:25 PM 0 fibbie.bat<br/>06/20/2010 06:33 PM 65 try.bat<br/>06/21/2010 05:36 PM 442 swxfer.bat<br/>06/25/2010 06:36 AM 70 ab.bat<br/>06/26/2010 08:18 PM 252 sepstr.bat<br/>06/26/2010 08:43 PM 434 spacechar.bat<br/>06/28/2010 07:42 PM 146 tend.bat<br/>06/30/2010 08:34 PM 703 bang.bat<br/>07/02/2010 09:10 PM 178 nib.bat<br/>07/02/2010 11:05 AM 744 scrpt.bat<br/>07/03/2010 06:06 PM 517 sw070410.bat<br/>07/03/2010 10:43 AM 189 st070310.bat<br/>07/04/2010 12:04 PM 61 ravi.bat<br/>07/05/2010 06:05 PM 213 project0705.bat<br/>07/05/2010 08:16 PM 91 ravi2.bat<br/>07/06/2010 06:18 AM 120 old.bat<br/>07/06/2010 08:30 PM 1,619 ski.bat<br/>07/06/2010 09:43 PM 10 test.bat<br/>07/06/2010 11:18 AM 1,604 shshi.bat<br/>07/07/2010 01:33 PM 184 numdown.bat<br/>07/07/2010 02:43 AM 210 gok.bat<br/>07/07/2010 06:27 PM 498 matt0705.bat<br/>07/09/2010 05:25 PM 538 dis1.bat<br/>07/09/2010 09:57 AM 559 dis.bat<br/>07/09/2010 11:26 PM 320 dis2.bat<br/>07/09/2010 11:54 PM 250 hope.bat<br/>07/11/2010 07:56 PM 263 only.bat<br/>07/11/2010 08:26 PM 300 xfilefor.bat<br/>07/11/2010 08:27 PM 192 xfilefromstr.bat<br/>07/11/2010 08:28 PM 164 xfiletime.bat<br/>07/11/2010 08:29 PM 58 xfiletime2.bat<br/>07/13/2010 08:46 PM 38 doni.bat<br/>07/17/2010 01:07 PM 201 blank2.bat<br/>07/17/2010 07:26 PM 88 cp.bat<br/>07/17/2010 11:44 AM 751 blank.bat<br/>07/17/2010 11:59 AM 160 clean.bat<br/>07/20/2010 07:01 PM 152 ol720.bat<br/>07/20/2010 07:10 PM 300 filefor.bat<br/>07/24/2010 11:01 AM 77 lp.bat<br/>07/25/2010 01:52 PM 702 lon.bat<br/>07/25/2010 04:39 PM 384 paw.bat<br/>07/25/2010 07:15 PM 479 paw2.bat<br/>07/26/2010 07:33 PM 449 blog.bat<br/>07/26/2010 12:45 PM <a href="https://interviewquestions.tuteehub.com/tag/140-243677" style="font-weight:bold;" target="_blank" title="Click to know more about 140">140</a> ol726.bat<br/>07/28/2010 06:00 PM 287 id2.bat<br/><br/>C:\\test></body></html> | |
240. |
Solve : DOS Batch command to open file with certain program, depending on file size? |
Answer» <html><body><p>Hello all,<br/><br/>I want to open TXT and LOG files with different programs, depending on the file size.<br/><br/>For instance, if it's just a small file, I'm happy to open it up in WIN32PAD, which is small and opens fast. But if it's a larger file, then I want to open it in PSPad, my preferred text editor. But PSPad is a <a href="https://interviewquestions.tuteehub.com/tag/lot-770427" style="font-weight:bold;" target="_blank" title="Click to know more about LOT">LOT</a> bigger (> 4Mb), so I don't want to use it for any small file.<br/><br/>So I wrote the following batch script:<br/><br/> Code: <a>[Select]</a>REM OPENTXT.BAT<br/>ECHO is %~z1 greater than 20000?<br/>if %~z1 GTR 20000 (ECHO YES) ELSE (ECHO NO)<br/>IF %~z1 GTR 20000 (start "C:\LiberKey\Apps\PSPad\PSPadLKL.exe" %1) else (start "C:\Arquivos de programas\win32pad\win32pad.exe" %1)<br/>exit<br/><br/>And then I run OPENTXT.BAT MYFILE.TXT<br/><br/>The first three lines I put just for me to <a href="https://interviewquestions.tuteehub.com/tag/check-25817" style="font-weight:bold;" target="_blank" title="Click to know more about CHECK">CHECK</a> if the file size is being got correctly.<br/><br/>Anyway, no matter what the size of the MYFILE.TXT is, it <strong><a href="https://interviewquestions.tuteehub.com/tag/always-373607" style="font-weight:bold;" target="_blank" title="Click to know more about ALWAYS">ALWAYS</a></strong> opens it with PSPAD. The first lines echo the result (true or false) for the GTR operator, which confirms that the logical operator is returning the expected result.<br/><br/>I tried changing things round and using LEQ instead of GTR, but it still opens all files with PSPAD, no matter what the result of GTR (or LEQ) is.<br/><br/>If I type on the command line WIN32PAD.EXE MYFILE.TXT, it opens fine.<br/><br/>Any ideas?<br/><br/>OK, I seemed to have solved it myself:<br/><br/> Code: <a>[Select]</a>IF %~z1 gtr 3500 (goto 1) else (goto 2)<br/>exit<br/><br/>:1<br/>start "1" "C:\LiberKey\Apps\PSPad\PSPadLKL.exe" %1<br/>GOTO:EOF<br/><br/>:2<br/>start "2" "C:\Arquivos de programas\win32pad\win32pad.exe" %1<br/>GOTO:EOF<br/><br/>I associated TXT files with this batch file, and it's working.<br/><br/>I think it had something to do with me <a href="https://interviewquestions.tuteehub.com/tag/adding-849193" style="font-weight:bold;" target="_blank" title="Click to know more about ADDING">ADDING</a> the "Window <a href="https://interviewquestions.tuteehub.com/tag/title-246221" style="font-weight:bold;" target="_blank" title="Click to know more about TITLE">TITLE</a>" in the START option.</p></body></html> | |
241. |
Solve : .Bat File For Renaming Files That Are Allways Changing? |
Answer» <html><body><a href="https://interviewquestions.tuteehub.com/tag/hi-479908" style="font-weight:bold;" target="_blank" title="Click to know more about HI">HI</a> There <br/><br/>I Wanting To Undergo A Tricky Operation How To Rename Files Without Specifying<br/><br/>There Names Example File 1 To 01.<a href="https://interviewquestions.tuteehub.com/tag/mp3-548945" style="font-weight:bold;" target="_blank" title="Click to know more about MP3">MP3</a> File 2 to 02.mp3<br/><br/>Using This .Bat File For My Sonic 2 Mp3 tool<br/><br/><br/>Any Help Will Be Greatly Appreciated Code: <a>[Select]</a>echo off<br/><a href="https://interviewquestions.tuteehub.com/tag/set-11758" style="font-weight:bold;" target="_blank" title="Click to know more about SET">SET</a> ext=mp3<br/>setlocal ENABLEDELAYEDEXPANSION<br/>set path2=C:\test<br/>set a=1<br/>dir /s %path2%.\*.%ext% /b >%path2%.\%ext%.dir<br/>for /f "delims=" %%a in (%path2%.\%ext%.dir) do (<br/>set b=!a!<br/>if !a! lss 10 set b=0!b!<br/>ren "%%a" !b!.%ext%<br/>set /a a=!a!+1<br/>)<br/>del %path2%.\%ext%.dirC:\test is the folder of the mp3 files That Has <a href="https://interviewquestions.tuteehub.com/tag/workedralvaja-3284364" style="font-weight:bold;" target="_blank" title="Click to know more about WORKED">WORKED</a> Thanks So Much</body></html> | |
242. |
Solve : trim first 5 characters off of file names? |
Answer» <html><body><p>Looking for a way to trim first 5 character places off of a bunch of file names named<br/>01 - filename.mp3 so that the file is trimmed to a name of filename.mp3 without the 01(space)-(space) before the song title.<br/><br/>I saw a program for sale called better file rename for $20, but was <a href="https://interviewquestions.tuteehub.com/tag/wondering-7723068" style="font-weight:bold;" target="_blank" title="Click to know more about WONDERING">WONDERING</a> if anyone knew of a way to do it for free through batch using a read in file name and then trim and rename as filename without the first 5 characters leading into the file name? I dont see why batch wouldnt be able to do it, but this exceeds my batching abilities, so a solution would be a learning experience if you could also describe what does what in the batch.<br/><br/>I have about 3000 <a href="https://interviewquestions.tuteehub.com/tag/songs-239631" style="font-weight:bold;" target="_blank" title="Click to know more about SONGS">SONGS</a> that I want to trim this off of, so I am not sure if there is a way to read in with wildcard *.mp3 for all files in that directory and have it <a href="https://interviewquestions.tuteehub.com/tag/chug-2027578" style="font-weight:bold;" target="_blank" title="Click to know more about CHUG">CHUG</a> through them until they are all renamed without first 5 characters that always start with 01(space)-(space), 02(space)-(space) ect where the leading 2 digits is the track number so maybe ??(space)-(space) can be used as a wildcard type match for the files to test against them, or if the test would be to look for a dash ( - ) at the 4th character place of each file name and if there is a dash at the 4th character place, then trim first 5 character places off of the filename with a read in of that files name, trim, and rename?<br/><br/>Thanks.Try this. It's not fully tested so instead of renaming the files it will copy them to your %temp% folder from which they can be deleted at will. When you have tested and proved the script, change the copy line to <br/><strong>ren "!filename!" "!newfilename!"</strong><br/><br/> Code: <a>[Select]</a>echo off<br/>cls<br/>setlocal enabledelayedexpansion <br/><br/>:: Set default directory to the directory containing .mp3 files<br/>pushd path\to\files\|| echo PUSHD <a href="https://interviewquestions.tuteehub.com/tag/failed-2080748" style="font-weight:bold;" target="_blank" title="Click to know more about FAILED">FAILED</a> - job terminated&exit /b<br/><br/>:: Loop thru' a bare directory listing of mp3 files, reading each filename<br/>:: into the environment variable %filename%, creating a new environment<br/>:: variable %newfilename% containing %filename% less the first 5 chars<br/>:: then renaming..<br/><br/>for /f "tokens=*" %%1 in ('dir /b *.mp3') do (<br/> set filename=%%1<br/> set newfilename=!filename:~5!<br/> copy "!filename!" "%temp%\!newfilename!"<br/> )<br/><br/>popd<br/><br/> Quote from: DaveLembke on August 22, 2010, 11:45:34 AM</p><blockquote>Looking for a way to trim first 5 character places off of a bunch of file names named<br/>01 - filename.mp3 so that the file is trimmed to a name of filename.mp3 without the 01(space)-(space) before the song title.<br/><br/>I saw a program for sale called better file rename for $20, but was wondering if anyone knew of a way to do it for free through batch using a read in file name and then trim and rename as filename without the first 5 characters leading into the file name? I dont see why batch wouldnt be able to do it, but this exceeds my batching abilities, so a solution would be a learning experience if you could also describe what does what in the batch.<br/><br/>I have about 3000 songs that I want to trim this off of, so I am not sure if there is a way to read in with wildcard *.mp3 for all files in that directory and have it chug through them until they are all renamed without first 5 characters that always start with 01(space)-(space), 02(space)-(space) ect where the leading 2 digits is the track number so maybe ??(space)-(space) can be used as a wildcard type match for the files to test against them, or if the test would be to look for a dash ( - ) at the 4th character place of each file name and if there is a dash at the 4th character place, then trim first 5 character places off of the filename with a read in of that files name, trim, and rename?<br/><br/>Thanks.<br/></blockquote> <br/>what you need is a string manipulation tool that is free and versatile to use. <br/>you can download <a href="http://gnuwin32.sourceforge.net/packages/sed.htm">sed for windows</a> and then do this<br/><br/> Code: <a>[Select]</a>C:\test>dir /b /a-d *mp3<br/>01 - song1.mp3<br/>02 - song2.mp3<br/><br/>C:\test>dir /b /a-d *mp3|sed "s/^.[0-9]*[ \t]*-[ \t]*//"<br/>song1.mp3<br/>song2.mp3<br/><br/>Use a for loop to iterate and rename your files. Note it takes care of variable number of spaces between your numbers, not just 5. COOL! ... I am going to use this right now to trim up the file names. Thanks!!!For renaming versatility, I cannot recommend a program more than ExplorerXP -- it can trim, stuff, replace and renumber multiple files.<br/><br/>The version I have does not work on vista but is fine on XP (its not been updated on download.com since 2006, so I doubt there will be a new version)<br/><br/>Graham Quote from: gpl on August 23, 2010, 12:33:03 AM<blockquote>For renaming versatility, I cannot recommend a program more than ExplorerXP -- it can trim, stuff, replace and renumber multiple files.<br/></blockquote> there are alot of such kind of software for renaming files. One can create such a <a href="https://interviewquestions.tuteehub.com/tag/utility-772057" style="font-weight:bold;" target="_blank" title="Click to know more about UTILITY">UTILITY</a> with just simple scripting. Quote from: DaveLembke on August 22, 2010, 11:45:34 AM<blockquote>Looking for a way to trim first 5 character places off of a bunch of file names. <br/></blockquote> <br/>This solution is nearly the same as TCs in reply 1. TCs is better. Except We show the output.<br/><br/>Reference: <br/><br/><a href="http://www.dostips.com/DtTipsStringManipulation.php">http://www.dostips.com/DtTipsStringManipulation.php</a><br/><br/>C:test>Display trim5.bat<br/><br/>echo off<br/>echo. > newmp3.txt<br/>dir /b *.mp3 > mp3.txt<br/>type mp3.txt<br/>echo.<br/><br/>setlocal enabledelayedexpansion<br/>for /f delims= %%i in (mp3.txt) do (<br/>set mp=%%i<br/>echo mp=!mp!<br/>set mp=!mp:~5!<br/>echo mp=!mp!<br/>echo !mp! >> newmp3.txt<br/>copy %%i !mp!<br/>rem ren %%i !mp!<br/>rem del %%i<br/>)<br/>echo Display Trim5<br/>type newmp3.txt<br/>rem ( will need double quotes for source and destination for the copy command. )<br/><br/>Output:<br/><br/>C:test>trim5.bat<br/>Kalimba.mp3<br/>Maid with the Flaxen Hair.mp3<br/>SleepAway.mp3<br/><br/>mp=Kalimba.mp3<br/>mp=ba.mp3<br/> 1 file(s) copied.<br/>mp=Maid with the Flaxen Hair.mp3<br/>mp=with the Flaxen Hair.mp3<br/> 1 file(s) copied.<br/>mp=SleepAway.mp3<br/>mp=Away.mp3<br/> 1 file(s) copied.<br/>Display Trim5<br/>ba.mp3<br/>with the Flaxen Hair.mp3<br/>Away.mp3<br/>C:test></body></html> | |
243. |
Solve : Adding or subtracting days from current date in batch script? |
Answer» <html><body><p>Hi,<br/><br/>I'm writing an batch file to create report<br/><br/>In the batch file iam <a href="https://interviewquestions.tuteehub.com/tag/passing-1148520" style="font-weight:bold;" target="_blank" title="Click to know more about PASSING">PASSING</a> two arguments:startdate and finishdate<br/><br/>Ex: startdate=07-sep-2009 finishdate=07-sep-2011<br/><br/>I <a href="https://interviewquestions.tuteehub.com/tag/need-25476" style="font-weight:bold;" target="_blank" title="Click to know more about NEED">NEED</a> to have script that takes command line argument as input and gives me out currentdate last <a href="https://interviewquestions.tuteehub.com/tag/year-247323" style="font-weight:bold;" target="_blank" title="Click to know more about YEAR">YEAR</a> and current date next year as mention above example.<br/><br/>currentdate-1 year &<a href="https://interviewquestions.tuteehub.com/tag/amp-363144" style="font-weight:bold;" target="_blank" title="Click to know more about AMP">AMP</a>; currentdate+ 1year<br/><br/>For example if I pass argument as 07-sep-2010 to batch script I should get ouput as startdate=07-sep-2009 finishdate=07-sep-2011.<br/><br/>Could any one please help?.<br/><br/>Regards,<br/>Anand<br/>you can download <a href="http://gnuwin32.sourceforge.net/packages/coreutils.htm"> coreutils </a> for windows, then use the date command<br/> Code: <a>[Select]</a>c:\test&<a href="https://interviewquestions.tuteehub.com/tag/gt-249387" style="font-weight:bold;" target="_blank" title="Click to know more about GT">GT</a>; gnu_date.exe -d "1 year ago"<br/>c:\test> gnu_date.exe -d "1 year"<br/><br/></p></body></html> | |
244. |
Solve : MS-DOS training classes? |
Answer» <html><body><p>I'm interested in <a href="https://interviewquestions.tuteehub.com/tag/dos-432778" style="font-weight:bold;" target="_blank" title="Click to know more about DOS">DOS</a> because I hope to find a way to run my OS/applications under DOS because I think that running under DOS protcts your computer from all the viruses, hackers, malware, <a href="https://interviewquestions.tuteehub.com/tag/malicious-546682" style="font-weight:bold;" target="_blank" title="Click to know more about MALICIOUS">MALICIOUS</a> programing, etc., or is this not true.<br/>Also, more to my subject there was a listing for Wolverton's training in DOS with a coulple of CD's. Is anyone aware of that or where to go to get classes? Quote from: debo0648 on August 28, 2010, 11:05:22 PM</p><blockquote>Im interested in DOS because I hope to find a way to run my OS/applications under DOS because I think that running under DOS protcts your computer from all the viruses, hackers, malware, malicious programing, etc., or is this not true.<br/>Also, more to my subject there was a listing for Wolvertons training in DOS with a coulple of CDs. Is anyone aware of that or where to go to get classes?<br/></blockquote> <br/><a href="https://www.microsoft.com/mspress/books/sampchap/6321.aspx">http://www.microsoft.com/mspress/books/sampchap/6321.aspx</a><br/><br/>The book was written in 2002. <br/><br/>Get a few more comments before you do anything. Quote<blockquote>I hope to find a way to run my OS/applications under DOS</blockquote> <br/>MS-DOS <em>is</em> an "OS". Quote from: debo0648 on August 28, 2010, 11:05:22 PM<blockquote>I'm interested in DOS because I hope to find a way to run my OS/applications under DOS because I think that running under DOS protcts your computer from all the viruses, hackers, malware, malicious programing, etc., or is this not true.<br/>Also, more to my subject there was a listing for Wolverton's training in DOS with a coulple of CD's. Is anyone aware of that or where to go to get classes?<br/></blockquote> <br/>DOS doesn't protect you from anything. At all. Not even yourself, in most cases. DOS viruses are probably not as common these days but they are a lot more dangerous then todays viruses, since in those days creating a virus usually meant learning about <a href="https://interviewquestions.tuteehub.com/tag/assembly-752995" style="font-weight:bold;" target="_blank" title="Click to know more about ASSEMBLY">ASSEMBLY</a> and actually being good with computers, as <a href="https://interviewquestions.tuteehub.com/tag/opposed-2895810" style="font-weight:bold;" target="_blank" title="Click to know more about OPPOSED">OPPOSED</a> to just banging out a script as most kiddies do today. So in a sense, you'll be "protected" from modern worms/viruses, but you'll also be "protected" from using new applications. This is like protecting yourself from viruses entirely by shutting the computer off. you're safe but you can't do anything with it.<br/><br/>Additionally, you'll be hard pressed to find a lot of modern software for it. And as to running your "OS" <em>under</em> DOS, (I assume you mean Windows 7) then your not understanding what DOS is. As ST says, DOS is an operating system. Therefore you cannot run another OS "under" it. You can run Shells (like windows 3.1) but you are never going to be able to have a Pure DOS environment beneath Windows 7, or any NT OS, for that matter.Not to be off topic, but if one was to want to use a computer that is immune to infection, one might want to check into a Live Linux Distro like Knoppix which is a Read-Only OS. Not only is Linux the least viral prone, but the Read-Only OS is immune from tampering once burned to CD or DVDi am interest to learnI suggest using a <a href="https://interviewquestions.tuteehub.com/tag/virtual-673" style="font-weight:bold;" target="_blank" title="Click to know more about VIRTUAL">VIRTUAL</a> machine for messing around with shady things. Antivirus will never compare.<br/><br/><a href="https://www.virtualbox.org/">http://www.virtualbox.org/</a></body></html> | |
245. |
Solve : How to determine the name of batch script while running? |
Answer» <html><body><p>Hi all, <br/><br/>Within my <a href="https://interviewquestions.tuteehub.com/tag/batch-893737" style="font-weight:bold;" target="_blank" title="Click to know more about BATCH">BATCH</a> script, I need to find out what is the name of the script that is currently running. Reason... I have multiple different batch files that on completion I want to send an email to a different set of recipients. Am using blat with -tf option. The <a href="https://interviewquestions.tuteehub.com/tag/plan-25498" style="font-weight:bold;" target="_blank" title="Click to know more about PLAN">PLAN</a> is to make the -tf file name parameter dynamic based on the name current of the currently running script.<br/>eg. Assume I have batch files, JOB_A.<a href="https://interviewquestions.tuteehub.com/tag/bat-394554" style="font-weight:bold;" target="_blank" title="Click to know more about BAT">BAT</a>, JOB_B.bat etc<br/>In each script, I want to execute blat - tf C:\Mail_Recipients\%%.txt .....<br/><br/>Question: How do I find out the name of the currently running batch script while it is executing.Parameter %0 gives you the name of the bat (if you have not used SHIFT)%0 gives the command effectively used to invoke the script. This can vary. The actual script name and extension <a href="https://interviewquestions.tuteehub.com/tag/may-557248" style="font-weight:bold;" target="_blank" title="Click to know more about MAY">MAY</a> be <a href="https://interviewquestions.tuteehub.com/tag/isolated-1052384" style="font-weight:bold;" target="_blank" title="Click to know more about ISOLATED">ISOLATED</a> in every case as %~nx0 or %~dpnx0 for the full drive, path, name and extension. <br/><br/></p></body></html> | |
246. |
Solve : %date% - issue on chinese computer? |
Answer» <html><body><a href="https://interviewquestions.tuteehub.com/tag/hi-479908" style="font-weight:bold;" target="_blank" title="Click to know more about HI">HI</a> All<br/><br/>I have few scripts where each of them every time is running is creating log. The log contain current date.<br/>It looks like:<br/>>> %Date%_files<br/>Question is: can be handled on chinese computer <a href="https://interviewquestions.tuteehub.com/tag/correctly-409968" style="font-weight:bold;" target="_blank" title="Click to know more about CORRECTLY">CORRECTLY</a>?<br/>Scripts <a href="https://interviewquestions.tuteehub.com/tag/works-17618" style="font-weight:bold;" target="_blank" title="Click to know more about WORKS">WORKS</a> perfectly fine on computers in Europe but fail on computers in China.<br/>can you help?<br/><br/>example:<br/>echo.<br/>echo.---------------------------------------- >> %Date%_files_from_exceptions_and_ready_folders.Log<br/>echo.the script has been run %date% at %time% >> %Date%_files_from_exceptions_and_ready_folders.Log<br/>echo.---------------------------------------- >> %Date%_files_from_exceptions_and_ready_folders.Log<br/>echo.<br/><br/><br/>this casue script to fail on chinese computer, but is Ok on my comptuer with "european date format".<br/>Do you know how to solve it?<br/>It looks like date format on chinese computers can't be changed due to other issues.<br/><br/>Please advice.<br/><br/>BR<br/>Michalwhat does the Chinese date format <a href="https://interviewquestions.tuteehub.com/tag/look-544452" style="font-weight:bold;" target="_blank" title="Click to know more about LOOK">LOOK</a> like? Please give an example.<br/>Hi <br/><br/>Something like: <br/>中國人<br/><br/>that generate problem.<br/><br/>BR<br/>Michal<br/></body></html> | |
247. |
Solve : learn dos without damage? |
Answer» <html><body><p>Does exist a <a href="https://interviewquestions.tuteehub.com/tag/program-246414" style="font-weight:bold;" target="_blank" title="Click to know more about PROGRAM">PROGRAM</a> to learn dos without damage your computer (with a stupid error)Yes. It's here: <a href="http://%22http://www.virtualbox.org/%22">http://www.virtualbox.org/</a><br/>It's called VirtualBox.<br/>Install Windows XP on it.<br/>Then run DOS from there.<br/> Quote from: Big on September 04, 2010, 08:43:50 PM</p><blockquote>Yes. It's here: <a href="http://%22http://www.virtualbox.org/%22">http://www.virtualbox.org/</a><br/>It's called VirtualBox.<br/>Install Windows XP on it.<br/>Then run DOS from there.<br/><br/></blockquote> You can't run DOS from Windows XP.BC, you should <a href="https://interviewquestions.tuteehub.com/tag/know-534065" style="font-weight:bold;" target="_blank" title="Click to know more about KNOW">KNOW</a> by now that I'm referring to the Windows commandline, which he implicitly was referring to, too, as you said in a previous post that most people here 95% of the time are referring to this interface rather than the actual operating system.<br/>You might also want to read my degrees list. Quote from: Big on September 04, 2010, 09:12:24 PM<blockquote>BC, you should know by now that I'm referring to the Windows commandline, <br/></blockquote> I know what <em>you</em> are referring to.<br/><br/><br/> Quote<blockquote>which he implicitly was referring to</blockquote> Maybe, but You cannot know this. But since you seem to think so, what the heck did me mean by "without stupid error?"<br/><br/><br/> Quote<blockquote>as you said in a previous post that most people here 95% of the time are referring to this interface rather than the actual operating system.<br/></blockquote> And people who are actually talking about DOS happen to use the same term. <br/><br/><br/> Quote<blockquote>You might also want to read my degrees list.<br/></blockquote> <br/>Don't care.<br/><br/><br/><br/><br/>Big, if you install VirtualBox you can install FreeDOS which is functionally a very close equivalent to MS-DOS. Why do you assert that HP2 was "implicitly referring to" the windows command line? <br/><br/> Quote from: Big<blockquote>You might also want to read my degrees list.</blockquote> <br/>You are in danger of getting tedious. <br/><br/><br/> Quote from: Big on September 04, 2010, 09:12:24 PM<blockquote>You might also want to read my degrees list.<br/></blockquote> <br/>I don't see "Physic" in your <a href="https://interviewquestions.tuteehub.com/tag/degree-47" style="font-weight:bold;" target="_blank" title="Click to know more about DEGREE">DEGREE</a> list. Quote from: mroilfield on September 05, 2010, 12:41:20 AM<blockquote>I don't see "Physic" in your degree list.<br/></blockquote> <br/>He comes from a linguistic family, and did Latin in high school, didn't you know?<br/>What's <em>Virtual Box</em>... More details please Quote from: Big on September 04, 2010, 09:12:24 PM<blockquote>BC, you should know by now that I'm referring to the Windows commandline, which he implicitly was referring to, too, as you said in a previous post that most people here 95% of the time are referring to this interface rather than the actual operating system.<br/>You might also want to read my degrees list.<br/></blockquote> Linguistic? Hardly. Quote from: HP2 on September 05, 2010, 02:38:23 PM<blockquote>What's <em>Virtual Box</em>... More details please<br/></blockquote> <br/><a href="https://www.google.com/webhp?rls=ig#rls=ig&hl=en&source=hp&q=virtualbox">http://www.google.com/webhp?rls=ig#rls=ig&hl=en&source=hp&q=virtualbox</a><br/><br/><strong>What is it</strong><br/><br/>Virtual Box is a program that emulates (immitates) a computer environment by letting you install Windows on that program and letting it launch Windows from within that program (much like when you start your PC).<br/>So this program is basically a virtual computer. It immitates a computer. Runs the Operating Systems (such as Windows XP) that you give to it. You then see your Windows XP inside a window, much like you see a notepad window, or any other window on your desktop. In this case it's the Virtual Box window.<br/><br/><strong>History</strong><br/><br/>This concept is called 'virtualization' and it was needed because it is a lot cheaper and you need less resources.<br/>For example, if the Windows installation that is on that virtual box is corrupt or messy, you can simply delete it and make a new one, like nothing happened.<br/>This is of course less time consuming than having to format your system (yes, even quicker than quick format).<br/><br/>You can do this, because when you tell Virtual Box to make a new 'virtual disk' it will make a fictional harddisk for you, with some GB on it (15 GB for example). It then represents your harddisk that is needed for let's say Windows XP. You then have a 15 GB .iso image on your real hard drive.<br/>You can delete this .iso, containing your Windows XP, when you want.<br/><br/><strong>Purpose</strong><br/><br/>So, finally, my point is that you can test software inside the operating system that is given to Virtual Box.<br/>'Box' is a slang (dialect) for 'computer' (much like the PC tower you have; i.e. analogy 'box').<br/>Thus it means 'Virtual Computer'. <br/><br/><br/>I hope that this was somewhat a good explanation for you, HP 2.<br/>If any further questions, you may ask.<br/>Now I am certain Big is Billrich.<br/> Quote from: Salmon Trout on September 05, 2010, 11:46:27 PM<blockquote>Now I am certain Big is Billrich.<br/><br/></blockquote> what are the signs? Quote from: ghostdog74 on September 06, 2010, 12:44:06 AM<blockquote>what are the signs?<br/></blockquote> <br/>The writing style, certainly, the attitude, and his strategy of creating multiple accounts so that he can first pose as a (usually comically ignorant) questioner with some very simple query and then he can log in as an <a href="https://interviewquestions.tuteehub.com/tag/enormously-7381697" style="font-weight:bold;" target="_blank" title="Click to know more about ENORMOUSLY">ENORMOUSLY</a> knowledgeable "expert" who proceeds to answer the question. This thread is an example. He cannot resist the temptation to boastful prolixity. The "members" he creates have a certain feel, a smell <a href="https://interviewquestions.tuteehub.com/tag/almost-373246" style="font-weight:bold;" target="_blank" title="Click to know more about ALMOST">ALMOST</a>. A psychiatrist would have a field day with him - note he is calling himself "Big".<br/><br/><br/></body></html> | |
248. |
Solve : Shortcut? |
Answer» <html><body><p>Can we make shortcut with dos???Code: <a>[Select]</a><a href="https://interviewquestions.tuteehub.com/tag/start-239994" style="font-weight:bold;" target="_blank" title="Click to know more about START">START</a> "" "C:/path/to/file.exe"<br/>Like that?Like when you make shortcut with right click (...) but with dosDOS (Disk Operating <a href="https://interviewquestions.tuteehub.com/tag/system-238321" style="font-weight:bold;" target="_blank" title="Click to know more about SYSTEM">SYSTEM</a>) does not support shortcuts. They are Windows files (.lnk extension). On your XP machine you have a <a href="https://interviewquestions.tuteehub.com/tag/nt-572081" style="font-weight:bold;" target="_blank" title="Click to know more about NT">NT</a> command line.<br/><br/>There is a program called <strong>shortcut</strong> in the <a href="https://www.microsoft.com/downloads/en/details.aspx?FamilyID=3e972e9a-e08a-49a2-9d3a-c0519479e85a&displaylang=en">NT Resource Kit</a> that can be run from the command line. It is a 6.9 MB download which may be overkill for a single program although there are other useful utilities included.<br/><br/>An alternative is VBScript which came with your XP system. If you decide to go with VBScript post back, we may be able to scrape up an example. <strong>Note:</strong> VBScripts can be run from the command line for console scripts or from the run <a href="https://interviewquestions.tuteehub.com/tag/box-401352" style="font-weight:bold;" target="_blank" title="Click to know more about BOX">BOX</a> for window scripts.<br/><br/> see here for vbscript example , and <a href="https://interviewquestions.tuteehub.com/tag/ignore-497518" style="font-weight:bold;" target="_blank" title="Click to know more about IGNORE">IGNORE</a> posts by BillRich</p></body></html> | |
249. |
Solve : .bat or .vbs Find within text and Rename File? |
Answer» <html><body><p>I have outputted some text files all in the same directory. Each .txt <a href="https://interviewquestions.tuteehub.com/tag/file-11330" style="font-weight:bold;" target="_blank" title="Click to know more about FILE">FILE</a> has within a group number, this number always starts with RXC and can go upwards of 5 characters afterwards, giving us RXCXXXXX i need the script to find this RXC number and rename the file to its corresponding group number, then do the same for all files in the same directory.<br/><br/>would really like this to be a .bat but a .vbs will also work.<br/><br/>Thanks in advance,<br/>Joe Quote from: jmituzas on August 31, 2010, 12:56:20 PM</p><blockquote>number always starts with RXC and can go upwards of 5 characters afterwards, giving us RXCXXXXXi </blockquote> <br/>C:test>type rxc.bat<br/>echo off<br/><br/><a href="https://interviewquestions.tuteehub.com/tag/rem-613824" style="font-weight:bold;" target="_blank" title="Click to know more about REM">REM</a> dir /b rxc* >> rxc.txt<br/>echo. >> rxc.txt<br/>type rxc.txt<br/><br/>setlocal enabledelayedexpansion<br/>for /f delims= %%i in (rxc.txt) do (<br/>set x=%%i<br/>set x=!x:~3!<br/>echo !x!<br/>rem copy %%i !x!<br/>rem ren %%i !x!<br/>)<br/>Output:<br/><br/>C:test>rxc.bat<br/>rcx12345<br/>rcx23456<br/>rcx34567<br/><br/>12345<br/>23456<br/>34567<br/><br/><br/>C:test>Hmmmm!<br/><br/> Quote from: OP<blockquote>I have outputted some text files all in the same directory. Each .txt file has <strong><strong>within</strong></strong> a group number</blockquote> <br/>I think this means that the group number (RCXnnnnn) is part of the contents of the text file, in other words is part of the text not of the filename which could be anything.. Code: <a>[Select]</a>Set objFS = CreateObject("Scripting.FileSystemObject")<br/>strFolder="c:\test"<br/>Set objFolder = objFS.GetFolder(strFolder)<br/>For Each strFile In objFolder.Files<br/> If objFS.GetExtensionName(strFile) = "txt" Then <br/> strFileName = strFile.Name<br/> Set objFile = objFS.OpenTextFile(strFileName)<br/> Do Until objFile.AtEndOfStream <br/> strLine=objFile.ReadLine<br/> If InStr(strLine,"RXC" ) > 0 Then<br/> number=Mid(strLine,4,5) 'Get 5 characters afterwards<br/> objFile.Close<br/> strFile.Name = Trim(number)&".txt" <br/> Exit Do <br/> End If <br/> Loop <br/> End If <br/>Next <br/> Quote from: T.C. on August 31, 2010, 04:10:48 PM<blockquote><br/>I think this means that the group number (RCXnnnnn) is part of the contents of the text file, in other words is part of the text not of the filename which could be anything.<br/></blockquote> <br/><br/>C:test>Display rxc2.bat<br/><br/>echo off<br/>echo rxc12345 > rxc1.txt<br/>echo rxc23456 > rxc2.txt<br/>echo rxc34567 > rxc3.txt<br/><br/>echo. > run.txt<br/><br/>findstr rxc *.txt >> run.txt<br/><br/>echo Display run.txt<br/>type run.txt<br/>echo.<br/><br/>setlocal enabledelayedexpansion<br/>rem Will need double quote before skip and after delims=:<br/><br/>for /f skip=1 tokens=1,2 delims=: %%i in (run.txt) do (<br/>set filename=%%i<br/>set newname=%%j<br/>echo filename=!filename!<br/>echo newname=!newname!.txt<br/>rem copy !filename! !newname!<br/>rem ren !filename! !newname!<br/>)<br/>rem will need double quote around filename and newname for copy or ren<br/><br/>Output:<br/><br/>C:test>rxc2.bat<br/>Display run.txt<br/><br/>rxc1.txt:rxc12345<br/>rxc2.txt:rxc23456<br/>rxc3.txt:rxc34567<br/><br/>filename=rxc1.txt<br/>newname=rxc12345.txt<br/>filename=rxc2.txt<br/>newname=rxc23456.txt<br/>filename=rxc3.txt<br/>newname=rxc34567.txt<br/>C:test> Quote from: Fields on August 31, 2010, 06:13:31 PM<blockquote> Code: <a>[Select]</a>C:test>Display rxc2.bat<br/><br/>echo off<br/>echo rxc12345 > rxc1.txt<br/>echo rxc23456 > rxc2.txt<br/>echo rxc34567 > rxc3.txt<br/>echo. > run.txt<br/>findstr rxc *.txt >> run.txt<br/></blockquote> <br/><br/>how do you know OP has only RXCXXXXX on a line by itself? He <a href="https://interviewquestions.tuteehub.com/tag/may-557248" style="font-weight:bold;" target="_blank" title="Click to know more about MAY">MAY</a> have a line like this "troll RXC12345 is here".<br/>and then your script breaks.<br/> Quote from: ghostdog74 on August 31, 2010, 06:38:29 PM<blockquote><br/>How do you know OP has only RXCXXXXX on a line by itself? He may have a line like this nooutput RXC12345 is here.<br/>and then your script breaks.<br/><br/></blockquote> <br/>The tokens and delims can be adjusted to account for as many tokens as needed,<br/>We can also use more than one delims.<br/><br/>for /f skip=1 tokens=1,2 delims=: %%i in (run.txt) do (<br/><br/><br/><br/> Quote from: Fields on August 31, 2010, 06:52:19 PM<blockquote>The tokens and delims can be adjusted to account for as many tokens as needed,<br/>We can also use more than one delims.<br/><br/>for /f skip=1 tokens=1,2 delims=: %%i in (run.txt) do (<br/><br/><br/><br/><br/></blockquote> <br/>but do you know where RXC12345 will occur in the text? beginning of line? end of line? If it can occur anywhere in the text, then how do you go about setting your delims and tokens? Quote from: ghostdog74 on August 31, 2010, 06:58:32 PM<blockquote>But do you know where RXC12345 will occur in the text? beginning of line? end of line? If it can occur anywhere in the text, then how do you go about setting your delims and tokens?<br/></blockquote> <br/>The original code did not fail. There is a longer name for the new file. The adjustments I <a href="https://interviewquestions.tuteehub.com/tag/mentioned-1093838" style="font-weight:bold;" target="_blank" title="Click to know more about MENTIONED">MENTIONED</a> will <br/>work but not needed now. If OP request the adjustments we will do it.<br/><br/><br/><br/><br/> Quote from: Fields on August 31, 2010, 07:39:01 PM<blockquote>The original code did not fail. There is a longer name for the new file. <br/></blockquote> yes it does. Like your example rxc4.txt, you now have "nooutput rxc45678 is here" as the new file name. It should be "45678.txt" as the new file name. Here's a suggestion :<br/><br/> Code: <a>[Select]</a>for .... ( txtfile ) do (<br/> rem set delim to whitspaces.<br/> rem go through all the tokens, look for "RXC", <br/> rem once found, get the substring from 4th character onwards. <br/> rem create the new file.<br/>)<br/> Quote from: ghostdog74 on August 31, 2010, 08:03:00 PM<blockquote>yes it does. Like your example rxc4.txt, you now have \"nooutput rxc45678 is here\" as the new file name. It should be \"45678.txt\" as the new file name. Here\'s a suggestion :<br/><br/> Code: <a>[Select]</a>for .... ( txtfile ) do (<br/> rem set delim to whitspaces.<br/> rem go through all the tokens, look for \"RXC\", <br/> rem once found, get the substring from 4th character onwards. <br/> rem create the new file.<br/>)<br/></blockquote> <br/>Yes that will work but I will not look at all the tokens until the OP asks for it.<br/><br/>The long file name is ok with me.<br/> <br/>Many <a href="https://interviewquestions.tuteehub.com/tag/ops-1137414" style="font-weight:bold;" target="_blank" title="Click to know more about OPS">OPS</a> ask a question and never return.<br/><br/>By the way, I dont know enough VBS to get your VBS code to run. I have not spent much time with your VBS. Wll try later. Quote from: Fields on August 31, 2010, 08:52:57 PM<blockquote>The long file name is ok with me.<br/></blockquote> its not ok as OP's required specs. He wants to find the RXC number following RXC. (without other alphabets/words)<br/> <br/> Quote<blockquote>By the way, I dont know enough VBS to get your VBS code to run. I have not spent much time with your VBS. Wll try later.<br/></blockquote> you don't have to know much to learn how to run a vbscript. <br/> Code: <a>[Select]</a>cscript //nologo myscript.vbs<br/> Quote from: ghostdog74 on August 31, 2010, 05:57:20 PM<blockquote> Code: <a>[Select]</a>Set objFS = CreateObject(\"Scripting.FileSystemObject\")<br/> <br/> </blockquote> <br/>I was able to run your vbs file. The output did not come to the screen but the vbs did change the names of the original file names. <br/>The original file rxc4.txt with text [ nooutput rxc45678 is here]<br/>was changed to utput.txt and not to 45678.txt. This is clearly a flaw with the vbs solution<br/>The ops specs were not followed. Please correct<br/><br/><br/>C:\\test>type ghost831.vbs<br/>Set objFS = CreateObject(\"Scripting.FileSystemObject\")<br/>strFolder=\"c:\\test\"<br/>Set objFolder = objFS.GetFolder(strFolder)<br/>For Each strFile In objFolder.Files<br/> If objFS.GetExtensionName(strFile) = \"txt\" Then<br/> strFileName = strFile.Name<br/> Set objFile = objFS.OpenTextFile(strFileName)<br/> Do Until objFile.AtEndOfStream<br/> strLine=objFile.ReadLine<br/> If InStr(strLine,\"rxc\" ) > 0 Then<br/> number=Mid(strLine,4,5) \'Get 5 characters afterwards<br/> objFile.Close<br/> strFile.Name = Trim(number)&\".txt\"<br/> Exit Do<br/> End If<br/> Loop<br/> End If<br/>Next<br/><br/>Input:<br/><br/>C:test>findstr rxc *.txt<br/><br/>rxc1.txt:rxc12345<br/>rxc2.txt:rxc23456<br/>rxc3.txt:rxc34567<br/>rxc4.txt:nooutput rxc45678 is here<br/><br/>Output:<br/><br/>C:\\test>dir * | sort<br/><br/>09/01/2010 04:55 AM 11 12345.txt<br/>09/01/2010 04:55 AM 11 23456.txt<br/>09/01/2010 04:55 AM 11 34567.txt<br/>09/01/2010 04:55 AM 29 utput.txt<br/>09/01/2010 04:55 AM 101 1.txt.txt<br/><br/>C:test>type 12345.txt<br/>rxc12345<br/><br/>C:test>type utput.txt<br/>nooutput rxc45678 is here<br/><br/>C:test>type 1.txt.txt<br/><br/>rxc1.txt:rxc12345<br/>rxc2.txt:rxc23456<br/>rxc3.txt:rxc34567<br/>rxc4.txt:nooutput rxc45678 is here<br/>that's easy to change. So now, are you going to change your batch script to do the same?<br/> Code: <a>[Select]</a>Set objFS = CreateObject("Scripting.FileSystemObject")<br/>strFolder="c:\test"<br/>Set objFolder = objFS.GetFolder(strFolder)<br/>For Each strFile In objFolder.Files<br/> If objFS.GetExtensionName(strFile) = "txt" Then <br/> strFileName = strFile.Name<br/> Set objFile = objFS.OpenTextFile(strFileName)<br/> Do Until objFile.AtEndOfStream <br/> strLine=objFile.ReadLine<br/> m=InStr(strLine,"RXC" ) <br/> If m > 0 Then<br/> number=Mid(strLine,m+3,5) <br/> WScript.Echo number<br/> objFile.Close<br/> strFile.Name = Trim(number)&".txt" <br/> Exit Do <br/> End If <br/> Loop <br/> End If <br/>Next <br/> Quote from: ghostdog74 on September 01, 2010, 04:59:10 AM<blockquote>Thats easy to change. <br/></blockquote> <br/>Same error as before: 45678.txt is not created. utput.txt is created from the input file rxc4.txt with the<br/>line [ nooutput rxc45678 is here ] inside of the rxc4.txt file.<br/><br/>The fix for the ghost.vbs did not work.<br/><br/>C:test>Display ghost901.vbs<br/>Set objFS = CreateObject(Scripting.FileSystemObject)<br/>strFolder=c:test<br/>Set objFolder = objFS.GetFolder(strFolder)<br/>For Each strFile In objFolder.Files<br/> If objFS.GetExtensionName(strFile) = txt Then<br/> strFileName = strFile.Name<br/> Set objFile = objFS.OpenTextFile(strFileName)<br/> Do Until objFile.AtEndOfStream<br/> strLine=objFile.ReadLine<br/> If InStr(strLine,rxc ) > 0 Then<br/> number=Mid(strLine,4,5) Get 5 characters afterwards<br/> objFile.Close<br/> strFile.Name = Trim(number)&.txt<br/> Exit Do<br/> End If<br/> Loop<br/> End If<br/>Next<br/><br/><br/>C:test>cscript //nologo ghost901.vbs<br/><br/>Output:<br/><br/>09/01/2010 08:15 AM 11 12345.txt<br/>09/01/2010 08:15 AM 11 23456.txt<br/>09/01/2010 08:15 AM 11 34567.txt<br/>09/01/2010 08:15 AM 29 utput.txt<br/>09/01/2010 08:15 AM 101 1.txt.txt<br/><br/>C:test>type 12345.txt<br/>rxc12345<br/><br/>C:test>type utput.txt<br/>nooutput rxc45678 is here<br/><br/><br/>C:test>type 1.txt.txt<br/><br/>rxc1.txt:rxc12345<br/>rxc2.txt:rxc23456<br/>rxc3.txt:rxc34567<br/>rxc4.txt:nooutput rxc45678 is here</body></html> | |
250. |
Solve : Bug...? |
Answer» <html><body><p>In some batch files, when I click on them, it open and close automatically and I don't have time to do anything... <br/><strong>WHY?</strong>create this batch file<br/><br/> Code: <a>[<a href="https://interviewquestions.tuteehub.com/tag/select-630282" style="font-weight:bold;" target="_blank" title="Click to know more about SELECT">SELECT</a>]</a>cmd /k %1<br/>then drag the non working batch file it will tell you the errorThis is not a "bug". It is normal. If you start a batch script by double clicking its icon in Windows Explorer it will start in a command window which will vanish when the script terminates. It might be a natural ending or a premature one if there is an <a href="https://interviewquestions.tuteehub.com/tag/error-25548" style="font-weight:bold;" target="_blank" title="Click to know more about ERROR">ERROR</a> in the code. To see error messages etc you <a href="https://interviewquestions.tuteehub.com/tag/need-25476" style="font-weight:bold;" target="_blank" title="Click to know more about NEED">NEED</a> to start the batch file from the prompt by typing its name.<br/>But how to run the batch file <a href="https://interviewquestions.tuteehub.com/tag/aeuroewithout-1475023" style="font-weight:bold;" target="_blank" title="Click to know more about WITHOUT">WITHOUT</a> this "bug" (call 'd the way you want) Quote from: HP2 on September 06, 2010, 12:32:16 PM</p><blockquote>But how to run the batch file without this "bug" (call 'd the way you want)<br/></blockquote> <br/>It isn't a bug, Bill, as you well know. Furthermore, the answer is in my post above, which you should read more attentively. You probably know this too. Did Big get banned?<br/><br/><br/></body></html> | |