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.

5001.

Solve : PLEASE HELP ME my Drive D is under attack!?

Answer»

PLEASE HELP ME my Drive D is under attack!

im no longer to acces my drive d after this COMMAND.. C:\XCOPY MEL D: /0


Waaaaaaaaaaaaaaa...........Quote from: mang mel on August 02, 2009, 02:58:09 AM

PLEASE HELP ME my Drive D is under attack!

im no longer to acces my drive d after this command.. C:\XCOPY MEL D: /0


Waaaaaaaaaaaaaaa...........
Please calm down. Did you get any error MESSAGES when you performed the command? Did you do anything after that? What MESSAGE do you get when you try and open the D: drive?
5002.

Solve : naming file name dynamicaly in dos?

Answer»

i need to assign a text file name into a variable in dos command. the text file name is created based on date. like 020809.txt Tomorrow the file name will be 030809.txt How can i assign this type of text file name into a variable in dos command?please correct me if i am wrong, but do you want to get the date from 1/23/45 to 12345?

if so(if your format is mm/dd/yyyy):
Code: [Select]@echo off
for /f "tokens=2-4 delims=/- " %%a in ('echo %date%') do SET dt=%%a%%b%%c
echo Todays date is %date% or %dt%
pause

Output:
Code: [Select]Todays date is Sat 08/01/2009 or 08012009
Press any key to continue . . .you tip has worked for me. thanks a lot. hope to keep in touch with you.your welcome, if you need any more computer help, just post a new thread.
@echo off
for /f "tokens=2-4 delims=/- " %a in ('echo %date%') do set dt=%b%a%c
copy E:\DATA\%dt%.txt E:\DATA\DD\FTA1.txt
exit

How can i use this dos command in a batch file?
Quote from: MMK on August 02, 2009, 04:14:36 AM

@echo off
for /f "tokens=2-4 delims=/- " %a in ('echo %date%') do set dt=%b%a%c
copy E:\DATA\%dt%.txt E:\DATA\DD\FTA1.txt
exit

How can i use this dos command in a batch file?

This isn't one DOS command, it is a group of them. They can be used in a batch file (.bat file). Paste the script into NOTEPAD (Notepad.exe) and save it as script.bat (but it could anything you want .bat), double-click the NEWLY created file and let it do it's thing.
5003.

Solve : Search for String in file and remove it?

Answer»

Hi
I have CSV data like

ERM,VU35201, COMP Ltd,VU35201,INS071,INS071,INS071,-157,USD,,,,,-157.00,-157.00,,,O,Open,18122007,19011900,,18122007,,,,,,,,,,19011900
ERM,WO01063,COMP Ltd,WO01063,SON010,SON010,SON010,-13,GBP,,,,,-13.00,-13.00,,,O,Open,01062006,19011900,,01062006,,,,,,,,,,19011900
ERM,WO08022,COMP Ltd,WO08022,SAA002,SAA002,SAA002,-44,GBP,,,,,-44.00,-44.00,,,O,Open,02082006,19011900,,02082006,,,,,,,,,,19011900
ERM,XXXXX,COMP Italy,XXXXX,SOL003,SOL003,SOL003,-870,EUR,,,,,-870.00,-870.00,,,O,Open,19032009,19011900,,19032009,,,,,,,,,,19011900
ERM,XXXXX,COMP Ltd,XXXXX,ASS001,ASS001,ASS001,-1522,GBP,,,,,-1522.00,-1522.00,,,O,Open,12032009,19011900,,12032009,,,,,,,,,,19011900
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,

The last commas with out data are causing problem for my load. I wanted to write Batch cmd to remove those .I tried with some code i FOUND but it gives error. I cant use any EXTERNAL pkg only batch.

This is something that i found on net but giving error
@echo off
REM -- Prepare the Command Processor --
SETLOCAL ENABLEEXTENSIONS
SETLOCAL DISABLEDELAYEDEXPANSION
set file="C:\myfile.csv"
if "%*"=="" findstr "^::" "%~f0"&GOTO:EOF
for /f "tokens=1,* delims=]" %%A in ('"type %file%|find /n /v """') do (
set "line=%%B"
if defined line (
call set "line=echo.%%line:%~1=%~2%%"
for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X
) ELSE echo.
)


Regards
Amit

you do not expect to plug something you found on the net and expect it to work without understanding and modifying it, do you?. here's a vbscript one
Code: [Select]Set objFS = CreateObject("Scripting.FileSystemObject")
strFile= "C:\test\file.txt"
Set objFile = objFS.OpenTextFile(strFile,1)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
If Left(strLine,2) = ",," Then
WScript.Echo strLine
End If
Loop
save as myscript.vbs and on command line
Code: [Select]C:\test>cscript /nologo test.vbs
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,
the output is not what you want. i leave it to you to change that. just have to invert the condition in the "if" statementthat's look like my coding style.
except i dont write in uppercase, i dont use REM to comment, i use ::.

anyway josh, here is the one liner solution:
findstr/v /b ",," data.csv

lol, i need to think faster :/ ghostdog beats me by 3minuteQuote from: Reno on April 03, 2009, 04:22:33 AM

i dont use REM to comment, i use ::.

Using a broken label as comment starter in a loop or other parenthetical structure will break it.

however...

Code: [Select]@echo off

% This is a comment %

echo hello world

for %%A in (a b c d e) do (

% This is a comment %
echo %%A

)





Quote from: Dias de verano on April 03, 2009, 04:50:07 AM
Using a broken label as comment starter in a loop or other parenthetical structure will break it.
here is a good explanation on double colon :: or using REM as comment:
http://www.robvanderwoude.com/comments.php

it seems to be common practice in batch to use ::., and i personally prefer :: double colon, because it makes my code more readable. ok, not really, in fact, i rarely put comment on my batch code.

now, here is another case, which one would be executed faster:
1. for /f "tokens=*" - default delims is {TAB}{SPACE}
2. for /f "delims=" - default token is 1
since microsoft don't publish his source code, it looks like no.2 will be faster by a split nano-second because it don't do parsing operation. but my preference is no.1, because it seems code is more readable using no.1
unless microsoft pseudocode is:
Code: [Select]s=readline
if tokens=* or delims is empty then
//do nothing
else
//do parsing on string s
end if

well, in batch, there is no need to follow the rule of correct syntax.
here is an example to count number of words, with limitation
Code: [Select]set s=sample test string
set/a n=1+.%s: =&set/a n+=1+.%%
echo words=%n%Quote from: Reno on April 04, 2009, 07:38:59 AM
here is a good explanation on double colon :: or using REM as comment:
http://www.robvanderwoude.com/comments.php

Yes, I am very familiar both with Rob's pages and with the arguments for and against using :: as a comment marker.

Quote
it seems to be common practice in batch to use ::

A bad practice in my opinion, (but only my opinion!)

Quote
., and i personally prefer :: double colon,

see above.

Quote
because it makes my code more readable.

That is, again, a matter of opinion. batch code has different readability requirements compared to (e.g.) poetry.

Quote
ok, not really, in fact, i rarely put comment on my batch code.

Like many sloppy programmers?

Quote
now, here is another case, which one would be executed faster:
1. for /f "tokens=*" - default delims is {TAB}{SPACE}
2. for /f "delims=" - default token is 1

Doesn't matter. Nobody codes in batch for speed.

Quote
code is more readable using no.1

Code is more readable (to the coder) if it contains that coder's preferences, then (a circular argument)?

Quote
well, in batch, there is no need to follow the rule of correct syntax.

So you say

Quote
here is an example to count number of words, with limitation
Code: [Select]set s=sample test string
set/a n=1+.%s: =&set/a n+=1+.%%
echo words=%n%

That is a hack!

When writing your own batch code, comment style and obeying rules of syntax are of course optional. However this is a forum where we give guidance to new and/or confused users, and in that situation, in my opinion, clarity and ease of understanding are more important than clever coding tricks.

for comments, I prefer /*...*/ blocks. but every time I try and use it, my batch breaks! so I change it back to

Code: [Select]REM now, use xcopy to copy the favourite goat pictures to a backup disk.

xcopy "..\Pics\Stay out\Hey, I said stay out\OK, seriously, how many times do I have to tell you\ok fine,
(wrapped) COME on in\well there goes my reverse psycology idea\more goat pics\Bessie" I:\BACKUPS\BESSIE /S

I just counted my BCFile project, and it contains 9,416 (72%) Code lines, and 3,518 (27%) comment lines.

and as for esoterics and readability, I'm probably at my worst in this section with string manip. I've become so practices with the VB string manipulation functions, I simply nest a bunch of them on one line,- a sample dug out from deep within my BASeParser evaluator LIBRARY:

Code: [Select] SplMake(CurrArgument) = Mid$(FromString, ArgStart, (CurrPos - ArgStart) + 1)
If right$(SplMake(CurrArgument), 1) = ARGUMENTSEP Then
SplMake(CurrArgument) = Mid$(SplMake(CurrArgument), 1, Len(SplMake(CurrArgument)) - 1)
End If

Quote from: BC_Programmer on April 04, 2009, 10:52:46 AM
I've become so practices with the VB string manipulation functions, I simply nest a bunch of them on one line

I do this a lot in VB6, VBScript, QB etc.
QB is a pain. I keep trying to use TRIM$... but there isn't one. so I end up doing LTRIM$(RTRIM$()) which is slightly longer.

I just can't stand that technically VB is working with an immutable string and always creates a completely new string...I don't actually use QB any more. That Ltrim(Rtrim(string)) thing was the first thing that popped into my head when I read your remark about nesting string functions all on one line.

you use Freebasic. I would too, but I managed to hack pretty good console support into Visual Basic, which would likely have been my only reason to use FreeBASIC.Code: [Select]@echo off
set '=REM
%'% this is a comment
echo hello world
Quote from: Dias de verano on April 04, 2009, 01:37:00 PM
Code: [Select]@echo off
set '=REM
%'% this is a comment
echo hello world
hahaha, nice one, almost got me.
C:\>set '
'=REM

Quote from: Dias de verano on April 04, 2009, 09:17:07 AM
That is, again, a matter of opinion. batch code has different readability requirements compared to (e.g.) poetry.

Like many sloppy programmers?
yes i am one of them , i dont have the time to write any comment about the code, just too busy thinking more trick to cramp multiple lines of codes into one line. and i always like one liner code which do the same job as the for example 10 lines of if else if else for loop.
only in batch though, not so easy to do with other programming language, such as vb, vbs, etc.

Quote from: BC_Programmer on April 04, 2009, 11:37:58 AM
I would too, but I managed to hack pretty good console support into Visual Basic, which would likely have been my only reason to use FreeBASIC.
BC, how do you implement console support into VB aps?
do you use reference to scrrun.dll Scripting.FileSystemObject, or using GetStdHandle API then later use link.exe or something else?Quote from: Reno on April 05, 2009, 01:13:38 AM
hahaha, nice one, almost got me.
C:\>set '
'=REM

Huh?

Code: [Select]S:\Test\Batch>type remtest.bat
@echo off
set '=REM
%'% this is a comment
echo hello world

S:\Test\Batch>remtest.bat
hello worldQuote from: Dias de verano on April 05, 2009, 02:38:24 AM
Huh?

Code: [Select]S:\Test\Batch>type remtest.bat
@echo off
set '=REM
%'% this is a comment
echo hello world

S:\Test\Batch>remtest.bat
hello world
at first, i though you use vb commenting style, wait, how that's going to work? then i realize you just create a variable ' with value REM. lol.

Quote from: Reno on April 05, 2009, 03:03:23 AM
i realize you just create a variable ' with value REM. lol.

Good old cmd.exe runtime variable expansion

Code: [Select] @echo off
set gosub=call
set return=goto :eof

echo in main
%gosub% :sub1
goto :end

:sub1

echo in subroutine
%return%

:end
Quote from: Reno on April 05, 2009, 01:13:38 AM
only in batch though, not so easy to do with other programming language, such as vb, vbs, etc.
Don't be silly. Take this, for instance:
Code: [Select]Public Function InStrCount01( _
String1 As String, _
String2 As String, _
Optional ByVal Start As Long = 1, _
Optional Compare As VbCompareMethod = vbBinaryCompare) As Long


Dim lenFind As Long

lenFind = Len(String2)

If lenFind Then
' silently correct illegal Start value
If Start < 1 Then
Start = 1
End If
Do
Start = InStr(Start, String1, String2, Compare)
If Start Then
InStrCount01 = InStrCount01 + 1
Start = Start + lenFind
Else
Exit Function
End If
Loop
End If

End Function

I say BAH to that procedure, This one is much better:

Code: [Select]Public Function InstrCount(ByVal InString As String, ByVal StrFind As String, Optional ByVal Start As Long = 1, Optional ByVal compare As VbCompareMethod = vbBinaryCompare) As Long
If StrFind = "" Then
InstrCount = 0
Else

InstrCount = (Len(InString) - Len(Replace$(InString, StrFind, "", Start, , compare))) / Len(StrFind)
End If

End Function

Which ties in with the whole bunch of string functions/operations one line thing.

Quote
BC, how do you implement console support into VB aps?
do you use reference to scrrun.dll Scripting.FileSystemObject, or using GetStdHandle API then later use link.exe or something else?

It's a secret ... sort of.

But I'll share. Essentially the second method, using WriteFile,ReadFile on the Handles returned by GetStdHandle. It's wrapped in a neat module that I can drop into each Console program.

