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.

4901.

Solve : add reg data through a batch file instead of a .reg file?

Answer»

hi there to all my friends specially you !
well. i have a reg key (myreg.reg) when i double click it.. it exports some data to registry and it's just fine
now here's the problem= i want to ADD these data through a batch file(not myreg.reg file) so i think i should USE REG ADD right?
here is my reg data

Quote

REGEDIT4

[HKEY_CURRENT_USER\Software\My Own File Sorter]

[HKEY_CURRENT_USER\Software\My Own File Sorter\Regcode]
@="DCFA1E43-4F572A3A-C6EC9F67-8A1C9C41-0607E9D7-BF1FDF3A-AE703C7E-B3666661"

[HKEY_CURRENT_USER\Software\My Own File Sorter\User]
@="new user"

i copid these data into a new batch file and replaced [ ] with " " then i added REG ADD at the beginning of each line so it looks like this

Quote
REG ADD "HKEY_CURRENT....
REG ADD "HKEY_CURRENT....
it adds each line successfully into the registry but it's not working what's wrong? can you fix it for me? Hello, mioo_sara.
You should use 'Reg Add', not 'Add reg'
For additional help go here.sorry i mistyped it !! i changed it to REG ADD and it still is not working !! why?
i believe problem is in lines (3 and 5)
by the way i updated my first post
thanks dear archer
i am wating can someone solve the problem?reg add "HKCU\Software\My Own File Sorter" /v Regcode /d "DCFA1E43-4F572A3A-C6EC9F67-8A1C9C41-0607E9D7-BF1FDF3A-AE703C7E-B3666661"
Code: [Select]REGEDIT4
;@start regedit /s "%~f0"&goto :eof
[HKEY_CURRENT_USER\Software\My Own File Sorter]

[HKEY_CURRENT_USER\Software\My Own File Sorter\Regcode]
@="DCFA1E43-4F572A3A-C6EC9F67-8A1C9C41-0607E9D7-BF1FDF3A-AE703C7E-B3666661"

[HKEY_CURRENT_USER\Software\My Own File Sorter\User]
@="new user"thank you both (Prince_ and Reno)
well Prince_ solved the problem thank you very much
but RENO although my problem is solved but just for learning purpose i ask this question=
in your codes all values are EXPORTED into registry and i don't see any error but it's not working(with your code not Prince_)
i changed "Regcode" line as you posted and "User" line as you see below

Quote
reg add "HKCU\Software\My Own File Sorter"

reg add "HKCU\Software\My Own File Sorter" /v Regcode /d "DCFA1E43-4F572A3A-C6EC9F67-8A1C9C41-0607E9D7-BF1FDF3A-AE703C7E-B3666661"

reg add "HKCU\Software\My Own File Sorter" /v User /d "new user"

but although it hasn't error but it's not working what's the CORRECT algorithm?
well as i mentioned problem is solved with ( Prince_ ) codes and it's just for educational purpose so if you don't have time ignore iti have had trouble with an error that comes up , it says error when write data to registry. how does one correct that ?Quote from: worrywart2009 on AUGUST 31, 2009, 02:45:37 AM
i have had trouble with an error that comes up , it says error when write data to registry. how does one correct that ?

Worrywart2009,

You need to start your own thread.
4902.

Solve : something is confuzzling me.?

Answer»

I need to write part of a BATCH file, that goes out to a folder, deletes all folders that have numbers in them (meaning they are strictly numbers) and nothing else. I have tried, and am probably not understanding rmdir, and also rd... but neither are working properly, for what I need to do. does anyone have any ideas?im sorry this may be off topic and i apologize in advanced but what kind of word is confuzzling?!?!?!.....lol

-sorry i dont know anything about batch!Quote from: zonatedace on August 28, 2009, 01:34:49 PM

im sorry this may be off topic and i apologize in advanced but what kind of word is confuzzling?!?!?!.....lol

-sorry i dont know anything about batch!

It is an American English jocular variant of "CONFUSING". (Surely you could have guessed that from the context in which it occurred?) You have to imagine a kind of white haired bearded Burl Ives type of Southern guy saying "These here new fangled Intarwebs sure are confuzzlin' me! Yee Har! I guess I'll just whip up a batch of corn pone!"
Type rd /? or rmdir /? at the command prompt to see the params.mmagruder, POSSIBLY the folders you are trying to remove are not empty? Rmdir / RD will fail in that situation, unless you use certain switches. Or maybe you do not have sufficient admin rights.

"Not working properly" is not ENOUGH INFORMATION. Perhaps you could show us (1) what code you are using and (2) what error messages you are getting?

Incidentally

Quote
rmdir, and also rd... but neither are working properly

They are the same command. Whether you use rmdir or rd, you get the same code running.


To add to Salmon's reply.

Please tell us the OS your using.
4903.

Solve : Copying to a remote computer?

Answer»

Ok, let's say I'm trying to copy a file from my computer, to another computer. Is this possible without being on a LAN? Can I send files if I have the computer's IP address? I'm trying to get another ALTERNATIVE to a FTP site that works via batch.If you are both on a peer to peer network you could share files.We're not...

If you can recommend a good FREE FTP host, that would greatly be apreciated. I'll even let you be a beta tester for when it's almost ready to release. Google is your friendQuote from: BatchFileBasics on AUGUST 30, 2009, 03:47:49 PM

Google is your friend
Not really for this. I tried getting a good host last year, one wouldn't accept my password, another had hidden costs, another would bring up random errors and crash my script, at least 3 wouldn't transfer files. The LIST goes on. oh, well 0catch.com works for me, really EASY stuff. and free, been using it for around a year nowWhat's the syntax for ftp with a file containing all the commands (including username and password)?it should look like this:
Quote
ftp> open 0catch.com
Connected to 0catch.com.
220 ftp NcFTPd Server (licensed copy) ready.
User (0catch.com:(none)): batchfilebasics.0catch.com
331 User batchfilebasics.0catch.com okay, need password.
Password: its a masked password

its just your login info
and btw, to login to the website, the username is user.0catch.comI know about that. But let's say I have a file called comm.txt and in it is this:

User.0catch.com
PASSWORD
COMMANDS

The ftp command can utilise that and run those commands automatically.
I've done this before, I just can't remember how. ah yes, thanks to my vault of scripts i always keep

you will have a file with the data
Code: [Select]username
password
commands
and in your ftp batch
Code: [Select]ftp -i -s:data.txt ocatch.comQuote from: BatchFileBasics on August 30, 2009, 04:27:08 PM
ah yes, thanks to my vault of scripts i always keep

