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.

6251.

Solve : BIG Question!!!????

Answer»

Is there any way to access to another PC with open port?i mean when 2 pc open some port so 1 guy can access to another[highlight][/highlight] :-? :-? :-? :-? :-? :-? :-? :-? :-? :-?Well what EXACTLY are you trying to accomplish? That is the better question, philosophically and gramatically.i mean: i WANT to access to my second pc with first
and i want to know can i do it with ports in FIREWALL?
Maybe you should do some READING and THEN ask the questions if you don't understand. Here are 38,200,000 starting points:

http://www.google.com/search?hl=en&q=how+to+network+two+computers

6252.

Solve : Changing file date and time stamp?

Answer»

On a Windows 95 system I WANT to change a file's date and time stamp (within the DOS command window). It's been a VERY long time since I manipulated files using DOS. I think this can be done, but I can't remember how to do it. Can someone help?

Thanks.Quote

On a Windows 95 system I want to change a file's date and time stamp (within the DOS command window). It's been a VERY long time since I manipulated files using DOS. I think this can be done, but I can't remember how to do it. Can someone help?

Thanks.

It has been a while for me too.

I used to do it with some utility programs. I can't remember any one in particular now, but I did a quick Google and several that SEEM to be the thing are found.

Check out:
http://david.tribble.com/programs.html

Grab chtime.exe . If you execute it with no parameters on the command line, it returns a brief 'help'. Looks like what you want.

Give it a try and let us KNOW if that does the job for you.

I tested chtime.exe on my XP computer and it seems to work great. I hope to TEST it on the Win95 machine tomorrow. Bottom line, I need to change the date on a data file. The real test will be executing the application to see if changing the data file hoses up everything. Sorry to be so longwinded, but thank you very much for your help today.Quote
I tested chtime.exe on my XP computer and it seems to work great. I hope to test it on the Win95 machine tomorrow. Bottom line, I need to change the date on a data file. The real test will be executing the application to see if changing the data file hoses up everything.

I'm sure you'll remember to keep a good BACKUP copy of everything.

Quote
Sorry to be so longwinded, but thank you very much for your help today.

I hope it works for you.

from somewhere.

Code: [Select] @echo off & setlocal enableextensions
if [%1]==[] (
echo Usage: %~0 ["FileName"]
echo Wildcards allowed
goto :EOF
)
for %%f in ("%~1") do copy /b /v %%f +,,> nul
dir "%~1"
endlocal & goto :EOF
6253.

Solve : Problem in using if within for?

Answer»

my ck.txt has (note there will be spaces after comma
jothi, m
john, n
joseph, o
jane,b
my data.txt has
jothi
john
joseph
johny
i have requirement like if first argument in the chk.txt file matches with argument in data.txt then write the second argument(m,n,o,etc by triing the spaces) of the chk.txt file to a file new.txt
i.e i need OUTPUT as new1.txt having
m
n
o
for this i USED
command
in batch file as
for /f %%i in (data.txt) do for /f " delims=, tokens=1,2 " %%j in (ck.txt) do if %%j==%%i set dat=%%k & set data=%dat: =% & echo %data% >> new1.txt
but in the file new1.txt
ECHO is on
ECHO is on
ECHO is on

Can anyone solve this

Regards
Jothish

If I understood you right the following code should work.
(No guarantue if it is buggy) ;-)
I am WORKING with NT4, so I don't know how it behaves in other Windows VERSIONS.


@echo off
setlocal
cls
del new1.txt

for /f %%i in (data.txt) do for /f " delims=, tokens=1,2 " %%j in (ck.txt) do call :sub1 %%i %%j %%k

endlocal
goto :eof
:sub1
set data=%1
set ck=%2
set k=%3
if %data% EQU %ck% (echo %k% >>new1.txt)

:eof


hope it helps
ulihey it is working fine gurantee that it is bug FREE

6254.

Solve : Read Text File?

Answer»

Hello,

I have a batch file that checks whether a text file exists. This WORKS fine. What I would like it to do now, is to read and set the CONTENTS of that text file into one variable so that I can execute a shutdown command.

This file is created by another standalone program that works fine, and creates the text file to have arguments in it. These arguments would be something like -f or something of the sort. Sometimes in this file, there would be a -c command, and this would signal for another text file to be opened with a comment in it.

I tried doing some of the basic stuff of this with the type command but to no avail. Does anyone have any suggestions?

Thank you all in advance for any help.

Hess SmithOn some VERSIONS of Windows you can use the for commmand to read FILES. Full details can be found by typing for /? at any command prompt.

8-)

6255.

Solve : Sorting Files - "dir" Command?

Answer»

I'm searching through large shares using DOS command, dir *.XXX /s.

I would like to GET the data for modified, or created, between two dates. Does anyone know how to do that? Thanks in advance.This REALLY needs a Windows script where dates can be compared easily. In the command shell, dates are available in the localized format. In many areas the localized format is mm/dd/yyyy where DEC 25, 2006 would come after Mar 01, 2007; not very helpful for comparisons.

8-)

6256.

Solve : How to select files by date in batch?

Answer»

For ms-dos
I ve got a FOLDER with multiple identical file named by numeric way (1 to 98 for example). The file 98 is the newest, and i want to copy these ONE and only these one. The problem is, if a NEWER file is add, the file name will be 99. So i want a batch file which could copying the newest file in a folder.
Thanks for your help.Easiest way would be to sort the files descending by date and skim off the top entry:

CODE: [Select]@echo off
for /f %%i in ('dir *.* /tc /o:d /a-d /b') do (
copy %%i targetdirectory
goto tag
)
:tag

You may have to add path information to suit your environment. Replace targetdirectory to MEET your specs.

Hope this helps. 8-)perfect thanks a lot

6257.

Solve : Can the "file created" date be changed??

Answer»

Thanks to those who helped me yesterday! What I figured out is I need to change a file created date, not the file last MODIFIED date. The host is running good ol' Win95.

Any takers?An OLD time favorite utility called Touch is just what you need:

Touch

The link to the PROGRAM is listed on the left side of the page at the bottom of the list.

Good luck. 8-)Thanks for the help. I also found Better File Attributes on the web. HOPEFULLY, one of the two will help.

6258.

Solve : call .vbs in a .bat file??

Answer»

Hello,
I'm using Windows 2k, I was wondering if it's possible to call a .vbs script and use the output as the variable in a BATCH file?
ie.
rem now-1
call now.vbs
for /f tokens=1-3 delims=/. " %%m in ("%now%") do (

set mm=%%m
set DD=%%n
set yy=%%o

set now=%%m%%n%%o)

echo%now% >>.log

Thank you for your time.One way would be to pass the variable thru the environment. Have the VBScript set the environment variable (now for example) and then read it BACK in your batch file (%now% for example)

Use the cscript ENGINE to call your VBScript; all work would need to be done in the same session of the cmd shell.

You can also persist DATA from one script to another by using a file.

Hope this gives you some ideas. 8-)

6259.

Solve : not able to use the "/"?

Answer»

Hello there. Hope all had a GREAT CHRISTmas.
Here's my problem:
I had lent out my toshiba 2060 laptop to my pastor to use in church, he had his father-in law reformat it. When I got it back & tried to do a "deltree" I found that I can't, as the "/" isn't there..instead what SHOWS up is an "e with a ' on top of it. What can be done to fix this problem..it runs on win98.
ANYWAY that'sit.
Hope someone can help.
Take care & have good day.
stargazerMaybe he did something to change the keyboard layout to another country. Anyway the / is number 047 and the e is number 101 so hold down the alt key and type 047 on the number pad. thank you very much.
Stargazer

6260.

Solve : Problem using substring in string ()DOS?

Answer»

Hai ppl,
i am using substring to get jothish from a xml file having
jothish
i have USED
Code: [Select]%above_strin:6,-7%it doesn't work the way it should work
i searched for the same in google i found that i have to give escape character(^) before the special characters like <,>,|,&. So i can explicitly specify ^ character but if the spcial character COMES in between the above code wont work
Need suggestions to solve it......

Thanks
PPLI had a similar problem with html tags.
Try this:
set var="%above_strin:6,-7%"

hope it helps
uliNO yar i cant able to resolve that using double quotes either....
Did you solve the problem using the double quotes

