This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 8901. |
Solve : Grep parameters in a make file? |
|
Answer» Hi, |
|
| 8902. |
Solve : Move cursor with batch file? |
|
Answer» Greetings. I'm not SURE this is the correct forum to ask something like this, but I've got to start somewhere, right? We've got an IBM mainframe, with 3270 on our machines to access the data. We can write VB script to automate the completion of repetitive tasks, and it actually saves countless hours of what would otherwise be MANUAL work. The problem is that when running a script, the speed is strangly dependent upon whether or not the mouse cursor is moving over the VB file. For example, say my VB script can perform a transaction in 5 seconds when the mouse is not moving over the VB file that is running. I can then move the mouse cursor in any direction or distance, as long as it is moving somewhere over the VB script file, and the script can all of the sudden perform the same transactions in 2 seconds. My first thought was to get one of those things people have on their desks that rock back and forth, producing a repetitive blue wave, and simply sit my mouse on it. My next thought was to have a program that would just move the cursor around. I'm not even sure that is possible, let alone how I would go about doing it. Any ideas or thoughts? Thanks. I was unaware VBScript even ran on IBM mainframes. It doesn't. He wrote Quote We've got an IBM mainframe, with 3270 on our machines to access the data. By "3270" I think he means a terminal emulator program that mimics an IBM 3270 terminal. I would be interested to know how the PC or PCs running this communicate with the mainframe (serial link, modem and phone line, ethernet?) and also how this is set up (priority, serial port interrupts, etc) and whether the mouse is serial or PS/2, and (whichever one it is) if it has been swapped for the other type, and most of all, since they are using a mainframe, and presumably would have some kind of support available, why they are not consulting with support personnel instead of dreaming up an almighty kludge! I presume the VBscript is running in a command window. Also there is a great deal we don't know about the VISUAL Basic Scripts, what the "repetitive tasks" are that they automate, how the scripts were written, etc.Salmon You hit the nail on the head, the 3270 application is a terminal emulator that opens up a window that looks like something from 1980. There is no mouse activity at all, with the exception of copy and paste. There is a macro feature built into the application that lets us program the keys that would normally be keyed, but it is very old VB. The script runs in another window, as you guessed, and when the mouse is moving over it it screams. When the mouse is not moving over it, it is like a cold turtle swimming in frozen molassas in Alaska in the middle of January. As for how it connects to the mainframe, I couldn't tell you, since it comes pre-installed on all of our machines, and the only connection we have is our ethernet. In any event, I found the answer in AUTOHOTKEY. Nifty little program that will simply move the cursor back and forth. I know it sounds strange, but I tested it this morning on 100 identical transactions. The time it took without the mouse moving was 0:06:32. The time it took with the cursor moving back and forth via the AutoHotKey program...0:00:26. As for IT helping us with an issue like that? Forget it. GregQuote AutoHotkey - Free Mouse and Keyboard Macro Program with Hotkeys ... Good solution. Quote from: Geek-9pm on June 29, 2011, 03:09:51 PM Good solution. Wow...Quote from: Geek-9pm on June 29, 2011, 03:09:51 PM Good solution. Ridiculous. I knew this reminded me of something... I found a reference to what was niggling at the back of my mind. Good old Old New Thing. http://blogs.msdn.com/b/oldnewthing/archive/2006/02/20/535440.aspx Quote Sometimes, people discover that a long-running task runs faster if you hold down the mouse. How can that be? I notice that gsnidow mentioned "VB Script" and later on changed this to "but it is very old VB". Visual Basic and Visual Basic Script are very different things. I also notice that in the responses to the above quote article, it was mentioned that Gnome-Terminal in Linux had been prone to a similar problem, subsequently solved. Also the related problem "why does my application run faster when I wiggle the mouse over the main window?" http://blogs.msdn.com/b/oldnewthing/archive/2005/02/17/375307.aspx |
|
| 8903. |
Solve : Macro help needed - please!? |
|
Answer» I have a macro that I RUN on my Word documents (MS Word 2003-2007). I need to add to it so that it strips out all TABS and indents in all Word documents within a folder. Below is the macro. I know nothing about macros, so just need some advice on how to do this! Thanks! I have a macro Below is the macro. I know nothing about macros So how did you get it? You could try typing "Word macro remove tabs and indents" into Google... you might find stuff like this http://word.tips.net/T001174_Removing_Tabs_Used_to_Indent_a_Paragraph.html |
|
| 8904. |
Solve : multiplying in a batch? |
|
Answer» I search the site a little and found not much on this topic Tried some things and so FAR nothing has WORKED so: Please Explain how to Fix Use set /A to do Arithmetic Quote from: Salmon Trout on July 02, 2011, 02:03:04 PM Use set /A to do ArithmeticThank you Mister Fish Man you are very helpful as always Kudos to youWhy do people keep making delay programs in Batch? A suitable delay program was written about twenty years ago. It isn't a "delay program in batch". It's a batch script which asks the user for a number which represents a desired delay measured in minutes. The script then multiplies that number by sixty and supplies it to a Windows program, timeout.exe, which pauses execution for a time which needs to be supplied as a number of seconds. Code: [Select]C:\>timeout /? TIMEOUT [/T] timeout [/NOBREAK] Description: This utility accepts a timeout parameter to wait for the specified time period (in seconds) or until any key is pressed. It also accepts a parameter to ignore the key press. Parameter List: /T timeout Specifies the number of seconds to wait. Valid range is -1 to 99999 seconds. /NOBREAK Ignore key presses and wait specified time. /? Displays this help message. NOTE: A timeout value of -1 means to wait indefinitely for a key press. Examples: TIMEOUT /? TIMEOUT /T 10 TIMEOUT /T 300 /NOBREAK TIMEOUT /T -1 Sorry, I was thinking of the SLEEP program somebody wrote awhile back. Quote from: Geek-9pm on July 03, 2011, 02:13:37 AM Sorry, I was thinking of the SLEEP program somebody wrote awhile back. That is the one I prefer. Quote from: Geek-9pm on July 02, 2011, 08:03:48 PM Why do people keep making delay programs in Batch?Im no Programer or anything like that so What is a Delay Program Quote from: millergram on July 05, 2011, 04:51:19 PM What is a Delay Program A Program that delays.Most delay programs written in batch use ping to the reply back address: PING 127.0.0.1 -n 6 for a 5 seconds delay. Here is a delay batch that always delays to within 1/100 secs regardless of machine: Code: [Select]@echo off&goto :start :Delay milliseconds echo.Delay milliseconds echo.Delays for the specified # of milliseconds echo.Always accurate to within 10 milliseconds echo.Returns error of precision in milliseconds exit /b 1 :start if [%1]==[] goto :Delay Syntax if /i %1 geq 600000 goto :Delay Syntax setlocal enableextensions set correct=0 set /a msecs=%1+5 if /i %msecs% leq 20 set /a correct-=2 set time1=%time: =% set /a tsecs=%1/1000 2>nul set /a msecs=(%msecs% %% 1000)/10 for /f "tokens=1-4 delims=:." %%a in ("%time1%") do ( set hour1=%%a&set min1=%%b&set sec1=%%c&set "mil1=%%d" ) if /i %min1:~0,1% equ 0 set min1=%min1:~1% if /i %sec1:~0,1% equ 0 set sec1=%sec1:~1% if /i %mil1:~0,1% equ 0 set mil1=%mil1:~1% set /a sec1+=(%hour1%*3600)+(%min1%*60) set /a msecs+=%mil1% set /a tsecs+=(%sec1%+%msecs%/100) set /a msecs=%msecs% %% 100 ::check for midnight crossing if /i %tsecs% geq 86400 set /a tsecs-=86400 set /a hour2=%tsecs% / 3600 set /a min2=(%tsecs%-(%hour2%*3600)) / 60 set /a sec2=(%tsecs%-(%hour2%*3600)) %% 60 set /a err=%msecs% if /i %msecs% neq 0 set /a msecs+=%correct% if /i 1%msecs% lss 20 set msecs=0%msecs% if /i 1%min2% lss 20 set min2=0%min2% if /i 1%sec2% lss 20 set sec2=0%sec2% set time2=%hour2%:%min2%:%sec2%.%msecs% :wait set timen=%time: =% if /i %timen% geq %time2% goto :end goto :wait :end for /f "tokens=2 delims=." %%a in ("%timen%") do set NUM=%%a if /i %num:~0,1% equ 0 set num=%num:~1% set /a err=(%num%-%err%)*10 endlocal&exit /b %err% This is helpful if timing is critical or if one wishes to measure the code execution time for a project the code is similar.Somewhere there is a delay or sleep program in the old NT stuff. In my personal stuff I have something hat came out of then-old Borderland Pascal library. Sorry, I can't find a version of it except for the one in my stuff. I don't thin they will let me attach it here. They are afraid of virus. One form of it is SLEEP milliseconds You hare to make in from the windows API stuff.Quote from: Geek-9pm on July 07, 2011, 02:13:37 AM Somewhere there is a delay or sleep program in the old NT stuff. In my personal stuff I have something hat came out of then-old Borderland Pascal library. Sorry, I can't find a version of it except for the one in my stuff. I don't thin they will let me attach it here. They are afraid of virus. Code: [Select]#define WIN32_LEAN_AND_MEAN #include <windows.h> int main (int argc, char *argv[]) { int convert=0; if(argc==1) { printf("enter number of ms to sleep.\n"); return 0; } convert=atoi(argv[1]); Sleep(convert); return 1; } Or, In Pascal (FreePascal, to be specific): Code: [Select]program Wait; uses sysutils; var SleepAmount:Integer; StrParam:String; Code:Integer; begin if ParamCount >=1 then begin StrParam :=ParamStr(1); Val(StrParam,SleepAmount,Code); Sleep(SleepAmount); exit(); end; writeln('Usage: Sleep <milliseconds>'); end. etc. Implementing something akin to "sleep" is pretty trivial, regardless of the language, or platform. (the above FreePascal example compiles and works on linux, for example) Also: Quote In my personal stuff I have something hat came out of then-old Borderland Pascal library.If it was a Pascal program (that you compiled) it might not work because it's 16-bit, but also, if it used the crt module it would crash on startup with a divide overflow (or a similar error) on anything newer than about a 486. (This of course would go for any "example" .pas files) Thank you BC. Stuck my foot in mouth again. Yes, it is so trivial, yet some many people want to rite it in a batch file. Somebody shroud compile a short, sweet win32 EXE that will count in tenths of a second or break from the keyboard. Using the system timer, I believe, is only useful down to 55 milliseconds. I used that years ago in a telecom program written in QBASIC. As I recall, Borland had a micro timer that nursed the hardware for very short time events. |
|
| 8905. |
Solve : Playing sound with a batch? |
|
Answer» I would like to play WINDOWS sound with a batch FILE but cannot find a method that works |
|
| 8906. |
Solve : Computer does not boot after Verifying DMI Pool Data...? |
|
Answer» Hi all, Shuttle is a mini PC, you cannot use e.g. a Dell or other hard drive on it, they won´t fit. I have been using Shuttles for 8 years. I have two, an ST62K and an SN78SH7. I am involved in several Shuttle forums. They take normal hard drives. Trust me. Anyhow Dell assemble computers. They do not make hard drives. Thanks, guys. Good to know about the hard drive. If Shuttle takes normal drives, it´s worth checking out. I will try one of the live CDs you recommended and will let you know how it goes. |
|
| 8907. |
Solve : XCOPY Problem? |
|
Answer» Hi all, also, why does COPY not work in this situation? How does it not work? Error messages? Usually it's easier to get COPY to work than XCOPY. Tried: Code: [Select]echo F | XCOPY "C:\TEST\TEST1\TEST2.DBF" "\\server\shared\test\test1\testSplit\LiveData\%1A.dbf" and i get 'Program too big to fit in memory' The COPY error i get using Code: [Select]COPY "C:\TEST\TEST1\TEST2.DBF" "\\server\shared\test and test\testSplit\LiveData\%1A.dbf" is 'too many parameters'ok new development. the actual copy to location I am using is Code: [Select]echo F | XCOPY "C:\TEST\TEST1\TEST2.DBF" "\\SERVER\TEST\Data and Analysis\UplSplit\LiveData\%1c.dbf" which is where i get the 'Program too big to fit in memory' but changing that to below works and the piping the F has done the job too: Code: [Select]echo F | XCOPY "C:\TEST\TEST1\TEST2.DBF" "\\SERVER\TEST\IT Group\TEST1\UpSplit\LiveData\%1b.dbf" So this seems to point at a problem with the length of the location name?Quote So this seems to point at a problem with the length of the location name? Doubtful. What format is the date from FoxPro (%1)? The interpreter seems to be choking and this is the only variable in the command. Post the date format, we may be able to show you how to fix it. Are you running these commands in a "pure" DOS environment?The date is sent from FoxPro and within FoxPro the date format is YYMMDD. I then just add a letter after the date. If it's not the UNC length then why does it work with another UNC (a shorter one) but not this one? Surely it cant be a problem with the %1 being passed from foxpro as it works with a different UNC? forgive my ignorance, but what is 'pure' DOS? I'm a newbie when it comes to all of this! ok to back up your theory, i ran the batch on its own outside of foxpro and it works fine, obviously the FILENAME is just a letter as no date is passed. so i end up with a filename called A.dbf. I then try and run it from foxpro and i get the 'Program is too big to fit in memory' message. I just cant get my HEAD round why it works with a different UNC. Also, if i map to the drive so have: Code: [Select]echo F | XCOPY "C:\TEST\TEST1\TEST2.DBF" "H\UplSplit\LiveData\%1c.dbf" this works perfectly,Depending what OS you're using, the length of each the source and destination path may indeed be a factor. If it works by mapping the drive, then the problem is solved. You might try RoboCopy if it runs on your system. turns out it was the length of the path so i've copied to another location with a shorter name and it works fine now. It wouldnt work with COPY said it couldnt find the path, but it works ok with XCOPY however, i'm now STRUGGLING with the fact it wont DEL the file. DEL says cant find the path too even though it's just successfully copied the file there. Any ideas?Quote I'm writing a batch that is run through FoxPro. I just noticed this line from the first post. I'm not familiar with FoxPro, so how exactly does this batch file run? On modern systems, file names can be up to 255 characters so that wouldn't seem to be a problem. Quote however, i'm now struggling with the fact it wont DEL the file. DEL says cant find the path too even though it's just successfully copied the file there. What happens if you use the shorter file name (mapped drive)? Why not post your batch file, mention what OS you're using and explain how the batch file gets executed. There is a bigger picture here that doesn't make a lot of sense. thanks for the help, now its copying to a shorter UNC it works fine, foxpro obviously cant cope with LONG UNC's. with regards to the DEL i ended up having to map to the drive anyway as foxpro cant 'set defualt' to a UNC, didnt really want to map as wanted to hide the contents from the user to avoid possible deletes/modifications, but alas they'll just have to accept some ownership. cheers all. Quote from: jimmy1981 on July 01, 2011, 04:55:52 AM thanks for the help, now its copying to a shorter UNC it works fine, foxpro obviously cant cope with long UNC's.Which version of FoxPro are you using? |
|
| 8908. |
Solve : Console2: spectacular shell wrapper? |
|
Answer» http://sourceforge.net/projects/console/files/ I really cannot praise this thing enough. Tabbed command prompts are simply awesome. Also, it's not limited to just using the built-in cmd.exe; I have it set up on my computer to have two tabs: one for command prompt, and one for power shell each with a custom background image; I'm going to add another one that starts the visual studio 2008 command prompt (cmd /k vcvars32.bat). I am usually sceptical about Windows console replacements because I have tried a few and most of them seem to have at LEAST one ANNOYANCE compared to the default Windows one. Console2 seems better than most; the jerky refresh I can live with; I like the easy colour palette control, but what is really annoying me is the (apparent) default overtype mode. I can hit INSERT to toggle the mode, but I type a command & hit Enter and when the prompt is presented again, it's back to overtype! This makes using command history a pain in the *censored*. At least the Windows console remembers the mode from command to command. Any ideas? Am I missing something? QUOTE from: Salmon Trout on July 02, 2011, 02:32:24 AM Am I missing something? I was; since Console is just a screen scraper for cmd.exe, you can set insert mode by default in the underlying cmd window. So... what's so great about Console2? The tabs? Quote from: Salmon Trout on July 02, 2011, 05:59:41 AM So... what's so great about Console2? The tabs?For me, The tabs are helpful, since I would often have 20 to 30 different command prompts open. Arguably, I ought to just close them when I'm finished, but once it get's to that many I no longer know which ones are still relevant for a task I am performing or plan to perform. Also, it allows the use of not just cmd, but also powershell, or cygwin's bash prompt. That said though, I did notice something; even though it's pinned to my taskbar, I don't actually use it very often, mostly because the muscle memory to Windows Key+R cmd generally takes less thought and is usually faster. And, because Console2 isn't something that is available by default I'm a little wary to actually use it as an all-out replacement. I also noticed that slightly off updating frequency after the Original Post. It's pretty much become just a novelty program that I don't actually use for serious purposes at this point.Quote from: BC_Programmer on July 02, 2011, 08:55:21 AM I did notice something; even though it's pinned to my taskbar, I don't actually use it very often [...] It's pretty much become just a novelty program that I don't actually use for serious purposes at this point. This has happened with every single "console replacement" I have ever tried. I suspect the latest, written in Python, PyCmd, is going to be the same. It has some interesting features - Ctrl-C Ctrl-X Ctrl-V copy/cut/paste, persistent command history, emacs support etc etc, but on the other hand (like so many) it's kind of unfinished.* Also it claims to helpfully abbreviate LONG paths to keep the (non-configurable) prompt short, but this kicks in with quite a short path string and can't be turned off. * Author says... Quote 4. Future plans http://sourceforge.net/projects/pycmd/ |
|
| 8909. |
Solve : wget errors? |
|
Answer» I USED wget to retrieve files from the web, but I dont want it to display crap in screen so I made it quiet. |
|
| 8910. |
Solve : hide prompt input (when asked for password)? |
|
Answer» Hi, |
|
| 8911. |
Solve : load contents of a text file into a variable.? |
|
Answer» is it possible to load the contents of a text file into a variable in a batch file. if so can can some one help help. is it possible to load the contents of a text file into a variable in a batch file. Quote from: pravinshembekar on October 18, 2007, 12:25:52 AM I have to read a .TXT file and have to store the contents of that file in a variable using the batch command. Hey I'm seeing double! and I haven't touched a drop... well, not much! Are you guys in the same class at school? Or in different schools in the same education system? Is there some kind of homework deadline looming somewhere in the world? Guys, you have to be clearer about what you want to do. Understand the task and your homework will be easier for YOU to do. You want to take the whole contents of a text file , an arbitrary number of lines, and store ALL OF THAT in one miserable little batch file variable? It would explode! That can't be what you mean, obviously. Until you clarify what is wanted, no USEFUL help will be FORTHCOMING. In fact, on here we like to see some examples of work you have done. We don't do people's homework for them. Maybe, in the interests of clarity, you could try scanning your homework assignments and posting the jpg on here NOPE, it is not homework, just another person struggling with the same PROBLEM. i dont know pravinshembekar, i just looked through the forum and found that thread. all that a side, does anyone know how to do it.what are you going to do after you load the whole file contents into a variable?Since you refuse to be any clearer about what you are trying to do, the short answer is No. You can't make a batch variable hold the "contents" of any arbitrarily chosen text file. Not all at once. Just think about it for a second. A batch variable can hold only one line of text. A randomly chosen text file could have any number of lines. In fact the question in nonsense. Maybe that isn't what you mean, but you have been asked for more information and you have not given it. Unless and until you do, this is where we stop, I think. what is in the text file? can u post a copy of file contents?Hi rhino_aus, Assuming you are using Windows XP, the following MS-DOS batch-file should do the job... Code: [Select]@echo off setlocal EnableDelayedExpansion REM ======== Load contents of text file into variable one line at a time ======== for /F "delims=" %%A in (TEST.TXT) do ( set LINE=%%A echo !LINE! ) PAUSE REM ======== Append **ENTIRE** contents of text file into one variable without LF/CR characters ======== set LINE= for /F "delims=" %%A in (TEST.TXT) do ( set LINE=!LINE!%%A ) echo !LINE! Here is an example of running this batch-file... Code: [Select]D:\TEST> type TEST.TXT This is an example of a text file which contains four lines. D:\TEST> TEST.BAT This is an example of a text file which contains four lines. Press any key to continue . . . This is an example of a text file which contains four lines. D:\TEST> Please NOTE that I would not recommend appending a LARGE text file into one variable. Please also NOTE that this batch-file excludes explanation mark characters ("!") as well as LF / CR characters. For example: Code: [Select]D:\TEST> type TEST.TXT This is an!!!! example of a!!!! !!!!text file which contains four lines!!!! D:\TEST> TEST This is an example of a text file which contains four lines Press any key to continue . . . This is an example of a text file which contains four lines D:\TEST> Hope that helps, JamesQuote from: James2000 on October 30, 2007, 12:43:39 PM Please also NOTE that this batch-file excludes explanation mark characters ("!") as well as LF / CR characters. For example: Exclamation? PS good code! I have similar question of this kind, I have to search for a content in .txt file then copy that content and i have to paste it into other txt file can anybody help me out |
|
| 8912. |
Solve : using the msg command? |
|
Answer» I'm wondering how, or if, it is possible to use the msg command to send a message to another computer. I'm wondering how, or if, it is possible to use the msg command to send a message to another computer. Basically you type msg username (which is the person you are typing to) then /SERVER:computername (which is the name of the PC you are sending it to then the message you want to send. I (when I used to do this) would use the net send command. An example would be C:\>msg coemah /SERVER:PC-one Testing this message INTERFACE thingy! The target PC would get a standard Windows box with something like "message from michaewlewis date time code" and then the text of your code (Testing this message interface thingy!) and an "OK" button to close the box. hmm... that's what I tried before and I get two errors each time I try: Error OPENING Terminal server otherComputer01 Error [5]:Access is denied. Is a password necessary? Is the msg command allowed in domains?If this is a school or office, messaging is often disabled by admins to avoid time wasting, distraction from work or study, or harrassment. Quote from: contrex on October 31, 2007, 12:17:18 PM If this is a school or office, messaging is often disabled by admins to avoid time wasting, distraction from work or study, or harrassment. I'm pretty sure it's not turned off, but if it is, how would I turn it on? I'm trying to find a simple way to send alerts to specific users, just in case I'm not at my own computer with my other tools for messaging. BTW, I am the network admin. You do have send message access permission? Terminal Services Configuration (tscc.msc) Open up the Properties of the RDP-Tcp connection object, PERMISSIONS tab, Advanced, Edit the entry you are interested in changing. Ok, I don't have a terminal server. It's starting to sound like it's necessary.... is it? Is tscc.msc only on servers? I don't have it on my xp machine. |
|
| 8913. |
Solve : Trim a string value? |
|
Answer» Dear All,
|
|
| 8914. |
Solve : trouble with creating a directory? |
|
Answer» Some COMMANDS don't work like MK dir,MKDIR,md. mkdir/? Better still, put a space between mkdir and /? |
|
| 8915. |
Solve : doing pop-up in batch? |
|
Answer» Hi, |
|
| 8916. |
Solve : display content of a list within a variable? |
|
Answer» Hi, |
|
| 8917. |
Solve : Good day people, can anyone enlighten me to what this command does.? |
|
Answer» I have been going through some files on a customers server, the old 'IT' guy was a bit of a whizz but stupid with it and lost his job due to stupidity and pron. |
|
| 8918. |
Solve : Take picture with webcam in dos. (command) ???? |
|
Answer» Hello everybody. |
|
| 8919. |
Solve : Dos prompt? |
|
Answer» Since I upgraded to WindowsXP Pro I haven't been able to, don't know how, change directorys. By right clicking on the MS-Doc Command icon and bringing up Properties then clicking the Suggest change your Cmd line box to read C:\WINDOWS\SYSTEM32\CMD.EXE and change your working box to read C:\ then when you click the icon you will always open cmd.exe and have just C:\> as the prompt. Or IMHO better still, CREATE a new shortcut on your desktop for cmd.exe Good luck Thanks Dusty, After I posted I discovered that I should have entered at the prompt: C:\WINDOWS\SYSTEM32> cd \QBasic, I forgot the slash. I have in my C:\Qbasic folder a program titled Cory.bas. I tried to open it using: C:\QBasic> QBasic /run Cory and C:\QBasic> QBasic /run Cory.bas but neither worked. LMK if this should this work? I already had a shortcut named: MS-DOS Command I renamed this, shortcut to Cmd.exe. In CMD.exe properties/Program Tab: I now have at the Cmd line C:\WINDOWS\system31\cmd.exe Working is:C:\WINDOWS\system32 I have this set to open as a window but when I want to copy a program from a forum to Qbasic I just need to change it to open as a window. I'm 79 and some of this is starting to FRAZZLE what little grey stuff I have left. You didn't indicate which version of QBasic you are using but... In the version I use (Qbasic 4.5) the interpreter is named QB not QBasic so the command to load it and run your program would be QB /RUN Cory.bas LMK what error message you get (if any) Upper case is used for emphasis only. At your prompt C:\Windows\system32 type cd\Qbasic... Then C:\QBasic> QBasic /run Cory and C:\QBasic> QBasic /runQuote from: chequer on October 28, 2007, 11:20:20 PM Since I upgraded to WindowsXP Pro I haven't been able to, don't know how, change directorys.Dusty, I managed to work it out. I had forgot that I had renamed Qbasic.exe to q.exe All I have to do is at C:\WINDOWS\system32> is to enter cd \qbasic to bring up, C:\Qbasic> then C:\Qbasic>q /run cory.txt to open the file. I am using QB 1.1 I have just bought a new Microsoft MultiMedia KEYBOARD 1.0A kb0186, It has a Fkey on/off BUTTON on it. On my old keyboard if I made a typing error at the Prompt, I could by pressing F3, bring back the text I had entered.. Regardless of the Fkey button being on or off it doesn't work now. In a program I use a lot, to save a lot of typing I have defined the F keys as, KEY 6, "WED" + chr$(13): key 7, "THU" +CHR$(13) etc..., won't work on my new Keyboard. Any clues? Quote from: patio on October 30, 2007, 06:13:07 AM At your prompt C:\Windows\system32 type cd\Qbasic...Thanks patio, I managed to work it out. I had forgot that I had renamed Qbasic.exe to q.exe All I have to do is at C:\WINDOWS\system32> is to enter cd \qbasic to bring up, C:\Qbasic> then C:\Qbasic>q /run cory.txt to open the file. I am using QB 1.1 See my reply to dusty |
|
| 8920. |
Solve : Routing issues, MS-DOS 6.22, Novell, and TINY (a sort of ssh/VNC)? |
|
Answer» Hi there everyone... first post |
|
| 8921. |
Solve : beep in dos? |
|
Answer» can anyone HELP me how to check WEATHER the beep in my ms-dos is on or off? |
|
| 8922. |
Solve : make zip/rar archive with bat file? |
|
Answer» HI, i want to MAKE a zip/rar archive of all text file in dir "d:\MAT" with a BAT file. is this possible? regds simus theirs a program called 7z.exe (7 Zip) all versions are listed here, http://www.7-zip.org/download.html includes a command line version , here http://downloads.sourceforge.net/sevenzip/7za442.zipIf you have winzip install you can also use it at the command line within your batch file! see: http://www.memecode.com/docs/winzip.html yp |
|
| 8923. |
Solve : why when i exit my command prompt it it asks me end now or cancel? |
|
Answer» I exit of my command prompt and then a |
|
| 8924. |
Solve : Shutdown Command? |
|
Answer» Hey, patio. Q: Is DOS dead in Windows 2000? Can I run an ancient DOS program or two that I still favor?it sounds pretty clear, doesn't it? But then, even pros are having some problems: MalekTips The title says: Quote Windows 2000 and DOS Help and TipsQuote but a form of DOS still exists. Emphasis mine...and therefore the DOS limitations on filenames no longer existed. I stand by my observation. Trust me after you see it as much as i have you'll agree. Quote from: Broni on October 21, 2007, 08:18:28 PM QuoteIsn't there a seven character limit that applies in DOS?Good QUESTION, but I believe, it doesn't apply to Win 2K, and later. Those Windows don't use real DOS. If I remember correctly, I was able to execute commands from Command Prompt under Win 2K, which didn't follow "7.3" rule. Just a point of clarification: In plain old MS-DOS, the format of filename.ext was 8.3 , not 7.3. Quote the format of filename.ext was 8.3Ooooops!!!....Thanks That is all fine and DANDY, but what about the shutdown command?When you open your Command Prompt, how does your prompt look like? C:\Documents and Settings\sharmall ?Whatever it is, your syntax should look like this: cd C:\Documents and Settings\sharmall\Desktop\shutdown shutdown /l /t:300 "The COMPUTER is shutting down" /y /cYou're amazing! It worked to perfection! (Then I had to abort it) Thank You!You're welcome but..... Quote Then I had to abort itYou're not playing any dangerous games on not yours computers, are you???No, I just tested it and the shutdown window appeared and I'm like like Yay! It worked! But then I'm like, holy crap it is going to close all my open programs! (Plus it takes forever for this to reboot Pentium II [laptop]) So I aborted it.Guys just a thought, but if I can add to the original question of shutting down. If your going to use a prompt to shut down the machine...... why not link it to "XCOPY" and BACK up some files along the way. One of my original thoughts was to copy documents when i finished with the computer for the night, then i got sick of coming back an hour later to turn it off so I ended up linking the two together. My pc now has a single "backup" button on the quickstart menu that initiates the backup and then switches the machine off after its done. A few weeks after that paranoia got me, so I got it to creat a "logfile.txt" after each backup so i could check when it was last completed.Quote from: trespasser on October 24, 2007, 04:40:35 PM If your going to use a prompt to shut down the machine...... why not link it to "xcopy" and back up some files along the way. This is exactly what I do every shutdown. |
|
| 8925. |
Solve : Sorting files to different folders - Help~? |
|
Answer» I need to create a batch file to sort the files into 2 different folders base on a WORD or a phrase. Let say I have 4 files, DSNO001, DSNO002, DSNO003, DSNO004 in Folder A. Only DSNO002 contains "Company ABC" which I want to put in Folder B, the other 3 files move to Folder C. How can I do it? Any expert can help me? Hi QK, |
|
| 8926. |
Solve : Is ther anyway to set the position of a new console window after using "start"? |
|
Answer» The title of the thread pretty much describes what I would like to know. The "Start" COMMAND OPENS up a new CONSOLE window, but the seem to open up pretty much in the same position when you open multiple windows, so is there any way to set where they will open prior to using the start command? You mean to change position of this: I don't think he means that. If you read the post, it seems pretty clear that he's talking about the command prompt START command. Z-Funk, as far as I know this is not easily possible in standard XP command language, but there is an extra command called CMDOW which you can download which will allow you to do this. http://www.commandline.co.uk/cmdow/ Contex, YES you understood my question completely (why would I ask where to change the XP start window in a DOS forum?) Anyway, thanks Contex. One last thing, is there any way to close other console windows that you've opened up using the "start" command. "EXIT" only closes the one you're currently working with. Quote from: Z-Funk on October 27, 2007, 06:20:15 AM One last thing, is there any way to close other console windows that you've opened up using the "start" command. "exit" only closes the one you're currently working with. CMDOW will do this also. |
|
| 8927. |
Solve : FOR in batch with enhanced variables? |
|
Answer» I am attempting a task that would work if I could use Does this feature really work, or is MicroSoft just jerking It works if you do it right, like Graham SAYS. !!!! That fixed it. I went back through the Windows Help system. There's nothing from which I could have inferred that reversal. (Thanks.) ============================================================ Gary Lynch | To send mail change no$pam in my [emailprotected]$pam.com | domain name to stacoenergy ============================================================I guess you just have to 'know' it In the old days, there were no enhancements so those of us used to how it used to work saw how the enhancements were slotted in. Good luck Graham |
|
| 8928. |
Solve : how to Find a file like windows search-Dos? |
|
Answer» DEAR All, How to write a msdos batch file to find a exe file like windows file search Thanks Jebesh S cd /d D:\ [where D is the drive letter] dir /s filename.exe [where filename is desired file] or dir /s *.exe to find all exe files Thanks for your immediate response, but i want to search globally for example.i wan to search a .exe file from any where( C: or d: or e:drive).the exe file also MAY be any where likely c: or d: or e: please LET me know whether it is possible in msdos SCRIPT (batch file) Thanks Jebesh S |
|
| 8929. |
Solve : HELP... how do i code a % within my command. ?? |
|
Answer» Hi all, THx for the reply, but please.......( as I would and do on Network System Mgmt sites).. VERIFY your posts\Replies..... Your solution is not valid and does not work as stated. n505mw, maybe some good manners would help you here? Shouting in capitals and loudly whining will not get you the quality help you want. We don't care what you would do on "Network System Mgmt sites". Your forum style is not valid and does not work as needed. Describe failure mode of supplied batch code. I'm still wondering why the answer was not available on your "Network System Mgmt. Sites"... you could try this ldap_sync -c "last_name LIKE 'A%%' AND type != 2308” -l “userid=?” |
|
| 8930. |
Solve : Squeak? |
|
Answer» Hello, ... What should I do? Did you mean, 'What should I do to get it to run properly under XP?' ? Do you have a floppy drive? While you are waiting for an XP person to come along and assist, here is something to experiment with: boot your computer to DOS, since that is what the game wants. ( www.bootdisk.com ) Then try running the game. You might discover that something is wrong with the game. This is a possibility needs to be considered. must be your OS, you need window 98, or I dun kno.Quote Did you mean, 'What should I do to get it to run properly under XP?' ? Sorry, that is what I mean. Quote Do you have a floppy drive? No, I don't. |
|
| 8931. |
Solve : how to know the file name? |
|
Answer» HI All, I'm trying to RETRIEVE the file name of my batch file inside the file itself. I know that %0% contains the file that I run, but I would like to remove the directory INFORMATION. I mean, if I have a test.bat file under c:\test and I run c:\test\test.bat .... %0% contains c:\test\test.bat instead of just "test.bat". I'm looking for something like basedir in linux.. Any hint ? Thanks a lot Stenichele, you typed too many percent signs. The variable that contains a batch file's path, name, and extension is %0 not %0%. You can use some of the STANDARD variable modifiers on the %0 variable to get the bare filename and extension. For full details of all the modifiers type FOR /? at the prompt Consider an (imaginary) batch file C:\Test Files\Batch\mybatch.bat Drive C: Path \Test Files\Batch\ name mybatch extension .bat %0 gives the full path, file name, and extension C:\Test Files\Batch\mybatch.bat %~n0 gives the name mybatch %~x0 gives the extension including the DOT .bat You can combine them so %~nx0 gives the filename and the extension only (no drive or path) mybatch.bat Actually you can build up the same result as %0 from parts as %~dpnx0 (drive, path, name, extension) Hi contrex, thanks a lot !! ste |
|
| 8932. |
Solve : Fixing Blue Screen of Death....Reg edit with MS-DOS Floppy startup? |
|
Answer» Hey everyone! I need some help with fixing my comp; it runs Win XP Pro with SP2. I understand that i can easily just re-install Windows, but that is my last resort. I am currently having some sort of registry problem, and i cant even start up in Safe Mode. I have already created a Windows XP MS-DOS startup disk, and i am really lost as to what to do from here. Here is the error i was receiving (on my blue screen of death): Hey everyone! I need some help with fixing my comp; it runs Win XP Pro with SP2. I understand that i can easily just re-install Windows, but that is my last resort. I am currently having some sort of registry problem, and i cant even start up in Safe Mode. I have already created a Windows XP MS-DOS startup disk, and i am really lost as to what to do from here. Here is the error i was receiving (on my blue screen of death): |
|
| 8933. |
Solve : capture file content as variable? |
|
Answer» i WOULD like to capture the content after the third comma . |
|
| 8934. |
Solve : list all computer in network? |
|
Answer» is there any dos COMMAND to list all the computer name or ip or both in my NETWORK?SEE your other post for replies. |
|
| 8935. |
Solve : regarding ping? |
|
Answer» Hello friends, Hello friends, When the ping command "times out" it means that a reply was not received from the remote system before a preset time limit was passed. The REASON could be that the remote system is down, or running very slowly, or there is a network problem. Or the remote system could be refusing pings. Many firewalls block pings because they let an potential attacker know the system is running.I believe to ping back n forth btwn two computers both need to configure their firewall to "Allow incoming echo requests". Go to Firewall settings in your control PANEL. Advanced tab. ICMP settings button. It's the first box. Here are some links on it: http://kb.iu.edu/data/aopy.html http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/hnw_understanding_firewall.mspx?mfr=trueQuote from: Deerpark on October 25, 2007, 04:10:33 AM Or the remote system could be refusing pings. Quite right, Deerpark. Also many web connected SERVERS, INCLUDING some well known ones, routinely refuse ping requests in order to reduce system workload. |
|
| 8936. |
Solve : COPY File? |
|
Answer» i would like to copy a.txt to b.txt and then CREATE c.txt echo. >> a.txt This (hopefully) adds an extra line to file a.txt, some it should show in c.txt. |
|
| 8937. |
Solve : Insufficient Memory to Install Windows XP - Help Needed!? |
|
Answer» It also happens when there is a previous Linux distro installed as well. Anyway, I thank you, contrex. From your words I could understand that there isn't a way to put the computer back to its initial state or, to be more specific, to put the conventional memory configuration back to what it was when the computer had came just right from the factory. You "understand" completely wrongly. "Conventional memory" refers to the first 640K of RAM, as seen by the MS-DOS operating system. I have now written that 3 times. Quote One more question, where is this DRDOS comes from? Is it from the OS CDROM? Yes. Genuine Windows XP disks do NOT have Caldera DR-DOS on them! Quote A copy of my actual XP-CD might be needed as I cannot be sure of its reliability Yeah yeah yeah. A genuine XP CD with Caldera DR-DOS? I don't think so. Nice try, but no cigar. Deerpark, I set up BIOS to start the computer from the CD, but as the computer is restarted, Boot from the CD turns, automatically, into the Caldera DR-DOS environment, instead of initialize Windows setup! [/quote] Then it is not a genuine XP install disk, or even a copy of one. It is something else. contrex, I don't know if you are trying to make from this issue some KIND of a contest. Anyway, I will not THROW myself up into a disruptive conversation. I would like to thank you all, properly, seeing that one got to give you CREDIT for trying to help others. The problem of this error was, indeed, setup disk-CD DAMAGE. Whether if it was a copy, a genuine, or "something else", whatever, I don't know, and, simply, I don't care anymore. I just bought another Operating System Install Disk (this time, I bought Vista) and EVERYTHING went right! No more issues referring to memory, it had just formatted the partitions and installed the OS. Here's the solution, buy a genuine CD install disk (don't ask anyone to buy it for you!) and clear away your install issues. Thanks! |
|
| 8938. |
Solve : I can't create a batch file to open the folder where the batch file located???? |
|
Answer» I can't create a BATCH file to open the folder where the batch file located (by explorer). |
|
| 8939. |
Solve : Expand value of the variable name stored within another variable? |
|
Answer» Hello there, @echo off[/tt] Quote 1 MY_CORE_HOME[/tt] You need to invoke another level of nesting call set MY_%PKG_NAME%_HOME=c:\home call echo 1 MY_%PKG_NAME%_HOME etc what happens is that the %PKG_NAME% is evaluated and substituted into the expression dont forget to double-up the %s inside a batch file GrahamNice catch Graham so finally to transfer the content of the variable into a one that i can access at the FIRST level I do: >call set TEST=%MY_%PKG_NAME%_HOME% >set TEST TEST=c:\home then I can use TEST directly for my manipulation! Thanks PS: I had to add % to get it work (see above) |
|
| 8940. |
Solve : Stop service Running on another Server using MS DOS Batch file code? |
|
Answer» Hi, |
|
| 8941. |
Solve : Pausing Help? |
|
Answer» Is there a way to pause for a certain amount of time in MS-DOS? ping -n 2 -w 1000 1.1.1.1 >nul Still, it is quite hard to get the timing accurate, so you may have to play around a bit with the -n variable.Oh, here's another way that you can pause (slightly more accurately I believe): Quote ping -n 1 -w 1000 1.1.1.1 >nul Except replace 3 with whatever number you want. You don't even have to include the numbers if you want.does PING Insert 7=(8-1) second delay work? i always use it is should work. i suppose..Quote from: Sharamall on October 20, 2007, 08:01:11 PM Is there a way to pause for a certain amount of time in MS-DOS? Another option - - use a third party utility program. ftp://ftp.simtel.net/pub/simtelnet/msdos/batchutl/ ftp://ftp.simtel.net/pub/simtelnet/msdos/batchutl/wait.zip Examples are in the included Readme.txt file. Does this work in Windows 2000? Sorry, I meant the syntaxes earlier in the thread. And they do work, so sorry for the spam.Quote from: Sharamall on October 21, 2007, 01:15:21 PM Does this work in Windows 2000? Without a quote, I'm guessing you are asking about wait.zip ? I don't know for sure about W2K, since I can't test it on that os. Since it is free, and the file is small and will d/l in a very short time, your best bet is to simply grab a copy and try it. As a matter of fact, after you do, please do come back here and post and let others know if it ran ok on W2K or not. By the way, your original post: Quote Is there a way to pause for a certain amount of time in MS-DOS?specified MS-DOS, not W2K. Quote from: Sharamall on October 21, 2007, 01:15:21 PM Does this work in Windows 2000?you can use sleep command, or create your own sleep..using vbscript Code: [SELECT]wscript.sleep(5000) 'sleep 5 secs save the above as myscript.vbs , usage : Code: [Select]@echo off rem ..my dos commands cscript /nologo myscript.vbs rem after sleeping 5 secs or you can create the script on the fly in your batch...using echo to file Code: [Select].... echo wscript.sleep(5000) > myscript.vbs cscript /nologo myscript.vbs .. del myscript.vbs Yes, those are all awesome and they work (I tested them). Now I need shutdown to work...I reopened this thread because I wanted to ask a question about the timed pause that was posted above. The ping thing: ping -n 1 -w 1000 1.1.1.1 >nul for example. But I thought ping sent a message to an IP address and waited for a response from that computer. So how does it work here? (Basically, explain why the syntax works)Here is how it works: ping -n 1 -w 1000 1.1.1.1 >nul You're sending 1 echo request (aka ping). -n 1 Code: [Select]-n count Number of echo requests to send. With a timeout of 1 second. -w 1000 Code: [Select]-w timeout Timeout in milliseconds to wait for each reply. To a nonexistent IP. 1.1.1.1 And >nul hides the text output from Ping. So you're pinging an IP that doesn't exist and telling Ping to wait 1 second for a reply that will never come. So since the the IP doesn't exist, after the timeout (which happens to be 1000 milliseconds) ping stops trying, and moves to the next operation? Awesome, I get it! |
|
| 8942. |
Solve : DOS with Wordperfect - changing font size, screen, size, background & font color? |
|
Answer» HELP! It has been a looonnnggg time since I was in the DOS environment - can't believe I actually wrote some files many, many years ago. Anyway, I have two computers. I use one (Windows XP) as my normal everyday computer for internet, etc. The other is simply a DOS COMPUTER that has WORDPERFECT 5.1 (I think) on it. This is my company computer. I do medical transcription. |
|
| 8943. |
Solve : Problem with string input under conditional? |
|
Answer» I am having a problem with reading user string input under a conditional statement set /p select="Select: " Fairly straight forward, what I need it to do when the user selects option 2, for him to enter the channels he wishes to scan. However, the parameter that needs to be entered is of the form "-channel 6" or "-channel 1-5", so I am appending the string "-channel" with the user input in the string %option%. However, for some unknown reason, no input is going into the string option. I've tried other string variables with the same result, when I echo the string I get nothing, the only difference of what I've been doing previously is that this is under a conditional "if" under option 2. What is the problem here? 1. The problem is that the WINDOWS NT command interpreter is somewhat simple minded. Using plain vanilla NT syntax, command scripts (preferred term, but many people still call them "batch files") are parsed just once, at run time. When the command processor reads a line of text, it expands any environment variables present.This means that setting variables inside FOR loops and conditional structures such as yours becomes problematic. The solution came with "delayed variable expansion" in Windows 2000. Enable it thus: (a) Place this statement at the beginning of the command script, or at any rate before the loop or conditional structure:- setlocal enabledelayedexpansion (b) The variables that need delayed expansion have exclamation marks front and back (American: exclamation points) instead of percent signs see this modified code which works... 2. Incidentally, the line "goto scan" within the conditional structure is redundant; if you get to that line, you're going to that label anyway! The label itself doesn't seem to serve any useful purpose - maybe it's a leftover from earlier experiments? Quote
Great, thanks, and also the explanation is appreciated. Another question, if I should start a new thread on this let me know. Is it possible to capture the text displayed in the counsol to a text file?Quote from: Z-Funk on October 21, 2007, 01:41:17 PM Great, thanks, and also the explanation is appreciated. As text The easiest way, if you are running the console window in Windows, is to click the icon at the top left corner of the console window, Once the "control menu" opens, select Edit. From there you can Select All, Mark, or Copy the text you require from the command window into the clipboard. Paste into Notepad. (Once some or all of the window contents are selected, pressing Enter does the same as Copy) As an image(This works with most if not all windows, not just command ones) Press the Right Alt and PrintScreen keys together. The whole command window, including border and title bar, is captured as an image and can be pasted with the edit menu of a graphics app such as Paint. Otherwise, of course you do know about redirection? Lol, thanks, but I know how to do it using windows functions, but I mean in a running batch file. For example, if I use a command with produces counsol output, could I make a script within the batch file to capture the counsol output. The problem I'm having with a particular command "> %temp%\fout.txt" isn't capturing all of the output of the command, so I thought that I could just capture the entire counsol outpout on the window and find what I want from there. Thanks in advance. Quote from: Z-Funk on October 21, 2007, 02:11:55 PM The problem I'm having with a particular command "> %temp%\fout.txt" isn't capturing all of the output of the command Could you describe a bit more fully, i.e. what is the command and what is not being captured? I presume the text file fout.txt differs in some way from the command's console output as seen on screen? (Which is odd) The command or program in question does not produce a set output. It is actually a continuous scan for available networks that it detects, so depending on the signals it recieves some networks popup and then dissappear, the console screen is constantly being updated depending on what data is being received. I want to put the available networks in a text file. The obvious way would just have the ACTUAL program put them in a text file. However, it is not my code, although it is open source, but even if I modified it to do so, once the source is updated by the devs, I would again have to modify it. My goal is just to create a shell around the program to make it easier to work with. In any event, the available networks while not in "fout.txt" is on the console screen. I don't know how "> %temp%\fout.txt" works so I don't know why they are not showing on the text file, but I went to c:\documents and settings\sauron\local settings\temp\fout.txt, and opened the text file and it just has the first line of output and that's it no matter how long I let the program run. Let me know if you need more information. I don't see why you don't tell me the name of this program; there may be some WORKAROUND that can be searched for. The program sounds a bit like certain Unix apps such as iwlist. I take it netsh won't do what you want? Sorry, the program is airodump-ng which is part of the aircrack-ng suite of software. The aircrack-ng suite of software is a native linux application. There is a limited windows version with a GUI, but this version is limited in terms of its full functionality. However, there is a cygwin port of the full aircrack-ng suite, as you know Cygwin is a Linux-like environment for Windows. Although Cygwin is not a way to run native linux apps on Windows, you can rebuild an application from source. This version since it is built primarily from the linux source does not have a GUI and runs from the windows console. I was trying to make a shell script to interact with the suite for easy use. There is such a script on linux, but for various reasons it doesn't interact the same way on the Cygwin environment. In particular, the program in question, "airodump-ng is used for packet capturing of raw 802.11 frames and is particularly suitable for collecting WEP IVs". It should be noted that aircrack is DEVELOPED for penetration testing purposes only. So I'm assuming that there is no way to capture the current screen output to a text file though a series of DOS commands? |
|
| 8944. |
Solve : Like to know the list of files created on particular date? |
|
Answer» Hi, |
|
| 8945. |
Solve : Problem with (Attrib) code? |
|
Answer» Hello DEAR all!! We must use qoutes for every folder which has spaces on their name?Yes. |
|
| 8946. |
Solve : Need help writing a script!!!!!!!!!!? |
|
Answer» Does anyone know how to do this? - input a string that is to be used for matching purposes set /P Quote - loop through the entire directory tree of your drive FOR dir /s Quote - loop through all the files on each drive *.* Quote - accumulate a total of all files that contain the input matching string set /a Quote -display the number of files on the drive that contain the input string using a formatted sentence like: echo, variables, This is an interesting little project, which, if you had been paying attention in CLASS, and read up a little bit, you should have no trouble in completing. Please feel free to post scripts which we can comment on and suggest improvements to. (We would have KNOWN it was your homework even if you hadn't said so!) |
|
| 8947. |
Solve : help with batch file? |
|
Answer» Hi everyone, i have batch FILE with 4 commands. 1st command start program. it should start the program and wait till it will close and after the REST is making backups. |
|
| 8948. |
Solve : scheduled tasks? |
|
Answer» i need a command LINE that will move a file to SCHEDULED task and MAKE it run everytime i logon. |
|
| 8949. |
Solve : Q&A Thread? |
|
Answer» Well as before CH is still poping up with the same stuff over and over... Should we post how to get to DOS when it is disabled? It was disabled at my school so I know how to get through.no |
|
| 8950. |
Solve : Way to set a string to a command output? |
|
Answer» I'm using Windos Xp professional corporate edition. i would like to know if there is a way to set a string to the output of a given command. Computer name \\C-8FCE127AFE9A2 I would like to be able to set a string to the addresses under "Workstations active on:". One of these: Quote NetbiosSmb (000000000000) Is there a way to do this in a standard dos batch file on windows xp pro? Thanks in advance. I'm not helping anyone called Sauron!! Seriously, I'll post something tomorrow. Which workstation did you want? Are there always 4? Quote from: contrex on October 20, 2007, 05:30:21 PM I'm not helping anyone called Sauron!! Ultimately, I wanted to let the user select from any one of the workstations. There will not always be 4, it depends on how many network adapters will be on the machine. This should illustrate the ideas needed: Quote
Saved as ch-adapt.bat Result of run: Quote
You still have leading spaces in the string, dunno if that will be a problem? Is the whole string desired, or part of it? Quote You still have leading spaces in the string, dunno if that will be a problem? Is the whole string desired, or part of it? First, thanks a lot. I thought it may involve making a separate file to first store the information. I just need the adapter address from the string for example: Quote {2FF4CC67-D07D-4FEB-85FD-860B1254C849} Agains, thanks for your help. I have a few questions since I'm new to batch programming. It looks like essentially that your storing the output of the "net config rdr" in a filed called fout.txt in the temp folder. Then you are sorting through that file looking for the identifying string "NetBT_Tcpip" storing them L, adding to a counter named "Count", then outputing the counter next to the the current string in L. The SECOND part looks like it is doing the same thing but that once the count variable equals the chosen number, then it stores the current string in L in chosen adapter. GREAT, I will now try to see if I can isolate just the numeric values from the output. (1) You don't actually need a separate file. It's just that my PC is not on a LAN so i could not just use the output of the command directly. This is how you could do that (note single quotes) for /f "delims==" %%L in ('net config rdr ^| find " NetBT_Tcpip"') do ( commands ) (2) Do you need just the hex string or do you want the curly brackets ("braces" in America, I believe) as well? If the string eg NetBT_Tcpip_{2FF4CC67-D07D-4FEB-85FD-860B1254C849} (00C0A8C16B59) is always a fixed length, you can just select so many characters from the string (first char is position 0) (with curly brackets) the 38 characters starting at position 20 set address=%chosenadaptor:~20,38% (without curly brackets) the 36 characters starting at position 21 set address=%chosenadaptor:~21,36% Or, parse out the chars in between the curly brackets (they will be the second token) with FOR add these lines to the end of my above batch to see what I mean Quote
Quote Quote It looks like essentially that your storing the output of the "net config rdr" in a filed called fout.txt in the temp folder. Then you are sorting through that file looking for the identifying string "NetBT_Tcpip" storing them L, adding to a counter named "Count", then outputing the counter next to the the current string in L. That is exactly right. You've been a great help, yea, I got the adapter addressed narrowed down using the numeric parameters ~20,38 (yes, I needed the curly brackets). One more question, how do I concatenate strings, for example, once I get the adapter address in a string, I need it appended to another string not in the original output, something like: Quote Test.dll|{2FF4CC67-D07D-4FEB-85FD-860B1254C849} Thanks again. Ultimately, these strings are going to be fed as parameters to another command so the syntax has to be just right. Quote from: Z-Funk on October 21, 2007, 07:36:05 AM You've been a great help, yea, I got the adapter addressed narrowed down using the numeric parameters ~20,38 (yes, I needed the curly brackets). Is that a pipe symbol | that I see after Test.dll? To concatenate strings, just put them one after another including any spaces needed e.g. Othercommand.bat Test.dll|%address% Otherprogram.exe Test.dll | %chosenadaptor:~20,38% can mix literal strings and variables set pet1=cat set pet2=dog echo %pet1% and %pet2% and pony set MENAGERIE=%pet1% and %pet2% and pony |
|