

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.
151. |
Solve : auto answer yes for uninstallation of winzip? |
Answer» <html><body><p>Hi... i am looking for a way to automate the step of click the yes button when doing the uninstallation of winzip or any program.. thanks. <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: bh on <a href="https://interviewquestions.tuteehub.com/tag/july-244157" style="font-weight:bold;" target="_blank" title="Click to know more about JULY">JULY</a> 01, 2010, 10:42:19 PM</p><blockquote>Hi... i am looking for a way to automate the step of click the yes button when doing the uninstallation of winzip or any program.. thanks.<br/></blockquote> <br/>Sometimes an echo yes and pipe to the uninstall program will work.<br/><br/>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>>echo YES | uninstall<br/><br/>or <br/><br/>C:\test>echo Y | uninstall</body></html> | |
152. |
Solve : Microsoft VBScript runtime error while running it from batch exe file? |
Answer» <html><body><p>I have <a href="https://interviewquestions.tuteehub.com/tag/created-938398" style="font-weight:bold;" target="_blank" title="Click to know more about CREATED">CREATED</a> a batch script .<a href="https://interviewquestions.tuteehub.com/tag/exe-447113" style="font-weight:bold;" target="_blank" title="Click to know more about EXE">EXE</a> file, <br/>in which i am calling below ProcessStartTime.vbs file to capture the start date & time of EXCEL.EXE process,<br/>----<br/>call ProcessStartTime.vbs<br/>----<br/>and i have scheduled that batch script .exe file in the scheduled task,<br/>but while running the .exe file below error message gets popped-up on the screen,<br/>Please help to <a href="https://interviewquestions.tuteehub.com/tag/resolve-622670" style="font-weight:bold;" target="_blank" title="Click to know more about RESOLVE">RESOLVE</a> the same,<br/><br/><strong>error as :- Windows Script host<br/>script: c:\aeclm\ProcessStartTime.vbs<br/>Line: 7<br/>Char: 1<br/>Error: Permission Denied<br/>code: 800A0046<br/>Source:Microsoft VBScript runtime error</strong><br/><br/>----------ProcessStartTime.vbs code-------------------<br/>Const ForReading = 1<br/>Const ForWriting = 2<br/>Const ForAppending = 8<br/><br/>Set objFSO = CreateObject("Scripting.FileSystemObject")<br/><br/>Set objLogFile = objFSO.OpenTextFile("C:\aeclm\Process_list.txt", _ <br/> ForWriting, True)<br/><br/>'objLogFile.Write _<br/>' ("Process Name,Start Time,Process ID") <br/><br/>'objLogFile.Writeline<br/><br/>strComputer = "."<br/><br/>Set objWMIService = GetObject("winmgmts:" _<br/> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")<br/><br/><br/>Set colProcessStartTrace = objWmiService.ExecQuery _<br/> ("<a href="https://interviewquestions.tuteehub.com/tag/select-630282" style="font-weight:bold;" target="_blank" title="Click to know more about SELECT">SELECT</a> * From Win32_Process")<br/><br/><br/>For Each objProcess in colProcessStartTrace<br/> <br/> if(objProcess.Name = "EXCEL.EXE")then<br/> objLogFile.Write(objProcess.Name) & "," <br/> objLogFile.Write(objProcess.CreationDate) & ","<br/> objLogFile.Write(objProcess.ProcessId)<br/> objLogFile.writeline<br/> end if<br/>Next<br/> <br/><br/>objLogFile.Close<br/>--------------------------------------------You don't have write permission in C:\aeclm. 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 obtain this.<br/><br/><br/></p></body></html> | |
153. |
Solve : MS DOS booted from Hard drive does not execute any .exe file even from outside? |
Answer» <html><body><p>I am a 68-years old Neurosurgeon - a die-hard-fan-*censored*-avid-user(for over <a href="https://interviewquestions.tuteehub.com/tag/three-708969" style="font-weight:bold;" target="_blank" title="Click to know more about THREE">THREE</a> decades) of MS DOS 6.22 with QBasic1.0, Foxpro for DOS 2.5 <br/><br/>a and Wordstar 4.0 for all my work - taking at the end of every day a zipped back up of all transaction files of the day into a single 1.44 <br/><br/>MB FDD and back them upto my other PCs via FDD / USB Pen drive / Network etc., I use Windows only for surfing - telemedicine etc.,<br/><br/>Recently my 10 year old mobo started acting funny - weird messages about FDD, Keyboard not present etc., After sending the old mobo to <br/><br/>service, I shifted the MS DOS ec., Hard disk to another mobo - removing a pre-existing XP Hard disk leaving the old MS DOS as the only HDD.<br/><br/>MS DOS booted <a href="https://interviewquestions.tuteehub.com/tag/fine-248571" style="font-weight:bold;" target="_blank" title="Click to know more about FINE">FINE</a> from the old HDD and did all internal commands like dir, type, copy etc but hung up on all .exe files - sacndisk, <br/><br/>qbasic, fox, foxpro, ws etc.,<br/><br/>I then booted from a DOS Boot Floppy and now all .exe files worked fine, except the inevitable time-lag of the processor looking up <br/><br/>command.com in the slower FDD each time I gave a command fom the command line or via MS DOS Batch files.<br/><br/>I then used sys.com in the FDD to transfer the system to the C:\ drive. Now command.com in the FDD and the C:\ on the HDD had the same size <br/><br/>and date stamp. Yet when I rebooted fom the hard drive - cold and hot, the .exe files did not work and the system hung!<br/><br/>Can anybody help Plsss!<br/><br/>Googol Thanx in advance!!<br/><br/>Have you still got the MS-DOS floppies? Did you do SYS C: ? What does your CONFIG.SYS contain? what is contained in %comspec%?<br/><br/>see here<br/><br/><a href="http://2dos.homepage.dk/batutil/help/COMM_E.HTM">http://2dos.homepage.dk/batutil/help/COMM_E.HTM</a><br/><br/><br/><br/><br/><br/>__How much RAM does your HP PC have,where I understand you installed and are running the old MS-DOS HDD? <br/>__what is the CPU type?<br/>__Do you have any type of lock/restriction on the HDD, as some HP PC's have set in the BIOS?<br/>__To use old DOS programs &<a href="https://interviewquestions.tuteehub.com/tag/amp-363144" style="font-weight:bold;" target="_blank" title="Click to know more about AMP">AMP</a>; files you <a href="https://interviewquestions.tuteehub.com/tag/probably-1167177" style="font-weight:bold;" target="_blank" title="Click to know more about PROBABLY">PROBABLY</a> need to manage upper memory like Salmon Trout hinted at, with smartdrv & <a href="https://interviewquestions.tuteehub.com/tag/emm386" style="font-weight:bold;" target="_blank" title="Click to know more about EMM386">EMM386</a> etc.</p></body></html> | |
154. |
Solve : Wage batch file, help?? |
Answer» <html><body><p>echo off<br/>cls<br/>:hourly<br/>Set hourly=<br/>set /p hourly=Hourly wage:<br/>Set hours=<br/>set /p hours=Hours:<br/>Set days=<br/>set /p days=Days:<br/>echo Weekly should be 4.5<br/>Set weekly=<br/>set /p weekly=weeks:<br/>Set year=<br/>set year= Months worked:<br/>echo daily amount:<br/>set /a %hourly%*%hours%<br/>echo weekly amount: <br/>set /a %hourly%*%hours%*%days%<br/>echo monthly amount:<br/>set /a %hourly%*%hours%*%days%*%weekly%<br/>echo <a href="https://interviewquestions.tuteehub.com/tag/yearly-1464796" style="font-weight:bold;" target="_blank" title="Click to know more about YEARLY">YEARLY</a> amount:<br/>set /a %hourly%*%hours%*%days%*%weekly%*%year%<br/>pause<br/><br/>I'm being returned that the operators are missing. If anyone has documentation I can look at to fix this, would appreciate it.remove your echo off and run it again. You will spot your mistake easily Quote from: ghostdog74 on <a href="https://interviewquestions.tuteehub.com/tag/april-380813" style="font-weight:bold;" target="_blank" title="Click to know more about APRIL">APRIL</a> <a href="https://interviewquestions.tuteehub.com/tag/15-237501" style="font-weight:bold;" target="_blank" title="Click to know more about 15">15</a>, 2010, 05:52:27 PM</p><blockquote>remove your echo off and run it again. You will spot your mistake easily<br/></blockquote> AHEM, you didn't set a variable name with the set /a commands. Quote from: Helpmeh on April 15, 2010, 08:23:42 PM<blockquote>AHEM, you didn't set a variable name with the set /a commands. <br/></blockquote> are you <a href="https://interviewquestions.tuteehub.com/tag/replying-7280258" style="font-weight:bold;" target="_blank" title="Click to know more about REPLYING">REPLYING</a> to me or the OP ? Quote<blockquote>If you use any of the logical or modulus operators, you will need to<br/>enclose the expression string in quotes. Any non-numeric strings in the<br/>expression are treated as environment variable names whose values are<br/>converted to numbers before using them. If an environment variable name<br/>is specified but is not defined in the current environment, then a value<br/>of zero is used. This allows you to do arithmetic with environment<br/>variable values without having to type all those % signs to get their<br/>values. If SET /A is executed from the command line outside of a<br/>command script, then it displays the final value of the expression. The<br/>assignment operator requires an environment variable name to the left of<br/>the assignment operator. Numeric values are decimal numbers...<br/> </blockquote> Also, the % is used as an operator. So use of the % when using SET /A will generate 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> if there is no operand to go with it. <br/><br/>Or to put it simply, take out those % things unless you really want them.<br/><br/> Quote from: ghostdog74 on April 15, 2010, 09:05:09 PM<blockquote>are you replying to me or the OP ?<br/></blockquote> OP. Quote from: ghostdog74 on April 15, 2010, 05:52:27 PM<blockquote>remove your echo off and run it again. You will spot your mistake easily<br/></blockquote> <br/>was fixed here, sorry lost the url for the post. thank you everyone =]</body></html> | |
155. |
Solve : need to replace strings from file? |
Answer» <html><body><p>Hi<br/><br/>1. 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 replace blank space and . from text file to _ <br/>2. Also I need to be replace the string from a file to another string for <a href="https://interviewquestions.tuteehub.com/tag/eg-445433" style="font-weight:bold;" target="_blank" title="Click to know more about EG">EG</a> (computer replace to hope)<br/>3. There are 3 strings in a text file sepereted with , need to display the same on the command prompt<br/><br/><br/>thanksdownload <a href="http://gnuwin32.sourceforge.net/packages/<klux>SED</klux>.htm">sed for windows</a>, <br/><br/> Quote from: tinkuy on July 12, 2010, 03:25:32 AM</p><blockquote>Hi<br/><br/>1. I need to replace blank space and . from text file to _ <br/></blockquote> Code: <a>[Select]</a>c:\> sed "s/[ \t.]/_/g" textfile<br/><br/> Quote<blockquote>2. Also I need to be replace the string from a file to another string for eg (computer replace to hope)<br/></blockquote> Code: <a>[Select]</a>c:\> sed "s/computer/hope/g" textfile<br/> Quote<blockquote>3. There are 3 strings in a text file sepereted with , need to display the same on the command prompt<br/></blockquote> Show samples of your text file next time, and explain clearly what your final output is.<br/><br/>Thanks but I would appreciate if it can be done using <a href="https://interviewquestions.tuteehub.com/tag/dos-432778" style="font-weight:bold;" target="_blank" title="Click to know more about DOS">DOS</a> command.<br/><br/>pls helpThis question has been asked and answered many times on the forum. You may have overlooked searching the forum before posting your question.<br/><br/>Also if you run <strong>set /?</strong> from the command prompt, the online <a href="https://interviewquestions.tuteehub.com/tag/help-239643" style="font-weight:bold;" target="_blank" title="Click to know more about HELP">HELP</a> should be of immense help.<br/><br/>Showing some initiative trumps waiting for a response every time. <br/><br/></body></html> | |
156. |
Solve : Renaming a file with yesterday's date.? |
Answer» <html><body><p>Hi folks, I need a little bit of help. I have a file that I need to rename with <a href="https://interviewquestions.tuteehub.com/tag/yesterdays-3298687" style="font-weight:bold;" target="_blank" title="Click to know more about YESTERDAYS">YESTERDAYS</a> date in the filename. I will be running this script on a Windows Server 2008 machine.<br/><br/>Currently I've <a href="https://interviewquestions.tuteehub.com/tag/got-23540" style="font-weight:bold;" target="_blank" title="Click to know more about GOT">GOT</a> this:<br/><br/>::echo off<br/>for /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set month=%%a& set day=%%b& set year=%%c& set blank=%%d)<br/><br/>ren "timeclock.csv" "%month%%day%%year% timeclock.csv"<br/>set date=<br/>pause<br/><br/>I suspect I am close, but could use a little help getting over the finish line. It has been years since I've written a batch file, so please take it easy on me, I'm re-new at this. <br/><em>This is a limited comment.</em><br/><br/>What you are asking appears to be a breach of security. It may not be possible due that on the server without extensive exceptions made to the security system. So for that reason you may not get much help on this forum because he uses here are very sensitive about things that would lead to serious security breaches. <br/><br/>What you are attempting to do could be the basis for a very serious fraud and use of the system. I don't mean to accuse yum of wrongdoing, but if we were to publish an answer here in this forum it would be seen by a lot of people who would quickly realize such a <a href="https://interviewquestions.tuteehub.com/tag/trick-1427567" style="font-weight:bold;" target="_blank" title="Click to know more about TRICK">TRICK</a> could be used for evil purposes.<br/><br/>Could you explain why such a procedure would be necessary? Perhaps someone here can offer a practical workaround to your problem.<br/>We have a time clock that gets polled every night after the last shift quits (1:30am). The punch information is stored in a .CSV file which we then add a date to the file name. Idealy this date would be yesterday's date, since this is when the punches start coming in.<br/><br/>I'm not entirely sure how this could be used for evil, but then my evil skills are sadly lacking.<br/><br/>Edit: We previously did this with 3rd party software, but we upgraded our server and this software no longer works, and I'm loath to shell out another $250 for a network capable version when I'm sure this can be done with a script.Can be done with vbscript. Not knowing your local date format, the date string may (probably does) contain slashes, which are not allowed in filenames, so must be replaced, in this <a href="https://interviewquestions.tuteehub.com/tag/example-239971" style="font-weight:bold;" target="_blank" title="Click to know more about EXAMPLE">EXAMPLE</a> with dashes. Remove echo when happy. Your local date format may differ from mine, which is dd/mm/yyyy, so test first. I know in N America you may get the day of the week (e.g. Wed)<br/><br/> Code: <a>[Select]</a>echo off<br/>>temp$$$.vbs echo Wscript.echo eval(WScript.Arguments(<a href="https://interviewquestions.tuteehub.com/tag/0-242464" style="font-weight:bold;" target="_blank" title="Click to know more about 0">0</a>))<br/>For /f "delims=" %%Y in ( 'cscript //nologo temp$$$.vbs "date-1" ' ) do set yesterdate=%%Y<br/>set yesterdate=%yesterdate:/=-%<br/>echo ren "timeclock.csv" "%yesterdate% timeclock.csv"<br/>Thanks Salmon Trout, that nearly did it, but it isn't actually renaming the file. The last command that runs looks like this:<br/> Quote</p><blockquote>C:\batch files>echo ren "timeclock.csv" "7-11-10 timeclock.csv"<br/>ren "timeclock.csv" "7-11-10 timeclock.csv"</blockquote> <br/>Any thoughts?See my post.<br/><br/> Quote<blockquote>Remove echo when happy.</blockquote> <br/>That is, the batch script, as posted, just shows (echos) the command on screen and does not make any changes to files. When you have run it and you are happy with what you see, change "echo ren" to "ren" and save the script. <br/><br/>You do realise that commenting out echo off like this --<br/><br/>::echo off<br/><br/>-- means that every line is shown on the screen? And that you don't have to have this if you don't need it?<br/><br/><br/>Ah there we go, thanks very much. I totally gapped and missed the echo in front of the ren statement, that is all.<br/><br/>Yeah I know that commenting out the echo shows everything, I was going to remove that once everything was working correctly.<br/><br/>Thanks again, you have no idea how much headache you've saved me.</body></html> | |
157. |
Solve : Identify file date? |
Answer» <html><body><p>Assume the following: location-1 creates a database update file and creates a zip file. Location-2 receives the zip file and will download it only if they do not already have that file. I would like to modify the download batch file to at least identify the date/time of the file and display in on screen with a <a href="https://interviewquestions.tuteehub.com/tag/message-25597" style="font-weight:bold;" target="_blank" title="Click to know more about MESSAGE">MESSAGE</a> that says 'this file was created on ____ at ____. If you have this update already, press <a href="https://interviewquestions.tuteehub.com/tag/esc-446582" style="font-weight:bold;" target="_blank" title="Click to know more about ESC">ESC</a> to abort.<br/><br/>So, my question is how to have the batch file look at the zip file, get the date/time, and display it on screen.<br/><br/>Later on we may want to automate this by having the batch file check the zip file against what is already on location-2 computer and abort or download - but for for now, I'm just interested in <a href="https://interviewquestions.tuteehub.com/tag/displaying-2059353" style="font-weight:bold;" target="_blank" title="Click to know more about DISPLAYING">DISPLAYING</a> the date/time.<br/>thanks,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>>type doni.bat<br/>echo off<br/><br/>dir /tc %1 | <a href="https://interviewquestions.tuteehub.com/tag/findstr" style="font-weight:bold;" target="_blank" title="Click to know more about FINDSTR">FINDSTR</a> %1<br/><br/>Output:<br/><br/>C:\test>doni.bat zee.bat<br/>05/30/2010 06:52 PM 87 zee.bat<br/><br/>C:\test></p></body></html> | |
158. |
Solve : auto increment for filename and file content? |
Answer» <html><body><p>how to append a new line into texts?<br/>i got full of codes at file1.txt<br/>test <a href="https://interviewquestions.tuteehub.com/tag/abcdefg-361051" style="font-weight:bold;" target="_blank" title="Click to know more about ABCDEFG">ABCDEFG</a> a1<br/>nmjkloi<br/>ddkkkoll<br/><br/>and i want to auto generate 1000 <a href="https://interviewquestions.tuteehub.com/tag/files-20889" style="font-weight:bold;" target="_blank" title="Click to know more about FILES">FILES</a>, the file name <a href="https://interviewquestions.tuteehub.com/tag/increase-238127" style="font-weight:bold;" target="_blank" title="Click to know more about INCREASE">INCREASE</a> by +1 and the number after a (a1) also increase by +1<br/>so i have<br/>file2.txt (a2)<br/>file3.txt (a3)<br/>....file1000.txt (a1000)<br/><br/><br/><a href="https://interviewquestions.tuteehub.com/tag/c-3540" style="font-weight:bold;" target="_blank" title="Click to know more about C">C</a>:\test>type only.bat<br/><br/> echo off<br/><br/>rem echo nmjkloi >> file1.txt<br/><br/><br/><br/>for /L %%i in (1,1,1000) do (<br/>echo %%i<br/>set ck=%%i<br/>echo hello >> file%%ia%%i.txt<br/><br/>rem if %ck%==10 goto :end<br/><br/>)<br/>:end<br/>type file*.txt<br/>rem echo nmjkloi >> file1.txt<br/><br/><br/>rem <a href="/cdn-cgi/l/email-protection">[email protected]</a><br/>C:\test>Cool new name, Bill.<br/></p></body></html> | |
159. |
Solve : Start was unexpected at this time? |
Answer» <html><body><p>Hey I was making a smiple script to install some stuff, but I <a href="https://interviewquestions.tuteehub.com/tag/got-23540" style="font-weight:bold;" target="_blank" title="Click to know more about GOT">GOT</a> the error<br/>"Start was unexpected at this time"<br/>here is the full code<br/><br/> Code: <a>[Select]</a>echo off<br/>cls<br/><br/>:start<br/>echo Je moet nooit opnieuwopstarten op het einde doet dit script het voor u!<br/>echo .......................................................................<br/>echo Mount Batllefield <a href="https://interviewquestions.tuteehub.com/tag/2-236987" style="font-weight:bold;" target="_blank" title="Click to know more about 2">2</a>.iso en installeer het.<br/>echo ..........................................<br/>echo Druk op <a href="https://interviewquestions.tuteehub.com/tag/enter-446119" style="font-weight:bold;" target="_blank" title="Click to know more about ENTER">ENTER</a> als het geinstaleerd is.<br/>echo ......................................<br/>pause<br/>goto Patch<br/><br/>:Patch<br/>(%time%) Start installatie patch.<br/>start /wait BF2_Patch_1.41.exe<br/>(%time%) Patch geinstaleerd.<br/>goto Choise<br/><br/>:Choise<br/>Choice /m "64-bit computer"<br/>If Errorlevel 2 Goto No<br/>If Errorlevel <a href="https://interviewquestions.tuteehub.com/tag/1-236780" style="font-weight:bold;" target="_blank" title="Click to know more about 1">1</a> Goto Yes<br/>Goto vervolg<br/>:No<br/>(%time%) Copieren files.<br/>copy BF2.exe "C:\Program Files\EA GAMES\BF2.exe"<br/>copy rzr-b241.nfo "C:\Program Files\EA GAMES\rzr-b241.nfo"<br/>copy CoreDLL.dll "C:\Program Files\EA GAMES\CoreDLL.dll"<br/>(%time%) Copieren files gedaan.<br/>Goto vervolg<br/><br/>:Yes<br/>copy BF2.exe "C:\Program Files (x86)\EA GAMES\BF2.exe"<br/>copy rzr-b241.nfo "C:\Program Files (x86)\EA GAMES\rzr-b241.nfo"<br/>copy CoreDLL.dll "C:\Program Files (x86)\EA GAMES\CoreDLL.dll"<br/>goto vervolg<br/><br/>:vervolg<br/>(%time%) Start installatie mappacken.<br/>start /wait ultimate-pack3.exe<br/>start /wait x-07 mappack.exe<br/>(%time%) Installatie mappacken gedaan.<br/>goto shutdown<br/><br/>:shutdown<br/>echo (%time%) Shutdown<br/>echo Je PC word heropgestart binnen 30 sec.<br/>pause<br/>shutdown -r -t 30<br/>endOw, found it forogt echo <br/>SrryVery good that you figured out your own solution! I had an issue once where the program was not echo-ing a line to a file...I just forgot a percent sign after the variable.Yeay, it's <a href="https://interviewquestions.tuteehub.com/tag/sometimes-648384" style="font-weight:bold;" target="_blank" title="Click to know more about SOMETIMES">SOMETIMES</a> the smallest things that let your script crash I hate that</p></body></html> | |
160. |
Solve : Time management? |
Answer» <html><body><p>Hi Folks.<br/><br/>I have small timer.<br/>Need to enter a break adherance system.<br/>I can simply count the time I started the program.<br/>While running the file. In between I want to enter something like break.<br/>So, that timer should continue to count. But, Let me also how much minute or hour I been on break. And when I come from break I can continue with normal work.<br/><br/>Here is the code<br/><br/><br/>echo off<br/>set sec=1<br/>set min=0<br/>set hour=0<br/>color 70<br/>:1<br/>title %hour% : %min% : %sec% Vishal timer<br/>set /a sec=%sec%+1<br/>Echo %hour% : %min% : %sec% Vishal timer<br/>ping -n 1 -w 900 1.1.1.1 <br/>cls<br/>if %sec% <a href="https://interviewquestions.tuteehub.com/tag/equ-446399" style="font-weight:bold;" target="_blank" title="Click to know more about EQU">EQU</a> 60 set /a sec=0 & set /a min=%min%+1<br/>if %min% equ 60 set /a min=0 & set /a hour=%hour%+1<br/>goto :1<br/><br/><br/>I want something that can record my break in between of this timer without <a href="https://interviewquestions.tuteehub.com/tag/stopping-774103" style="font-weight:bold;" target="_blank" title="Click to know more about STOPPING">STOPPING</a> the timer in any point.<br/><br/><br/>Thanks and regards<br/>Vishu open cmd<br/>type Code: <a>[Select]</a>ver and <a href="https://interviewquestions.tuteehub.com/tag/tell-1240910" style="font-weight:bold;" target="_blank" title="Click to know more about TELL">TELL</a> me result<br/>type Code: <a>[Select]</a>echo %time% and tell me resultMicrosoft Windows XP [version 5.1.2600]<br/><br/>1:16:49.27if it doesn't need to run past midnight this works<br/> Code: <a>[Select]</a>echo off<br/>set /a x3=%x%<br/>set /a HH=0<br/>set /a MM=0<br/>set /a SS=0<br/>set /a HM=0<br/>set /a MS=0<br/>set /a HS=0<br/>set /a SA=0<br/>set HH1=%TIME:~0,2%<br/>set MM1=%TIME:~3,2%<br/>set SS1=%TIME:~6,2%<br/>rem time consuming task here<br/>set SS2=%TIME:~6,2%<br/>set HH2=%TIME:~0,2%<br/>set MM2=%TIME:~3,2%<br/>set /a HH=%HH2%-%HH1%<br/>set /a MM=%MM2%-%MM1%<br/>set /a SS=%SS2%-%SS1%<br/>if %HH%==0 goto alt<br/>if %MM%==0 goto alt1<br/>set /a HM=%HH%*60<br/>set /a MS=%MM%*60<br/>set /a HS=%HM%*60<br/>set /a SA=%HS%+%MS%+%SS%<br/>echo it took %SA% seconds<br/>goto C<br/><br/>:alt<br/>if %MM%==0 goto alt1<br/>set /a MS=%MM%*60<br/>set /a SA=%MS%+%SS%<br/>echo it took %SA% seconds<br/>goto C<br/><br/>:alt1<br/>set /a SA=%SS%<br/>echo it took %SA% seconds<br/><br/>:C<br/>pause<br/>exit<br/>don't add the <br/>set /a x3=%x%<br/>line cut and paste error <a href="https://interviewquestions.tuteehub.com/tag/sorry-648642" style="font-weight:bold;" target="_blank" title="Click to know more about SORRY">SORRY</a>.how about the time sheets? have you used it before..<br/><br/><a href="http://www.labortimetracker.com/"> Staff Time Management </a> <br/> <br/><br/>This is out of the figure.<br/>Actually this is not the thing that I was asking.<br/><br/>I want something to check the break time while running the counter.<br/>I want to input a word B that will start to count break.<br/>when I return from break press S and it will save the time spent on break.<br/>Counter still be continued. Will give me total time i logged in. I mean from the time I ran the file. Code: <a>[Select]</a>echo off<br/>:77<br/>choice /c:B /N<br/>set /a HH=0<br/>set /a MM=0<br/>set /a SS=0<br/>set /a HM=0<br/>set /a MS=0<br/>set /a HS=0<br/>set /a SA=0<br/>set HH1=%TIME:~0,2%<br/>set MM1=%TIME:~3,2%<br/>set SS1=%TIME:~6,2%<br/>choice /c:S /N<br/>set SS2=%TIME:~6,2%<br/>set HH2=%TIME:~0,2%<br/>set MM2=%TIME:~3,2%<br/>for /l %%a in (1,1,9) do if %MM2%==0%%a set MM2=%%a<br/>for /l %%a in (1,1,9) do if %HH2%==0%%a set HH2=%%a<br/>for /l %%a in (1,1,9) do if %SS2%==0%%a set SS2=%%a<br/>for /l %%a in (1,1,9) do if %MM1%==0%%a set MM1=%%a<br/>for /l %%a in (1,1,9) do if %HH1%==0%%a set HH1=%%a<br/>for /l %%a in (1,1,9) do if %SS1%==0%%a set SS1=%%a<br/>set /a HH=%HH2%-%HH1%<br/>set /a MM=%MM2%-%MM1%<br/>set /a SS=%SS2%-%SS1%<br/>if %HH%==0 goto alt<br/>if %MM%==0 goto alt1<br/>set /a HM=%HH%*60<br/>set /a MS=%MM%*60<br/>set /a HS=%HM%*60<br/>set /a SA=%HS%+%MS%+%SS%<br/>goto C<br/><br/>:alt<br/>if %MM%==0 goto alt1<br/>set /a MS=%MM%*60<br/>set /a SA=%MS%+%SS%<br/>goto C<br/><br/>:alt1<br/>set /a SA=%SS%<br/>:C<br/>set h=0<br/>set m=0<br/>set s=0<br/>:B<br/>if %sa% lss 360 goto D<br/>set /A h=%h%+1<br/>set /A sa=%sa%-360<br/>goto b<br/>:D<br/>if %sa% lss 60 goto E<br/>set /A m=%m%+1<br/>set /A sa=%sa%-60<br/>goto D<br/>:E<br/>if %sa% lss 1 goto F<br/>set /A s=%s%+1<br/>set /A sa=%sa%-1<br/>goto E<br/>:F<br/>cls<br/>title %H% : %M% : %S%<br/>echo %H% : %M% : %S%<br/>pause > nul<br/>cls<br/>goto 77note needs choice download in zip<br/><br/>[recovering disk space - old attachment deleted by admin] <br/><br/>It's not working. Sorry you can check it yourself.is choice in windows\system32 folder</p></body></html> | |
161. |
Solve : files listed added to folder during last week? |
Answer» <html><body><p>Hi All<br/><br/>I have rather very difficult task to accomplish. Can you help me and prepare script as *.bat. That script should check folder (it will be network path) and list all files created within last week in that folder. Next to file name should be creation date. <br/>Script should list results on <a href="https://interviewquestions.tuteehub.com/tag/screen-25632" style="font-weight:bold;" target="_blank" title="Click to know more about SCREEN">SCREEN</a> and also create txt fog file each time script is running.<br/><br/>Is possible to create such script?<br/>Unfortunatelly my programming skills are not so big therefore if possible please advice in more details <br/><br/>Thank you in advance.<br/><br/>BR<br/>MichalWill this do ?<br/> Code: <a>[Select]</a>echo off<br/><br/>REM create the vb script<br/>>evaluate.<a href="https://interviewquestions.tuteehub.com/tag/vbs-3852369" style="font-weight:bold;" target="_blank" title="Click to know more about VBS">VBS</a> echo Wscript.echo eval(WScript.Arguments(0))<br/><br/>REM extract todays date less 7 days<br/>for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate = %%A<br/><br/>REM tidy<br/>del evaluate.vbs<br/><br/>REM break up the date into constituent parts<br/>REM Note - the date is parsing UK format dates,<br/>REM swap the MM and DD in the lines below<br/>REM for US format<br/><br/>set MM=%OldestDate:~3,2%<br/>set DD=%OldestDate:~0,2%<br/>set YYYY=%OldestDate:~6,4%<br/><br/>REM reconstruct US format with '-' separators<br/>set OldestDate=%MM%-%DD%-%YYYY%<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 echo %%A %%~tA<br/><br/>I assume you meant to say 'logfile each time the script runs' ... what would go in there ? the date and time the script ran ?Hi<br/><br/>Thank you for replay.<br/><br/>Basically what we need is script which we will add to scheduled tasks in windows.<br/>When script finish we should have results displayed on the screen (for example in cmd) and log file when script was run (date is enough but if is possible also time)<br/><br/><br/><br/>How should save that file as *.bat or *.vbs?<br/><br/>I do not need copy files, just list the newest from last week with creation date.<br/>My time zone is Europe (DK), maybe some part of the script has to be changed.<br/><br/>I am sorry if I am asking not to smart questions <br/>Thank you very much.<br/><br/>BR<br/>MichalHi Michal<br/>No, you are asking very good questions!<br/><br/>You would save it with a .bat extension, the small vbscript that is used is created by the batch, this is because date and time manipulation is simple in vbscript but nearly impossible in batch files<br/><br/>The XCopy is not actually copying anything - but listing the files that would be copied; the /L tells it not to copy anything<br/><br/>If you schedule this then you will not see any output, I suggest that the list of files is placed in the log also.<br/><br/>Denmark uses the correct date format so that you will not need to change the script<br/><br/>This is the latest version, you will need to change the drive and directory in line 2 to be the folder that you wish to <a href="https://interviewquestions.tuteehub.com/tag/monitor-563344" style="font-weight:bold;" target="_blank" title="Click to know more about MONITOR">MONITOR</a><br/>In Line 3, a variable is created to hold the location of your logfile, you will have to change this also to be the name and location of your log<br/> Code: <a>[Select]</a>echo off<br/>CD /d F:\FolderForFiles<br/>Set LogFile="d:\logs\NewFiles.Log"<br/><br/>REM create the vb script<br/>>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))<br/><br/>REM extract todays date less 7 days<br/>for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate = %%A<br/><br/>REM tidy<br/>del evaluate.vbs<br/><br/>REM break up the date into constituent parts<br/>REM Note - the date is parsing UK format dates,<br/>REM swap the MM and DD in the lines below<br/>REM for US format<br/><br/>set MM=%OldestDate:~3,2%<br/>set DD=%OldestDate:~0,2%<br/>set YYYY=%OldestDate:~6,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/>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 %%~fA %%~tA<br/><br/>goto :EOF<br/>One problem with this is that the last line of each log entry will say xxx File(s) Copied, with the path preceding itHi gpl<br/><br/>Thank you very much for your help. The script is working almost I just got information: "Invalid number of parameters"<br/><br/>I do not know why. only what I did was change folder location:<br/>echo off<br/>CD /d e:\pictures<br/>Set LogFile="e:\NewFiles.Log"<br/><br/>Can we have separate log for each day? then we can track changes for each day. It is complicated to explain why ( read -> bos) <br/><br/>Thank you very very much for help <br/><br/>BR<br/>MichalHi Michal<br/>It is hard to tell what the problem is, change the first line to Echo On and you will see how each command is made up after variables have been expanded<br/><br/>Yes you can have a new file every day, remember the section that creates a variable with the date of 1 week ago, we can do domething similar:<br/><br/> Code: <a>[Select]</a>echo off<br/>CD /d e:\pictures<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/>>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))<br/><br/>REM extract todays date less 7 days<br/>for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate = %%A<br/><br/>REM tidy<br/>del evaluate.vbs<br/><br/>REM break up the date into constituent parts<br/>REM Note - the date is parsing UK format dates,<br/>REM swap the MM and DD in the lines below<br/>REM for US format<br/><br/>set MM=%OldestDate:~3,2%<br/>set DD=%OldestDate:~0,2%<br/>set YYYY=%OldestDate:~6,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/>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 %%~fA %%~tA<br/><br/>goto :EOF<br/><br/><br/>I suspect the error about the invalid number of parameters is because you have a file or directory name somewhere with a space in it and the name is not enclosed by quotes - with echo on, it will be clear where.<br/><br/>GrahamHi gpl<br/><br/>I jsut make as suggested, here is error information:<br/>E:\Pictures>for /F "delims=" %A in (' xcopy /l /i /d:~3 2-~0 2-~6 4 *.* NonExist<br/>entDirectory ') do call :ProcessEach %A<br/>Invalid number of parameters<br/><br/>Do you know how to fix that?<br/><br/>BTW:<br/>error log: excellent job <br/><br/>Thank you in advance for help.<br/><br/>BR<br/>MichalIt is clear why the error comes up, the %oldestdate% variable no longer holds a date<br/><br/>you will note that the xcopy instruction looks like this before expansion<br/>xcopy /l /i /d:%OldestDate%<br/>but what you see expanded is<br/>xcopy /l /i /d:~3 2-~0 2-~6 4<br/><br/>I think you may have deleted a % or more in these lines<br/> Code: <a>[Select]</a>set MM=%OldestDate:~3,2%<br/>set DD=%OldestDate:~0,2%<br/>set YYYY=%OldestDate:~6,4%<br/><br/>REM reconstruct US format with '-' separators<br/>set OldestDate=%MM%-%DD%-%YYYY%<br/><br/>GrahamHi Graham<br/><br/>I just tried to add more, but I can't make it work.<br/><br/>Can you try how it works on your computer, and publish the code. I make some mistake (s) - my programming skills are not so great therefore I do not trust my self <br/><br/>maybe something to do is also about date, I <a href="https://interviewquestions.tuteehub.com/tag/noticed-2877256" style="font-weight:bold;" target="_blank" title="Click to know more about NOTICED">NOTICED</a> that log file has this date format:<br/>NewFiles_7-14-0--20.Log which is almost correct <br/><br/><br/>Thank you in advance.<br/><br/>BR<br/>MichalOK Michal<br/>The last change I did to make the logfile name hold todays date stopped it working.<br/><br/>In the version below, I have blanked the OldestDate, DD, MM and YYYY variables before they are reused and it is working again .... except the bit that shows the name and creation time didnt work either - that is now fixed.<br/><br/>Try this<br/> Code: <a>[Select]</a>echo off<br/>CD /d e:\pictures<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/>>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 evaluate.vbs "Date -7" ' ) do set OldestDate=%%A<br/><br/>REM tidy<br/>del evaluate.vbs<br/><br/>REM break up the date into constituent parts<br/>REM Note - the date is parsing UK format dates,<br/>REM swap the MM and DD in the lines below<br/>REM for US format<br/><br/>set MM=<br/>set DD=<br/>set YYYY=<br/><br/>set MM=%OldestDate:~3,2%<br/>set DD=%OldestDate:~0,2%<br/>set YYYY=%OldestDate:~6,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/>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/>Grahamhi Graham<br/><br/>It seems to be working now. No error <br/><br/>But )))<br/><br/>in the log message there is no new files listed only date like that (I think date when script was running - your correction):<br/><br/>2010-07-14 13:55:08,37 <br/>========================================<br/>2010-07-14 13:55:14,53 <br/>========================================<br/>2010-07-14 13:55:26,75 <br/>========================================<br/><br/><br/>I created few files today, but they are not listed. Any change to list them together with creation date?<br/><br/>Thank you very much for help.<br/><br/>I very much appreciate your fast help.<br/><br/>BR<br/>MichalI think I have it<br/>The entry in your log is <br/>2010-07-14 13:55:26,75 <br/>I think that this is the default way a date is shown on your computer; the section that calculates the date 7 days before is not quite right; I think that you should try this instead<br/> Code: <a>[Select]</a>echo off<br/>CD /d e:\pictures<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/>>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 evaluate.vbs "Date -7" ' ) do set OldestDate=%%A<br/><br/>REM tidy<br/>del 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/>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/>Ive added a line which inserts into the log<br/>Since : 'the value of OLDESTDATE'<br/>which is in US format<br/>Could you try it ?<br/>Thanks<br/>GrahamHi Graham<br/><br/>It seems to be working a lot better now. It is creating log with information like that:<br/><br/>2010-07-14 14:42:31,45<br/>Since : 07-07-2010<br/>E:\all <br/>E:\New<br/>E:\NewFiles_7-14-0--20.Log 2010-07-14 14:42<br/>E:\test.xml 2010-07-14 14:41<br/>E:\4 <br/>========================================<br/><br/><br/>the only small problem is that file names are not complet (I marked 2 names as blue as example).<br/><br/>2010-07-14 14:42:31,45<br/>Since : 07-07-2010<br/>E:\all Briefcase.bfc<br/>E:\New all files for last 7 days.bat<br/>E:\NewFiles_7-14-0--20.Log 2010-07-14 14:42<br/>E:\test.xml 2010-07-14 14:41<br/>E:\4 <br/>========================================<br/><br/><br/>The other is I do not have file 4, and I do not know from ´where it come from.<br/><br/>To easier read log is possible to have file file name few "spaces" and then date?<br/>example:<br/>E:\test.xml 2010-07-14 14:41<br/><br/>One more question, I tried to change path to network path as we are going to monitor network folders, but the script is constantly show <a href="https://interviewquestions.tuteehub.com/tag/report-25448" style="font-weight:bold;" target="_blank" title="Click to know more about REPORT">REPORT</a> for "old" my local path (that same result after deleting path). Do you know how to fix that?<br/><br/>In the future I will be monitoring few network folders, by simply copy/paste this code in that some file and change monitoring folder path (log will stay that some).<br/><br/>like this:<br/><br/>code<br/>----------------<br/><br/>echo off<br/>CD /d \\server\path1<br/><br/>REM grab todays date into variables<br/>.<br/>.<br/>.<br/>goto :EOF<br/><br/>CD /d \\server\path2<br/><br/>REM grab todays date into variables<br/>.<br/>.<br/>.<br/>goto :EOF<br/><br/><br/>BR<br/>MichalHi Michal<br/>The 4 is simply the number of files found (it should actually read 4 File(s) copied)<br/>the batch file which you highlighted is locked as it is executing, I expect that is why it does not show the timestamp, maybe that is why the 'all Briefcase.bfc' file does not show a date either<br/><br/>the line near the bottom is the one that writes the info to the log<br/> Code: <a>[Select]</a>>> %LogFile% echo %~f1 %~t1<br/>change to this<br/> Code: <a>[Select]</a>[code]>> %LogFile% echo %~f1 %~t1or even use tab characters instead of spaces<br/><br/>I am not very sure how to user the \\servername - batch files dont like it and try to change to a d: type drive<br/>You could try remapping the servers to drive e: and running the batch ?<br/><br/>Otherwise, perhaps one of the more experienced members here could jump in with the solution ?<br/><br/>Graham[/code]Hi Graham<br/><br/>Thank you for info with log it works fine.<br/><br/>I just checked. Whenever I use one of mounted diskson my computer like c: or e: then I can see the list.<br/>However when I use \\servername\network path it is not working.<br/>Conclusion is that application works on mapped disks but not on network.<br/><br/>Regarding 'all Briefcase.bfc' the name have space. That is the problem. With no space I can see all as expected <br/>Luckily that is not a problem because all files I have to monitor insted of space have "_".<br/><br/><br/>It is very important for me that application can work with network path as I am going to monitor many folders (probably I do not have enough letters to map all the disks <br/>Please help <br/><br/>Do you or anybody know how to fix that?<br/><br/>Thank you for any help.<br/><br/>BR<br/>Michal<br/><br/></p></body></html> | |
162. |
Solve : Hide ping? |
Answer» <html><body><p>I want to <a href="https://interviewquestions.tuteehub.com/tag/hide-767501" style="font-weight:bold;" target="_blank" title="Click to know more about HIDE">HIDE</a><br/><br/><br/>ping -n 1 -w 800 1.1.1.1<br/><br/>Can we hide this command from being <a href="https://interviewquestions.tuteehub.com/tag/displayed-2586485" style="font-weight:bold;" target="_blank" title="Click to know more about DISPLAYED">DISPLAYED</a> on dos window after echo off?<br/>ping -n 1 -w 800 1.1.1.1 > nul<br/>Hey mat that worked.<br/>I <a href="https://interviewquestions.tuteehub.com/tag/thanked-2289102" style="font-weight:bold;" target="_blank" title="Click to know more about THANKED">THANKED</a> you for that<br/>Just a small <a href="https://interviewquestions.tuteehub.com/tag/thing-25656" style="font-weight:bold;" target="_blank" title="Click to know more about THING">THING</a> and good work<br/><br/>>nul <br/><br/>You rock</p></body></html> | |
163. |
Solve : how to extract version of perl while using batch file? |
Answer» <html><body><p>Dear experts..<br/>based on different versions of Perl, how do I extract the version number (e.g. 5.10 or 5.12) in the examples below<br/><br/>This is perl, v5.10.0 built for MSWin32-x86-multi-thread<br/>This is perl 5, version 12, subversion 1 (v5.12.1) built for MSWin32-x86-multi-thread<br/><br/>Thanks..<br/>NaradiDear experts, <br/>I am a newbie in windows batch scripting and to this forum. If this is not a right forum for this post, please let me know. I apologize for the post in <a href="https://interviewquestions.tuteehub.com/tag/wrong-1462035" style="font-weight:bold;" target="_blank" title="Click to know more about WRONG">WRONG</a> forum. <br/><br/>To clarify earlier request further..<br/><br/>I would like to extract the version number of perl installed in different folders.<br/><br/>examples of relevant texts of "perl -v" are given in my previous post...<br/><br/>Thanks again...<br/><br/>-------------<br/>Dear experts..<br/>based on different versions of Perl, how do I extract the version number (e.g. 5.10 or 5.12) in the examples below<br/><br/>This is perl, v5.10.0 built for MSWin32-x86-multi-thread<br/>This is perl 5, version 12, subversion 1 (v5.12.1) built for MSWin32-x86-multi-thread<br/><br/>Thanks..<br/>Naradi Quote from: naradi on July 14, 2010, 05:58:26 PM</p><blockquote>based on different versions of Perl, how do I extract the version number (e.g. 5.10 or 5.12) in the examples below<br/><br/>This is perl, v5.10.0 built for MSWin32-x86-multi-thread<br/>This is perl 5, version 12, subversion 1 (v5.12.1) built for MSWin32-x86-multi-thread<br/></blockquote> <br/>The following snippet should help you out. I'm a bit confused. Do you have two versions of Perl installed or do you just <a href="https://interviewquestions.tuteehub.com/tag/want-1448756" style="font-weight:bold;" target="_blank" title="Click to know more about WANT">WANT</a> the version of Perl that is installed?<br/><br/> Code: <a>[Select]</a>echo off<br/>setlocal<br/><br/>for /f "tokens=4" %%i in ('perl -v ^| find /i "This is perl, "') do (<br/> if not errorlevel 1 echo %%i<br/>)<br/><br/>for /f "tokens=9 delims=()" %%i in ('perl -v ^| find /i "This is perl 5, "') do (<br/> if not errorlevel 1 echo %%i<br/>)<br/><br/>Good luck and welcome to the forum Thanks so much for your response.. <br/><br/>Different machines have different versions of perl installed and I want to extract the version # using a <a href="https://interviewquestions.tuteehub.com/tag/msdos-549596" style="font-weight:bold;" target="_blank" title="Click to know more about MSDOS">MSDOS</a> batch script. The <a href="https://interviewquestions.tuteehub.com/tag/position-246411" style="font-weight:bold;" target="_blank" title="Click to know more about POSITION">POSITION</a> of version number seems to change with the text as seen from the provided examples. However, v5.XX.XX seems to be the only relevant string of characters that have, so far, remained consistent across versions. So, is there a way to extract "vX.XX.XX"?<br/><br/>Thanks again,<br/>Naradi<br/><br/> Quote from: naradi on July 15, 2010, 12:38:54 PM<blockquote>However, v5.XX.XX seems to be the only relevant string of characters that have, so far, remained consistent across versions. So, is there a way to extract "vX.XX.XX"?<br/></blockquote> <br/>Did the code not work properly? I only have Perl 5.10.0 installed on my machine so I could not test version 5.12.1. If there is an error with the script please post your output. I may have miscounted the tokens.<br/><br/>I made one <a href="https://interviewquestions.tuteehub.com/tag/small-1212368" style="font-weight:bold;" target="_blank" title="Click to know more about SMALL">SMALL</a> change to display the "v" with the 5.12.1 version.<br/><br/> Code: <a>[Select]</a>echo off<br/>setlocal<br/><br/>for /f "tokens=4" %%i in ('perl -v ^| find /i "This is perl, "') do (<br/> if not errorlevel 1 echo %%i<br/>)<br/><br/>for /f "tokens=9 delims=()" %%i in ('perl -v ^| find /i "This is perl 5, "') do (<br/> if not errorlevel 1 echo v%%i<br/>)<br/><br/> OP, since you are using Perl, then use Perl. It has more powerful text processing capabilities than batch<br/><br/> Code: <a>[Select]</a>C:\test>perl -version | perl -ne "print if s/(.*[(,][ \t])(v\d+\.\d+\.\d+).*/\2/"<br/>v5.10.1<br/><br/></body></html> | |
164. |
Solve : date log? |
Answer» <html><body><p>Hi guys!<br/>I have a small <a href="https://interviewquestions.tuteehub.com/tag/little-1075899" style="font-weight:bold;" target="_blank" title="Click to know more about LITTLE">LITTLE</a> question, everytime I start my PC a batch file saves the <a href="https://interviewquestions.tuteehub.com/tag/date-11316" style="font-weight:bold;" target="_blank" title="Click to know more about DATE">DATE</a>, time and username in a %date%.log but if overwrites the file when i restart.<br/>How can I make the batch save the next log in the same file in different line?Try this:<br/><br/>echo off<br/>if exist %date%.log (<br/>echo %time%---%username% >> %date%.log<br/>) <a href="https://interviewquestions.tuteehub.com/tag/else-printfy-344787" style="font-weight:bold;" target="_blank" title="Click to know more about ELSE">ELSE</a> (<br/>echo %time%---%username% > %date%.log<br/>)<br/><br/>OR, you can just use the double >> signs and it will create a new file if required, or append the info on a new line.Not working, '07' is not recognised as an internal or external command, operating program or batch file.<br/>It's too complicated this way, but I made it using just a file (Date.log) where is saved the date, time and username <br/>Thank you for the help!What is the format of your date?<br/><a href="https://interviewquestions.tuteehub.com/tag/please-601513" style="font-weight:bold;" target="_blank" title="Click to know more about PLEASE">PLEASE</a> send the result of <br/> Code: <a>[Select]</a>echo %date%<br/>I suspect it is made up with <a href="https://interviewquestions.tuteehub.com/tag/slashes-3037044" style="font-weight:bold;" target="_blank" title="Click to know more about SLASHES">SLASHES</a> as dividers, in which case you need to remove them before using it in a filename<br/><br/>is your logfile called just Date.log ?<br/>in which case, do this<br/> Code: <a>[Select]</a>>> date.log echo %date% %time%---%username%</p></body></html> | |
165. |
Solve : Batch file command to read the sentence at run time? |
Answer» <html><body><p>Hi,<br/><br/>I am trying to write a batch file to capture the arguments at run <a href="https://interviewquestions.tuteehub.com/tag/time-19467" style="font-weight:bold;" target="_blank" title="Click to know more about TIME">TIME</a>.<br/><br/>I have to capture the arguments at run time. I am capturing the same using %1 , %<a href="https://interviewquestions.tuteehub.com/tag/2-236987" style="font-weight:bold;" target="_blank" title="Click to know more about 2">2</a> etc.<br/><br/>But the issue is that it is passing one string value as "Indicates 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>". While capturing the same, I am getting the output as Indicates, rather than the <a href="https://interviewquestions.tuteehub.com/tag/complete-423576" style="font-weight:bold;" target="_blank" title="Click to know more about COMPLETE">COMPLETE</a> sentence.<br/><br/>Is there is any way to capture the complete sentence.<br/><br/>regards,<br/>AtulInstead of using %1, %2 etc. try using <strong>%*</strong><br/><br/> Code: <a>[Select]</a>echo off<br/>set var=%*<br/>echo %var%<br/><br/>Be aware that embedded spaces may cause problems with other commands.<br/><br/> <br/><br/></p></body></html> | |
166. |
Solve : Automatic Deletion of Files With Spreadsheet? |
Answer» <html><body><p>Hello, I am trying to make my life easier at the moment, I have multiple hard-drives and computers containing lots and lots of image files. I have also created an excel spreadsheet with all of these images' information (such as image #, date the image was acquired, type of camera used etc...). However after the images are processed there are many that need to be rejected, these rejected images are manually noted in the Spreadsheet. However I am now looking to create a batch file (or any other possible solution) that looks at the excel spreadsheet, finds out which items are rejected, and then deletes these items from their respective windows folder. Is this possible? <br/><br/>Any help on this would be greatly appreciated. I am a beginner programmer looking to learn a thing or two so hopefully someone can help me out?<br/><br/>Thanks yes, it is possible, the whizzy answer would be to have a vba macro that goes out and deletes the files for you<br/><br/>however, you say you are still on the lower slopes of the learning curve, so lets take a more direct route.<br/><br/>you say you can identify the rejected images -- filter your spreadsheet to show only the rejected ones<br/><br/>save as a text file only the column holding the filenames (with their paths)<br/><br/>all you need now is a simple 1 line command that reads through the file, deleting each filename as it is read<br/><br/>suppose your text file is called rejects.txt, then<br/> Code: <a>[Select]</a>For /f "delims=" %%S in (rejects.txt) do ECHO del "%%S"<br/><strong>BUT <br/>I really strongly recommend that you try this out on a copy of your images, before you find out you have lost irreplaceable pictures<br/><br/>We've all done it -- be aware that a batch file delete does not go into the recycle bin (unless you have downloaded and installed an extra piece of software), they are just gone</strong><br/><br/>Actually, my example does not really delete, it prints to the screen the delete instructions that it would have executed, when you are sure all is well, then remove the ECHO from the instruction, cross your fingers and fire it off<br/>Hey thanks for that I'm <a href="https://interviewquestions.tuteehub.com/tag/going-1008806" style="font-weight:bold;" target="_blank" title="Click to know more about GOING">GOING</a> to try that out. <br/><br/>However you did mention that VBA Macro, I would like to gain as much experience with VBA as possible for my own personal benefit, so is there a chance that somebody can help me make this function through that? And just to be sure would Excel's VBA be sufficient for this operation or would I need VB.net or anything else? <br/><br/>Thanks again Quote from: gpl on July 13, 2010, 04:25:55 PM</p><blockquote>yes, it is possible, the whizzy answer would be to have a vba macro that goes out and deletes the files for you<br/></blockquote> <br/>This assumes that rows 1 to <a href="https://interviewquestions.tuteehub.com/tag/4-238406" style="font-weight:bold;" target="_blank" title="Click to know more about 4">4</a> of column A in Sheet 1 contain path and filenames e.g.<br/><br/> Code: <a>[Select]</a>T:\tempvu\Test-2-01.qry<br/>T:\tempvu\Test-2-02.qry<br/>T:\tempvu\Test-2-03.qry<br/>T:\tempvu\Test-2-04.qry<br/><br/>You can delete the Rem and MsgBox lines when you are happy that it runs OK <br/><br/> Code: <a>[Select]</a>Sub delfile()<br/> Sheets("<a href="https://interviewquestions.tuteehub.com/tag/sheet1-1205244" style="font-weight:bold;" target="_blank" title="Click to know more about SHEET1">SHEET1</a>").Select<br/> Col = "A"<br/> StartRow = 1<br/> <a href="https://interviewquestions.tuteehub.com/tag/maxrow-546921" style="font-weight:bold;" target="_blank" title="Click to know more about MAXROW">MAXROW</a> = 4<br/> For Row = StartRow To MaxRow<br/> Range(Col & Row).Select<br/> MsgBox (Selection.Value)<br/> Rem Kill (Selection.Value)<br/> Next<br/>End Sub<br/><br/>Thank you Salmon Trout that does work however there is still something I need help with. <br/><br/>On my original post I was a bit unclear on the information that is contained in the Excel Spreadsheet. Since these files are moving to different locations/harddrives very often, their file path/name is not contained in the spreadsheet. What is contained is a different number for each image called its "exposure #". So under the "Exp" column I have a list of all of these various numbers.<br/><br/>Similarly, the files themselves, which are in .tif format, also have that same number in their filename. Except for they also have other unassociated numbers in their filename.<br/><br/>For example for exposure # 57, the filename would be something like "ABC2JL4_04007_00057_RGB.tif" where the 00057 is the exposure number. <br/><br/>So now what would be awesome is if Excel could take the number from the Exp column, and use it to locate its associated .tif file(after say I specified a directory somehow), and then I could just delete that file using the code that you suggested. <br/><br/>Am very appreciative of any willing to help!!! <br/><br/> <br/><br/> Quote from: Salmon Trout on July 14, 2010, 11:13:50 AM<blockquote><br/>You can delete the Rem and MsgBox lines when you are happy that it runs OK <br/><br/></blockquote> <br/>That was carelessly written.<br/><br/>Correction:<br/><br/>You can uncomment the Kill line and comment out the MsgBox line when you are happy that it runs OK <br/><br/></body></html> | |
167. |
Solve : creating multiple instances of folders in a directory? |
Answer» <html><body><p>I am tasked with reorganizing an academic server. I have recently realized that there needs to be another folder in each of the course folders. I don't want to go into <a href="https://interviewquestions.tuteehub.com/tag/every-243531" style="font-weight:bold;" target="_blank" title="Click to know more about EVERY">EVERY</a> single course folder and create a new folder using the regular windows explorer windows. is there a way to do this repetetive task in the command prompt? Thanks.yes, check out the FOR command - for /? will give help<br/>Check the For /D option, it iterates through all directoriesperhaps I should have given an example, so try this<br/> Code: <a>[Select]</a>for /D %a in (*.*) do md "%%a\new folder" Quote from: gpl on <a href="https://interviewquestions.tuteehub.com/tag/july-244157" style="font-weight:bold;" target="_blank" title="Click to know more about JULY">JULY</a> 13, 2010, 01:35:40 PM</p><blockquote>perhaps I should have given an example, so try this<br/> Code: <a>[Select]</a>for /D %a in (*.*) do md "%%a\new folder"</blockquote> <br/>Sorry for my ignorance, but I'm relatively inexperienced with the command prompt. That being said, I <a href="https://interviewquestions.tuteehub.com/tag/read-619994" style="font-weight:bold;" target="_blank" title="Click to know more about READ">READ</a> the description of FOR /D and your example of code looks like the (*.*) is telling it to search in a set of files. Let me give you an example directory:<br/><br/>│ ├───NE300<br/>│ │ └───AY11-1<br/>│ │ ├───<a href="https://interviewquestions.tuteehub.com/tag/additional-367648" style="font-weight:bold;" target="_blank" title="Click to know more about ADDITIONAL">ADDITIONAL</a> Resources<br/>│ │ ├───Admin Files<br/>│ │ ├───Homework Files<br/>│ │ ├───Instructor Files<br/>│ │ ├───Lab Files<br/>│ │ ├───Lesson Files<br/>│ │ ├───Submissions<br/>│ │ └───Writs and WPRs<br/><br/>There are about 40 more of these course directories (NE300 is a course) and I want to add a folder called JSmith in all of the existing "Instructor Files" folders. Please let me know where I am making my mistake in understanding the code you gave me. Thanks.<br/>No, you are right - sort of. Directories can be treated as files, in as much as they have a name that can be filtered by *.*, or whatever.<br/><br/>Suppose your master directory is called courses, inside are all of the course folders<br/>NE300<br/>NE310<br/>NE320<br/>NE340<br/>etc<br/><br/>and within each course there is an AY11-1 folder and inside that there is an Instructor Files directory<br/>This is quite easy, make Courses the current directory and execute the following to make JSmith in each<br/> Code: <a>[Select]</a>for /D %a in (*.*) do md "%%a\AY11-1\Instructor Files\JSmith"<br/>However, I suspect that the actual name of the AY11-1 directory is different in each course; if it is the top level (ie the only one as you seem to indicate in your tree) within the individual course directory - like this<br/>Courses<br/>¦ +---NE300<br/>¦ ¦ +---AY11-1<br/>¦ ¦ +---Additional Resources<br/>¦ ¦ +---Admin Files<br/>¦ ¦ +---Homework Files<br/>¦ ¦ +---Instructor Files<br/>¦ ¦ +---Lab Files<br/>¦ ¦ +---Lesson Files<br/>¦ ¦ +---Submissions<br/>¦ ¦ +---Writs and WPRs<br/>¦ +---NE310<br/>¦ ¦ +---AY11-2<br/>¦ ¦ +---Additional Resources<br/>¦ ¦ +---Admin Files<br/>¦ ¦ +---Homework Files<br/>¦ ¦ +---Instructor Files<br/>¦ ¦ +---Lab Files<br/>¦ ¦ +---Lesson Files<br/>¦ ¦ +---Submissions<br/>¦ ¦ +---Writs and WPRs<br/>¦ +---NE320<br/>¦ ¦ +---AY11-3<br/>¦ ¦ +---Additional Resources<br/>¦ ¦ +---Admin Files<br/>¦ ¦ +---Homework Files<br/>¦ ¦ +---Instructor Files<br/>¦ ¦ +---Lab Files<br/>¦ ¦ +---Lesson Files<br/>¦ ¦ +---Submissions<br/>¦ ¦ +---Writs and WPRs<br/>¦ +---NE330<br/>¦ ¦ +---AY11-4<br/>¦ ¦ +---Additional Resources<br/>¦ ¦ +---Admin Files<br/>¦ ¦ +---Homework Files<br/>¦ ¦ +---Instructor Files<br/>¦ ¦ +---Lab Files<br/>¦ ¦ +---Lesson Files<br/>¦ ¦ +---Submissions<br/>¦ ¦ +---Writs and WPRs<br/><br/><br/>then a nested loop will be needed to identify the relevant <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 the Instructor Files. Im sure that one of my esteemed colleagues will be able to show a wonderful bracket example, here is my offering using a subroutine call -- blimey it seemed to work first time !<br/><br/> Code: <a>[Select]</a>for /D %%a in (*.*) do Call :ProcFolder "%%a"<br/>GoTo :EOF<br/>:ProcFolder<br/>for /D %%b in ("%1\*.*") do md "%%b\Instructor Files\JSmith"<br/></body></html> | |
168. |
Solve : Help w/batch merging files? |
Answer» <html><body><p>Hello,<br/><br/>I have several file, 1KB each. Some are empty but few are not. If I merge all of them into one file I end up with blank lines. How can I find the empty files when I can not use the size and merge only the ones w/data? Or is there a way to remove the blank lines automatically from the <a href="https://interviewquestions.tuteehub.com/tag/new-1114486" style="font-weight:bold;" target="_blank" title="Click to know more about NEW">NEW</a> file?Test for the file size in a For loop using %%~zA and reject/accept the file for merging based on the file size using an If command. Note that if a file contains just a CR/LF it is not 'empty', the length will be shown as 2 bytes.<br/><br/>At the command prompt enter For /? to view For help<br/><br/>Post your script. Or exploit the fact that FOR /F skips blank lines<br/> Code: <a>[Select]</a>if exist temp.txt del temp.txt<br/>for /f "delims=" %%a in (file.txt) do echo %%a >>temp.txt<br/>del file.txt<br/>ren temp.txt file.txt<br/>replace all <a href="https://interviewquestions.tuteehub.com/tag/instances-770152" style="font-weight:bold;" target="_blank" title="Click to know more about INSTANCES">INSTANCES</a> of file.txt with <a href="https://interviewquestions.tuteehub.com/tag/name-237998" style="font-weight:bold;" target="_blank" title="Click to know more about NAME">NAME</a> of file to remove blank lines fromThank you all for suggestions. I understand now why, even though the file 'looks' empty, it is not (size is 2 bytes). As a test, I combined 3 files (1 record each) into 1 and then removed the blank lines, at least I thought I did, but when I try to load them it shows 6 records where 3 are blank so the load process aborts. I don't think I can check for size because the file is only 2 bytes, as Dusty pointed out, it's not 'empty'.I can't get this to work. I still end up with 6 records when I only have 3. How I end up with 3 blank ones, which you can not actually see in the file, when I already removed the blank lines? Please, if anybody can help, let me know. Here are the batch files I am using.<br/><br/>rem RUN_CLEAN_TEST_FILE.BAT<br/>echo on<br/>date /t<br/>time /t<br/>call clean_test_file TEST1.txt TEST.txt<br/>exit<br/><br/>rem clean_test_file.bat<br/>echo off<br/>For /F "tokens=* delims=" %%A in (%1) Do Echo %%A >> %2<br/>exit Quote from: Cookie</p><blockquote>As a test, I combined 3 files (1 record each) into 1 and then removed the blank lines</blockquote> <br/>How did you "combine" the files, which software did you use?<br/> <br/>Please post a screenshot of a hex editor output of test1.txt and test.txtHi,<br/>I don't use any software to combine the file, I just use the copy command because I want everything to run in batch:<br/>copy *.txt test1.txt /b<br/>Here is where test1.txt contains blanks so I run the clean batch to remove the blanks and create the test.txt file.<br/>I am not sure if this is what you're <a href="https://interviewquestions.tuteehub.com/tag/asking-2445373" style="font-weight:bold;" target="_blank" title="Click to know more about ASKING">ASKING</a> for, but here they are<br/><br/><br/>[recovering disk space - old attachment deleted by admin]Suggest you do the lot in one script as below. This should <a href="https://interviewquestions.tuteehub.com/tag/read-619994" style="font-weight:bold;" target="_blank" title="Click to know more about READ">READ</a> your three test files and write them to output omitting blank lines, after testing you can change the inputs/output filenames to whatever you want:<br/><br/> Code: <a>[Select]</a>echo off<br/>cls<br/><br/>for /f "tokens=*" %%1 in (inputfile1.txt inputfile2.txt inputfile3.txt) do (<br/> echo %%1>>outputfile.txt<br/>)<br/><br/></body></html> | |
169. |
Solve : Cancel Exit Application? |
Answer» <html><body><p>Hi <br/><br/>I'm looking for cmd code that will cancel the x button that a user clicks to exit an application.<br/><br/>Any help will be very much appreciated!<br/><br/>Amram Chayim Eirinberg<br/>You mean you want a code which will prevent a user from closing the window? Not going to work. Why not? I'm not <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 make something cheeky <br/><br/>What I'm really to do is <a href="https://interviewquestions.tuteehub.com/tag/display-25607" style="font-weight:bold;" target="_blank" title="Click to know more about DISPLAY">DISPLAY</a> a Msg asking for confirmation (this part I can do), and if the user clicks cancel, I will run a bat file to cancel the exit.It's not possible. you cannot create a ConsoleCtrlHandler() nor can you programmatically call SetConsoleCtrlHandler().<br/><br/>If you want to disable the Exit button, you'll probably need to write your "batch file" as an actual program.<br/><br/>Some utilities can be used to disable the exit button, but this is different- they do this by acquiring the window handle of the console window, calling GetSystemMenu() on that handle, and then disabling the Close menu <a href="https://interviewquestions.tuteehub.com/tag/option-25810" style="font-weight:bold;" target="_blank" title="Click to know more about OPTION">OPTION</a> (which also disables the X button).<br/><br/>After the program does this, it exits, and you are back at the <a href="https://interviewquestions.tuteehub.com/tag/prompt-592976" style="font-weight:bold;" target="_blank" title="Click to know more about PROMPT">PROMPT</a> or the batch continues.<br/><br/>however, a utility cannot easily be run that will do what you require.<br/><br/>First: the SetConsoleCtrlHandler() accepts the address of a callback function. by definition, it has to be in the address space of the caller (the "utility" program. however, you cannot get back to the prompt or resume the batch file until that utility exits, and once it exits, there is no valid hook function to call.Is it possible to cancel out the exit through VBScript?In VB and VBScript, the behaviour of the window close button (the 'x') varies in Windows messageboxes depending on which buttons are specified. It is visible but greyed out and disabled for a YesNo or a AbortRetryIgnore message box. <br/><br/>Summary:<br/><br/>1. AbortRetryIgnore and YesNo disable the X.<br/>2. If a Cancel button is provided (all other combinations except vbOkOnly) then X is enabled<br/>3. If only one button is displayed then X is enabled<br/><br/>Here's what happens when the above scenarios are displayed and user hits X instead of clicking on a button<br/><br/>1. N/A. X button not enabled<br/>2. MsgBox returns Cancel<br/>3. MsgBox returns value of only button<br/><br/>This really makes it almost pointless to disable the button once you are aware of these things. <br/><br/>By the way, it is not just clicking X. When X is enabled, <a href="https://interviewquestions.tuteehub.com/tag/esc-446582" style="font-weight:bold;" target="_blank" title="Click to know more about ESC">ESC</a> will trigger same results. <br/>Thanks Salmon! For some reason I thought they were talking about batch files, and the close button of the console window.</p></body></html> | |
170. |
Solve : Is One Second too quick for "SHUTDOWN -s -t 1"? |
Answer» <html><body><p>To shutdown the P.C. I launch a script to run various things that tidy up and remove junk,<br/>and when they have finished it runs<br/> Code: <a>[Select]</a>SHUTDOWN -s -t 10<br/>That causes Windows to :-<br/>close applications and possibly allow me to <a href="https://interviewquestions.tuteehub.com/tag/save-637275" style="font-weight:bold;" target="_blank" title="Click to know more about SAVE">SAVE</a> anything I have forgotten to save;<br/>Possibly allow my intervention if the wretched un-invited cftmon.exe refuses to let go;<br/>probably allow Firefox extensions to synchronise servers with my latest changes;<br/>possible allow my intervention if Firefox cannot close for any reason, e.g. dead Internet.<br/><br/>Then it closes the CMD.EXE window and the SHUTDOWN pop-up appears and gives a 10 second countdown.<br/><br/>WHY should I wait 10 seconds - is it safe to wait only one second ?<br/><br/>Is there something <a href="https://interviewquestions.tuteehub.com/tag/important-1038039" style="font-weight:bold;" target="_blank" title="Click to know more about IMPORTANT">IMPORTANT</a> that may take 10 Seconds to complete in the background ?<br/><br/>Your advice please :-<br/>Can there be something important the needs to finish during the 10 second countdown ?<br/>Would it be safer to allow a longer countdown ?<br/>Is it just as safe to use a 1 Second countdown ?<br/><br/>I know my numbers, I know my 12 times table, watching a countdown does not improve my numeracy ! ! !<br/><br/>I could see the sense of having a ten second countdown to reconsider and abort,<br/>but I find it does a Magnus Magnusson "I've started, so I'll finish".<br/><br/>It would save 9 seconds of electricity if I cut it down to 1 second,<br/>but I will happily give it another thousand seconds if that would ensure that nothing was damaged by a "premature" shutdown.<br/><br/>I am using Windows XP Home with SP3<br/><br/>Regards<br/>Alan<br/> Quote</p><blockquote>Is it just as safe to use a 1 Second countdown ?</blockquote> <br/>Why wait at all? I customarily shut down using a batch file; I have the delay set to 0. I have been doing this for 6 years in XP, Vista and Windows 7. Windows won't trip the power until it is safe to do so.<br/><br/> Quote from: ALAN_BR<blockquote>Is there something important that may take 10 Seconds to complete in the background ?</blockquote> <br/><br/>The delay chosen by shutdown -s -t <em>N</em> is number of seconds <em>before</em> Windows commences the shutdown procedure. Nothing happens during that time, other than the display of a message to the user. You might as well skip it altogether if you know you want to shut down and you don't need to save any data.<br/><br/><br/><br/>Thank you.<br/><br/>I thought one second should be legitimate, but have often come to grief when I attempt a value of zero where the code only expects 1 to 255. <br/>Zero Seconds it is then.<br/><br/>I am sure that when I launch my script there "should" be nothing that needs to be saved.<br/>If I reconsider during the script I can immediately close and abort the script.<br/>I just do not see how a final 10 second countdown would allow me to see that a file needed closing, or to tell an application to close its files - and even if I could see, am I not logged out with zero authority once the countdown has started ?<br/>I have never managed to close down/abort the countdown, even the top right close button does nothing.<br/><br/>For many years Windows 98 would give me, every day, a random selection of<br/>BSOD<br/>Lost Clusters<br/>Reprimand for not closing down windows properly<br/>Continuous never ending idle when I told it to shutdown, and I had to pull the plug when the janitor came to lock up the office.<br/><br/>I have not learnt respect for Windows,<br/>but I have learnt to be wary of the grief and misery it imposes without warning ! ! !<br/><br/>I am not a trail blazer, but am happy to follow in your footsteps.<br/>Thank you<br/><br/>Regards<br/>Alan<br/> Quote from: ALAN_BR on July 17, 2010, 11:34:44 AM<blockquote>am I not logged out with zero authority once the countdown has started ?</blockquote> <br/>Quite the reverse. If you open a command prompt, and type <strong>shutdown /?</strong> (This is quite safe, as is just typing <strong>shutdown</strong> on its own, which has the same effect) you will see all the options available. One of these is <strong>shutdown /a</strong> (a is for abort) which immediately terminates any pending shutdown. The help states that the /a switch is only usable during the "time-out period", in this context this is the number of seconds which were specified at the command prompt or in a script with the <strong>-t</strong> option. <br/><br/>Note that in the Windows 2000 and XP help the options are preceded by a dash, (e.g. shutdown -s -t 10) whereas in Vista, Windows 7 etc a slash is used (shutdown /s /t 10) but in fact you can use either format.<br/><br/>Try this - open two command prompt windows and position them side-by-side. In one, type <strong>shutdown /s -t</strong> with some suitably large number e.g. 300 (five minutes). Observe the information box that appears. In the other command window, type <strong>shutdown /a</strong> and see what happens.<br/><br/>I imagine a reason for having a short delay might when you are pretty sure the user will be looking at the screen (e.g. it is you) and you just want to assure them or yourself that the shutdown (or shutdown and restart) is actually going to happen, and a longer one might be where you want to give the user plenty of time to save any work that might be in progress. Remember that shutdowns can be triggered remotely over a network by a system admin, who might for example give everybody an hour to get everything saved and log out. As the help makes clear, the options include the ability to include "reasons for shutdown" information.<br/><br/>.I am sorry that I doubted the "help" from "SHUTDOWN /?" and also your own advice.<br/><br/>My previous experience was that I had zero control once the countdown commenced.<br/><br/>I find that the top right corner still does not close the countdown,<br/>but I now have the ability to launch CMD.EXE and abort the shutdown,<br/>which was not possible last year.<br/><br/>Most system changes I put down to a Patch Tuesday update,<br/>but I think on this occasion it is what I did before SHUTDOWN.<br/><br/>To close down I simply double click a desktop icon (visible because all tasks are <a href="https://interviewquestions.tuteehub.com/tag/closed-919469" style="font-weight:bold;" target="_blank" title="Click to know more about CLOSED">CLOSED</a>).<br/>This icon launched a tidy-up script which concluded by running<br/>CCleaner /AUTO /SHUTDOWN<br/>That purged temporary and unwanted files automatically without interaction,<br/>and then shut down the computer - 95 times out of 100.<br/>There must have been a race hazard somewhere, and on the failure occasions :-<br/>Task <a href="https://interviewquestions.tuteehub.com/tag/manager-239636" style="font-weight:bold;" target="_blank" title="Click to know more about MANAGER">MANAGER</a> showed that about 5 normal process.exe were missing ; and<br/>repeating the launch of the tidy-up script never succeeded,<br/>some service or process *.exe was no longer available to support CCleaner.<br/><br/>I then created a pure SHUTDOWN script with the single command<br/>SHUTDOWN -s -t 10<br/>I then found that whenever "CCleaner /AUTO /SHUTDOWN" failed<br/>my new shutdown script would always shut down.<br/><br/>I decided that the pop-up screen was totally wrong because :-<br/>1. The top right corner "X" fails to close that window / application as it should,<br/>2. There was no way I could do anything to save the documents as it suggested.<br/><br/>I now realise that criticism 2 is only true if CCleaner has caused 5 services to stop.<br/>Those 5 services did not seem to be <a href="https://interviewquestions.tuteehub.com/tag/required-1185621" style="font-weight:bold;" target="_blank" title="Click to know more about REQUIRED">REQUIRED</a> for me to view files and launch task manager etc etc., and "SHUTDOWN -s -t 10" would still operate.<br/>I now deduce that whilst Windows is closing down because "SHUTDOWN -s -t 10" told it to do so, some further bits of Windows were closed, and it is probably the loss of these bits in addition to the loss of 5 services which has destroyed all my interactive control<br/><br/>My new tidy-up script no longer gives CCleaner the /SHUTDOWN argument,<br/>and concludes with the new line<br/>SHUTDOWN -s -t 1<br/>I like about 1 second to see it go,<br/>and I have never yet thought within 10 seconds of something I forgot to save ! !<br/><br/>Regards<br/>Alan<br/><br/><br/>I am not convinced that programs like CCcleaner are a good idea. Many people think that gee-whiz "registry cleaners" do more harm than good, that they sometimes cause more problems than they prevent.<br/><br/>I do not oppose that view.<br/><br/>For my /AUTO mode I use a very light profile that only zaps stuff that I know is not needed,<br/>and all the flash cookies that always arrive,<br/>and all the Firefox caches in the User profile.<br/>This gives me the benefit that my daughters music and video downloads that filled her caches are erased when she shuts down, leaving more free disc space for me (and vice versa).<br/><br/>I have a more serious manual mode which is more stringent, but I always scrutinise the analysis and use Google to investigate anything that CCleaner has not previously offered to purge, and only commit to a clean after un-checking any items I have doubts about.<br/><br/>The registry was the dreaded end.<br/>I only had a cautious cleanse (with backups) before un-installing something,<br/>and after un-installing when CCLeaner told me of things that had been left behind when something was removed, I believed it and let it purge them.<br/><br/>In my view registry cleaning is no longer the worst bogeyman.<br/>There are new kid's in the block :-<br/>Secure multi-pass erase ; and even worse<br/>Wipe Free Space.<br/><br/>I find it incredible that new users of CCleaner are so eager for a new experience they go for maximum effect, and check all the boxes which for safety are NOT checked on a fresh install.<br/>They even believe that Wipe Free Space will somehow make more free space available for them to use - and then after the disc has been chundering away for a few hours they abort to see what has been happening and find the entire free space has been lost.<br/>Eventually they find the CCleaner forum and users explain what a bad idea it is and point them to documentation, and explain that the free space was overwritten with a monster file that would have been deleted had they allowed CCleaner to finish its work.<br/><br/>You just have to cry - or laugh - take your choice ! !<br/><br/>Having said all that, I trust CCleaner as being much safer than many of the expensive cleaners that the naive grab as today's giveaway on GAOTD and similar sites.<br/><br/>Regards<br/>Alan<br/></body></html> | |
171. |
Solve : Run a batch file across the network? |
Answer» <html><body><p>Can anyone give info about <a href="https://interviewquestions.tuteehub.com/tag/running-1192206" style="font-weight:bold;" target="_blank" title="Click to know more about RUNNING">RUNNING</a> a batch file across a network? Is it possible?<br/><br/>Thanks<br/>Maybe <a href="https://interviewquestions.tuteehub.com/tag/want-1448756" style="font-weight:bold;" target="_blank" title="Click to know more about WANT">WANT</a> you want is <br/><strong>remote <a href="https://interviewquestions.tuteehub.com/tag/execution-979196" style="font-weight:bold;" target="_blank" title="Click to know more about EXECUTION">EXECUTION</a></strong> over the network.<br/><br/>There are a number of ways to do that if you are the system <a href="https://interviewquestions.tuteehub.com/tag/administrator-368059" style="font-weight:bold;" target="_blank" title="Click to know more about ADMINISTRATOR">ADMINISTRATOR</a> for the <a href="https://interviewquestions.tuteehub.com/tag/pcs-244204" style="font-weight:bold;" target="_blank" title="Click to know more about PCS">PCS</a> on the local network. <br/><br/>Google emote execution.<br/><br/>Or watch this video.<br/><a href="https://www.youtube.com/watch?v=-QjScAtBIHY">Remote execution and deployment of Windows Scripts </a>I will take a look around.<br/><br/>Thanks!<br/></p></body></html> | |
172. |
Solve : Q AND A? |
Answer» <html><body><p>IQ test......<br/><br/><strong>Question 1</strong><br/>I have a batch <a href="https://interviewquestions.tuteehub.com/tag/file-11330" style="font-weight:bold;" target="_blank" title="Click to know more about FILE">FILE</a> called "Test.bat". Look below<br/> Code: <a>[Select]</a>echo off<br/>msg * <a href="https://interviewquestions.tuteehub.com/tag/line-239358" style="font-weight:bold;" target="_blank" title="Click to know more about LINE">LINE</a> number <a href="https://interviewquestions.tuteehub.com/tag/one-241053" style="font-weight:bold;" target="_blank" title="Click to know more about ONE">ONE</a> loaded!<br/>msg * Line number two loaded!<br/>msg * Line number three loaded!<br/>msg * Ending program!<br/>exit<br/>I want to replace the script "Line Number Two Loaded!" with "Line Two Loaded!"<br/>How can i do that with batch command?<br/><br/><strong>Question 2</strong><br/>I have a batch file called "test.bat". Look below.<br/> Code: <a>[Select]</a>echo off<br/>:a<br/>taskkill /f /im password_viewer.exe<br/>goto a<br/>Ok, the password_viewer.exe is a little worm in my PC. I want to kill it using Batch command.<br/>But the worm will then restart itself after killing it so i have to put a loop in my batch command.<br/>Putting the loop make my computer slow. How can i kill the WORM when only it is running?<br/><br/><strong>Question 3</strong><br/>I have a batch file called "Test.bat". Look below.<br/> Code: <a>[Select]</a>echo off<br/>echo Type Your Score.<br/>set/p score=><br/>echo %score% >>Score.txt<br/>pause<br/>echo View your score.<br/>type score.txt<br/>pause<br/>exit<br/>And a Text file called "Score.txt"<br/> Code: <a>[Select]</a>score 76<br/>score 89<br/>score 85<br/>score 67<br/>I want my batch file to display only the score in line three char six that is 85. How can i do that?<br/><br/><strong>Question 4</strong><br/>In my drive "G:\Junk" have a lot of subfolder, jpg, mp3, txt, bat and a lot of junk in it.<br/>But an error occured when i try to remove the "G:\Junk" using batch command:<br/>Cannot remove directory because the directory is not empty<br/>What <a href="https://interviewquestions.tuteehub.com/tag/must-1702064" style="font-weight:bold;" target="_blank" title="Click to know more about MUST">MUST</a> i do?<br/><br/>ONE QUESTION RIGHT GET 25 MARKS. I WILL BE APPRECIATED IF ANYONE GOT MOST OF THE QUESTION RIGHT. Quote from: progmer on July 18, 2010, 07:28:21 PM</p><blockquote>IQ test......<br/><br/><strong>Question 1</strong><br/>I have a batch file called "Test.bat". Look below<br/> Code: <a>[Select]</a>echo off<br/>msg * Line number one loaded!<br/>msg * Line number two loaded!<br/>msg * Line number three loaded!<br/>msg * Ending program!<br/>exit<br/>I want to replace the script "Line Number Two Loaded!" with "Line Two Loaded!"<br/>How can i do that with batch command?<br/></blockquote> you can use a file processing tool, such as <a href="http://gnuwin32.sourceforge.net/packages/sed.htm">sed for windows</a>.<br/> Code: <a>[Select]</a>C:\test>sed "s/Line number two/Line two/" file<br/>echo off<br/>msg * Line number one loaded!<br/>msg * Line two loaded!<br/>msg * Line number three loaded!<br/>msg * Ending program!<br/><br/> Quote<blockquote><strong>Question 2</strong><br/>I have a batch file called "test.bat". Look below.<br/> Code: <a>[Select]</a>echo off<br/>:a<br/>taskkill /f /im password_viewer.exe<br/>goto a<br/>Ok, the password_viewer.exe is a little worm in my PC. I want to kill it using Batch command.<br/>But the worm will then restart itself after killing it so i have to put a loop in my batch command.<br/>Putting the loop make my computer slow. How can i kill the WORM when only it is running?<br/></blockquote> you are not solving the root of the problem. Use a virus scanner to remove the worm, or do it manually such as <a href="https://interviewquestions.tuteehub.com/tag/registry-1182422" style="font-weight:bold;" target="_blank" title="Click to know more about REGISTRY">REGISTRY</a> and system32. Then make an effort to always update your virus signatures, and discipline yourself not to run unknown <br/>executables anyhow.<br/><br/> Quote<blockquote><strong>Question 3</strong><br/>I have a batch file called "Test.bat". Look below.<br/> Code: <a>[Select]</a>echo off<br/>echo Type Your Score.<br/>set/p score=><br/>echo %score% >>Score.txt<br/>pause<br/>echo View your score.<br/>type score.txt<br/>pause<br/>exit<br/>And a Text file called "Score.txt"<br/> Code: <a>[Select]</a>score 76<br/>score 89<br/>score 85<br/>score 67<br/>I want my batch file to display only the score in line three char six that is 85. How can i do that?<br/></blockquote> again, if you have downloaded sed<br/> Code: <a>[Select]</a>C:\test>sed -n "3s/^score //p" score.txt<br/>85<br/><br/> Quote<blockquote><strong>Question 4</strong><br/>In my drive "G:\Junk" have a lot of subfolder, jpg, mp3, txt, bat and a lot of junk in it.<br/>But an error occured when i try to remove the "G:\Junk" using batch command:<br/>Cannot remove directory because the directory is not empty<br/>What must i do?<br/></blockquote> If it says its not empty, then go empty them...or you can "force" deletion using switches from some of the delete commands eg del, deltree..etc...<br/><br/> Quote<blockquote>ONE QUESTION RIGHT GET 25 MARKS. I WILL BE APPRECIATED IF ANYONE GOT MOST OF THE QUESTION RIGHT.<br/></blockquote> next time, try to research a bit on the internet as well.. Quote from: ghostdog74 on July 18, 2010, 07:56:43 PM<blockquote>you can use a file processing tool, such as <a href="http://gnuwin32.sourceforge.net/packages/sed.htm">sed for windows</a>.<br/></blockquote> Can you give me a script that don't need to download "sed"?<br/>Because machine without "sed" will not be able to run the program.progmer, why did you choose such an irritating way of asking your questions? It is bound to limit the help that you get.<br/></body></html> | |
173. |
Solve : how to record user input and cmd output? |
Answer» <html><body><p>export them to 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> or other easier method?<br/><br/>i send a <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 through lpr command, then i want to log the activities (fail to print..files copied...<br/>try cutting and pasting if all of the information you want is in the 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> window. right click and choose mark, then <a href="https://interviewquestions.tuteehub.com/tag/select-630282" style="font-weight:bold;" target="_blank" title="Click to know more about SELECT">SELECT</a> all you want to copy, then copy and paste into a notepad or word fileC:\test>type ol.bat<br/><br/> Code: <a>[Select]</a>echo off<br/><br/>set /p in=Enter input :<br/><br/>echo %in% | lpr 2> log.txt<br/><strong>Output:</strong><br/><br/>C:\test> ol.bat<br/>Enter input : Hello<br/><br/>C:\test>type log.txt<br/>'lpr' is not recognized as an internal or external command,<br/>operable program or batch file.<br/><br/>C:\test>¡Hola, Carlos! ¿Qué tal? <br/></p></body></html> | |
174. |
Solve : Net use for a local network connected drive? |
Answer» <html><body><p>Hi,<br/>I cannot access my local <a href="https://interviewquestions.tuteehub.com/tag/net-1887" style="font-weight:bold;" target="_blank" title="Click to know more about NET">NET</a> work connected drive from my <a href="https://interviewquestions.tuteehub.com/tag/administrator-368059" style="font-weight:bold;" target="_blank" title="Click to know more about ADMINISTRATOR">ADMINISTRATOR</a> account.<br/>I am trying to issue Takeown and ICACLS from the command prompt to fix some ownership and permission problem for <a href="https://interviewquestions.tuteehub.com/tag/18-242944" style="font-weight:bold;" target="_blank" title="Click to know more about 18">18</a> files.<br/>I think I need:<br/> NET USE S: \\FranksPC\ \\EXTERNALDRIVE<br/><br/>\\EXTERNALDRIVE is the name of the drive. Can I use the <a href="https://interviewquestions.tuteehub.com/tag/uac-2314977" style="font-weight:bold;" target="_blank" title="Click to know more about UAC">UAC</a> addressing?<br/>The IP for drive is 192.168.1.4<br/>The question is: How is the disk identified to Net Use?<br/>Thanks<br/>Frank C</p></body></html> | |
175. |
Solve : Old computer has HHD earased and want to load now for CAD? |
Answer» <html><body><p>I have an old computer with <a href="https://interviewquestions.tuteehub.com/tag/2-236987" style="font-weight:bold;" target="_blank" title="Click to know more about 2">2</a> HHD's- <a href="https://interviewquestions.tuteehub.com/tag/1-236780" style="font-weight:bold;" target="_blank" title="Click to know more about 1">1</a>- is small and overloads quickly the other is large- together they can handle WIN98- XP loads but bottoms out with a code 14<br/>The system was changed from a Fat 32 to NTFS but there is now no OS loaded and I can't remember where to start in DOS to format the <a href="https://interviewquestions.tuteehub.com/tag/drives-959782" style="font-weight:bold;" target="_blank" title="Click to know more about DRIVES">DRIVES</a> again-It rejects WIN98 and will not load XP- I'm Stuck! Pls help- any suggestions or lead me to a help page- Thanks---IMGONNAWINIf there is no OS <a href="https://interviewquestions.tuteehub.com/tag/installed-499454" style="font-weight:bold;" target="_blank" title="Click to know more about INSTALLED">INSTALLED</a>, just boot to either OS cd and start the <a href="https://interviewquestions.tuteehub.com/tag/installation-16361" style="font-weight:bold;" target="_blank" title="Click to know more about INSTALLATION">INSTALLATION</a> process.</p></body></html> | |
176. |
Solve : config.sys in what ditectory is found? |
Answer» <html><body><p>on a PC running ms-dos or windows <a href="https://interviewquestions.tuteehub.com/tag/98-malyana-ka-rinae-samajhata-para-hasatakashhara-236807" style="font-weight:bold;" target="_blank" title="Click to know more about 98">98</a> the file Config.sys where <a href="https://interviewquestions.tuteehub.com/tag/would-3285927" style="font-weight:bold;" target="_blank" title="Click to know more about WOULD">WOULD</a> this file be placed. in what <a href="https://interviewquestions.tuteehub.com/tag/directory-11615" style="font-weight:bold;" target="_blank" title="Click to know more about DIRECTORY">DIRECTORY</a> In the <a href="https://interviewquestions.tuteehub.com/tag/root-237331" style="font-weight:bold;" target="_blank" title="Click to know more about ROOT">ROOT</a> directory of C:<a href="https://interviewquestions.tuteehub.com/tag/thanks-665909" style="font-weight:bold;" target="_blank" title="Click to know more about THANKS">THANKS</a></p></body></html> | |
177. |
Solve : COPY A FILE TO DESKTOP (XP)? |
Answer» <html><body><p>hi everyone!<br/><br/>need help in <a href="https://interviewquestions.tuteehub.com/tag/copying-426077" style="font-weight:bold;" target="_blank" title="Click to know more about COPYING">COPYING</a> 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> so that it will be visible in the <a href="https://interviewquestions.tuteehub.com/tag/desktop-949558" style="font-weight:bold;" target="_blank" title="Click to know more about DESKTOP">DESKTOP</a>.<br/>just like shortcuts!<br/><br/>what will be the directory then?<br/>the problem is that the path is not fixed like...<br/>C:\Documents and Settings\comp1\Desktop<br/>C:\Documents and Settings\comp2\Desktop<br/>C:\Documents and Settings\comp3\Desktop<br/>C:\Documents and Settings\comp4\Desktop<br/>C:\Documents and Settings\comp5\DesktopTry:<br/><br/>"%userprofile%\Desktop"<br/>"%allusersprofile%\Desktop"<br/><br/>Those work for XP and <em>should</em> work with Vista/7. The second will work for all user accounts on that computer and the <a href="https://interviewquestions.tuteehub.com/tag/first-461760" style="font-weight:bold;" target="_blank" title="Click to know more about FIRST">FIRST</a> will work for the current user (the one who ran the batch file).<br/>C:\>cd \<br/><br/>C:\>dir /s desktop<br/> Volume in drive C has no label.<br/> Volume Serial Number is 0652-E41D<br/><br/> Directory of C:\Users\marylane<br/><br/>07/26/2010 10:13 AM Desktop<br/> 0 File(s) 0 bytes<br/><br/> Directory of C:\Users\Default<br/><br/>07/13/2009 09:04 PM Desktop<br/> 0 File(s) 0 bytes<br/><br/> Total Files Listed:<br/> 0 File(s) 0 bytes<br/> 2 Dir(s) 293,939,007,488 bytes free<br/><br/>C:\>COPY "P:\A\T\H\*.*" %USERPROFILE%\Desktop<br/><br/>Use quotes if there are spaces involved.THANKS to all! now I can complete my trial installer^^</p></body></html> | |
178. |
Solve : Need to get advance summary from a jpg? |
Answer» <html><body><p>Hey guys,<br/><br/>You know when you go into a files properties and summary then advance you can see a photos resolution, dpi etc<br/><br/>i want to be able to write a <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 that will <a href="https://interviewquestions.tuteehub.com/tag/obtain-582970" style="font-weight:bold;" target="_blank" title="Click to know more about OBTAIN">OBTAIN</a> all the resolutions of the files and move files under certain res to another folder.<br/><br/>i can figure the <a href="https://interviewquestions.tuteehub.com/tag/latter-7376806" style="font-weight:bold;" target="_blank" title="Click to know more about LATTER">LATTER</a> on my own but is this possible?you can <a href="https://interviewquestions.tuteehub.com/tag/download-11414" style="font-weight:bold;" target="_blank" title="Click to know more about DOWNLOAD">DOWNLOAD</a> jpeg tools like jhead to parse jpg information. search the web.I've used "exiftool" for things similar to this before.</p></body></html> | |
179. |
Solve : How to set a time limit for program execution? |
Answer» <html><body><p>I want to set a time limit of 100 seconds for executing a Java program. <br/><br/>In a UNIX I just write<br/><br/> ulimit -t 100<br/> java Program<br/><br/>How can I achieve the same with DOS?<br/><br/><br/>start java program<br/>ping localhost -n 101 > nul<br/>taskkill java program<br/> Thanks mat123<br/><br/>I have tried your solution, but it is not satisfactory for me. The ping command always works for 101 seconds, regardless of the started Java program, that typically finishes in a few seconds. <br/><br/>I need a solution for running a bunch of student programs and want to be sure that no more than 100 seconds 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> per run.start java.exe<br/>set a=1<br/>:A<br/>if %a%==100 goto out<br/>ping localhost -n 2 > nul<br/>tasklist|find "java.exe"<br/>if errorlevel 1 exit<br/>set /a a=%a%+1<br/>goto a<br/>:out<br/>taskkill java.exeThanks again mat123. I implemented your solution. However, it seems to have some drawbacks:<br/><br/>(1) The -n option for the ping command does not specify seconds, but number of <a href="https://interviewquestions.tuteehub.com/tag/pings-2929260" style="font-weight:bold;" target="_blank" title="Click to know more about PINGS">PINGS</a>.<br/>(2) The value of ERRORLEVEL (exit status) from the Java program cannot be accessed.<br/><br/>Furthermore, I get an annoying <a href="https://interviewquestions.tuteehub.com/tag/error-25548" style="font-weight:bold;" target="_blank" title="Click to know more about ERROR">ERROR</a> message from taskkill if the Java program to be killed has finished. <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>replace ping line with Code: <a>[Select]</a>ping localhost -w 500 -n 2 > nuli am not getting the errorlevel of the java program but find.exe<br/>the whole code is<br/><br/> Code: <a>[Select]</a>start java program<br/>set a=1<br/>:A<br/>if %a%==100 goto out<br/>ping localhost -w 500 -n 2 > nul<br/>tasklist|find "java program"<br/>if errorlevel 1 exit<br/>set /a a=%a%+1<br/>goto a<br/>:out<br/>taskkill java programThe -w option does not have the desired effect. <br/><br/>I even tried with '-w 1' to see if the time limit was reached faster. Unfortunately not.<br/><br/>The Java programs are supposed to solve a puzzle. If the puzzle cannot be solved the program must call System.exit(1); otherwise, ii should exit normally (calling System.exit(0)). After execution the argument to System.exit must be be tested using ERRORLEVEL.<br/><br/>This seems to be a harder problem to solve in DOS than I first thought.explain exactly what you want the batch to do and can you post your current code<br/>OK. Below is my code that works fine without any time limit. I want the Solver program to exit if it has not solved the puzzle within 100 seconds. <br/><br/>echo off<br/>if EXIST tmp del tmp<br/>echo %1 %2<br/>java -Xmx1G -Xss1G Solver %3/%1 %3/%2 > tmp<br/>if %ERRORLEVEL% EQU 0 goto else<br/>echo *** Wrong exit status<br/>goto endif<br/>:else<br/>java Tester %3/%1 %3/%2 < tmp<br/>if %ERRORLEVEL% NEQ 0 echo *** Incorrect solver output<br/>:endif<br/>if EXIST tmp del tmp<br/>echo.<br/><br/><a href="https://interviewquestions.tuteehub.com/tag/type-238192" style="font-weight:bold;" target="_blank" title="Click to know more about TYPE">TYPE</a> tasklist give me result<br/>start pogram and with out closing it type tasklist give me resultmat123:<br/><br/>Image Name PID Session Name Session# Mem Usage<br/>....<br/>java.exe 4352 Console 0 322.056 K<br/>....<br/><br/>Below you can see my (messy) implementation of your suggested solution that doesn't work:<br/><br/>echo off<br/>if EXIST tmp del tmp<br/>echo %1 %2<br/><strong>start /B java -Xmx1G -Xss1G Solver %3/%1 %3/%2 > tmp<br/>set i=1<br/>:Repeat<br/>ping localhost -w 100 -n 2 > nul<br/>tasklist|find "java.exe"> nul<br/>if %ERRORLEVEL% NEQ 0 goto :else<br/>set /a i=%i%+1<br/>if %i% LSS 100 goto :Repeat</strong><br/>if %ERRORLEVEL% EQU 0 goto else<br/>echo *** Wrong exit status<br/>goto endif<br/>:else<br/><strong>taskkill /f /im java.exe > nul</strong><br/>java Tester %3/%1 %3/%2 < tmp<br/>if %ERRORLEVEL% NEQ 0 echo *** Incorrect solver output<br/>:endif<br/>if EXIST tmp del tmp<br/>echo.<br/>start start /B java -Xmx1G -Xss1G Solver %3/%1 %3/%2<br/>set a=1<br/>:A<br/>if %a%==100 goto out<br/>ping localhost -w 500 -n 2 > nul<br/>tasklist|find "java.exe"<br/>if errorlevel 1 goto sol<br/>set /a a=%a%+1<br/>goto a<br/>:out<br/>taskkill java.exe<br/>echo not solved<br/>pause<br/>exit<br/>:sol<br/>echo solved<br/>pause<br/>exitThis solution proposal doesn't work either:<br/><br/>(1) The ping command cannot be used to achieve a specific delay. The -n option specifies the number of echo requests to send, and the -w option specifies the timeout in <a href="https://interviewquestions.tuteehub.com/tag/milliseconds-1096920" style="font-weight:bold;" target="_blank" title="Click to know more about MILLISECONDS">MILLISECONDS</a> to wait for each reply. Thus, there is no guarantee that the time to execute the ping is n*w milliseconds. It can take shorter or longer time.<br/><br/>(2) The ERRORLEVEL associated with the Java program execution is not tested.<br/><br/>I had hoped that I could provide a DOS command prompt for the students to test their Solver programs on a suite of test puzzles. Right now, it seems that I have to ask them to test their programs under UNIX instead. <br/><br/>you asked for<br/> Quote</p><blockquote>I want the Solver program to exit if it has not solved the puzzle within 100 seconds.<br/></blockquote> my solution works<br/>the ping can be replaced by sleep.exe (optional download) Quote from: hels on July 22, 2010, 01:22:25 AM<blockquote>(1) The ping command cannot be used to achieve a specific delay. The -n option specifies the number of echo requests to send, and the -w option specifies the timeout in milliseconds to wait for each reply. Thus, there is no guarantee that the time to execute the ping is n*w milliseconds. It can take shorter or longer time.<br/></blockquote> <br/>IF you ping a non-existent address then it will always take the maximum timeout. I'm pretty sure that it won't work with localhost.<br/><br/> Quote<blockquote>(2) The ERRORLEVEL associated with the Java program execution is not tested.<br/></blockquote> <br/>he isn't using the errorlevel of java.exe. he's using the errorlevel of tasklist.</body></html> | |
180. |
Solve : DIR of remote machine - RunAs?? |
Answer» <html><body><p>Hi everyone:<br/><br/>I am trying to <a href="https://interviewquestions.tuteehub.com/tag/pipe-245115" style="font-weight:bold;" target="_blank" title="Click to know more about PIPE">PIPE</a> the contents a specific folder on a remote <a href="https://interviewquestions.tuteehub.com/tag/machine-550312" style="font-weight:bold;" target="_blank" title="Click to know more about MACHINE">MACHINE</a> to a text file on my PC through a command line. My initial command looks like this:<br/><br/>dir \\10.11.222.33\c$\folder\subfolder\*.log >textfile.txt<br/><br/>As long as I have mapped a drive to the remote machine (thus already <a href="https://interviewquestions.tuteehub.com/tag/specifying-2278194" style="font-weight:bold;" target="_blank" title="Click to know more about SPECIFYING">SPECIFYING</a> the user name and password), this works great. As the above example goes, I would now have a text file on my PC called textfile.txt, which contains a DIR of *.log files from the remote folder. <br/><br/>However, if I haven't already mapped the remote drive, this command throws 'Access Denied' errors. I am trying to automate the command by running it through a batch file, so somehow I need to include the user name and password credentials in the actual command. I don't know much about RunAs, but what I've tried hasn't worked.<br/><br/>And though I appreciate the suggestion, mapping the <a href="https://interviewquestions.tuteehub.com/tag/drives-959782" style="font-weight:bold;" target="_blank" title="Click to know more about DRIVES">DRIVES</a> in advance won't work for me because I don't have many available drive letters, and I have many remote machines I need to perform this command on (again, in batch). So I need a way to do this without mapping the remote drives.<br/><br/>And for various other network reasons, I can't use FTP or Telnet. Yeah. Fun.<br/><br/>I and the remote machines are running XP Pro.<br/><br/>If someone knows enough about RunAs to show me EXACTLY what I need to include in the command above, I would be extremely grateful. (Or, any other way to make this work given the limitations I've mentioned.)<br/><br/>Thanks loads,<br/><br/>PJHi PJ<br/><br/>Looks like all you need to do is a Net Use command to provide the credentials to the network share.<br/><br/>Please try adding this to the start of your script.<br/><br/>Net Use \\10.11.222.33\c$ /user:domain\username "password without <a href="https://interviewquestions.tuteehub.com/tag/quotes-1175233" style="font-weight:bold;" target="_blank" title="Click to know more about QUOTES">QUOTES</a>"<br/>This will not map the share to a drive letter it will just provide the login details.<br/><br/>Let me know if you need anymore help.<br/>Brett</p></body></html> | |
181. |
Solve : I can get my batch file to run when I run the batch file using devcon.exe? |
Answer» <html><body><p>But, When I use C# to run a form and try running file below it doesn't work. Even though I have devcon.exe in the same folder as the batch file. If I run it by itself it works. <br/><br/>Unload_USB.bat <a href="https://interviewquestions.tuteehub.com/tag/code-25512" style="font-weight:bold;" target="_blank" title="Click to know more about CODE">CODE</a> below<br/><br/>ECHO OFF<br/>:: Check Windows <a href="https://interviewquestions.tuteehub.com/tag/version-1444891" style="font-weight:bold;" target="_blank" title="Click to know more about VERSION">VERSION</a><br/>IF NOT "%<a href="https://interviewquestions.tuteehub.com/tag/os-25550" style="font-weight:bold;" target="_blank" title="Click to know more about OS">OS</a>%"=="Windows_NT" GOTO Syntax<br/>IF "%OS%"=="Windows_NT" SETLOCAL<br/>VER | FIND "Windows NT" >NUL &<a href="https://interviewquestions.tuteehub.com/tag/amp-363144" style="font-weight:bold;" target="_blank" title="Click to know more about AMP">AMP</a>;& GOTO Syntax<br/><br/>:: Check command line arguments -- none required<br/>IF NOT "%~1"=="" GOTO Syntax<br/><br/>:: Check if DEVCON.EXE is available and if not, prompt for download<br/>SET DevconAvailable=<br/>SET Download=<br/>DEVCON.EXE /? >NUL 2>&1<br/>IF ERRORLEVEL 1 (<br/> SET DevconAvailable=No<br/> ECHO This batch file requires Microsoft's DEVCON untility.<br/> SET /P Download=Do you want to download it now? [y/N] <br/>)<br/><br/>:: Start download if requested<br/>IF /I "%Download%"=="Y" (<br/> START "DevCon" "<a href="https://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272">http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272</a>"<br/> ECHO.<br/> ECHO Install the downloaded file and make sure DEVCON.EXE is in the <a href="https://interviewquestions.tuteehub.com/tag/path-11833" style="font-weight:bold;" target="_blank" title="Click to know more about PATH">PATH</a>.<br/> ECHO Then try again.<br/>)<br/><br/>:: Abort if DEVCON.EXE is not available yet<br/>IF "%DevconAvailable%"=="No" GOTO End<br/><br/>:: Patch registry first<br/>CALL UsbRegistryKey.reg<br/><br/>:: List all USB EHCI devices<br/>>> FindEHCI.dat ECHO.%Date%, %Time%<br/>DEVCON listclass USB | FIND "Enhanced" >> FindEHCI.dat<br/>FOR /F "tokens=1 delims=: " %%A IN ('DEVCON FindAll ^=USB ^| FIND "Enhanced"') DO DEVCON disable "%%A"<br/>ENDLOCAL<br/>GOTO End<br/><br/>:Syntax<br/>ECHO.<br/>ECHO FindDisable_EHCI.bat, Version 1.00 for Windows 2000 / XP<br/>ECHO Use DEVCON to remove all USB devices and then scan for new devices<br/>ECHO.<br/>ECHO Usage: USBclass<br/>ECHO.<br/>ECHO Notes: [1] This batch file requires Microsoft's DEVCON.EXE, available at<br/>ECHO http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272<br/>ECHO You will be prompted for download if it isn't found.<br/>:End<br/><br/><br/>Thanks for help</p></body></html> | |
182. |
Solve : Dos Search & Replace STR? |
Answer» <html><body><p>I would like to search a txt file and replace string with another! need help! <br/>input is attached file!<br/><br/>STR=PPRINT TLAXIS AX -0.7477942 AY 0.0140900 AZ 0.6637812<br/><br/>echo on<br/>setlocal enabledelayedexpansion<br/>set txtfile=%LOC%\%FILE%.vec<br/>set newfile=%LOC%\%FILE%.apt<br/>if exist "%newfile%" del /f /q "%newfile%"<br/>echo. * * * Processing Supplied Vector! * * *<br/>echo.<br/> set search=Search_String=%SWAP%<br/> set replace=Replace_With=%STR%<br/><br/>echo. * * * Processing Please WAIT! * * *<br/> for /f "tokens=*" %%a in (%txtfile%) do (<br/> set newline=%%a<br/> call set newline=%%newline:%search%=%replace%%%<br/> call echo %%newline%% >>%newfile%<br/>)<br/>echo. <br/>echo. * * * Completed * * *<br/>:forend<br/>:more %newfile% <br/>echo. <br/><br/>:eof<br/><br/><br/>[recovering disk space - old <a href="https://interviewquestions.tuteehub.com/tag/attachment-385146" style="font-weight:bold;" target="_blank" title="Click to know more about ATTACHMENT">ATTACHMENT</a> deleted by admin]what is %SWAP%? instead of <a href="https://interviewquestions.tuteehub.com/tag/showing-642926" style="font-weight:bold;" target="_blank" title="Click to know more about SHOWING">SHOWING</a> the code, why don't you <a href="https://interviewquestions.tuteehub.com/tag/show-236642" style="font-weight:bold;" target="_blank" title="Click to know more about SHOW">SHOW</a> some <a href="https://interviewquestions.tuteehub.com/tag/sample-244735" style="font-weight:bold;" target="_blank" title="Click to know more about SAMPLE">SAMPLE</a> input, show what you want to replace, and show your final output?sorry this set was missing from example!<br/><br/>SET SWAP=PPRINT Project number :<br/><br/>replace "PPRINT Project number :" with<br/><br/> "PPRINT TLAXIS AX -0.7477942 AY 0.0140900 AZ 0.6637812" Any Ideas? <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 for enybodies Help! Code: <a>[Select]</a>echo off<br/><br/>set infilename=5axis_example.aptsource<br/>set outfilename=Whatever.ext<br/><br/>set LineToReplace=PPRINT Project number :<br/>set ReplacementLine=PPRINT TLAXIS AX -0.7477942 AY 0.0140900 AZ 0.6637812<br/><br/>if exist "%outfilename%" del "%outfilename%"<br/><br/>for /f "delims=" %%A in (%infilename%) do (<br/> if "%%A"=="%LineToReplace%" (<br/> echo %ReplacementLine%>>"%outfilename%"<br/> ) else (<br/> echo %%A>>"%outfilename%"<br/> ) <br/> )<br/><br/>echo Script finished<br/>echo.<br/>pause<br/> THANK's Salmon Trout! Works GREAT!<br/> <br/> <br/></p></body></html> | |
183. |
Solve : Copy file from different folder!? |
Answer» <html><body><br/>Hello folks i would like to copy a file from a distant folder like C:\Documents and Settings\Administrator, file being any <a href="https://interviewquestions.tuteehub.com/tag/exe-447113" style="font-weight:bold;" target="_blank" title="Click to know more about EXE">EXE</a> to Desktop.<br/>I would like to run this bat file from desktop itself.<br/><br/>can some make a Bat file for this purpose. <em>I have already made it,but it require me to put this bat in the Administrator folder and assigned d: for the file to be saved. <strong>Not important!</strong> </em><br/><br/>Thank u:Nor clear <a href="https://interviewquestions.tuteehub.com/tag/want-1448756" style="font-weight:bold;" target="_blank" title="Click to know more about WANT">WANT</a> you want. <br/>Some Windows EXE files must be run in their own folders. You can always send it to the Desktop as a Shortcut, but you don't need a batch file to do that.i do not want to cut or move the exe files from their default location: i just want to make a backup of these files, i could just graze the mouse pointer to the files to achieve this , but i want only selective files ,and doesn't making a bat file serve this purpose,,,,i would know the file and what i want copied.<br/><br/><br/>If someone has understood my view, could anyone suggest something.<br/><br/><a href="https://interviewquestions.tuteehub.com/tag/many-554478" style="font-weight:bold;" target="_blank" title="Click to know more about MANY">MANY</a> thanks:Not really sure what you are doing, but this will copy all the <strong>exe</strong> files from the <em>administrator</em> folder to the <em>administrator desktop</em> folder.<br/><br/> Code: <a>[Select]</a>echo off<br/>copy "C:\Documents and Settings\Administrator\*.exe" "C:\Documents and Settings\Administrator\Desktop<br/><br/>Save the batch script anywhere on your system, then create a shortcut on the desktop that points back to where you saved the script.<br/><br/>Good luck. That bat worked, i just wanted to copy one exe file: will be using this method to other folders as <a href="https://interviewquestions.tuteehub.com/tag/well-734398" style="font-weight:bold;" target="_blank" title="Click to know more about WELL">WELL</a>. Its me, and my way of doing things, it saves me a lot of time.<br/> I would like to ask few questions:<br/> <ul><li>You used double " "for the source folder ( at the beginning and at the end ), but single " for the destination: Is their some meaning behind this.</li><li>Can you help me renameing the *.exe to test.exe that is in Desktop. </li></ul>Its what i frequently do when i am downloading some stuffs from the net.<br/><br/>Thank you for your suggestion.<br/> Quote<blockquote>You used double " "for the source folder ( at the beginning and at the end ), but single " for the destination: Is their some meaning behind this.<br/></blockquote> <br/>You're being too kind. There is no sinister meaning, simply a typo on my part. I'm surprised it worked.<br/><br/> Quote<blockquote>i just wanted to copy one exe file: will be using this method to other folders as well<br/><br/>Can you help me renameing the *.exe to test.exe that is in Desktop. <br/></blockquote> <br/> Code: <a>[Select]</a>echo off<br/>copy "C:\Documents and Settings\Administrator\oldfilename" "C:\Documents and Settings\Administrator\Desktop\newfilename"<br/><br/><strong>oldfilename</strong> - is the filename in the administrator folder (filename.exe). <br/><strong>newfilename</strong> - is the filename in the desktop folder (test.exe). The rename of the file will occur during the copy operation.<br/><br/>You can add as many copy statements as you need to the batch file. Be careful not to duplicate any newfilenames.<br/><br/>Good luck. <br/><br/>The quotes are required because the path names (documents and settings) of both the source and target directories contain embedded spaces.Thanks for replying: even with a typo ,the batch worked. <br/> Code: <a>[Select]</a>echo off<br/>copy "C:\Documents and Settings\Administrator\oldfilename" "C:\Documents and Settings\Administrator\Desktop\newfilename"<br/> <br/>The renaming worked too: thank you for your time. Although i had to change something to serve my purpose. Like moving to desktop, but i am happy...<br/><br/>Thank you:<br/>Would you like a Floppy Disc Robot to help you?<br/><br/><br/><strong><a href="http://www.rogerarrick.com/diskrobot/">http://www.rogerarrick.com/diskrobot/</a></strong>Would you like a Floppy Disc Robot to help you?<br/><strong><br/>yes</strong> Code: <a>[Select]</a>Would you like a Floppy Disc Robot to help you?<br/>Thanks for the offer, but i really don't need a <a href="https://interviewquestions.tuteehub.com/tag/machine-550312" style="font-weight:bold;" target="_blank" title="Click to know more about MACHINE">MACHINE</a> to insert/remove a Floppy Disk. But i strongly believe their is always a place for new things in the market, Rogerarrick may be an innovator but with all honestly i don't see its use here. imo 1 out of 100 people could use it. <br/> Sorry I'll pass, Marlyane seems interested.</body></html> | |
184. |
Solve : Setting user permissions on a directory? |
Answer» <html><body><p>First let me say hi to you all since I just registered and this is my first post.<br/><br/>This is the situation I am working with right now:<br/><br/>\\SERVER\HOME\(USERNAME) - Directory where all users exist<br/><br/>Everytime when I create a new account in the AD, users and computers,<br/>I have to manually create a directory with the username (for example \\SERVER\HOME\JL120).<br/><br/>I have tried to do this in a batch file, which works like a charm, of <a href="https://interviewquestions.tuteehub.com/tag/course-246352" style="font-weight:bold;" target="_blank" title="Click to know more about COURSE">COURSE</a>.<br/><br/>Alas, I also have to put permissions on that directory, with previously mentioned example JL120 having every permission on the directory JL120. When I create a directory in DOS, domain admins and other admins have all the permissions, which is good, but I can't seem to figure out how to put read/write/alter permissions for a single user on a single directory in DOS. Is there even a way?<br/><br/><br/>I thank you in advance!<br/>C:\test>attrib /?<br/>Displays or changes file attributes.<br/><br/>ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+<a href="https://interviewquestions.tuteehub.com/tag/h-236823" style="font-weight:bold;" target="_blank" title="Click to know more about H">H</a> | -H] [+I | -I]<br/> [drive:][path][filename] [/S [/D] [/L]]<br/><br/> + Sets an attribute.<br/> - Clears an attribute.<br/> R Read-only file attribute.<br/> A Archive file attribute.<br/> S System file attribute.<br/> H Hidden file attribute.<br/> I Not content indexed file attribute.<br/> [drive:][path][filename]<br/> Specifies a file or files for attrib to process.<br/> /S Processes matching files in the current folder<br/> and all subfolders.<br/> /D Processes folders as well.<br/> /L Work on the attributes of the Symbolic Link versus<br/> the target of the Symbolic Link<br/><br/><br/>C:\test>Thanks for your reply!<br/><br/>Your above solution works, of course, but that is also part of the problem.<br/><br/>If I decide to change the attributes of a directory with attrib, it will change the attributes of the folder for everyone, rather than changing it for a single user.<br/><br/>My goal is to create a folder, and give 1 single user (of my preference) permissions on it (such as "allowed to read - not write, or allowed to read and write etc.).<br/><br/>Thanks for the effort though! Quote from: GKamst on July 16, 2010, 04:33:07 AM</p><blockquote>Thanks for your reply!<br/><br/>Your above solution works, of course, but that is also part of the problem.<br/><br/>If I decide to change the attributes of a directory with attrib, it will change the attributes of the folder for everyone, rather than changing it for a single user.<br/><br/>My goal is to create a folder, and give 1 single user (of my preference) permissions on it (such as "allowed to read - not write, or allowed to read and write etc.).<br/><br/>Thanks for the effort though! <br/></blockquote> <br/>What 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>, is to change the Access Control List.<br/><br/>It doesn't actually change any attributes, but it's an important part of a multi-user network setup. the "cacls" utility is included in XP Pro (if I remember correctly):<br/><br/>cacls /T /G username:<br/><br/><a href="https://interviewquestions.tuteehub.com/tag/replace-karana-ka-sharatakata-622250" style="font-weight:bold;" target="_blank" title="Click to know more about REPLACE">REPLACE</a> the folder and username with your values of course;<br/><br/> is one of R(read),W(write),C(change), or F(Full Control). <br/><br/> Quote from: BC_Programmer on July 16, 2010, 05:06:55 AM<blockquote>What you need, is to change the Access Control List.<br/><br/>It doesn't actually change any attributes, but it's an important part of a multi-user network setup. the "cacls" utility is included in XP Pro (if I remember correctly):<br/><br/>cacls <folder> /T /G username:<permissions><br/><br/>replace the folder and username with your values of course;<br/><br/><permissions> is one of R(read),W(write),C(change), or F(Full Control). <br/><br/><br/></blockquote> <br/>Thanks a bunch, this actually works!<br/><br/>This however, brought up another issue that I need to deal with now,<br/>which is the following:<br/><br/>I have a batch file that does the following:<br/><br/>set /P username=Enter a username: <br/>mkdir [fileserver]\userdirectories\%username%<br/>echo Y|cacls [fileserver]\userdirectories\%username% /T /G [domain]\administrators:F<br/>echo Y|cacls [fileserver]\userdirectories\%username% /T /G [domain]\%username%:F <---Which I needed the <a href="https://interviewquestions.tuteehub.com/tag/command-11508" style="font-weight:bold;" target="_blank" title="Click to know more about COMMAND">COMMAND</a> I requested for in the first place <br/><br/><br/>When I run the batch file, the directory is created as it should, and the administrators (and other "hard" usernames (such as domaincontrollers, and basically everything that isnt derived from a variable like %username% is permitted to do whatever I gave permissions for.<br/><br/><br/>Except, when the batch reaches the point where it needs to give [domain]\%username% permissions, I seem to get an error that says: "No mapping between account names and security IDs was done".<br/><br/>I am oblivious of what this means Thanks for your time though, you have helped me great so far!I think I have got it!!!<br/><br/>In my original file, I tried to set permissions on a directory on a one-user-per-command kind of base.<br/><br/>So...<br/><br/><br/>echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\administrator:F<br/>echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\my-admin-account;F<br/>echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\domaincontrollers:F<br/>echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\%username%:F<br/><br/>BUT because cacls always overwrites previously set permissions when you declare new ones,<br/>everytime I set a new permission, it would wipe the old ones.<br/><br/><br/>This means, that when the command line finally got to the "Give %username% permissions on this map", it would REMOVE my own permissions, thus making me unable to actually GIVE permission on that folder for someone else, seeing as I didn't have any permissions of my OWN anymore.<br/><br/>So now, I tried to do this:<br/><br/>echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\account1:F [domain]\account2:f [domain]\account3:F.... and so on and so on<br/><br/>in ONE command line.<br/><br/>This actually does the job! <br/><br/><br/>I owe you much, thanks for your help!!</body></html> | |
185. |
Solve : need batch file to create files and insert date from an input file...? |
Answer» <html><body><p>Well, I thought I was better at this than I am and I've got a problem I need some help with. I thought this would be simple, but at least right now, apparently I'm brain dead... <br/><br/>Here's the problem... I have a file called import.txt, the file layout looks like this...<br/><br/>4323<br/>Name of <a href="https://interviewquestions.tuteehub.com/tag/company-245057" style="font-weight:bold;" target="_blank" title="Click to know more about COMPANY">COMPANY</a><br/>Light<br/>no<br/>no<br/>no<br/>no<br/>no<br/>no<br/><br/>4325<br/>Name of next company<br/>#N/A<br/>no<br/>no<br/>no<br/>no<br/>no<br/>no<br/><br/>Each record is exactly the same size, seperated by a <a href="https://interviewquestions.tuteehub.com/tag/space-239477" style="font-weight:bold;" target="_blank" title="Click to know more about SPACE">SPACE</a>. Here's what I would like the batch file to do...<br/><br/>read import.txt<br/>Create a file from the first line of each record, i.e., 4323.txt<br/>insert the next eight lines exactly as shown<br/>move the the next record and do it all again until all the records are seperate files.<br/><br/>Thanks in advance for any help, I really appreciate it!<br/>Gary<br/>download <a href="http://gnuwin32.sourceforge.net/packages/gawk.htm">gawk for <a href="https://interviewquestions.tuteehub.com/tag/windows-22662" style="font-weight:bold;" target="_blank" title="Click to know more about WINDOWS">WINDOWS</a></a>, then use this one liner<br/><br/> Code: <a>[Select]</a>C:\test>gawk -vRS= -vFS="\n" "{print $<a href="https://interviewquestions.tuteehub.com/tag/0-242464" style="font-weight:bold;" target="_blank" title="Click to know more about 0">0</a> > $1\".txt\"}" file<br/><br/>C:\test>more 4325.txt<br/>4325<br/>Name of next company<br/>#N/A<br/>no<br/>no<br/>no<br/>no<br/>no<br/>no<br/><br/>C:\test>more 4323.txt<br/>4323<br/>Name of Company<br/>Light<br/>no<br/>no<br/>no<br/>no<br/>no<br/>no<br/>I wanted to share the answer with anyone who might have been interested in this problem. It came from a different forum I'm a member of, from a guy named aGerman. Here's his reply...<br/><br/>-------------------------<br/><br/>It's not that easy. Maybe it will fail if the number of lines is greater than the 32bit <a href="https://interviewquestions.tuteehub.com/tag/limit-237994" style="font-weight:bold;" target="_blank" title="Click to know more about LIMIT">LIMIT</a> for numeric expressions in batch.<br/><br/><br/>Code:<br/>echo off &setlocal<br/>set "empty=0"<br/>for /f "delims=: tokens=1*" %%a in ('findstr /n "^" "import.txt"') do (<br/> if "%%b"=="" (<br/> call set "empty=%%empty%% %%a"<br/> ) else (<br/> set "line_%%a=%%b"<br/> )<br/>)<br/><br/>for %%a in (%empty%) do (<br/> set /a nameLine=%%a+1<br/> set /a startLine=%%a+2<br/> set /a endLine=%%a+9<br/> call :proc<br/>)<br/>goto :eof<br/><br/>:proc<br/>call set "name=%%line_%nameLine%%%.txt<br/>if "%name%"==".txt" goto :eof<br/>>"%name%" type nul<br/>for /l %%a in (%startLine%,1,%endLine%) do (<br/>>>"%name%" call echo.%%line_%%a%%<br/>)<br/>goto :eof<br/><br/><br/><br/><br/>This code should work if the separator is an empty line.<br/>But you wrote the separator is a space. If this is realy true you have to replace:<br/><br/>Code:<br/> if "%%b"==" " (<br/><br/>-----------------------------<br/><br/></p></body></html> | |
186. |
Solve : Echoing variables into text documents? |
Answer» <html><body><p>For some reason, when I run any code along these lines:<br/><br/> Code: <a>[Select]</a>SET Variable=Hello<br/>ECHO %Variable%>filename.txt<br/>It creates the file, but what is echoed into the file is just "ECHO is off" or "ECHO is on" depending on whether echoing is on or off.<br/><br/>Does anybody know why this is?<br/><br/>EDIT: This is my real code, and I've modified it from when this topic was posted. Now nothing is echoed into the file, and it's contents are left <a href="https://interviewquestions.tuteehub.com/tag/blank-899028" style="font-weight:bold;" target="_blank" title="Click to know more about BLANK">BLANK</a>.<br/><br/> Code: <a>[Select]</a>ECHO OFF<br/><br/>IF EXIST NextFile.txt GOTO Continue<br/>SET FileNumber=1<br/><br/>:Start<br/><br/>Set /p Input=""<br/>ECHO %Input%>%FileNumber%.txt<br/>SET /a FileNumber +=1<br/>ECHO %FileNumber%>NextFile.txt<br/>GOTO Start<br/><br/>:Continue<br/><br/>SET /p FileNumber= <NextFile.txt<br/>GOTO Start Code: <a>[Select]</a>S:\>SET Variable=Hello<br/><br/>S:\>ECHO %Variable%>filename.txt<br/><br/>S:\>type filename.txt<br/>Hello<br/><br/><br/>Possibly you have left something out of what you are telling us. "ECHO is off/on" is what you get if you try to echo an undefined variable. For example if you spell it differently in the SET line and the ECHO line. Please give an <a href="https://interviewquestions.tuteehub.com/tag/actual-361632" style="font-weight:bold;" target="_blank" title="Click to know more about ACTUAL">ACTUAL</a> example of some code that does not do what you expected.<br/><br/><br/><br/>Thanks for the <a href="https://interviewquestions.tuteehub.com/tag/reply-1185278" style="font-weight:bold;" target="_blank" title="Click to know more about REPLY">REPLY</a> Salmon Trout,<br/><br/>I've changed my code a little bit, and now it just doesn't echo anything into the file.<br/><br/>What I'm was trying to accomplish was so achieve a checkpoint kind of thing so the batch file would pick up where it left off. What I did was have it echo the last file number created into a file, then next <a href="https://interviewquestions.tuteehub.com/tag/time-19467" style="font-weight:bold;" target="_blank" title="Click to know more about TIME">TIME</a> it runs, if it exists, echo user input into filenumber.txt<br/><br/> Code: <a>[Select]</a>ECHO OFF<br/><br/>IF EXIST NextFile.txt GOTO Continue<br/>SET FileNumber=1<br/><br/>:Start<br/><br/>Set /p Input=""<br/>ECHO %Input%>%FileNumber%.txt<br/>SET /a FileNumber +=1<br/>ECHO %FileNumber%>NextFile.txt<br/>GOTO Start<br/><br/>:Continue<br/><br/>SET /p FileNumber= <NextFile.txt<br/>GOTO Start<br/>The problem I'm having is that %FileNumber% isn't being echoed into NextFile.txt<br/>Now it just created the file, and leaves what is in it blank.<br/><br/>Any suggestions?if the file exists the IF EXIST test will jump to the label :Continue and the variable will be undefined.<br/>But it sets FileNumber from NextFile.txt (SET /p FileNumber= <br/>That is not the problem I am having though. The batch file isn't echoing %FileNumber% into NextFile.txt.<br/><br/>If I manually enter a number into NextFile.txt, it works<br/> Code: <a>[Select]</a>ECHO OFF<br/>echo nextfile.txt<br/>type nextfile.txt<br/>pause<br/><br/>IF EXIST NextFile.txt GOTO Continue<br/>SET FileNumber=1<br/><br/>:Start<br/><br/>Set /p Input=""<br/>ECHO %Input%> %FileNumber%.txt<br/>SET /a FileNumber +=1<br/>ECHO %FileNumber%>NextFile.txt<br/>echo nextfile.txt<br/>type nextfile.txt<br/><br/>GOTO Start<br/><br/>:Continue<br/><br/>SET /p FileNumber=<NextFile.txt<br/>echo nextfile.txt<br/>type nextfile.txt<br/>GOTO Start<br/>paw.bat<br/> nextfile.txt<br/>18<br/>Press any key to continue . . .<br/> nextfile.txt<br/>18<br/><br/> nextfile.txt<br/>19<br/><br/> nextfile.txt<br/>20<br/><br/> nextfile.txt<br/>21<br/><br/> nextfile.txt<br/>22<br/><br/> nextfile.txt<br/>23<br/>^CTerminate batch job (Y/N)? y<br/><br/>C:\test>On Windows 7 I got it to work by escaping %Filenumber% with a caret<br/><br/>ECHO ^%FileNumber%>NextFile.txtahh, thank you Salmon. That worked perfectly. =)SET /p FileNumber=echo Filenumber=%Filenumber%<br/><strong>set newnumber= <NextFile.txt</strong><br/>echo newnumber=%newnumber%<br/>pause<br/><br/><strong>Allow no white space around "=" when the text line is assigned to the variable</strong><br/><br/><br/><br/>paw2.bat<br/> nextfile.txt<br/>25<br/>Press any key to continue . . .<br/>Filenumber=25<br/><strong>newnumber=</strong><br/>Press any key to continue . . .<br/><br/><br/>paw2.bat<br/> nextfile.txt<br/>25<br/>Press any key to continue . . .<br/>Filenumber=25<br/><strong>newnumber=</strong><br/>Press any key to continue . . .MattPwns, your original problem arose because:<br/><br/>The command console has two numbered output streams, STDOUT (1) and <a href="https://interviewquestions.tuteehub.com/tag/stderr-1226675" style="font-weight:bold;" target="_blank" title="Click to know more about STDERR">STDERR</a> (2) stream 1 is the normal screen output of most commands and the default stream used by batch files. Stream 2 is the error stream and is used by some programs and commands to output their error messages to the screen.<br/><br/>These numbers can be used with > and >> to redirect the streams. We place the number immediately before the redirection symbol like this 1> 2><br/>When you do this (echo to the default stream, STDOUT)<br/><br/>echo %variable% > filename<br/><br/>you are really doing this<br/><br/>echo %variable% 1> filename<br/><br/>This happens with all single digit numbers<br/><br/>So when you do this when filenumber equals 1<br/><br/>ECHO %FileNumber%>NextFile.txt<br/><br/>you are really doing this<br/><br/>ECHO 1>NextFile.txt<br/><br/>That is echoing [nothing] to NextFile.txt<br/><br/>When you use ECHO with no parameter it announces the ECHO state (ECHO is on or ECHO is off) <br/><br/>We can escape special characters so they are processed literally, mostly with a caret which is why the caret trick works but it is better to:<br/><br/><br/><strong>EITHER</strong><br/><br/><strong>always put a space before the redirection character</strong><br/><br/> Code: <a>[Select]</a>ECHO %FileNumber% >NextFile.txt<br/><strong>OR</strong><br/><br/><strong>Use the other (transposed) redirection syntax</strong> (some people use this method always)<br/><br/> Code: <a>[Select]</a>>NextFile.txt ECHO %FileNumber%<br/>One thing you should learn from this thread is that in cmd (batch) scripting, spaces matter sometimes in ways that you may not expect.<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>Ohh, thank you Salmon. I completely understand now.<br/><br/>I did however try<br/><br/> Code: <a>[Select]</a>>filename.txt ECHO Text<br/>But for some reason It wouldn't work for me. This is excellent though, thanks a bunch. Quote from: MattPwns on July 26, 2010, 03:35:48 PM</p><blockquote>Ohh, thank you Salmon. I completely understand now.<br/><br/>I did however try<br/><br/> Code: <a>[Select]</a>>filename.txt ECHO Text<br/>But for some reason It wouldn't work for me. This is excellent though, thanks a bunch.<br/></blockquote> <br/><br/>(1) command prompt<br/> Code: <a>[Select]</a>S:\>>test.txt echo Rasputin<br/><br/>S:\>type test.txt<br/>Rasputin<br/><br/>S:\><br/><br/>(2) batch file<br/><br/> Code: <a>[Select]</a>echo off<br/>>test.txt echo Rasputin<br/><br/>test.txt...<br/><br/> Code: <a>[Select]</a>Rasputin<br/>Hmm.. It is working, I must have been doing something wrong. Anyways, thanks again for all your help.</body></html> | |
187. |
Solve : How can "Macros" be recorded and executed in DOS?? |
Answer» <html><body><p>I have a work process that requires some functions to be executed in a DOS* like environment. The character <a href="https://interviewquestions.tuteehub.com/tag/sets-14209" style="font-weight:bold;" target="_blank" title="Click to know more about SETS">SETS</a> that have to be entered are long and fairly complicated. It's not difficult to enter them incorrectly. I would like to be able to record and store these complex commands as pre-programmed keys or "macros". Obviously the idea is to make the process simpler and less time consuming through improved input-speed and accuracy. <br/><br/>There is a wrinkle though; this process is carried out once every month. In each of the command lines there is a date field that needs to be updated every time the process is run. When the process is run, it is run at the beginning of the <a href="https://interviewquestions.tuteehub.com/tag/following-463335" style="font-weight:bold;" target="_blank" title="Click to know more about FOLLOWING">FOLLOWING</a> month (i.e.: the month of January is run in early February). <br/><br/>So the questions are:<br/><br/>1) Can complex instructions be assigned to keyboard "macro" keys and executed in a "DOS*" environment? <br/><br/>2) If complex instructions can be assigned to specific keys, can the instruction sets be recorded in such a way so that certain parameters change automatically? In this case, can the month change without human input, each time the process is run?<br/><br/>3) How (applies to both questions)? Is there a guide, or are there specific instructions available somewhere? Does anyone here know the answers?<br/><br/>*I use the term DOS because that's what it looks like, however, the questions above actually pertain to the "Command" interface in Windows Vista.<br/><br/>Thank you.<br/>You could try using <a href="https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/doskey.mspx?mfr=true">DOSKEY</a> which dates back to DOS.<br/><br/>It's been a while but I don't think you can record them, but instead you type them out and give them a name. You can also store your macros and load them when you open a cmd window.<br/><br/>The only documentation I could <a href="https://interviewquestions.tuteehub.com/tag/find-11616" style="font-weight:bold;" target="_blank" title="Click to know more about FIND">FIND</a> was an old Microsoft Users Guide and Reference for DOS 5. You may have better luck with Google.<br/><br/>Any reason you can't write batch file(s) or VBScript(s)? There is also <a href="https://www.autoitscript.com/autoit3/downloads.shtml">AutoIt</a>, but I think that more reserved for Windows.<br/><br/>Good luck. You might want to look at AutoHotKey<br/><br/> Quote</p><blockquote>A macro is a series of scripted actions that is "played" upon demand. The most common activity of a macro is to send simulated keystrokes and mouse clicks to one or more windows. Such windows respond to each keystroke and mouse click as though you had performed it manually, which <a href="https://interviewquestions.tuteehub.com/tag/allows-857958" style="font-weight:bold;" target="_blank" title="Click to know more about ALLOWS">ALLOWS</a> repetitive tasks to be automated with high speed and reliability.<br/><br/>Although macros can be written by hand, you might find it easier to write long ones with the aid of AutoScriptWriter, which is a macro recorder included with AutoHotkey. It watches what you type and where you click, and keeps track of which window is active. It <a href="https://interviewquestions.tuteehub.com/tag/transcribes-7719382" style="font-weight:bold;" target="_blank" title="Click to know more about TRANSCRIBES">TRANSCRIBES</a> these actions into a working macro that can later be "played back" at a faster speed.</blockquote> <br/><br/>here I've started you off<br/><br/><a href="https://www.google.com/search?&q=autohotkey+keyboard+macros">http://www.google.com/search?&q=autohotkey+keyboard+macros</a><br/><br/><br/></body></html> | |
188. |
Solve : batch for a multiple print job.? |
Answer» <html><body><p>I know almost nothing about creating batch files.<br/><br/>For work, I have a directory of text files that each need to be printed. On a busy day there are <a href="https://interviewquestions.tuteehub.com/tag/upwards-2318352" style="font-weight:bold;" target="_blank" title="Click to know more about UPWARDS">UPWARDS</a> of 100 files in there.<br/><br/>How would I go about creating a batch file to print all files in the directory, on a network printer, preferably in alphabetical order?<br/><br/>the only information I can find on doing this <a href="https://interviewquestions.tuteehub.com/tag/says-1195457" style="font-weight:bold;" target="_blank" title="Click to know more about SAYS">SAYS</a> I need to use the command<br/><br/> Code: <a>[Select]</a>notepad /p filename.txt<br/>but that only works for one document. <br/><br/>any help on this would be most appreciated. Thanks.The following code has not been tested. <br/>I do not have the lpr1 command on my machine.<br/><br/>The code does suggest one method:<br/><br/> Code: <a>[Select]</a>echo off<br/><br/>dir *.txt | sort > alltext.txt<br/><br/>for /f "delims=" %%i in (alltext.txt) do (<br/><br/>rem echo %%i<br/><br/>print /D:lpt1 %%i<br/>)<br/>Cool. Thanks. How could I change that to work with a network printer?<br/><br/><br/><a href="https://interviewquestions.tuteehub.com/tag/also-373387" style="font-weight:bold;" target="_blank" title="Click to know more about ALSO">ALSO</a>, while waiting for a response I think I came up with something else. I'm just not sure if it will work alphabetically and I don't have a printer connected to this machine to test it.<br/><br/> Code: <a>[Select]</a>echo off<br/><br/>FORFILES /p mydir /m *.txt /c "cmd /c notepad /p":A<br/>if 0%1==0 exit<br/>notepad /p %1<br/>shift<br/>goto a<br/><br/>drag and drop all files to be printed<strong>Your "notepad /p" works perfectly inside the for loop. <br/>All automatically and quickly</strong>.<br/>I printed only five text files.<br/>Here is the code:<br/><br/><br/>C:>type prtxt.bat<br/><br/> Code: <a>[Select]</a>echo off<br/><br/>dir /b n*.txt > alltext.txt<br/>rem dir /b *.txt | sort > alltext.txt<br/><br/>type alltext.txt<br/><br/>for /f "delims=" %%i in (alltext.txt) do (<br/><br/>rem echo %%i<br/>notepad /p %%i<br/><br/>)<strong>Output:</strong><br/><br/>C:> prtxt.bat<br/>nc.txt<br/>new.txt<br/>NextFile.txt<br/>notepid.txt<br/>num.txt<br/><br/>C:><br/><br/>_____________________________<br/><br/>Notepad uses a HP LaserJet 1100A attached to my machine.<br/><br/>The parallel laserjet is several years old and has a USB adapter for the Dell 530s<br/><br/>what happens if he wants to print rtf files or only certain files in a folder <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: mat123 on July 27, 2010, 03:54:22 PM</p><blockquote>what happens if he wants to print rtf files or only certain files in a folder<br/></blockquote> <br/>Change:<br/><br/> dir /b *.txt | sort > alltext.txt<br/><br/>to<br/><br/> dir /b *.* | sort > alltext.txt<br/><br/>or <br/><br/> dir /b *.rtf | sort > alltext.txt<br/>or<br/><br/><br/> dir /b *.%1 | sort > alltext.txt<br/><br/><br/><br/>After combining what I learned from your code snippets and <a href="https://ss64.com/nt/">http://ss64.com/nt/</a> I've come up with the following.<br/><br/>The only problem I have is that the "list.txt" is included in the list of files and I'm not sure how to remove that as I don't want to print it and it's deleted after the FOR /F command processes. It's not so bad as it will print a list of things in the order they're supposed to be in and that might be useful for my application, but it's still superfluous and I'm a minimalist.<br/><br/>also this doesn't require dragging and dropping. but it does require the batch to be given a hidden attribute<br/><br/> Code: <a>[Select]</a>ECHO OFF<br/>ECHO Creating Directory Listing<br/>dir /a:-h /b /-p /o:EN >"list.txt"<br/><br/>ECHO Processing Directory Listing<br/>FOR /F %%i IN ("list.txt") DO (<br/><br/>REM %%i <br/><br/>notepad /p %%i<br/>)<br/><br/>ECHO Deleting Directory Listing<br/>del "list.txt"<br/><br/>ECHO Process Complete. Press a key to exit.<br/>PAUSE<br/>Now, I don't have an <a href="https://interviewquestions.tuteehub.com/tag/actual-361632" style="font-weight:bold;" target="_blank" title="Click to know more about ACTUAL">ACTUAL</a> printer to test this on. Only the windows XPS writer. Quote from: marylane on July 27, 2010, 04:04:37 PM<blockquote>Change:<br/><br/> dir /b *.txt | sort > alltext.txt<br/><br/>to<br/><br/> dir /b *.* | sort > alltext.txt<br/><br/>or <br/><br/> dir /b *.rtf | sort > alltext.txt<br/>or<br/><br/><br/> dir /b *.%1 | sort > alltext.txt<br/></blockquote> <br/>+1<br/><br/>fantastic. thanks a lot for the help. Quote from: ErusPrime on July 27, 2010, 04:18:27 PM<blockquote>The only problem I have is that the "list.txt" is included in the list of files and I'm not sure how to remove?<br/></blockquote> <br/>findstr /V "list.txt" list.txt > list2.txt<br/>copy list2.txt list.txt<br/>del list2.txt<br/><br/><br/>For example:<br/><br/><br/>C:\test>type erus.bat<br/> Code: <a>[Select]</a>echo off<br/>echo Creating Directory Listing<br/><br/>rem dir /a:-h /b /-p /o:EN >"list.txt"<br/><br/>dir /b l*.txt > list.txt<br/>dir /b n*.txt >> list.txt<br/><br/>findstr /v "list.txt" list.txt > list2.txt<br/>type list2.txt<br/>pause<br/>copy list2.txt list.txt<br/>del list2.txt<br/>echo type list.txt<br/>type list.txt<br/>pause<br/>ECHO Processing Directory Listing<br/>For /F %%i in (list.txt) do (<br/><br/>echo %%i<br/>rem notepad /p %%i<br/><br/>)<br/><br/>ECHO Deleting Directory Listing<br/>rem del "list.txt"<br/><br/>ECHO Process Complete. Press a key to exit.<br/>PAUSE<br/><strong>Output:</strong><br/>C:\test>erus.bat<br/>Creating Directory Listing<br/>log.txt<br/>nc.txt<br/>new.txt<br/>NextFile.txt<br/>notepid.txt<br/>num.txt<br/>Press any key to continue . . .<br/> 1 file(s) copied.<br/>type list.txt<br/>log.txt<br/>nc.txt<br/>new.txt<br/>NextFile.txt<br/>notepid.txt<br/>num.txt<br/>Press any key to continue . . .<br/>Processing Directory Listing<br/>log.txt<br/>nc.txt<br/>new.txt<br/>NextFile.txt<br/>notepid.txt<br/>num.txt<br/>Deleting Directory Listing<br/>Process Complete. Press a key to exit.<br/>Press any key to continue . . .<br/>C:\test>okay. I think that makes sense.<br/><br/>I need all the files though and not just l*.txt and n*.txt<br/><br/>are the pauses absolutely necessary? sometimes the list is going to be more than 100 lines long. or is that just a "look how it works" kinda thing? Quote from: ErusPrime on July 27, 2010, 07:16:16 PM<blockquote>okay. I think that makes sense.<br/><br/>I need all the files though and not just l*.txt and n*.txt<br/><br/>are the pauses absolutely necessary? sometimes the list is going to be more than 100 lines long. or is that just a "look how it works" kinda thing?<br/></blockquote> <br/>The pauses are not necessary. It was used while testing.<br/><br/>I noticed your code got all files and also all directories. How do you print a directory with notepad? Also *.exe files will not print with notepad.<br/><br/>I have never used may of the dir options in your batch file so I'm not sure what files you are after. I thought you were only after *.txt files?<br/><br/>I'm not sure what this line does:<br/><br/>dir /a:-h /b /-p /o:EN >"list.txt"<br/><br/>It appears you get more files than needed?<br/><br/>Good luck<br/><br/></body></html> | |
189. |
Solve : copy/xcopy subdirectory???? |
Answer» <html><body><p>hello there!<br/><br/>what is the code for copying 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> subdirectory?<br/><br/>thanks in advance!!!<br/> Code: <a>[Select]</a><a href="https://interviewquestions.tuteehub.com/tag/xcopy-747962" style="font-weight:bold;" target="_blank" title="Click to know more about XCOPY">XCOPY</a> "Drive:\Path\" "Drive:\Path\"<br/><a href="https://interviewquestions.tuteehub.com/tag/example-239971" style="font-weight:bold;" target="_blank" title="Click to know more about EXAMPLE">EXAMPLE</a>:<br/> Code: <a>[Select]</a>XCOPY "C:\Users\Matt\Desktop" "C:\Users\Matt\My Documents"Will copy the folder desktop to to my documents folder.<br/><br/>how about to delete that subdirectory?</p></body></html> | |
190. |
Solve : Adding some words end of multiple files? |
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>, i want to rename multiple rar <a href="https://interviewquestions.tuteehub.com/tag/files-20889" style="font-weight:bold;" target="_blank" title="Click to know more about FILES">FILES</a> by adding some words at end of filename.<br/><br/>ABC.rar &<a href="https://interviewquestions.tuteehub.com/tag/gt-249387" style="font-weight:bold;" target="_blank" title="Click to know more about GT">GT</a>; ABC-sheeper.rar <br/>123.rar > 123-sheeper.rar<br/>qwe.rar > qwe-sheeper.rar<br/><br/>how can i do it by <a href="https://interviewquestions.tuteehub.com/tag/one-241053" style="font-weight:bold;" target="_blank" title="Click to know more about ONE">ONE</a> bat file, i want to say rename all rar files to original names plus -sheeper for example.<br/><br/>Thank you for help!In a <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:<br/><br/> Code: <a>[Select]</a>for %%A in (*.rar) do ren %%~dpnxA %%~nA-sheeper%%~xA<br/>At the prompt:<br/><br/> Code: <a>[Select]</a>for %A in (*.rar) do ren %~dpnxA %~nA-sheeper%~xA<br/></body></html> | |
191. |
Solve : Prevent exclamation marks from going away? |
Answer» <html><body><p>What I am trying to do is use a FOR loop to send the contents of one batch file (<a href="https://interviewquestions.tuteehub.com/tag/starting-1224778" style="font-weight:bold;" target="_blank" title="Click to know more about STARTING">STARTING</a> at the <a href="https://interviewquestions.tuteehub.com/tag/37-247766" style="font-weight:bold;" target="_blank" title="Click to know more about 37">37</a> line) into another. To do this, I use this code:<br/><br/>for /f "skip=36 delims=" %%Z in (batchfile.bat) do echo %%Z >> newbatchfile.bat<br/><br/>However, it removes exclamation marks (which as you may know, can be critically important in batch files). Can someone help me prevent this from removing the exclamation marks?<br/><br/>EDIT: I tried <a href="https://interviewquestions.tuteehub.com/tag/disabling-2058727" style="font-weight:bold;" target="_blank" title="Click to know more about DISABLING">DISABLING</a> delayed expansion and it worked! Thanks anyway!you can use more <br/> Code: <a>[Select]</a>more +36 file >newfile<br/> Quote from: ghostdog74 on July 30, 2010, 10:07:10 PM</p><blockquote>you can use more <br/> Code: <a>[Select]</a>more +36 file >newfile<br/></blockquote> <br/>I noticed that the help for more says <br/><br/> Code: <a>[Select]</a> +n Start displaying the first file at line n<br/>in fact more +n skips n lines, and starts displaying the file at line n+1.<br/><br/> Code: <a>[Select]</a>del testfile.txt & for /L %%N in (1,1,<a href="https://interviewquestions.tuteehub.com/tag/40-241999" style="font-weight:bold;" target="_blank" title="Click to know more about 40">40</a>) do echo This is line %%N>>testfile.txt<br/>echo (1) FOR /f "skip=36"<br/>for /f "skip=36 delims=" %%Z in (testfile.txt) do echo %%Z<br/>echo (2) more +36<br/>more +36 testfile.txt<br/><br/> Code: <a>[Select]</a>(1) FOR /f "skip=36"<br/>This is line 37<br/>This is line 38<br/>This is line 39<br/>This is line 40<br/>(2) more +36<br/>This is line 37<br/>This is line 38<br/>This is line 39<br/>This is line 40<br/><br/><br/><br/><br/><br/></body></html> | |
192. |
Solve : Extracting the date of a file into an excel file? |
Answer» <html><body><p>Hi All,<br/><br/><br/><br/>I have a file called Myfile.mdl. This file is located in some <strong>D:\Folder_Name1\Folder_Name2\Myfile.mdl</strong>.<br/><br/>When we see the the details of this file We can <a href="https://interviewquestions.tuteehub.com/tag/find-11616" style="font-weight:bold;" target="_blank" title="Click to know more about FIND">FIND</a> out <strong><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, <a href="https://interviewquestions.tuteehub.com/tag/date-11316" style="font-weight:bold;" target="_blank" title="Click to know more about DATE">DATE</a> Modified etc...</strong><br/><br/>I want to extract only that date into one Excel file called <strong>Myexcel.xls.</strong> And I want to send this date into the database table called Mytable into the column <strong>Success_date</strong>.<br/><br/>My database is <strong>Oracle.</strong><br/><br/>My table having the columns like <strong>Success_date, Failure_date.</strong><br/><br/>I need this <a href="https://interviewquestions.tuteehub.com/tag/urgently-2315680" style="font-weight:bold;" target="_blank" title="Click to know more about URGENTLY">URGENTLY</a>... anyone's help is most appriciated.<br/><br/><br/>Thanks & Regards<br/>SarayuYou can't do this with batch language. Batch code can process files at the file level (copy/move/delete etc) but only text files at the record level (create/update/delete etc).<br/><br/>You might try VBScript where you can use the FileSystemObject (<a href="https://interviewquestions.tuteehub.com/tag/fso-458441" style="font-weight:bold;" target="_blank" title="Click to know more about FSO">FSO</a>) to get the date and use the ActiveX Data Object (ADO) to update both the Excel spreadsheet and the Oracle database.<br/><br/>This link will provide you with the <a href="http://www.connectionstrings.com/">connection strings</a> used by ADO to access the records in both Excel and Oracle.<br/><br/>Good luck.</p></body></html> | |
193. |
Solve : 3 Dos floppy file configuration? |
Answer» <html><body><p>I wonder if anyone can <a href="https://interviewquestions.tuteehub.com/tag/help-239643" style="font-weight:bold;" target="_blank" title="Click to know more about HELP">HELP</a> me.<br/>I have a folder of what appears to be Dos622 files on a CD and I was wondering if anyone knew the way for me to put the <a href="https://interviewquestions.tuteehub.com/tag/right-239192" style="font-weight:bold;" target="_blank" title="Click to know more about RIGHT">RIGHT</a> files on each floppy disk.<br/>Help would be most gratefully received<br/>Nigel.Since MS-DOS was never distributed thus, it sounds like you have an illegal copy. We don't offer advice about using copyright material. <strong>He <a href="https://interviewquestions.tuteehub.com/tag/could-410026" style="font-weight:bold;" target="_blank" title="Click to know more about COULD">COULD</a> buy a <a href="https://interviewquestions.tuteehub.com/tag/nexus-578218" style="font-weight:bold;" target="_blank" title="Click to know more about NEXUS">NEXUS</a> One!</strong><br/><a href="https://www.engadget.com/2010/05/17/nexus-one-runs-windows-3-11-possibly-the-saddest-thing-weve-se/">http://www.engadget.com/2010/05/17/nexus-one-runs-windows-3-11-possibly-the-saddest-thing-weve-se/</a><br/><br/><br/></p></body></html> | |
194. |
Solve : shedule time for copy/transfer folders job? |
Answer» <html><body><p>i want to copy 8 huge folders to external hardisk, but i want to do this one folder each time at schedule time, because those files may <a href="https://interviewquestions.tuteehub.com/tag/access-846773" style="font-weight:bold;" target="_blank" title="Click to know more about ACCESS">ACCESS</a> by others during office hour.<br/><br/>so when i run it, it will only copy specific folder to ext <a href="https://interviewquestions.tuteehub.com/tag/hdd-479551" style="font-weight:bold;" target="_blank" title="Click to know more about HDD">HDD</a> at schedule time (e.g 7/24/2010 12.00a.m)...and a log file will be generated when finished copy (e.g abc folder 1234 files copied at 7/24/2010 12.30a.m)...<br/>i got this code to create data folder but <a href="https://interviewquestions.tuteehub.com/tag/somehow-7378511" style="font-weight:bold;" target="_blank" title="Click to know more about SOMEHOW">SOMEHOW</a> it doesn't work perfectly<br/><br/> Code: <a>[Select]</a>echo off<br/>SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"<br/><br/>md D:\2\%date%<br/>xcopy /e C:\1\*.* D:\2\%date%<br/>pause<br/>the folder create is D:\2\2010-07-\2<br/><br/>my system date format is <br/>07/25/2010 Sun 15:22:52.92<br/>xcopy /e C:\1\*.* D:\2\%date%<br/><br/>Prompt user for folder name <br/><br/>or<br/> use a command line argument<br/><br/>xcopy /e C:<strong>\%1</strong>\*.* D:\2\%date%<br/><strong>Rem date is a command and should be used a variable name</strong><br/><br/> Code: <a>[Select]</a>echo off<br/>set MM=%date:~4,2%<br/>set DD=%date:~7,2%<br/>set YYYY=%date:~10,4%<br/>echo MM=%MM%<br/>echo DD=%DD%<br/>echo YYYY=%YYYY%<br/>set mydate=%MM%-%DD%-%YYYY%<br/>echo mydate=%mydate%<br/>pause<br/>e:<br/>cd 2<br/><br/>md %mydate%<br/>copy C:\1\*.* e:\2\%mydate%\<br/><br/>cd e:\2\%mydate%\<br/>dir<br/>lon.bat<br/>MM=07<br/>DD=25<br/>YYYY=2010<br/>mydate=07-25-2010<br/>Press any key to continue . . .<br/><br/>C:\1\world1.txt<br/>C:\1\world2.txt<br/>C:\1\world3.txt<br/> 3 file(s) copied.<br/> Volume in drive E is My Book<br/> Volume Serial Number is 0850-D7C5<br/><br/> Directory of e:\2\07-25-2010<br/><br/>07/25/2010 05:10 PM .<br/>07/25/2010 05:10 PM ..<br/>07/25/2010 05:10 PM 07-25-2010<br/>07/25/2010 05:01 PM 16 world1.txt<br/>07/25/2010 05:01 PM 16 world2.txt<br/>07/25/2010 05:01 PM 16 world3.txt<br/> <br/>e:\2\07-25-2010>Rem date is a command and should be used a variable name<br/><br/><strong>date is a command and should not be used as a variable name.</strong> Quote from: marylane on July 25, 2010, 08:14:36 PM</p><blockquote>Rem date is a command and should be used a variable name<br/><br/><strong>date is a command and should not be used as a variable name.</strong><br/></blockquote> <br/>%date% is already used as a system variable name, Bill, so it should not be modified or altered.<br/><strong>date is a command and should not be used as a variable name</strong>.<br/> Quote from: only_lonely on July 25, 2010, 01:18:15 AM<blockquote>i got this code to create data folder but somehow it doesn't work perfectly<br/><br/> Code: <a>[Select]</a>echo off<br/>SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"<br/><br/>md D:\2\%date%<br/>xcopy /e C:\1\*.* D:\2\%date%<br/>pause<br/>the folder create is D:\2\2010-07-\2<br/><br/>my system date format is <br/>07/25/2010 Sun 15:22:52.92<br/><br/></blockquote> <strong>date is a command and should not be used as a variable name.</strong>C:\>date /t<br/>Mon 07/26/2010<br/><br/>C:\>echo %DATE%<br/>Mon 07/26/2010<br/><br/>C:\>date<br/>The current date is: Mon 07/26/2010<br/>Enter the new date: (mm-dd-yy)<br/><br/>C:\> Quote from: marylane on July 26, 2010, 09:13:25 AM<blockquote><br/>C:\>date /t<br/>Mon 07/26/2010<br/><br/>C:\>echo %DATE%<br/>Mon 07/26/2010<br/><br/>C:\>date<br/>The current date is: Mon 07/26/2010<br/>Enter the new date: (mm-dd-yy)<br/><br/>C:\><br/></blockquote> Yes, and your point is, Bill?The original poster( only_lonely ) used the command "date" as a personal variable:<br/><br/>echo off<br/><strong>SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%</strong>"<br/>Good job editing your post bill! Quote from: marylane on July 26, 2010, 09:24:40 AM<blockquote>The original poster( only_lonely ) used the command "date" as a personal variable:<br/><br/>echo off<br/><strong>SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%</strong>"<br/><br/></blockquote> <br/><strong>Bill,</strong> this may or may not be a bad <a href="https://interviewquestions.tuteehub.com/tag/idea-770073" style="font-weight:bold;" target="_blank" title="Click to know more about IDEA">IDEA</a>, as thereafter in that session, (and only in that session) the system variable %date%, which is provided for the user's convenience, will be different from the default (as set in Regional Options in Control Panel). As I say, it may or may not be a bad thing. The sky won't fall, however, <strong>Bill</strong>.<br/>Like I said, only in that session...<br/><br/><strong><br/>The following (reply 1 above ) is from the original poster, only_lonely. The name given to the file was not the goal. Using a command, "date" as a personal variable does not work</strong>.<br/><br/>type ol726.bat<br/><strong>echo off<br/>SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"<br/>echo date=%date%<br/>pause<br/><br/>md e:\2\%date%<br/>copy C:\1\*.* e:\2\%date%<br/><br/>dir</strong>ol726.bat<br/><strong> date="Mo-n-"/-26"</strong><br/>the above is mistake<br/><br/>Terminate batch job (Y/N)? y<br/><br/>p.s. It does not work for this session or any sessionBill posts his usual nonsense. Countdown to ban time... <br/></body></html> | |
195. |
Solve : Dos Batch Variables? |
Answer» <html><body><p>Looking for a was to restate if "!<a href="https://interviewquestions.tuteehub.com/tag/line-239358" style="font-weight:bold;" target="_blank" title="Click to know more about LINE">LINE</a>!"=="19" in the following example to accept a variable Example: if "!LINE!"==%value% <br/><br/><br/>SET S=%%i<br/>SET LINE=0<br/>for /F "delims=" %%<a href="https://interviewquestions.tuteehub.com/tag/l-236827" style="font-weight:bold;" target="_blank" title="Click to know more about L">L</a> in (%FILE%) do (<br/> set /A LINE += <a href="https://interviewquestions.tuteehub.com/tag/1-236780" style="font-weight:bold;" target="_blank" title="Click to know more about 1">1</a><br/> if "!LINE!"=="19" (<br/> set STR=%%L<br/> echo. !STR:~8!> %TEMP%.\T1.DAT<br/> FINDSTR /B /C:"TLAXIS" %TEMP%.\T1.DAT > nul<br/> del %TEMP%.\T1.DAT<br/> if not errorlevel=1 (<br/> set NAME=%FILE%.vec<br/> copy %FILE% %LOC%\%FILE%.vec<br/> cls<br/> echo.Looking for a way to restate if "!LINE!"=="19" in the following example to accept a variable! Example: if "!LINE!"==%value% <br/>(before the FOR statement)<br/>set value=19<br/><br/>(in the loop)<br/>if "!LINE!"=="%value%" (<br/><br/>or<br/><br/>if !LINE! equ %value% (<a href="https://interviewquestions.tuteehub.com/tag/thank-1731949" style="font-weight:bold;" target="_blank" title="Click to know more about THANK">THANK</a> YOU AGAIN! Works <a href="https://interviewquestions.tuteehub.com/tag/perfect-1150611" style="font-weight:bold;" target="_blank" title="Click to know more about PERFECT">PERFECT</a>!</p></body></html> | |
196. |
Solve : Batch Desktop Command? |
Answer» <html><body><p>Hey. I was wondering if anyone knows a batch script that will show your <a href="https://interviewquestions.tuteehub.com/tag/desktop-949558" style="font-weight:bold;" target="_blank" title="Click to know more about DESKTOP">DESKTOP</a> and minimize all programs. Thanks in advance for <a href="https://interviewquestions.tuteehub.com/tag/anyones-2436475" style="font-weight:bold;" target="_blank" title="Click to know more about ANYONES">ANYONES</a> helpFor batch code normally <em>rundll32</em> can be helpful, but I had zero luck. This short little snippet will minimize all the open windows:<br/><br/> Code: <a>[Select]</a>Set objShell = CreateObject("Shell.Application")<br/>objShell.MinimizeAll<br/><br/>In case you're wondering, this little snippet will undo the previous script:<br/><br/> Code: <a>[Select]</a>Set objShell = CreateObject("Shell.Application")<br/>objShell.UndoMinimizeALL<br/><br/>Save each script separately with a <strong>vbs</strong> extension. They can be run from the command <a href="https://interviewquestions.tuteehub.com/tag/line-239358" style="font-weight:bold;" target="_blank" title="Click to know more about LINE">LINE</a> as: <strong>cscript <em>scriptname.vbs</em></strong> or they can be run in Windows as: <strong><a href="https://interviewquestions.tuteehub.com/tag/wscript" style="font-weight:bold;" target="_blank" title="Click to know more about WSCRIPT">WSCRIPT</a> <em>scriptname.vbs</em></strong><br/><br/>Good luck. Thank you very much for your help. It works fine.</p></body></html> | |
197. |
Solve : random password genrator? |
Answer» <html><body><p>i made this code to generate random passwords.<br/>the password often has spaces in it can some one help me fix it.<br/> Code: <a>[Select]</a>echo off<br/>:7<br/>cls<br/>set /p t=password length: <br/>set /a t=%t%-1<br/>set /a p=%random% %%9<br/>for /l<br/>set /a c=%random% %%<a href="https://interviewquestions.tuteehub.com/tag/18-242944" style="font-weight:bold;" target="_blank" title="Click to know more about 18">18</a><br/>set d=%c%<br/>if %c%==10 set d=a<br/>if %c%==11 set d=b<br/>if %c%==12 set d=c<br/>if %c%==13 set d=d <br/>if %c%==14 set d=e<br/>if %c%==15 set d=f <br/>if %c%==16 set d=g<br/>if %c%==17 set d=h <br/>if %c%==18 set d=i <br/>set p=%p%%d%<br/>set /a l=%l%+1<br/>goto a<br/>:out <br/>echo %p%<br/><a href="https://interviewquestions.tuteehub.com/tag/pause-1149128" style="font-weight:bold;" target="_blank" title="Click to know more about PAUSE">PAUSE</a> > nul<br/>goto 7<br/>I tried to fix it, but I simply could not <a href="https://interviewquestions.tuteehub.com/tag/guess-1013936" style="font-weight:bold;" target="_blank" title="Click to know more about GUESS">GUESS</a> how the <strong>for</strong> statement was constructed. I checked in with the snippet closet and turned up this masterpiece that only needed a few tweaks.<br/><br/> Code: <a>[Select]</a>echo off<br/>setlocal<br/>set pool=ABCDEFGHIJKLMNOPQRSTUVWXYZabcde<a href="/cdn-cgi/l/email-protection">[email protected]</a>$?<br/><br/>:retry<br/> set /p len=Enter length of <a href="https://interviewquestions.tuteehub.com/tag/key-11608" style="font-weight:bold;" target="_blank" title="Click to know more about KEY">KEY</a>: <br/> if %len% GTR 65 goto retry<br/><br/>for /l %%i in (1, 1, %len%) do call :GetNext<br/>echo Key: %key%<br/>goto :eof<br/><br/>:GetNext<br/> set /a rnd=(%random% %% 65) - 1<br/> call set <a href="https://interviewquestions.tuteehub.com/tag/new-1114486" style="font-weight:bold;" target="_blank" title="Click to know more about NEW">NEW</a>=%%pool:~%rnd%,1%%<br/> set key=%key%%new%<br/> goto :eof<br/><br/>Good luck.</p></body></html> | |
198. |
Solve : a batch with blank spaces in between? |
Answer» <html><body><p>how to <a href="https://interviewquestions.tuteehub.com/tag/create-427332" style="font-weight:bold;" target="_blank" title="Click to know more about CREATE">CREATE</a> a batch with copy as header and end with lpt1?<br/>copy space space lpt1<br/>so when i click on it, it will run, but not stop/end, then i can enter my file name in between the space space, then it run only when i hit enter key..<br/>Im afraid I cannot even guess what you want!<br/><br/>Are you trying to get user input ? if so, use Set /Pwhen i click the .bat file, it will call the cmd.exe then at the cmd, it auto insert "copy lpt1" but the line will not run, until i type my file name in between, like "copy 1.txt lpt1".<br/>then i hit enter key, cmd will send my file...But what happens if your filename is too long for the available "blank space" in your request?<br/>so i cannot insert any file name??<br/>or any way to allow user drag and drop file over, then it will inserted ?what's wrong with the PRINT command?<br/>1. Save to desktop as .bat or .cmd file (name as you like)<br/>2. To use, drag and drop file onto icon.<br/><br/> Code: <a>[Select]</a>copy "%1" lpt1:I use this<br/>copy "%1" lpt1:<br/>pause<br/><br/> but not working<br/><br/>The system cannot find the file specified.<br/><br/><a href="https://interviewquestions.tuteehub.com/tag/c-3540" style="font-weight:bold;" target="_blank" title="Click to know more about C">C</a>:\>pause<br/>Press any key to continue . . . Code: <a>[Select]</a>copy "%~dpnx1" lpt1:copy "%~dpnx1" lpt1:<br/>not working too............ Code: <a>[Select]</a>echo off<br/>echo File to copy: "%~dpnx1"<br/>pause<br/>copy "%~dpnx1" lpt1:<br/>pause<br/><br/>Please post what you see on screen (by copying and pasting)<br/>File to copy: "C:\urban.txt"<br/>Press any key to continue . . .<br/><br/>nothing happend when i press any keyYou <a href="https://interviewquestions.tuteehub.com/tag/sayaeur-637418" style="font-weight:bold;" target="_blank" title="Click to know more about SAY">SAY</a> "nothing happened". Please say what you are <a href="https://interviewquestions.tuteehub.com/tag/expecting-7262936" style="font-weight:bold;" target="_blank" title="Click to know more about EXPECTING">EXPECTING</a> to happen.<br/><br/>a. Is "C:\urban.txt" the file you dragged and dropped? (i.e. are the path and filename correct?)<br/>b. Does your computer have a parallel port which is enabled in the BIOS and is there a device such a printer properly connected to it and switched on?<br/>c. Do you get to the second Press any key message?<br/>d. What operating system are you running?<br/><br/>Please try this and post results as before...<br/><br/> Code: <a>[Select]</a>echo off<br/>echo 1 File to copy: "%~dpnx1"<br/>pause<br/>echo 2 Copying file to printer port<br/>copy "%~dpnx1" lpt1:<br/>echo 3 Printer finished<br/>pause<br/><br/><br/> Quote from: Salmon Trout on July 25, 2010, 12:53:59 AM</p><blockquote>You say "nothing happened". Please say what you are expecting to happen.<br/><br/>a. Is "C:\urban.txt" the file you dragged and dropped? (i.e. are the path and filename correct?)<br/>yes, i drag and drop, both .bat and urban.txt are located at desktop<br/>b. Does your computer have a parallel port which is enabled in the BIOS and is there a device such a printer properly connected to it and switched on?<br/>i think i found the problem, now i <a href="https://interviewquestions.tuteehub.com/tag/change-238106" style="font-weight:bold;" target="_blank" title="Click to know more about CHANGE">CHANGE</a> my adobe print to lpt1...semms working...<br/>c. Do you get to the second Press any key message?<br/>yes<br/>d. What operating system are you running?<br/>XP<br/> Code: <a>[Select]</a>1 File to copy: "C:\urban.txt"<br/>Press any key to continue . . .<br/>2 Copying file to printer port<br/> 1 file(s) copied.<br/>3 Printer finished<br/>Press any key to continue . . .</blockquote> how to make the cmd do not close after i press any key?<br/>so i can drag and drop the file while cmd window open...</body></html> | |
199. |
Solve : Enter into network? |
Answer» <html><body><p>Hi folks,<br/><br/>Actually I am trying to create a form for the front end user.<br/>But saving the data entered at the back end.<br/><br/>But, as we know that dos cannot enter the file on network<br/><br/>Do we have any work around?<br/><br/><br/>echo off<br/>color f0<br/>echo **********this is a form for all the users*************<br/><br/>:1<br/>Echo please enter the following details<br/><br/>set /p "cust_name= Pleaser enter customer name : "<br/>set /p "ph_no= Pleaser enter Phone number : "<br/>set /p "printer= Pleaser enter Printer : "<br/>set /p "st= Pleaser enter Service ticket : "<br/>set /p "lead= Pleaser enter lead number : "<br/><br/><br/>echo %cust_name%<br/>echo %ph_no%<br/>echo %printer%<br/>echo %st%<br/>echo %lead%<br/><br/><br/><br/>echo %cust_name%>>c:\banner\track.xls %ph_no%>>track.xls %printer%>>track.xls %st%>>track.xls <br/><br/>%lead%>>track.xls<br/><br/>Echo <br/>:mo<br/>set /p "mo= Do you want to add more details? y or n"<br/>if not defined mo <a href="https://interviewquestions.tuteehub.com/tag/goto-1009988" style="font-weight:bold;" target="_blank" title="Click to know more about GOTO">GOTO</a> :mo<br/>if "%mo%"=="y" goto :1 else EOF:<br/><br/><br/><br/>Thanks and regards Quote</p><blockquote>But, as we know that dos cannot enter the file on network<br/></blockquote> <br/>Could you explain more. Maybe I'm missing something, but where is the network file?<br/><br/> Quote<blockquote>echo %cust_name%>>c:\banner\track.xls %ph_no%>>track.xls %printer%>>track.xls %st%>>track.xls <br/><br/>%lead%>>track.xls<br/></blockquote> <br/>Batch code cannot add records to an Excel spreadsheet file. You could create a <strong>C</strong>omma <strong>S</strong>eparated <strong>V</strong>alues file which can be imported into Excel.<br/><br/> Code: <a>[Select]</a>echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>c:\banner\track.csv<br/><br/> <br/>I can enter the details on the Excel file.<br/><br/>I would like to enter the data on home drive that is on network like.<br/><br/><br/>\\hphome\vishu<br/><br/>This is a network driver<br/><br/>but, Dos is not able to enter the file on network and gives error. Quote<blockquote>but, Dos is not able to enter the file on network and gives error.<br/></blockquote> <br/>What error? Posting the error will save me time trying to guess it.<br/><br/>You keep <a href="https://interviewquestions.tuteehub.com/tag/referring-2982035" style="font-weight:bold;" target="_blank" title="Click to know more about REFERRING">REFERRING</a> to "DOS" but there is no "DOS" on Windows XP. Are you referring to the NT command prompt?<br/><br/>You could try mapping the network drive to your local machine: <strong>net use N: \\hphome\vishu</strong> You would then refer to your file as <strong>n:\banner\track.xls</strong> Note: the letter N was arbitrary; chose any unused letter you want.<br/><br/>You can also use the UNC notation and refer to your file as: <strong>\\hphome\vishu\banner\track.xls</strong><br/><br/>As previously mentioned, you cannot use batch code to update an Excel spreadsheet.<br/><br/>Good luck. Thanks for the reply.<br/><br/>But, it is not working.<br/><br/>Is there any way that I can enter on the network path.<br/><br/>So, that I can save my output file<br/><br/>The syntax of this command is:<br/><br/><br/>NET USE<br/>[devicename | *] [\\computername\sharename[\volume] [password | *]]<br/> [/USER:[domainname\]username]<br/> [/USER:[dotted domain name\]username]<br/> [/USER:[<a href="/cdn-cgi/l/email-protection">[email protected]</a> domain name]<br/> [/SMARTCARD]<br/> [/SAVECRED]<br/> [[/DELETE] | [/PERSISTENT:{YES | NO}]]<br/><br/>NET USE {devicename | *} [password | *] /HOME<br/><br/>NET USE [/PERSISTENT:{YES | NO}]<br/><br/><br/>I am getting this message while I done that.<br/><br/>Something may be missing. Please help...<br/><br/>Help appreciated..<br/><br/>Regards <br/><br/>VishuActually I am trying to make a user end dos file. That will save the data on the network.<br/><br/>Network has a dedicated space. It is not the shared <a href="https://interviewquestions.tuteehub.com/tag/computer-243299" style="font-weight:bold;" target="_blank" title="Click to know more about COMPUTER">COMPUTER</a>.<br/><br/>It is little bit peculiar.<br/><br/>But, I know since we can open drive from computer means in windows XP.<br/>So, we should be able to open it from dos.<br/><br/>Cause dos is the basic unit of the computer. It can do most of the thing so, I hope it can do this as well.<br/><br/>I want to see <br/><br/>\\vishu\vishal<br/><br/>instead of<br/><br/>c:>documents and users\vishu\desktop><br/><br/>I know we do have lots of expert on dos. <br/><br/>I hope I will get the answer.<br/><br/>And I also want to save my output file on the network.<br/><br/><br/>Thanks and regards<br/><br/>VishuYou still haven't posted the error message. <br/><br/>If you want to put the batch file output on the network, you can you use this:<br/><br/> Code: <a>[Select]</a>echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>\\vishul\vishal\banner\track.csv<br/><br/>The banner directory must exist on the network drive. <br/><br/><strong>OR</strong><br/><br/>If you want to put the batch file output on the network, you can you use this:<br/><br/> Code: <a>[Select]</a>net use N: \\vishu\vishal<br/>echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>n:\banner\track.csv<br/><br/>The banner directory must exist on the network drive. <br/><br/>You cannot use the UNC path as the current directory, but you can use a drive letter that has been mapped.<br/><br/>This could be a permissions problem but you need to be more responsive to my requests for information. <br/><br/> Sir, I am not able to get inside the path.<br/><br/>Actually it is <br/><br/>\\10.120.3.50<br/><br/>Getting error System error 1909 has occurred<br/><br/>The referenced account is currently locked out and may not be logged on to.<br/><br/>So, I hope bad luck?<br/><br/><br/><a href="https://interviewquestions.tuteehub.com/tag/thank-1731949" style="font-weight:bold;" target="_blank" title="Click to know more about THANK">THANK</a> you for the replie<br/><br/>vishu<br/>The account you are trying to log in with is locked, you will need to go to the machine authenticating users to \\10.120.3.50 and then unlock your user account.<br/><br/>Then go into the settings for the share you are trying to access and make sure that your account has permission to <strong>read and write </strong>to the share name (I''m guessing in your case it's called 'vishal'<br/><br/>Depending upon the OS of the machine, there maybe at least 2 spots you need to change. One is the 'share permissions' and the other is the 'folder/file' permissions.<br/><br/>I would suggest temporarily granting full access to everyone to the share until you get it working, then you can lock down the security to only your own account later.Thanks for the reply.<br/><br/>I have access to read and write.<br/><br/>As I can create any file on the network drive.<br/><br/>I can copy and paste anything.<br/><br/>Actually working on comp<br/><br/>Don't want to reveal the name completely and even network path name.<br/><br/>it's like<br/><br/>\\10.120.3.50\user mail\agent access\<br/><br/>It is not the correct path but it is like this only.<br/><br/>I can enter text word excel zip file in it. Can modify also. I have access.<br/>But, I am not able to enter anything using DOS window.<br/><br/>I have this form that saves the file on my computer but not on path.<br/><br/>What can I do???<br/><br/>Thanks for the information.<br/><br/><br/>echo off<br/>color f0<br/>echo **********this is a form for all the users*************<br/><br/>:1<br/>Echo please enter the following details<br/><br/>set /p "cust_name= Pleaser enter customer name : "<br/>set /p "ph_no= Pleaser enter Phone number : "<br/>set /p "printer= Pleaser enter Printer : "<br/>set /p "st= Pleaser enter Service ticket : "<br/>set /p "lead= Pleaser enter lead number : "<br/><br/><br/>echo %cust_name%<br/>echo %ph_no%<br/>echo %printer%<br/>echo %st%<br/>echo %lead%<br/><br/><br/>cd\<br/><br/>echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>\\10.120.3.50\agent mail\agent access\track.csv<br/><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/>Make sure you include your path name in quotes if the files have spaces<br/><br/>echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>"\\10.120.3.50\agent mail\agent access\track.csv"<br/><br/>or try<br/><br/>echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>%TEMP%\track.csv<br/>copy %TEMP%\track.csv "\\10.120.3.50\agent mail\agent access\track.csv" <br/><br/><br/>You are <br/><br/><br/>Thank you so much. I have also clicked on thanks to you.<br/><br/>you can see it increasing.<br/><br/><br/>You are dude man!!!!!!!!!!!!<br/><br/>A thousand of raise to you.<br/><br/>Thank you so much.<br/><br/>I don't know how to thank you.<br/><br/>Really thank you.<br/><br/><br/>Thank you thank you.<br/>Thank you thank you.<br/>Thank you thank you.<br/>Thank you thank you.<br/>Thank you thank you.<br/>Thank you thank you.<br/><br/><br/>I know we have masterminds on this forum.<br/><br/>And also thank you other dudes who given replies.<br/><br/>hat off<br/>or <br/>head off.<br/><br/><br/><br/>Thanks and regards<br/>VishuYou're very welcomeThere is a little problem in excel format<br/><br/>I want to add the format like<br/><br/>Name then next cell phone no and next cell and id etc.<br/>All I want to add it into next cell. But datas are entered in single cell. So, how can I avoid it?<a href="https://interviewquestions.tuteehub.com/tag/figured-7681243" style="font-weight:bold;" target="_blank" title="Click to know more about FIGURED">FIGURED</a> it.<br/><br/>Tab will help.</body></html> | |
200. |
Solve : Batch Script Question? |
Answer» <html><body><p>Let's say I do a simple clean up command like:<br/><br/>cd c:\users\username\desktop<br/><br/>move *.jpg c:\Images<br/><br/>Let's say some files were moved, is there any way to record that to a log?<br/>Like have it look like:<br/><br/>Image1.jpg moved to [C:\Images]<br/>Image2.jpg moved to [C:\Images]<br/><br/>You can't just echo move *.jpg C:\Images > Log.log can you?<br/>And also, let's say it didn't move anything. Could I record that too?<br/><br/>All help appreciated.<br/><br/> ~SacredUse the <a href="https://interviewquestions.tuteehub.com/tag/redirector-7272638" style="font-weight:bold;" target="_blank" title="Click to know more about REDIRECTOR">REDIRECTOR</a> '>' '>>'<br/>move *.jpg c:\Images >> C:\Somefile.ext<br/><br/>a single > will start a new file basically<br/>a >> will append<br/><br/>My bad I hadn't looked at your whole structure it should be like<br/><br/>move "C:\Images\*.txt" 01\ >> 01\Somefile.txt<br/>I wrap my directory commands just to be safe.. but with no spaces in the dir names it wouldn't be necc.. the folder to be moved to ie. 01\ doesn't need an extension if your not changing them.. finally you can out put your Results anywhere just remember if the distination folder has spaces in any Dir name wrap it...<br/><br/>Usually in a case of recording and not.. I just use a '<br/>if exist C:\ balh <a href="https://interviewquestions.tuteehub.com/tag/bla-399162" style="font-weight:bold;" target="_blank" title="Click to know more about BLA">BLA</a>\*.jpg (<br/>move......<br/>) else (<br/>someother command<br/>) Quote from: pfmk2 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> 01, 2010, 09:27:03 PM</p><blockquote>Use the redirector '>' '>>'<br/>move *.jpg c:\Images >> C:\Somefile.ext<br/><br/></blockquote> <br/>that will not log anything. move does not give you a stdout when it moves <a href="https://interviewquestions.tuteehub.com/tag/successfullybrbr-3084898" style="font-weight:bold;" target="_blank" title="Click to know more about SUCCESSFULLY">SUCCESSFULLY</a>.yeah I know that.. <a href="https://interviewquestions.tuteehub.com/tag/maybe-2821687" style="font-weight:bold;" target="_blank" title="Click to know more about MAYBE">MAYBE</a> if ya actually read the rest.........................<br/><br/>well when it successfully moved on my machine it recorded just fine as<br/>C:\Tests\01\Fri.txt<br/>C:\Tests\01\Mon.txt<br/>C:\Tests\01\Sat.txt<br/>C:\Tests\01\Sun.txt<br/>C:\Tests\01\Thu.txt<br/>C:\Tests\01\Tue.txt<br/>C:\Tests\01\Wed.txt<br/> Code: <a>[Select]</a><br/>S:\>echo hello>test1.txt<br/><br/>S:\>echo hello>test2.txt<br/><br/>S:\>echo hello>test3.txt<br/><br/>S:\>echo hello>test4.txt<br/><br/>S:\>echo hello>test5.txt<br/><br/>S:\>move t*.txt subdir>report.txt<br/><br/>S:\>type report.txt<br/><br/>S:\test1.txt<br/>S:\test2.txt<br/>S:\test3.txt<br/>S:\test4.txt<br/>S:\test5.txt<br/> 5 file(s) moved.<br/><br/>S:\><br/><br/></body></html> | |