thanks
jothishI used this to delete the
tag from the var:
(It didn't work WITHOUT double quotes cause of the html tag.)

set var="uli
glueck"
set var=%var:
=%

uliif you have scripting LANGUAGES like Perl/Python or even vbscript and others similar, they can make your life easier
example in Python
Code: [Select]import re
xmlcontents = open("yourfile.xml").read()
print re.findall("<name>(.*?)</name>",xmlcontents)[0]

output:
Code: [Select]jothish

6261.

Solve : Copying ONLY files from subdirectories?

Answer»

Hi fellows,
I'm trying to copy files with the same file extension from a directory and its subdirectories and, to accomplish that task, I'm using the xcopy /s command. But, besides copying the files, the subdirectories are copied too, and I don't want that happen.
Can anybody help me??
Thank'sI may be WRONG but I THOUGHT XCOPY was used for directory structures. This little snippet might be helpful:

Code: [Select]@echo off
for %%i in ('dir [highlight]path\*.exe[/highlight] /s /B /a:-d') do (
copy %%i [highlight]targetpath[/highlight]
)

path and targetdirectory are placeholders for which you must supply values.

Hope this helps. 8-)

Note: *.exe is just an example; change to whatever extension needed.Hi Sidewinder,
Thank's for HELPING me!!
I'm not good at DOS programming so I'd like to ask you some questions:

1 - Would Path be the directory where my files are at?

2 - Would Targetpath be the directory where I want my files be placed?

Could explain me how your code works?

Thank's!!
I'm not Sidewinder, but:

1) Yes

2) Yes

As for the code, my DOS is a little rusty, so he'll need to explain it. Until he does, treat it like it's his magical incantation. Thank's for your help, Dilbert!! alpcruz,

How does it work? Beats me! In the example posted, the code gets a list of all the exe files in a directory and it's subdirectories; then copies them one by one to the target directory.

8-)Sidewinder,

Thank's for the explanation!!

I tested your code and it worked well but it is still not what I really want.

Let me explain:

I tested your code with 4 TXT files. They are placed at C:\Test1\Test2\Test3 but I put the batch file at C:\Test1. So, in the code, dir path = C:\Test1\Test2\Test3 and Targetpath = C:\Test.

What I really want is to set dir path = C:\Test1 and make it get the TXT files at Test1, Test2 and Test3 and copy them to C:\Test.

In this example it is easy because the NAMES of directories are short, but, if they are big dir path would be very large in some cases!!

If you have no doubts about what I want, I ask you: Is it possible to do that??

Thank's for your pacience!!I can't find anything that will handle this for you with an easier code block than

Code: [Select]COPY C:\Test1\*.txt C:\Test
COPY C:\Test1\Test2\*.txt C:\Test
COPY C:\Test1\Test2\Test3\*.txt C:\Test
Trust me, I looked.

I did have a code that would work if Test 1, Test 2 and Test3 were all in C:\, Like so:

C:\Test1
C:\Test2
C:\Test3
C:\Test <- Has the test.bat file

In the above scenario, this works:

Code: [Select]FOR %%A IN (1 2 3) DO COPY C:\Test%%A\*.txt C:\Test\
I had one text file in each folder, and all three copied successfully. Unfortunately, that isn't what you wanted. But it's closer. Dilbert,

I appreciate your help!!

As you said, it's not precisely what I want but those are good ideas and maybe I can handle, in the future, a scenario like that.

I will keep those codes you posted with me!

Thank's a lot!!alpcruz,

Sorry for the confusion. I failed to include the /f switch in the original code:

Code: [Select]@echo off
for /f %%i in ('dir path\*.exe /s /b /a:-d') do (
copy %%i targetpath
)

Note: the /f switch is supported only in some versions of the command prompt.

As Dilbert has pointed out, there are usually many ways to do the same thing. Think of it as a buyers market.

8-)Ok, Fellows!!

Your tips helped me a lot.
I have a better understanding now and I think I can do what I want.

Thank you both!!

6262.

Solve : Cool Camera Syncing BAT?

Answer»

Hi Everyone! I just recently got a new camera over the holidays, and a 2gig card to go with it!

Then I thought: It's going to be a pain organizing that many pictures!

So I DECIDED to create a bat file to do the job for me!

It worked So Well, I decided to share it with the rest of you! =D

I know it's such a simple BAT file, and half of you could probably make a better version within 5 minutes or reading this post, but I still wanted to share it anyway =Þ. Props to Sidewinder for his %date% variable code for the folder creation.

Code: [Select]@ECHO OFF
for /f "tokens=2-4 delims=/ " %%i in ("%date%") do (
set mm=%%i
set dd=%%j
set yy=%%k
)
set today=%yy%_%mm%_%dd%

md "C:\DOCUMENTS and Settings\Neo\My Documents\My
Pictures\XMAS Camera\%today%\"

MOVE "DCIM\100CAMEA\*.*" "C:\Documents and Settings\Neo\My
Documents\My Pictures\XMAS Camera\%today%\

Happy New Year Everyone! =DNicely done. Good work. That's pretty cool.
However, remember that the folder name will change between cameras, as different manufacturers USE different names for photos and different folder names/structures.
W00t, this is my first post in the DOS section!
Lol.Hey, could someone help me out with my batch file?

I just found out that by moving All the pictures from the camera, it resets the IMAGXXXX number. Is there a way that I could, after moving the file to My Pictures, re-copy Only the Last file back?

There are two types of files. VIDEO and Picture.

They both have the same naming SYSTEM. IMAGXXXX, where XXXX is the number of that file. I.E. IMAG0001.JPG is the first file made, and IMAG0012.JPG is a file made later. The Video and Picture files have the different endings of ASF, and JPG.

Anything that I can do?

6263.

Solve : Perform find and count in test file.?

Answer»

Hi,

I am quite new to the Dos yet, would need a solution on the below.
OS MS XP Professional
Writing on DOS in batch .BAT file

Would need to perform a count and list inside a text file:

Inside Data.txt file:

C:\Test\T1\C1\File1.txt
C:\Test\T1\C2\File1.txt
C:\Test\T1\C2\File2.txt

C:\Test\T2\C2\File1.txt
C:\Test\T2\C2\File1.txt

C:\Test\T3\C1\File1.txt
C:\Test\T4\C1\File1.txt
C:\Test\T5\C1\File1.txt

Wish to have the below output screen:

Output to screen:
Folder T1\C1\ 1 File(s)
Folder T1\C2\ 2 File(s)
Folder T2\C2\ 2 File(s)
Folder T3\C1\ 1 File(s)
Folder T4\C1\ 1 File(s)
Folder T5\C1\ 1 File(s)

I manage to create the Data.txt file using a for loop to list all files in folder and sub folder.
But i need to generate a statistics summary for each folder.

Hope all the Gurus can help.
Appreciate your help in advance.

Simon
Finally have manage what i want.
Maybe you have a better solution.

REM Compile the folder STATISTICS.
CLS
Echo Folder Statistics:
Echo.
SET /A Count1=0
For /F "Delims=" %%i IN ('Dir /B /AD "%CD%\%CF%\"') DO (
For /F "Delims=" %%j IN ('Dir /B /AD "%CD%\%CF%\%%i"') DO (
If !Count1! GTR 0 Echo Folder [!p!] Contains !Count1! Files.
Set /A Total=Total+Count1
Set /A Count1=0
For /F "Delims=" %%y IN ('Dir /B /A-H "%CD%\%CF%\%%i\%%j\" ".bmp"') DO (
Set /A Count1=Count1+1
Set p=%%i\%%j
)
)
)
Echo Folder [%p%] Contains %Count1% files.
Set /A Total=%Total%+%Count1%"Maybe you have a better solution. "

Why mess with something that works?

Couple of questions though, where did %CF% get it's value from? and is not the p variable being used before it's value is set?

Just asking. Yup, i think i miss to set the p variables.

For the CF is actually a variable for folder selection in the earlier stage,
apologies for not showing... coz dun wanna mess up the question with plenty of unnecessary codes...


@echo off
Title File Lister
Setlocal Enabledelayedexpansion


REM Generate FILE NAME
:START
CLS
Set /P Name=Enter a file title :

Set HR=%time:~0,2%
if %HR% LSS 10 set hour=0%hour:~-1%
CLS
Echo Generating file list...
Set Filename=%Name% %date:~-4%%date:~-10,2%%date:~-7,2%.csv


REM Search for EXISTING FILES List
If Exist "%Filename%" (
Goto SLT
) ELSE (
Goto GEN
)
Goto END


REM CHOICE and Selection
: SLT
Echo The file is currently exist in directory,
Echo [1] To replace the file entirely with new data.
Echo [2] To continue writing new data under same file.
Echo [3] To choose a new file title.
Set /P Choice=Enter a choice : )
If "%Choice%" EQU "3" Goto START
If "%Choice%" EQU "2" Goto GEN
If "%Choice%" EQU "1" Echo. > "%Filename%"
Goto GEN


