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.

7401.

Solve : Load text file strings into variables?

Answer»

I'm running XP with SP 2. Command prompt version shows [Version 5.1.2600].

As part of a DOS batch job I'm developing, I'm trying to read 8 lines from a text file and want to store the string on each line as a separate variable for later use within the script. Variable names could be as simple as Var1, Var2, Var3, etc.

I've been able to read the lines and echo them to the screen via a FOR loop, and planned to somehow make use of a numeric COUNTER to populate the variables. Haven't quite determined the method -- possibly by appending the counter to the variable names, or possibly by calling the FOR loop once for each line read, but jumping out of the loop after skipping through the appropriate number of lines each time.

My counter seems to get incremented correctly as it shows "8" if I echo the value after the loop ENDS, but I haven't been able to echo the correct value within the FOR loop, nor have I been able to reference the current value within an IF statement inside the loop.


Here's the code I'm trying:

Set Count=0
For /F "tokens=*" %%A in (test_input.txt) Do (
Set Var=%%A
Set /A Count+=1
Echo %%A
Echo %Var%
Echo %Count%
)
Echo %Count%


Here are the contents of test_input.txt:

One
Two
Three
Four
Five
Six
Seven
Eight


Here's the output I'm getting:

One
Eight
0
Two
Eight
0
Three
Eight
0
Four
Eight
0
Five
Eight
0
Six
Eight
0
Seven
Eight
0
Eight
Eight
0
8


The "8" at the bottom seems to show the correct Count value after the loop has ended, but the Count is ALWAYS showing "0" within the loop.

I'm also not sure why I'm getting "Eight" for the Var variable each time around. I'd appreciate an explanation if anyone can offer one.

Also, in doing research, I've seen people sometimes using exclamation points around variables, such as !Count!, but I'm not sure of their significance. Could someone please clue me in on their relevance?

Thanks in advance.
what exactly are you trying to do for your project? post a sample of input, your expected output, and the code you have so far. (and any other information)The snippet of code and sample input file I'm CURRENTLY testing is above. For that, I was expecting to get output along the lines of the following:

One
One
1
Two
Two
2
Three
Three
3
Four
Four
4
Five
Five
5
Six
Six
6
Seven
Seven
7
Eight
Eight
8
8


What I'm really trying to achieve is to load some variables with values related to the environment being used. Those values are in the text file being read. (The "echo" lines in my original code above are just for debugging.)

What I was hoping to do was something like:

Set Count=0
For /F "tokens=*" %%A in (test_input.txt) Do (
Set /A Count+=1
Set Var%Count%=%%A
)

My intent was to set variables of Var1=One, Var2=Two, Var3=Three, etc. (The actual values in the file are logins, passwords, filenames, paths, etc.)
You experience your problem because ordinary percent sign variables within a loop are EVALUATED once only, before the loop is executed.

You need to use delayed expansion and also use the exclamation mark as a variable delimiter instead of a percent sign within the loop.

Also, Var%count% won't work. You cannot make a variable name out of a variable value!







you have misunderstood what i am asking.
show what your test_input.txt looks like, and after manipulation, what are you expecting to see as output. That way, ppl here may suggest better ways of doing it instead of what you are doing now. The delayed expansion with exclamation points used for variable delimiters within the loop did the trick. I'm now able to load environment variables from a text file. Thanks for the tips!

I'll attach sample code for what I've got running. I basically have a main process which calls a routine called SET_VARIABLE once for each line in the input file, test_input.txt, and then echos the values of all 8 variables at the end. (In the batch file that I'll be deploying, the environment variables will have more descriptive names, and the input file will have values other than simply the {One, Two, ... Eight} I've been testing with as shown in my original post.)

The output for the code below looks like:

VAR_1=One
VAR_2=Two
VAR_3=Three
VAR_4=Four
VAR_5=Five
VAR_6=Six
VAR_7=Seven
VAR_8=Eight


Here's the tested code:

@Echo Off
setlocal enabledelayedexpansion
goto MAIN

rem --------------------------
rem Procedure Set_Variable

:SET_VARIABLE

Set Count=0
For /F "tokens=*" %%A in (test_input.txt) Do (
Set Var=%%A
Set /A Count+=1
if !Count!==%INI_FILE_POSITION% goto DONE_FOR_LOOP
)
:DONE_FOR_LOOP
set !VARIABLE_TO_SET!=%Var%

if %INI_FILE_POSITION%==1 goto DONE_SET_VARIABLE_1
if %INI_FILE_POSITION%==2 goto DONE_SET_VARIABLE_2
if %INI_FILE_POSITION%==3 goto DONE_SET_VARIABLE_3
if %INI_FILE_POSITION%==4 goto DONE_SET_VARIABLE_4
if %INI_FILE_POSITION%==5 goto DONE_SET_VARIABLE_5
if %INI_FILE_POSITION%==6 goto DONE_SET_VARIABLE_6
if %INI_FILE_POSITION%==7 goto DONE_SET_VARIABLE_7
if %INI_FILE_POSITION%==8 goto DONE_SET_VARIABLE_8
echo Error -- INI_FILE_POSITION %INI_FILE_POSITION% not recognized
goto END


rem --------------------------
rem Main Process

:MAIN

set VARIABLE_TO_SET=VAR_1
set INI_FILE_POSITION=1
goto SET_VARIABLE
:DONE_SET_VARIABLE_1
set VARIABLE_TO_SET=VAR_2
set INI_FILE_POSITION=2
goto SET_VARIABLE
:DONE_SET_VARIABLE_2
set VARIABLE_TO_SET=VAR_3
set INI_FILE_POSITION=3
goto SET_VARIABLE
:DONE_SET_VARIABLE_3
set VARIABLE_TO_SET=VAR_4
set INI_FILE_POSITION=4
goto SET_VARIABLE
:DONE_SET_VARIABLE_4
set VARIABLE_TO_SET=VAR_5
set INI_FILE_POSITION=5
goto SET_VARIABLE
:DONE_SET_VARIABLE_5
set VARIABLE_TO_SET=VAR_6
set INI_FILE_POSITION=6
goto SET_VARIABLE
:DONE_SET_VARIABLE_6
set VARIABLE_TO_SET=VAR_7
set INI_FILE_POSITION=7
goto SET_VARIABLE
:DONE_SET_VARIABLE_7
set VARIABLE_TO_SET=VAR_8
set INI_FILE_POSITION=8
goto SET_VARIABLE
:DONE_SET_VARIABLE_8

Echo VAR_1=%VAR_1%
Echo VAR_2=%VAR_2%
Echo VAR_3=%VAR_3%
Echo VAR_4=%VAR_4%
Echo VAR_5=%VAR_5%
Echo VAR_6=%VAR_6%
Echo VAR_7=%VAR_7%
Echo VAR_8=%VAR_8%

:END

what you need is arrays...
Code: [Select]Set objFSO=CreateObject("Scripting.FileSystemObject")
Set myFile=objFSO.OpenTextFile("c:\temp\test.txt")
Do until myFile.AtEndOfStream
linenumber=myFile.Line
If linenumber = 9 Then
Exit Do
End If
ReDim Preserve myArray(linenumber)
myArray(linenumber)=myFile.ReadLine
Loop
For i=LBound(myArray) To UBound(myArray)
WScript.Echo myArray(i)
Next
I had a question on something like this but didn't really know how to phrase it... this really helped me a lot though.

7402.

Solve : Copy particular file and replace it into multiple sub-directories?

Answer»

Hi,

I am NEW in creating complex batch file.

I am having two folders, one is "Master" and another is "Projects". In Master, i have master file named with core.css.

I would LIKE to create a batch file which will search for core.css in Projects folder and its subfolders (apprx. 140) and where find replace it with Master>core.css file.

Anyone can please provide me exact command for this.

Regards,
NitinQuote from: ng2010 on July 05, 2010, 01:45:18 AM

I am having two folders, one is "Master" and another is "Projects". In Master, i have master file named with core.css.

I would like to create a batch file which will search for core.css in Projects folder and its subfolders (apprx. 140) and where find replace it with Master>core.css file.



C:\test>type project0705.bat
@ECHO off
dir /s /b core.css

dir /s /b core.css | findstr "project" > core.txt

echo type core.txt

type core.txt

for /f "delims=" %%i in (core.txt) do (
copy c:\test\master\core.css %%i
)

Output:

C:\test>project0705.bat
C:\test\master\core.css
C:\test\project\project1\core.css
C:\test\project\project3\core.css
type core.txt
C:\test\project\project1\core.css
C:\test\project\project3\core.css
1 file(s) copied.
1 file(s) copied.

C:\test>Thank you so much marvin, it really works for me.

Do you have any IDEA how to apply this approach in VSS like my Projects and Master folder is in VSS so i need to first check out all core.css in folders and subfolders then applied copy command.

e.g. I am using ss checkout $/Projects/project1/core.css

I know it is out of this topic , but would be great if got any help on this.
7403.

Solve : Is there any DOS forums out there??

Answer»

Hi,

Is there any MS-DOS forums out there? If so, is there alot? I tried searching in GOOGLE for DOS forums but couldn't find. Does anyone have a list for DOS forums?Here is a good DOS forumWell
there is this place - http://www.ss64.org/viewforum.php?id=2

but it is not ANYWHERE as active as this one.

Stay here !!
GrahamI do want to stay here but i made a topic in the Windows section and i THINK everyone gave up on me by helping me setup a dual boot with Vista and DOS. That topic is most likely on page 2 PUSHING towards page 3. I would love to stay here. It is just i want a dual boot with Vista and DOS. Vista isn't recognizing there is another OS. I EVEN tried re-installing Vista like they suggested but no luck.Hey php111, I haven't really noticed your topic about dual booting Vista and DOS... but have you considered using a virtual machine? Then you don't need the hassle of setting up dual boot but can just run DOS from within Vista. Virtual PC is free from Microsoft.

7404.

Solve : Append a file content to another txt file?

Answer»

I would like to APPEND a file content to anther file
such as in a.txt's content: 123 and b.txt's content :456
i would like to append a's content to b's content ,
the expected result:
123
456


Many thanks
You example is a little confusing, you say that you want to append a.txt to b.txt, but the result you show is b.txt appended to a.txt !

However, to append 1 (TEXT, not binary) file to the end of another, do this
Type a.txt >> b.txt

The result (in b.txt) would be

456
123

GrahamI tried doing this and it works except for the fact that instead of b.txt being:

456
123

It's:

456123this is another alternative:
Code: [Select]c:\> copy a.txt+b.txt c.txt
then rename c.txt back to b.txt. (if desired)

7405.

Solve : Ms-dos command prompt question for computer class using windows XP?

Answer»

I have two questions on a lab that I have due for a "Window XP command prompt" class. I'm having trouble FINDING the commands in my text book to do what the question is wanting. I am hoping that someone ELSE has had this before and can TELL me what command I need to enter.

Here are the two questons:

1. Issue the command to display only .TXT files with short file names.

2. Issue the command to display only .TXT files with short file names sorted by name.

