Explore topic-wise InterviewSolutions in .

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,

I am trying to use the grep command within a makefile but I'm having DIFFICULTY with the syntax e.g. :-

Code: [Select] $(shell $(GREP) "apple" fruitlist.txt)
RETURNS an error that the file can't be located, it appears that the parameters are read as ONE hence returning an invalid file name.
Is there a PARTICULAR separator I should be using?
Any help is appreciated thanks.

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.

GregApparently this is how VB scrip is helping the unemployment issue.

Now the IT department shave to hire somebody to rock the mouse back and forth to speed up the process. Just think of how this will help he under skilled people who can not otherwise hold a job.

Put an ad in the local newspaper:
mouse rocker wanted,
no experience needed.,
mouse provided.. Well, I can't tell you how many times I have sat there, racing the clock to a deadline, doing nothing but just what you suggested.I was unaware VBScript even ran on IBM mainframes. There is no native way in VBScript to do this, but if you have a VB compiler, you can build a class wrapper using the Windows API and use it within VBScript to move the cursor:

Class Wrapper:
CODE: [Select]Public Class SetCursorPos
Private Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" _
(ByVal x As Long, ByVal y As Long) As Long

Public Sub MoveTheCursor(ByVal xPos As Integer, ByVal yPos As Integer)
SetCursorPos(xPos, yPos)
End Sub
End Class

The above is for VB6; replace every occurrence of long to integer if using VB.Net

In your VBScript, add the following code:

Code: [Select]Set pointer = CreateObject("vbWrappers.SetCursorPos")
pointer.MoveTheCursor 100, 80

The 100 and 80 coordinates are arbitrary. Change as needed to hover in the correct spot.

Good luck.






Quote from: Sidewinder on June 29, 2011, 08:00:10 AM

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 ...
Introduction. AutoHotkey is a free, open-source utility for Windows. With it, you can: Automate almost anything by sending keystrokes and mouse clicks.
www.autohotkey.com

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?

This strange state of affairs typically results when a program is spending too much time updating its progress status and not enough time actually doing work. (In other words, the programmer messed up badly.) When you click and hold the mouse over the caption bar, the window manager waits for the next mouse message so it can determine whether you are clicking on the caption or attempting to drag. During this waiting, window painting is momentarily suppressed.

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!

Dim oShp As Shape
Dim oIShp As InlineShape

Dim myFile As String
MyPath = "C:\Convert\"
myFile = Dir(MyPath)

Do While myFile <> ""
If myFile LIKE "*.*" Then
Documents.Open FileName:=MyPath & myFile

For Each oShp In ActiveDocument.Shapes
oShp.Delete
Next

For Each oIShp In ActiveDocument.InlineShapes
oIShp.Delete
Next

Selection.WholeStory
Selection.Font.Name = "Courier New"
Selection.Font.Size = 12

With ActiveDocument.PageSetup
.TopMargin = InchesToPoints(1)
.BottomMargin = InchesToPoints(1)
.LeftMargin = InchesToPoints(1)
.RightMargin = InchesToPoints(1)

End With
Selection.MoveUp Unit:=wdLine, Count:=1
ActiveDocument.SaveAs FileName:=MyPath & myFile, FileFormat:=wdFormatDocument
Documents.Close (wdDoNotSaveChanges)
End If
myFile = Dir
Loop
End SubQuote from: CindyM on June 30, 2011, 01:37:38 PM

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:
Code: [Select]@echo off
title Batch Timer v1.00
mode con: cols=50 lines=15
:main
echo.Welcome To Batch Timer
set /p input=Minutes=
set input=%input%*60
timeout /t %input% /nobreak
echo.Done
Echo.Press Any Key To Continue!
Pause>nulif what i have i'm trying to make a simple timer and can not
the %input%*60 dosent work the WAY i want it to it comes out as
1*60 and i get an error message saying not with in valid ranges
Please EXPLAIN how to FixQuote from: millergram on July 02, 2011, 01:36:35 PM

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 Arithmetic
Thank 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?
A suitable delay program was written about twenty years ago.
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.

One form of it is
SLEEP milliseconds
You hare to make in from the windows API stuff.

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
mplay32 /play /close c:\windows\media\chimes.WAV
this does not WORK
and
start example.mp3
does not work either
any sugestions??Try Playwav from http://www.muconsulting.com/playwav/index.html

Understand it only plays .wav files.

8906.

Solve : Computer does not boot after Verifying DMI Pool Data...?

Answer»

Hi all,

Need help with the following:

Original error: Verifying DMI Pool Data....

After inserting a boot disk:
Starting ….

A:\> mode code con page prepare =((850) ega.cpi)
MODE prepare code page function completed
A:\> mode code con page select =850
MODE select code page function completed
A:\> keyb gr, keybrd2.sys
A:\>

Typed the following:
sys c:
Bad command or file name

fdisk \mbr

Bad command or file name
dir

List of files on A:\>
13 files in all

config.sys
Bad command or file name

autoexec.bat
A:\> mode code con page prepare =((850) ega.cpi)
MODE prepare code page function completed
A:\> mode code con page select =850
MODE select code page function completed
A:\> keyb gr, keybrd2.sys
A:\>

F8 during booting
Microsoft Windows Startup Menu
1 Normal
Enter a choice: 1

F5 = Safe Mode, Shift + F5 Command Prompt, SHIFT+F8 Step-by-Step-Confirmation [N]


Don´t have a start up or restore CD, just a boot disk.

Thanks for your answers.

Welcome!
Computer HOPE is the number one location for free computer help.
The forum will help EVERYONE with all computer questions.

Can you provide some detail about the computer and what history it has?

Have you tried to turn it out without the floppy in place?
The floppy disc you have appears to be part of an early installation set. But not all components are present. Do you have more floppy discs like that?
Hi Geek,

When I switch it on and try to boot, it freezes at "Verifying DMI Pool Data...". I made an MS-DOS boot disk from another PC that runs on XP Home. That´s all I got. This PC is a few years old, but it worked well until it got infected by malware, which I then removed. Then it started freezing. I have just exchanged the keyboard and mouse to make sure the peripherals are OK. Since the OS was pre-installed, I don´t have an installation CD. Even I had, reinstalling the OS would cause all my data to be lost, which I do not want to happen. Any idea how I can save the data?

CheersThe freeze up after DMI is almost ALWAYS caused by a hard drive that has corruption in the first sector or the boot partition. That does not mean the drive is bad. It just had a bad experience with some bad software.

Now we can make some progress. The topic has moved moved over to the DOS section because it sounded like you were working with an early DOS version. However, if your computer is less than 10 years old and it came with a preinstalled operating system, it was not DOS.

The floppy drive is not going to help you very much. To install the operating system over again requires the use of the CD-ROM drive and a suitable installation disc for an operating system. Let's suppose you had windows XP preinstalled on this computer.

Do NOT try ton format the hard drive with MS-DOS. It will destroy most or all of the data on the Hard Drive. But first, more questions.