REM Prompt User to CHOOSE a FOLDER to output list:
:GEN
CLS
Echo Type a main folder below to list output:
Echo Enter 0 if default folder [DefaultFolder] is used.
Echo.
For /F "Delims=" %%i IN ('Dir /B /AD "%CD%\"') DO (
Echo %%i
)
Echo.

Set /P CF=Folder Name :
If "%CF%"=="0" Set CF=Atlanta Defects
Echo Folder named [%CF%] is choosen.


REM Begin to LIST ALL FILES from current and sub directories.

For /F "Delims=" %%i IN ('Dir /B /AD "%CD%\%CF%\"') DO (
For /F "Delims=" %%j IN ('Dir /B /AD "%CD%\%CF%\%%i"') DO (
Echo.

Echo [%%i] Folder Contains:
For /F "Delims=" %%y IN ('Dir /B /A-H "%CD%\%CF%\%%i\%%j\" ".bmp"') DO (
Echo %%i\%%j\%%y
Echo %%i\%%j\%%y >> "%Filename%"

)
)
)


REM Compile the folder STATISTICS.
CLS
Echo Folder Statistics:
Echo.
Set /A Count1=0
For /F "Delims=" %%i IN ('Dir /B /AD "%CD%\%CF%\"') DO (
For /F "Delims=" %%j IN ('Dir /B /AD "%CD%\%CF%\%%i"') DO (
If !Count1! GTR 0 Echo Folder [!p!] Contains !Count1! Files.
Set /A Total=Total+Count1
Set /A Count1=0
For /F "Delims=" %%y IN ('Dir /B /A-H "%CD%\%CF%\%%i\%%j\" ".bmp"') DO (
Set /A Count1=Count1+1
Set p=%%i\%%j
)
)
)
Echo Folder [%p%] Contains %Count1% files.
Set /A Total=%Total%+%Count1%
Echo.
Echo Total All Listed Files %Total%

Echo Document listed on %Date% %Time%
Echo Document listed on %Date% %Time% >> "%Filename%"
Echo Refer to %CD%\%Filename% for generated file list.
Echo.>>"%Filename%"
Echo.

Pause

6264.

Solve : ms-dos command?

Answer»

I don't know how to end one of these dos commands. Can you help me?
It remains listening to COM1 port until it receives CTRL+Z or F6 code from
the device connected to COM1 port.

COPY COM1 C:\FILE.TXT
COPY COM1 CON

As my modem connected to COM1 don't SENT CTRL+Z or F6 codes, my batch stops
at this line.

In other words:
I have an EXAMPLE batch file, when i run it, it stops at the line before "ECHO OK" line so it does not show OK on the screen. It stops at "COPY COM1 C:\FILE.TXT" and remains on listening from COM1 port, indefinitely. File.txt is created with the data needed, all ok but the fact not going on to the next line.
The actual batch is:

@ECHO OFF
ECHO ATDT0742586486>COM1
PING LOCALHOST>NUL
COPY COM1 C:\FILE.TXT
ECHO OK
PAUSE
END

How can i pass to the next line "ECHO OK"?
----------
Another different question would be:
can i copy data from COM1 port directly into a system variable?I'm not 100% sure of what you need, but try this for the first. It sets up a nice infinite loop:

Code: [Select]@ECHO OFF
ECHO ATDT0742586486>COM1
PING LOCALHOST>NUL
:Loop
COPY COM1 C:\FILE.TXT
GOTO Loop
ECHO OK
PAUSE
END I tried it and it did not work even 1 loop. It stops at "COPY COM1 C:\FILE.TXT" and directs all data from the port to file.txt on and on. You can easily realise if you run:
@ECHO OFF
COPY COM1 C:\FILE.TXT
ECHO OK
PAUSE
END
and see that no OK appears on the screen.It would help if you could tell what you want to do. The command "COPY COM1 TO FILE.TXTWhen the modem detects busy tone, it sends a string to COM1 that i receive in file.txt right to that moment. This string i need to associate a system variable instead of a file, eventually.Seems to me you are missing a control program that will talk to the modem. Sending a transmission string (ECHO ATDT0742586486>COM1 ) with batch language will not work.

If memory serves, ATDT is a DIAL command, but this would need to be translated into sense bytes the modem can understand.

After you receive the data you can use something LIKE find or findstr within a for loop to set your variable.

8-)After you receive the data you can use something like find or findstr within a for loop to set your variable.
>>>Thanks but it didn't work that way, any other idea?

6265.

Solve : Plzzzzzzzz Help Me?

Answer»

Hi Every one

I'm doing a research report about the PC Operating systems and of course including MC Dos so I NEED some information about it ;
I want to know if it is single user or multi user , Also if it is single tasking or multi tasking and I want also some information about the CPU, Memory,HD space.


So I'm waiting for your help plzzzzzz


See U[size=14][/size]Do you mean MS DOS, rather than MC Dos?
Try using Google.
Or try here.
Next time make an attempt at least before looking for the easy button.Quote

Do you mean MS DOS, rather than MC Dos?
Try using Google.
Or try here.
Next time make an attempt at least before looking for the easy button.

You should know that OS even though your young Calum.

It came out before McWindows.

At least I McThink it did. [smiley=thumbsup.gif]

Lewis Carroll should have coined Mc this and Mc that.Chortle,Chortle,Chortle!
Quote
Do you mean MS DOS, rather than MC Dos?
Try using Google.
Or try here.
Next time make an attempt at least before looking for the easy button.


Yes I mean MS DOS and I did a typing mistake;
I did look in google and in the wikipedia before I jumped to the easy button as you said


So no one will help me?Sorry,Laughter is good for the soul.I never mean to ridicule a
member.

Please read the below site.

http://en.wikipedia.org/wiki/Multiuser_DOS


Below is a noteworthy site.
http://www.old-computers.com/museum/computer.asp?st=1&c=1197

After you read and study these two sites come back and ASK some
McQuestions.just joking. Quote
I did look in google and in the wikipedia before I jumped to the easy button as you said


So no one will help me?

Sure.
But you forgot to give us the EXACT url that you visited, and you forgot to direct us to exactly what part of the page there, that you read an didn't understand.
Do that, and I'm sure somebody here will try to go over it with you.


*Agrees with all of the above*
What are you trying to find out?
It says in the Wikipedia article about multitasking in DOS.
And what do you mean by
Quote
I want also some information about the CPU, Memory,HD space.
What CPU, memory and HD space?
Those required for DOS?
Or just CPUs etc in general?
BTW, Street1 - yet more chortles . . . McWindows . . . I was thinking more MC DOS, like MC Hammer . . . rapping computers . . . LOL!Quote
After you read and study these two sites come back and ask some McQuestions.just joking.

Sorry to be COMPLETELY offtopic here but omg thats hilarious lol. That word is probably going to be used alot more around these forums haha
Quote
Quote
After you read and study these two sites come back and ask some McQuestions.just joking.

Sorry to be COMPLETELY offtopic here but omg thats hilarious lol. That word is probably going to be used alot more around these forums haha

Do you really McThink so?Now y'all got me McChortling again.
Quote
So no one will help me?

I think the point the others are trying to make is that no one wants to, or should be expected to do your homework. That is part of how you learn. The other part is being able to explain what you have learned. So do your research, let us know what you have learned and what you are not CLEAR on.

Another good site is www.howstuffworks.com
6266.

Solve : Anyone know how to change str to no.?

Answer»

OS: XP Professional
Prog: MS DOS Batch

Would NEED to convert a strings cropped from a file name to become a number,

Example:

Set A=0022.txt
Set /A Num=%A:~0,4%
Echo %Num%

Screen Output: 18

Will not work as it will display 18 instead of 22.

I have TRIED the below lousy method to convert it:

Set /A End4=%Num:~3,1%
Echo %End4%
Set /A End3=%Num:~2,1%
Echo %End3%
Set /A End2=%Num:~1,1%
Echo %End2%
Set /A End1=%Num:~0,1%
Echo %End1%

Set /A End4=End4*1
Set /A End3=End3*10
Set /A End2=End2*100
Set /A End1=End1*1000

Set /A Num=End4+End3+End2+End1
Set /A Num=Num+1

Echo %Num%

If %Num% LSS 10 (
Echo Yes 10
Set Num=000%Num:~-1%
Echo %Num%
Pause

And the output will still 3 instead of 03 which i need to use it to rename a file.

Any help?

You only need the /a switch when doing arithmetic:

Code: [SELECT]Set A=0022.txt
Set Num=%A:~0,4%
Echo %Num%

Good luck. 8-)Hi...Thanks for your reminder.

I have tried the below, but how can i increase the counter by 1?
The below method will not work as it give a wrong arithmetic RESULTS:
18 instead of 23... Hope you can suggest a way for it...