I then run this VBScript, which runs my LINK.EXE (as you've said) to switch the executables subsystem:



Code: [Select]
Option Explicit

Dim strLINK, strEXE, WSHShell

' Be sure to set up strLINK to match your VB6 INSTALLATION.
strLINK = """D:\Programs\Microsoft Visual Studio\VB98\LINK.EXE"""

strEXE = """" & WScript.Arguments(0) & """"

Set WSHShell = CreateObject("WScript.Shell")

WSHShell.Run strLINK & " /EDIT /SUBSYSTEM:CONSOLE " & strEXE

Set WSHShell = Nothing
WScript.Echo "Complete!"


I normally only use the scrrun FSO for VBScript's designed for others- I've been trying to give my BCFile library some exercise. Main benefit being that it can show the explorer menu for any file/folder- as well as including a FileSearch and FileSearchEx classes.
5004.

Solve : Who's up to the challange????

Answer»

hey all,

I've got 5 machines that I have to uninstall Symantec's endpoint Anti-Virus from. Sadly I don't have the uninstall password as these machines have come from another company (that we recently brought out) and their IT dept are less than helpful.

Below is a link to Symantec's website detailing how to manually remove the software.

Is anybody willing to have a crack at creating a script for it??? I've built loads of scripts before I've not really done much with the registry so I'm not really willing to give it a go myself.

A shiny new donkey to the winner???!!!???


linky;

http://service1.symantec.com/support/ent-security.nsf/854fa02b4f5013678825731a007d06af/5db8e519e16d42f2882573290005aa1d?OpenDocument



Cheers in advance!! a script that manipulates the registry to remove virus protection? Hmmm......

this is what I have so far...

Code: [Select]
smc -stop

Rem stopping symantec endpoint protection
net stop "Symantec AntiVirus"

Rem stopping symantec event manager
net stop ccEvtMgr

Rem stopping symantec network access control
net stop SNAC

Rem stopping symantec settings manager
net stop ccSetMgr

Rem stopping windows installer
net stop MSIServer

Rem disabling windows installer
sc config MSIServer start=disabled




Rem Step 2

Rem killing "ccApp.exe" process
taskkill /F /IM ccApp.exe




Rem Step 3


Rem creating backup of registry
regedit /E C:\RegBackup.reg

Rem removing reg keys
regedit.exe /s c:\removeKeys.reg




I have no idea how to change the values of certain reg keys, or that what I've posted is any good.

I'm I on the right track???

Any help appreciated.

[recovering DISK space -- attachment deleted by admin]....why not remove them in Safe Mode.... or just get some software that is professinally made to change registry keys, not saying that your stupid, im just saying that you may acceidently change one of the keys that may be vital to your system. but if you get software made from a company, then you'll have less of a risk.Quote from: macdad- on June 26, 2008, 04:21:43 PM

or just get some software that is professinally made to change registry keys

REGEDIT.Quote from: macdad- on June 26, 2008, 04:21:43 PM
not saying that your stupid

There are many that have.....


This is what I've got so far. I've completed all steps listed on Symantec's website but after I've removed Endpoint I can't INSTALL my version as it fails half way through the installation process. (Something about the wizard being interrupted)

Can someone have a quick look at the attached .zip file for me and make sure I've got it right???

There is no big drama about screwing the registry as I'd just reinstall XP if it does fail, but I'd RATHER fix an issue than cover over it's cracks. (plus backing up users profile's and installing XP on 5 machines isn't a job I want to fo on a Friday!!)


You'll notice that it's in quite a few parts, I was following the instructions completely, doing everything in order. (I hope!)

Cheers in advance



[recovering disk space -- attachment deleted by admin]ok, I've found a snag.....


I'm having troblue editting the vaule of a REG_EXPAND_SZ key.

I'm doing this via a reg file;

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RasMan\PPP\EAP\13]
"ConfigUiPath"=C:\WINDOWS\system32\ratls.dll

(also tried) - "ConfigUiPath"=hexadecimal(2):C:\WINDOWS\system32\ratls.dll


but no matter what i do I can't change the value. I can delete the key, but that no good as I can't re=create it.

I think the secound : might be casuing issues.

Any ideas???ok, fixed that bit.

I had to use hex as the value in the reg file;

"ConfigUiPath"=hex(2):43,00,3a,00,5c,00,57,00,49,00,4e,00,44,00,4f,00,57,\
00,53,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,\
61,00,73,00,74,00,6c,00,73,00,2e,00,64,00,6c,00,6c,00,00,00

Only trouble now is I still get the same error when trying to install the next version.

Grrrrrrrr Quote from: blastman on June 26, 2008, 03:05:32 AM
hey all,

I've got 5 machines that I have to uninstall Symantec's endpoint Anti-Virus from. Sadly I don't have the uninstall password as these machines have come from another company (that we recently brought out) and their IT dept are less than helpful.

Below is a link to Symantec's website detailing how to manually remove the software.

Is anybody willing to have a crack at creating a script for it??? I've built loads of scripts before I've not really done much with the registry so I'm not really willing to give it a go myself.

A shiny new donkey to the winner???!!!???


linky;

http://service1.symantec.com/support/ent-security.nsf/854fa02b4f5013678825731a007d06af/5db8e519e16d42f2882573290005aa1d?OpenDocument



Cheers in advance!!
hmm... you mean you haven't solve this?
its been that long and its only 5 machines. you could have manually done it and solve it by now.
Quote from: ghostdog74 on June 27, 2008, 08:23:48 AM
hmm... you mean you haven't solve this?
its been that long and its only 5 machines. you could have manually done it and solve it by now.

lol, I forgot I started that thread.

Yes it is the same set of machines. The problem is that the users work so many long HOURS and I can't really get near the *censored* things, and when they first arrvied (time of first post) the priority was to get them on the desks and working otherwise I'd have used the 2 hour long script. - which I've now lost...

I had used a script supplied by the previous company and it worked, but the machine had "issues" after that so I ended up doing a fresh install of XP anyway.

I reckon I have everything removed and all the steps covered on Symantec's website, but I'm having problems installing our version of antivirus now. It seems that the removal process deleted a few services and the install process KEEPS failing when it try's to start the "Symantec AntiVirus" service.

It has a dependent (ccSetMgr) that was removed during the instructions from Symantec and every attempt to recover it has failed. I managed to the revalent key back, and the service appears in service.msc but it won't start, giving "The process didn't start or respond to the control request in a timely fashion." error.


I'm left with a machine that won't install cos a poxy service won't start right!!!

GRRRRRRR - time for a coffeedoesn't your company use cloning technology ? If it does, i am sure you can get a new OS up and running within few hours.
5005.

Solve : search for white spaces in text files..?

Answer»

how to search for WHITE spaces in a text file and TRUNCATE 'em and then find matching string from a GIVEN list of FILES, using windows Batch files....how to do homework?

i will lead you to it for a start, try findstr /?

5006.

Solve : Help On Health/Damage Calculation?

Answer»

Basically i have this:
Code: [Select]IF %AS1%==Charge (
SET %ECHP%=%ESHP%*%ECS%*%ECF%/3-10
) ELSE (
IF %AS1%==Distract (
set %ECF%=%ESF%-5
)
)
For some reason it doesn't work, i think it is because of this calculation:
Code: [Select]set %ECHP%=%ESHP%*%ECS%*%ECF%/3-10
I am not too sure how to do +,-,* and / in MS-DOS/Batch.
Any help is appreciated.

All of them are declared correctly.
set ECHP=Example
and so on..Quote from: Dias de verano on June 26, 2008, 12:01:02 PM

Quote from: Jacob on June 26, 2008, 11:29:13 AM
Basically i have this:
Code: [Select]IF %AS1%==Charge (
set %ECHP%=%ESHP%*%ECS%*%ECF%/3-10
) ELSE (
IF %AS1%==Distract (
set %ECF%=%ESF%-5
)
)
For some reason it doesn't work, i think it is because of this calculation:
Code: [Select]set %ECHP%=%ESHP%*%ECS%*%ECF%/3-10
I am not too sure how to do +,-,* and / in MS-DOS/Batch.
Any help is appreciated.

All of them are declared correctly.
set ECHP=Example
and so on..

Really?

Quote
IF %AS1%==Charge

What exactly is "Charge"?

Is it a literal string or a variable? Or SOMETHING else?


Are these MEANT to be arithmetic operations?

Quote
set %ECHP%=%ESHP%*%ECS%*%ECF%/3-10

Quote
set %ECF%=%ESF%-5


Charge is just an attack style
and yes those ones are meant to be mathematical sums.Quote from: Jacob on June 26, 2008, 11:29:13 AM
I am not too sure how to do +,-,* and / in MS-DOS/Batch.

You have to use set with the /a switch to do calculations. A is for Arithmetic.

set /a sum=%NUMBER1%+%number2%


That works, thanks, but what to i do if i want to 'goto dead' if %ECHP% is less than or equal to 0.
Thank you.Quote from: Jacob on June 26, 2008, 12:29:11 PM
That works, thanks, but what to i do if i want to 'goto dead' if %ECHP% is less than or equal to 0.
Thank you.

if %ECHP% LEQ 0 goto dead

It's all in the IF help, which you can access by typing IF /? at the prompt.
Thank you, i have no finished my basic battle/fighting ENGINE.
5007.

Solve : Using the DIR function after launching a .BAT file from a Javascript?

Answer»

Hi,

I create a Photoshop Javascript that does some stuff and then launches a .BAT file to do the rest of the job. The problem is that the batch file needs to look into it's own folder to find files and do stuff with them, but since I launched the .BAT file from a javascript, it doesn't know what his own folder is. I tried using the DIR function in the .bat to see what folder it was looking into and instead of looking in it's own folder in my documents it looks on the M: drive for some reason.

I tried running the batch file by itself and it works correctly, it's only when I launch it from Javascript that it GETS mixed up. Is there a way to fix that, or is there a way to link to the .bat file's own directory with some code?


I'd also like to know if it's possible to send a variable from Javascript to a Batch file? Right now to do it I create a temp file with the variable and the batch file gets the temp file into ONE of it's own variables, but is there a way to pass a variable directly as we can do in the Run tool in the Start menu?

Thanks,Quote from: FausseFugue on June 25, 2008, 02:13:24 PM

I tried running the batch file by itself and it works correctly, it's only when I launch it from Javascript that it gets mixed up. Is there a way to fix that, or is there a way to link to the .bat file's own directory with some code?

I take it the folder that contains the java script your running is different from the batch file's working directory.

I'd add "CD C:\path\to\batch\file\working\directory" to the top of the batch file. That way when it does the rest of code it's ALREADY in the correct location.

Quote from: FausseFugue on June 25, 2008, 02:13:24 PM
I'd also like to know if it's possible to send a variable from Javascript to a Batch file?

Yeah, when starting the batch file add the variable to the end. "run batch_file.bat variable" (forgive my complete lack of javascript knowage!!)

I believe you can add up to 3 variables this way. The batch file will see these variables as %1, %2 and %3 (in entered order)

You can then use "set variable_name=%1" and so on.

Hope it helps. Every batch file knows the folder where it is located (stored). This is held in a special variable %0 (read that as percent zero). You can use the normal variable modifiers so that %~dp0 is the complete drive letter and path.Quote from: Dias de verano on June 25, 2008, 03:41:48 PM
Every batch file knows the folder where it is located (stored). This is held in a special variable %0

Didn't know that....

Nice one. Quote from: blastman on June 25, 2008, 04:04:15 PM
Quote from: Dias de verano on June 25, 2008, 03:41:48 PM
Every batch file knows the folder where it is located (stored). This is held in a special variable %0

Didn't know that....

Nice one.

I made a slight error.

%0 is the batch file's own FILENAME

%~dpnx0 is its drive, path, filename and extension

%~dp0 is its drive and path
Wow, thanks a lot to you both for this quick reply, this will really help!!!Actually,

I just tested and both solutions don't work.

For:
Quote
"run batch_file.bat variable"
In Javascript we use the execute command, so it normally looks like this:
File("C:/Folder/File.bat").execute()
so I tried:
File("C:/Folder/File.bat variable").execute()
but it doesn't work. It doesn't do anything, it doesn't EVEN execute the batch file.

For:
Quote
%~dp0 is its drive and path
I tried:
ECHO %~dp0
that works fine.
But when I try:
CD %~dp0
it doesn't work.


If anyone would know a solution to those two problems I would really appreciate!

Thanks!Quote from: FausseFugue on June 26, 2008, 06:56:53 AM
File("C:/Folder/File.bat variable").execute()

Sounds like it looking for the file "file.bat varaible" which does exist. I'd try;

File(""C:\folder\file.bat " variable").execute()

Pleae bear in mind I know NO JS at all! this is based on other shell script's ie, vbs

Quote from: FausseFugue link=topic=60062.msg380322#msg380322
But when I try:
CD %~dp0
it doesn't work.

"It doesn't work"... every help forum helper's favourite answer!!! (Not). Just how does it "not work"?

try

cd /d "%~dp0"Thank you both again!

Quote
File(""C:\folder\file.bat " variable").execute()
That doesn't work in Javascript, but now I don't absolutely need that anymore since this works:
Quote
cd /d "%~dp0"
so I can store my variables in a tmp file in the folder where the .bat file is located and use this code Code: [Select]SET /P VARIABLE=<"variable.tmp" to get the variable in the .bat file.

Thank you!
5008.

Solve : Limitation in MS DOS batch file??

Answer»

in order to ACCESS parameters beyond %9, it would be necessary to employ the SHIFT command, which shifts all the parameters down a notch, what would be beyond %9 becomes %8,%8 becomes %7, etc.. and %1 is removed.

Remove the CALL to cmd.exe, and PLACE your parameters directly on the command-line.Ohh Thanks for this nice suggestion "BC_Programmer", as i am not GOOD(DOS) in this I'll try !!

Is any one can get some IDEA how to