I know that part of the command will be DISPLAYED as follows for each of them:

C:\>DIR *.TXT

But I don't know what to put after that to display the short file names.

Any help will be greatly appreciated.Welcome to the CH forums.

Thank you for COMING straight out and telling us it's homework which we don't usually assist with but...

At the command prompt enter DIR/? to view the options list. Study all the options but particularly the /O and /X options.

Good luck

7406.

Solve : How to test if "MD C:\A\B\C\D\E\F" will succeed - WITHOUT executing it.?

Answer»

I am bullet proofing a script to supervise the removal of all traces of a security application in preparation for the clean install of an upgrade.

I have a list of paths, each of which terminates with a list of folders and files to be removed. That is no problem - job done ! !

Unfortunately when all traces are removed the upgrade will FAIL if any folder/file is not removed because it cannot be seen because of a lack of access to any PORTION of the path.

I can easily try "MD C:\A\B\C\D\E\F" to test whether there may be permission issues to prevent a clean install. This would be a nice bonus if I can "throw it in free".
Unfortunately if "MD C:\A\B\C\D\E\F" is successful then I ought to "do no harm" and restore the previous status QUO.
"RD C:\A\B\C\D\E\F" only removes the "\F" tail, whilst MD could have appended "\D\E\F".
Various people with various XP/VISTA/etc have listed various paths and items that need purging - hardly a %USERPROFILE% in any of them.
If MD has created relevant paths for both XP and VISTA, then after the RD there will be almost complete VISTA paths extra on XP, and almost complete XP paths extra on VISTA.

I therefore wish to predict whether it is possible to create a specific path before it is done.

CACLS GIVES me some clues about some access restrictions, and other numbers apply to both creatable and UNcreatable folders.
CACLS "C:\A\B\C\D\E\F" gives the following results :-
%ERRORLEVEL% = 2 when "F" does not exist - MD will make it;
%ERRORLEVEL% = 3 when "E\F" do not exist - MD will make it;
%ERRORLEVEL% = 267 if "F" cannot exist when "E" is a file, MD will never correct that;
%ERRORLEVEL% = 3 if "E\F" cannot exist when "D" is a file, MD will never correct that;
%ERRORLEVEL% = 5 if "E" is different user profile with no access, MD will never correct that;
%ERRORLEVEL% = 3 if "D" is a folder with no access, MD will never correct that;

Has anyone any ideas about SIMPLE alternative tests.
This is only a "FREE BONUS" that I do NOT need to include in an un-install script,
and I am not prepared at this stage to parse the path into individual folders and test the accessibility of each folder for a permissions blockage.

I have more than enough complexity with REG.EXE telling me all sorts of lies when I try to delete a key -
with one breath it tells me on the console stream success because the key exists,
and with the same breath on the error console it tells me of sub-keys which are access denied,
whilst %ERRORLEVEL% == 0 whenever the console stream says anything and it ignores the error stream.

regards
Alan
surely RD /S C:\A will remove the whole tree?
Agreed, but that is not what I want.

There are very many paths to be dealt with, here are two of them.

For my Win XP I need to deal with application folders held under
"%systemdrive%\Documents and Settings\%username%\L*\Application Data\..."
For another P.C. with W7 the same application folders are held under
"%systemdrive%\Users\%username%\L*\Application Data\

To my script I have recently added the paths for W7,
and absolutely no harm is done when I delete appropriate files after
CALL :SET_CD "%NEXT_PATH%"
because that will use
CD /D "%NEXT_PATH%"
and if "%NEXT_PATH%" does not exist it will then take action to avoid deletion of the existing current directory.
No harm is done even when a W7 path is used on an XP machine, and vice-versa.

For my BONUS feature I tried "MD %PATH%" cancelled by "RD %PATH%"
This perfectly removes the very last folder on the designated path,
but if the last 3 folders did not exist before "MD %PATH%" I leave behind a couple of extras.
And if this is a W7 path on an XP machine it will be left with a complete redundant W7 path I never had before, and vice-versa.

With a small bit of code I can parse the contents of %PATH% and then remove the whole tree with
RD /S C:\A
That will perfectly remove from XP the W7 path starting at %systemdrive%\Users\
But it would be bad news for a W7 system to have that path wiped out.
So I would need to classify each path that is specific to either XP or W7,
and at "run time" the O.S. must be determined and the "wrong" paths bypassed.

I am sure I can do that, and though I "never make mistakes" I always test my code to be sure - but I have no W7 to test on so I will not release code that may endanger the health of other people's computers.

I can use %USERPROFILE% to cover both the examples above and avoid all such problems.
Unfortunately there are many other paths that are to be dealt with, and for some there is no convenient environmental variable that will deal with either version.

My BONUS feature is not worth all the extra code and testing, nor is it worth putting at risk VISTA and W7 MACHINES - but they should have remained faithful to XP ! ! !

Hence I am looking for a simple solution that does not involve writing and deleting folders.

Regards
Alan

7407.

Solve : Search directory, but ignore certain ones?

Answer»

I have a script that searches the entire hard drive and if it finds a file to delete the corresponding folder, now I would like to search the whole hard drive, but if the file is found in say the Program Files directory, how can I tell the program to print out a warning, but and to continue on instead of deleting that file.

Here is what I am doing so far
Code: [Select] for /f "delims==" %%D in ('dir /s /b "!filename!"') do (
set direc=%%~dpD

IF "!direc!"=="C:\Windows\*" Call skip
IF "!direc!"=="C:\Program Files\*" Call skip2
I'm guessing this is part of a larger script where your syntax is correct:

Code: [Select]for /f "delims==" %%D in ('dir /s /b "!filename!"') do (
set direc=%%~dpD

IF "!direc!"=="C:\Windows\*" echo Warning
else IF "!direc!"=="C:\Program Files\*" echo Warning
else echo put your delete logic here

Someday, someone will have to explain to me at what POINT in time batch language became a programming language. Well I can I can post my entire script because when I was trying the checks I have, it wasn't working.

Code: [Select]@echo off
setlocal enabledelayedexpansion
c:
cls
echo *********************************************
echo **Delete Given File Names that can Be found**
echo *********************************************

echo Studying the file for banned file names.

for /f %%A in (H:\gameLocations\gameList.txt) do (
set filename=%%A


echo Searching for !filename!
title Searching...

for /f "delims==" %%D in ('dir /s /b "!filename!"') do (
set direc=%%~dpD

IF "!direc!"=="C:\Windows\*" Call skip
IF "!direc!"=="C:\Program Files\" Call skip2

echo !filename! found in folder !direc!
echo removing files/folder
echo rmdir /s /q "!direc!" && echo OK
)

echo Searching Hidden Files and Folders for !filename!

for /f "delims==" %%D in ('dir /s /b /a:H "!filename!"') do (
set direc=%%~dpD

IF "!direc!"=="C:\Windows\*" Call skip
IF "!direc!"=="C:\Program Files\" Call skip2

echo !filename! found in folder !direc!
echo removing files/folder
echo rmdir /s /q "!direc!" && echo OK
)
)
pause

:skip
echo Found in the Windows Directory Not Deleting...
)

:skip2
echo Found in the Program Files Directory Not Deleting...
)

So I was calling :skip and :skip2 if it was found in the directories, but the problem is that one of the files that I was searching for to test this script was IEXPLORE.exe and it found it in c:\windows\system32\... and it failed the check test c:\windows\* and it acted like it was going to delete the folder c:\windows\system32

So, what I need to do is see how I can have it check the folders, but print the warning.%%~dpD produces a path with the trailing backslash. In your Windows directory compare you used a wildcard which presumably is recognized as a literal.

You don't need a separate pass for the hidden items, use /a without any attributes.

Made the if instructions case-insensitive; you never know! Kept the for loops self-contained. Outside calls can screwup the return address.

Code: [Select]@echo off
setlocal enabledelayedexpansion
cd /d c:\
cls
echo *********************************************
echo **Delete Given File Names that can Be found**
echo *********************************************

echo Studying the file for banned file names.

for /f %%A in (H:\gameLocations\gameList.txt) do (
set filename=%%A


echo Searching for !filename!
title Searching...

for /f "delims==" %%D in ('dir /a /s /b "!filename!"') do (
set direc=%%~dpD

IF /i "!direc!"=="C:\Windows\" echo !direc! Found in the Windows Directory Not Deleting...
else IF /i "!direc!"=="C:\Program Files\" echo !direc! echo Found in the Program Files Directory Not Deleting...
else (
echo !filename! found in folder !direc!
echo removing files/folder
echo rmdir /s /q "!direc!" && echo OK
)
)
)

Good luck.
is there any way to test against recursive folders in the windows directory. Like if it is anywhere below c:\windows don't delete it, but notify me?

I mean if its under the base c:\windows i can test it, but there are many subfolders under c:\windows and many are important. So is there anyway to recursively check the c:\windows\anyotherfoldernotallowednomatterhowdeep (any other folder not allowed no matter how deep)The bells and whistles added to the solution are screaming for you to use another tool. However in the interest of CH policy that the customer is always right, this little batch snippet might be helpful.

Code: [Select]@echo off
setlocal enabledelayedexpansion
cd /d c:\
cls
echo *********************************************
echo **Delete Given File Names that can Be found**
echo *********************************************

echo Studying the file for banned file names.
title Searching...

for /f %%A in (H:\gameLocations\gameList.txt) do (
for /f "tokens=* delims=" %%i in ('dir "%%A" /a /s /b ^| find /i "%%A"') do (
set ddr=%%i
set dw=!ddr:~0,10!
set dp=!ddr:~0,16!
if /i "!dw!" equ "c:\windows" (echo %%A Found In Windows
) else if /i "!dp!" equ "c:\program files" (echo %%A Found In Program Files
) else (echo %%A Found but not in Windows or Program Files)
)
)

If the batch police see this, I'm a dead duck.

Note: replace this line (echo %%A Found but not in Windows or Program Files) with your delete logic.

Good luck.well can you name another language that I could use? I am using cmd because they basically want a solution that we can modify (its for an internship) but still be able to distribute to other tech support groups in our county.

Thanks for the help anyways. I think I will look into your solution. I ended up using a different solution because the one you posted had some errors (the one from like yesterday). It currently WORKS and can discover in the base of the windows directory, but not much father.

Is there a way I can break apart the string into tokens like you were doing but then join the first 2 tokens and see if it matches c:\WINDOWS?Yesterdays solution was not designed to look further down the directory tree than Windows or Program Files. Used the blueprint in your original post.

Today's snippet slices off a piece of the directory and checks for Windows or Program Files. This should include all the subdirectories under Windows and Program Files.

Batch code is designed as command language. A batch file ACTS as a container so you can stack program calls without having to repetitively type them in at the command prompt. Batch code is not designed as a programming language.

VBScript and JScript come installed with Windows and are great at down and dirty solutions. As with batch, they are interpreted with no need of all that pesky compile and linking of full-blown programming languages

I'll post a VBScript solution shortly.



Can you post the record layouts and the record count of the gamelist.txt file.gameList.txt looks like this