@Echo Off

Set A=0022.txt
Set Num=%A:~0,4%
Echo %Num%

Set /A Num=%Num%+1
Echo %Num%

PauseThe leading zeros are tricking the interpreter into using octal notation. (octal 22 = decimal 18) This snippet will solve your immediate problem. For a more generic solution you need to develop a loop to strip off any high order zeros.

Code: [Select]@echo off
Set A=0022.txt
Set Num=%A:~0,4%
set num=%num:0=%
Echo %num%
Set /A Num="Num+1"
Echo %Num%
Pause

Good luck. 8-)Hi, thanks a lot for your solutions.
Else i will be searching like mad for the reason.

If you do have any web link good for these details information do let me know ok?
I have been searching through quite abit but those are either i don't quite understand or not for MS XP dos.
Honest to say i pick up most of it through browsing through this forum for peoples question and answer.
I will post more code in future for people to CRITICIZE and learn as well. Will be making more good stuffs...

Thanks.

6267.

Solve : Help with Variables and DIR?

Answer»

Currently I am PLAYING around with some bat files, but when I wanted to create one that starts a program from anywhere on the COMPUTER, I had some difficulty. It was supposed to take user input for a filename and extension, put it in %input%, use dir /s /a /b %input% and the directory found should have gone in a variable CALLED %location%, which the bat file would then switch to, and opening the file.

It doesn’t work as I have no idea on how to get the output (searched results of %input%) into %location%. COULD you please help me fix this issue, or is there a easier method. (This bat file is for Microsoft XP).

Ps. Is there also a way to deal with multiple results?

Code of Scan.bat:
cd ..
cd ..
cd ..
rem Just to be sure...
cd /d C:
set /p input=Filename:
rem Not sure if this is the right method
dir /s /a /b %input%>scan.txt
set location cd %location%
rem Changes to directory
%input%
rem Opens file
echo Finished!
pausefor %%a in (%input%) do set location=%%a

sets %input% in the var location.

hope it helps
uliWhen developing batch code, it is always helpful to try the commands at a command prompt so you can see the results that are produced:

Code: [Select]:: guarantee the root directory
cd /d C:\
set /p input=Filename:
rem Not sure if this is the right method
dir /s /a /b %input%>scan.txt
[highlight]set /p location=<scan.txt[/highlight]
%location%
rem Opens file
echo Finished!
pause

Your dir command will produce the full path and file name, not just a directory name.

Note: This method may be problematical should the dir command produce multiple results.

Hope this helps. 8-)Thanks for the feedback, much appreciated. One more question though. Is it POSSIBLE to count the number of words/symbols in the %input%? Because then you could have cd %location:~0,-n%. I'm not even sure if this can be done. Is it possible? Thanks anyway.

6268.

Solve : Need help on MKDIR command?

Answer»

I all. First of all, thanks in advance for any answers i might have.

I need to create a directory called %SYSVOL from a batch file

Does anyone knows how?

Ps: I've tried MKDIR "C:\ANY\%SYSVOL" but din't work.

Once again, thanks.Ok. problem solved.

Just ADD another % in the name.

MKDIR "%%SYSVOL"

Thanks.Glad we COULD help...

6269.

Solve : How can you hide a .bat file?

Answer»

I created a easy start up bat file for a EMU, But i DONT want to see it, I would like for it to be hid,

Can i do this?

Where its in my TASKBAR, or just in my prossece?Did you FIRST try the EMU site?
http://www.emu.com/

6270.

Solve : Wanting to know if I can solve this through DOS?

Answer»

My system will not BOOT up even with the recovery CD because somehow the C drive has been erased. Is there anyway to ressurect it with DOS commands?? All that can be ACCESSED is A:\:> or X:\> - I don't care about losing data, I just want to be able to reformat the C Drive. Let know if there is any hope....
Somehow the C drive got erased?

If that is so, then you need to insert your legal Windows CD and restart the machine and reinstall it. What version of Windows was this? How do think it got erased? How are you getting to an A:> ? What FLOPPY or CD is in the drive?Don't want to go into how it happened here. Suffice it to say that I've tried what you suggest with a work copy of XP just to see if that would reformat it, then I would go back to the Recovery CD's that came with my computer and reformat from there (the legal way). Even trying it this way it only GOES up to a point , but when it tries to load windows the error message comes up that the hard drives are missing. Do I have to get a new hard drive to solve this? There were no windows disk that came with the computer (it is a Sony Vaio) that had Windows ME (I know, I know I know)... Just need some practical advice on whether I should just give up and buy a new hard drive, new computer, etc....Check the physical connections on that HDD and or put it in another machine to see if it is recognised...
It SOUNDS like it was only partially formatted and therefore Windows can't see it...

Another option would be to travel to bootdisk.com and grab a WinME bootdisk and use the file on a working machine to creat a bootdisk.
Then boot your machine with the newly created bootdisk and at the A: prompt type fdisk and hit enter.

If this doesn't show the drive it has probably died an early death. If it does pick it up use fdisk to partition that drive as active and when it's finished at the A: prompt type "format C: /u" without the quotes and hit Enter...this will prepare the HDD for a clean install.Thank you so much!!

6271.

Solve : Running executables with arguments?

Answer»

Hi there,

I am trying to create a batch file that reads all FILES from a specific folder (ie. input) and processing these files and outputing the results in the output folder.

for example this is my file structure

process
input
output
transform

so BASICALLY, my batch file and my executable resides in the process folder. all my files that NEEDS to be processed are kept in process\input and the files that have been processed by the executable are stored in process\output. the process is kept in process\transform.

the executable file that takes in 3 argument, 1st argument is the output filename, 2nd arg is the process file, 3rd arg is input file. my batch file looks like this

for %%x in (.\input\*.xml) do (
echo processing %xx
transform.exe -o .\output\trans%xx %xx .\xslt\this.xsl
)

for some REASON, i am getting a runtime error and the reason for that is the output to dos from my 3rd line goes like this
transform -o .\output\transxx .\xslt\this.xsl

it doesnt seem to recognize the 2nd argument and it is missing in the output.

could someone kindly point out where i am goin wrong here?

cheersSorry folks,

I did realise my mistake, i should have used %%x instead of %xx. its a typo error on my part and a waste 2hours of my time trying to figure out what is wrong.

anyway, i still have a problem. the value returned in the set (.\input\*.xml) is including the path as well. How can i tweak it so that it only returns the filename when I access %%x?

Assuming my filename in the input folder is input.xml and my process is process.xslt, the batch file returns

transform -o .\output\.\input\input.xml .\input\input.xml .\xslt\process.xsl

as you can see the path for the output file is wrong, hence i just need the filename instead of the WHOLE value in the set.

thanksIt's always helpful to mention your OS in this section as each version of the shell program is different. This may work on some machines:

Code: [Select]for /f %%x in ('dir /b .\input\*.xml') do (
echo processing %%x
transform.exe -o .\output\trans%%x %%x .\xslt\this.xsl
)

8-)

Thanks a lot mate. that worked.

6272.

Solve : exiting from ms dos?

Answer»

I have a Gatway2000 and operating win xp. How do i GET out of ms DOS. When I start pc with nothing in drives BLACK screen only. I put recovery disk in takes me to ms dos but i don't know what to do from here. Any HELP would be GREAT. thank you. Lakerat

6273.

Solve : "shutdown" command help?

Answer»

When trying to shutdown other computers on my network using shutdown -s -m\\computername the reply reads..

The operation completed successfully.
A required privilege is not held by the client.

I would really like to be able to do this..any help greatly appreciated.

edit:Yes its at home and i have ADMINISTRATOR rights,running windows XP on both.Could it be that one of the windows versions arent genuine? By the way im a complete newb so i dont know how to change the command parameters and all that other stuff geek9 is talking about.
Which OS?
Is it your Network at home?
Which privilegs do you have? (On the CLIENTS)

uliThis GOT my curiosity. So I looked around on the Microsoft site. Here is my first impression.

This is a new command in Windows XP. The command is WORKING fine. It is not a 'backdoor' command where you can force another computer to do something that it should not do. It required the network administrator to set up some others things to allow proper and secure shutdown of each remote computer. The remote computer will shutdown only if the command parameters satisfy the rules on the remote computer. For more information on this you will have to really dig into the Microsoft WEB site. The trick is that the remote computer was already on a task schedule to shutdown anywayQuote

The trick is that the remote computer was already on a task schedule to shutdown anyway
This isn't needed, it works perfectly well without.