Next question is: was this a major manufacturer ? Was it a Dell desktop? How about Gateway ? Maybe it was a Hewlett-Packard. Most OEM installation CDs are available from the respective manufacturer. Look around on the case for underside of the computer and see if there is a little tag with the name Microsoft on it and some numbers. That would be the COA, which means certificate of authenticity. If so, you're entitled to put the original OEM system back on the hard drive.

Now let's talk about backing up your data. You will need the help of a friend with another computer. The best way to do this is to carefully remove the hard drive from your computer and then slay the to your friend's computer. You can either use an external adapter, or you can just open up your friend's case and FIND the cable that goes to the CD-ROM and simply stick it on your hard drive. And of course the power connector also. If your friend has free space on his hard drive, you can make an image copy of the hard drive, or just copy over the files you need to a new folder on his PC. Later you can get it back. Such is my documents and my photos.

(I don't need to mention that you turn power off when doing stuff inside the PC case. Do I? Turn power back on only when it is safe to do so without shorting something. You can instantly sap a hard drive or motherboard if you mess up.)

Once you have your data off the drive, he can format the drive for you and you can put it back in your computer. Once the drive has been properly formatted, the thing swill not freeze up, instead say something like NTLDR is missing or No OS found, insert boot media. The drive is ready for the installation.

So at this point the important question is: what brand of computer do you have? And did you find the COA ? That is important information and makes a difference. It will determine how you will get a copy of the OS.
(On this forum we don't pirate software. But you don 't have to.)Hi Geek,

Thanks for your detailed advice. The manufacturer is Shuttle. It is a barebone. Very tricky to fix. Only opened it a couple of times when I exchanged the PSU. I got OEM software on it, but I got it through a dealer, they no longer offer support. Since I don´t want pirated software, the easiest way is to purchase a new copy. Do you think I could boot up from an external hard drive if I managed to install the new OS on it. Let´s say the external hard drive as master and the temporarily unavailable one as slave.

Regarding data backup, another tricky one. It is all confidential data. Just cannot go to a buddy and ask them to use their computer. Will have to find another way to back them up before the install. And Shuttle is a mini PC, you cannot use e.g. a Dell or other hard drive on it, they won´t fit.You can boot your PC from a CD drive that has a suitable OS on it.
For Windows, it can be a BartPE
http://en.wikipedia.org/wiki/BartPE
However, it requires a working PC to build it.
Many Linux version can boot from a CD and actually do stuff, like copy files.
There is a Boot CD for windows that is ready to go.
Here is a place to check out some free boot CDs that can help.

http://lifehacker.com/5157811/five-best-live-cds

Have a friend download one and burn the ISO to a CD, using a ISO burner. Like Nero or just about any of the popular CD burners.
Or: http://www.tucows.com/preview/507688
Hope this helps.
Quote from: imsyak on July 03, 2011, 01:46:13 PM

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,

I'm writing a batch that is run through FoxPro.

it basically copies a file from C and then places that COPY on a network folder.

Code: [Select]XCOPY "C:\TEST\TEST1\TEST2.DBF" "\\server\shared\test\test1\testSplit\LiveData\%1A.dbf"
the %1 is the date that is pulled from foxpro.

At the minute i keep getting a prompt for File name or Directory Name, it's a file so i press F and it works perfectly. How do i stop it
prompting for the F?

also, why does COPY not work in this situation?

thanks in advance, i'm out of ideas!You might try piping the F response into the XCOPY command:

Code: [Select]echo F | XCOPY "C:\TEST\TEST1\TEST2.DBF" "\\server\shared\test\test1\testSplit\LiveData\%1A.dbf"

Quote

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
---------------
- add some sort of a configuration mechanism (config file)
- custom TAB-completion for the arguments of common commands
- clean-up the mechanism that dispatches commands to cmd.exe (currently kind
of hacky)

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.
Is there a WAY to retrieve only the error and PRINT it to screen?

thanks
yp check the wget help section...if you can find the quiet option, you can find others that may(or may not) do what you want. -nv and -o options are what i can think of...look at the man page again.Thanks,

in fact the -o options outputs the information to a file, but if -q quiet mode is activated at the same time, the file is empty. This look to do exactly the same as a file redirection (> wget.log). So I have to set -nv non-verbose option with the -o option and then seek the generated file for errors. I can LIVE with that limitation but there SURELY are a variable set by wget (à la ERRORLEVEL) that can give me the error type/number right away, isnt-it?

yp

8910.

Solve : hide prompt input (when asked for password)?

Answer»

Hi,

I have a batch file that needs to ask the user a password if I do:

> set /p IN_PASSWORD=enter your password:
enter your password: PSWD

but I would like the command window to hide the letters with * as the user types it, like
enter your password: ****

is there a tool that would allow to overwrite a letter at a certain position?
is there a way to get input CHARACTER by character?

thanks
ypfor now I have something but I have to do a enter after each character in order to get it WORK, it LOOKS like this:

Code: [Select]:SET_PASSWD
set IN_PAWD=
set TEMP_PAWD=
set COUNT=0

:SET_PASSWD2
SET HIDEN_PAWD=
cls
FOR /L %%I IN (1,1,%COUNT%) DO call SET HIDEN_PAWD=!HIDEN_PAWD!*
set /p TEMP_PAWD=enter your password: %HIDEN_PAWD%
SET IN_PAWD=%IN_PAWD%%TEMP_PAWD%
set /a COUNT=%COUNT%+1
goto :SET_PASSWD2
so basically if I comment the cls command it gives me the output:
Code: [Select]enter your password: a
enter your password: *b
enter your password: **c
enter your password: ***d
enter your password: ****e
enter your password: *****f
enter your password: ******
So basically what I need now is to find a way to gather character one by one (without having to do enter) and then exits from my loop when the character entered is a actually an enter...

thanks
ypSince I got no answer
I give up and used the simple TRICK to change text color to be the same one as the background:

Code: [Select] ECHO enter your password:
SFK COLOR black
SET /p IN_PAWD=
SFK COLOR grey

the only thing is that if you copy/paste the content of the screen you will see it
and when you scolled up the command typed, you will see it either!

it fills my needs for now since it was not for nationnal security passwords
ypThis may be what you're looking for.
I got this online, didn't make it myself.
@echo off
SET REAL_PASS=pass
SET REAL_LENGTH=****

echo e100 B4 00 CD 16 88 E0 B4 4C CD 21> %temp%.\\\\scan.com
for %%? in (rcx A w q) do echo %%?>> %temp%.\\\\scan.com
type %temp%.\\\\scan.com |DEBUG %temp%.\\\\scan.com > nul

:pre
for %%? in (pass length) do set user_%%?=

:loop
set input=
cls
echo Type password: %user_length%
if \\"%user_pass%\\"==\\"%real_pass%\\" goto granted
if \\"%user_length%\\"==\\"%real_length%\\" goto denied
call %temp%.\\\\scan.com
if errorlevel=2 if not errorlevel=3 set input=1
if errorlevel=3 if not errorlevel=4 set input=2
if errorlevel=4 if not errorlevel=5 set input=3
if errorlevel=5 if not errorlevel=6 set input=4
if errorlevel=6 if not errorlevel=7 set input=5
if errorlevel=7 if not errorlevel=8 set input=6
if errorlevel=8 if not errorlevel=9 set input=7
if errorlevel=9 if not errorlevel=10 set input=8
if errorlevel=10 if not errorlevel=11 set input=9
if errorlevel=11 if not errorlevel=12 set input=0
if errorlevel=30 if not errorlevel=31 set input=a
if errorlevel=48 if not errorlevel=49 set input=b
if errorlevel=46 if not errorlevel=47 set input=c
if errorlevel=32 if not errorlevel=33 set input=d
if errorlevel=18 if not errorlevel=19 set input=e
if errorlevel=33 if not errorlevel=34 set input=f
if errorlevel=34 if not errorlevel=35 set input=g
if errorlevel=35 if not errorlevel=36 set input=h
if errorlevel=23 if not errorlevel=24 set input=i
if errorlevel=36 if not errorlevel=37 set input=j
if errorlevel=37 if not errorlevel=38 set input=k
if errorlevel=38 if not errorlevel=39 set input=l
if errorlevel=50 if not errorlevel=51 set input=m
if errorlevel=49 if not errorlevel=50 set input=n
if errorlevel=24 if not errorlevel=25 set input=o
if errorlevel=25 if not errorlevel=26 set input=p
if errorlevel=16 if not errorlevel=17 set input=q
if errorlevel=19 if not errorlevel=20 set input=r
if errorlevel=31 if not errorlevel=32 set input=s
if errorlevel=20 if not errorlevel=21 set input=t
if errorlevel=22 if not errorlevel=23 set input=u
if errorlevel=47 if not errorlevel=48 set input=v
if errorlevel=17 if not errorlevel=18 set input=w
if errorlevel=45 if not errorlevel=46 set input=x
if errorlevel=21 if not errorlevel=22 set input=y
if errorlevel=44 if not errorlevel=45 set input=z
if errorlevel=71 if not errorlevel=72 set input=7
if errorlevel=72 if not errorlevel=73 set input=8
if errorlevel=73 if not errorlevel=74 set input=9
if errorlevel=75 if not errorlevel=76 set input=4
if errorlevel=76 if not errorlevel=77 set input=5
if errorlevel=77 if not errorlevel=78 set input=6
if errorlevel=79 if not errorlevel=80 set input=1
if errorlevel=80 if not errorlevel=81 set input=2
if errorlevel=81 if not errorlevel=82 set input=3
if errorlevel=82 if not errorlevel=83 set input=0
if \\"%input%\\"==\\"\\" goto loop
set user_length=*%user_length%
set user_pass=%user_pass%%input%
goto loop

:granted
cls
echo Access granted.
goto pass_end

:denied
del %temp%.\\\\scan.com
cls
echo.
echo Access Denied.
echo.
echo.
pause
exit

:pass_end
cls
for %%? in (pass length) do set user_%%?=
for %%? in (pass length) do set real_%%?=
del %temp%.\\\\scan.com
echo.
echo. Acsess Granted.
echo.
echo.
pause
exitThanks Carbon!

This is exactly the kind of answer I was looking for!

but I looked at it and tried it but I cannot understand what does the program created at the beginning:

Code: [Select]>type %temp%.\\\\scan.com
e100 B4 00 CD 16 88 E0 B4 4C CD 21
rcx
A
w
q
I bet this is what it uses to gather character one by one since it is called just before checking the input...

at least I have a working example, thanks again!
yp

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.

thanks: RhInOQuote from: rhino_aus on October 27, 2007, 04:50:47 PM

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 checked msg /?, but got confused by it.
Anyone know how to do it?Quote from: michaewlewis on October 31, 2007, 11:54:24 AM

I'm wondering how, or if, it is possible to use the msg command to send a message to another computer.
I checked msg /?, but got confused by it.
Anyone know how to do it?

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,

I ve RED the regedit by using following script line
REG QUERY "HKLM\Software\Oracle" /v FORMS60.it returns the value like
FORMS60 REG_EXPAND_XZ d:\forms6i\FORMS60.but i need to show d:\forms6i\FORMS60 these part of the string only

please help me to trim this and also help me to show the trimmed value

Thanks
JebeshQuote


@echo off

SET string=FORMS60 REG_EXPAND_XZ d:\forms6i\FORMS60

REM 1: trim the string into its 3 tokens

for /f "tokens=1,2,3 delims= " %%a in ("%string%") do (
set token1=%%a
set token2=%%b
set token3=%%c
)

REM show the 3 SUB strings
echo token number 1 is %token1%
echo token number 2 is %token2%
echo token number 3 is %token3%

8914.

Solve : trouble with creating a directory?

Answer»

Some COMMANDS don't work like MK dir,MKDIR,md.
Tries them but don't now how to view and USE them.
Please give me a straight answer. I use Windows XP.mkdir/?

type that in CMDQuote from: lordoftheplat on October 31, 2007, 04:00:39 AM

mkdir/?

type that in CMD

Better still, put a space between mkdir and /?
8915.

Solve : doing pop-up in batch?

Answer»

Hi,

is there a way to do POP up in a batch file. I already know that MSG will display a MESSAGE with an OK button. But I would prefer a pop-up with YES and NO buttons or EVEN better someting where I could enter a text string.

thanks
ypyou can USE the MsgBox() function in vbscript

8916.

Solve : display content of a list within a variable?

Answer»

Hi,

I have a variable LIST=ELEM1;ELEM2;ELEM3
which command should I call to have for results
ELEM1
ELEM2
ELEM3


if I do the following command line; I do have only the first element of the list (while the other are probably in %J and so on)
> for /F "delims=;" %i in ("%LIST%") do echo %i
ELEM1


note that I do construct the LIST, so I can CHANGE the delimiters or the FORMAT if required.

thanks
found by myself

I change my list format to have space as delimiters LIST=ELEM1 ELEM2 ELEM3

SET AUTO_VARIABLE_LIST=%LIST%
:FOR_LOOP
for /f "tokens=1* " %%i in ("%AUTO_VARIABLE_LIST%") do (
call echo %%i
set AUTO_VARIABLE_LIST=%%j
)
if "%AUTO_VARIABLE_LIST%"=="" GOTO :END_LOOP else (
GOTO :FOR_LOOP
)
:END_LOOP



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.

Going through the old server I inherited I found this batch file, I understand that its designed to copy files from one drive to another and probably write a TEXT file at the end of copying, but I can't QUITE grasp the way its been written. I frequently use batch files myself and now prefer these to drag and drop as they seem quicker and I dont have to watch that stupid folder and flying paper crap ..... it MAY be an illusion but thats my preference.

The file in question is below, and my main boggle is whats with the ">" in the middle? Is this some sort of "xcopy" shorthand??

"\\SERVER1\120gig (H)\Backup\COPY TO BACKUP SERVER.BAT" > "\\SERVER1\120gig (H)\Backup\backup.txt"

I LOOK forward to you educated and varied replies.

Many ThanksThe ">" redirects the output from the batch to a file. So while the batch script would NORMALLY output text to the console, with the ">" it instead writes it to "backup.txt".

With one ">" the text will be written to the beginning of the file, overwriting anything currently in it. If you instead use two ">>" the text will be written to the end of the file, thereby appending the text instead of overwriting.

Check out this site for more redirection action:
http://www.ss64.com/ntsyntax/redirection.html


Many thanks, its very useful to know. Now that I know exactly what it does I may well start incorporating it into a few "batches".

Many thanks for your help.

8918.

Solve : Take picture with webcam in dos. (command) ????

Answer»

Hello everybody.

I BUSY making a security .bat file.
Is there any COMMAND or script so you can make a photo with your webcam and save it??

GREETINGS Ultimate-TesterIf you got some software with your webcam it might have a command line or batch mode. Did you GET any?
Only the drivers and a viewer are on the cd.
No command line or something.
I think I have to look on google or something for a command line webcam prog

Do you have any??I doubt very much a webcam will have DOS drivers...even so you would NEED a DOS based app to run it.

8919.

Solve : Dos prompt?

Answer»

Since I upgraded to WindowsXP Pro I haven't been able to, don't know how, change directorys.
At my Dos prompt I have, C:\WINDOWS\SYSTEM32>
I tried, cd Windows, but it won't work
If I type A: it will change to, A:\>
By right clicking on the MS-Doc Command icon and bringing up Properties then clicking the
Program tab, I have in the Cmd line box: C:\WINDOWS\system32\command.com, and in the Working box:, C:\WINDOWS\system32
Is this where I have to amend any of these lines and if so, what do I change them to and is it safe to do so.
I need to open or edit a BAS programs at C:\Qbasic so I get them into Notepad.
When you enter CD Windows the system is looking for a directory named Windows as a child (subdirectory) of C:\Windows\System32 which does not exist.

Use CD C:\Windows (Note the C:\)

Quote

By right clicking on the MS-Doc Command icon and bringing up Properties then clicking the
Program tab, I have in the Cmd line box: C:\WINDOWS\system32\command.com, and in the Working box:, C:\WINDOWS\system32

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.
At my Dos prompt I have, C:\WINDOWS\SYSTEM32>
I tried, cd Windows, but it won't work
If I type A: it will change to, A:\>
By right clicking on the MS-Doc Command icon and bringing up Properties then clicking the
Program tab, I have in the Cmd line box: C:\WINDOWS\system32\command.com, and in the Working box:, C:\WINDOWS\system32
Is this where I have to amend any of these lines and if so, what do I change them to and is it safe to do so.
I need to open or edit a BAS programs at C:\Qbasic so I get them into Notepad.
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...
Then C:\QBasic> QBasic /run Cory and C:\QBasic> QBasic /run
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

Note: I like to ramble on a lot, skip to the bold/italic/underlined text below if you just want my problem.

Well, I have a MS-DOS 6.22 machine (as stated in the subject) and you can probably guess that the box is running real DOS .

Well, I have an ethernet card - specifically a Realtec RT(L)8029(AS) (words in brackets sometimes admitted) in this 400MHz Celeron with 32MB of RAM and 160MB of HD space... this was just thrown "quickly" together from parts I had "around", I plan to upgrade (especially the HD ) and SWITCH to Linux or FreeDOS or something else at one stage, I'm just fooling around at the moment.

The point of explaining all that?
I'd really like my problem to GET resolved... but don't push yourselves too hard, as it'll be, well, wasted effort

Okay, now for the problem.

The card works, I have its packet driver, as well as PCIODI.COM (which I'll explain below).

TINY, my "DOS-based VNC system" works absolutely wonderfully, except it requires use of either the PCTCP or Novell Client32 TCP/IP stacks. I initially (after a long search) found the required PCTCP files off the net, and got everything working - I connected VIA another of my PCs (specifically my "main" box) to the MS-DOS machine (wow).

Then I discovered that the PCTCP stack system had been sold and was no longer available, except if I paid $100+ to its new owner.

YIKE.

So... I then began the long, long journey of Novell Client32.

And I managed to get it to "go"!!!

I first load the packet driver, then LSL, then PCIODI, then IPXODI, then NIOS, uncountable NLMs (including my network card's NLM)... and it shows the magic DHCP screen... and BOOM, it gets an IP off of DHCP.

My problem:
I can connect locally to 1.2.3.7 via the TINY client and up comes the display.
However... I can't connect via the internet (ie 'truly' remotely) and view the display.
What's so weird is that... REMOTE (ie out-of-my-network) clients can type and the keys are sent... yet the display doesn't update.

So, to sum up, I think that this is a routing issue between my router and the PC, and not so much to do with the actual machine itself.

I did try giving the machine my external "internet" IP, but that naturally didn't work

?!?!?!?!

Thanks in advance for any help you might be able to give!
-dav7

8921.

Solve : beep in dos?

Answer»

can anyone HELP me how to check WEATHER the beep in my ms-dos is on or off?

is there any command to play beep?

can how to on and off the beep in dos?

PELASE do tell me
i am waitingIf you motherboard has a speaker, you can beep in DOS. if not, you cannot.

1. strike CTRL + G on the keyboard while at the DOS prompt.
2. Type this at the prompt

echo aY | choice

3. If you have QBASIC, run this BATCH.

@echo off
echo beep> beep.bas
echo system>> beep.bas
qbasic /run beep.bas
del beep.bas
cls


rundll32 user32.dll,MessageBeep

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
DIALOG box COMES up with CHOICES of
end proggram or cancel. Why is this?You are clicking on the red X in the top right corner. You need to type EXIT and ENTER at the prompt to avoid this.

8924.

Solve : Shutdown Command?

Answer»

Hey, patio.
I agree, but it may be confusing.
If you read couple of sentences from PC World description: http://www.pcworld.com/article/id,61687-page,5/article.html
Quote

Q: Is DOS dead in Windows 2000? Can I run an ancient DOS program or two that I still favor?

A: The demise of DOS, to pinch a pithy line from Mark Twain, has been greatly exaggerated.

The terminology surrounding it has changed, but a form of DOS still exists. Windows 2000 calls it the Command Prompt rather than MS-DOS Prompt, and tucks it into the Start, Programs, Accessories menu. Windows 2000 won't let you reboot to the DOS prompt, as Windows 95 and 98 did, but you can run DOS executable files from within Windows 2000.
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 Tips
Quote
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
Quote
Isn'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.
I'm too lazy to turn my 2K on, now, so I'll wait for you to try it....LOL

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.3
Ooooops!!!....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 /c
You're amazing! It worked to perfection! (Then I had to abort it)

Thank You!You're welcome

but.....

Quote
Then I had to abort it
You'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.
[...] I got it to creat a "logfile.txt" after each backup so i could check when it was last completed.

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,

Assuming you are using Windows XP, the following MS-DOS batch-file should do the job...
Code: [Select]@echo off
if not exist Folder_A md Folder_A
if not exist Folder_B md Folder_B

for %%A in (*.txt) do (
find "Company ABC" %%A>nul
if errorlevel 1 (move %%A Folder_A) else (move %%A Folder_B)
)


Here is an example of RUNNING this batch-file...
Code: [Select]D:\TEST> DIR /b
DSNO001.txt
DSNO002.txt
DSNO003.txt
DSNO004.txt
FileSorter.bat

D:\TEST> FileSorter

D:\TEST> dir /b
Folder_A
Folder_B
FileSorter.bat

D:\TEST> dir /b Folder_A
DSNO001.txt
DSNO003.txt
DSNO004.txt

D:\TEST> dir /b Folder_B
DSNO002.txt

D:\TEST>

Hope that helps,
James

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:

Quote from: Broni on October 26, 2007, 08:41:01 PM

You mean to change position of this:

(picture of Windows XP Start Button menu)


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
(inside a batch file) the 'enhanced syntax for variable
references:

%~nI - expands %I to a file name only

which I first discovered this week. I am running MS WinXP,
Ver 5.1.2600 (with Svc pak 2) on a SysteMax Venture with a
3.4 GHz Pentium D, 1.00 GB of RAM.

The following is a 1-line batch file--t.bat:

for %%~nS in (*.c) do echo c51Cmd %%S NML SPV_BETA

The c51Cmd is another batch file. I will replace 'echo' with
'call' should I ever get this thing to work.

When I run it as shown, I get:
>
> M:\xxx>t
> %~nS was unexpected at this time.
>
> M:\xxx> for %~nS in (*.c) do echo c51Cmd %
> S NML SPV_BETA
>

I had doubled the percent sign, since it had been necessary
in all prior versions of Windows. I decided to remove one
'%':
>
> M:\xxx>t
> The following usage of the PATH operator in batch-parameter
> substitution is invalid: %~nS in (*.c) do echo c51Cmd %S NML SPV_BETA
>
>
> For valid formats type CALL /? or FOR /?
> t was unexpected at this time.
>
> M:\xxx> for %~nS in (*.c) do echo c51Cmd %
> S NML SPV_BETA
>

I read though all the HELP I could get from windows. On one
web forum I saw an inference that that the 'enhanced'
features could not be used unless extended PARAMETERS were
enabled. I found no WAY to query my command interpreter as
to whether this was true, but did find a way to run it with
them on:

cmd /E:ON
for %%~nS in (*.c) do echo c51Cmd %%S NML SPV_BETA
exit

No difference.

Does this feature really work, or is MicroSoft just jerking
my chain?
============================================================
Gary Lynch | To send mail change no$pam in my
[emailprotected]$pam.com | domain name to stacoenergy
============================================================Just one tiny mistake, the for %%S defines the variable, its after the DO that you use the variable expansion, like this below

for %%S in (*.c) do echo c51Cmd %%~nS NML SPV_BETA

GrahamQuote

Does this feature really work, or is MicroSoft just jerking
my chain?

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,
just joined, looks like fantastic site.
I need some help, first, I'm not a coder so please consider that when replying.

I need to run a command that will do a ldap sync against A.D. and the VENDOR states that it can't be run as a whole and it must be split up in groups of lastnames like A-G, then H-......
So, the base command is "Ldap_sync". This command alone would grab A-Z. IF the vendor had scripted the executable correctly and it didn't run out of MEMORY. ( vendor is COMPUTER Associates. BOO.....)

So i need to run this command ( which works fine when typed on a cmd prompt, but NOT when run from a .Bat file. ( It does not like the % that is embeeded within the command.)

ldap_sync -c "last_name LIKE 'A%' AND type != 2308” -l “userid=?”

Thank you all for reading this and verified SOLUTION.!You need to 'escape' the % char as it is special to DOS, your line should look like this -

ldap_sync -c "last_name LIKE 'A^%' AND type != 2308” -l “userid=?”

the ^ before the % MEANS treat it literally as a % and not the special meaning it normally has.
GrahamTHx 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.Quote from: n505mw on October 25, 2007, 01:31:28 PM

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,

First I want to say that I hope I posted in the right section.
Running Windows XP SP2 and just downloaded a game called Squeak.

The program was built to run under MS-DOS. When I started the program, it exits automatically. I went to properties and unticked the check box that said "Close on Exit". I ran the program again, but this time the title bar changes to [INACTIVE GAME.EXE]. Went back to properties, ticked the box that said "Close on Exit" and now when I open the game, it automatically exits. What should I do?Quote from: dairyman on October 28, 2007, 07:06:20 PM

... 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):

STOP: c0000218 {Registry File Failure}
The Registry Cannot Load the Hive (file):
\systemroot\system32\config\default
Or its log or alternate.
It is corrupt, absent, or not writable.

What is it that i need to do in the command prompt? Any help would be greatly appreciated, even if its just a lead in the right direction, because right now, i am quite the newb at navigating MS-DOS! Thanks everyone!

ALSO: If it wasn't obvious before, i do have another computer to perform neccessary operations as needed.thanks for the quick response! It looks to be exactly what i need! I wouldn't have guessed that the windows website would actually be USEFUL X-o. I'll let you KNOW how it goes, thanks for your help!ok, i'm still having problems...my Windows XP cd is a backup disk..it WORKS if a comp boots up normally, but it wont boot up from the cd unless you can already accesss windows int he first place...anyone know how i could initialize the boot up from my cd drive from a floppy disk (dos?)?can you explain a little more? , your in dos and your trying to boot the installation cd , from dos?
or your just trying to load the cd , instead of starting windows?Both, essentially, if that makes any sense:

I need to be able to access the recovery window, and then i can solve my issues from there (thanks to your previous link that is now gone for some reason?). In order to reach the recovery window (as i'm sure u well know, but i'd much rather be more clear this time =D), i need to be able to boot up off of the Windows XP installer CD since i cannot even make it through a windows boot up. The problem is, my Windows XP CD i have is a backup CD (original MIA), and its all i have; this CD works just fine for whatever reason if you run it while in Windows, where it manually restarts your computer, and your good to go, and everything runs just fine. Otherwise, if you designate in the bios to boot up off the CD, it doesn't FIND anything and continues on to booting up off the hard drive :-/. So, i thought that my best chance would be to somehow start my Windows XP CD through MS-DOS, as so far, thats the most i've been able to get to. So, if i can start it up with MS-DOS, or any other alternative method you can think of, i would appreciate it mucho =) Thanks for your time Diablo416 =)

have you tryed rebooting it with ctrl+alt+delete , after the cd fails to load .. so that the cd is inserted before it startsup , ive had similar problems.. and found success with that, im not completely sure but after you fix dos prompt to read a cd , once it does .. its going to ask to reboot anyways

http://www.microsoft.com/technet/archive/win98/tips/erd.mspx?mfr=true
that page underneith .. "adding the cd-rom driver" contains a solution to using a cd drive at dos prompt,
idealy if you can get a windows nt recovery disk , it will have an option to boot with a cd drive support, saves alot of time.. id send it to you myself, but i do not have an a:\ drive anymore and cant get it off the diskette.. ill see if i can track one down thats already online though

hope this helps, sorry for the delayDont worry, i appreciate all the help i can get, dont even worry about the response time, i'm not exactly hasty either =)

I'm not sure what you mean by a ctrl+alt+del boot, i've never done one before; whats different about it, and when do you hold it down? because initially after it fails to boot from the cd, it jumps right into booting off the HD, and then after it almost completely loads, i get my lovely BSOD...so i'm not sure when it is i'm supposed to hold it down.

Also, what do you mean by "so that the cd is inserted before it startsup"? Sorry, i just wish to clarify so we don't have any misunderstandings =)

"its going to ask to reboot anyways" -- Right, but hopefully it will have some sort of temporary storage to where it correctly boots off the Win XP Installer CD after it restarts the computer (i'm not sure exactly how it works, but i know something happens, read a little further)...because thats the only way i found that the Win XP Install CD works....heres what i mean by that...as i said before, when i run the CD normally while in Windows, and you select "install Windows", it says it will reboot the computer, and then after it restarts, it boots up off the Win XP Installer CD perfectly fine...i can reinstall windows/do whatever without a hitch. Why does it work then and not from a bios startup? I believe if i initialize some sort of startup other than the bios doing it, it will work due to some sort of boot record save.

I took a look at your link...and it seems like that would be a solution, but the problem is, i can't find "config.sys", and i wont have my specific cd-rom driver info, as the brands of my cd-roms are different. I guess if it came down to it, i could borrow the cd drive for this process, which really isnt that much of a pain, but none the less, i'm not sure where to find "config.sys"; searching for it via Windows turned up nill (hidden files and everything).

I saw that there was a 4.2 MB Windows startup disk that i could download when i was lookin stuff up (from the official Windows site, if i remember correctly)...it was the only worthwhile result i found besides what you've come up with...i'm not sure how exactly that will work (will it seperate it onto several floppys?)...is this the correct thing i would need? I thought the windows startup disk was only one floppy. Just curious to see if you thought this would be a waste of time and/or unlikely to be useful...cuz if it will work, i wouldn't mind going out and buying a few ancient floppys =). I'm in doubt due to the separation of the file that would be NECC to save it to floppys...not sure if it would correctly break it up for you, or if it would even work being broken up.

Thanks a lot for stickin with me man, hopefully we can fix this =) . I appreciate the help!!! =D Let me know what you think, i'll check back tomorrow.Hello y'all.......I've got the exact same problem as "Armenix" and I've quoted his post below. I cant read any responses on the forum though, so, I have to ask again. My computer is a Dell laptop. While I was online yesterday, the screen went black (I thought the battery died, but that wasn't it) I plugged in the power supply and hit the start button and the last page came back up. I continued working for a few minutes, but then the computer shut down. This may have been because I pressed the power button more than once, I don't know. Later, when I re-started, the BSOD came up. Now, problem is that when I do restart, it always gets to the BSOD and it won't let me go to any safe or MSdos page on startup. It also won't boot to the cd-rom. I don't have a floppy drive, so, what now? I am only slightly familiar with DOS, and moving around in the registry, so, please bear with me. Thanks

Quote from: Armenix on October 15, 2007, 03:54:20 PM

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):

STOP: c0000218 {Registry File Failure}
The Registry Cannot Load the Hive (file):
\systemroot\system32\config\default
Or its log or alternate.
It is corrupt, absent, or not writable.

What is it that i need to do in the command prompt? Any help would be greatly appreciated, even if its just a lead in the right direction, because right now, i am quite the newb at navigating MS-DOS! Thanks everyone!

ALSO: If it wasn't obvious before, i do have another computer to perform neccessary operations as needed.
8933.

Solve : capture file content as variable?

Answer»

i WOULD like to capture the content after the third comma .
Such as : a,b,C,d
i would like the use d as a variable

MANY thanks
a FOR loop with the delims set to be commas, using the "tokens=1,2,3,4,5*" IMPLICIT variable creation should do it.

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.
Double Post. Topic Closed.

8935.

Solve : regarding ping?

Answer»

Hello friends,

i just want to know about PING command which were used for networking. When i use this command to know about the status of the remote system some times it gives reply and in some case it gives request time out.

Dear friends i want to know about when it gives request time out , what it actualy mean i mean the server is not in ACTIVES or some thing else ...

can any one on this plzQuote from: sree on October 24, 2007, 11:35:55 PM

Hello friends,

i just want to know about PING command which were used for networking. When i use this command to know about the status of the remote system some times it gives reply and in some case it gives request time out.

Dear friends i want to know about when it gives request time out , what it actualy mean i mean the server is not in actives or some thing else ...

can any one on this plz

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.
Many firewalls block pings because they let an potential attacker know the system is running.

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
i try this "copy a.txt+b.txt .\c.txt"
however, i would like the content of b.txt are PLACED on the NEW line under a.txt

If the content of a.txt is "ABC" and b's content is "DEF"
i want c.txt is: abc
def

Many thanksMaybe something like....

Quote

echo. >> a.txt
copy a.txt+b.txt .\c.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.

But mostly from homemade install CD's.Quote from: Taysanro on October 25, 2007, 09:10:39 AM

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).
I create an autorun file and I want it to open my flash disk by explorer. It's really crazy but I NEED. Help me!!!!This isnt MAKING very MUCH sense, what is it that you want to do ?
GrahamIt makes plenty of sense.