you will have a file with the data
Code: [Select]username
password
commands
and in your ftp batch
Code: [Select]ftp -i -s:data.txt ocatch.com
I remember the -s: part now, but what does -i do (I can't access my computer right now)?-i is for no prompting "would you like to send file xx (y/n)"
its for automated use with lots of filesQuote from: Helpmeh on August 30, 2009, 04:29:47 PM
what does -i do

Turns off interactive prompting during multiple file transfers.

List of FTP commands for the Microsoft command-line FTP client

http://www.nsftools.com/tips/MSFTP.htm

Thank you.
4904.

Solve : [solved] Create 100 files in a folder?

Answer» QUOTE from: BC_Programmer on August 22, 2009, 12:18:56 PM
I'm trying to understand why multiple batch files are even necessary.

Is for my program Goldmine 5.5 from Frontrange.

This program make macros with the structure user.800 .... user.899

When I launch from the exterior a user.800.bat ...... user.899.bat I'm launching the program with my parameters and a specified macro.

In this way

user.860.bat launch

echo off
taskkill.exe /im gmw5.exe /f
Y:\GoldminePrg\gmw5.exe /i:esm /U:JOSE /p: /m:Y:\GoldminePrg\Macros\user.860
exit

P.D. Each macro goes o search for a certain field in the database. So is equivalent to enter Goldmine and go to the field determined by the interior macro.....

I hope is understood.

Thanksxxxx

Quote from: BC_Programmer on August 22, 2009, 12:18:56 PM
I'm trying to understand why multiple batch files are even necessary.

Well.
I use excel 2002 and have a check list. I would like to link this list with certain contacts in the database.
Each bat is used to link to a contact predetermined with a INTERNAL goldmine macro.

In an excel cell I put the PATH to the bat : \pepe.800.bat

Each bat EXECUTE the program goldmine and a internal macro , and goes to a predetermined contact in the database. And edit that contact.

I hope this is understood.

I have to make one internal macro for each contact to search.

And one corresponding bat for each internal macro.

The internal macro have the structure pepe.800
and the bats have the structure pepe.800.bat

....



Quote from: BatchFileBasics on August 22, 2009, 12:25:01 PM
Esgrimidor, what do you need 100 batch files for anyways? 1 file, about 10 lines, and a good for loop can probably do what all these files would do..

and really, this is confusing me,
here you go
Code: [Select]@echo off
:begin
set pth=
echo.
set /p pth=Path of folder:
if not exist "%pth%" (
mkdir "%pth%"
goto :PRE
)
echo.
echo ERROR: Folder exists
goto :begin
:PRE
set /p pr=Prefix for files:
echo.
echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
pause
cd /d "%pth%"
for /l %%a in (800,1,899) do (
echo @echo off>%pr%.%%a.bat
echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a.bat
echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a >>%pr%.%%a.bat
echo exit>>%pr%.%%a.bat
)


Please tell me if this modification is correct or not :

Code: [Select]@echo off
:begin
set pth=
echo.
set /p pth=Path of folder:
if not exist "%pth%" (
mkdir "%pth%"
goto :PRE
)
echo.
echo ERROR: Folder exists
goto :begin
:PRE
set /p pr=Prefix for files:
echo.
echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
pause
cd /d "%pth%"
for /l %%a in (800,1,899) do (
echo @echo off>%pr%.%%a
echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a
echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a >>%pr%.%%a
echo exit>>%pr%.%%a
)sorry, i mean the extensions it is being output to is not in bat

following your..."requests"

this is it:
Code: [Select]@echo off
:begin
set pth=
echo.
set /p pth=Path of folder:
if not exist "%pth%" (
mkdir "%pth%"
goto :PRE
)
echo.
echo ERROR: Folder exists
goto :begin
:PRE
set /p pr=Prefix for files:
echo.
echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
pause
cd /d "%pth%"
for /l %%a in (800,1,899) do (
echo @echo off>%pr%.%%a.bat
echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a.bat
echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a >>%pr%.%%a.bat
echo exit>>%pr%.%%a.bat
)Of course you are right

Sure there are a lots of ways of doing this : DDE, API Goldmine, COM procedures, etc.
But in the goldmine forum , at the present moment, they don't give support for via VB create an script for seek a record in the database without need to open goldmine.

This way is one of many ways, and for me is enough.

Thank very much.

100 is the number of macros you can create with a user. Each user can have 100 macros. And the user JOSE can use the macros of other users......

In this way I can have all the links I need from excel, word.

To make "fussions" Goldmine have an utility : gmlinks I use to prepared personalyzed writes....













Quote from: BatchFileBasics on August 22, 2009, 12:41:24 PM
sorry, i mean the extensions it is being output to is not in bat

following your..."requests"

this is it:
Code: [Select]@echo off
:begin
set pth=
echo.
set /p pth=Path of folder:
if not exist "%pth%" (
mkdir "%pth%"
goto :PRE
)
echo.
echo ERROR: Folder exists
goto :begin
:PRE
set /p pr=Prefix for files:
echo.
echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
pause
cd /d "%pth%"
for /l %%a in (800,1,899) do (
echo @echo off>%pr%.%%a.bat
echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a.bat
echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a >>%pr%.%%a.bat
echo exit>>%pr%.%%a.bat
)



I see.....

How can I do bat files pepe.800.bat and inside the bat : pepe.800 only ?

thats what it is, they are all .bat files.
but inside are just pre.800
no .bat insideOh yes.

Perfect. Is enough for me.
You have saved me a lot of work.
With the bats is another thing....

Code: [Select]@echo off
set /p prefix=Enter Prefix:
for %%d in (0, 1, 100) do (
set /A i=%%d+800
taskkill.exe /im gmw5.exe /f
Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%%prefix.%%i.bat
)
exit
4905.

Solve : Batch file for high contrast?

Answer»

I NEED help creating a batch FILE that will automaticall turn on high CONTRAST under display in ACCESSIBILITY options for a user that has problems seeing. I have Zenworks and have used a roaming profile, but the high contrast will work even better.What video display adapter is it ? ?
Some allow creating profiles which you could simply create a Desktop icon for...1 clik and boom.It is for a user that will LOG in to different systems in a large environment. The one that I am testing it on is an nvidia geforce 7950. Is the one click program executed with a batch file?

4906.

Solve : CD-ROM drivers for Compaq?

Answer»

Where could I find DRIVER cdc710.sys for download?http://www.driverfiles.net/No, I`m sorry but the driver I`m searching for is not found on the webadress you refer to, or is it me who is not able to search properly??Quote from: tor47 on August 29, 2009, 10:30:33 AM

Where could I find driver cdc710.sys for download?

You really need a SCSI cd-rom driver? Really?
The CD-rom drive has so far got no drive letter and is not working. The drive is a Compaq CR-503BCQ. According to the manual "CD-ROM Drive Installation and Operations Guide" from Compaq the driver name is CDC710.sys. Quote "The CDC710.sys driver works with Microsoft CD_ROM extensions (MSCDEX.EXE) to allow DOS to view up to two CD_ROM drives as read-only hard drives and will atomatically assign a drive letter for the CD_ROM drive".

That`s the reason for my search for this spesific driver. If ANYBODY has other solutions to get th CD_ROM working I would be grateful. I should also add that I`m not quite sure the autoexec.bat and config.sy files are correct.You would only need this driver if:

(1) You are using MS-DOS or Windows version 3.

(2) The CD-ROM is a SCSI drive.

unless BOTH of these are true, that file is not going to help you.



yes, this is used for dos and he probably understands that.

so you can download the driver here
and you MAY see the virus report here

so put it on a floppy, insert, RUN, setup yeaOptical drives don't need any extra drivers under XP.Quote from: Broni on August 30, 2009, 12:52:48 PM
Optical drives don't need any extra drivers under XP.

Indeed.
4907.

Solve : Alternate Data Streams?

Answer»

Win XP Home - Cmd.exe

The only Internal/External command which works with ADS appears to be More. Any others please?

ThanksQuote

The only Internal/External command which works with ADS appears to be More

Not really sure of the context of this statement. More can display output on the console. It can TAKE input from the output of another command or as a passed command line parameter.

Is this what you're referring to? If so, Sort, Find, and Findstr act in a similar manner.

Sort Find and Findstr are not really what I had in mind.

I'm creating ADS's but find that there's not really a lot can be done with them except by using More. Because they are totally hidden it seems none of the cmd.exe commands can access them individually.

If I create an ADS using:
Echo The quick BROWN fox jumps over the lazy dog > cookyfile.txt:brownfox
the cookyfile.txt file is created as a 0 byte file and the ADS brownfox contains the echoed string.

If I now want to display/print/edit/etc.. the contents of the ADS I cannot access it using Type, Print, Edit etc... I enter Type cookyfile.txt:brownfox and the error message returned is "The filename, directory name, or volume label syntax is incorrect."

I wondered if anyone had gotten commands to work on an ADS, am not really interested in third party products.

ThanksYou can use the mep command which is the Microsoft Editor available in the Platform SDK.

I can't help but be a bit suspicious. ADS can be used to fork file data (read: inject malicious code/rootkits) into existing files without affecting their functionality, size, or display to traditional file browsing utilities like dir or Windows Explorer.

I could only find one legitimate use of ADS for certain files in Windows that have a summary tab in their properties. This information is saved as ADS files attached to the document. This can just as easily be done through the Windows GUI or any of the Windows script languages.

What are you trying to accomplish?

good question, Sidewinder.
Quote from: Sidewinder
I can't help but be a bit suspicious...... I could only find one legitimate use of ADS for certain files in Windows that have a summary tab in their properties...... I can't help but be a bit suspicious...... What are you trying to accomplish?

Quote from: Dias de verano
good question, Sidewinder.

Wow, my little innocuous project brought out the big GUNS. All I want is a better (faster) method of displaying the contents of ADS which I am capable of writing. Had I wanted to BOMBARD all and sundry with hidden malicious code/rootkits that would already be happening.

My purpose is to add confidential comments to personal files. Sure there are other ways of doing this, such as encryption, but I just wanted to try ADS which, IMO, is simpler and secure enough for my purpose.

Now I shall try hard LINKS using the script(s) supplied by MS.

Thanks for your comments.Quote from: ValerieMay
All I want is a better (faster) method of displaying the contents of ADS which I am capable of writing.

Subsequently I found that Notepad can do everything I want so I'm upward & onward.

Quote
Wow, my little innocuous project brought out the big guns.

Nonsense. We only scrambled a few jets with their Sidewinder payloads. For the big guns we would have gone to the silos for the Titans.

Quote
All I want is a better (faster) method of displaying the contents of ADS which I am capable of writing.

A VBScript could do this faster and easier than Notepad. Less prone to error also. As long as you're doing it manually with Notepad, why not right click the document and enter built-in or custom properties?

But hey!, as long as you're upward and onward, we're happy.

Good luck. Quote from: Sidewinder on October 18, 2008, 07:37:36 AM

Nonsense. We only scrambled a few jets with their Sidewinder payloads. For the big guns we would have gone to the silos for the Titans.

Those are missiles, or what Americans call "missles". This is a little gun.



This is a big gun

4908.

Solve : Wildcards in a variable?

Answer»

Can I use wildcards when defining a variable name? Like this:

set num*=abc

If I have these variables: num1, NUM2, num3, etc.

Would be a pretty big timesaver if I could.you NEED a programming construct called an array. batch doesn't have that... (although in batch you could probably do a enable delayed expansion , use a for loop and set to CREATE each individual variables with those names)Quote from: gh0std0g74 on August 29, 2009, 06:18:30 PM

you need a programming construct called an array. batch doesn't have that... (although in batch you could probably do a enable delayed expansion , use a for loop and set to create each individual variables with those names)
So this should work?

For /L %%a in (1,1,10) do set num%%a=abc

Right?no it doesnt i just tried itQuote from: smeezekitty on August 29, 2009, 06:24:13 PM
no it doesnt i just tried it
Did you do that from the COMMAND prompt or a batch FILE? One % for command prompt, two % for batch file.oops i forgot that
yes it does work
4909.

Solve : Rename Various files with a batch file?

Answer»

I have a lot of .jpg's in one folder with a lot of different names. I want to rename them all in sequence i.e. 10001.jpg, 10002.jpg and so on. Or even with names like a.jpg, B. jpg or even aa.jpg, ab.jpg ac.jpg...

Can anyone shed light on how to do this?

Thanksthis is what i got...not really much to explain...except this will rename all files jpg in order 0 - xxx.

change "C:\path\of\files\" for the path of your files
Code: [SELECT]:begin
set count=1
cd
FOR /F "tokens=*" %%f IN ('dir /A-d /b') do (call :filecount "%%f")
:filecount
set /a count+=1
for /f %%a in ('dir /w /b "*.jpg"')do (
for /l %%b in ('1,1,%count%') do (
ren %%a %%b.jpg
)
)@echo off&setlocal enabledelayedexpansion
(for %%a in (*.jpg) do echo "%%a")>jpg.tmp
set i=0
for /f %%a in (jpg.tmp) do (
set /a i+=1
ren %%a !i!.jpg
)
del jpg.tmpCode: [Select]@echo off&setlocal enabledelayedexpansion
set i=0
(for %%a in (*.jpg) do (
set /a i+=1
ren %%a !i!.jpg
)

4910.

Solve : Batch file for Windows XP?

Answer»

I posted this in the Windows forum and was told that I should have posted it here:

--------------------------------------------------------------------------------
I have been actively using computers since 1979 so I am quite familiar with batch files in a DOS environment. I find the are certain tasks that I do over and over in Windows XP and I would like to write a batch file to bring this repetition down to just one click.

The following are tasks that I would like to have batch files for:

1. Click an icon to open the same group of 4 windows and if possible SIZED so they are all visible (like my screen had been quartered).

2. Click an icon to search for a file in a specific directory along with its subdirectories no matter what my current window/directory is and show the results in a window and not a dos shell environment so that I can just click on the file to open it. I KNOW that I can search the whole computer but I have over 1 TB of files so a general search takes some time. Usually I have to navigate to the window I want, click "Search" from the toolbar, pick "all files and folders" from the side bar and the type in the file name I am looking for. I want to click once and then type in the file name.

3. Format/erase everything on a SD card or thumb drive and except for one file (always the same exact file).

There are other things that I already use batch files for. I am good at DOS, I grew up on it but I haven't FIGURES out how to use DOS to do thinks like open a window in the Windows environment.

Slam
[emailprotected]

email addy removed to prevent SPAM.(1) You will need a 3rd party app to do this. CMDOW is free.

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

You can start the 4 apps and then move / RESIZE them to specified positions and window sizes

(2) HMMM....

(3), is the file in the root folder or buried somewhere in a sub folder?

4911.

Solve : Change File Name??

Answer»

Help:


<<"I have 100 files that are named 001xxx, 002xxx, 003xxx, and so on with the "xxx" standing for the remainder of the file name. Each name being different after the numbering.

I would like to know if there is a way to globally change the files name, taking off the numbering and leaving the remainder of the name intact.">>I use this: http://www.bulkrenameutility.co.uk/Main_Intro.phpAssuming that

1. In each case, you wish to remove the first 3 characters of each filename
2. All the files to be renamed are in the same folder
3. There are not any other files in the same folder that should not be renamed.

Code: [Select]
@echo off
setlocal enabledelayedexpansion
set batchname=%~nx0
for /f "delims=" %%F in ( ' dir /B ^| find /v "%batchname%" ' ) do (
set oldname=%%F
set newname=!oldname:~3!
echo renaming "!oldname!" to "!newname!"
REM ren "!oldname!" "!newname!"
)
echo Done
echo.
echo pause


Put a copy of this batch in the folder with the files to be renamed; it will not rename itself; test it and use Notepad to remove the REM when you are HAPPY it works; test it with a copy of your data to be safest.


Quote from: Salmon Trout on August 20, 2009, 01:03:15 AM

Assuming that

1. In each case, you wish to remove the first 3 characters of each filename
2. All the files to be renamed are in the same folder
3. There are not any other files in the same folder that should not be renamed.

Code: [Select]
@echo off
setlocal enabledelayedexpansion
set batchname=%~nx0
for /f "delims=" %%F in ( ' dir /b ^| find /v "%batchname%" ' ) do (
set oldname=%%F
set newname=!oldname:~3!
echo renaming "!oldname!" to "!newname!"
REM ren "!oldname!" "!newname!"
)
echo Done
echo.
echo pause


Put a copy of this batch in the folder with the files to be renamed; it will not rename itself; test it and use Notepad to remove the REM when you are happy it works; test it with a copy of your data to be safest.



i was looking for a batchfile to do that
it works great
and i am not the ORIG poster
it makes no sense to me
how does it work?
how do you MAKE it take of 5 chars?
Quote from: smeezekitty on August 20, 2009, 01:35:20 AM
how do you make it take of 5 chars?

Code: [Select]set newname=!oldname:~N!
Replace N in that line with the number of characters to remove from the beginning of the filename.

works perfectly
4912.

Solve : .bat file to end a process...?

Answer»

Can someone please help me? I'm trying to find a command line that will end a process like when you open task manager and go to the process TAB and end processes. The reasoning is when I run my virus removal software it tells me to end a few things and it would just be easier to click a .bat file then to bring up task-manager ..please help A similar question appeared earlier this week. I guess some code just never dies.

Code: [Select]@echo off
:loop
for /f "tokens=1 skip=3" %%f in ('tasklist') do (
if /i .%%f equ .%1 taskkill /im %1 /f
)
if not .%2==. (
shift
goto loop
)

Save the above snippet with a bat extension. You can then run your batch file to KILL any number of jobs named on the command line.

ie: If you saved the file as RunTheKill, you could run it as:

RunTheKill excel.exe iexplore.exe

Both Excel and Internet Explorer will be killed.

Good luck. it says tasklist is not recognized as .... am i supposed to put the tasks in there?Apparently my crystal ball was not PLUGGED in. Tasklist and Taskkill are utilities installed with some NT operating systems. (Note: XP Home has TLIST).

You can download both from here

Happy coding.

Next time please mention your OS. You'd be surprised how helpful that little piece of information can be.What would the code be for Windows Server 2003?It's FLATTERING you would drag up an OLD post from 11 months ago. Gives new meaning to Groundhog Day.

Windows XP pre-dates Windows Server 2003. Seems reasonable taskkill and tasklist would be included with the newer OS. The snippet has been slightly modified from the original.

Code: [Select]@echo off
:loop
for /f "tokens=1-2" %%f in ('tasklist') do (
if /i %%f equ %1.exe taskkill /F /IM %%f 2>nul
)
if .%2==. goto :eof
shift
goto loop




Thanks so much!

4913.

Solve : How to trace the order of the batch files which are running one after the other?

Answer»

Hello all,
From my web application when i click on "Done" button a group of 7 batch files will be downloaded in to the users PC in the path "C:\temp" and these batch files will be executed one after the other.

I want to find the order of the batch files running. I mean, i want to find which batch file is excuted at first, second,third...

All these batch files will be running in silent mode.

Anybody please help me. Please give me the code.

Thanks in advanceIt seems to be impossible.QUOTE

these batch files will be executed one after the other.

Then you already know, don't you?
use debug:


C:\>debug /?
Runs Debug, a program testing and editing tool.

DEBUG [[drive:][path]FILENAME [testfile-parameters]]

[drive:][path]filename Specifies the file you want to test.
testfile-parameters Specifies command-line information required by
the file you want to test.

After Debug starts, type ? to display a list of debugging commands.

C:\>debug
-?
assemble A [address]
compare C range address
dump D [range]
enter E address
    fill F range list
    go G [=address]
[addresses]
HEX H value1 value2
input I port
load L [address] [drive] [firstsector] [number]
move M range address
name N [pathname] [arglist]
output O port byte
proceed P [=address] [number]
quit Q
register R [register]
search S range list
trace T [=address] [value]
unassemble U [range]
write W [address] [drive] [firstsector] [number]
allocate expanded memory XA [#pages]
deallocate expanded memory XD [handle]
map expanded memory pages XM [Lpage] [Ppage] [handle]
display expanded memory status XS

-[/list]Billrich, can you talk me through how this will enable the OP to do what he wants?
Quote from: Salmon Trout on August 29, 2009, 05:13:04 AM
Billrich, can you talk me through how this will enable the OP to do what he wants?


Oh, this is a production site and we are being paid? Contact my secretary at BR549 with a $2000.00 advance. My consulting FEES are $500.00 per hour.

Do not use wait* or *wait*I asked because I don't believe debug will help the OP one little bit. I CHALLENGE you to say how it would, if you can.

Quote from: Salmon Trout on August 29, 2009, 07:15:07 AM
I asked because debug will not help the OP one little bit, and I don't believe you actually know an answer to the OP's question.


My secretary has not received the $2000.00 advance.

Would you list your company? We need to check your credentials.

Is the name of your company "Computer Phishing?"
Quote from: simhadri1985 on August 20, 2009, 05:50:04 AM
Hello all,
From my web application when i click on "Done" button a group of 7 batch files will be downloaded in to the users PC in the path "C:\temp" and these batch files will be executed one after the other.

I want to find the order of the batch files running. I mean, i want to find which batch file is executed at first, second,third...

All these batch files will be running in silent mode.

Anybody please help me. Please give me the code.

Thanks in advance

Mr. Trout:

This thread is a Charade. The OP is Fake. His call for assistance is fake. Why would anyone try to a download programs to a user's computer silently?

The OP has a warped sense of humor. No one believes the OP is serious.
4914.

Solve : drag and drop problem?

Answer»

i WANT to have so if i click on it it will SAY "what do you want to do" and when i drag a torrent file it will open utorrent

[attachment deleted by admin]Drag and Drop is a technique with windows. There is no drag and drop command for the command prompt ( Dos commands? ).

http://www.linfo.org/drag-and-drop.html

<<"Drag-and-drop is the ability to MOVE graphical user interface (GUI) objects, i.e., ICONS and windows (and menus on some programs), by means of manipulating a mouse or other tracking device (such as a trackball, touchpad or pointing stick). ">>Quote from: billrich on August 19, 2009, 07:44:08 PM

Drag and Drop is a technique with windows. There is no drag and drop command for the command prompt ( Dos commands? ).

If you drag a file into a command window, something HAPPENS. Try it.

yes i know that but i want it to open utorrent when i put a torrent file on top of the batch fileQuote from: rubiks231 on August 20, 2009, 10:53:56 AM
yes i know that but i want it to open utorrent when i put a torrent file on top of the batch file

Well, make a shortcut to the batch file and whatever is dropped on it is "%*" and then you can start utorrent with the parameter, if utorrent supports it.

thanks it worked
4915.

Solve : set /a and variable names?

Answer»

An example of the code I'm using that works properly. This allows a user to input a numerical value, then the process will loop that many times, letting the user specify a new VARIABLE each time.

Code: [Select]setlocal enabledelayedexpansion

set /p counter=Enter numerical value:

: loop

if not %counter%==0 (
set /p var=Enter a NAME:
set /a counter=!counter!-1
goto loop
)
However, when I give the %counter% variable a different name with two words, such as %counter a%, it breaks.

Code: [Select]setlocal enabledelayedexpansion

set /p counter a=Enter numerical value:

: loop

if not %counter a%==0 (
set /p var=Enter a name:
set /a counter a=!counter a!-1
goto loop
)
Maybe it's something simple like quoting the name somewhere in the code, or perhaps set /a doesn't like spaces? Anyone know?

Thanks for the help.Your second thought is correct, variable names cannot include spaces

GrahamQuote from: gpl on October 17, 2008, 02:26:22 AM

Your second thought is correct, variable names cannot include spaces

Graham

They can, but it should be avoided as a rule because sometimes problems can happen, like now when the combination of set /a and delayed expansion is a bit toxic.
Really!!!

Just shows how far BACK I go, we never had spaces in anything when I were a lad
GThanks for the help.

I played around with the code above and removed the delayed expansion. Seems set /a just won't play with multi-word variable names. Guess I need to break this bad habit in naming my variables. Just seems so much more logical and easy to ready with spaces. Maybe it's just me.

Anywho, thanks again.Quote from: gregory on October 17, 2008, 08:23:29 AM
Just seems so much more logical and easy to ready with spaces. Maybe it's just me.

Not many programming or scripting languages ALLOW spaces in variable names. With Windows command prompt at least you can use them sometimes, although many serious programmers strongly deplore their use. Underscores hyphens and dots are popular as substitutes.


The reason why set /a does not like variable names with spaces is, I think quite simply because unlike simple set, set /a does not require % signs around a variable to the right of the = for operations with literal numbers such as

set /a number=number+1

alternative, more compact format: set /a number+=1

and therefore would have trouble DECIDING where variable names end.

although of course you would need to use !number! on the right of the = when using delayed expansion.

4916.

Solve : DOS Batch To Run When Logging Out?

Answer»

Hello,

I am FAMILIAR with NOHUP in unix. I have a SCHEDULED job on 2003 which calls a BATCH file. Within this file it calls a cygwin (Unix) script. When I LOG out of the box, after the schedule starts, the program dies. The scheduled job is actually not even the same user as I am. It's just that when I exit the box, the started job ENDS. (I would use nohup on the bash script but I don't know how to call a bash script and nohup at the same time either.

bash nohup

4917.

Solve : Question about the rename command?

Answer»

Hi everyone

IM new to batch files, so please bear with me as I try to explain Ive got a batch file that is giving me worms actually 2 of them they look like this

rename panel.{21EC2020-3AEA-1069-A2DD-08002B30309D} panel
ren panel panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}


now when I have this folder "panel" in the same directory as the batch files they work as expected.. but I need to move these two batch files out of the same path so I tried this

cd E:\Documents and Settings\handsome\Desktop\
ren panel.{21EC2020-3AEA-1069-A2DD-08002B30309D} panel


and put it in another folder but it wont work? But if I copy and paste it into a CMD window then hit ENTER it does! THATS when I get frustrated is there a way to do an "enter" statement in dos or does someone have a suggestion?? Im sure I am OVERLOOKING some rule of DOS or something

Thanks in advance Chas

Quote from: chas_3rd on October 15, 2008, 08:41:09 AM

cd E:\Documents and Settings\handsome\Desktop\
ren panel.{21EC2020-3AEA-1069-A2DD-08002B30309D} panel


is panel.{21EC2020-3AEA-1069-A2DD-08002B30309D} in the file E:\Documents and Settings\handsome\Desktop ?

you need to change directory to where the panel.{21EC2020-3AEA-1069-A2DD-08002B30309D} is and the rename it.

FBthx yes thats where I pointed to its on my desktop

like I said if I paste this into the command prop and hit enter it works like I expect but not from the different path/directory

any clue why this isnt right ?if you the current directory is on a different drive letter, CD is not enough, you need to do CD /D otherwise you remain on the first drive letter.
You nailed it summer

where I had moved the file was on a shortcut folder which was linked to a different drive.. when I placed the files back on the same drive as the folder it works great TYVM also can you give me an example of the syntax on cd/d ?


Again thanksQuote from: chas_3rd on October 16, 2008, 06:42:51 AM
also can you give me an example of the syntax on cd/d ?

You are in drive C, in folder \apples

The prompt looks like this

C:\apples>

If you do a DIR you will SEE the files and folders in C:\apples

But now you want to be in folder C:\oranges

You type CD C:\oranges

The prompt changes to this

C:\oranges>

If you do a DIR now you will see the files and folders in C:\oranges

You want to change to a folder on drive D, called \pears.

You type CD D:\pears

but the prompt does not change. It still shows

C:\oranges>

If you type DIR you still see the files in C:\oranges.

This is because the new folder is on a different drive.

You have to type CD /D D:\pears

The prompt changes to

D:\pears>

You do a DIR and you see the files and folders in D:\pears.

Awesome ty sir/maam im one step closer to being a dos genius

Have a good one and thx again chas
4918.

Solve : prefix each line in a txt file with a value?

Answer»

I have searched QUITE a few topics and haven't seen ANYTHING which seems to meet my REQUIREMENTS......

objective - read every record in a txt file and prefix it with a variable..

1. set a variable (XXX) to the current TIME
2. read the txt file
3. write to a new txt file PREFIXING the output record with XXXYou probably won't find an exact solution. You'll need to write a script.

1. set a variable equal to the current time.

2. In a loop:

a. Read every "record" (do you mean every line?) in the text file
b. Prepend the time variable to the line and
c. Write it out to the new file.

4919.

Solve : MS-Win CLI network configuration?

Answer»

Hi folks,

I am using a WinXP computer that is used on two NETWORKS. Both are using TCP/IP but one network uses DHCP and the other uses a static configuration. It is imperative that it is NEVER connected to both at the same time. For now I have been switching the network cable and going into the microsoft Control Panel to reconfigure the interface every time I switch. The machine has two ethernet SOCKETS but I am currently restricting usage to only one to ensure that the two networks never meet. As I need to switch 3-4 times a day it wasn't LONG before 'there must be an easier way' popped into mind.

I know that if this was a 'nix system I could have each network plugged in to each socket and use 'ifconfig' to start/stop each interface. I could then write a script that would ensure that eth0 was disabled before ETH1 was activated, and vice versa. However the MS equivalent seems unable to do this. Does anyone know otherwise?

An acceptable alternative would be to stay with the lead-switching but have a script reconfiguring the interface. Again the MS command set seems lacking?

Any help would be greatly appreciated,
Many thanks, kimdino

4920.

Solve : How to pass a return value from a jar file to a batch file?

Answer» QUOTE from: BatchFileBasics on AUGUST 19, 2009, 11:34:03 AM
just remove the delims

If the OUTPUT is just (e.g.) 33 then the TOKENS= part needs to go as well and the variable is the same (e.g.) %%A in the FOR and in the DO parts.

4921.

Solve : print ot file from DOS?

Answer»

Hello

i have one BAT FILE, and i whant to print to file everything what this file do.
For example:
test.bat
Quote

cd\
cd c:
cd:\temp3
ping 127.0.01

and this one i whant to save into the file
Quote
D:\>cd\

D:\>cd c:
C:\

D:\>cd:\temp3
The filename, directory name, or volume label syntax is incorrect.

D:\>ping 127.0.01

Pinging 127.0.0.1 with 32 bytes of data:

Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, MAXIMUM = 0ms, Average = 0ms
Quote
D:\>cd\

D:\>cd c:
C:\

D:\>cd:\temp3
The filename, directory name, or volume label syntax is incorrect.

What's the purpose in creating a file containing command errors

Code: [Select]test.bat >>outfile.txt
i have 2 bat files, in first i check my NETWORK connection:
Quote
echo off
ping 10.0.0.1 > c:\CheckPoint\ping.txt
findstr "Reply from" c:\CheckPoint\ping.txt
IF %ERRORLEVEL% == 0 GOTO END
cd\
cd c:
call c:\secu.bat >> test.txt

:END
If not ok with connection it calls another bat file which restart my connection(i NEED two files, i can't make it in one)
And i need to log everything what happens in second file(secu.bat)

i try to call it like this c:\secu.bat >> test.txt, it's make file called test.txt but this file is empty.try using call command

Code: [Select]call c:\path\of\file.bat
4922.

Solve : Win/Batch: If then else related questionHi there,?

Answer»

Hi there,

I am going to use Dos/Batch with VBscript suggested from some guru in this forum to generate time stamp for text files. The partial codes are as follow: -

@echo off
IF EXIST "collect_*.TXT" (
echo Wscript.echo eval(WScript.Arguments(0))>"%cd%\evaluate.vbs"
For /f %%D in ( ' CSCRIPT //nologo "%cd%\evaluate.vbs" "day(date)" ' ) do set /a d=%%D
For /f %%M in ( ' cscript //nologo "%cd%\evaluate.vbs" "month(date)" ' ) do set /a m=%%M
For /f %%Y in ( ' cscript //nologo "%cd%\evaluate.vbs" "year(date)" ' ) do set /a yyyy=%%Y
del/q "%cd%\evaluate.vbs"
if %d% LSS 10 (set dd=0%d%) ELSE (set dd=%d%)
if %m% LSS 10 (set mm=0%m%) else (set mm=%m%)
set TimeStamp=%yyyy%-%mm%-%dd
) else (
echo.
echo no information collected!
)
echo.
pause
exit

However, the program does not run properly with following error mesages:

It gives an error message: ) was unexpected at this time.
for statement:
echo Wscript.echo eval(WScript.Arguments(0))>"%cd%\evaluate.vbs"

and it gives error message: 10 was unexpected at this time.
for the statements: if %d% LSS 10 (set dd=0%d%) else (set dd=%d%)
if %m% LSS 10 (set mm=0%m%) else (set mm=%m%)

Any idea about that?


Thanks,
ThomasI suspect it does not like nested IFs
I would fake it with GoTos

Code: [SELECT]@echo off
IF Not EXIST "collect_*.TXT" GoTo IfElse

echo Wscript.echo eval(WScript.Arguments(0))>"%cd%\evaluate.vbs"
For /f %%D in ( ' cscript //nologo "%cd%\evaluate.vbs" "day(date)" ' ) do set /a d=%%D
For /f %%M in ( ' cscript //nologo "%cd%\evaluate.vbs" "month(date)" ' ) do set /a m=%%M
For /f %%Y in ( ' cscript //nologo "%cd%\evaluate.vbs" "year(date)" ' ) do set /a yyyy=%%Y
del/q "%cd%\evaluate.vbs"
if %d% LSS 10 (set dd=0%d%) else (set dd=%d%)
if %m% LSS 10 (set mm=0%m%) else (set mm=%m%)
set TimeStamp=%yyyy%-%mm%-%dd
GoTo IfEnd

:IfElse
echo.
echo no information collected!
GoTo IfEnd

:IfEnd
echo.
pause
exit

Quote from: gpl on August 19, 2009, 09:32:10 AM

I suspect it does not like nested IFs
I would fake it with GoTos

I wrote the evaluate.vbs script some months AGO, under a different screen name.

Anyhow, you are partly right. Use of this parenthetical structure:

IF EXIST "collect_*.TXT" (
blah blah blah
) else (
blah blah blah
)

means that

1. the parentheses in this statement...

echo Wscript.echo eval(WScript.Arguments(0))>"%cd%\evaluate.vbs"

and these...

cscript //nologo "%cd%\evaluate.vbs" "day(date)"
cscript //nologo "%cd%\evaluate.vbs" "month(date)"
cscript //nologo "%cd%\evaluate.vbs" "year(date)"

...need escaping, ^(with carets^) and...

2. without delayed expansion the variables d, m and yyyy will be set to blanks and thus result in "not expected at this time" messages when you do LSS GTR EQU etc comparisons

So the idea of using gotos is a good one.

Here is my version

Code: [Select]@echo off

IF not EXIST "collect_*.TXT" goto noinfo

echo Wscript.echo eval(WScript.Arguments(0))>"%cd%\evaluate.vbs"
For /f %%D in ( ' cscript //nologo "%cd%\evaluate.vbs" "day(date)" ' ) do set /a d=%%D
For /f %%M in ( ' cscript //nologo "%cd%\evaluate.vbs" "month(date)" ' ) do set /a m=%%M
For /f %%Y in ( ' cscript //nologo "%cd%\evaluate.vbs" "year(date)" ' ) do set /a yyyy=%%Y
del/q "%cd%\evaluate.vbs"
if %d% LSS 10 (set dd=0%d%) else (set dd=%d%)
if %m% LSS 10 (set mm=0%m%) else (set mm=%m%)
set TimeStamp=%yyyy%-%mm%-%dd

:noinfo
echo.
echo no information collected!

echo.
pause
exit

4923.

Solve : Copying files from hard drive to USB?

Answer»

but i assume the computer is XP+
and i will not help you shut down the prompt because it sounds slightly fishy
just USE googleanybody else getting a headache from the brick wall?if all this fighting continues
an admin should jsut lock or delete the threadQuote from: BC_Programmer on August 17, 2009, 09:21:42 PM

anybody else getting a headache from the brick wall?

I'm fine...wait what was the question ? ?
Is that you ToTo ? ?QUOTE from: stanko1610 on August 18, 2009, 06:05:54 PM
Ok. How it can be done to copy files to CD in background without promting?
I don't think you can copy files straight to a cd without burning. Quote from: Helpmeh on August 18, 2009, 06:08:50 PM
I don't think you can copy files straight to a cd without burning.

packet writing

Quote from: Salmon Trout on August 19, 2009, 12:17:40 AM
packet writing



good, so all that the OP needs to do is to invisibly check wether packet writing software is installed, if not, invisibly install it, then invisibly invoke it, then invisibly copy the files to it,after invisibly ENSURING a disc is present and if not invisibly asking the user to insert one, all while remaining invisible to the user for some unknown reason that I'm sure we can all fathom on our own. Quote from: BC_Programmer on August 19, 2009, 12:33:29 AM
good, so all that the OP needs to do is to invisibly check wether packet writing software is installed, if not, invisibly install it, then invisibly invoke it, then invisibly copy the files to it,after invisibly ensuring a disc is present and if not invisibly asking the user to insert one, all while remaining invisible to the user for some unknown reason that I'm sure we can all fathom on our own.
dont forget all in batch all in a batch file that somehow also runs invisibly, yes Of COURSE you can do it all in one line with awk.

whats awk?
i think the original poster should not ask for rediculus requestsQuote from: smeezekitty on August 19, 2009, 12:51:10 AM
whats awk?

Are you serious?!

PS it's "ridiculous".
4924.

Solve : Rename files with specific extension pattern?

Answer»

I’ve searched the forums on this site & couldn’t find ANYTHING conclusive. I need a DOS batch command similar to the one below to add a '.tif' extension to multiple files that have a specific pattern in their extension.

The DOS batch command line:
for %%i in (*.??) do REN %%i %%i.tif

For example, rename *.20080902 to *.20080902.tif in the same DIRECTORY as the batch file.

The only problem is that the above script renames all files in the directory (including the batch file 'ren2tif.bat').

The script needs to SKIP files that DO NOT have the 8-digit numeric format (i.e., *.yyyymmdd) in the extension.

Any ideas?ok, so this is a PRETTY sloppy way because it does not cover the whole 8 digit thing, but just finds if the files have 2008 or 200x in it.

Code: [Select]ren "*.2008*" "*.2008*.tif"
ren "*.2009*" "*.2009*.tif"
using asterisks to fill in the "void" of numbers will find all files with the "pre" file as a guide.

or, if i am wrong. please correct mekeep in mind, a rename of a pic.jpg to pic.tif does not change the format of the picture. The picture remains a jpg picture.

There are conversion programs that will change the format. And almost any image editor will allow you save a picture as a new format.

p.s. Until you are pleased with the new name use copy instead of ren or move. Good luckCode: [Select]for %%i in (*.2???????) do ren %%i %%i.tif
that should do it Thanks,

That worked. The solution looks so obvious now.

I changed the the batch file as follows:
for %%i in (*.20???) do ren %%i %%i.tif

This will rename any file produced this century. These are simply TIF images that get churned out by a CAD program & uploaded to a unix server. I needed this script to work for WINDOWS so we can review/print drawings before uploading them to our unix server. Some projects may over a hundred drawings so renaming them one by one is not practical!

To rename them back I just use:
ren *.20*.tif *.

4925.

Solve : Telnet using batch script?

Answer»

Hi,
I am trying to connect two telnet sessions using batch script.
After connecting one telnet session I have to enter login/password and then connect other telnet session from there.
I tried some thing like
@echo off
telnet 192.11.1.111
set /p login= ABCD
set /p password= ABCD1946
telnet 192.10.1.123

and ALSO using net use z: \\ServerName\ResourceName\ ABCD /user:Domain\ABCD1946
but I have to enter only login and password without any server name or resource name
Please suggest correct syntax for this.Any help would be appreciated.
telnet and windows command prompt are two different things.

both have different syntax.

Code: [SELECT]Microsoft Telnet> help

Commands may be abbreviated. Supported commands are:

c - close close current connection
d - display display operating parameters
o - open hostname [port] connect to hostname (default port 23).
q - quit exit telnet
set - set set options (type 'set ?' for a list)
sen - send send strings to server
st - status print status information
u - unset unset options (type 'unset ?' for a list)
?/h - help print help informationI am beginner so not ABLE to make it.Please suggest batch script for thisQuote from: BatchFileBasics on August 17, 2009, 01:28:05 AM

telnet and windows command prompt are two different things.
MAYBE so, but the OP asked if possible to automate the login of a telnet session, which sounds REASONABLY possible. Is there no way we can acheive this??Please help me out..try using putty.

much easier....interface.
4926.

Solve : Help...?

Answer»

I have a CODE...


@echo off
echo.
echo. Please Select the TASK you want to execute.
echo.
echo 1-Install SOFTWARES
echo 2-Install GAMES
echo 3-Play a game
echo.
set /p T= Select 1,2 or 3 and then press Enter:
echo.
If %T%==1 GOTO softwaremenu
IF %T%==2 GOTO gamesmenu
If %T%==3 GOTO playgame


Now if d USER types anything other than 1,2 or 3 the batch ends...
I want it to flash back a msg sayin to check no. entered & enter again....

Plz...help me...Try this.


Code: [Select]@echo off
:beginning
echo.
echo. Please Select the task you want to execute.
echo.
echo 1-Install SOFTWARES
echo 2-Install GAMES
echo 3-Play a game
echo.
set /p T= Select 1,2 or 3 and then press Enter:
echo.
If %T%==1 GOTO softwaremenu
IF %T%==2 GOTO gamesmenu
If %T%==3 GOTO playgame
cls
code here
pause
cls
goto :beginningAnd what about if they just press Enter?
Quote from: Salmon Trout on August 17, 2009, 05:56:35 AM

And what about if they just press Enter?

If its not 1, 2 or 3 then it loops.Quote from: Helpmeh on August 17, 2009, 05:58:24 AM
If its not 1, 2 or 3 then it loops.

In the IF test, since %T% is (hopefully) a string, if you don't have any "quotes" or .dots. or {spider brackets} etc around the input variable %T% and the comparison value then it will crash if just Enter is PRESSED. Enter is an empty string.

So, if just Enter is pressed -

If %T%==1 GOTO softwaremenu

expands

to

If ==1 GOTO softwaremenu

This will cause an error.

So do it like this

If "%T%"=="1" GOTO softwaremenu

Then if enter is pressed it expands to this

If ""=="1" GOTO softwaremenu



Ahh. Makes sense.
4927.

Solve : export registry?

Answer»

Hi there,

I have a weird problem, I can't manage to export the registry.

Actually, I manage to export the registry, by using reg export, or the regedit command, but when I open the registry FILES on A DIFFERENT computer, then I always get the error: "corrupted file" or SOMETHING. Everytime I open the file I see a lot of chinese/japenese characters. I know that it is normal if you use reg save that you see strange characters because the file is encrypted, but even with the regedit, where batch saves as a normal .reg I can't manage to open the file

Please help me, I really need a SOLUTION for THISI suggest using ERUNT...Quote from: patio on August 17, 2009, 06:34:18 AM

I suggest using ERUNT...

I forgot to mention that I cannot use third-party programs, sry.
But as seen as the option is built-in in windows, why shouldn't it work
4928.

Solve : Move file out of unknown subfolder(s)?

Answer»

Hi there,
I want to BACKUP my firefox profiles and with xcopy I can copy all the files, but the problem is the map structure is copied too. Now I want that all files from the profilesxxx folders are moved into one folder. The problem is: the xxx in profilesxxx is a random string so I can't just say "move profilesxxx onefolder"

Any IDEAS??

Tnx in forwardPlease describe how your Firefox profile folders are arranged. The default is one folder for each user called

%APPDATA%\Mozilla\Firefox\Profiles\xxxxxxxx.default\

where %APPDATA% translates to the following

Vista: C:\Users\\AppData\Roaming\

XP, 2000: C:\Documents and Settings\\Application Data\

In this folder you will find one or more folders with names like

nlqmgqma.default
p0js9db5.default

Are your profile folders set out like this?

Hi Salmon,

I have a similar problem, so I'm posting here, too.
We are working on XP, so our Mozilla profiles are in C:\Documents...\...\Profiles\xxxxxxx.default\.
We need to copy a CERTAIN file into that folder (for all users, on all machines), but I do not have a clue how to do that with DOS.

Any idea?

Thanks in advance!use wildcard.

copy *.default C:\Documents...\...\Profiles\


http://www.easydos.com/copy.html

"You can also combine files by using wildcard characters (? and *). To copy all files with a .DOC filename extension on drive C to a new file ALLDOCS on drive B, enter"

copy c:*.doc b:alldocs C:\Documents and Settings\Bill Richardson\Local Settings\Application Data\Mozilla\Firefox\Profiles&GT;



05/09/2009 07:11 AM .
05/09/2009 07:11 AM ..
08/15/2009 10:18 PM wphrcj55.default
0 File(s) 0 bytes
3 Dir(s) 307,326,705,664 bytes free

copy *.default D:\

( use copy instead of move until you know it works )Hi Bill,

thanks for your input, but I think we are talking about different things (maybe my explanation was poor...).
1. When Firefox is installed and started, the folder C:\Documents...\...\Profiles\xxxxxxx.default\ is created. This is the status of our machines which we cannot change...
2. One certain File shall be copied in a subdirectory of the xxxxx.default folder (or: into the xxxx.default folder on every machine).
3. I think the problem with copying inside DOS comes up only when I want to use a wildcard in the destination folder, not the source (and, especially, FOLDER).

Any more ideas?

Thanks a lot!
Quote

chobbes wrote:

"I think the problem with copying inside DOS comes up only when I want to use a wildcard in the destination folder, not the source (and, especially, FOLDER)."
[/color]

I have never used a wildcard as part of the destination folder or destination path.

There might be more restrictions with xcopy than copy?

Play with both copy and xcopy until they do what you need. I'd just use MozBack to backup a Firefox/TBird profile myself...

Directory of C:\Documents and Settings\Bill Richardson\Local Settings\Application Data\Mozilla\Firefox\Profiles

05/09/2009 07:11 AM .
05/09/2009 07:11 AM ..
08/15/2009 10:18 PM wphrcj55.default
0 File(s) 0 bytes
3 Dir(s) 307,320,496,128 bytes free

C:\Documents and Settings\Bill Richardson\Local Settings\Application Data\Mozill
a\Firefox\Profiles>cd wphrcj55.default

C:\Documents and Settings\Bill Richardson\Local Settings\Application Data\Mozilla\Firefox\Profiles\wphrcj55.default>dir
Volume in drive C is OS
Volume Serial Number is F4A3-D6B3

Directory of C:\Documents and Settings\Bill Richardson\Local Settings\Application Data\Mozilla\Firefox\Profiles\wphrcj55.default

08/15/2009 10:18 PM .
08/15/2009 10:18 PM ..
08/15/2009 10:18 PM CACHE
05/23/2009 12:59 PM Cache(2)
08/11/2009 09:01 PM OfflineCache
08/15/2009 10:18 PM 38,076,416 urlclassifier3.sqlite
08/11/2009 09:53 AM 2,260,858 XPC.mfl
08/15/2009 11:11 AM 1,018,170 XUL.mfl
3 File(s) 41,355,444 bytes
5 Dir(s) 307,320,471,552 bytes free

C:\Documents and Settings\Bill Richardson\Local Settings\Application Data\Mozill
a\Firefox\Profiles\wphrcj55.default>copy * C:\wphrcj55.default\
urlclassifier3.sqlite
XPC.mfl
XUL.mfl
3 file(s) copied.

C:\Documents and Settings\Bill Richardson\Local Settings\Application Data\Mozilla\Firefox\Profiles\wphrcj55.default>
4929.

Solve : Copying/Buring files into DOS?

Answer»

Ok, I'll open up with I'm VERY new to the computer experience, outside from game's, internet, and simple matinence. The man guiding me in this excellent experience GAVE me a test.

After a month and a half, I finally GOT a Pentium 3 to run windows 98, and have it fully operational. Now he want's me to get the setup files, onto my DOS, format the computer, and run the setup, and re-install windows 98, without the CD.

I could have BASTARDIZED what he told me. But any idea of what I'm talking about and what to do?

Thank's!The only way to do this without using the CD would be to copy the Windows i386 directory onto a freshly created partition...boot back into DOS...change drives to the new partition and run setup from there...
Is this Homework ? ?Now, I can make a partition once window's is already installed using the DOS correct?

It is in a way. But he said to use all mean's and recourses that I can to get this done.

That mean's you guy's=)Quote

Now, I can make a partition once window's is already installed using the DOS correct?

No. You misunderstood....the partition containing the i386 files would have to be created before the fact in order to install Windows...How WOUL I go about getting said i386 files onto the partition without having the OS installed?Quote from: NathanC on August 15, 2009, 10:45:42 AM
How woul I go about getting said i386 files onto the partition without having the OS installed?

Custom bootable CD or pen drive maybe...Quote
Custom bootable CD or pen drive maybe...

I have neither..
4930.

Solve : Determine which Multi-line missing Corresponding line?

Answer»

I have a text file which contains some type of LOG, I want to parse the file for a corresponding line, EG.,

archiving abc1
inflating abc1
some type of garbage
some type of garbage
some type of garbage
archiving abc2
inflating abc2
some type of garbage
archiving abc3
inflating abc3
some type of garbage
archiving abc4
some type of garbage
archiving abc5
inflating abc5
some type of garbage
archiving abc6
inflating abc6
some type of garbage
archiving abc7
some type of garbage
archiving abc8
inflating abc8
some type of garbage
some type of garbage

For each of the above line which has "archiving abcN", I want to know which one is missing the second half of the MESSAGE. From the above, you can see that "archving abc4" is missing "inflating abc4" line.
if you can download gawk for windows(see my sig), its a piece of cake to do

Code: [Select]C:\test>gawk "/archiving/{s=$NF;getline;if($0!~/inflating/){print \"no inflating \"s};next}" file
no inflating abc4
no inflating abc7
Thanks for posting the UNIX like utility to use. I wish I knew how to do this when I was writing some UNIX scripts awhile back, it WOULD've made life easier.

4931.

Solve : NC?

Answer»

hi
does some BODY knows how to USE NORTON Commander (NC) to MAKE a network between a DOS 6.22 &AMP; a XP. of course NC is installed on both of them.
thanks

4932.

Solve : Win/Batch: Date/Time question?

Answer»

Hi,

I am going to use batch FILE to rename group of folders with timestamp so that I can perform backup and hosue-keeping tasks.

My current regional and language setting for date/time is dd/MM/yyyy and h:mm:ss respectively.

Therfore the name of folder would be xxxx_dd-MM-yyyy[hh.mm']

Here is the code:

@echo off
for /f "tokens=1-3 delims=/- " %%a in ("%date%") do set XDate=%%a-%%b-%%c
for /f "tokens=1-3 delims=: " %%d in ("%time%") do set Xtime=[%%d.%%e']
set TimeStamp=%XDate%%XTime%
mkdir "%CD%\xxxx_%TimeStamp%"
move/y test*.TXT "%CD%\xxxx_%TimeStamp%" > nul


However, if I changed to different date/time format, the name would be changed accordingly.
for example:
yyyy/MM/dd will create a folder name with format of xxxx_yyyy-mm-dd[hh.mm']

Is it possible to create a timstamp as dd-MM-yyyy[hh.mm'] from different date/time setting ?

Thanks,
Thomaswell if you are asking what i think you are, you would take
Code: [Select]for /f "tokens=1-3 delims=/- " %%a in ("%date%") do set XDate=%%a-%%b-%%c
and rearrange %%a %%b %%c accordingly
%%a = day
%%b = month
%%c = year


correct me if im not understanding your question?Sorry, it is not I want.

Actually, my batch code will be used in other PC clients but I don't know what
Date/Time setting they are using.

Therefore, I'm afraid that the generated Date/Time format
would not be what I expected.

I think using system variables ("%Date%") and ("%Time%") only get the Date/Time format according to the setting in Regional and Language setting.

I wonder whether there is a way to get the fields of yyyy, MMM, and dd
from system clock so that I can format to a proper format.

Thanks,
Thomas ok, with an intense 10 minutes of searching google, i have came upon this:
which at the end, gives out the year(yyyy) month(mm) day(dd) and day of week(dow)
Code: [Select] @echo off
if %1/==:/ goto %2
if NOT %1/==/?/ goto Begin
for %%C in (echo. goto:End) do %%C
:Begin --------------------------------------------------------------
echo. | date | FIND "(mm" > NUL
if NOT errorlevel 1 %0 : %OS%Parse MM DD
%0 : %OS%Parse DD MM
:Windows_NTParse ----------------------------------------------------
for /F "tokens=1-4 delims=/.- " %%A in ('date /T') do if %%D!==! (
set %3=%%A&set %4=%%B&set YYYY=%%C
) else (
set DOW=%%A&set %3=%%B&set %4=%%C&set YYYY=%%D)
goto End
:Parse --------------------------------------------------------------
for %%C in (md cd) do %%C @[emailprotected]
echo @prompt set _D=$D$_> ~tmp1.bat
%COMSPEC% /e:2048 /c ~tmp1.bat > ~tmp2.bat
call ~tmp2
echo %_D% | FIND "/" > NUL
if NOT errorlevel 1 goto Slash
lfnfor on > "%_D%.-"
ren "%_D%.-" "??? ?? ?? ????"
for %%F in ("??? ?? ?? ????") do set _D=%%F
lfnfor off
:Slash
echo set DOW=%%%3%%>~tmp1.bat
for %%S in ("%3=%%%4%%" "%4=%%YYYY%%" "YYYY=%%1") do echo set %%S>>~tmp1.bat
for %%S in (%_D%) do call ~tmp1 %%S
echo %_D% | FIND "/" > NUL
if errorlevel 1 goto Cleanup
echo @prompt set %4=$%%%4%%$_set YYYY=$%YYYY%$_ > ~tmp1.bat
%COMSPEC% /e:2048 /c ~tmp1.bat > ~tmp2.bat
call ~tmp2
:Cleanup
for %%C in ("set _D=" cd.. "deltree /y @[emailprotected] > NUL") do %%C
:End ----------------------------------------------------------------
echo YYYY=%YYYY% MM=%MM% DD=%DD% DOW=%DOW%
pauseYou can get the day, month and year in a standard format, independent of the local settings, in Visual Basic Script. It is quite easy to do this from a batch file. A one-line VBS script can be created "on-the-fly", used to get the day, month and year, and then deleted. the VBS Day(Date) and Month(Date) FUNCTIONS return a single figure if the day or month is before the 10th so we can add a leading ZERO in these cases to get the dd mm and yyyy format.

Code: [Select]@echo off
echo Wscript.echo eval(WScript.Arguments(0))>"%temp%\evaluate.vbs"
For /f %%D in ( ' cscript //nologo "%temp%\evaluate.vbs" "day(date)" ' ) do set /a d=%%D
For /f %%M in ( ' cscript //nologo "%temp%\evaluate.vbs" "month(date)" ' ) do set /a m=%%M
For /f %%Y in ( ' cscript //nologo "%temp%\evaluate.vbs" "year(date)" ' ) do set yyyy=%%Y
del "%temp%\evaluate.vbs"
if %d% LSS 10 (set dd=0%d%) else (set dd=%d%)
if %m% LSS 10 (set mm=0%m%) else (set mm=%m%)

echo dd %dd%
echo mm %mm%
echo yyyy %yyyy%
echo dd-mm-yyyy %dd%-%mm%-%yyyy%
echo dd/mm/yyyy %dd%/%mm%/%yyyy%
echo yyyymmdd %yyyy%%mm%%dd%Thank you for your suggestions.

Chris(BatchFileBasics) codes still does not fit my requirement.
I had tested with different Date/Time setting but generated
different format. for example:
it gives YYYY=Sun MM=09 DD=08 DOW=16 for d/MM/yy
but it gives YYYY=16 MM=08 DD=2009 DOW= for yyyy/MM/dd

Any ideal?

Salmon's code works FINE, but my clients' working
environment does not allow to use VBscripts.

Thanks,
Thomas

4933.

Solve : dos task number?

Answer»

im taking a class right now that has alot to do with using dos command prompt and in my homework it says to do a few commands then to "type in the task number and the commands i used to create directories"...what is the task number and how do i know what it is? ive looked around google and cant seem to find anything on it...can SOMEBODY please help me?
PID is the Process IDentification number
C:\>tasklist

Image Name PID Session Name Session# Mem Usage
========================= ====== ================ ======== ============
System Idle Process 0 Console 0 28 K
System 4 Console 0 240 K
smss.exe 776 Console 0 424 K
csrss.exe 1120 Console 0 4,300 K
winlogon.exe 1288 Console 0 2,960 K
C:\>mkdir /?
Creates a directory.

MKDIR [drive:]path
MD [drive:]path

If Command Extensions are enabled MKDIR changes as follows:

MKDIR creates any intermediate directories in the path, if needed.
For example, assume \a does not exist then:

mkdir \a\b\c\d

is the same as:

mkdir \a
CHDIR \a
mkdir b
chdir b
mkdir c
chdir c
mkdir d

which is what you would have to type if extensions were disabled.

Quote from: xbabyboy4021x on August 12, 2009, 11:39:39 PM

im taking a class right now that has alot to do with using dos command prompt and in my homework it says to do a few commands then to "type in the task number and the commands i used to create directories"...what is the task number and how do i know what it is? ive looked around google and cant seem to find anything on it...can somebody please help me?

Do your own homework. We don't provide homework assistance here.Quote from: Quantos on August 15, 2009, 07:43:03 PM
Do your own homework. We don't provide homework assistance here.

errr. yes we do...


In either case- I think the "task number" might be akin to a "question number" or something, since I don't see a PID or process handle being applicable to something as simple as creating folders.Not according to Nathan.Quote from: Flame on April 03, 2006, 05:46:46 PM
Just for any other people out there who need homework help, one or two questions is ok usually, but please, for the love of God, Google it first, READ your textbooks, do your PART! All I gotta say

Flame

they googled. Besides, they aren't asking for help DOING the homework, they're asking what a "task number" is.Okay, just checking, remember I'm new here too and still getting accustomed...
4934.

Solve : Calling Batch file not shows echo message?

Answer»

Hi,

I have Parent file DEL_FOLDER.BAT which call Del_archive.bat file .

Batch file Del_archive.bat CONTAIN a question for user to delete or not the archive file like

SET /P Option=Do you REALLY want to delete all previous month Backup folders (Y/N)=: -^>
IF NOT '%Option%'=='' SET Option='%Option%'


if %Option%=='Y' goto :menu1
if %Option%=='y' goto :menu1
if %Option%=='N' goto :menu2
if %Option%=='n' goto :menu2
echo "%Option%" is not valid choice then try again......
goto :menu4


but when I tried to ran DEL_FOLDER.BAT parent file then the question from child file doesn't appear on screen.
CODE for DEL_FOLDER.BAT
CALL Del_archive >%LOG_FIL%


What is missing in the code?Quote

code for DEL_FOLDER.BAT
CALL Del_archive >%LOG_FIL%

You are calling Del_archive and redirecting output to %LOG-FIL% so the Set /p command in Del_archive writes the question to %LOG_FIL% instead of the screen where you expect to view it.

What kind of file is %LOG_FIL%. If it's text I could GIVE you some code to show the contents of %LOG_FIL% on the screen.Quote from: BatchFileCommand on August 15, 2009, 12:35:06 PM
What kind of file is %LOG_FIL%. If it's text

I think that is pretty certain, given that it is the output of a batch file.
4935.

Solve : batch file to run on last day of the month...?

Answer»

good day,

i have a batch file that i have made slowly over the past months to do backups, with help from here, and several other websites. i want to update the batch file to backup up some other FOLDERS but only need that part of the batch file to run if it is the last day of the month.

ex. currently i back up C:\DOCS every day. But if it's the last day of the month, i want it to back up C:\TOSHIBA along with the C:\DOCS folder. can that be done, or is it easier to write the code to do it on the first of the month (last day of the month varies as ending on the 28th, 29th, 30th and 31st.

I was thinking just write another batch and run it on the first of every month to do the monthly backup, but the daily backup creats a log file, and when that back up is done, it reboots the system. i do not want the system to reboot while the monthly backup is still being performed.

any ideas?

jat
This combination of VB Scripting and batch commands should do what you want. The VB script gets tomorrow's day-of-month number and passes it to the FOR command which sets the NewDay variable. Should be run on the last day of each month. I have done some testing in XP but you should confirm...

Quote

@ECHO off
cls

set vbsfile=%temp%\newdate.vbs

echo Newdate = (Date()+1)>%vbsfile%
echo Dd = DatePart("D" , Newdate)>>%vbsfile%

echo Wscript.Echo Dd>>%vbsfile%

FOR /F %%A in ('cscript //nologo %vbsfile%') do (
set NewDay=%%A
)
del %vbsfile%

echo %NewDay%

IF %NewDay% NEQ 1 GOTO Docs

{backup commands for C:\TOSHIBA here}

:Docs
{backup commands for C:\DOCS here}


Code: [Select]if exist ME del ME
Mshta VBScript:Execute("If Month(Now)<>Month(DateAdd(""d"",1,Now)) Then CreateObject(""Scripting.FileSystemObject"").CreateTextFile(""ME""):END If:Close")

if not exist ME goto Docs
del ME
{backup commands for C:\TOSHIBA here}

:Docs
{backup commands for C:\DOCS here}And another which uses the Doff.exe utility from this site..

Code: [Select]@echo off
cls

for /f %%a in ('doff dd +1') do (
if %%a neq 1 goto docs
)

{Toshiba backup commands here}

:docs
{Docs backup commands here}

Good luckhave used the following for exactly what your doing, used it for 2 different
small businesses I supported...worth a look at:

http://www.karenware.com/powertools/ptreplicator.asp

fully automated alsoThis really useful tool. Thanks a lot for the postQuote from: Prince_ on November 27, 2008, 01:22:42 AM
Code: [Select]if exist ME del ME
Mshta VBScript:Execute("If Month(Now)<>Month(DateAdd(""d"",1,Now)) Then CreateObject(""Scripting.FileSystemObject"").CreateTextFile(""ME""):End If:Close")

if not exist ME goto Docs
del ME
{backup commands for C:\TOSHIBA here}

:Docs
{backup commands for C:\DOCS here}

i have this in my code as follows:

@echo off
set folder=%date:~0,3%

ECHO %date%, %time% Checking connections, please wait... > C:\BackUpHistory\Report.txt

ECHO %date%, %time% Checking to see if www.google.ca can be reached... >> C:\BackUpHistory\Report.txt
PING -n 3 www.google.ca >> C:\BackUpHistory\Report.txt|find "Reply from " >NUL

:if exist ME del ME
Mshta VBScript:Execute("If Month(Now)<>Month(DateAdd(""d"",1,Now)) Then CreateObject(""Scripting.FileSystemObject"").CreateTextFile(""C:\BackUpHistory\ME""):End If:Close")

if not exist "C:\BackUpHistory\ME" goto Finish
del "C:\BackUpHistory\ME"
ECHO ------------------------------------------------------- >> C:\BackUpHistory\Report.txt
ECHO %time% Initiating monthly cleanup >> C:\BackUpHistory\Report.txt
FOR /D %%G IN ("C:\Documents and Settings\*.*") DO DEL/S/Q/F "%%G\Cookies\*.*"
FOR /D %%G IN ("C:\Documents and Settings\*.*") DO DEL/S/Q/F "%%G\Local Settings\Temp\*.*"
FOR /D %%G IN ("C:\Documents and Settings\*.*") DO DEL/S/Q/F "%%G\Local Settings\History\*.*"
FOR /D %%G IN ("C:\Documents and Settings\*.*") DO DEL/S/Q/F "%%G\Local Settings\Temporary Internet Files\*.*"
ECHO %time% Finished cleaning up internet explorer >> C:\BackUpHistory\Report.txt
:Finish
for /f "tokens=1-6 delims=/: " %%d in ("%date%" "%time%") do rename "C:\BackUpHistory\Report.txt" %%g-%%e-%%f(%%d)@%%h%%i.txt

:END

it was tested and does work in a batch file format (this is only part of the entire code). i convert the file to an exe file using a batch file to exe converter. when the exe file is run, the code does not run COMPLETELY. the reporting stops at the following line:

Initiating Monthly cleanup

there is nothing after this line.

any suggestions?

thank you,

jat
Quote from: kalasha on August 13, 2009, 11:12:03 PM

any suggestions?

thank you,

jat


Yes. Do not use or rely upon batch-to-exe converters. They generally only work with a limited subset of batch language. They are a kludge.

Get tomorrow's day number

Employ one-line vbs to determine date of tomorrow, yesterday, 999 days time/ago (whatever)

Code: [Select]@echo off

echo Wscript.echo eval(WScript.Arguments(0))>"%temp%\evaluate.vbs"

REM put date difference in a variable
REM tomorrow is +1
REM today is +0
REM yesterday is -1
set diff=+1

REM set trigger number in a variable
set trigger=1

For /f %%D in ( ' cscript //nologo "%temp%\evaluate.vbs" "day(date%diff%)" ' ) do set daynum=%%D

del "%temp%\evaluate.vbs"

if "%daynum%"=="%trigger%" (
do stuff
)

4936.

Solve : boot disk?

Answer»
yes I have a windows 98 . I just tried to install and after 22 minutes 77% file copy it gives me suewin an ERROR occured . I choose to ingnore and show application error caused in general protection fault in module verx.dll so i CLOSE and it ended SETUP.
4937.

Solve : temporary file in DOS?

Answer» HELLO all,
I want to create a dummy file that have faster read/write access in batch SCRIPT. Could temporary file help me in this situation? If so i want to know about the details

Thank you
Please explain more clearly what you want to know.Decrease read/write TIMES? Unless the file is WITHIN hundreds of folders in another drive, you probably won't notice the SPEED.
4938.

Solve : shutdown issue?

Answer»

I am working on a shut down bat that will shutdown a list of computers remotely. I am having issues getting it to work correctly. I have narrowed the issue down to the shut down command. Any IDEAS on what the cause of the issue might be? It will hit the shutdown command and then loop back to the :SHUT portion of the bat.

Code: [Select]@ECHO OFF
CLS

ECHO THIS WILL SHUTDOWN THE COMPUTERS.....
ECHO.
ECHO.


REM CHECKING TO SEE IF SHUTDOWN LIST EXISTS

IF EXIST "%TEMP%\SMOShutDown.TXT" DEL "%TEMP%\SMOShutDown.TXT"




REM THIS SECTION IS ALL OF THE SYSTEMS THAT WILL BE SCHEDULED TO BE SHUTDOWN

ECHO DOTVCOSMO3>"%TEMP%\SMOShutDown.TXT
ECHO DOTSCOSMO2>>"%TEMP%\SMOShutDown.TXT



REM USE SMOShutDown.TXT IN A FOR LOOP

FOR /f "delims==" %%A IN (C:\DOCUME~1\%USERNAME%\LOCALS~1\Temp\SMOShutDown.TXT) DO SET A=%%A& CALL :SHUT %%A


REM CLEANING UP FILES

IF EXIST "%TEMP%\SMOShutDown.TXT" DEL "%TEMP%\SMOShutDown.TXT"
GOTO EOL


:SHUT
:LOOPSH
SET errorlevel=
ECHO TESTING %A%

REM TEST TO SEE IF SYSTEM IS ACTIVE

ping -n 1 %A% > nul
ECHO %errorlevel%


REM PING ERRORLEVEL OF 0 MEANS SUCCESS
REM PING ERRORLEVEL OF 1 MEANS THE HOST IS NOT FOUND OR TURNED OFF

IF NOT %errorlevel%==0 GOTO OFF


REM PROCEEDING WITH SYSTEM SHUTDOWN
pause
SHUTDOWN -s -f -m \\%A% -t 05 -c "SMO SYSTEM SHUTDOWN DUE TO HEAT"

ping -n 1 -w 25000 1.1.1.1 > nul

GOTO LOOPSH




:OFF

ECHO SYSTEM %A% HAS BEEN SHUTDOWN.....
ping -n 1 -w 500 1.1.1.1 > nul

:EOL

thanks,
WayneThis behavior can occur if the Unlock Computer dialog box appears on the desktop, or if the computer is locked.

http://support.microsoft.com/kb/317371

Quote from: Salmon Trout on July 21, 2009, 01:46:40 PM

This behavior can occur if the Unlock Computer dialog box appears on the desktop, or if the computer is locked.

http://support.microsoft.com/kb/317371



this is not the behavior of the issue I am seeing. If you WISH you can copy and RUN the bat. You just need to change the system names.

when the batch gets to the shutdown command it will loop back to the top of the :SHUT portion and continue to loop. it will not process past the shutdown command. any ideas?If you enable echo, what messages do you see?
it will hit the shutdown command then go back to the :SHUT portion and continue from there. there are no error messages. If I rem out the shutdown command the batch will continue to process correctly. If I copy the command from the batch file and paste it into a cmd window the command will work correctly. That is how I know there is an issue with the batch file and this command.Is the %A% variable being expanded correctly?

what happens if you put echo %errorlevel% straight after the shutdown LINE?
Quote from: Salmon Trout on July 21, 2009, 02:14:11 PM
Is the %A% variable being expanded correctly?


yes it is because I see it when it runs the following line:

Code: [Select]ECHO TESTING %A%

Quote from: Salmon Trout on July 21, 2009, 02:14:11 PM

what happens if you put echo %errorlevel% straight after the shutdown line?


nothing because the lines after the shutdown command do not process.

It is strange because if I enter each command in to a cmd window they work correctly. But, if I run the batch the shutdown command creates a loop.
4939.

Solve : How can I retrieve partition information like free space with MS-DOS Command?

Answer» HELLO!
I'm a beginer using MS-DOS Commands, I Need to retrieve information about Disks, PARTITIONS or Volumes with MS-DOS Commands to integrate the output with an aplication.

Can you help me????Welcome to the CH forums.

You don't indicate which OS you are using, in XP Fsutil is available to return lots of info.

TRY FSUTIL VOLUME DISKFREE C: to return the partition size and freespace of C: in bytes.

Fsutil and Command-line reference info is available here..

Good LUCK.
4940.

Solve : Replace integrity of many files with one?

Answer»

Good morning, I have a very daunting task before me that I really could use some help with. I have 652 files named in an increasing sequence “startofthefilename000_000” the 000_000 change. My problem is I need to take one file and replace the integrity of the 652; while keeping their naming convention of course.

I have a few years programming experience, and networking but its been years since I have touched dos. I have windows XP, is there anyway I could use Replace with wild cards or some other command from the windows Command Prompt to do this? Or could a batch file be able easily accomplish this?

I would greatly appreciate any help,Could you please explain what you mean by the "integrity of the 652"? In fact, could you please explain much more clearly what it is that you want to do?

I have 6 folders, with a total of 652 files. To simplify things I'll just deal with one.

The folder is called small and it has 310 files in it are "small00_00" followed by "small00_01" up through "small00_09" then next file is "small01_00" this goes up to "small29_09". They are different color textures, I need to bland things out by replacing each of them with the same color. So I meant integrity as the files contents being changed.Thank you. Please confirm that I understand properly.

You have a number of folders. Each folder contains a number of files. They are different. You want to change them so all the files have the same contents as each other, but preserving their former filenames?

Correct, you hit the nail right on the head. So... you want to do this, I think?

For each file in a folder:

delete (Query: or rename?) the file?
create a new file with the same NAME
place in that file some standard contents (Query: unique to that folder, or the same for all 652 files?)

There are a number of tools that can be used to do this. A batch file, or a Visual Basic Script (VBS), or another tool such as awk or perl or others still. I know how to do this sort of thing in a batch file, but other people can probably suggest much more elegant SOLUTIONS using the other tools I have mentioned. Please, THEREFORE, state your preference.

Great to hear, I dislike VB, a batch file would work well.

Quote from: Salmon Trout on July 21, 2009, 10:35:12 AM

(Query: unique to that folder, or the same for all 652 files?)

Unique to that folder.So you might have a folder called small and a file called small_new (in that folder?) and you WISH to MAKE all the other files identical to that?

That would be perfect!You did not answer whether you wish to destroy or preserve the previously existing files.
I apologize, I would wish that they are destroyed. Suppose you call this file MakeAllSameAs.bat and

place it in a folder containing the files to be altered and the file to be copied to each

open a command window in that folder and type its name followed by the name of the file to be copied e.g.

MakeAllSameAs "small_new"

Code: [Select]@echo off
set repfile=%~1
echo Replacement file: %repfile%
for /f "delims=" %%F in (' dir /b ^| find /v "%repfile%" ^| find /v "MakeAllSameAs.bat" ' ) do (
Echo Replacing %%F
del "%%F"
copy "%repfile%" "%%F"
)


It works, thank you very much. This is very exciting!!!Quote from: Salmon Trout on July 21, 2009, 11:48:59 AM
Suppose you call this file MakeAllSameAs.bat and

place it in a folder containing the files to be altered and the file to be copied to each

open a command window in that folder and type its name followed by the name of the file to be copied e.g.

MakeAllSameAs "small_new"

Code: [Select]@echo off
set repfile=%~1
echo Replacement file: %repfile%
for /f "delims=" %%F in (' dir /b ^| find /v "%repfile%" ^| find /v "MakeAllSameAs.bat" ' ) do (
Echo Replacing %%F
del "%%F"
copy "%repfile%" "%%F"
)



you can use findstr, then you don't need to pipe to find 2 times
Code: [Select]for .... ( dir /b .. | findstr /v /c:string1 /c:string2 ) do (... )
4941.

Solve : Batches file window flashes on and off quickly when run?

Answer»

Can anyone tell me why this BATCH file's window flashes on and off quickly when it is run, it is supposed to write a password to the desktop but for some reason it has stopped doing so.
any help is much appreciated

@echo off
set sDate=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%
set aux=%sDate%

set sDate=

:LOOP
if "%aux%"=="0" goto END
set last_digit=%aux:~-1%
set sDate=%sDate%%last_digit%
set /A aux=%aux%/10
goto LOOP

:END

set /A div=2260
set /A integer=%sDate%/%div%
set /A remainder=(%sDate% - %div%*%integer%)%%div%
set /A fracc=10000*%remainder%/%div%
if %fracc% lss 999 set fracc=0%fracc%


setsol=%fracc%
echo %fracc%
echo password = %sol% >"C:\Documents and Settings\genie\Desktop\Password.txt"
pause



Thanks
Geniewell HERES what you could do,
take out @echo off, open command prompt then run your batch from there:

c:\> "C:\path\of\file.bat"

and you should get all your syntax etc. it should tell why it stopped. i.e. Sysntax is incorrect.

the lines above that should be the errors that caused itThanks BFB,
I did as you suggested and it came up with these errors at the end. I'm a newbie here and am not sure what's GOING on. It appears to be date related as some days it will run fine but I'm clueless as to how to fix it. again your help is much appreciated. The program is supposed to take the present date (year,month, day) then reverse the numbers and divide by 2260. The four digits after the decimal point of the answer is what should be displayed on the screen if everything runs correctly

Genie
...........
C:\> set /A integer=02709002/2260
invalid number. Numeric constants are either decimal (17),
hexadecimal (0x11), or octal (021)

C:\>set /A remainder=02709002 - 2260*)%div
invalid number. Numeric constants are either decimal (17),
hexadecimal (0x11), or octal (021)

C:\>set /A frac=1000*/2260
Missing operand.
999 was unexpected at this time.

C:\> if 1ss 999 set fracc=0well for the first two,

CODE: [Select]invalid number. Numeric constants are either decimal (17),
hexadecimal (0x11), or octal (021)
you cannot have a 0 in front of your value, to shorten it,
youll take your original code:

Code: [Select] set /A integer=%sDate%/%div%
change it to:

Code: [Select] set /A integer=%sDate:~1,20%/%div%
starts after the first char(in this case its a 0) and stops after 20th char(set as you like, but 20 is so it will always show the val)

so it WOULD look like Code: [Select]2709002thanks BFB , that worked wonderfully

best regards
Genie

4942.

Solve : Batch file to check the contents in a file?

Answer»

I would like to find a particular word in a text file and check if the word is available in the other text file
C:\>findstr /n /o particular *.txt

textfileone.txt:1:0:particular word

textfiletwo.txt:1:0:particular word

C:\>TYPE textfileone.txt
particular word
C:\>C:\>type findstring.bat
Code: [SELECT]@echo off

Rem Use COMMAND line argument to search for any word

findstr /n /o %1 *.txtC:\>findstring.bat particular
textfileone.txt:1:0:particular word

textfiletwo.txt:1:0:particular word
C:\>REM From the root directory, search the complete disk for the word. In this case the word is "support" The /s option will search all sub directories
The wc -l counts how many times "support" occurred on the disk in a *.txt ( text ) file. Correction: It is only counted one TIME for each file when using the /m option

Code: [Select]findstr /s /m support *.txt | wc -l

517Hey, thanks for the update...

Can you help me to put this in a if condition ....

I have a batch file batch1.bat and two text files first.txt and second.txt file

Batch1.bat should have if statement to check if a particular word is there in first.txt, if available SEND "Success" to second.txt file

Thanks in advanceSureShred,

C:\>type Batch1.bat
Code: [Select]@echo off

REM Use Batch1.bat particular

echo. > second.txt
type second.txt

echo %1 > first.txt

findstr particular first.txt

if %errorlevel%==0 echo Success > second.txt

type second.txt
Output:

C:\>Batch1.bat bad


C:\>Batch1.bat particular

particular
Success
C:\>it works.

Thanks a lot billrich

4943.

Solve : A problem that's too long to explain in this title?

Answer»

As the title states, my BATCH problem is too long to simply write in the title. I have tried everything and I can't figure out how to do this. So, here's my problem:
I have a program that GENERATES a code, specifically with a STRING of numbers divided by underscores.
(there won't be any strings with matching numbers) Example : 1_2_3_4_5, 2_7_4_9_0 etc. So I have a folder filled with text files with titles containing the same kind of string, none of the strings match. But here's what I would like to do: take a random string like 1_3_5_7_9 and see how many matching numbers the two strings contain. I have tried experimenting with the for command but everything I try fails. This one is more difficult then what I normally do as it requires more extensive knowledge and use of the for command. Quote from: BatchFileCommand on August 13, 2009, 10:12:55 PM

As the title states, my batch problem is too long to simply write in the title. I have tried everything and I can't figure out how to do this. So, here's my problem:
I have a program that generates a code, specifically with a string of numbers divided by underscores.
(there won't be any strings with matching numbers) Example : 1_2_3_4_5, 2_7_4_9_0 etc. So I have a folder filled with text files with titles containing the same kind of string, none of the strings match. But here's what I would like to do: take a random string like 1_3_5_7_9 and see how many matching numbers the two strings contain. I have tried experimenting with the for command but everything I try fails. This one is more difficult then what I normally do as it requires more extensive knowledge and use of the for command.

EH, this is quite complicated,
Batch files need specific dirrections and information to perform opperations,
Just out of pure currosity and to help with this investigation, what exactly is your batch file destined to do? As in its purpose.after reading your essay, i still don't understand what you are trying to do. Give examples and show your final output.Quote from: BatchFileCommand on August 13, 2009, 10:12:55 PM
here's what I would like to do: take a random string like 1_3_5_7_9 and see how many matching numbers the two strings contain.

You want to examine each filename and see if it contains one or more of (for example) 1, 3, 5, 7 or 9?

something like this

need delayed expansion
for blah blah blah %%F in ('dir /b') do
set filename=%%F
for /f "tokens=1-5 delims=_" %%A in ("!filename!") do (
echo !filename! | find "%%A" && echo found %%A
echo !filename! | find "%%B" && echo found %%B
etc
)
)




IF YOU WANT A BETTER DESCRIPTIONG OF WHAT I WANT TO DO SKIP THE FIRST SECTION!

I figured out how to do it!
1, set both strings to variables like %1% and %2%.
and do the following: %1:~0,2% I would set that to a variable like %n1% which stands for number 1.
do the same thing again : set n2=%1:~2,4%
then repeat the process for the other 3 numbers and the second string! Then
using lots of if commands (MAYBE for loops) I would simply see how many numbers match!
_______________________________________ ___________________________________

Okay, so this is what I wanted to do take 2 strings like
1_4_9_2_5
and
5_9_7_5_4
and see how many numbers matched between the two of them. in this case it would be 3.

4944.

Solve : XCOPY question`?

Answer»

I've searched for an answer to this but haven't come across it. I apologize in advance if I just missed it.

I'm USING the following to copy files from the local hard drive to a USB drive:

XCOPY c:\Database_Backup\*.* E:\Database_Backup\*.* /D /S /Y

It will copy several .bat files that are in that directory but then ERRORS out when it gets to the first .bak file I have with:

File creation error - The parameter is incorrect.

I tried several of the variations to this that I found in this forum but get the same error. The interesting thing to me is that I USE the exact same batch file command to copy files from a mapped drive to the local drive and all works correctly.

Thanks in advance for any help you can provide.

DaveSorry, I think I found the problem. When COPYING the file through windows I get an error that tells me the file is too large for the destination drive. I has plenty of room on it so I must have a DIFFERENT problem not related to the DOS command.

4945.

Solve : key word search?

Answer»

Background information:
I am writing a batch program, which can search the employee.txt file and through the result based on the user input. EXAMPLE, One user may enter Department as a key WORD and see all the EMPLOYEES in the department. In another case he may enter name as the keyword to find the department. I have used the "findstr" command for the case above. Also I have CREATED a shortcut and changed the Target variable name.

When the user click the shot cut icon, he will get a dos screen and he will type emp HR to see all HR employee. (FYI - Bath file name is emp.bat)

Help required:
Here I do not want the user to enter the batch file name and the keyword. The user should simply click the icon and enter the key word directly and the batch files should do the rest.

Thanks in advance

Rangsha
Use command line options or a menu:

emp.bat HRThanks, But my point here is, I do not want the user to see the batch file name.try MAKING a shortcut to it?

4946.

Solve : batch help filename?

Answer»

How WOULD I find out the name of the batch file that's running the current command?

i.e. If I run abc.bat, what command would return the value of "abc.bat"?%1-9 are the parameters paseed to a batch file.

%0 is the batch file itself.
Quote from: justaguylooking on August 13, 2009, 09:29:37 AM

%1-9 are the parameters paseed to a batch file.

%0 is the batch file itself.


More exactly, it is the command line that called it.

If this is myname.bat:

Code: [Select]@echo off
echo %0

If you are in the same folder and you type myname.bat, you will see "myname.bat" echoed to the screen. If you type "myname" it will echo "myname". This behaviour also occurs if you save it to a folder on your PATH and call it by either of these two methods.

If you type the WHOLE path e.g. "C:\batch\myname.bat", then that is what %0 will be. If you open the folder in Windows Explorer, and double click on the batch file's ICON, %0 contains the full drive, path, name and extension, surrounded by quotes.

To avoid this ambiguity, you can get the name, extension, path and drive by using the %~d0, %~dp0, %~nx0 etc variable modifers DESCRIBED in the FOR documentation. For example the drive LETTER, path, name and extension is %~dpnx0

4947.

Solve : How to realize the dos raw input?

Answer»

In fact, I have a .EXE file which want to be executed by dos COMMAND, and I need to input the directory which "" should be included , just like Path = "C:\test\simple.dll", but after the .exe file executed, the result is only Path = C:\test\simple.dll, so do you know how to realize the raw input which won't filter my """.
Any ideas? Thanks in advance!Dir D:\Test

That will get a directory of the folder "Test" within the D drive. I am sorry, maybe I did not express clearly...
infact, I have a .exe file which want to be executed by dos command, and I need to input the directory which should be included "", just like Path = "C:\test\simple.dll", but after the .exe file executed, the result is only Path = C:\test\simple.dll, so do you know how to realize the raw input which won't filter my """.

Quote from: Helpmeh on August 13, 2009, 05:14:55 AM

Dir D:\Test

That will get a directory of the folder "Test" within the D drive.
OHHH! Now it makes sense. Put the command in quotes (and the command's path) and put the path to SOMETHING else in different quotes. For example:

"C:\folder name\prog.exe" "D:\other folder\"


Understand?Hi, thanks for help!!
I am not quite understand what you mean...here are more details:

first I input :the "Selected DLL="D:\testsimu0158.dll"" is the input PARAMETER of line_replace.py
D:> python line_replace.py "Selected DLL="D:\testsimu0158.dll""

The output is:
Selected DLL=D:\testsimu0158.dll

but I need : Selected DLL="D:\testsimu0158.dll"

Any ideas ? Thank you very much!

Quote from: Helpmeh on August 13, 2009, 05:28:46 AM
OHHH! Now it makes sense. Put the command in quotes (and the command's path) and put the path to something else in different quotes. For example:

"C:\folder name\prog.exe" "D:\other folder\"


Understand?
Hi, I get it!
If I input :
D:> python line_replace.py "Selected DLL=""D:\testsimu0158.dll"""
then it WORKS:
I will get : Selected DLL="D:\testsimu0158.dll"
Also thank you for you help!!


Quote from: Helpmeh on August 13, 2009, 05:28:46 AM
OHHH! Now it makes sense. Put the command in quotes (and the command's path) and put the path to something else in different quotes. For example:

"C:\folder name\prog.exe" "D:\other folder\"


Understand?
4948.

Solve : Directory Listing?

Answer»

Hi Im looking to create a txt file which contains a list of all FILES located in a folder directory.

I currently use the following script in a .BAT file.

But I just require it to display a list of files located and not system info.

I also want to be able to apply it to various folders, not just files on c:drive

@dir %1 /A /S > c:\dirListing.txt
@echo OPENING c:\dirListing.txt in Notepad
@notepad c:\dirListing.txt
@echo Deleting c:\dirListing.txt
@del c:\dirListing.txt
@pauseI can't remember what the A switch does, but the B switch is "bare format", meaning only names (or names and paths with the S switch).

If you want to do a different folder, the whole command would be (using your chosen switches)
Dir [foldername] /a /b /s

You have it so this batch file is best run off the command prompt because it IMPLEMENTS %1. That means that the first word you put after the batch NAME becomes part of the script. So to do it that way, drag and drop the batch file (after adding the B switch between the A switch and the S) and type the folder you want to run the directory script on (remember to add path!)

4949.

Solve : I'm back! With a huge project....?

Answer»

Sorry for the double POST, but I have a project update. Okay, I have the base of the program. There's one problem, I can't seem to find a way to cycle through the files. I've tried USING a for /l loop. But even with setlocal enabledelayedexpansion and all the VARIABLES SET in the foor loop are surrouned with !'s and all that other crap. But it just seems like the for /f loop won't function in the for /l loop.

4950.

Solve : error code?

Answer»

what is ERROR CODE ?error code 5??List of MS-DOS &AMP; COMMAND Prompt Error Codes