The shutdown command for remote shutdown (-m) works without the // of the computer name. I'm sure you know all the computer names, but if not, use:
Code: [Select]net view >C:\comps.txtThis gives you a list of computers that you can use the command on. All computers must be part of the workgroup, or they won't shut down. The (-m) command only supports shutdown (-s) and restart (-r), not logout (-l). An example of this command in action would be
Code: [Select]shutdown -m COMP1 -s -f -t "0" Hope this helps. Thanks Jarjee. I was dead wrong. I plead ignorance, but that is not excuse for not doing my homework!
I found an item on the MS site that helps with a problem I also have with the remote shutdown command. And I found that the command has been around for years.

http://technet2.microsoft.com/WindowsServer/en/library/58ede3d5-c4cc-4532-bf75-997c165961ec1033.mspx

6274.

Solve : Tasklist?

Answer»

Hello all,
I REALISE that [highlight]tasklist [/highlight]can't get RESULTS of a [highlight]windowtitle[/highlight] on a remote system.
How can this be ALTERNATIVELY be done or acquired?
CHEERS,
CAMERON

6275.

Solve : DOS native drivers for IDE ZIP (100) drive?

Answer»

Trying to repair my old pc which won't load it's win98. I have made up a boot CD with DRDos 7 which sees my 2 disks and 2 CD drives. But I need the DOS native drivers for the ZIP drive. Where to get them and what commands to place in Autoexec.bat and Config.sys to access the ZIP drive?

Also how can I place WAIT commands in auto&config so I can SEE what is happening on boot up both in BIOS start and boot CD start? It sends text to the screen so fast that I can't read them.

ThanksQuote

Trying to repair my old pc which won't load it's win98. I have made up a boot CD with DRDos 7 which sees my 2 disks and 2 CD drives. But I need the DOS native drivers for the ZIP drive. Where to get them ...

Thanks

Check out:
http://www.storagedrivers.com/drivers/31/31083.htm

http://www.storagedrivers.com/drivers/71/71025.htm

http://pw2.netcom.com/~deepone/zipjaz/dos.html

http://www.computing.net/dos/wwwboard/forum/14438.html

Quote

Also how can I place WAIT commands in auto&config so I can see what is happening on boot up both in BIOS start and boot CD start? It sends text to the screen so fast that I can't read them.

Thanks

There are a couple little 'wait' programs out there, that if placed in autoexec.bat would allow you to configure a pause of x seconds.
But I'm not sure that is exactly the best way to GO for what you WANT.


As far as slowing things down so you can see it:

For the bios stuff, try hitting the pause key when whatever you want to review is on the screen.
Does that stop the process, until you hit ESC?


For config.sys and autoexec.bat, try tapping the F8 key repeatedly as soon as the boot process starts to read from the drive. It should put you in a multiple choice menu. One of the choices is line-by-line confirmation.
Another is to create a boot log - that might be handy to review later.
Would either of these accomplish what you need?

I hope this helps.


Thanks all for excellent responses. One problem remains. When I evoke "guest.exe" or "guest.exe = H:" in the autoexec.bat file or from the command line it says it can't assign a drive letter. I do have "lastdrive=Z" in autoexec.bat.

What is missing?
I forgot to ask how to create a boot log.

Thanks
Quote
Thanks all for excellent responses. One problem remains. When I evoke "guest.exe" or "guest.exe = H:" in the autoexec.bat file or from the command line it says it can't assign a drive letter. I do have "lastdrive=Z" in autoexec.bat.

What is missing?


I've got a Zip drive .... somewhere.... that's the problem, I haven't USED it in ages.
I remember using guest with it too.
But as for the particulars, it has been too long. I'm sorry, I just don't remember the finer points about configuring and using it.
You might have to wait for somebody else to come along here and advise you.

Or, have you tried various word combinations in Google? You can't be the only one that ever had that happen.


Quote
I forgot to ask how to create a boot log.

Thanks


??
Did you try the F8 key? (see above post)
What happened when you did?
Did you get a menu to choose from?


Btw, did the Pause key help for stopping the boot process so you could see what was going on with what bios was seeing?



Thanks guys, I tried the PAUSE key and it worked fine. Didn't try the F8 key yet.
Quote
Thanks guys, I tried the PAUSE key and it worked fine. Didn't try the F8 key yet.

Aha.

The F8 key is what should get you a menu. As stated PREVIOUSLY, one of the choices will allow you to step through and confirm or deny the loading of each line.

Another choice would be to create a new bootlog. I haven't tried this in ages - so you'd have to try it and then look for it. Examine it. See if it holds anything useful to you.

Let us all know if it what it held was what you needed. It might help somebody else here someday.

6276.

Solve : OR Command (or similar)?

Answer»

Hello hopers,

I'm trying to set up a batch file for LOGIN script on SBS 2003.
What I really want to do is set it up so that the script will put a standard set of shortcuts onto users desktops if they dont already have them.
The problem I have is that different users have several different names for their Outlook shortcut, therefore my
IF NOT EXIST "%userprofile%\desktop\Microsoft Office Outlook.lnk". (copy "[location of LINK]" "%userprofile%\desktop".) code DOESNT guarantee against users getting multiple outlook shortcuts on their desktop.

Is there an OR command I can USE so that the .bat looks for several different shortcut names before creating a new one, or is there an alternative way to code the .bat for shorcuts (perhaps by target rather than file name).

Cheers guys

Ben (noob)You can piggyback commands in batch code so only one of a series of statements get executed.

Code: [Select]if condition1 do something1 & goto skip
if condition2 do something2 & goto skip
if condition3 do something3 & goto skip
:skip

I'll LEAVE it to you to decide who gets what Outlook shortcut. 8-)I couldnt get your method to work, but I modified it a bit using the GOTO SKIP command to create:

IF EXIST "%userprofile%\desktop\Microsoft Office Outlook.lnk" GOTO SKIP
IF EXIST "%userprofile%\desktop\EMAIL.lnk" GOTO SKIP
etc...
etc...

copy "[shortcut location]" "%userprofile%\desktop"

:SKIP

et voila, it works

Cheers for pointing me in the right direction

6277.

Solve : ftp timeout?

Answer»

I send every day 2000 different pdf files to a ftp server with dos.

But i always get a timeout and then i have to START again from zero untill i don't get a timeout.

Can SOMEONE help me?

Just a suggestion, but you could write a loop and send one file at a time. If you really got sophisticated you even create a log as to whether each file was successful or not.

Even zipping the 2000 pdf files and sending one massive zipped file might work (don't forget to unzip at the other end)

Just some IDEAS. 8-)That is very good information, but it depends on how fast his internet connection is and how big the allowed file size is. That WOULD DETERMINE whether or not your connection will time out with the ftp server.

6278.

Solve : get file based on most current date?

Answer»

I’m working on something using an FTP command. I’m trying to FTP a file from /SYSRES/SHOPPERS to a network directory….but, I only want the current file. The file has a date/time stamp, but I only care about the date. The most current file is named SHOP010907112030. How can I add to check for the date to my batch script? Tomorrow's file would be SHOP011007HHMMSS. Let me know if you can help….thanks much.

Quote

I’m working on something using an FTP command. I’m trying to FTP a file from /SYSRES/SHOPPERS to a network directory….but, I only want the current file. The file has a date/time stamp, but I only care about the date. The most current file is named SHOP010907112030. How can I add to check for the date to my batch script? Tomorrow's file would be SHOP011007HHMMSS. Let me know if you can help….thanks much.


I have an idea as to how you could get tomorrow's date into an environment variable. Would that help? ... could you work with it then?

The time of day part - don't know how to HANDLE that. Sorry.

.
I don't want to set an environment variable because both of these files are on DIFFERENT servers. I just want to disregard the time part and I want this to be variable so when it runs, it will always get todays file. thanks much.Quote
I don't want to set an environment variable because both of these files are on different servers.

Can you explain that a bit?
Why is the files being on different servers important?

Quote
I just want to disregard the time part and I want this to be variable so when it runs, it will always get todays file. thanks much.

Set today's date in an environment variable then - if you can use it that way.



It's always HELPFUL if you mention what version of DOS or Windows you're running as batch language changes often.

One way would be to sort the files descending by date and skim off the top one. See Previous Post

The other would be to localize the environment variable to the batch file:

Code: [Select]setlocal
set today=%date:~4,2%%date:~7,2%%date:~12,2%
echo %today%
endlocal

The above snippet is just an example but you can incorporate the setlocal/endlocal in your own batch file.

Good luck. 8-)

Disclaimer: This will only work on some machines, maybe even yours!Ok...I'm new to this, so bare with me!

I'm running windows XP.

I still don't understand why/how to set the environment variable to help me.