Code: [Select]halo.exe
project64.exe

Not really sure by what you mean by this
Quote

Can you post the record layouts and the record count of the gamelist.txt file

I was actually surprised by the VBScript, but it seems pretty zippy. At LEAST this is readable and if your tech support groups have Windows they can run this.

Code: [Select]Const ForReading = 1

strComputer = "."

Set fso = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set f = fso.OpenTextFile("H:\gameLocations\gameList.txt", ForReading)

Do Until f.AtEndOfStream = True
retString = f.ReadLine
fname = Split(retstring, ".")(0)
fext = Split(retString, ".")(1)
Set colFiles = objWMIService.ExecQuery _
("Select * From CIM_DataFile Where FileName = '" & fname & "'" & " and Extension = " & "'" & fext & "'" & "")

For Each objFile in colFiles
If InStr(1, objFile.Caption, "c:\windows") > 0 Then
WScript.Echo retstring & " Found In Windows...Not Deleting"
Else
If InStr(1, objFile.Caption, "c:\program files") > 0 Then
WScript.Echo retstring & " Found In Program Files...Not Deleting"
Else
WScript.Echo retstring & " Found In " & objFile.Drive & objFile.Path
WScript.Echo "Removing Files/Folder " & objFile.Drive & objFile.Path
strFolder = Left(objFile.Drive & objFile.Path, Len(objFile.Drive & objFile.Path) - 1)
'fso.DeleteFolder strFolder, True
End If
End If
Next
Loop
f.Close

Save script with a vbs extension and run as cscript scriptname.vbs

You can test this as written and see what it will do. When you ready for the production run, uncomment this line: 'fso.DeleteFolder strFolder, True by removing the single quote.

This script can be most destructive, be very careful in it's application.

Good luck.

thanks so much, that works like a charm. I changed one line to actually say what it was searching for, other than that, I left it how it was.
7408.

Solve : Equivalence of REM and :: syntax: Problem with if clause?

Answer»

Please CONSIDER the following example:
Code: [Select]@echo off

:: question: why is test1 correct but TEST2 not?
:: (tested on Windows XP)


echo test1:
if 1 equ 1 (
rem t1(): test1 works
)
echo ...works

echo test2:
if 1 equ 1 (
:: t2(): test2 throws a syntax error
)



Could somebody explain me why test2 fails?

Thank you very much in advance!

Best regards,

ThorstenMeanwhile I found the answer myself, it's always the same....:

http://www.robvanderwoude.com/comments.php

Quote

since DOUBLE colons are actually labels, they should be placed at the start of a command LINE; leading WHITESPACE is allowed, nothing else is
using double colons inside code blocks violates the previous "rule" and will result in errors
try to avoid comments inside code blocks, or use REM if you have to

ThorstenUsing double colon as REM substitute is unofficial and discouraged. It will break all parenthetical blocks including IF, FOR and && and || constructs.
7409.

Solve : open file then kill task?

Answer»

hi all,

i WANT to open excel file (via batch file) , but when it open, cmd command prompt (black screen) opened with it, so how can i close the cmd command prompt in the batch file with keep excel file opened?

any idea...
Thanks after you've open the excel file from your batch, PUT 'exit' at the end.

That will close the prompt window.

hope it helps.i tried that, and i tried to kill cmd.exe process, but it stops when open the file, and didn't excute any statement after open the file command untill the file closedpost your batch file, and I'll have a LOOK for you.it's very simple

if exist "TS.xls" "TS.xls"

if it exist, it opens it and open the command prompt

Thanks for helpYou should read the start HELP by typing start/? There you will see that the /B switch does this:
"Start application without creating a new window."

Try this:

Code: [Select]if exist "TS.xls" start "" "TS.xls" /B
it works, thanks you

7410.

Solve : another question involving the Windows XP command line class?

Answer»

I have another quesiton on my lab assignment that I can't figure out what the command is.

Here's the question:

Issue the command the will display the directory with the attributes of Archived and Hidden in reverse order by name.

I believe that I know what part of this command is going to look LIKE:

C:\>DIR /A:H

I believe that the [H] stands for Hidden files, because the text book has some of this listed. It says the following command:

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]. The entire line is in BRACKET, [], meaning that all of the parameters or switches are optional.

When it shows all of the lisings for [/A] command, it has the following LIST of attributes that follows the [/A] command.

attributes:
D Directories
H Hidden files
S System files
R Read-only files
A Files ready for archiving
- Prefix meaning not

No where on that list does it have the letter to display the Archive files.

Any help on this will be helpful.

Do you think that /A:A may work for what you are meant to be doing?

And as for the reverse alphabetical... /O:-N


Just as long as you understand what's happening here, it should be OK to use...
~~Dark Blade
From your own post...

Quote from: mnascarland on September 09, 2007, 11:09:09 PM

A Files ready for archiving

No where on that list does it have the letter to display the Archive files.

Maybe you need eyeglasses?

7411.

Solve : Self Renaming Batch File Help?

Answer»

I WROTE this batch file to test out some stuff I had just learned and I can not figure out why it's not working.

Code: [Select]@ECHO OFF
TITLE Rename Test

:Restart2

IF EXIST Title.txt GOTO Next2

:Restart

CLS
ECHO Please choose a number
ECHO 1-5
ECHO.
Set /P Save=""
IF "%Save%"=="1" goto Next
IF "%Save%"=="2" goto Next
IF "%Save%"=="3" goto Next
IF "%Save%"=="4" goto Next
IF "%Save%"=="5" goto Next
CLS
ECHO Error - Unknown Command
ECHO.
PAUSE
GOTO Restart

:Next

CLS
ECHO %Save% > Title.txt
ECHO Saving . . .
ECHO.
PAUSE
GOTO Restart2

:Next2

Set /p Title= < Title.txt
TITLE %Title%
ECHO Rename Successful!
Echo.
Pause

:Restart2

CLS
ECHO What would you like to Do?
ECHO Restart or Quit?
SET /p Next=""
IF "%Next%"=="Restart" GOTO Next3
IF "%Next%"=="restart" GOTO Next3
IF "%Next%"=="Quit" GOTO Next4
IF "%Next%"=="quit" GOTO Next4
CLS
ECHO Unknown Command
PAUSE
GOTO Restart2

:Next3

CLS
DEL Title.txt
ECHO Restarting . . .
ECHO.
PASUE
GOTO Restart2

:Next4

CLS
DEL Title.txt
ECHO Quitting . . .
ECHO.
PAUSE
EXIT
It creates the file properly and then will delete the file on exit properly, but it skips the renaming step.
Can anybody lend me a hand and help me figure out why?PASUE?

Thank you Salmon!

That doesn't solve the PROBLEM though, it still skips over the renaming part.

You enter a number, it saves the number in a txt file, and then prompts for a restart/quit. Completely SKIPPING over the renaming part.

Any ideas?one possibility is that a number before the redirection symbol tells it to write to a different stream, try it with the redirection at the start of the line:
Code: [Select]>Title.txt ECHO %Save% I know there was a post here in the last week or 2 that explained how to avoid this, but cannot locate it right nowIt creates the file properly, so that's not the problem,

Whatever though, thank you for the help. It was just for fun, to see if i could do it.

I rewrote it much more simplified:
Code: [Select]@ECHO OFF

:Start

TITLE %Title%
IF "%Title%"=="Matt" GOTO Next

CLS
ECHO Enter a title for this .bat:
SET /p Title=""

GOTO Start
Just add some "IF"s to make only certain titles work etc...

I'll just find some way to add on to this to make it more complex.

Thanks again Salmon and gpl!

7412.

Solve : How to read text file and value into batch file variable??

Answer»

Hi all
I have a file CALLED a.txt and it has some values. Now I want to read this file in a.bat file and get EVERY value into some VARIABLES. Can any one help me how to do this.

Best Regards@echo off
set idx=0
for /f "tokens=1*" %%a in (a.txt) do (
call set /a idx=%%idx%%+1
call set E.%%idx%%=%%a
)


variables WOULD be, e.1, e.2 ,e.3 ect.Awesome . I really apreciate it. Thank you very much

7413.

Solve : How do you add a string of text to multiple lines of text.?

Answer»