This batch file will open WINDOWS explorer in whatever folder it is located.

@echo off
explorer.exe /root,"%~dp0"





thank you contrex.

8939.

Solve : Expand value of the variable name stored within another variable?

Answer»

Hello there,

I have the following variables defined in a script

SET PKG_NAME=CORE
set MY_%PKG_NAME%_HOME=c:\home


So this creates a variable named MY_CORE_HOME (but I dont know that from within the script).
Then if I try to acces my variable using MY_%PKG_NAME%_HOME:

> ECHO MY_%PKG_NAME%_HOME
MY_CORE_HOME

> echo %MY_%PKG_NAME%_HOME%
CORE

What should I do can to access the content of the MY_%PKG_NAME%_HOME and have for result c:\home ?

please help
thanks
You cannot do this. Batch variables do not work in that WAY. You cannot hide a variable INSIDE another.

Quote

@echo off
set PKG_NAME=CORE
set MY_%PKG_NAME%_HOME=c:\home
echo 1 MY_%PKG_NAME%_HOME
echo 2 %MY_%PKG_NAME%_HOME%
echo 3 %MY_CORE_HOME%
[/tt]

Quote
1 MY_CORE_HOME
2 PKG_NAME
3 c:\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,

How can we 'Stop a service running on different machine or another SERVER using normal MS DOS Batch file code.
If somebody have any code for the same, please send me.