In the example pasted above for sorting and skimming 1 off the top, I tried that and it didn't work...perhaps I missed something? Could you repeat that slowly for the newbie Thanks!Quote
In the example pasted above for sorting and skimming 1 off the top, I tried that and it didn't work

Not knowing how or what you ran, it's hard to tell what went wrong.

The example below will sort all the files beginning with SHOP descending by date. The most recent file will sort first where you can use it in the context of your FTP COMMANDS. (the %%i variable contains the file name)

Code: [Select]@echo off
for /f %%i in ('dir SHOP*.* /tc /o:d /a-d /b') do (
ftp commands go here
goto tag
)
:tag

The next example is much the same, but uses a local variable containing today's date: (the filename is still in %%i)

Code: [Select]@echo off
setlocal
set today=%date:~4,2%%date:~7,2%%date:~12,2%
for /f %%i in ('dir SHOP%today%*.* /tc /o:d /a-d /b') do (
ftp commands go here
goto tag
)
:tag
endlocal

You still have to put the appropriate FTP commands where INDICATED. You may also have to include path information based on your environment. 8-)
6279.

Solve : New to DOS Help!?

Answer»

I have some very basic questions i HOPE you can help!

I have this line of code:-

for /F %%k in ('dir /b*.cgm') do set FILENAME=%%nk.cgm

what are, and where can i find a description of:-
1. /F
2. /b
3. k
4. nk

Cheers For the help


Danfor /F %%k in ('dir /b*.cgm') do set FILENAME=%%~nk.cgm

what are, and where can i find a description of:-
1. /F : process each line in the FILE (or command OUTPUT)
2. /b : only output filename in dir command
3. k : a loop variable
4. ~n : note the squiggle, means get just the name part of the filename held in variable k

Does this help?
Graham
Or at a command line type: for /?
Or LOOK here for the same: http://www.dostips.com/DosCommandRef.htm#FOR



6280.

Solve : Please help with this bat file....?

Answer»

I am trying to right a batch file to REPLACE a custome game map. I would like to have the bat request 1 of 2 choices...the original file or the modded file. If I run this script:

copy c:\program_files\microsoft_games\halo\mods\deathisland_238_mod.map program_files\microsoft_games\halo\maps\deathisland.map

It works fine. BUt when I place it in the FOLLOWING bat file it does not:

@echo off
CLS
:LOOP
ECHO 1. Original Death Island Map
ECHO 2. 238 Modded Death Island Map
ECHO E. Exit
SET Choice=
SET /P Choice=Type the letter and press Enter:
IF '%Choice%'=='1' GOTO 1
IF '%Choice%'=='2' GOTO 2
IF /I '%Choice%'=='E' GOTO End
ECHO "%Choice%" is not valid. Please try again.
GOTO Loop
:1
copy c:\program_files\microsoft_games\halo\mods\deathisland_238_mod.map program_files\microsoft_games\halo\maps\deathisland.map
GOTO Again
:2
GOTO Again
:Again
PAUSE
CLS
GOTO Loop
:End
exit



Can anyone help figure out how to make this work?
Put quotes before and after the path of the files.

Al968HEY I THINK YOU DIDNT WRITE SUMAT GOOD,I MEAN MOD PLACE,..
Quote

HEY I THINK YOU DIDNT WRITE SUMAT GOOD,I MEAN MOD PLACE,..

WoW is that even English. :-?Quote
I am trying to right a batch file to replace a custome game map. I would like to have the bat request 1 of 2 choices...the original file or the modded file. If I run this script:

copy c:\program_files\microsoft_games\halo\mods\deathisland_238_mod.map program_files\microsoft_games\halo\maps\deathisland.map

It works fine. BUt when I place it in the following bat file it does not:

- - -

Can anyone help figure out how to make this work?


Is your os WinXP?

Does that computer have choice.com on it? in the path?
(because I'd do it a bit different, and it requires choice.com in the path)


You said, "BUt when I place it in the following bat file it does not: "
Describe exactly what happens.

selkov,

I think your problem is that the copy destination is relative path. You might want to make it ABSOLUTE like the source:

[edit]copy c:\program_files\microsoft_games\halo\mods\deathisland_238_mod.map [highlight]c:\[/highlight]program_files\microsoft_games\halo\maps\deathisland.map[/edit]

DOS IT HELP? Quote
HEY I THINK YOU DIDNT WRITE SUMAT GOOD,I MEAN MOD PLACE,..

Welcome back, wangming...
6281.

Solve : Create Driver?

Answer»

Hello,

I would like to know hows to create a driver, all that this driver would do is launch an executable and male sure that its process is not terminated. This is kind of a protection for a security program.

Thanks

Al968I don't think a driver is the issue. You may want to google about for info on batch files, etc.Thank you for the responce,

could you explain what you mean because I don't see the relation with batch files??

Thanks

Al968
How about I just move this to the DOS forum as this has nothing to do with drivers?Your question is a bit ambiguous, but I'm guessing you need a script to monitor the execution status of a program and restart it if necessary.

A VBScript can help:

Code: [Select]strComputer = "."
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "[highlight]c:\windows\system32\notepad.exe[/highlight]"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objEventSource = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN 2 WHERE TargetInstance ISA 'Win32_Process'")

Do While True
Set objEventObject = objEventSource.NextEvent()
If objEventObject.TargetInstance.Name = "[highlight]notepad.exe[/highlight]" Then
Select Case objEventObject.Path_.Class
Case "__InstanceDeletionEvent"
WshShell.Run "[highlight]c:\windows\system32\notepad.exe[/highlight]"
End Select
End If
Loop

The example uses notepad.exe, but you can use any executable. Save script with a vbs extension and run from the command prompt as wscript scriptname.vbs. Path information may be needed depending on your environment.

Good luck. 8-)

PS. A batch solution would need a loop, which would suck up CPU cycles. A VBScript can actually wait for events to happen. Are you sure that this works ??

I get an error message':

script: c:\script.vbs
line: 4
char: 1
error: 0x80041021
code: 8004121
source: (null)


I am running XP Home.

Thanks

Al968Works fine on my XP Home machine. The only variable in line 4 is strComputer, which is set in line 1 of the script. Scripts of this type are mostly boilerplate code....did you cut and paste the script in it's entirety?

:-?

BTW: setting strComputer to a dot is shorthand for the local computer. You might also want to adjust the WITHIN 2 clause. The 2 REPRESENTS seconds.Yes I did COPY the code exactly as you said :-?
I am sorry but I don't know VBScript. Can you clarify what I qhould do.

Thanks

Al968

Not knowing what you are doing makes it difficult to debug. Save the script (cut and paste into notepad is fine).

To run the script, type: wscript scriptname.vbs from a command prompt. If you are not logged on to the same directory as to where you saved the script you will need to provide a path pointer. (example: wscript drive:\path\scriptname.vbs)

If you still have problems, please post a screen print of the command prompt output so we can see exactly what's going on.Still getting the problem, I saved the vbs script in c:\document and settings\my username, I ATTACHED the sreen shot.

Thanks

Al968Well, I'm at a loss for words You're obviously logged into the correct directory otherwise the error would be different.

Just for kicks, post back your version of the script. This is getting very interesting. 8-)Its the EXACT same one:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "c:\windows\system32\notepad.exe"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objEventSource = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN 2 WHERE TargetInstance ISA 'Win32_Process'")

Do While True
Set objEventObject = objEventSource.NextEvent()
If objEventObject.TargetInstance.Name = "notepad.exe" Then
Select Case objEventObject.Path_.Class
Case "__InstanceDeletionEvent"
WshShell.Run "c:\windows\system32\notepad.exe"
End Select
End If
Loop


Thanks

Al968Quote

Its the exact same one:
*sigh*

Not quite. It seems line 1 of the original script has gone missing. See reply #4.

[highlight]strComputer = "."[/highlight] points to the local machine.

Good luck. 8-)
Sorry, well it WORS now but its using too much processor

Thanks Any Way

Al968
6282.

Solve : call a vbs script?

Answer»

Can I call a vbs script from my dos batch file? If so...how?

I am using windows XP. Thanks.Use CScript - see below

Usage: CScript scriptname.extension [OPTION...] [arguments...]