I'm creating a quick download batch file for use with rapidshare. I want to add 'START """ ' to the begining of each LINK when I copy and paste multiple links into a text file. I can copy and paste the start myself but I use this a lot and I'd like to AUTOMATE the process. Any help?Process the text file with a FOR loop. Prepend the additional text to each line and write it to a batch file, then call the batch file when you exit the loop.
I have'nt written anything in a long TIME. I don't remember how use prepend or the for loop, but I can make an adewuate loop using an if loop. The MAIN problem was prepending the text. I don't know the command. Thanks for the quick response.something like this

if exist doit.bat del doit.bat
for /f "delims==" %%L in (urls.txt) do (
echo start "" "%%L" >> doit.bat
)
call doit.bat

7414.

Solve : killing a vpn via dos?

Answer»

hey guys,

I have a batch file that needs a certain vpn dialed, so i have made shortcut for it and simply get the batch file to run "start vpn" and it connects ok.

My question is how can i get it to disconnect via dos also???

cheers in advance.find out whether that vpn SOFTWARE has a disconnect function. If no and you really absolutely can't find a way, KILL the vpn process using taskkill. i'm using XP to connect a vpn, so no other software is included.

also when you connect with xp i couldn't find a process in taskmgr to kill. (had the same idea)

cheers for the reply.
yes..so what is the command that you use to connect vpn?Quote from: ghostdog74 on September 12, 2007, 02:46:00 AM

yes..so what is the command that you use to connect vpn?
Also, if you can get the path of vpn and type path\file.exe /? in Command Prompt, we would learn if there's any COMMANDLINE parameters for it.having spent a day on google and speaking to the NETWORK admin at my office, i've found "rasdial"

i can use;

rasdail name-of-vpn username password

this will connect me to already made vpn.

Then it just a simple case;

rasdial /Disconnect

and i'm done.

Cheers guys.
7415.

Solve : Using command line find and checkout particular file from VSS?

Answer»

I would like to search a specific extn file in a VSS Project > Multiple Sub Project through command line

(e.g. $/Applications is my current project and $/Applications/Project1, $/Applications/Project2, $/Applications/Project3 are my Sub projects. )

Please can anyone provide me command line syntax for following:

1) Search specific extension file across sub-projects (e.g. abc.css)

2) Check out all those files which display in result

Thanks a lot in advance.

The MSDN site here msdn.microsoft.com/en-us/library/asxkfzy4(VS.80).aspx will tell you how to use the command lineThanks gpl, I've already gone through their site but I didn't any command similar to wild CARD search which locate file across projects. I know it is possible through VSS interface, but I am looking for command line solution.I dont have VSS anymore, so working from first principles, are you able to extract a list of the files in the repository or do you have to know what you want before you start ?

If you can extract a list, then you can save it to a file, filter it with findstr then PROCESS it line by line knowing that you are only looking at the files that meet your criteria.

Does this help at all ?Yes I am to able to extract all the files in NOTEPAD, but not in a position to check out all those files.If you can extract a list of files into a text file, finsdstr can then filter this list
for example (here Im not SURE what your list of files would actually look like) suppose you extracted your list to vss.lst and it held:
Code: [Select]a\fred.vb
a\fred.cls
b\fred.task
b\abc.css
c\def.css
c\cars.vb
d\abc.cssthen the line
Code: [Select]FindStr "abc.css" vss.lst>vss-filter.lstwill select these files into the filtered list
Code: [Select]b\abc.css
d\abc.css
You can now process the filtered list line by line to extract each of the wanted filesBelow is the complete output txt file using Findstr, all of them are in VSS Working folder location means they are with read only attributes, and i would like all of them into check out mode.

D:\Test\Projects\RAS\cc\core.css
D:\Test\Projects\RAS\css\core.css
D:\Test\Projects\SFA\css\core.css
D:\Test\Projects\SSD\css\core.css
D:\Test\Projects\TSMS\css\core.css

For your reference here is the command line code to check out single file from VSS

ss checkout $/Test/Projects/RAS/cc/core.css

7416.

Solve : Adding a new user?

Answer»

Hi peopple,

I need to add a user in the network domain as administrator but i have already an user with the same name but in the local domain, not in the network domain.

how can i MAKE it?Do you need to KEEP the same name can you not for example

Spero (original)

Instead

spero-t (new) I need keep the same name, but they TWO dont use the same domain...So if I understand that correctly, you want a user on the local computer and a user in your domain to have the same user name? Can I ask why? You could just create a new user in the network domain and add him to the ADMINISTRATORS group on the local machine giving him access to all the other users FILES. If that is why you want the same name.When we format some machine here, we rename the user Adminisrtator to mgr and add a new user that will use the PC. In our server, there is an user mgr too, and all machines must have this user on network domain, because the script we have need this user to run perfect.

I need the user mgr/network domain to run the script and the suer mgr/machine as administrator right?

how can i do it by DOS? By windows its easy to do.

Tks.


7417.

Solve : C:\ G:\ /D:04-02-2008/E/F/R/C/I/K/Y/EXCLUDE:\Windows\?

Answer»

XCOPY C:\ G:\ /D:04-02-2008/E/F/R/C/I/K/Y/EXCLUDE:\Windows\
does not work. Why?

XCOPY C:\ G:\ /D:04-02-2008/E/F/R/C/I/K/Y
works fine !

I use the above to BACKUP my files
Jim ParentLet's assume there's an XCOPY somewhere.

What does your command prompt LOOK like?

EDIT: OK you edited your original post to INCLUDE Xcopy - now answer the query - what does your command prompt look like?assuming you are using windows2000 or later
you should write in the command the name of a file
that contains a list of files to exclude

make a textfile dontneed.txt that have this line in it
\Windows\

and then write the command
XCOPY C:\ G:\ /D:04-02-2008/E/F/R/C/I/K/Y/EXCLUDE:dontneed.txt


(yes it is a stupid way this parameter is made)

7418.

Solve : Appending the System Path using a Batch File?

Answer»

Hi there, does anybody know of an EASY way to APPEND the REGISTRY ENTRY for a system VARIABLE?

I would like to create some sort of batch file that will keep what's already in the system variable, but just add an entry to the end of it.

IE:
OLD PATH: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem

WOULD LIKE TO ADD: O:\ORANT\BIN

NEW PATH: SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;O:\ORANT\BIN

Is this at all possible? Without having to manually add the path through the Control Panel - System - Advanced.....

Thanks alot,

7419.

Solve : how do u make a batch file delete another batch file on exit??

Answer»

i have opened a batch file called colorchange.bat, and it WRITES and calls another one called preferences.bat, which i want only temporarily, as it only contains one line of code.

how do i make it so when i hit the X button on the top right hand corner of colorchange.bat, preferences.bat disappears?
(i kno its possible, i hav cn it happen, but the person i hav cn code it won't show me his code.)

PLEASE HELP US!

kamak, RandomGuywhen you say "hit the X button on the top right hand corner of colorchange.bat"
I guess you MEAN close the WINDOW that have the batfile colorchange.bat
running in it. You should know that the bat-file is just running inside the window
and don't know anything about it. And a bat-file don't have any "destructor"
(if you happen to be a obect oriented programmer) that can start when you
kill the batfile if it is still running.

what you should do instead is at the end of your batfile colorchange.bat
just delete the file preferences.bat
(or directly after the call, whichever you prefer)


make colorchange.bat like this example:

@echo off
echo we have only one earth
echo don't use airplanes

echo %1 %2 %3 > %TEMP%\preferences.bat
call %TEMP%\preferences.bat
del %TEMP%\preferences.bat

echo or soon it is too late to save (what is left of) earth
echo don't be environmental un-friendly
rem (or place the del-line here, this is the last thing done)

7420.

Solve : Running a program and giving it input in a batch file...?

Answer»

I am not sure if I am going to word this correctly but this is what I am trying to do. I am WRITTING a batch file that will do a few things... create a text file...start a couple programs... but what I need to do is open a Development Shell for a COMPILER I am using and execute a couple commands. I have no PROBLEM getting the Development Shell to open in the process of doing things, but I dont know how to tell it to execute a command. This is the code I have so far:

::Prepare the VxWorks Image Using the VxWorks Development Shell
START C:\WindRiver\wrenv.exe -p vxworks-6.5
vxprj create simpc diab testing1234

the Start command works, but the second line "vxprj create simpc diab testing1234" NEEDS to be a command passed to the VxWorks Development Shell (which is exactly like the command prompt in how it works) ... I dont know if I am missing something but right now it seems impossible to accomplish this.

Thank you very much in advance for your help!

PS I am working on a WinXP machine if that helps.Is this something I would need to write a SCRIPT for? If so can anyone direct me to where I can find a tutorial on writing a script that can be executed through a batch file... Thank you everyone again.My guess would have been to pass the parameters on the command line but could find nothing specific. You might try this PDF document.

Page 12 discusses the command line and profiles which may be helpful.

Good luck. when you start a program, then you are out of what a dos batch file can do
until the program stops.

If you can't get the program to do what you want with command line parameters
then you need something that can write the text inside the program for you
like BUFFER 2, KEY-FAKE, KEYPRS or KEYBUF 128
and other programs that filles the keyboard buffer, mentioned at
http://www.bookcase.com/library/software/msdos.util.keyboard.html
http://short.stop.home.att.net/freesoft/keyb.htm#bufferstuffers
I guess you can download some and try which works best


Thank you everyone for your input, tomorrow morning I will try to see what I can get working. Thanks!

7421.

Solve : Copy and....?

Answer»

I know how to copy a file and paste it to the same directory where the .cmd or .bat is located.
EXAMPLE:
copy C:\windows\explorer.exe

But how do I make copies of that same file automaticaly ?

EXAMPLE:
Copy of explorer.exe
Copy (2) explorer.exe
Copy (3) explorer.exe

I want the code to automaticaly make copies of the same file in the folder without having to copy the code over and over again in the same .cmd file.
why do you want to do this?
Sounds like he's trying to make a "fork bomb".

Which is basically a .bat that copies/runs itself over and over again tying up all the ram.What is this forum now, a school for the DUMBER sort of script kiddie?


i don't know about you guys, but how does this differ from what OP is asking?
Code: [Select]for a range of numbers using the for loop
copy file file+counter
increment counter
this is a "fork" bomb too right? Imagine the counter is a huge number.....and I believe the actual batch code is posted somewhere....Wasn't that kind of dumb, Fen_Li? Now the script kiddie will cause much damage and TROUBLE, and you showed him how. I hope he fills up your hard drive!
contrex, I tried to PM you but it said you had blocked my message.
Is the advice above actually dangerous?
If so, Fen_Li should remove it.Wasn't that kind of dumb, Contrex? Now the script kiddie will cause much damage and trouble, and he will fills up your hard drive!

hei you, i think you just incriminate people, not give an answer or little suggestion..
are you chicken-hearted ?? (/w that script)
are you think with your level "SPECIALIST" you think better than me "a Rookie", aint always...
Quote from: Calum on September 10, 2007, 11:47:00 AM

contrex, I tried to PM you but it said you had blocked my message.
Is the advice above actually dangerous?
If so, Fen_Li should remove it.

I looked in my PM settings & somehow it was set to ignore all messages! (asterisk in ignore list box). Don't know how that happened.

Well, after I asked why the OP wanted a script to do what he asked, a number of people replied that the OP was asking for a script for a "fork bomb". Well, a fork bomb is actually something different. The fork bomb is a form of denial of service attack against a computer system that implements the fork operation, or equivalent functionality whereby a running process can create another running process.

What the OP asked for was a script which would continue copying a file indefinitely. The script supplied by Fen_Li, if run on a Windows system, would continue until the drive or partition was full. It could be copied, by a person who could not have dreamed it up themselves, onto a floppy or PENDRIVE or CDROM, or emailed into a school or work environment, where it would create havoc if run on machines in that environment by a malicious* person.

* see Fen_Li's reply to me.

So it is in fact a dangerous script.
Fen_Li - please remove the advice you have given as it appears to be dangerous.
If you do not remove the info within the next 10 minutes I will remove it myself.
Thanks.
Edit: thanks for removing the post.Fork bomb? First time I hear of that. I am new to MS-DOS and I was lurking though the help file looking at the "COPY" parameters. Then I wanted to know if there was a way to copy the same file automaticaly. I just wanted to know if it were possible though MS-DOS. I know how to do it in Visual Basic but since MS-DOS seems more simple to me, I just wanted to know how to do it in MS-DOS.

If nobody can help me, it's OK. There are MS-DOS books I can buy that can help me.
Its just that I wanted to take the easy route.
Take Care! What do you mean "copy the same file automatically". Why would you want many copies of the same file in one folder?
Quote from: FORMAT on September 11, 2007, 08:03:08 AM
If nobody can help me, it's OK. There are MS-DOS books I can buy that can help me.
yup, read those books, and then using the pseudocode that i posted as a guide, you will be able to come up with one on your own.A good friend of this forum sent me the code.
It does work but it did not function automatically.
What I had to do was place "Call (and the name of the .CMD or .BAT)"
and woohoo! It started copying automaticaly!

Problem is that after deleting the files. The Hard disk is still missing valuable free space. I don't know why...

Anyway, Thanks guys!
7422.

Solve : turn on a computer remotely?

Answer»

Hi,
Anyone knows how i can turn on a computer remotely?

MANY thanksas far as i can tell you

http://en.allexperts.com/q/Windows-Networking-1050/remotely-turn-computer.htm

School's back I see

You get a long stick and poke the power BUTTON with it, if you want to be more "remote" than that, you need network admin rights, and people with those don't need to post on forums like this.

Lol.
Not wat you think contrex....although am stl in uni...I work part time.

I have got admin rights and have been able to shutdown the computers remotely after file transfers. Just wondering if i could trun them on same way...RATHER than take the long walk to the room As ever, Google is your friend.

http://www.networkworld.com/columnists/2005/030705nutter.htmlIt's so weird how people would sign up to CH and post "I have a lot of computers on the network and I want to shut them all down remotely at the end of the day. How do I do this with cmd?"

If you want to turn off all the computer, go around to each one and press Start key, Up arrow key, Enter and Enter.
Simple.

Although I would see how turning computers on remotely would be useful but a little EXERCISE pressing a few dozen buttons wouldn't hurt...

As Contrex SAID, School has started and my school is taking the remote shutdown thing seriously this time.iMon do a RF version that turns on and off your computer up to 30feet, even through walls or you can put your main box in a cuboard. I know i own one
see here for some reference.
Quote from: Carbon Dudeoxide on September 10, 2007, 06:42:09 AM

Although I would see how turning computers on remotely would be useful but a little exercise pressing a few dozen buttons wouldn't hurt...
are you an administrator by job nature? if not, you shouldn't jump to such conclusions as to the usefulness of WOL. See here for a random example. crosstec remote control will let you turn remote computers on and off over a network, among tons of other remote control features. It's kind of an expensive program, but very impressive.

Another option is to train a monkey to push the power button for you.
7423.

Solve : Batch file to check not responding processes in one exe??

Answer» HI,
Has any one got any IDEAS how I could go about writting a batch file to
check whether a server process ( one exe ) has stopped responding

I guess I'd use the TASKLIST COMMANDLINE, but me DoS skills are
extremly limited?!

Thanks in advance.

thanks,
SENTHIL
7424.

Solve : auto up ftp?

Answer»

hi there,

I would like to know if it's possible to upload an index.html file to my ftp server automatically.

I'm ASSuming i'd need some sort of .bat file

would anybody be able to write a batch file (ftp.servername.com: - user name: - password:) to auto upload files to ftp please, Actually i would like it to auto update every...say.... 2 hours?, if possible

living in hope.

Lionel
see this code i hope its useful

PUT these ftp commands inside a file for eg a2.
assuming UR destination server IP is 192.168.2.1

open 192.168.2.1
USERNAME
password
ascii
cd "specified directory u want to sent the files to"
mput *.htm
bye

then inside a bat file do this

ftp -i -s:.\a2 >>ftplog.txt

put the two files to gether in the same directory where u put the html files u want to ftp them
and when u put the username and password make sure that u have no spaces after them unless they include a one

and to make it auto u have to put the bat file in the windows Scheduled Taskshi .bat_man

lol love the NICK, very apt

thanks for the reply, now.......

the code file is a *.txt file right?

i can create a .bat file by creating a .txt file, type in the code, then, change extension from .txt to .bat, right?

i'm hopeless at this stuff, is there a timer there somewhere, ...say .. to auto ftp up files every 30 minutes?

lionel thats right u just write the code and then change the extension
now if u want to make it work every 30 minute then the best way is to use windows Scheduled Tasks its very easy to use it. U can find it in control panel


and don't be depressed there always a solution for any problem
and the more problems u face the more experience u get

i hope its useful for u yes thanks

BUT, now the added problem overwriting the file already sitting in my server, btw: it's an updates channel STATS html file

7425.

Solve : How to add some text to all txts in directory??

Answer»

How to add some text to all txts in directory?

ECHO blahblah&GT;>*.txt doesn't work.for /f "delims=="" %%A in ('dir /b *.txt') do echo BLAH blah blah >> %%A

It doesn't work. I have WinXP.are you doing it in a BATCH file or from the prompt?

in a batch

for /f "delims=="" %%A in ('dir /b *.txt') do echo blah blah blah >> %%A

at the prompt

for /f "delims=="" %A in ('dir /b *.txt') do echo blah blah blah >> %A




Both doesn't work, in console and as a batch file.Quote

for /f "delims=="" %%A in ('dir /b *.txt') do echo blah blah blah >> %%A
I think 'double "' is the problem..
--- for /f "delims=="" ---
---------------------------------------------------------------------------------------------
for /f "delims==" %%A in ('dir /b *.txt') do echo blah blah blah >> %%A
7426.

Solve : How to check the single exe in system process?

Answer»

Hi,

I want to check the system process ( exe ) in task manager. some time the exe is DISAPPEAR , when ever i restart the services the process running properly.
Is there any solution to solve this issue.
Kindly help me.
If you need more question.let me inform
senthilYou can take a snapshot of the tasklist and restart services.exe if it has stopped running:

CODE: [Select]tasklist | findstr services.exe || sc start services.exe

I MAY have misinterpreted your post, so feel feel free to CHANGE the service NAME if necessary.



An alternative would be to setup a monitor script. Let us know.

7427.

Solve : Want to run win98 from a dos boot?

Answer»

I have an Itronix laptop that is running Win98
It has a PCMCIA slot that I have a COMPACT flash card I can insert
The flashcard is formatted with Win98 system files
With the flashcard out the laptop boots to Win98
With the flashcard in it boots to Dos
After booting to Dos with the flashcard can I run Win98 directly from Dos ?
I try going to the Win98 directory and typing "win"
But I get errors that say..."Cannot find a device file that MAY be needed to run windows"
I tried putting "path=d:\;d:\windows;d:\windows\system\" in the AUTOEXEC boot file but doesnt help
Just i can say that.... we can run dos using windows but not windows by dos. SINCE dos is inbuilt in windows.

regards,
chinnachinna with Windows 98 it is the other way around. It is actually built on top of DOS. You're THINKING about cmd in windows 2000/XP/Vista which many people mistakenly think is DOS.

zebra why do you want to run Win98 from a flash card if you already got it installed on your hard drive?

7428.

Solve : how to tell if "The device is not ready or not"..???

Answer»

is there a way to test if a drive is available-ready or not using cmd-batch codes..??

im trying this:
dir A:\ && start calc.exe
and it outputs this: "The device is not ready." then nothing happens...

im TRY the same thing again but for a USB drive F:\
dir F:\ && start calc.exe
the drive is there but no files are on it so it fials to DIR any files and then start calc.

so i want to be able to check to see if a drive is ready or not without having to check to see if it has files on it or not can this be done another way..??

like sumhow ping the drive to see if its active and if its active execute some code...As long as you GET the message "The device is not ready.", why don't you parse your OUTPUT and determine indirectly WHETHER the drive is ready or not.

On the other hand you can query the system directly:

Code: [Select]strComputer = "."

Set WshShell = CreateObject("Wscript.Shell")
Set dct = CreateObject("Scripting.Dictionary")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")

Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk",,48)
For Each objItem in colItems
dct.Add objItem.Caption, ""
Next

If dct.Exists("F:") Then WshShell.Run "calc.exe",,True

Save the script with a vbs extension and run from the command prompt as CSCRIPT scriptname.vbs


7429.

Solve : inputting data to another file with dos?

Answer»

hey all,


I need a batch file to INPUT certain data to another batch when run.

seems odd i know so let me explain.

i have a prgom that i have written that starts a batch file with 3 following add on's (shell ("c:\batch\mine.bat " + choice + " " + choice1 + " " + box.text)

the proble is that i want to have a stauts bar of the progress of this bacth file but VB won't let me do this with a PROGRAM or batch that has added on information on the end, there fore i require the 1st batch file to take the inputted date (%1, %2, %3) and autofill in a template so that VB can run the 2nd batch file with the correct data and with no added information on the command line.

any ideas as i'm stumped!!!All I FOUND was this template for the shell function which MAKES no mention of a status bar:

Code: [Select]Public Function Shell( _
ByVal PathName As String, _
Optional ByVal Style As AppWinStyle = AppWinStyle.MinimizedFocus, _
Optional ByVal Wait As Boolean = False, _
Optional ByVal TIMEOUT As Integer = -1 _
) As Integer

Does your shell function work? Do your batch files work? More info needed. Create bat file one with parameters & echo out bat file two with the parameters filling in the blanks.

7430.

Solve : using dos base programme in window vista in full screen mode?

Answer»

hi
i am using my inventory programme which is DOS BASE.
previously i was using window xp with service pack2
and to run the above dos base programme in full screen window i used to press alt and enter.
but the same is not working in window vista HOME premium
please inform if anyone any solution to this.

thanksthe solution is of course to get rid of that ugly drm-riddled Vista
and reinstall winXP sp2 again, since vista isn't exactly made to
let you run dos-programs or older windows software

(if you ask microsoft you should of course go buy a new
inventory programme made especially for vista so some microsoft-
friendly software COMPANY can earn more money from you :-D )

When ms made hasta-la-Vista then backward compatibility
and usability with older software wasn't in their direct
focus (only drm was). I believe you can't have fullscreen
with vistas graphic drivers because then you could possibly
circumvent vistas drm-system that tries to prevent you from
copying films or something :-/

it you insist on running fista anyway, I guess your only
hope is to run your application in the dosbox-emulator.

(note that it is possible to have more than one operating system
installed on your computer so you can select if you want to
run shvista-vista or xp (or freedos or linux or something else)
when the computer starts, if you want)
Quote from: just-a-teddybear on April 23, 2008, 09:19:00 PM

the solution is of course to get rid of that ugly drm-riddled Vista
and reinstall winXP sp2 again, since vista isn't exactly made to
let you run dos-programs or older windows software

(if you ask microsoft you should of course go buy a new
inventory programme made especially for vista so some microsoft-
friendly software company can earn more money from you :-D )

When ms made hasta-la-Vista then backward compatibility
and usability with older software wasn't in their direct
focus (only drm was). I believe you can't have fullscreen
with vistas graphic drivers because then you could possibly
circumvent vistas drm-system that tries to prevent you from
copying films or something :-/

it you insist on running fista anyway, I guess your only
hope is to run your application in the dosbox-emulator.

(note that it is possible to have more than one operating system
installed on your computer so you can select if you want to
run shvista-vista or xp (or freedos or linux or something else)
when the computer starts, if you want)

whaa... you can have 2 OS'? ummm sweet... and ummm how? and ummm does it take up HDD space? and ummm will it screw up my pc if i do it wrong? and um tuts, links, galore?
7431.

Solve : Help with echo command.?

Answer»

So I want to echo something along the LINES of 123|456|789 to a text file. I know how to do that using

Echo 123|456|789 >> C:\ect\etc

But the problem is it wont LET me echo the | charactor. Any help on how to be able to do that?The | character MEANS something special to DOS; s you need to 'escape' it, like this

Echo 123^|456^|789 >> C:\ect\etc

GrahamThanks.

7432.

Solve : Simple .bat file?

Answer»

Hi, as topic name said i need help making simple .bat file.
When it run it should EDIT this file...
C:\Windows\system32\drivers\etc\hosts
Can ANYONE post exemple?How do you want it to be edited? Appending a line based on user input or what?
You haven't given much to go on.

What reason do you have for needing to do this?when run,user need to see just this..not to type anything or do anything

CONFIGURATION to your hosts are changed successful.

Press any button to continue.

and i need this to change hosts. so it allow people to connect to lineage2 private server@echo off

>>"C:\Windows\system32\drivers\etc\hosts" echo line you want to add

echo Configuration to your hosts are changed successful.
echo.
pausethanks you...
now, i have only 1 qusetong, can it make to delete all exiting lines in that file, and insert new lines, that is given as command?>"C:\Windows\system32\drivers\etc\hosts" echo line you want to add

Use only one redirection arrow (>)

here
Code: [Select]@echo off

COLOR 0A

>"C:\Windows\system32\drivers\etc\hosts" echo 127.0.0.1
>"C:\Windows\system32\drivers\etc\hosts" echo 89.149.200.219 l2authd.lineage2.com
>"C:\Windows\system32\drivers\etc\hosts" echo 89.149.200.219 l2testauthd.lineage2.com


echo Configuration to your hosts are changed successful.
echo.
pause


and when i run it it create only last line?
this Code: [Select]89.149.200.219 l2testauthd.lineage2.comOh, I didn't realise that you were doing multiline.

Only use one redirection arrow for the first line, but 2 for all the REST, like below:

@echo off

COLOR 0A

>"C:\Windows\system32\drivers\etc\hosts" echo 127.0.0.1
>>"C:\Windows\system32\drivers\etc\hosts" echo 89.149.200.219 l2authd.lineage2.com
>>"C:\Windows\system32\drivers\etc\hosts" echo 89.149.200.219 l2testauthd.lineage2.com


echo Configuration to your hosts are changed successful.
echo.
pausethx dude

7433.

Solve : Copying hard drive?

Answer»

Hi,

We have a piece of equipment with proprietary software running in DOS (6 I THINK). We INSTALLED a second hard drive and ghosted the drive using norton. It didn't work. We can't BOOT from the drive.
We can't get to DOS command prompt, so we booted from a win98 floppy. I tried formatting the drive in the same computer and xcopying the data over. I still can't boot from the copied drive.

Any ideas?

Thanks

Richarddthats because when you copied the data over, you didnt first make a partion on the drive. Ok, so I FDISK th e drive and create a partition and then copy the data over....right?

RicharddQuote from: Richardd on April 28, 2008, 07:45:23 PM

Ok, so I FDISK th e drive and create a partition and then copy the data over....right?

Richardd

Fdisk to create the partition, then Format using the /S parameter to transfer system files to the new drive (IO.Sys, MSDos.sys and Command.com) then copy the data.

See the commands/parameters listed here for MS-Dos ver.6

Good luckyes once you make a partion and THEN format it then you can ghost it with Norton.What version of Ghost is this ? ?

The Ultimate Ghost Resource

Kudos and Thanx Again to the folks at Radified !
7434.

Solve : msdos?

Answer»

Hello..

please help me to compile and run turbo c programs by giving MSDos command...
Have you STUDIED the documentation? Please describe your problem

didn't turbo c have a ide/programming environment where you can
just use compile or run in it's menus?

at least turbo PASCAL did have a NORMAL menubar with
DROPDOWN menus since version 4.0 and before that had some
fullscreen menu, wasn't turbo c made something similar?

so just START turboc and open your c-file in it
and select compile or run

7435.

Solve : Dos Help Command "copy /b"?

Answer»

Hi!

I used command copy /b to hide one file into another

Now the pickle is that I FORGOT to learn how to Extract one file from the other. It is EASY to extraxt or should I say Look at the combind file if both are .txt files, but FIRST file is an Image and another is a Zipped Exe (A tiny one).

Can someone Help ?Steganography is not for the faint-hearted or forgetful.

If image is first and zip is second...

Open file in hex editor and look for zip file header. Cut as needed.

If reverse

If file is bmp, study bmp header INFORMATION pages on web and look at whole file in hex editor and work out where to cut

If image is jpeg




7436.

Solve : Execute EXE through a Batch with Windows Command?

Answer»

Hi there, does anybody know if it's possible to execute a file within a batch file and have it also run some windows commands?

This is what I have so far:

Command to execute a file:
"\\ykapp\RIMS9000\_Filing Bin Installation Files\_3 FBinConf.exe"

This executable file POPS up with "INSTALL" or "CANCEL" commands. I WOULD like to always have this file select the "INSTALL" option (HOTKEY ALT I)

I'm trying to get my batch file to execute the EXE file and select "INSTALL" to continue the installation. Make sense

Thanks a lot.does the "_3 FBinConf.exe" support command line switching??

like /silent to install without promptingI don't believe it does. Is there a way to find out?
Thanks..navigate to the exe in a dos prompt and type exename /?when I do that, it just launches the executable file.that'll be a no then.

tbh i'm not sure your going to be able to do this in dos (i could be wrong - it has happened before!!)

As i'm sure you know dos won't click on "ok" or ANYTHING like that. You might have to try a different language.


sorry i couldn't help more.


You could try echo I | command[/i], but don't take my word for it.

7437.

Solve : Batch errors?

Answer»

I am trying to make a simple batch file that will copy jpgs to a flash drive, renaming each jpg in a numerical COUNT (1.jpg, 2.jpg, 3.jpg, etc) and log the corresponding number with original location/filenames to a log (list.txt)

Here is my code:
Code: [Select]set num=0

mkdir "%~d0\HIDDEN\%computername%"

set targetfolder=%~d0\hidden\%computername%
ECHO %computername% > %targetfolder%\list.txt

d:
for /f "delims==" %%F in ('dir /s /b *.jpg') do (
set num=%num%+1
xcopy "%%F" "%targetfolder%\%num%.jpg" /s/c/q/r/h
ECHO %num% %%F >> %targetfolder%\list.txt
)


@pause
@cls
@exit

However, it seems to ignore my handles for the xcopy command. It also seems to ignore adding one onto the variable 'num' on each loop.

What am I doing wrong?Variables set within a for loop require special handling:

Code: [Select]setlocal enabledelayedexpansion
set num=0

mkdir "%~d0\hidden\%computername%"

set targetfolder=%~d0\hidden\%computername%
ECHO %computername% > %targetfolder%\list.txt

d:
for /f "delims==" %%F in ('dir /s /b *.jpg') do (
call set /a num=%%num%%+1
xcopy "%%F" "%targetfolder%\!num!.jpg" /s/c/q/r/h
ECHO %num% %%F >> %targetfolder%\list.txt
)


@pause
@cls

Sidewinder: STILL does not increase num. CONTINUALLY tries to write to file 0.jpg each time.I guess I missed the one on the echo statement. The XCOPY should have been fine. Not for nothing but what OS are you using?

Code: [Select]setlocal enabledelayedexpansion
set num=0

mkdir "%~d0\hidden\%computername%"

set targetfolder=%~d0\hidden\%computername%
ECHO %computername% > %targetfolder%\list.txt

d:
for /f "delims==" %%F in ('dir /s /b *.jpg') do (
call set /a num=%%num%%+1
xcopy "%%F" "%targetfolder%\!num!.jpg" /s/c/q/r/h
ECHO !num! %%F >> %targetfolder%\list.txt
)


@pause
@cls

I'm using XP Pro SP2

I tried simplifying the count for now, creating a new batch file with only that FOR loop ECHOing the value of num, then adding to num, then ECHOing num again. When I use ! in place of %, it literally outputs "!num!" instead of it's value, but it is still not adding to num's value.Are you using the setlocal statement? I'm still unable to duplicate your results.

Sorry, that was a stupid typo on my part. The counting variable is working just fine now.

However, the xcopy command is apparently ignoring the handles I have sent to it, so it is asking whether each and every file copied is a File or a Directory. That doesn't make for a very automated process.Quote

xcopy command is apparently ignoring the handles I have sent to it

Do not understand the terminology.

Try piping the XCOPY response:

echo D | xcopy "%%F" "%targetfolder%\!num!.jpg" /s/c/q/r/h

OR

echo F | xcopy "%%F" "%targetfolder%\!num!.jpg" /s/c/q/r/h

You might want to double check if those are the proper responses. Sorry, to clarify:
Xcopy is ignoring the handles/options/attributes I'm trying to send it with the source and destination:
"/s/c/q/r/h"

which tells it to search subfolders, continue even if there are errors, do not display filename while copying, overwrite read-only files, and to copy hidden and system files; respectively
7438.

Solve : Find text in file?

Answer»

I have searched the forums, and found several instances of using FOR in a batch file to read lines of text from a text file... what I need is to read a specific portion of a line of text. Basically, I'm writing a script that will get the version of the current bios, so that I can then automate updating the BIOS.

So, given the following text file:
Code: [Select]Program: eSupport.com BIOS Detect v1.2 July 21, 2003
BIOS Date: 12/02/04
BIOS Type: Phoenix - AwardBIOS v6.00PG
BIOS ID: 12/02/2004-CLE266-8235-6A6LUAKCC-00
OEM Sign-On: **** POD-6717 BIOS V1.10c (04/24/2008) ****
Chipset: VIA 82C3123 rev 0
Superio: Winbond 697HF rev 2 found at port 4Eh
CPU Type: Intel Celeron(R)
CPU Speed: 650 Mhz
CPU Max: 1500 Mhz
BIOS ROM In Socket: YES
BIOS ROM Size: 256K
Memory Installed: 1024 MB
Memory Maximum: 768 MB

eSupport.com, Inc.
1-800-800-BIOS (2467)
www.esupport.com
Where the line containing "OEM Sign-On:" contains the version information I am looking for, I would like to retrieve just the "V1.10c" portion of the string and evaluate it.
Other version NUMBERS that we may come across include V1.11, V1.14, and V1.10. OBVIOUSLY, I would need a way to also handle the instance where V1.10c includes an extra character. Once I can evaluate this, then I can move within my batch file to install the correct update to the bios.

Thanks in advance! @echo off
set file=bios-text.txt
for /f "tokens=1,2,3,4,5,6 delims= " %%a in ('type %file% ^| find "OEM Sign-On"') do set version=%%f
echo BIOS version appears to be %version%

Code: [Select]Set objFS = CreateObject("Scripting.FileSystemObject")
strMyFile = "C:\test\bios.txt"
Set objFile = objFS.OpenTextFile(strMyFile)
Do Until objFile.AtEndOfLine
strLine = objFile.ReadLine
If InStr(1,strLine,"OEM") Then
ArrR = SPLIT(strLine," ")
For i = LBound(ArrR) To UBound(ArrR)
If Mid(ArrR(i),1,1) = "V" Then
WScript.Echo ArrR(i)
End If
Next
End If
Loop
save the above as script.vbs and on command line
Code: [Select]c:\test> cscript /nologo script.vbs
V1.10c
hi all
i think this will do it
for /f "tokens=1,2,6 " %%i in (filename) do (if '%%i' EQU 'OEM' if '%%j' EQU 'Sign^-On:' echo %%k)

am I wrong if so kindly explain for me .
have you tried it out?
yes well then

7439.

Solve : DNS on xp?

Answer»

how to get DNS by USING command prompt in windows xp?what do you mean "get DNS" ?
TRY exploring the possibilities of IPCONFIG...err..don't know how to explain,but i want the DNS obtain manually,but in xp & using command prompt.
like in the windows 98 run - command - ipconfig
but if i did that in xp,will it come out?
If you want it manually, type ipconfig /all and under DNS servers it should be there.yup,that's help a lot!
TQ Dark Blade

7440.

Solve : How to capture file path in a variable?

Answer»

Hi guys,
I have a doubt that , can we capture path of the file in a variable and use it for other purpose.

eg:
suppose i have a text file named test.txt in this location c:\newfolder1\newfolder2\newfolder3\text.txt. And iam USING this path many times in my batch file and i donot want to COPY and paste this path EVERY time. can i set c:\newfolder1\newfolder2\newfolder3 in a variable and use it. I couldn't figure it out. Will u guys help me...

THANKS in advance.

regards,
chinnaset /?
Hi guys,
Will you plz provide the syntax for this....

Thank you,

regards
chinnaTo set the variable for use,

Quote

set variablename=value

To use it in code,

Quote
echo %variablename%
hi guys,
i need to set the filepath as variable but not value. plz help me..

thanks

regards,
chinnaWhat do you mean you want to set it as a variable but not a value?

A variable in a batch program has a value, whether it be numeric or a string of CHARACTERS it is a value.
7441.

Solve : All batch file items execute at once?

Answer»

I am using a DOS batch file to execute SEQUENTIAL jobs using MATLAB to run overnight. Because Matlab tends to cause memory fragmentation, I have found that exiting Matlab and restarting for the next job is the best way to conserve memory. At the end of each file I use quit to exit from Matlab and proceed to the next job which opens a new instance. A sample of the batch file is given below:

matlab /r command1('input1')
matlab /r command2('input2')
matlab /r command3('input3') etc...

On most computers the batch file will execute the first line and open Matlab, then wait for the task to complete and the Matlab window to close before executing the next line and opening the next instance.

However, on some computers the batch file will execute all the items at once, openning many instances of Matlab and swamping the system resources.

I believe the issue is with the DOS prompt and not with Matlab, although I will try to post this on a Matlab forum as well. I was wondering if there is a property of the DOS command window that causes it to behave differently on different system environments, and if there is a way to CHANGE to sequential operation from simultaneous. Has anyone encountered anything like this before?

Thanks for your help.perhaps you can START matlab from your bat-file with the command start /wait

start /wait matlab /r command1('input1')
start /wait matlab /r command1('input2')
start /wait matlab /r command1('input3')

which will wait until the command is completed
(normally all windowsprogams started from bat-files runs in PARALLELL)

7442.

Solve : How to copy a directory using a startup disk or Installation CD?

Answer»

I have been in a fix for some days....the issue is a simple one but couldnt find any solution to it

I have Microsoft XP installed running SP2
I am in SITUATIONS when i need to boot up using Microsoft XP Installation CD or MS DOS Startup disk. After booting from these, when DOS loads, i cannot find any command that can copy a folder (having LOTS of files and subfolders) from my CD ROM to my Hard Drive.
Remember xcopy and Robocopy only run when u r in Windows XP Environment. Even then, if they r tried in DOS, the error message ARISES
" This command cannot be run in MS-DOS mode"

tried using "help" but it doesnt have any other command than "copy" to copy files.
The copy command can only copy files but it fails when u need to copy a directory having multiple files and subdirectories

Does anybody have a solution?Quote

Remember xcopy and Robocopy only run when u r in Windows XP Environment.

The version of xcopy that comes with Windows 98 works fine from my MS-DOS 7 startup disks and my bootable MS-DOS 7 pen drive. However as you say, Robocopy is a 32 bit Windows application. Sounds like you need the right version of xcopy.exe.

7443.

Solve : Set command help!!!?

Answer»

hi all, i am need of some help for using the set command, in place of the choice command in XP. Here is my task:
I need to create a menu in a box centered on the SCREEN from which users can choose from any of the following commands: net user, ipconfig, echo, findstr, XCOPY, set, and a way to exit. After making their selection, my batch file must display help for that command on a freshly blanked screen, stay there for the user to read, then redisplay the menu on a freshly blanked screen for the user to continue.
Please help!!!! Your help would be greatly appreciated.

set /p a=- , /p is the option in set that allows it to be similar to choice.

@echo off
cls & echo. & echo Choice
echo A-Ipconfig & echo B-E^cho & echo C-Findstr & echo D-Xcopy & echo E-Set
echo. & set /p chs=- & if "%chs%"=="a" set chsa=ipconfig
if "%chs%"=="b" set chsa=echo & if "%chs%"=="c" set chsa=findstr
if "%chs%"=="d" set chsa=xcopy & if "%chs%"=="e" set chsa=set
cls & %chsa% /?
Looks like diablo is very close, but forgot to test it.
It needs a pause at the end. And even then only choices b & d work.(in XP anyway)
Apparently the "if set ..." commands do not like to follow the & sign.

Try this:
Code: [Select]@echo off
cls & echo. & echo Choice
echo A-Ipconfig & echo B-Echo & echo C-Findstr & echo D-Xcopy & echo E-Set
echo. & set /p chs=-
if "%chs%"=="a" set chsa=ipconfig
if "%chs%"=="b" set chsa=echo
if "%chs%"=="c" set chsa=findstr
if "%chs%"=="d" set chsa=xcopy
if "%chs%"=="e" set chsa=set
cls & %chsa% /?
pause>nul

For more information read this:
MS-DOS set command help
How to use the set command as a substitute for the choice command in Windows 2000 and Windows ...
Quote from: rhoads on April 20, 2008, 08:32:15 PM

hi all, i am need of some help for using the set command, in place of the choice command in XP. Here is my task:
I need to create a menu in a box centered on the screen from which users can choose from any of the following commands: net user, ipconfig, echo, findstr, xcopy, set, and a way to exit. After making their selection, my batch file must display help for that command on a freshly blanked screen, stay there for the user to read, then redisplay the menu on a freshly blanked screen for the user to continue.
Please help!!!! Your help would be greatly appreciated.

give this a try and let me know if you need it to do SOMETHING more.

code:


@echo off
:loop

cls & echo. & echo Choice
echo A-Ipconfig & echo B-Echo & echo C-Findstr & echo D-Xcopy & echo E-Set & echo F-EXIT

echo. & set /p chs=-
echo %chs% |findstr /i /r "[a-f]"
if /I %errorlevel% == 1 goto bad
if "%chs%"=='' goto bad
if not '%chs%'=='' SET Choice=%Choice:~0,1%
if "%chs%"=="a" set chsa=ipconfig
if "%chs%"=="b" set chsa=echo
if "%chs%"=="c" set chsa=findstr
if "%chs%"=="d" set chsa=xcopy
if "%chs%"=="e" set chsa=set
if "%chs%"=="f" goto exit

cls & %chsa% /?
echo PRESS any key
pause>nul
goto loop

:bad
ECHO "%chs%" is not valid. Please try again.
ECHO.
ping -n 2 localhost > nul
GOTO Loop

:exitwow, thnx guys!!! i used set, if...........modified a bit using goto but cool!! Thnx again!!
7444.

Solve : batch file that can assign a specific IP Add... help pls?

Answer»

any one who can help me about creating a batch file that can assign specific Ip add, subnet mask, DEFAULT gateway, and DNS.... THANKS in advanceWithout KNOWING your OS, we can only GUESS that netsh might work.

Netsh is an environment where you can add IP addresses, subnet MASKS, DNS, gateways and WINS entries to the network configuration tables.

Good luck.

7445.

Solve : When Window is closed start website..???

Answer»

how do i make a batch script to wait for a SPECIFIC titled window to close and then once it closes i need it to GO to a certain website.

how can i do this..??You could do this with 3rd PARTY software to TEST for the PID of the program running, and if the PID is running do one thing and if not running do SOMETHING elese etc.

DOS Batch isnt smart enough to do what you want unfortunately without another program to interface through an API etc to Windows

7446.

Solve : disable and enable network connection settings using batch file?

Answer»

hi guys! ANYONE here knows how to create batch file to disable and enable network connections settings? i badly need it ASAP..HOMEWORK?NOPE. im a newbie IT Staff in our company and sad to say im the only IT Staff here. this company is just under workgroup, that's why it has a weak security. and some user's are changing their network setting just to have an INTERNET access.

is it possible to create a batch file to disable and enable network connection settings in all member of the workgroup? if not is there any other way?

THank you very much..you can use DEVCON. You should redesign your environment to restrict user access for changing network settings (and those privileged commands)

7447.

Solve : Running Path?

Answer»

Hi. I'm TRYING to call a batch file from another batch, both scripts are in the same folder, but the first one to run is called from a scheduled task, in a remote computer, and the location of scripts may vary depend on many factors.

I've tried SIMPLY "CALL myscript.cmd" without path, but isn't running. It run if I run the first script from the prompt, but not when is called remotely by the task.

I need to know if there is a way to retrieve the 'running path' of a script (like app.path in VB)

I can't pass it as parameter, because there are many scheduled tasks already, calling the first script, and i can't change all of them.

thx. show your code, and how you called the batch remotely.The first script runs from a windows scheduled task, using:

"\\srvname\sharedfolder\script\firstscript.cmd"

I'm replacing several lines of many scripts, changing all the var setting, placing it in a second script, common for all. For that, i need that all the scripts execute a script called var.cmd, practically in the first LINE.

var.cmd is in the same folder than firstscript.cmd

i can't hardcode anything in firstscript.cmd, the folder where the scripts are may vary, and i need to avoid to change anything from the scheduled tasks.

In short, i simply need to run this line in my script:

CALL var.cmd

But, i don't know where var.cmd is, i only know that both scripts are in the same folder.
CALL var.cmd, without path works fine if i LAUNCH it from prompt locally, but doesn't from the task, maybe the unc path has something to do.

For that, i think that if i can retrieve the working path in the first script, i can use it when calling the second script.

do i explain myself? or is it more confused now?

FINALLY FOUND IT!

%~p0

I always use it as: %~p1 ; %~p2 ; %~pX, with PARAMETERS...but never realized that 0 means the script itself.

%~n0 works the same way, with the name of the script.

Thanks anyway

7448.

Solve : How the *censored* do i install MSCDEX ????

Answer»

I have windows XP and would like to play an old game.
I have resolved all issues with DOSBOX and VDMSound except one.
It asks me to install MSCDEX v2.21 or above.
I have downloaded the latest version , but i have no clue what to do with it !!!

I have read hundreds of posts and yet cannot figure where my driver (mscd001 or something) is? There is no such line in my autoexec.nt and config.nt .

There is also no such thing as config.sys or autoexec.bat in my c:\Windows\system32

Please guide me to install this MSCDEX , it's driving me crazyQuote from: hopefulguy on April 22, 2008, 10:02:42 PM

It asks me to install MSCDEX v2.21 or above.
I have downloaded the latest version , but i have no clue what to do with it !!!

I have read hundreds of posts and yet cannot figure where my driver (mscd001 or something) is? There is no such line in my autoexec.nt and config.nt .

There is also no such thing as config.sys or autoexec.bat in my c:\Windows\system32

you have to put mscdex "microsoft cd extension" in c:\autoxec.bat
(or autoexec.nt or whatever winXP uses, perhaps in
c:\WinNT\System32\ or c:\Windows\System32\ instead of c:\ ?)
so dos and dos-programs can read the FILES on your cd.
(without it, dos just ignore your cd-disks)

but since back in the dark ages (~1990 or so) all cd players were not connected
in the pc in the same way, you needed a device driver too, and that driver should
be loaded in c:\config.sys (or perhaps config.nt if you use winXP)

Since you have a new computer, you need one for cd-players connected
with the normal ide/atapi -interface in the computer (the same way you connect
normal parallell harddisks)

it can look something like this

in c:\config.sys this line was added:
DEVICE=C:\ATAPICDD\ATAPICDD.SYS /D:MSCD001

in c:\autoexec.bat this line was added:
C:\SHSUCDX\SHSUCDX /D:MSCD001

"MSCD001" is just a NAME, but it have to be the same name
in both files. you can write FRITJOFF if you like :-)

if you're not having a cd-driver file there allready you can
SEARCH google for dos cdrom driver or something
or use this one that freedos uses:
http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/util/system/xcdrom/

with that one you have to write
DEVICE=C:\Xcdrom.sys /D:MSCD001
instead of course (if you put your driver in c:\)


....but if you use DOSBOX, perhaps you should instead just look at this page
http://www.dosbox.com/wiki/MOUNT
about how to "Mounting your CD-ROM in DOSBox"
More info about how to run games in dosbox at http://www.dosbox.com/

:-)
Woah ! Thats real good information right there .
But i tried to use your info and it still says mscdex not installed.

What is all that ATAPICDD and SHSUCDX in the syntax ?

Do i have to make a autoexec.bat and config.sys for myself ??Quote from: hopefulguy on April 23, 2008, 09:49:24 PM
But i tried to use your info and it still says mscdex not installed.
What is all that ATAPICDD and SHSUCDX in the syntax ?

oups :-)
I ment MSCDEX not SHSUCDX (I was just pasting from freedos pages,
and in freedos mscdex is called SHSUCDX. Both are small programs that
do the same thing, "extending" dos so it can use cds, the one made by
microsoft is called mscdex and the one made by someone at freedos is
called shsucdx. there are other such programs too that you can use
instead of course, some made to live under windowsNT/2000/XP)

ATAPICDD.SYS is just the dos cd-rom driver in the example
(a generical one for modern cd players I belive, but there are others,
and with old computers you want one that matches the way
the cd player is connected)


Another example how it could look like with windows98.....

in c:\config.sys:
device=c:\oakcdrom.sys /d:hello

in c:\autoexec.bat:
c:\windows\command\mscdex /d:hello


When dos start it first read config.sys and load drivers like
himem.sys (for extended memory) and oakcdrom.sys
("Generic device driver for ATAPI CD-ROM drives") into memory
and read settings there. Then it starts to execute the dos-commands
and run the programs listed in autoexec.bat, like setting the path
variable and running the program mscdex.exe (a program that helps
dos understands cd's). After that it displays the dos-prompt where
you can enter commands and start programs.

If you start a dos-program from within windows, things work a little differntly
depending on what windows version you use.

O.K. I get it , Thanx.

This really helped me. I'm 1 step closer to getting the game to work.
But the thing is my MSCDEXNT (already installed from when i bought this computer)
seems to be corrupt (i.e the game talks about a fatal error due to corrupted MSCDEX) . I downloaded the new MSCDEX version but i can't get it to replace the already present MSCDEXNT. Every time i delete MSCDEXNT it promptly appears back again and again.
What am i supposed to do
7449.

Solve : Ping Specific Ip batch file?

Answer»

How can i do ?
I want to execute the ping.bat, INSERT a ip and then the script will use ping -t "adress" until i exit.use SET /p to get the address and then ping -t %address%

Because this is very simple and I'm in a good mood I will write this for you.

Quote

@echo off
:start
set ip=
set /p ip=IP Address to ping:
cls
if not '%ip%==' (
ping -t %ip%
)
GOTO start
This is the absolute minimum code that will do the desired task

set /p ip=IP Address to ping:
ping -t %ip%

The -t switch tells ping to continue until Ctrl + C are pressed.

i am in a good mood too. here's a vbscript.
Code: [Select]'*******************************************************
'* Name: pingMachineArgs.vbs ****
'* Function: Ping a machine *
'* Input: Machine IP/hostname *
'* Limitation: Only a few response cases. ****
'* Author: ghostdog74 ****
'* Usage: cscript /nologo pingMachineArgs.vbs 127.0.0.1 *
'*******************************************************
Option Explicit
Dim objPing,objFSO,objArgs
Dim query,PingMachine,PING,response
Set objArgs = WScript.Arguments
PingMachine=objArgs.Item(0)
Set objFSO=CreateObject("Scripting.FileSystemObject")
query="select * from Win32_PingStatus where address ='"& PingMachine & "'"
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery(query)
For Each PING In objPing
Select Case PING.StatusCode
Case 0
response="Reply from " & PING.ProtocolAddress
Case 11002
response="Destination Net Unreachable"
Case 11003
response="Destination Net Unreachable"
Case 11010
response="Request Timed Out"
End Select
Next
WScript.Echo response
Code: [Select]@ECHO OFF
COLOR 0A
TITLE PingUtil
:LOOP1
SET /P ENDMAQ=ENDERECO:
TITLE %ENDMAQ%
ping -t %ENDMAQ%
TITLE PingUtil
SET ENDMAQ=
GOTO LOOP1

Now how can i doto rename the tittle window to %ENDMAQ% ON if it is responding and %ENDMAQ% OFF if not respondig ?If not respondig, errorlevel will be 1, otherwise will be 0.

But you can't use -t in this case. You must ping de ip address, check errorlevel, CHANGE title, and go to loop1Maybe I GOT this wrong, but I understand that if you:

@echo off
ping xxx.xxx.xxx.xxx

OR

@echo off
ping name_of_the_resorce

you should be done
7450.

Solve : I do not have autoexec.bat or config.sys !!!?

Answer»

The C:\windows\system32\ does not contain autoexec.bat or config.sys .
Can you pls send me yours ?
I can post my email.What Operating System is it?Quote from: hopefulguy on April 23, 2008, 06:05:51 AM

The C:\windows\system32\ does not contain autoexec.bat or config.sys .
Can you pls send me yours ?

since you mention C:\windows\system32\ probably you are using
windowsXP and not just ms-dos ?

in windowsXP they have renamed the files autoexec.nt and config.nt
and put them there instead of in the root c:\ where they belong
in real dos.

what are you trying to do? those two files are textfiles that
contains your dos-settings and are not programs. if you have not
changed any settings from default, they will perhaps not exist yet.
if so, you have to create them yourself with for example notepad.

since windowsXP don't have support for real dos like windows98 had
(win98 is a better OPERATINGSYSTEM if you want to run dos-things)
you probably want to run dosbox wich is a program that EMULATES dos
and hardware like Soundblaster soundcards that old dos-games need.


Ah yes! you are right , i do have config.nt and autoexec.nt .
But they are just full of nonsense , Look at my autoexec.nt :

***
REM AUTOEXEC.BAT is not used to initialize the MS-DOS environment.
REM AUTOEXEC.NT is used to initialize the MS-DOS environment unless a
REM different startup file is specified in an application's PIF.

REM Install CD ROM extensions
lh %SystemRoot%\system32\mscdexnt.exe

REM Install network redirector (LOAD before dosx.exe)
lh %SystemRoot%\system32\redir

REM Install DPMI support
lh %SystemRoot%\system32\dosx

REM The following line enables Sound Blaster 2.0 support on NTVDM.
REM The command for setting the BLASTER environment is as follows:
REM SET BLASTER=A220 I5 D1 P330
REM where:
REM A specifies the sound blaster's base I/O port
REM I specifies the interrupt request line
REM D specifies the 8-bit DMA channel
REM P specifies the MPU-401 base I/O port
REM T specifies the type of sound blaster card
REM 1 - Sound Blaster 1.5
REM 2 - Sound Blaster Pro I
REM 3 - Sound Blaster 2.0
REM 4 - Sound Blaster Pro II
REM 6 - SOund Blaster 16/AWE 32/32/64
REM
REM The default value is A220 I5 D1 T3 and P330. If any of the switches is
REM left unspecified, the default value will be used. (NOTE, since all the
REM ports are virtualized, the information provided here does not have to
REM match the real hardware setting.) NTVDM supports Sound Blaster 2.0 only.
REM The T switch must be set to 3, if specified.
SET BLASTER=A220 I5 D1 P330 T3

REM To disable the sound blaster 2.0 support on NTVDM, specify an invalid
REM SB base I/O port address. For example:
REM SET BLASTER=A0
***

There's no such line about the driver "MSCD001",
how do i create a new file for myself ?
can you pls tell me?
Quote from: hopefulguy on April 23, 2008, 09:43:56 PM
Ah yes! you are right , i do have config.nt and autoexec.nt .
But they are just full of nonsense , Look at my autoexec.nt :
yeah hehe... that was lots of comments
but the thing is, since your winXP does all the things itself
(that dos should have done) there is not much things to set.
there is no real dos in winXP after all, it just pretends to be :-)

Quote from: hopefulguy on April 23, 2008, 09:43:56 PM
lh %SystemRoot%\system32\mscdexnt.exe
this line is windowsXP's own version of mscdex that don't need
the MSCD001-parameter because it is especially made to just
ask windowsxp do its STUFF for it. So mscdexnt don't need a dos
device driver in config.sys for the cd - and thereby not need the
cddrive-name MSCD001 to connect the driver with mscdex

I've read that xp's version of mscdex is somewhat limited though
and can't do everything that is shuold so some games won't work:
http://vogons.zetafleet.com/viewtopic.php?t=1715

Quote from: hopefulguy on April 23, 2008, 09:43:56 PM
REM Install network redirector (load before dosx.exe)
lh %SystemRoot%\system32\redir
REM Install DPMI support
lh %SystemRoot%\system32\dosx
those are support for network and for 32-bit dos-applications and such

Quote from: hopefulguy on April 23, 2008, 09:43:56 PM
SET BLASTER=A220 I5 D1 P330 T3
settings for xp's emulation of the Sound Blaster 2.0 soundcard
that is address, interrupt and dma-channels that dos-programs need to
know to be able to use the soundcard

Quote from: hopefulguy on April 23, 2008, 09:43:56 PM
There's no such line about the driver "MSCD001",
how do i create a new file for myself ?
can you pls tell me?

since xp dont have a device driver in config.sys (or config.nt) for the cd
when using mscdexnt instead of mscdex, it don't use a name like
MSCD001 for it
Cool ! You seem to know a lot about these things.

Well i would really like to use a device driver so that i can GET my game to work.
I tried xcdrom.sys (like you said) but i don't think its working.
Is there any driver for SAMSUNG DVD-RW

About that MSCD001 , i'll try to make one up myself. (again,like you said)