

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.
9001. |
Solve : batch, variables, and images? |
Answer» <html><body><p>Hello world,<br/>first <a href="https://interviewquestions.tuteehub.com/tag/post-2638" style="font-weight:bold;" target="_blank" title="Click to know more about POST">POST</a> for me here.<br/><br/>I've a problem about identify if an <a href="https://interviewquestions.tuteehub.com/tag/image-11684" style="font-weight:bold;" target="_blank" title="Click to know more about IMAGE">IMAGE</a> is portrait or landscape...<br/><br/>Find a program that tell me meseurement in this <a href="https://interviewquestions.tuteehub.com/tag/format-11876" style="font-weight:bold;" target="_blank" title="Click to know more about FORMAT">FORMAT</a>: myprog.exe test.jpg<br/><br/>[IPTCFIELDS]<br/>3:40 = 256<br/>3:50 = 171<br/><br/><br/>So i write a small batch that find 2 <a href="https://interviewquestions.tuteehub.com/tag/value-238057" style="font-weight:bold;" target="_blank" title="Click to know more about VALUE">VALUE</a> (256,171) and <a href="https://interviewquestions.tuteehub.com/tag/put-11868" style="font-weight:bold;" target="_blank" title="Click to know more about PUT">PUT</a> into a variable:<br/><br/>myprog.exe %1 -ds | for /f "Tokens=1-2 Delims==" %%e in ('find /I "3:40 ="') do set g=%%f<br/>myprog.exe %1 -ds | for /f "Tokens=1-2 Delims==" %%s in ('find /I "3:50 ="') do set h=%%t<br/><br/><br/><br/>all seems to work but in my environment %g% and %h% are not present.<br/><br/>Anyone can help me?<br/><br/>A.Try<br/><br/>for /f "Tokens=1,2,3 Delims==" %%e in ('myprog.exe %1 -ds | find /I "3:40 ="') do set g=%%f<br/></p></body></html> | |
9002. |
Solve : Problem Echoing a Digit to a File? |
Answer» <html><body><p>Hi,<br/><br/>I <a href="https://interviewquestions.tuteehub.com/tag/apologize-363663" style="font-weight:bold;" target="_blank" title="Click to know more about APOLOGIZE">APOLOGIZE</a> if this has been covered before, but I've been searching for 2 days for a solution to no avail. I've wasted enough time on it, so I'm going to go ahead and ask.<br/><br/>The root of the problem is this:<br/><br/>echo 9> myfile.txt<br/><br/>The 9 (or any single digit for that matter) and the > next to each other cause the command to be interpreted incorrectly.<br/><br/><br/>I've found it easy enough to overcome this by "escaping" the 9, ie:<br/><br/>echo ^9> myfile.txt<br/><br/>However, here's the rub, what I'm actually <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 do is echo a variable. The variable is set by the user with the SET /P command. The user is prompted to type in the path to their Flight Simulator <a href="https://interviewquestions.tuteehub.com/tag/installation-16361" style="font-weight:bold;" target="_blank" title="Click to know more about INSTALLATION">INSTALLATION</a> which is then set as the variable %fspath%. To avoid the user having to type the path each time he runs the .bat file, I'm attempting to store it (along with some other variables) in an .ini file. When the .bat file is run, the .ini is copied to temp.bat which is then called by the main .bat to set the variables. Something like this:<br/><br/>:start<br/>if not exist myfile.ini goto firstrun<br/>copy myfile.ini temp$$$.bat<br/>call temp$$$.bat<br/>del temp$$$.bat<br/>goto menu1<br/><br/>:firstrun<br/>set /p fspath=Please type the path to your FS installation:<br/>echo set fspath=%fspath%> myfile.ini<br/>copy myfile.ini temp$$$.bat<br/>call temp$$$.bat<br/>del temp$$$.bat<br/>goto menu1<br/><br/>The problem is that typically the path to the user's FS installation is "[drive]:\Program Files\Microsoft Games\Flight Simulator <strong>9</strong>" and because of the "9" at the end of the directory name, nothing at all gets written to the myfile.ini. Any other directory name seems to work fine.<br/><br/>I need some way "escape" the 9 in %fspath%, but short of instructing the user to insert the caret character before the 9 while typing the path, I'm drawing a blank. Any suggestions?<br/><br/>Thanks,<br/>JimTry:<br/><br/>echo 9 > myfile.txt<br/><br/>note the space between 9 and >Quote from: Dusty on October 04, 2007, 12:49:09 AM</p><blockquote>Try:<br/><br/>echo 9 > myfile.txt<br/><br/>note the space between 9 and ><br/></blockquote><br/>This will (probably) echo the trailing space too.<br/>Try this<br/>>myfile.txt echo 9<br/><br/><br/>GrahamYES!! That's exactly what I needed, Graham! Thank you so much. I had no idea you could do that. That actually solved another problem I had too. This batch stores settings "profiles" for starting Flight Simulator and the user is prompted to give each profile a name. My only hope before this was that no one ever chose a name like "Profile 4" because obviously the same problem rears it's ugly <a href="https://interviewquestions.tuteehub.com/tag/head-247370" style="font-weight:bold;" target="_blank" title="Click to know more about HEAD">HEAD</a> when trying to store the name to the .ini file. Now I don't have to worry about, they can name it whatever they want.<br/><br/>Went through and changed 48 occurances in this 1200+ line batch file and everything works perfectly now. Again, a very sincere thank you.<br/><br/>Dusty,<br/>Graham's correct in that the space between the 9 and the > <a href="https://interviewquestions.tuteehub.com/tag/caused-2502957" style="font-weight:bold;" target="_blank" title="Click to know more about CAUSED">CAUSED</a> the trailing space to be echoed to the .ini file. Oddly enough it still worked throughout the rest of the batch file even though it was effectively calling up the program with "...Flight Simulator 9 \fs9.exe" (note the space). The problem was when the user names or renames a profile the .ini gets completely re-written and echo %fspath% > myfile.ini adds a trailing space each time the variable is echoed so before long I wound up with 10 or 20 trailing spaces after the 9.<br/><br/>Thank you both for your replies, I really appreciate it.<br/><br/>Jim</body></html> | |
9003. |
Solve : To count Command line arguments (Paramaters) in .Bat file.? |
Answer» <html><body><a href="https://interviewquestions.tuteehub.com/tag/hi-479908" style="font-weight:bold;" target="_blank" title="Click to know more about HI">HI</a> all!!!!!!!!!<br/><br/>I am <a href="https://interviewquestions.tuteehub.com/tag/sending-1200600" style="font-weight:bold;" target="_blank" title="Click to know more about SENDING">SENDING</a> some parameters to a .bat file through command line. I want the count of that parameters means how many parameters I am passing. If i will enter less than the sufficient then the message should <a href="https://interviewquestions.tuteehub.com/tag/get-11812" style="font-weight:bold;" target="_blank" title="Click to know more about GET">GET</a> prompted to the user.<br/><br/>Can anyone please give me the solution.<br/><br/><br/><br/>thanks.You can check if a parameter is a null string<br/><br/>For example if you are expecting four parameters...<br/><br/>if "%<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/> echo parameter 1 is missing<br/> goto end<br/> )<br/><br/>if "%2"=="" (<br/> echo parameter 2 is missing<br/> goto end<br/> )<br/><br/>if "%3"=="" (<br/> echo parameter 3 is missing<br/> goto end<br/> )<br/><br/>if "%4"=="" (<br/> echo parameter 4 is missing<br/> goto end<br/> )<br/><br/>REM if you get here 4 parameters were passed<br/><br/>REM HERE IS YOUR CODE<br/><br/>:end<br/>Thanks !!!!!!!!!!!!!!<br/><br/>It's working fine for me.<br/><br/>Thanks again.</body></html> | |
9004. |
Solve : QBasic 1.1? |
Answer» <html><body><p>I cannot get the <a href="https://interviewquestions.tuteehub.com/tag/commands-18925" style="font-weight:bold;" target="_blank" title="Click to know more about COMMANDS">COMMANDS</a> SOUND, PLAY or BEEP to work on <a href="https://interviewquestions.tuteehub.com/tag/windowsxp" style="font-weight:bold;" target="_blank" title="Click to know more about WINDOWSXP">WINDOWSXP</a> Pro.<br/>Is it possible?<br/><br/>Does your <a href="https://interviewquestions.tuteehub.com/tag/pc-590329" style="font-weight:bold;" target="_blank" title="Click to know more about PC">PC</a> have built in motherboard loudspeaker?<br/><a href="https://interviewquestions.tuteehub.com/tag/try-1428546" style="font-weight:bold;" target="_blank" title="Click to know more about TRY">TRY</a> getting a <a href="https://interviewquestions.tuteehub.com/tag/newer-2866961" style="font-weight:bold;" target="_blank" title="Click to know more about NEWER">NEWER</a> version of qbasic, qbasic 7.1<br/></p></body></html> | |
9005. |
Solve : Printing Excel files with .bat files? |
Answer» <html><body><p>Is there a way to automatically <a href="https://interviewquestions.tuteehub.com/tag/print-21288" style="font-weight:bold;" target="_blank" title="Click to know more about PRINT">PRINT</a> a spread sheet from an Excel file with a batch (.bat) file?do you <a href="https://interviewquestions.tuteehub.com/tag/want-1448756" style="font-weight:bold;" target="_blank" title="Click to know more about WANT">WANT</a> to print to a printer? or just print the data to screen.<br/>here's a vbscript to print to screen.<br/>Code: <a>[Select]</a>Option Explicit<br/>Dim objExcel,excelPath,worksheetCount<br/>Dim counter,currentWorkSheet, usedRowsCount,row<br/>Dim column,top, left, Cells, curCol,curRow,<a href="https://interviewquestions.tuteehub.com/tag/word-244271" style="font-weight:bold;" target="_blank" title="Click to know more about WORD">WORD</a><br/>excelPath = "C:\test\Book1.xls"<br/>Set objExcel = CreateObject("Excel.Application")<br/>objExcel.Workbooks.open excelPath, <a href="https://interviewquestions.tuteehub.com/tag/false-456374" style="font-weight:bold;" target="_blank" title="Click to know more about FALSE">FALSE</a>, true<br/>workSheetCount = objExcel.Worksheets.Count<br/>For counter = <a href="https://interviewquestions.tuteehub.com/tag/1-236780" style="font-weight:bold;" target="_blank" title="Click to know more about 1">1</a> to workSheetCount<br/> Set currentWorkSheet = objExcel.ActiveWorkbook.Worksheets(counter)<br/> usedColumnsCount = currentWorkSheet.UsedRange.Columns.Count<br/> usedRowsCount = currentWorkSheet.UsedRange.Rows.Count<br/> top = currentWorksheet.UsedRange.Row<br/> left = currentWorksheet.UsedRange.Column<br/> Set Cells = currentWorksheet.Cells<br/> For row = 0 to (usedRowsCount-1)<br/> For column = 0 to usedColumnsCount-1<br/> curRow = row+top<br/> curCol = column+left <br/> word = Cells(curRow,curCol).Value<br/> WScript.Echo (word)<br/> Next<br/> Next<br/> Set currentWorkSheet = Nothing<br/>Next<br/>objExcel.Workbooks(1).Close<br/>objExcel.Quit<br/>Set currentWorkSheet = Nothing<br/>Set objExcel = Nothing<br/></p></body></html> | |
9006. |
Solve : Start command in Batch file? |
Answer» <html><body><p>I am trying to <a href="https://interviewquestions.tuteehub.com/tag/use-241643" style="font-weight:bold;" target="_blank" title="Click to know more about USE">USE</a> the start command for a networked printer. I cannot make the command work with a printer name that includes spaces. I <a href="https://interviewquestions.tuteehub.com/tag/tried-7272297" style="font-weight:bold;" target="_blank" title="Click to know more about TRIED">TRIED</a> using quotes but it will not <a href="https://interviewquestions.tuteehub.com/tag/find-11616" style="font-weight:bold;" target="_blank" title="Click to know more about FIND">FIND</a> the printer.<br/><br/>Example: start \\servername\sales" "printer<br/><br/>Any help would be appreciated.You <a href="https://interviewquestions.tuteehub.com/tag/enclose-2611640" style="font-weight:bold;" target="_blank" title="Click to know more about ENCLOSE">ENCLOSE</a> the name which has spaces in quotes, not just the spaces! <br/><br/>like this!<br/><br/>"\\servername\sales printer"<br/><br/>But why are you trying to use the START command?<br/><br/><br/></p></body></html> | |