Options:
/B Batch mode: Suppresses script errors and prompts from displaying
/D ENABLE Active Debugging
/E:engine Use engine for executing script
/H:CScript CHANGES the default script host to CScript.exe
/H:WScript Changes the default script host to WScript.exe (default)
/I Interactive mode (default, opposite of //B)
/Job:xxxx Execute a WSF job
/Logo Display logo (default)
/Nologo Prevent logo display: No banner will be shown at execution time
/S Save CURRENT command line options for this user
/T:nn Time out in seconds: Maximum time a script is permitted to run
/X Execute script in debugger
/U Use Unicode for redirected I/O from the console
THANKS!

6283.

Solve : Why Wont This Work??

Answer»

[highlight]@echo off
echo %time%
pause
set /p tim=what time do you want to wake? :

:W
cls
echo %time%
echo %tim%:??,??
if "%time%"=="%tim%:??,??" goto x
goto W

:X
msg * times up!
pause
exit[/highlight]

i dont know what im done wrong? :S please help me :-/ :-/ :-/
im running on a windows xp professional not Ms Dos
but it shuld be 4:

/meNot sure what AM/PM has to do with this. The only way out of the :W loop is if the date (%date%) is equal to some random time entered by the user (%tim%). The hardcoded 4 (echo 4:%tim%:??,??) doesn't help matters.

With Windows XP you have MANY tools available to build an alarm CLOCK. Batch code is not the best tool for this. 8-):-/ so do you say it is 100% impossible to build an alarm clock in bat? please help Edit.Quote

arnt u missing the E im tim or is like that?

It is supposed to be like that as ogelami declared it "set /p tim=what time do you want to wake?:".Quote
so do you say it is 100% impossible to build an alarm clock in bat? please help

Not QUITE and probably EASIER than digging the Panama Canal with a spoon.

if "%time% GEQ %tim%:00:00.00 goto x

You will have to localize the time format for your area.

8-)
6284.

Solve : Not-Recognized Problem?

Answer»

Hello All,

I am running XP SP2. When I am running HELP COMMAND, here is what I get:

'help' is not RECOGNIZED as an internal or external command,
operable program or batch file.


Any idea about the problem?

Thank you very much.

Leo
There is not a command "HELP", what exactly are you trying to do?There is such a command, with no parameter, it LISTS all of the commands available with a few words describing what each does.
Otherwise, enter help commandname
where commandname is listed in the output from help with no parameters (equivalento to commandname /?)
Check and make SURE that c:\windows\system32 is in your path. (hint: RUN set path at a command prompt)

6285.

Solve : for /F command?

Answer»

If I use following command :
for /F %i in ('DIR \\server\jur00\ /S /B /a:d') do setacl "%i"

I receive the security of all the folders but if there is a folder with a space
(LIKE \\server\jur00\my documents) the command works any more because
for /f stop after a first space
setacl \\server\jur00\my

how can I skip a space with the for command ?

any solution ?
Not SURE if this will fix this or not, but you can try ADDING " " instead of ' ' to the command like
for /F %i in ("dir \\server\jur00\ /S /B /a:d") do setacl "%i"

In my batches when ever I know I will hit a space in a tree or file name, I always bind the command with " " and usually DONT have any problems.

Dave

6286.

Solve : echo list of path(s) of file(s).?

Answer»

I want to do a BATCH FILE 'pathof.bat' which ECHOS list of path(s) of file(s).
the file 'pathof.bat' consists of only one line which is:

FOR %%F IN (%1) DO echo "%%~ff"

the program echos the correct path for these examples:
pathof anyfile
or
pathof subfolder/anyotherfile
or
pathof *.doc