set TargetService=Themes
set ServiceHost=HDBLTERGHS0005
set PathToSC=c:\WINNT\system32
set PathToSleep=C:\Program Files\ResKit

set LOGFILE=restart.service.log

echo %DATE% %time% Entering sequence to restart %TargetService% >> LogFile%
%PathToSC%\sc.exe \\%ServiceHost% stop %TargetService%
echo %date% %time% Restarted %TargetService% >> %LogFile%

Thanks....
Sudheer
have you tried the above code, and what does it say[SC] StartService: OpenService FAILED 5:

Access is denied.


I am getting the above ERROR, how can we set the permissions so that another user on different machine can access a service.
Also both the users have the same admin privilege

8941.

Solve : Pausing Help?

Answer»

Is there a way to pause for a certain amount of time in MS-DOS?
i seen something SIMILAR to this here the other day

ping 1.1.1.1 -i 10 >nul


change the number 10 for amount of seconds to timeout , i dont think its entirely accurate..I have learnt it USING this way (still by ping):

QUOTE

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
echo 3
echo.
ping -n 2 -w 1000 1.1.1.1 >nul
echo 2
echo.
ping -n 2 -w 1000 1.1.1.1 >nul
echo 1
echo.
ping -n 2 -w 1000 1.1.1.1 >nul
echo.
echo 0

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?