How can I add a comma in between a string (treating comma as a space )
Quote

(-6.26620974,53.34899072)
This is my single string which includes numbers, bracket and comma.
5009.

Solve : I need help with outputting data from a runas command?

Answer»

As the subject states I need some help with outputting whats printed to the Dos screen after the runas command is executed. Now I can get it to output...
"Enter the password for Guest\ADMIN: "
...but thats not what I want it to output I want it to output the data on if the password entered was correct, if it could run what it was told to run and if not what was the error it came across and I want all this printed into "Text.txt". Thanks for any and all help.So you're looking for something to output the command to a text file??

You might want to have a look at this: >>

For example: dir C:\ >>"C:\Documents and Settings\%username%\Desktop\file.txt" will output the results for the Dir to a text file.Well I use the ">>" but all they will out put of the runas command is...
"Enter the password for Guest\admin: "
...which is not what I want outputted. This is what I have.
Code: [Select]@echooff
ECHO ****** | runas /noprofile /env /netonly /user:***\Admin MozillaFireFox.exe >> Text.txt
pauseEvery time it runs threw fine but when it outputs the data all I get is "Enter the password for Guest\admin: ".i dont think thats possible because you are using a file pipe, i could be wrong*censored*, can any one else confirm or DENY this?Wait...Do you want:
echo ****** | runas /noprofile /env /netonly /user:***\Admin MozillaFireFox.exe
in a text file?

If so, you need 2 echos.
Code: [Select]echo echo ****** | runas /noprofile /env /netonly /user:***\Admin MozillaFireFox.exe >>"C:\text file.txt"No, I need to now whats printed to the screen after that command is executed. So say I do...
Code: [Select]echo ****** | runas /profile /env /netonly /user:***\Admin MozillaFireFox.exe...now since most of you already know that you cant use "/profile" and "/netonly" in the same line of code it would GIVE me an error or print the huge help thing on the runas command I would want all of that outputted to a text file.Hmmm....If you can see all of that in the Command Prompt Window, you can right click on the CMD window and click Edit --> Mark and then highlight everything. Then go back to Edit --> Copy and then paste it into notepad.

Kind of ruins the point, but thanks for all the help any way!Just a hunch, but try redirecting the STDERR stream to your text file.

Code: [Select]runas /profile /env /netonly /user:***\Admin MozillaFireFox.exe 2>file.txt

As far as I know, you cannot pipe the password to the runas command. Besides being a security breach, not all programs can accept input from the pipe.



Oh, I can pipe the password to the runas command just fine its just outputting the information to a text document that its not liking. Thanks for the INFO on not all programs accepting input from a pipe though.

5010.

Solve : Possibility??

Answer»

Is it possible for the user to select an option like this:
- types the number 1 responding to an option.
- does not have to press enter to continue.
So when the user presses "1" it automatically "goto whatever".
Thanks,
Jacob
yes the choice COMMAND. SEARCH it up on google and LOOK at the page on CH about this command's parameters i think if you use set /a inside a for array that might ALSO workThanks diablo and macdad, although i went for the array option because choice does not work on my computer system.

EDIT: DOESN'T WORK

Thank you.sorry i ment to say set /p and it might need to look more like this

set;/p,b=- that will cause set /p to not PAUSE.. i dont know exactly how to do this, but ive made it work by mistake.. it wasent what i was looking for, ill try and figure it out though

5011.

Solve : Assign keystroke to mousebutton in batch?

Answer» HEYA. First of all of course: is it at all possible to configure mouse buttons in batch?

I want to use it as a remote control for Winamp so I want to bind the global hotkeys (ctrl-alt-pgdn/up etc.) to like.. the thumb button on my Logitech G5 mouse. 'Course there are easier ways to do this but it's more of a hobby to get this method to work than that it is usefull

Of course any other (batch) way to achieve the same result does just fine too.(Bump) I couldn't find anything regarding this kind of DOS use through the search box nor Google.

Even if you are not a professional, please share your thought on whether it is at all possible or not...So you mean like you want a batch file to turn right click into something else?

I really DOUBT this is possible...Quote from: Carbon Dudeoxide on June 25, 2008, 05:28:19 AM
I really doubt this is possible...

+ 1K, guess that's enough info for me then
thanks
5012.

Solve : multiple file remanes with suffix .bat?

Answer»

C:\test>a
24062008_145426
The filename, directory NAME, or volume label syntax is incorrect.

It DIDNT work?!
What is wrong


Regards,
nkrstic
Quote

NOW i have tried using many thing but it just didn't work

Didn't work how? While a few of the MEMBERS may be psychic, even fewer are detectives.

Base on the information you provided, this may work. Notice the move does the rename all in one command.

Code: [Select]@ECHO OFF
FOR /F "tokens=2,3,4 delims=/ " %%A IN ('date /t') DO SET DATEVAR=%%B%%A%%C
FOR /F "tokens=5,6,7 delims=:. " %%A IN ('ver ^| time') DO IF NOT "%%A" == " %1" SET DATETIMEVAR=%DATEVAR%_%%A%%B%%C
echo %DATETIMEVAR%

for /f "tokens=1-2 delims=." %%x in ('dir /b c:\test') do (
move c:\test\%%x.%%y c:\test1\%%x*_%DATETIMEVAR%.%%y
)

Good luck. C:\test>a
24062008_145426
The filename, directory name, or volume label syntax is incorrect.


what is wrong?


NOTE is should move and rename only files with extension .sft the .bak files should ignored from the whole process.

regards,
nkrsticYou typed it in wrong. i did copy and pasteThe original post was edited 28 minutes after the first reply, rendering any continuity in this thread meaningless.

For anybody trying to make SENSE of this thread, I wish you luck.


Hi
Ill try to explain one more time, maybe you or anyone can help thank!


FOLDER C:\TEST\
MT210.sft
MT200.sft
MT300.sft
MT2102008202030.bak
MT2002008303020.bak
MT3002008151515.bak

I need to move only the .sft files ( not the .bak they are not to be touched) to another folder c:\test1 and add a date-time stamp at the end of the name in the following format;
MT210_DDMMYYYY_HHMMSS.sft

I have tried using the script posted earlier but it didn't work.

Help anyone!
reagards,
nkrstic

Sorry Sidewinder

I am new to the forum, sorry for the confusion!

nkrsticfor /f "tokens=1*" %%a in ('dir C:\tst\*.sft /b') do move C:\tst\%%a %%a_%date:~4,2%%date:~7,2%%date:~10,4%_%time:~0,2%%time:~3,2%%time:~6,2%.sftThanks but i got an error;


The syntax of the command is incorrect.Your original script generated the the datetime variable correctly. The original reply had an typo and did not filter the sft files. This should fix you right up:

Code: [Select]@ECHO OFF
FOR /F "tokens=2,3,4 delims=/ " %%A IN ('date /t') DO SET DATEVAR=%%B%%A%%C
FOR /F "tokens=5,6,7 delims=:. " %%A IN ('ver ^| time') DO IF NOT "%%A" == " %1" SET DATETIMEVAR=%DATEVAR%_%%A%%B%%C
echo %DATETIMEVAR%

for /f "tokens=1-2 delims=." %%x in ('dir /b c:\test\*.sft') do (
move c:\test\%%x.%%y c:\test1\%%x_%DATETIMEVAR%.%%y
)

Thank you !!!!

IT WORKS GREAT...

GREAT FORUM
5013.

Solve : How to input line commands in another program from DOS?

Answer»

Hi, I've been reading your posts, but I couldn't find a problem similar to what I have. I'm trying to create a DOS FILE to input line commands in another program, FLUENT. FLUENT has a line command like DOS, and I wanted to create an executable or .bat file to open (a simple START Fluent.exe), and then input commands to the fluent command line. For example, something to write FILE in FLUENT's command line. Any ideas would be very much appreciated!

Thanks,
IsabelWelcome to the forum dude,

Basically, DOS or XP's prompt (which I guess is the OS your using) won't 'input' commands like that. The closest thing I think you'll get to is to use command line switches written into FLUENT.

The best way to tell, is to open a dos prompt and navigate to the folder that contains the FLUENT .exe file and type 'fluent.exe /?' and see what happens.

Hope it helps.
Hi, thanks for your reply. I've tried it and it doesn't return anything. I've tried to give commands through strcmd but it didn't work either! Any other ideas?

Thanks,
IsabelI'm no expert, but I'd say that it's unlikely to work. sorry


Someone please prove me wrong!!!!Not 100% either but you could try this:

Batch file:
Code: [Select]start "" FLUENT.exe
start "" script.vbs
Script.vbs:
Code: [Select]set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 5000
For i = 1 to 1
WshShell.SendKeys "{C}"
WScript.Sleep 500
WshShell.SendKeys "{o}"
WScript.Sleep 500
WshShell.SendKeys "{m}"
WScript.Sleep 500
WshShell.SendKeys "{m}"
WScript.Sleep 500
WshShell.SendKeys "{a}"
WScript.Sleep 500
WshShell.SendKeys "{n}"
WScript.Sleep 500
WshShell.SendKeys "{d}"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
Next
WScript.Sleep 5000 This will make the script wait 5 seconds (1000=1 sec) before starting the next commands
WshShell.SendKeys "{C}" This sends a key as if you pressed it on the keyboard. In this case, you have press 'C'
WScript.Sleep 500 This will make the script wait half a second before typing the next letter
WshShell.SendKeys "{ENTER}" This presses the Enter key. (like executing the command)

Note, you can have as many WshShell.SendKeys as you want. Just add them along with the WScript.Sleep 500 command.
Note2, you can change the time delay.
Nice piece of code but Dos can not really use a vbs because they are different LANGUAGES but it can use lines of and exe, EG if you were to make a sever in C or C++ and then run the programme inside of the dos it would work as long as the C or C++ programme runs in a console window.

That is what I did for a sever I made for CSS,
Tan_ZaQuote

Nice piece of code but Dos can not really use a vbs
By using start "" filename.vbs, it runs the script outside the DOS.An alternative METHOD would be to have the script launch Fluent. Missing from the previous VBScript is grabbing a handle on the Fluent window. Consequently, the destination of the keystrokes is unpredictable.

Code: [Select]Set WshShell = CreateObject("Wscript.Shell")
WshShell.Run "Fluent.exe",,False
WScript.Sleep 100
WshShell.AppActivate "Fluent Window Title"
WScript.Sleep 100
WshShell.SendKeys "command{enter}"
WScript.Sleep 100

Just a thought. Hi, thank you all for your ideas! It turnsout it was simple, all it needed was a batch file with an indication like 'fluent -g -i start', being start' a journal file with all the inputs I wanted to give through the command line! Thank you all very much!

IsabelQuote from: IMartins on June 24, 2008, 11:17:08 AM
'fluent -g -i start'

that looks awfully like a command line switch to me....... Yes, you're right, but when I tried "fluent.exe /?" it didn't return a thing, so I thought it didn't have those capabilities, until I found a pdf that explained exactly how to do it. Thanks for your trouble!Quote from: IMartins on June 25, 2008, 04:32:10 AM
I tried "fluent.exe /?" it didn't return a thing

I'll let you off then...


Just pleased it's working now.
5014.

Solve : COPY SPECIFIC CONTENTS OF ONE FILE TO ANOTHER FILE..???

Answer»

How can i copy some specific contents from ONE .txt file to another .txt file, but in a certain way though..
in the .txt file there is some text above this dashed line and some TIME-stamps below it like this..
Code: [Select]text above dashed line
----------------------------
time-stamps
time-stamps

so all i want to do is copy the time stamps under the dashed line to another .txt file SOMEWHERE else
is there any way at all to do this with batch commands..??Do the time stamps always start on the third line? If so, you could use the for command with the skip parameter.

You might also use the for command and count lines, copying the output when the count gets to three.

You might also use the findstr command with a regular expression if the text above the line has no numerics and the text below the line does.

Without seeing at least a snippet of actual data, we can only guess at what solution may work.

the time-stamps always start on the 10TH line in the .txt file
so how would i code a bat file to copy everything from the 10th line down into a new txt file..??In keeping with the KISS method of batch coding, for your consideration:

Code: [Select]@echo off
if exist out.txt del out.txt
for /f "skip=9 tokens=* delims=" %%i in (data.txt) do (
echo %%i >> out.txt
)

The file NAMES are negotiable, so feel free to change them.

5015.

Solve : Need help with tokens?

Answer»

I am NOT a DOS programmer - but I need some help writing this simple utility. I want the batch to read
a file (icu.txt) and pass two parameters to a command (%%i"ip" and %%j"location")- here is what I have so far - EVERYTHING works except it doesn't pass the IP address to the executable - it just shows up as "%i" - I appreciate any help you can give.