but this program fails to echo the right path when I do:
pathof subfolder/*
because the batch program echos paths which discards the 'subfolder'
what shell I do?
thanks
jokop

6287.

Solve : How do I create a popup message box using DOS??

Answer»

I am on a network and would LIKE to somehow use DOS to create a message box that will popup on users MONITORS so that I can COMMUNICATE with them regarding the database we are all using.

Is there any way to do that?sjbchapman

From command line run this in one line:
[edit]start cmd /c "mode 40,10&AMP;title My Popup&color 1E&echo.&echo. It's %date%&echo.&echo. Press a key!&pause>NUL"[/edit]

DOS IT HELP?
Thank You Heavenly ! DoSiTHelP !!!!!!!!You could also try...
Code: [Select]net send CoMpUtErNaMe helloEdit.

6288.

Solve : i hate the stupid sonic wall?

Answer»

[size=16][/size]please HELP me get past the stupid sonic wall.
i have a proxy server i just can't get into the proxy settings. all i really NEED to KNOW is what dos command will let me SET up a proxy server. if not just a way to get past the sonic wall WOULD be appreiciated. thanks.Try again and take your time.

6289.

Solve : Simple Question: How to delete a " ??

Answer»

Anyone can help in this?
NEED to Delete a " in a text file.
Its hard fpr me as i need to use "Tokens=* Delims=" in a for loop.
Or i should ask how to FIND a " and delete it as Find """ "File.txt" ?

simonchin79

Try this:
[edit]for /f "delims=" %%a in (File.txt) do (
set "ln=%%a"
call ECHO.%%ln:"=%%
)[/edit]
DOS IT HELP? Would like to THANKS you, quite busy recently.

Yes it WORKS, but how you find out this "ln=%%a" ?
I only found something like %%~i from For command.
Can share abit?

6290.

Solve : install from boot disk problem?

Answer»

hi newbie here i managed to load winme on pc but when it closes to restart
the logo appears then it freezes error message appears:an exceception oe has
occurred at 0028:c0013c19 in vxd vmm(01)+0005055c in vxd vpicd(01)+00001448.it may be possible to continue normally.
i press a key windows shuts down can SOMONE TELL me whats happening?Bad install or bad hardware are best bets. How did you "manage to install" it? Do we get a clue about the hardware? Is this a real Microsoft CD or what?Thanks for help:ok well its an ibm 300pl i had put away then had use for again it came with a windows cd-rom and win95 on the system no start up disk a recovery disk but it never worked has i found later i upgraded to winme using a copy a friend gave me to enable broadband cable the cable guy installed it at the time i knew nothing not that i know much now he wanted me to get the package ha, later i got a larger hard drive and learned how to install it. using a start up disk made from previous winme install loaded new drive which has i type this i recall that first clich a thin streak shot across the screen just before the system rebooted to had hardware but it did reboot later a virus crashed my system everything was deleted lost registry when tried to boot winme again couldn't so i loaded win95 and then loaded winme from run command in win95 can't remember but it worked then i got a dell and put my old pc away until now so i've tried to load with winme boot disk i downloaded from puter geeks and win95 boot also downloaded my original start disks long misplaced the winme which is COPIED onto cd when i run it displays bad fault in ms-dos extender. the win95 runs setup copies files then at finish when it reboots to add hardware logo appears then my hard drive sounds like a gigercounter close to radioactive material the error message appears {protection error restart}when i try windows shuts down this is the closet i've come.You should start by running the free diagnostics from the appropriate hard drive maker's site. If unsure, use SeaTools from the www.seagate.com You should be able to see the appropriate manufacturer on the drive itself. Those models frequently used Maxtors.

The second thing is to get a real copy of Windows so you are legal and it is complete.

You can get an appropriate boot disk from www.bootdisk.com A Win98SE OEM disk would be FINE from that site.

I am not convinced the hardware is intact at this point. I have a few 300PL's here and have loaded Windows on hundreds with no problem. There is something amiss.thank you , GX1_Man
for this internet site
www.bootdisk.com

Thank you, thank you, and thank you again for a direction i'll give a try. We'll keep the light on. ok gentleman sharing pc with younglings downloaded drive tool and since i had
brought the drive in question to this pc {dell optiplex110}} i decided to switch drives quick and to my surprise when i turned it on win95 booted up and displayed desktop so iassume it not the drive so excited i took drive the back to my ibm and tried it again win95 logo displayed then went into safe mode pushed enter message protection error restart did so new message invalid windows configuration. LEARNING things.

6291.

Solve : Modify DOS autoexec.bat file?

Answer»

:-?

I am trying to do some programming with Java. I need to modify the DOS autoexec.bat file in order to access the Java compiler. Can someone pls help me by guiding me through the steps for:
1. copying the autoexec.bat file and save it under a different extension eg .txt so that I can use it back if the modified file does not work, I can use the OLD file back.
2. open the autoexec.bat file to modify it and
3. how to save the modified file.Open Autoexec.bat using Notepad.

Click on File>Save As and in the File Name box type "autoexec.old" - you have now saved a copy of your EXISTING autoexec.bat.

Amend the autoexec.bat you opened in Notepad then click on File>Save As and in the File Name box type "autoexec.bat" - you have now saved your new autoexec.bat

Click YES to the message asking if you want to replace Autoexec.bat.

Close Notepad.

[highlight]Note[/highlight]: the double quotes " " are required around the autoexec filenames where they are shown above.

Also see Valerie's reply to your query on the Easy Dos forum.

Good luckNo need to do that...Right click My Computer, goto properties, click the advanced tab, click the environment variables BUTTON, look where it says "System Variables", scroll down to where you see "Path", and just add the path of where Java was installed. If you need help look here. I do programming in Java DAILY for the most part(depending on if I have time) as I am working on an RPG game for a school project. And a good IDE is Jcreator and you can download it here.

6292.

Solve : File date?

Answer»

How can I start a command if a file is older then 2 days or 48 hour? :-?
Code: [Select]for /F %%A in ("filename.zip") do If %%~tA le %DATE%-1 echo OlderUnless you are prepared to write a boatload of if STATEMENTS, doing date arithmetic in batch code is not a simple matter. First you'd have to isolate the day value and SUBTRACT one. You can imagine the fun if the day value resolves to the first of the month.

Try one of the scripting languages available for Windows.

8-)Is it possible to create an log of last time the baths file was RUN and compare the last time to the file time?

O my that was a long SENTENCE...Quote

Unless you are prepared to write a boatload of if statements, doing date arithmetic in batch code is not a simple matter.

This utility program does simple arithmetic and date arithmetic:
http://www.ferg.org/fdate/

It is free.

Quote
First you'd have to isolate the day value and subtract one. You can imagine the fun if the day value resolves to the first of the month.

Try one of the scripting languages available for Windows.





6293.

Solve : Batch (or .com) file to count on screen from 1 to?

Answer»

Years and years ago I wrote a (I think) batch file that would just START counting from one up to a million or so. Used it as smoke test for new computers I built and to just get ian dea of how fast computer was.

By time got up to 386s, they were too fast for the latter.

Anyhow, a friend's kid wants a program like this, and for the life of me I can't remember how I did it. Maybe it was in BASIC RATHER than a batch file, don't remember, but have forgotten all BASIC or GBASIC commands now that my brain RAM is down to 512K.

Can ANYBODY tell me how can write a simple program like this, and then run it from Win if possible, or if not, from DOS, so that it displays on the screen?

Many thanks.Here ya GO... 8-)

Code: [Select]FOR /L %%G IN (1,1,1000000) DO echo %%G
Just copy that and save as filename.bat and happy counting. Quote

Here ya go... 8-)

Code: [Select]FOR /L %%G IN (1,1,1000000) DO echo %%G
Just copy that and save as filename.bat and happy counting.

Many thanks, fffreak, that's even easier than the one I recall doing. Just what I needed.

I used to be a dosfreak, but that's outdated today.
Your welcome, Happy to help 8-)
6294.

Solve : Sonic Wall?

Answer»

I need to no how to get into the proxy settings threw dos. at school we have a sonic wall and i no i can get AROUND it threw the proxy servers. i have a proxy server i just need a dos command that will get me into the proxy settings. if you don't KNOW how, a WAY to get PAST the sonic wall would be apprectiated. thanks

6295.

Solve : Simple Batch Script not working.. Can anyone help??

Answer»

I have created a simple batch script that acts as a "hosts file switcher", but it doesn't seem to be working. The code is posted below.. Can anyone please tell me why this isn't working? This is very frustrating!

Thanks in ADVANCE!

Code: [Select]IF EXIST %windir%\system32\drivers\etc\hosts_restricted (
ren %windir%\system32\drivers\etc\hosts hosts_normal &
ren %windir%\system32\drivers\etc\hosts_restricted hosts
)
ELSE (
ren %windir%\system32\drivers\etc\hosts hosts_restricted &
ren %windir%\system32\drivers\etc\hosts_normal hosts
)

when you say doesn't work, what doesn't work? the files did not rename? or you encountered other errors?
I noticed there's a "&", what is it for? i don't think you need it.Hi ghostdog,

Thanks for your reply!

When I say "it doesn't work", I mean that when I execute the batch file, I get the command prompt window flash for 2 SECONDS, and it disappears. Afterward, when I check the relevant directory, none of the files have been RENAMED as they should have been.

I am trying to execute 2 commands if the if statement evaluates to "true". I thought the "&" was needed to say: execute this line & also execute this line after it.

Is this not the right syntax for it?

Thanks!

The & is not needed. By default the file will go through commands in order. If the two commands are in () then there really isn't a need for it. The & is used for MULTIPLE commands on the same line. You can try it on the command prompt if you want -- the one I use the most is the command "cls & dir". well, you can put a pause at the end of your batch, the see what the error message is.Probably the punctuation. I seem to recall that the else must be on the same logical line as the if. Also REMOVE the ampersands; they're used incorrectly in this context.

Code: [Select]IF EXIST %windir%\system32\drivers\etc\hosts_restricted (
ren %windir%\system32\drivers\etc\hosts hosts_normal
ren %windir%\system32\drivers\etc\hosts_restricted hosts
) ELSE (
ren %windir%\system32\drivers\etc\hosts hosts_restricted
ren %windir%\system32\drivers\etc\hosts_normal hosts
)

8-)

6296.

Solve : Shutdown a computer over LAN?

Answer»

Hello, I under if it's possible too shut down a computer by LAN?
I would be GLAD if someone could TELL me a code for itHere ya GO...

Code: [Select]shutdown -s -F -m \\computername -t xx(your TIME in seconds) -c "your comment"
that should work.

6297.

Solve : Mount network drive?

Answer»

Hello all,

I am TRYING to mount a network drive in DOS and am having trouble.

What I am trying to do is to assign the drive letter F to CORRESPOND to the network place //server/share

How do I mount a network drive within DOS?

Thanks,
-darrylnet USE f: \\server\share

should work
ulibeautiful.
thank you
-darryl

6298.

Solve : Spaces in the file path?

Answer»

i have a BATCH file that opens a file and WORKS fine how ever if i try it with a file path that has spaces it doesnt like it. Is there a way around this without changing the file path?Hi JTWork,

You can use DOUBLE INVERTED commas to ignore the blank SPACE between file name.

Ex. "C:\Windows\System32\file name.exe"

6299.

Solve : I'm so pretty.?

Answer»

I made a boot diskette floppy. when I USED it, almost all the COMMANDS won't work. the only one works is MD. any fine gentleman knows why? that is cool. how can it made the word > f*k? do they use DOS?Calling us a**holes doesn't exactly encourage us to help you and your second post makes no sense at all.
And please be more specific about your problem. How did you create the boot DISK for example? What kinds of error msg do you get when you type in commands? etc.You need to watch it, buddy, or you'll be out of here real fast.

6300.

Solve : Hey quick question hope the answer is quick but I will take all?

Answer»

Hi I have an old laptop with windows 95 I screwed up and renamed a folder now the farthest I can go is the comand prompt after pressing F8 then selecting comand prompt ......... C:\>

Dont remember the folder name I renamed but it should be easy to find because I only added some letters to the front or back.

Can I use the comand prompt to rename the folder?Run a directory listing to find the name(s).

Win.95 commands are here

Good luckAt the prompt try typing CD\Windows and hit Enter...then type Win and hit Enter.

System folders should NEVER be re-named.I suppose reposting the same question again in a duplicate thread is different from bumping the original every 55 minutes...
thanks I will be trying that now!!!I have tired;

Quote from: patio on March 23, 2008, 07:12:56 AM

At the prompt try typing CD\Windows and hit Enter...then type Win and hit Enter.

And;

Quote from: Dusty on March 23, 2008, 12:31:29 AM
Run a directory listing to find the name(s).

Win.95 commands are here

Good luck



The first results in the same MESSAGE I get when I try to start up normally;

"While initializing device IOS:
Error: An I/O subsystem driver failed to load.
Either a file in the .\iosubsys subdirectory is corrupt,
or the system is low on memory."

The second results in me guessing I have used all of my luck somewhere because I could not figure out which folder it was, although I do spend what little free time I can looking.

Thanks for the help if you know what I might try next please let me know and I will get on it. As for finding the folder as soon as I figure out which one I have renamed I will post it.

Also I am starting to wonder if it was a file I renamed and not a folder. Is there a WAY to use the command prompt to rename files or folders that is easy to explain or will I just need to post when I find and hope for the best.

Thanks againOkay I am trying to use the find command to find the files or folder I renamed, but I am having alot of trouble doing this. THINGS I have learned so far include;

It is most likely in c:\WINDOWS\SYSTEM

Small possibility it is a folder MUI which contains other folders named numbers.

It must be the folder iosubsys but I can not find what I named it to I would think if I was going to rename something I would make it easy to find by just adding a number or LETTER to the BEGGINING or end but must not be unless the system deleted it or something.I have been able to find boot disks but if I try to do the windows/win to boot it almost works then I get the same message. I am just going to start a new thread int he Microsoft section and reinstall win 95

I just wanted to say thank you to everyone that helped and if you have an idea of what todo next please look for my new post.

thanks again