Sorry, I meant the syntaxes earlier in the thread. And they do work, so sorry for the spam.
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.

I have asked the tech guys to PLEASE, PLEASE go into the MAINMENU (I think) in DOS and change the screen and text colors (and size). I have problems with my eyes after cataract surgery, etc. The big bright blue screen with white letters is really not working well for me.

I told the tech guys that I KNOW there is a simple way to change the background and text colors - they won't budge to help and claim that they have no idea how to do it! Yes, someone wrote the company's "program" with a nice menu and stuff, so SOMEONE knows DOS pretty well.

Now, the DOS screen itself is not where I have a problem. Once I choose something from their menu (in the DOS environment), it brings me into the WordPerfect program (older verision there as well). The screen is still BIG (takes up my entire 24" monitor) and is huge. I hate it.

If someone could please tell me how to change all this, I would appreciate it. I have found out how to go into Wordperfect and change the background and text color while typing, but once I am done and send my files and come BACK into the program, I have to change it again. So it is not defaulting to my chosen colors.

Is there a way I can permanently change all this and also have the font be somewhat smaller on the screen - more "closed in" looking - much more like what you see on windows now?

Please advise if you know how to do this. You may email me because I really don't remember how I EVEN found this forum! I may not be able to find it again!

I would like to have detailed instructions so that once I am able to do this and have it work, I can pass it along to those who work in the DOS environment at my company every day and are clueless on how to do it.

Thank you!

Patricia

E-Mail Removed to prevent SpamPlease, remove your email address from your post, or all junk mail will be on its way.Patricia
Its many years since I used Wordperfect (but I still occaisionally use the Wordperfect Office Editor)

I cannot remember if I ever got the colours to stay in place -- but if they dont, my option would be to hack around it ..

Create a macro that sets the colours to those you like and then on your command line, tell it to run the macro on startup (I dont know how to do this, the manual will tell you).

Hope this helps
GrahamHello - thank you for your help but I have no idea how to do a macro. Unfortunately I do NOT have the Wordperfect "book" - my employer has it and they are in Chicago while I am in Atlanta. No one really SEEMS too keen on helping me there since they do not see it as a big deal I guess.

I do see what you are saying, but I just do not know how to do it.

I'm not sure they would want me to edit "their" program, so to speak.....guess I'm out of luck.

In DOS - don't you go to autoexecbat or something like that and go to MAINMENU (in DOS)? I know there is a LINE in MAINMENU somewhere where the text and background colors reside - I would like to change it THERE so this cannot be that difficult I wouldn't think.

If I am at the C PROMPT, how do I get to the "line" that has set the colors for text and background?

Thanks

PatriciaMainmenu is a menu program set up for you .. there is probably a line that starts wordperfect there.

Macros are pretty easy to do ... Im pretty sure they are the same keystrokes as for the Office Editor.

In wordperfect, do control-F10 to start recording the macro; you are askedt to 'define macro' - this means which key do you want to assign it to, Alt-C (for colour) would be sensible
now key in what you would normally do to change the colours, then press control-F10 again to save the macro.

Now WHENEVER you press Alt-C, you colours will be set up.

An internet search came up with the following info
Where the line in your menu starts up wordperfect, add this /M-macroname
so the line might look something like
c:\wordperfect\wp51.exe /M-Alt-C

Give it a whirl and see how it goes

Graham

8943.

Solve : Problem with string input under conditional?

Answer»

I am having a problem with reading user string input under a conditional statement

Here is the piece of code that is causing the problem:

Quote

set /p select="Select: "
if %select%==1 set channel=-s0
if %select%==2 (
echo.
echo ###########################
echo ### Input Channel Number
echo ###
echo ### A single Channel 6
echo ### A range 1-5
echo ### Multiple channels 1,1,2,5-7,11
echo ###
echo ###########################
set /p option="Enter Channel(s): "
echo %option%
set channel=-channel%option%
goto scan
)

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

@echo off
setlocal enabledelayedexpansion
set /p select="Select: "
if "%select%"=="1" set channel=-s0
if "%select%"=="2" (
echo.
echo ###########################
echo ### Input Channel Number
echo ###
echo ### A single Channel 6
echo ### A range 1-5
echo ### Multiple channels 1,1,2,5-7,11
echo ###
echo ###########################
set /p option="Enter Channel(s): "
echo !option!
set channel=-channel!option!
)
:scan
echo %channel%


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.

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?

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,

I like to know the list of files created on particular date e.g. i like to know number of files created particular directory daily??

i am trying like the following batch commands


cd

DIR /o:-d >> test\file_list.txt (capturing in the text file )

find /c "10/22/2007" test\file_list.txt >> (SEARCHING the date now here i need how to print the SYSTEM date daily )

or any other suggestions??

--Raman@echo off

cd

dir /o:-d > todays_files.txt

find /c "10/22/2007" todays_files.txt > report.txt

echo "Note: There will two hidden files" >> report.txt

-- this was i have created so far.. can anybody send me the syntax of MAILING and capturing the system date as in this format mm/dd/yyyy the system date is given by the system variable %date%

C:\>echo %date%
22/10/2007

It will be in whatever your local date format is.





Thanks contrex i GOT it...

--Raman

8945.

Solve : Problem with (Attrib) code?

Answer»

Hello DEAR all!!

I wish u will be fine and doing well.

First i want to say that my English is not good if there be any mistake in my writing, forgive me please.

I use Windows XP SP2

My computer was infected by a virus and my all folders became Super Hidden and also task Manager, Folder Option, Regedit and some other options was disabled by this virus.I removed the virus using kaspersky Antivirus v.7.0.119 and I also recovered approximately all of my folders using the following Attrib code:

attrib -s -h -r [drive] [folder]
attrib -s -h -r d:\Farahmand

But the problem which I have is this that whenever I want to recover My Document folder using this attrib code, it cant be recovered! I write the attrib code as following:

attrib -s -h -r C:\Documents and Settings\Administrator\My Documents

After I type this code in Cmd and and press Enter button it gives the following message:

Parameter format not correct -

If there is any special attrib code for recovering/enabling the My Document folder from Super Hidden, please write it to me.

Help me please!
Farahmand
Farahmand
I think the solution will be SIMPLE ... you see the My Documents folder name contains spaces.

To allow this you must put quotes around the folder name, LIKE this :

attrib -s -h -r "C:\Documents and Settings\Administrator\My Documents"

This should work

GrahamHello friend!

Sorry for comming late.I had some problem and I couldn't come and see the Topic.

Thanks for ur ANSWER!

It worked and I recovered My Documents folder.

but I have another question:

We must use qoutes for every folder which has spaces on their name?

Thank you so much.

Farahmand

Quote from: Farahmand on October 23, 2007, 04:57:40 AM

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
- loop through the entire directory tree of your drive
- loop through all the files on each drive
- accumulate a TOTAL of all files that contain the input matching string
-display the number of files on the drive that contain the input string using a formatted sentence like:

There are nnn files on the drive that contain the string "xxxxx".- String that was input as postional parameter.

PLEASE HELP ME! It's for my homework!Homework helping mode:-

Quote

- 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.
but it doesnt wait for the program to STOP, but it CONTINUES while the program is runnig, do u know if exist some way, how to say to the batch file that it should wait for thge program to stop and and after process the other commands.
thanx for reply!you can do it manually by adding
" pause "

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.
how do i do that?

thanks in adv.See here for INSPIRATION

8949.

Solve : Q&A Thread?

Answer»

Well as before CH is still poping up with the same stuff over and over...
Why not make a thread so PEOPLE dont ask the samething over and over and over and over and over and over.... ETC

Q:HOW TO GET ACCESS TO DOS WHEN ADMIN BLOCKS IT???
A:Figure it out urself no one here is going to help you. This Question pops up everytime i come and VIST CH.

Q:How to run a batch file hidden?
A: No idea why you would do that...but this might help...

http://www.commandline.co.uk/cmdow/

Q:Where to get all the commands of DOS?
A: I use this site
http://www.ss64.com/nt/
first thing that comes up on google when u search cmd commands.

Q:How to make a "pause"?
A: Many ways to do it...

ping -N 2 -w 1000 1.1.1.1 >nul

or

ping -n 1 -w 1000 1.1.1.1 >nul
echo 3
echo.
ping -n 2 -w 1000 1.1.1.1 >nul
echo 2
echo.
ping -n 2 -w 1000 1.1.1.1 >nul
echo 1
echo.
ping -n 2 -w 1000 1.1.1.1 >nul
echo.
echo 0

or

PING Insert 7=(8-1) second delay

Q: How to set a batch file to start at a certain time?
A: Control Panel > Scheduled Task
or
http://www.ss64.com/nt/schtasks.html

Q: How come the batch solution to my virus / trojan / etc doesnt work?
A: Try Running in Safe Mode

Q: How to BACKUP stuff?
A: xcopy or copy
here is a simple code that
transfer all the stuff from one drive onto my USB

xcopy "H:\*.*" "E:\wis" /s /y

*.* = all
*.txt = all text files
*.x = all x files

for more info:
http://www.ss64.com/nt/xcopy.html


Thats most of the FAQ around here.
So yea....It's a Help Forum...

It's the nature of the Beast.I have lost count of the number of times I have typed FOR /? at the command PROMPT and then copied-and-pasted the part about variable modifiers into an answer.
I thought the Q&A is here ? maybe you can add yours there?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. Quote from: Sharamall on October 21, 2007, 07:44:29 PM

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.

For example, the command "net CONFIG rdr" will give the following output:

Quote

Computer name \\C-8FCE127AFE9A2
Full Computer name c-8fce127afe9a21
User name Sauron

Workstation active on
NetbiosSmb (000000000000)
NetBT_Tcpip_{2FF4CC67-D07D-4FEB-85FD-860B1254C849} (00C0A8C16B59)
NetBT_Tcpip_{8F676250-5DA4-424D-924E-1300965208B9} (00508DEB7F3E)
NetBT_Tcpip_{45CF33C4-A270-4E9F-945F-C9FB6E1B0875} (005056C00001)
NetBT_Tcpip_{26B53747-C608-45FC-8FBE-3C4A845AB750} (005056C00008)

Software VERSION Windows 2002

Workstation domain RADEON
Workstation Domain DNS Name (null)
Logon domain C-8FCE127AFE9A2

COM Open Timeout (sec) 0
COM Send Count (byte) 16
COM Send Timeout (msec) 250
The command completed successfully.

I would like to be able to set a string to the addresses under "Workstations active on:". One of these:

Quote
NetbiosSmb (000000000000)
NetBT_Tcpip_{2FF4CC67-D07D-4FEB-85FD-860B1254C849} (00C0A8C16B59)
NetBT_Tcpip_{8F676250-5DA4-424D-924E-1300965208B9} (00508DEB7F3E)
NetBT_Tcpip_{45CF33C4-A270-4E9F-945F-C9FB6E1B0875} (005056C00001)
NetBT_Tcpip_{26B53747-C608-45FC-8FBE-3C4A845AB750} (005056C00008)

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!!

Seriously, I'll post something tomorrow.

Which workstation did you want? Are there always 4?

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


@echo off
setlocal enabledelayedexpansion

REM using your command output in %temp%\fout.txt
REM use this in real situation
REM net config rdr > %temp%\fout.txt

echo.
echo Workstations found:
echo.

REM count 'em and list 'em

set /a Count=0
for /F "delims==" %%L in ('type %temp%\fout.txt ^| find " NetBT_Tcpip"') do (
set /a Count += 1
echo !Count! %%L
)

echo.

REM get user to choose one

set /p chosennumber=Choose a number between 1 and %Count% :

REM get the string and put it in a variable

set /a Count=0
for /F "delims==" %%L in ('type fout.txt ^| find " NetBT_Tcpip"') do (
set /a Count += 1
if "!Count!"=="%chosennumber%" set chosenadaptor=%%L
)

REM here it is

echo.
echo Adaptor Chosen: %chosennumber% %chosenadaptor%
echo.


Saved as ch-adapt.bat

Result of run:

Quote

S:\Test>ch-adapt

Workstations found:

1 NetBT_Tcpip_{2FF4CC67-D07D-4FEB-85FD-860B1254C849} (00C0A8C16B59)
2 NetBT_Tcpip_{8F676250-5DA4-424D-924E-1300965208B9} (00508DEB7F3E)
3 NetBT_Tcpip_{45CF33C4-A270-4E9F-945F-C9FB6E1B0875} (005056C00001)
4 NetBT_Tcpip_{26B53747-C608-45FC-8FBE-3C4A845AB750} (005056C00008)

Choose a number between 1 and 4 :3

Adaptor Chosen: 3 NetBT_Tcpip_{45CF33C4-A270-4E9F-945F-C9FB6E1B0875} (005056C00001)

S:\Test>


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


REM parse out address

echo method (1)

echo address with curly brackets is %chosenadaptor:~20,38%
echo address without curly brackets is %chosenadaptor:~21,36%

echo method (2)

for /F "delims={} tokens=1,2" %%A in ("%chosenadaptor%") do set address=%%B

echo address with curly brackets is {%address%}
echo address without curly brackets is %address%


Quote

method (1)
address with curly brackets is {45CF33C4-A270-4E9F-945F-C9FB6E1B0875}
address without curly brackets is 45CF33C4-A270-4E9F-945F-C9FB6E1B0875
method (2)
address with curly brackets is {45CF33C4-A270-4E9F-945F-C9FB6E1B0875}
address without curly brackets is 45CF33C4-A270-4E9F-945F-C9FB6E1B0875

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.

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.

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).

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.


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