setlocal EnableDelayedExpansion
FOR /F "tokens=1,2 delims=," %%i IN (icu.txt) do call :hello
:hello
d:\scheduled\icu_hello\send_message_to_ip.exe %%i 3046 HELLO
if %ERRORLEVEL% neq 0 (c:\g\glh\blat d:\scheduled\icu_hello\message.txt -to [emailprotected] -subject "PROBLEM WITH %%j" -ATTACH -q -PRIORITY 1 -mailfrom [emailprotected] -replyto [emailprotected] -noh2 -r -d) else (ECHO Site Resonding:%ERRORLEVEL%Since we are not telepathic, an example of icu.txt would be nice.
sorry about that.....

10.121.48.5,AF40
10.114.48.6,AF42
This is just a quick hack, and as I don't have send_message_to_ip.exe I can't properly test it, but I believe I have mostly sorted out the batch logic and simplified things a bit.


Code: [Select]@echo off
setlocal EnableDelayedExpansion
set errprogname=c:\g\glh\blat
set errprogparam1=d:\scheduled\icu_hello\message.txt -to [emailprotected] -subject "PROBLEM WITH
set errprogparam2=" -attach -q -priority 1 -mailfrom [emailprotected] -replyto [emailprotected] -noh2 -r -d
for /F "tokens=1,2 delims=," %%i IN (icu.txt) do (
d:\scheduled\icu_hello\send_message_to_ip.exe %%i 3046 HELLO
set /a err=!errorlevel!
if !err! neq 0 (
%errprogname% %errprogparam1% %%j%errprogparam2%
) else (
echo Site Responding:!err!
)
)
Notes:

1. Double-percent variables such as %%i and %%j are loop variables. They only exist IN A LOOP. Your "subroutine" at the label HELLO is outside the loop so therefore cmd.exe strips off the first percent sign and passes the rest on.

2. Since you have ENABLED delayed expansion you may as well use it!


that works great - THANKS!!

5016.

Solve : Adding comments in a DOS Batch file that are not sent to DOS window?

Answer»

Hello,

How do I ADD COMMENTS to a batch file that are NOT SENT to the DOS WINDOW such as with a "REM" command? I want to include comments for only the programmer.

Tim_C
you can use :: say this was your batch file

@echo off
for,/f;"tokens=1*",%a;in('dir /a /b'),do;echo.%a
::This is a line
cls,&;echo. &;echo,OK

5017.

Solve : call DOS script in Remote server?

Answer»

i WANT to execute a DOS batch file in remote server. how to invoke script in remote server?? PLS advicedepends what your after;

if the script is on the remote server and you want it to run on a local machine, just "start \\servername\path\to\batch\file.bat" will do the job.

if however you want it to run on the server it's self then you'll need some 3rd party TOOLS. I recommend Pstools as it free and has loads of useful features. One of them is psexec.

Basic usage;

C:\pstools\psexec \\servername C:\path\on\server\to\batch\file.bat

useful link;

http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx

Hope it helps.

5018.

Solve : Reading webpages through batch??

Answer»

Hi all!

I was wondering if it's possible to make a batch file that connects to the internet and looks at a web page, and if it sees a certain trigger word (E.g: It sees the word "mudcake")it would execute an action.

Thanks in Advance,

KamakQuote

was wondering if it's possible to make a batch file that connects to the internet and looks at a web page, and if it sees a certain trigger word (E.g: It sees the word "mudcake")it would execute an action

Only if the batch file launches a WINDOWS script. Most of the script languages provide for interaction with the web. Batch code not so much (actually not at all)

VBScript and Jscript come installed with Windows. Perl, PHP, Python, and REXX are ALSO tools you can use, however each must be downloaded. (all are free).

Quote from: Sidewinder on June 24, 2008, 05:39:07 AM
Quote
was wondering if it's possible to make a batch file that connects to the internet and looks at a web page, and if it sees a certain trigger word (E.g: It sees the word "mudcake")it would execute an action

Only if the batch file launches a Windows script. Most of the script languages provide for interaction with the web. Batch code not so much (actually not at all)

VBScript and Jscript come installed with Windows. Perl, PHP, Python, and REXX are also tools you can use, however each must be downloaded. (all are free).



Thanks for the fast reply Sidewinder

Do you know which of those languages would be simplest and most conveniant?My personal favorite is REXX. It has only 20 odd instructions to learn and is darned near idiot proof As mentioned it does require a download and install. For convenience, VBScript comes already installed with Windows.

This site has many tools, articles, and sample scripts to help you out.

This little snippet will give you an idea how your request looks in VBScript:

Code: [Select]Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate "http://www.yahoo.com/"
Do While objie.Busy
WSCRIPT.Sleep 500
Loop

Set ieRange = objIE.Document.Body.createTextRange
If ieRange.FindText("Mudcake", 0, 2) = True Then
MsgBox("Mudcake Found")
End If
objIe.Quit

The Yahoo ADDRESS is an example. Any address can be used.

Quote from: Sidewinder on June 24, 2008, 06:31:31 AM
My personal favorite is REXX. It has only 20 odd instructions to learn and is darned near idiot proof As mentioned it does require a download and install. For convenience, VBScript comes already installed with Windows.

This site has many tools, articles, and sample scripts to help you out.

This little snippet will give you an idea how your request looks in VBScript:

Code: [Select]Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate "http://www.yahoo.com/"
Do While objie.Busy
WScript.Sleep 500
Loop

Set ieRange = objIE.Document.Body.createTextRange
If ieRange.FindText("Mudcake", 0, 2) = True Then
MsgBox("Mudcake Found")
End If
objIe.Quit

The Yahoo address is an example. Any address can be used.



Thank you so much again Sidewinder, i only have 1 last question.

How do i execute programs in VBscript?One way is to type the scriptname at the command prompt, much like a batch file. The vbs extension was registered when you installed Windows. Another is to use a specific script host: wscript scriptname.vbs or cscript scriptname.vbs either at the command prompt or the Windows Run box.

If you really want to impress your friends, you can write scripts in WSF files where you can use multiple languages in a single script and you can create multiple scripts within a single file.

Happy Coding.

5019.

Solve : Incrementing part of multiple files?

Answer»

Of 1434 .jpg files, all named "Picture [number]" how can I increment all of the files after the 230th by one? Such that "Picture 231" becomes "Picture 232" and so on.

Sorry to ask such an amateur question, but I have no experience with .bat files and this needs to be done fairly quickly, while the prospect of renaming each file myself is somewhat less then attractive considering their number.Probably the quickest way is to put the list of files into a text file :

dir /b /o-n > mylist.bat

This gives you a sorted (reverse order) list of files, delete (from the list) all those entries from the first you dont want to CHANGE until the bottom

Using the rectangular blocking facility of your editor (or Word) copy all the filenames and PASTE them at the end of the line, one line down -- eg

before

"picture 234.jpg"
"picture 233.jpg"
"picture 232.jpg"
"picture 231.jpg"

after

"picture 234.jpg"
"picture 233.jpg" "picture 234.jpg"
"picture 232.jpg" "picture 233.jpg"
"picture 231.jpg" "picture 232.jpg"

now paste in REN and a space at the start of each line and manually add in the first new filename

Like this

REN "picture 234.jpg" "picture new.jpg"
REN "picture 233.jpg" "picture 234.jpg"
REN "picture 232.jpg" "picture 233.jpg"
REN "picture 231.jpg" "picture 232.jpg"

You see by doing it in reverse order, files are renamed out of the way first

GrahamQuote

Sorry to ask such an amateur question, but I have no experience with .bat files and this needs to be done fairly quickly, while the prospect of renaming each file myself is somewhat less then attractive considering their number.

More IMPORTANTLY is your OS. Microsoft usually adds UTILITIES and batch code facilities with each new release. Without knowing your OS we have no idea what functions are AVAILABLE on your machine.

This may work:

Code: [Select]@echo off
setlocal enabledelayedexpansion
for /l %%v in (1434, -1, 231) do (
set /a w=%%v+1
ren "picture %%v.jpg" "picture !w!.jpg"
)

Ah my bad. It's Windows XP - Media Edition I believe. I'll go try that out now.
5020.

Solve : dir \My Documents?

Answer»

I am trying to work at the DOS command PROMPT. EVERY time I type in
C:\ Documents and Settings\Compaq_Owner>dir My Documents

it returns (exactly)
Volume in drive C is PRESARIO
Volume Serial NUMBER is .... (#do you need this?)

Directory of C:\Documents & Settings\Compaq_Owner

Directory of C:\Documents & Settings\Compaq_Owner
File Not Found



My Documents is a large file on my computer but dos is not ALLOWING me to list it out. What can I do?

Thank you
Diane MilinowskiFor usage information on the DIR command, type
Dir /?

Your going to want to do this:

Type:
Dir "My Documents"
(Dir is shorthand for "directory)

To go into the My Documents folder, type in:

Cd "My Documents"
(Cd means "Change Directory")

Any time there is a space in a folder name, or file, you need have it in "Quotation" MARKS.

5021.

Solve : creating filename with date?

Answer»

I have searched through this site and found this code that looked like it should work in reference CH000987:

for /f "tokens=2-4 delims=/ " %%a in ('date/t') do rename "extrfile.dat" extrfile_%%a-%%b-%%c.dat

I am getting the error "%%a was unexpected at this time".

SUGGESTIONS please??

I am RUNNING on Windows XP
What is it your trying to do???

I think you've missed the ( ) in the for loop. Try;


for /f "tokens=2-4 delims=/ " %%a in ('date/t') do (
rename "extrfile.dat" extrfile_%%a-%%b-%%c.dat
)

I am trying to keep a back up file with the date it was created in the filename.
I'll try adding the ()s

for /f "tokens=2-4 delims=/ " %%a in ('date/t') do (rename "extrfile.dat" extrfile_%%a-%%b-%%c.dat)

same error "%%a was unexpected at this time."are you running this from the command prompt or from a batch file??At the moment I am running from Command Prompt but ultimately want to run from a batch file.blastman's question about WHETHER I was running from command prompt or batch file led me to try it from the batch file --- and it works!! Nothing wrong with the code, only where I was running it from.

Thanks, Blastman!!not a PROBLEM mate.

the For command requires you use just one % when running from the prompt, but when running from a batch file you have to add an extra %.

Glad it's working now.yes, the date is working.
but now I'm going to complicate things and want to add the time - hour,min, second.
I'm trying to scope it out on my own but if you have the code for this already...
I'm SUPPOSING I need to set the date elements aside and the time elements and then put them all together?
Can you help??

5022.

Solve : find string in txt file, return true value?

Answer»

hey all,

Is there a way to use the find command to return a true value, depending WEATHER the PROVIDED string is there??

example;

I want to search 1.txt for the word "November" but use the output as part of a if statement doing one thing if it's there and another if it's not.

any ideas??try to use the for with the find command LIKE this

for /F "tokens=2 delims=:" %%i in ('find /c "
November" 1.txt') do (
if "%%i" NEQ " 0" ( echo notexists ) else ( echo exists)


nice, cheers.

it tells me that 'echo' was unexpected at this time??!??

any ideas?sorry
just close the brackets of the do ( ADD ) at the end of ur code )this is what I got..


for /F "tokens=2 delims=:" %%i in ('find /c "
november" 1.txt') do (
if "%%i" NEQ " 0" ( echo notexists ) else ( echo exists)
)


but it's still telling me that "echo" was unexpected at this time.


GRRRRR fixed it,

for /F "tokens=2 delims=:" %%i in ('find /c "november" 1.txt') do (
if "%%i" NEQ " 0" ( echo notexists ) else ( echo exists)
)

Nice cheers for the help, dude.



thats good

5023.

Solve : Conditional statements in DOS batch files?

Answer»

Hello,

Microsoft Windows XP [Version 5.1.2600].

How does one write an IF statement with several conditions? Also, can anyone explain the use and syntax of the parenthesis the IF statement? I have read the help files on the IF statement and still do not understand enough to write more complicated conditional logic than the one line examples.

Tim_C

what is it your trying to do???

some examples would help.

For 3 conditions you'll need 2 if statements, for 4 conditions you'll still want 2 statements. For 5 conditions you require 3 statements and so on...

I want to run a program but only if all 9 files exists. The program will run without error as long as one of more of the files is available. So I want to write a conditional that looks something like the following.

If EXIST 2007_033.h20v08.hdf
AND EXIST 2007_033.h20v09.hdf
AND EXIST 2007_033.h20v10.hdf
AND EXIST 2007_033.h21v08.hdf
AND EXIST 2007_033.h21v09.hdf
AND EXIST 2007_033.h21v10.hdf
AND EXIST 2007_033.h22v08.hdf
AND EXIST 2007_033.h22v09.hdf
AND EXIST 2007_033.h22v10.hdf

then

dir /b /s 2007_033.*.hdf > tmp.log
mrtmosaic tmp.log

else echo incomplete data >> 2007_033.txt
Quote

I want to run a program but only if all 9 files exists. The program will run without error as long as one of more of the files is available.

Seems contradictory. This little snippet will test for all files being available. It's a simple change to have one or more available.

Code: [Select]@echo off
set count=0
for %%V in (2007_033.h20v08.hdf 2007_033.h20v09.hdf 2007_033.h20v10.hdf 2007_033.h21v08.hdf 2007_033.h21v09.hdf 2007_033.h21v10.hdf 2007_033.h22v08.hdf 2007_033.h22v09.hdf 2007_033.h22v10.hdf) do (
if exist %%v call set /a count=%%count%%+1
)
if count neq 9 goto :eof
.
. put your code here
.
.
.

Quote
For 3 conditions you'll need 2 if statements, for 4 conditions you'll still want 2 statements. For 5 conditions you require 3 statements and so on...

Perhaps someone could explain this statement.


Quote from: Sidewinder on June 22, 2008, 02:36:05 PM

Quote
For 3 conditions you'll need 2 if statements, for 4 conditions you'll still want 2 statements. For 5 conditions you require 3 statements and so on...

Perhaps someone could explain this statement.




I'd be surprised.
Sidewinder,

Thanks for the For-loop. I hope to use it this WEEK sometime.

Perhaps I should explain my purpose even more since my explanation above seemed contradictory or at least confusing.

The nine hdf files are MODIS satellite images of different but adjacent portions of East Africa from the same 8-day period. The mrtmosaic program will mosaic these adjacent images into one image. mrtmosaic, however, is designed for researchers having different areas of interest. So mrtmosaic will mosaic as many or as few images as are supplied to it, whether there are 9, 2, or 50 images. You get the picture. Due to atmospheric conditions, not all images are available for each time period. Since my team can only use a mosaiked image if it covers the ENTIRE area of interest, and I have thousands of time periods to process, I only want to mosaic those time periods for which all 9 images are available and skip the time periods with incomplete imagery.

Thank you again.

By the way. Your answer incorporated a For-loop which is another programming design I wanted to use in other applications. So your one answer has HELPED me twice.



Quote from: Dias de verano on June 22, 2008, 03:35:59 PM
Quote from: Sidewinder on June 22, 2008, 02:36:05 PM

Quote
For 3 conditions you'll need 2 if statements, for 4 conditions you'll still want 2 statements. For 5 conditions you require 3 statements and so on...

Perhaps someone could explain this statement.




I'd be surprised.


Surprised??? whys that??

OK the sentence and grammar are very poor. (had been a long day) I was trying to explain that if you have 2 conditions (yes/no for example) you'd need 1 if statement. If you had 3 conditions, you'll need 2 if statements and so on.

I was under the impression that this was what the OP was after.

I misunderstood.
5024.

Solve : changing ipnumber?

Answer»

there's one thing i never done before and that is changing my ip from dos
iv'e allready googled and didn't found any answers so i decided to ask in here.


Quote

if theres a POSSIBILITY i want to know how to make a batch file that changes my
automatic received ip number to a local ipnumber such as 192.168.0.66

i want to be able to change the local ip number and also a possibility to
change it BACK to automatic with automatic dns.
I am not professional with this but I fear that it's impossible. Probably changing you IP can be done but changing it from automatic to manual...
If I'm not wrong you might try finding a .com or .exe written especially for networking configuration, put it in your system folder and USE it through batch.

Again, sorry if I am totally wrong. Don't trust me I'm not 100% sure either but I remember reading somewhere that you cannot change your IP through a Batch file.

Any reason why you want to change your IP?becuse some times i use a crossed network cable between me and my friends computer and then i have to write in local ip manually, and some times i use my router.

okey but is there a possibility that I can handle that with c++?Quote
okey but is there a possibility that I can handle that with c++?
I think you can only change your IP if you contact your ISP but I'm not really sure.

Hang tight and someone will give you a straight answer. Depending on your OS you might have access to the netsh utility. CHECK out this link to find out how it may be helpful.

Good luck.



Quote from: Sidewinder on June 23, 2008, 07:07:11 AM
Depending on your OS you might have access to the netsh utility. Check out this link to find out how it may be helpful.

Good luck.






thank you side it was the answer i was looking for =)Heh, nice one...TNX, Learnt that Netsh is the app. I was aiming at in my first reply
5025.

Solve : Tip: How to make zero length files?

Answer»

Code: [Select]type nul>zerosize.zzz
Neat I might use that.

Tan_ZaThanks. Note: zerosize.zzz is just an example. You can use any allowable filename.
ok thxWhat about
Code: [Select]echo.>>"C:\file.jpg"
That creates an empty file.Quote from: Carbon Dudeoxide on June 22, 2008, 03:46:07 AM

What about
Code: [Select]echo.>>"C:\file.jpg"
That creates an empty file.

No it doesn't. The file has 2 bytes: 1 carriage return, and 1 line feed

Code: [Select]C:\>echo.>>file.jpg

C:\>dir file.jpg
Volume in drive C is WinXP
Volume Serial Number is FC8E-1A31

Directory of C:\

22/06/2008 11:14 2 file.jpg
1 File(s) 2 bytes
0 Dir(s) 11,525,836,800 bytes free

Oh ok. Thanks.Still what I don't get is where/how it stores the file name... it sure hás to. EVEN though the actual data is null.Quote from: Schop on June 22, 2008, 06:01:09 AM
Still what I don't get is where/how it stores the file name... it sure hás to. Even though the actual data is null.

In an index type file system structure. The FAT file system uses a file allocation table, and in NTFS, the Master File Table.
So when I create zero length FILES, eventually my disk gets occupied just by my MFT, and I've read that the MFT doesn't shrink (delete entries) when you delete files? If so you could easily clog up disk space with like... twenty or so? bytes at a time.
I might just go figure out a batch LOOP to write a "few" zero lengths

(edit)
Did some research (creating lots of zero length files END calculating disk space per file) and figured they use like.. 1.2 Kb per file and when deleted there are Five bytes freed up (guess the write PROTECTION takes five bytes then) This was done on a 500Gb drive with 512 cluster size NTFS btw.
Anyway, can any one point me to some accurate data on this? Just interested
5026.

Solve : how to compile c programe from commond line??

Answer»

hi FRIENDS,

i have a problem while USING tcc command line options to compile and run a C PROGRAM. i have GOOGLED it already but didn't find any solution.

please help me out


regards
sanYou've not told us what the problem is or shown your command line entry.


i mean how to use -I and -L options along with tcc commond to compile a C program in DOS?Have you looked at the Command Line Invocation here?

5027.

Solve : i have searched to site over and found answers to parts of my question scattered?

Answer»

i am in a MESS it is simple i open my cmd and command prompt to type commands and i get internal external command not recognized. what disk do i use? for external commands and are my internal commands in a wrong folder and also when i type a command a new window with file, or a edit bar does not pop up a blue window. i have worked for 3 days day and night now i am asking this simple question. and might i add i have followed your batch file ms dos command a hundred times nothing i can't get dos to work only the dir, command only i cant change of move i know this question has to be somewhere i am sorry please tell me what i am doing that i can't get the commands to work. maybe i should add i have WIN 98 dos files in a seperate folder i can't find xp folder i took out a cab folder from win 98 i read that i a booboo where should my files be
thank you Hello RUBY - welcome to the CH forums.

Most of your post doesn't make sense, at least to me. I assume you are able to boot to Windows XP but cannot find the internal/external commands from the Command Prompt? Or are you booting to Windows 98 in a dual boot configuration?

Quote from: Ruby04

i have followed your batch file ms dos command a hundred times nothing i can't get dos to work only the dir, command only i cant change of move i know this question has to be somewhere
What does this mean?

Quote from: Ruby04
maybe i should add i have win 98 dos files in a seperate folder i can't find xp folder i took out a cab folder from win 98 i read that i a booboo where should my files be
And this? If you mean you are booting to Windows 98 then trying to locate folders/files on an NTFS partition then the answer is that this cannot be done. Win 98 will not recognize NTFS.

If you are booting to Windows XP and receive the error message command not recognized when entering commands at the Command Prompt then it might be that the folder C:\Windows\System32\ does not appear in your Path environment variable.

Did all your problems suddenly appear or have they grown over a period? Can you be sure your system is not infected?

Please read this...

i am sorry i am a NEWBIE, i have XP2 PROGRAM. yes i am trying to get dos commands to heed to their commands. i read the dos section, i copied all the commands. i understand what they do. (dos is not foreign to me) i have tinkered here and there. and at no time have i been able to get but a few to work. for that reason, i went under ground and found their files and what i could do with a mouse i have explored(or maybe i haven't) this computer was an upgrade from 98 to XP the dos command prompt wouldn't work until i put in windows 98 dos file into the win32 file(anyway i believe that's what made the prompt work). i can now open the dos window, but every command i type disobey's me. i have a feeling i am missing something very simple maybe the order of process, the disk, maybe a program, a re-boot process. i just need some simple coaching not mentioned in the dos section.

by the way when i gave up on the dos commands i stumbled into the edit window and typed a java (welcome.java) file (i am trying to learn to program) i couldn't get it to preform whatever. i saved it and downloaded it into my browser. it did not have a graphic interface.

another perdictiment, i downloaded a gnu program. it took me a week going in and out of the files to find the window to type in and, before that a week, to figure out which/how file to put the path to the program in. the intructions kept telling me to put the path in autoexec.exe well XP HAS autoexec.nt. when i tried using the gnu window it kept saying i should close because it couldn't find the path i created. well XP does not have a config file(empty)XP doe not have a config.exe, or an autoexec.exe. remember in am underground opening files with my mouse because i can't get dos commands to work) so i made one or i think i did. i did find the autoexec.nt and i also entered the path there. i also entered a path in the window of the dos interface admin. window. i kept entering and making files because i couldn't get the gnu program to work without warnings.
i am telling you this hoping you can get a mental picture of whatever i am missing in programming.
the interface of OF WIN 98/XP i can change any setting and i am pretty suave at fixing any problem so long as i stay where a mouse is required. as soon as i GO sub-ground the computer skills stop. it is much simplier when you insert a disk, after the program downloads you go to your desktop and boom an icon. it doesn't work in computer programming. computer programmers who write books and explain the process are excellent instructors but, if they skip a "byte" you don't get to program or get the program to function. there is one way in, one way out, one way process. instructors assume because your reading their book you must know how to get to a file and where it's located but, you don't know how to change the function(not always so)
thank you so much for your time so much appreciated beyond every byte!
ruby
5028.

Solve : help me, I'm stupid. Simple .bat files question?

Answer»

Sorry for bothering you people, but I am realy stupid, and it seems I CANT get even a VERY simple task done.
What I WANT to know is how can I put multiple command lines in a .bat file, so it may run all of them at once.
what I wanna do is something like:
go to the secific directory
copy 2 files into one.(I know how to do this in the prompt, but when it gets to the . bat file, DOS seems to run only the first line.)
Thanks,
Zare.What's the code you've got so far?

If you go to Notepad, you can create a batch file with pretty much as many lines as you want.
For example:
Code: [Select]copy "C:\documents and settings\username\desktop\file1.txt" "C:\file.txt
copy "C:\documents and settings\username\desktop\file2.txt" "C:\file.txt
Then go to File, Save As, copyfiles.batQuote from: Zarevock on June 20, 2008, 06:33:46 PM

Sorry for bothering you people, but I am realy stupid, and it seems I cant get even a VERY simple task done.
What I want to know is how can I put multiple command lines in a .bat file, so it may run all of them at once.
what I wanna do is something like:
go to the secific directory
copy 2 files into one.(I know how to do this in the prompt, but when it gets to the . bat file, DOS seems to run only the first line.)
Thanks,
Zare.
there's no stupid people, only LAZY peopleQuote from: Zarevock on June 20, 2008, 06:33:46 PM
What I want to know is how can I put multiple command lines in a .bat file, so it may run all of them at once.

You can't do that. You can put multiple commands in a batch file, so that it will run them one after the other. I expect that is what you meant?

Quote
go to the SPECIFIC directory

Code: [Select]cd /d "d:\path\to\desired\directory"
I am not sure what you mean by this:

Quote
copy 2 files into one

If you mean join two files together to form a third file, then this would do that:

Code: [Select]copy file1+file2 file3
Why don't you post the batch file that you wrote, since there may be an error in the first line that stops it ever getting to the second one.




It may be usefull to insert a "Pause" command after each line so that you can take time to read the console output and determine what's failing.
A simple spelling mistake can be found by reading the output.
5029.

Solve : Read file, filter text and output new file.?

Answer»

Hello!

Can i use script like this:
Code: [Select]Set INP=%1
Set pref=%2
set outp=%3

FOR %%I IN (%inp%) DO @(
FIND "%pref%" %%I>%tmp%\note.tmp
FOR /F "EOL=- tokens=1,2" %%t IN (%tmp%\note.tmp) DO @(
Set fail=%%~nxI
Set fail2=%fail:~0,5%KR%fail:~7%
ECHO %%t>>%3%fail2%
)
)
What this script do:
1. scan all files like batch*.* (%1)
2. find all rows where exist %2 PARAMETER and otputh to %tmp%\note.tmp
3. read note.tmp and SKIP 1-st and 2-nd row and output %3 folder with earlier scanned file.
4. next input file

But problem is the output file name?! it dosn't work Don't bump threads. Bad manners. Esp. after only a short time!Quote from: Cass on June 11, 2008, 03:40:23 AM

But problem is the output file name?! it dosn't work

You need to use delayed expansion for the variables in the loop, fail and fail2. OTHERWISE they will be blank.
5030.

Solve : reading and writing to certain lines of a txt file?

Answer»

hey all,

I'm looking for a way to read and write to certain lines of a txt file. The files looks like this;

[Frozen *censored* - Save Data]

[Player info]
-name
Blastman
-Current level
1
-health
80
-ammo
25
-weapon
Pistol
-Last Save data
19.6.2008


[Avaiable Weapons]
Pistol
Dual Pistols
Sub Machine Gun
Machine Gun


[Invertory]
Rusty Key


I'm aware a FOR loop could pull certain lines into a variable for me to use, but I don't know how??

Also how could I update one line within this file???


Basically I'm writing a game and I have been using different txt files for all the different THINGS I want to STORE. However as the game has progressed the number of files is BECOMING a little unmanageable.

any help would be fantastic!!

Cheers in ADVANCE guys!!Reading from a file has been answered many times, a quick search will identify some approaches.

As for updating a line, you will have to read / write each line in turn, when the line you want to CHANGE turns up, you need to make your change and then write the updated value out.

Grahamumm, thats too long winded me thinks.

I think that vbs might be able offer a find and replace. I'll give that line a go.

Cheers anyway.why does everyone find interest in writing little games in DOS? That's not fun at all.
If you want to write games, see here. Learn the language. Also , if you want to parse files like this, you can use configparser. Makes things easier.

5031.

Solve : DOS Rename batch file for files in different directories?

Answer»

What I need to do is create a simple batch file that I will run from a logon script. I need the batch file to go out and SEEK all the files names consisting of *ADP*DMS*.lnk and RENAME these to ASP.lnk. The files may or may not always be in the same directory. I CREATED the command:
dir /s *ADP*DMS*.lnk ren ASP.lnk
But that just finds all the files, but never renames them.....

Any HELP would be appreciated.try this code

Code: [Select]@echo off
for /f "delims=" %%a in ('dir /s /b "*ADP*DMS*.lnk"') do (
rename "%%~pa%%~nxa" "ASP.lnk"
)That worked PERFECTLY. I can not thank you enough!!!! Thanks.kindly chang %%~pa to this %%~dpa just to insure correctness
so that the code will be
Code: [Select]@echo off
for /f "delims=" %%a in ('dir /s /b "*ADP*DMS*.lnk"') do (
rename "%%~dpa%%~nxa" "ASP.lnk"
)

5032.

Solve : Change Things in Administrative tools?

Answer»

Hi,

I need to Create a batch file that will go into control panel then administrative tools, then into services and turn MESSAGES ON!.
I want it to do that automatically.

Thanks,
Tan_ZaI'd find the service like messenger and USE NET START servicename to start, and NET STOP to stop...
so messenger would be NET START MESSENGER


Hope this HELPS... Its easier to directly start and stop services!!! This can also be done REMOTELY from one computer to another as well with the NET START command.

You can also have it start all the TIME by setting to Automatic in Windows services instead of a batch.

Thx

5033.

Solve : How do you print one of three words at random??

Answer»

Ok I'm trying to set it up so when a certain variable is equal to a certain thing Dos picks from three predetermined words and echos on of them at random, any way at doing this?TRY this

Code: [Select]set word1=<watever phrase>
set word2=<wateverphrase>
set word3=<wateverphrase>
if '%<watever variable>%'=='<watever thing>' (
set /a rnd=%random% %%3 + 1 >nul
if '%rnd%'=='1' (
echo %word1%
pause
exit)
if '%rnd%'=='2' (
echo %word2%
pause
exit)
if '%rnd%'=='3' (
echo %word3%
pause
exit)
)

ok this part states the three preditermined words
Code: [Select]set word1=<watever phrase>
set word2=<wateverphrase>
set word3=<wateverphrase>
this creates a random number( between 1 and 3)
Code: [Select]set /a rnd=%random% %%3 + 1 >nul
does this work for you?
Yeah, works like a charm thanks!your quite welcome, if you need help with anything else, give one of us a holler Well now I'm having issues again. For some reason or another dos doesn't like these lines of code.
Code: [Select]@echo off
set DC1=10
if '%DC1%'=='10' (
set /a ST=%random% %%3 + 1 >null
pause
if '%ST%'=='3' (
pause
set DC1= King
goto :Done
)
if '%ST%'=='2' (
pause
set DC1= Queen
goto :Done
)
if '%ST%'=='1' (
pause
set DC1= Jack
goto :Done
)
goto :DC2
)
:DC2
echo %DC1%, this is DC2.
pause
:Done
echo %DC1%, this is DONE.
pause
The two different done statements aren't going to be apart of the finial code its just there so I know if its even running threw the other if statements. Now I'm guessing it has some thing to do with having the if statements inside a unfinished if statement but I'm not completely sure on this. It always PRINTS "10" to the SCREEN instead of one of the three words and it always hits DC2 instead of DONE so it appears to me for some reason or another its ignoring
Code: [Select]pause
if '%ST%'=='3' (
pause
set DC1= King
goto :Done
)
if '%ST%'=='2' (
pause
set DC1= Queen
goto :Done
)
if '%ST%'=='1' (
pause
set DC1= Jack
goto :Done
)I know it picks a random number because it creates the null file but after that it just JUMPS for no reason. None that I can see atleast. Thanks in advance for all help.I'm guessing KISS doesn't live here anymore. I probably missed something, but why make this so complicated?

Code: [Select]@echo off
set DC1=10
if '%DC1%'=='10' set /a ST=%random% %%3 + 1
if '%ST%'=='3' set DC1= King
if '%ST%'=='2' set DC1= Queen
if '%ST%'=='1' set DC1= Jack

echo %DC1%, this is OVER DONE.

Sometimes fall thru logic makes sense. ST can only have one value per run, so it drops thru the VALUES that are false.



ok i change it so there isnt the if statement inside the other if. and also i changed the null because this ">null" makes a file, this doesnt ">nul".

Code: [Select]@echo off
set DC1=10
if '%DC1%'=='10' (
set /a ST=%random% %%3 + 1 >nul
pause
)
if '%ST%'=='3' (
pause
set DC1=King
goto :Done
)
if '%ST%'=='2' (
pause
set DC1=Queen
goto :Done
)
if '%ST%'=='1' (
pause
set DC1=Jack
goto :Done
)
goto :DC2
:DC2
echo %DC1%, this is DC2.
pause
:Done
echo %DC1%, this is DONE.
pause
does this work?Works great, thanks again for the help.

5034.

Solve : random number in dos (xp prompt)?

Answer»

hey GUYS,

I'm writing a game and I'd like to have a few random things happen.

I've used %random% to generate a number but the number is allways very simlier to tha last one.

I had intended to get a ramdom number, divided by 2 and then do a if gtr then do.... if lss than do.... but beacuse the number is allways around the 170** range.


example

test.bat

@echo off

Code: [Select]set NUM=%random%
echo %num%

set /a num=%num% / 2
echo %num%

if /i "%num%" GTR "16384" (echo number low) ELSE echo number low

set num=

pause

any ideas??thing about it,

I've just grabbed the last digit as it allways changes and used that instead;


set num=%random%

set /a num=%num% / 2

set /a num=%num:~3,2%

if /i "%num%" GEQ "5" (echo number high) else echo number low

set num=

pause

job done.

Cheers ANYWAYS guys

What about this:

Set /a Number=(%Random% %%10)+1

That will generate a number between 1 and 10.arh,


That's much neater.

Cheers mate.No problem.

5035.

Solve : Over look a > but use the >> %filename%?

Answer»

Hi all, long time listener, first time caller.

I am trying to write a script to add several wifi configurations (30+) to multiple laptops via windows "Windows Wireless Network Setup Wizard." I couldn't get the WSETTING.WFC to accept more than one profile, so I am trying to do it via .bat. This is where I get stuck.

rem @ ECHO OFF
set filename="WSETTING.WFC"
set wepkey="Computer_Hope.com_Rocks"
ECHO "> >> %filename%

Output is ">> was unexpected at this time" or I get nothing sometimes as well. There are many more lines that are created, but this is as far as the current script succesfully runs.

I have talked to Google and he pretty much says that this can be done with GPO, but it will be the same effort both ways and I would rather do it this way.

Thanks for any help! !

*note* Running XP SP2Quote

rem @ ECHO OFF
set filename="WSETTING.WFC"
set wepkey="Computer_Hope.com_Rocks"
ECHO "<?xml version="1.0"?> >> %filename%

Using characters that are meaningful to the cmd shell can create all sorts of challenges, but one problem is the unbalanced quotes. Hard to tell if you want quotes in the output or not.

No quotes:
Code: [Select]rem @ ECHO OFF
set filename="WSETTING.WFC"
set wepkey="Computer_Hope.com_Rocks"
ECHO ^<?xml version="1.0"?^> >> %filename%

With quotes:
Code: [Select]em @ ECHO OFF
set filename="WSETTING.WFC"
set wepkey="Computer_Hope.com_Rocks"
ECHO "<?xml version="1.0"?>" >> %filename%

Sorry about that, I was trying a few things earlier and left that extra quote in there. What I am trying to get accomplished is to have the bath file recreate WSETTING.WFC with the different setting each time so I can run it and add all the wireless settings with little or no manual intervention.

Code: [Select]rem @ ECHO OFF
set filename="WSETTING.WFC"
set wepkey="Computer_Hope.com_Rocks"
ECHO <?xml version="1.0"?> >> %filename%

The entire code in the WSETTING.WFC I am trying to recreate is:

Code: [Select]<?xml version="1.0"?>
<wirelessProfile xmlns="http://www.microsoft.com/provisioning/WirelessProfile/2004">
<config>
<configId>000E06EE-C94E-432A-B492-12AE01CBF3B8</configId>
<configAuthorId>0B4E59B8-8317-46B2-B8C2-C46850162E6C</configAuthorId>
<configAuthor>Microsoft Wireless Network Setup Wizard</configAuthor>
</config>
<ssid xml:space="preserve">SSID_GOES_HERE</ssid>
<connectionType>ESS</connectionType>
<primaryProfile>
<authentication>WPAPSK</authentication>
<encryption>TKIP</encryption>
<networkKey xml:space="preserve">Computer_Hope.com_Rocks</networkKey>
<keyProvidedAutomatically>0</keyProvidedAutomatically>
<ieee802Dot1xEnabled>0</ieee802Dot1xEnabled>
</primaryProfile>
</wirelessProfile>

The set command will accept just about any character, so by using quotes with set wepkey="Computer_Hope.com_Rocks", the quotes become part of the string. In addition each and every < and > must be escaped with the caret (^).

I could have sworn there was another post in this thread that explained all that, but I'll just chalk it up to another senior moment.

This should produce what you're looking for. LOOKS a bit like chicken scratch.

Code: [Select]@echo off
set wepkey=Computer_Hope.com_Rocks
set filename="WSETTING.WFC"
>>%filename% echo ^<?xml version="1.0"?^>
>>%filename% echo ^<wirelessProfile xmlns="http://www.microsoft.com/provisioning/WirelessProfile/2004"^>
>>%filename% echo ^<config^> >>%filename%
>>%filename% echo ^<configId^>000E06EE-C94E-432A-B492-12AE01CBF3B8^</configId^>
>>%filename% echo ^<configAuthorId^>0B4E59B8-8317-46B2-B8C2-C46850162E6C^</configAuthorId^>
>>%filename% echo ^<configAuthor^>Microsoft Wireless Network Setup Wizard^</configAuthor^>
>>%filename% echo ^</config^>
>>%filename% echo ^<ssid xml:space="preserve"^>SSID_GOES_HERE^</ssid^>
>>%filename% echo ^<connectionType^>ESS^</connectionType^>
>>%filename% echo ^<primaryProfile^>
>>%filename% echo ^<authentication^>WPAPSK^</authentication^>
>>%filename% echo ^<encryption^>TKIP^</encryption^>
>>%filename% echo ^<networkKey xml:space="preserve"^>%wepkey%^</networkKey^>
>>%filename% echo ^<keyProvidedAutomatically^>0^</keyProvidedAutomatically^>
>>%filename% echo ^<ieee802Dot1xEnabled^>0^</ieee802Dot1xEnabled^>
>>%filename% echo ^</primaryProfile^>
>>%filename% echo ^</wirelessProfile^>
There doesn't seem to be a setting for SSID_GOES_HERE.

Hope this helps or at least gives you some ideas.

Question: Is this some sort of template or is there a source for the data?The SSID will vary between the many Access points, the xml code is generated by the Windows Wireless Network Setup Wizard. Thanks for the help on this. It has helped me out a lot. When I get it finished I will let you know how effective it is.

Thanks Bud!!Ok, the next step that I can't figure out. This .bat will open Windows Wireless setup wizard and require the user to actually click on the "ok" button. Is there a way to make it run silent or SEND KEY strokes to the active window? The wireless setup wizard is initiated by "setupSNK.exe."Batch code cannot send keystrokes to other processes. The good news is you can write a quick VBScript which can be run from your batch file.

Would need to know the title of the window which contains the OK button, whether the OK button has focus when the window opens and if not how many times you have to hit the tab key to give the OK button focus.

Did you try running setupSNK.exe from the command prompt using the usual suspects for help functions? (-h, /h, /?, -?). If there is a help function, it should describe any switches that may be helpful.



Yeah I tried running it from cmd with help tags trying to find more commands, but don't seem to be any. No matter what you put behind setupSNK.exe, it executes the program and does not display anymore options.

First Window: The title of the window is "Wireless Network Setup Wizard." It has two option "Ok" and "Cancel", by DEFAULT "Ok" is selected.

Second Window: The title of the window is "Wireless Network Setup Wizard." It only has one option "Ok" and by default it is selected.

As far as writing VB, I am still struggling with .bat files.


Side note: Sidewinder, I really all your help!
Quote
The title of the window is "Wireless Network Setup Wizard."

I chose not to include the dot. If it really exists, the script can be changed easily.

Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "setupSNK.exe"
WScript.Sleep 1000
WshShell.AppActivate "Wireless Network Setup Wizard"
WScript.Sleep 100
WshShell.SendKeys "~"
WScript.Sleep 2500
WshShell.AppActivate "Wireless Network Setup Wizard"
WScript.Sleep 100
WshShell.SendKeys "~"
WScript.Sleep 2500

Save the script with a vbs extension, preferably in the same directory as your batch file.

In your batch file place the following reference: cscript scriptname.vbs The script will run setupSNK and click the OK buttons as needed. If for any reason the OK buttons do not have focus, the script can be changed to bounce around the window until they do.

Hope this helps.
5036.

Solve : Delete A File With No Visible Characters.?

Answer»

Hey Guys,

I have a program that keeps creating files of 1KB (on Windows XP), but the files contain no characters. I already have a script going that deletes all the files in that same directory that are 0KB, but now I wish to have a script that deletes all files that have no visible characters in them instead, regardless of file size.

Does anyone have any ideas how to do this?

Thank you for your TIME.how about;



rem create a variable to locate the file, including path
set filepath="C:\path\to file.txt"

rem pull first line out of file
set /p file=<%filepath%

rem if first line is empty, delete the file
if %file% == "" (del %filepath%) else file contains information.


hope it helps

Quote from: kaydo on June 17, 2008, 08:23:42 AM

I have a program that keeps creating files of 1KB (on Windows XP), but the files contain no characters.

If there were no charactors, the file would be zero bytes. What you meant to say was that "the files contain no visible characters."
Is it possible the program needs that file (maybe a LOG or something).

I don't see any reason why it needs to be deleted. It's not taking up any space.
However, if this file is on the desktop, then I UNDERSTAND why you want to delete it.wouldnt be easier to use the sort command, you could create a FOR loop that goes through ever folder in your drive and ever time it changes folders, it uses the sort command to sort the files out and then delete em. How about letting us in on what program is doing this ? ?Quote from: blastman on June 17, 2008, 08:31:30 AM
how about;



rem create a variable to locate the file, including path
set filepath="C:\path\to file.txt"

rem pull first line out of file
set /p file=<%filepath%

rem if first line is empty, delete the file
if %file% == "" (del %filepath%) else file contains information.


hope it helps



Thank you very MUCH for the responses. The above worked for me w/ a little bit of modification. I appreciate it very much. I'm just pleased something I posted helped someone!!!

5037.

Solve : USB Safely Remove Problem?

Answer»

Im using USB safley remove software right now and i want to remove it automatically using batchfile with this command usr stop -d (DRIVE letter)

@ECHO OFF
ECHO sample
dir \
dir "C:\Program Files\USB SAFELY Remove\"
CALL "C:\Program Files\USB Safely Remove\usr.exe"

pause
CLS
EXIT


what's my next step inorder to EXECUTE usr stop -d (drive letter)

THANKSIF it was drive D you wanted to remove you'd do this I think

Code: [Select]CALL "C:\Program Files\USB Safely Remove\usr.exe" -d D

5038.

Solve : help with if?

Answer»
5039.

Solve : Making directories using a batch file?

Answer»

I am having trouble CREATING a batch file that reads a list of names from a "test.txt" file which contains names like bob,joe,bill each name is on a seperate line. I WANT to set up a batch file which will read test.txt and create a DIRECTORY C:\bob then ANOTHER directory c:\joe etc.... Can anyone help?You can make a FOR loop that does something like
FOR %%A in test.txt do MKDIR %A

You'll probably have to read the txt file into a variable first. But a FOR loop is definitely what you should be LOOKING at.

5040.

Solve : Capturing first input only?

Answer»

hey all,

I'm working a game (inspired by Jacob's good work!) and I'm after a little help...

I have menu's that I require the user to enter 1 or 2 or 3 and so on, but [emailprotected] like to only capture the first inputted value.

example,

if the user enters 20 I'd like only the 2 to be assigned to my variable.

any ideas how??

Cheers in advanceHave a look at this:

Code: [Select]@echo off
echo.
echo Type two digit number:
SET /p a= :
cls
echo.
echo. %a:~0,1%
pause
perfect thanks.

So the :~0,1 is saying keep the 0 and ignore the 1

could this be applied to other strings.

example;

if "1234" was entered, would :~0,1,0,1 capture the 1 and 3???

Cheers again.The best description I can give it is it is like moving decimal points when multiplying or dividing by 10.

a = 25
%a:~0,1%

Go forward 0 times and then select 1 away.

= 2



Just experiment arh, I get it.

:~"number of places to move to the right","how many CHARACTERS to keep"

Nice one.


Cheers mateYeah, there we go.

Glad to help.

Don't FORGET to show us your game when you're done.Quote from: Carbon Dudeoxide on June 16, 2008, 09:09:52 AM

Don't forget to show us your game when you're done.

Gladly, but it might take a while. Ideas just keep coming to me........

so far I've got the basic story line planned out, with a start menu including new game, load and game options. (all work) I've also got my base setup, for buying health, weapons and ammo.

it looks good, but I'm still a long way off.

Cheers the help.
5041.

Solve : ping port?

Answer»

Hi all,

How can PING some SPECIFIC port ?
for example

I typed
ping ***.***.***.***:21 -t


I just want to check is some port working or not on specific IP .

THANKS for reading .
I'm pretty SURE that ping does not support a port address, You might try telnet or you could use a free port scanner.

Hope this helps. ok, thanks for trying to help .

5042.

Solve : How read a particular line from a text file??

Answer»

Hi Friend,

In batch code, is it possible to read a particular line from the text file.

For eg.,
Text file "test1.txt" contains the following text....

data1
data2
data3
data4
data5


I need to read the 3 line of the "test1.txt" file and print that line ALONE
(Ie.., It should echo the 3 line alone "data3")

Is there any option to RESOLVE this issue....

Thank in Advance.

Urs,
VinothIt is especially important that posters on this BOARD tell US their operating system. Batch code changes with each release from Microsoft, so what may work on one OS may not work on another.

This code will work for the test data provided:

Code: [Select]@echo off
setlocal enabledelayedexpansion
set count=0
for /f %%v in (test.txt) do (
call set /a count=%%count%%+1
if !count!==3 echo %%v
)

Good luck. Quote from: Sidewinder on June 16, 2008, 06:20:02 AM

Code: [Select]@echo off
setlocal enabledelayedexpansion
set count=0
for /f %%v in (test.txt) do (
call set /a count=%%count%%+1
if !count!==3 echo %%v
)

Why not increment the count like this?

Code: [Select]@echo off
setlocal enabledelayedexpansion
set count=0
for /f %%v in (test.txt) do (
set /a count=!count!+1
if !count!==3 echo %%v
)

Quote from: Dias de verano on June 16, 2008, 06:50:06 AM
Why not increment the count like this?

No particular reason. The result is the same, so I suggest it's a matter of style rather than efficiency.

Why do you ask?

I was curious why you used found that call set /a %%count%% statement.
Quote from: Dias de verano on June 16, 2008, 08:45:35 AM
I was curious why you used found that call set /a %%count%% statement.

Probably from deranged habit.

In the OP case, delayed expansion was necessary, but sometimes other approaches create interesting results:

Code: [Select]@echo off
set count=0
for /f %%v in (test.txt) do (
call set /a count=%%count%%+1
call echo %%count%%
)

The call to echo produces a running tally of the count variable. Without the call, results are less than stellar. If I could have, I'd have called the if statement, but it doesn't QUITE work.

5043.

Solve : How to read particular line from the TXT file??

Answer»

Hi EVERYONE,

In batch code, is it possible to read a particular line from the text file.

For EG.,
Text file "sample.txt" contains the following text....

vinoth
rajesh
RAMESH
mathew
mithun



I NEED to read the 3 line of the "sample.txt" file and print that line alone
(Ie.., It should echo the 3 line alone "ramesh")

Is there any OPTION to resolve this issue....

Thank in Advance.

Urs,
Rajesh



This question was asked and answered in this post

5044.

Solve : Ipconfig?

Answer»

I went to command prompt and checked my Ip address(Ipconfig /all) and it didn't say that there was an Ip address. The weird thing is that the internet was still working. What the heck is up with that?

thx

post the output of ipconfig /all on here and we'll try to tell you, if we can.Gone very QUIET - what's the betting he saw... his IP address?
Same as on France not advancing into the 2nd Round....

In group C only Netherlands is in. Three others...we'll see.As i stated... I didn't know, you watch football....Both types..... You know what I meant...I have no idea what the game, where you use your hands to throw the ball has anything to do with foot...LOLI'm sticking my neck out here, but footy BORES me to tears. As do rugby, cricket, and in fact all sports. Except Olympic women's diving maybe.Dias, you're lucky this board is located in US, or you'd have bunch of angry people KNOCKING on your door....LOLQuote from: Dias de verano on June 14, 2008, 05:51:28 PM

I'm sticking my neck out here, but footy bores me to tears. As do rugby, cricket, and in fact all sports. Except Olympic women's diving maybe.

Women's Beach Volleyball ? ?
Tell me you've never watched that....

However Baseball is the ultimate Sport...Period...End.Quote
However Baseball is the ultimate Sport
Now, I'm gonna stick out my head, but to me it's more boring, than chess.Quote from: Broni on June 14, 2008, 06:31:51 PM
Quote
However Baseball is the ultimate Sport
Now, I'm gonna stick out my head, but to me it's more boring, than chess.
Sorry for jumping in here but Baseball is got to be the only sport I would sit through (at least longer than any other sport).

Go Boston!

Quote
I'm sticking my neck out here, but footy bores me to tears.
Agreed. Just stick your nose little bit out of US, and you'll see...
5045.

Solve : Batch file that can write a command without executeing it in DOS 6??

Answer»

I wont to MAKE a batch FILE that can write a commando without executeting it.

Example:

If i RUN C:\test.bat it will automatically TYPE in another command like: C:\program.exe but without executing the command so that I only need to hit enter to run the program.

How do I do?

Thanks You mean like (for example) a batch file to browse the internet for you? That's not possible...not with a batch file.

You can have it to open other programs but that's pretty much as FAR as it goes.

5046.

Solve : How to copy a file from source to all destination directory,all its sub dirs?

Answer»

Quote from: llmeyer1000 on June 15, 2008, 08:38:05 AM

Here is what I don't understand:
NORMALLY the <Enter> (carriage return/line feed) tells DOS to execute the command as written on that line. It appears to me that in Reply #7 you have added 2 extra <Enter>'s in the middle of what should be one line.

Thus the QUESTION(s):
1. Did you use the <Enter> to break up a single line?
(or was some other charactor that I can't see here?)
2. When is it OK to break the line this way for appearance sake.?

1. Yes. I used Enter.
2.

When you use (
brackets like this
)

Not just in FOR loops

IF "%var%"=="apple" (
ECHO it's an apple
call fruit.bat
)

Try typing ( at the command prompt.

Code: [Select]C:\>(
More? echo CAT
More? echo dog
More? echo horse
More? )
cat
dog
horse

C:\>



PS We are not talking about "DOS" here, but NT/Win2k/XP/Vista command language.
Is it possible to create sort of a batch like that?
'Course inserting a 50 line complicated batch script won't work lik this but what does?Quote from: Dias de verano on June 15, 2008, 08:45:14 AM
Try typing ( at the command prompt.

OK! After a bit of experimenting, I managed to duplicate your example as follows.

Code: [Select]C:\>(
More? echo test1
More? echo test2
More? echo test3
More? )
test1
test2
test3

C:\>
That's pretty cool, and it goes a very long way in explaining something that has long confused me about many of the posts on this site.

But it still appears to me that each section is treated as a separate command line. In this case 3 separate echo statements.

It appears that it works on the "for" command line, if used after the "do" , but would not work when I tried it on the "echo" command:

Code: [Select]C:\>(
More? echo
More? test1
More? )
ECHO is on.
'test1' is not recognized as an internal or external command,
operable program or batch file.

C:\>
Can I assume from this that there are only certain commands(like "for in do") that can be split this way? If so, where in the help does CMD explain this? I tried "( /?" to no avail.


Quote from: Dias de verano on June 15, 2008, 08:45:14 AM
PS We are not talking about "DOS" here, but NT/Win2k/XP/Vista command language.

I did say DOS, but I knew that the for command was way more limited back then than now. I should have said CMD instead to clarify.
OK! I have been going over your earlier posts (Reply #13)

Quote from: Dias de verano on June 15, 2008, 01:14:39 AM
NT/Win2K/XP/Vista batch language allows you to use brackets to enclose groups of commands so you can do this ...

and I think I can answer my last question. You can use the brackets to enclose any number of commands in a "for in do" statement, but they must be complete command lines, not broken up as I tried in my last example. Duh! I may be slow, but I think I will get it eventually.

Thanks again for explaining.

EDIT: I see now that in Reply #15, you also used the brackets in an "if then" command line:

Quote from: Dias de verano on June 15, 2008, 08:45:14 AM
Not just in FOR loops

Code: [Select]IF "%var%"=="apple" (
echo it's an apple
call fruit.bat
)

I have always thought of an "if then" or "for in do" as a single command, that should all be on one line. Apparently, the "then" or "do" parts are considered as separate commands and thus may appear on the same, or separate lines.

Is that correct, or am I still way out in left field?

Thanks! Quote from: Schop on June 15, 2008, 09:30:56 AM
Is it possible to create sort of a batch like that?
'Course inserting a 50 line complicated batch script won't work lik this but what does?

This much even I can answer.

Yes, most of the code Dias posted was intended for use in a batch file.

For example this code found in Reply #13:
Quote from: Dias de verano on June 15, 2008, 01:14:39 AM
Code: [Select]FOR %%A in (cat dog horse) do echo %%A

will work only in a batch file because of the use of the double percent signs. At the command line, you would need to use single percent signs, as in this code:

Code: [Select]@echo off&FOR %A in (cat dog horse) do echo %A

Quote from: llmeyer1000 on June 15, 2008, 10:08:49 AM
and I think I can answer my last question. You can use the brackets to enclose any number of commands in a "for in do" statement, but they must be complete command lines, not broken up as I tried in my last example.

Exactly. I was just about to post more or less exactly what you wrote.

Quote
Duh! I may be slow, but I think I will get it eventually.

You are not slow at all, believe me!

Thanks.

But sometimes, it is very difficult to fully grasp "new" concepts. (New to me, although not new to many of you!)

I was in the process of editing the post you QUOTED (Reply #18) while you posted the above. In the edit I am requesting a bit more clarification, if you would be so kind.

Thanks again. (With your expertise, maybe my questions and your answers will help a few others, who are weak in the "for-in-do" area like me. )Quote from: llmeyer1000 on June 15, 2008, 10:08:49 AM

I have always thought of an "if then" or "for in do" as a single command, that should all be on one line. Apparently, the "then" or "do" parts are considered as separate commands and thus may appear on the same, or separate lines.

Is that correct, or am I still way out in left field?


That is correct. They can be on separate lines if you use brackets as I have shown. In essence, brackets (or "parentheses" in N. America) can be used to extend statements over multiple lines. The commands contained within a pair of parentheses are treated like a single command. Such a construct is referred to as a "parenthetical expression". This is one of the major differences between MS-DOS/Win9x (which does not have them) and NT/Win2k/XP/Vista command languages.

They also serve to keep commands that need grouping, together.

Services.txt exists. Service.txt does not.

These don't work...

Code: [Select]C:\>if exist services.txt echo yes else echo no
yes else echo no
Code: [Select]C:\>if exist service.txt echo yes else echo no


But these do...

Code: [Select]C:\>if exist services.txt (echo yes) else (echo no)
yes
Code: [Select]C:\>if exist service.txt (echo yes) else (echo no)
no
These are equivalent in a batch...

Code: [Select]if exist services.txt (echo yes) else (echo no)
Code: [Select]if exist services.txt (
echo yes
[...]
) else (
echo no
[...]
)
One slight gotcha is that variables in parenthetical expressions are evaluated before the expression is executed, so sometimes you need to use delayed expansion, but I think you need not worry about that until you encounter it naturally.
5047.

Solve : < - standard in?

Answer»

hey all,

I've forgotten hoe to pull the fist line of a txt file into a variable. I thought it was..

set var=&LT;
but it doesn't work!!

All i'm trying to capture is a single WORD, so it should be NICE and easy.

(ALSO I've lost all my old batch files so can't look up whats I've done before.)

Cheers in advanceQuote from: blastman on JUNE 14, 2008, 10:46:25 AM

hey all,

I've forgotten hoe to pull the fist line of a txt file into a variable. I thought it was..

set var=<<C:\test.txt

but it doesn't work!!

Code: [Select]set /p var=<myfile.txt
arh,


/p - thats what I needed.

Cheers boss.
5048.

Solve : Sneak Preview?

Answer»

Quote from: blastman on June 14, 2008, 08:25:19 AM

Jacob, you've inspired me...

I'm off to write my own game. (see you all a little later for help then.......)


Good Luck!Quote from: Carbon Dudeoxide on June 14, 2008, 06:09:40 AM
I can't wait to see the credits


Meaning?It would be nice to see my name on a game.

It will give me motivation to finish the game to see the credits. Quote from: Carbon Dudeoxide on June 14, 2008, 08:50:35 AM
It would be nice to see my name on a game.

It will give me motivation to finish the game to see the credits.
I'll put your name on my game Quote from: Carbon Dudeoxide on June 13, 2008, 09:57:50 PM
I've done something like that before. I used the call COMMAND for that. The whole game I made was 23 Batch files

Sounds quite simple, make a main menu like Jacob's first post and call a random MISSION batch on selecting "mission"
Though including those EXTERNAL batches in labels might be handier. Even then you could add labels with call commands later after the labels with batches... if you get what I mean.

Kinda modular system..Quote from: Schop on June 14, 2008, 09:17:31 AM
Quote from: Carbon Dudeoxide on June 13, 2008, 09:57:50 PM
I've done something like that before. I used the call command for that. The whole game I made was 23 Batch files

Sounds quite simple, make a main menu like Jacob's first post and call a random mission batch on selecting "mission"
Though including those external batches in labels might be handier. Even then you could add labels with call commands later after the labels with batches... if you get what I mean.

Kinda modular system..
It's a bit more complex than that....well what I did anyways....
5049.

Solve : DOS 6.22?

Answer»

Hi

We have an old PC which is only used to run DOS. It is in a very hostile environment (engineering factory).

Firstly we would like to backup the Hard Drive but there are no USB, Firewire ports on the machine.

Secondly we would like to UPGRADE the PC and install the backed up data. I am not sure what version of Windows runs DOS and will need to choose a PC that can run it.

Any help will be much appreciated.

Cheers BradYou can back up the data a number of ways... Easiest if you are not good with hardware is to Laplink it to another system in which you copy the drive entireties to another systems larger drive. There was a FX program a while back as well as Filevan that did this from Rainy City Software, but they are all not free. You can send data via LPT (Parallel) or Serial port from one system to the next to back it up and migrate data to new systems.

Or you can install a second hard drive in the case as a slave drive and XCOPY the root and all data to the other drive.

As far as Windows and DOS, Windows 3.x, 95, and 98SE are DOS friendly. I would avoid Windows Me. You can also run a newer OS if the hardware supports it such as if your system is at least a 200Mhz Pentium 1 CPU with 64MB Ram and a 2.5GB HD you can install Windows 2000 Pro. And if your system is at least a Pentium II 233Mhz with 128MB Ram and 8.4GB Hard Drive you can install Windows XP Pro SP2. Windows 98 SE and all prior Windows OS will run fine on less than 200Mhz CPUs and less than 64MB Ram.

If a 286, 386, or 486 or better CPU, and 1MB+ Ram, you can run Windows 3.11

If a 386 or 486 or better CPU, and 8MB+ Ram you can run Windows 95

If a 486 or Pentium CPU, and 16MB+ Ram you can run Windows 98 SE

If it is so old that it is an 8088XT CPU, you could try to find Windows 2.0 and run that, but you will need 512k Ram. Pointless unless you had an old app that had to run in a Windows OS that was supported by Win 2.0.

Also to note, your DOS version will change from 6.22 to 7.xx if you install Win 95 or 98 or newer, Windows 3.11 will stay with 6.22 and you can use the memmaker etc to get EMS etc set teh way you want and keep your base 640k as close to 640k as possible to keep the performance up, and avoid problems with too low of base memory that some apps will puke about if you are running in the 500-560k base memory range or less due to hogged base memory resources of a ugly config.sys and autoexec.bat setup.DOS 6.22 comes with interlnk / intersvr -- essentially the same thing as laplink, it makes the local drive available through the parallel / serial port to other pcs (if they are running DOS 6.22 too)

GrahamThank you so much, I really appreciate the comprehensive help.

Cheers BradQuote from: Whaletx on June 09, 2008, 08:42:55 PM

We have an old PC which is only used to run DOS. It is in a very hostile environment (engineering factory).

Firstly we would like to backup the Hard Drive ...

Secondly we would like to upgrade the PC and install the backed up data. I am not sure what version of Windows runs DOS and will need to choose a PC that can run it.

Whaletx, If you are still monitoring this post, I suggest that the easiest and probably safest way to backup the drive is to remove it and temporarily attach it to another PC. Then copy the entire drive to a folder on the other HD.

Then, do you have access to another small HD that the PC in use will recognise?
If so, great. Then you can experiment on the 2ND HD, without worrying about screwing the original up.

What is the PC used for, and what software is it running. DaveLembke gave you a list of OP system requirements. Win98SE will very likely do the job for you either in real DOS mode, or possibly out of a Windows command prompt. We can help you get it going if you need more help.

This is just a stab in the dark, but are you using the PC to communicate through the com port to an industrial machine?
Thanks everyone.

I followed your advice and now we have a newer PC with the data and a way to back up in the future. Yes you are right limeyer1000 the PC sends data to 2 very old CNC machines.

Thanks again everyone, I am a Filemaker developer so if you have any questions on that front I may be able to help.

Cheers Brad Quote from: Whaletx on June 13, 2008, 02:47:46 PM
Yes you are right limeyer1000 the PC sends data to 2 very old CNC machines.

When you said "very hostile environment (engineering factory) ", I knew it!
You're post brings back memories. We have a 1984 Mark Century 2000 that had a NON-DOS computer with 2 - 5 1/4 floppy drives, and no HD. I don't even know what the OP system was but management where I work told us that it would "NEVER communicate with a DOS computer." Several years back I got it communicating with an old 286 & DOS 6.22. (The CNC machine didn't know or care what the OP system was. It was simply looking at serial data transfer through the com port.) The operator moved all of his programs directly from the old NON-DOS computer to the "NEW" 286 computer one at a time over the com cable. Since then, we have progressed to a P4 with Windows XP.

We used to have proprietary software for every different CNC we had.(Five different controllers & 5 different softwares) Now we use DostekDNC from: http://www.dostek.com/ on 13 different CNC machines. Doug Struthers at DostekDNC was great working with us to get us set up. (It is Windows software, despite the DOS sounding name.) We couldn't get any software from anywhere to work (well) on our Fadals, except the old DOS software that CAME with them. Doug & I emailed back & forth repeatedly to work out the bugs on the Fadals. He actually altered the software to make it work on the Fadals, which had some weird stuff in the handshake that wreaks havoc on most other software.

If you are looking to get to a user friendly Windows environment, look into the above software. It can be set to work with almost every CNC out there. The guys here complained at first, but now love it because the software is easy and all the machines are the same now.
I forgot to MENTION this. Really glad to hear that you got the files backed up & the upgrade computer going.

Quote from: Whaletx on June 13, 2008, 02:47:46 PM
I am a Filemaker developer so if you have any questions on that front I may be able to help.

I have three questions in that area.
What does a Filemaker developer do?
What kinds of files do you work on?
What software do you use to assist in the filemaking?
5050.

Solve : [Solved] Hard drive not detected by DOS install CD?

Answer»

Hello,

First of all, I'm new to DOS, MS-DOS 6.22a in my case.

I have made an install CD though the (auto launching) setup fails. Pressing a key brings me to the A: prompt and it appears that A: is the only drive, no C: or whatever.
My hard drive is 160 gigabytes with four primary partitions: 20GB windows XP, 100GB, 25GB and finally a 1GB FAT.
I figured this last partition meets the requirements for DOS so it would work but apparently it doesn't.

Since I'm FAIRLY unfamiliar with any DOS environment I do not know what information is usefull so my question is simple: Can anyone post what information is needed from me to troubleshoot this and, hopefully, explain my problem to me.

Thanks,

Schop.It's been a long time since DOS6.22, but ... first, is the partition FAT(16) or FAT32. DOS won't be able to see a FAT32 partition.

Is the drive formatted? It may be that the partition is OK, but unformatted.

Also, it may be that you need to put your DOS partition at the beginning of the drive in order to be bootable. (DOS had more limitations than newer OP systems, as you know) but I'm not sure that the location at the end of the physical drive would prevent DOS from seeing the drive.I have verified that the partition is formatted as what windows calls just FAT, indeed not FAT32. Guess that'll be FAT16 then. I do think using the first partition makes it a lot easier but DOS really should be able to see others as well, maybe the MBR is written in some DOS unreadable way..? just thinking out loud. Or probably my disk requires a driver that's not on my bootdisk yet?

I'll try some driver in the meantime.(Bump) It is unfortunately not a driver problem.. :SSorry, I've been busy and I couldn't find any of my old PartitionMagic manuals. Plus, Google did not cooperate very well when I searched for information on DOS partition limitations, but I finally found a manual online. The following information is found on pages 38 & 39 of PartitionMagic 8.0 User Guide:

Quote

Creating Bootable Partitions:

Before creating a partition where you plan to install an operating system (a bootable
partition), you should understand the following information.

With the exception of DOS 6.22 (or earlier), partitions beyond 8 GB are visible to the current operating system. For more information, see “Understanding the BIOS 1,024 Cylinder (8 GB) Limit” and “Understanding the 2 GB Boot Code Boundary” in Help.

PartitionMagic 8.0 User Guide

I don't currently have PartitionMagic installed, so I couldn't look at the Help, as suggested, but I believe this means that DOS 6.22 or earlier cannot see beyond 8GB & in order to be a bootable partition, the partition must reside within the first 2GB of the physical drive, so ... my MEMORY was close, but ... not completely accurate.

Quote from: llmeyer1000 on June 09, 2008, 03:38:11 PM
Also, it may be that you need to put your DOS partition at the beginning of the drive in order to be bootable. (DOS had more limitations than newer OP systems, as you know) but I'm not sure that the location at the end of the physical drive would prevent DOS from seeing the drive.

If you want to boot DOS 6.22 on your HD, you will need to a tool such as PartitionMagic to resize and move your existing partitions, so that the FAT partition is at the beginning of the drive.

I have this suggestion:
As an alternative, why not install DOS 6.22, or Windows 98SE DOS on a jump drive and boot with it when you want to run DOS. I have a couple of bootable jump drives with Windows 98SE DOS for that purpose. Is there any reason in particular that you need DOS 6.22? Windows 98SE DOS is very similar to DOS 6.22 as far as functionality, but has much higher limitations. IE: It has a Boot Boundary of 8 GB & can see either FAT or FAT32 partitions anywhere on very large HD drives. The Edit.com program is way better and able to handle much larger files. A bootable jump drive will save you a lot of trouble and get you pretty close to where you want to be! Also, go with 98SE DOS, if you can.
Thank you for the investigation, llmeyer.
The problem then indeed lies with the partition being at the end of the drive. Judging from what you wrote I guess Partition Magic can actually physically move partitions on the disk?
I have Windows installed so that might give some trouble as well when moving its partition and using the first one for DOS. That is my main concern now: can I move my system partition without breaking Windows? If not I'll indeed try another medium for DOS, or just wait a month or so when I (hope to) get a second HDD.

Also, the reason I am trying to install DOS 6.22 is that fooling around with different OSes is a bit of a HOBBY. Linux also had a try but it just worked as it should, not much fun
And second, I like old-school original software, my ultimate goal is to run the original version of Tetras in a native and as old as possible environment. The most reasonably possible is then DOS 6.22, the latest version of like.. "the original DOS" Not the later ones extracted from Windows 9x.

Again, thanks for your post.Yes, PartitionMagic can move partitions, without losing data, but I still suggest learning how to setup a bootable jump drive as a safe simple solution to your needs.I will

USB booting isn't quite hard at all these days an I'll give it a go for the time being.
Until I have my second HDD it will do just fine i guess. Nothing i do will require anything near the maximum data transfer or storage capacity of my 1Gig jumpdrive