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.

3501.

Solve : Read a particular word using DOS??

Answer»

Hi,

Is there is any possiblity to read a particular word in a TEXT file. I know where the word will START and end.

For EXAMPLE:

Consider the text file contains the following content...,

ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM NOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM NOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM NOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM NOPQRSTUVWXYZ

I need to read the character from 4th position to 9th position of the line1.
i.e., I need to get "DEFIJK" alone from this text file.

Will you please HELP me to resolve the same.

Thanks in advance...,

With Regards,
Vinoth R

The easiest way:
Code: [Select]@echo off
set data=ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM NOPQRSTUVWXYZ
echo %data%
set data1=%data:~3,3%
set data2=%data:~8,3%
echo %data1%%data2%
PAUSE

3502.

Solve : Batch File to read individual lines of .txt document?

Answer»

I've written a basic batch file to read a directory and output all the files into another .txt. file.

Code: [Select]@echo off
cd C:\Production Change Actions\Input
dir /b > "C:\Documents and Settings\username\Desktop\Imports.txt"
I'm now trying to get all of those file names placed into this line of another batch file.

Code: [Select]@echo off

cls
:start
cd C:\Program Files\Thunderhead35
Thunderhead.Importer.exe -user DPS\username -conflict overwrite -verbose -file
INSERT FILE NAME FROM IMPORTS.ZIP
The file names have to be placed into the second batch file individually and the Thunderhead.Importer.exe does not allow "*.zip" for me to do them all at once. So, I'll need the batch to be able to read each line, insert it into the second batch, then have the batch file run, then start over all the way through all of the file names.what actually are you wanting to do?This should work:

Code: [Select]@echo off
cd /d C:\Program Files\Thunderhead35
for /F "tokens=* delims=" %%v in ('dir /b "C:\Production Change Actions\Input"') do (
Thunderhead.Importer.exe -user DPS\%username% -conflict overwrite -verbose -file "%%v"
)

Double check username. Wasn't sure if that is a literal or the system variable.


thanks...i'm gonna try that out. The "username" is a SPECIFIC username that I'll change it to. I just changed it to username for PRIVACY. I'll let you know how this works in a little while.Okay...I got it to work...I had to make a minor change in order to get it to read the file correctly:

Code: [Select]@echo off
cd /d C:\Program Files\Thunderhead35
pause
for /f "tokens=* delims=" %%v in ('dir /b "C:\Production Change Actions\Input"') do (
Thunderhead.Importer.exe -user domain\username-conflict overwrite -verbose -file [b]C:\Production Change Actions\Input\\[/b]"%%v"
)
pause
without adding that part, it kept saying, "cannot find C:\Program Files\Thunderhead35\whateverthefilename.zip" And, I had to add in two slashes to get it to read correctly.

Thanks for the help!!! Is their anything wrong with the way I tweaked it?Quote

Is their anything wrong with the way I tweaked it?

Not a thing. Any TWEAK that works is a good tweak. Code: [Select]@echo off
cd /d C:\Program Files\Thunderhead35
pause
for /f "tokens=* delims=" %%v in ('dir /b "C:\Production Change Actions\Input"') do (
Thunderhead.Importer.exe -user domain\username-conflict overwrite -verbose -file C:\Production Change Actions\Input\\"%%v"
)
pause
Could you explain what some of this actually means?

I guess the for and do are where I'm lost on what this is actually doing.

Tokens=*
delims=nothing???
why is the variable %%v???

I'd like to understand this so I don't have to ask a similar question later. Thanks.tokens=*
tokens=2* defines 3 variables (tokens)
tokens=1* defines 2 variables
tokens=* defines 1 variable

Could I have used tokens=1? Yes! Go figure!

delims=nothing
the default delimiters are tab and space; overriding with no delimiters avoids dropping data when file names have embedded spaces

why is the variable %%v??? Why not? The variable declared can be any lower or upper case letter. Numerics can be used, but are easily confused with command line arguments.

Using the tokens=, delims= and the declared variable, each for statement is constructed specific to the data.

The for command is highly nuanced. These sites are MUCH more eloquent than I could be.

Iterating with FOR

FOR




Thank you for your assistance. It is greatly appreciated.
3503.

Solve : call bat file inside batch file.?

Answer»

I USED to do following flow in batch file

>> GO to abc PATH
>> call startup.bat
>> go to xyz
>> call makefile

startup.bat :
>> set the enviorment variables
>> go to xyz
>> call cmd.exe

But I faced one problem that enviorment is set but it doesnot run the makefile .

I do this with using batch file and perl script both.But the same issue comes in observed.
can any one hleps me out in this ?


I think the issue is comes because i call cmd.exe inside ALREADY opened command prompt.
but i have to call the cmd.exe (because i have to give the option if person direct clicks on the batch file (startup.bat) it should open the shell with the preset enviorment to work with).
In this case nesting of command prompt happens .

Now my issue is that
currentally I run makefile at perent cmd.exe while i have to run it on current instanse of cmd.exe (whether it is based or drived) .

So how can i do that, because it in write in base it runs after closing the drived and i dont WANT to write it into drive.
how can i run it in drive but call in base?

3504.

Solve : reformat a string?

Answer»

Hi

here's my problem: When I enter a string in the form S-1-5-21-12345-6789 via
SET /p sid=SID:
I need to have it "converted" to the following format: 5 21 12345 6789 (so without "-", "S" and "1").

The reason for this is that I have SIDs that I want to have resolved to usernames with the tool "sid2user.exe", which unfortunately needs this special format as a parameter.
(
set /p sidtousersidname=SID:
CONVERSION, no idea how to do this
sid2user %formattedsid%
)

Is this possible?Code: [Select]set /p sid=SID:
set sid=%sid:~4%
set sid=%sid:-= %
sid2user %sid%

Good luck. Beware using
(
%PERCENT sign VARIABLES% in parenthetical expressions
)

3505.

Solve : FTP Question?

Answer»

Hey guys, i've GOT a question. Say you have a website, which has an FTP server; now in that FTP server i would LIKE to replace index.html for one DIRECTORY inside my FTP server. Would it be possible to if you used the del and send commands while connected? Thanks, Clipper34.yes, you can just CD to the directory, send a delete command , use put to send your new file.

3506.

Solve : Get current folder name?

Answer»

Hi all,

can anyone tell me how can I get the current folder name?

example: If I'm now in C:\XXX\YYY\ZZZ
I would to set a variable var, that takes the current folder name only not the whole path, so when try to print the value of the variable (echo %var%)

the result will be: ZZZ

thanks in advanceTry this but not been tested with LFN or spaces in directory names.

Code: [Select]@echo off & setlocal
cls

set var=%cd%
for /d %%b in (%var%) do set fold=%%~nb

echo Default directory = %fold%
endlocal

Good luckThis also works, uses the fact that the cd command without any parameters echoes the current folder drive\path\name and ~nx will extract the name.

Code: [Select]for /f "delims=" %%A in ('cd') do set foldername=%%~nxA
It is perfectly happy with a long folder name with or without spaces, (the "delims=" sees to that) although that name might need quoting elsewhere, depending on what you intend to do with it. Quote from: Dusty on September 02, 2008, 04:33:09 AM

Try this but not been tested with LFN or spaces in directory names.

doesn't work on folder with spaces. Just returns the part after the last space, e.g. "folder name with spaces" shows up as "spaces".

These modifications made it work plus I trimmed unnecessary code

@echo off
for /f "delims=" %%b in ("%cd%") do set fold=%%~nb
echo %fold%

Thanks alot Hey guys, the ~nx example seems to work fine until I come across a folder with an ampersand (&) in it.

(Btw, the ~nb example does NOT work correctly if there are any periods in the folder name--it always cuts off EVERYTHING after the last period. The ~nx method works fine with periods THOUGH.)

To test it, make a folder called This.is.{ –a ]} crazy.test,}—folder #.[@mad(symbols)!='%^-

The ~nx works fine on that.

Now rename the folder, adding a & symbol anywhere in the folder name, and you get "........blah blah blah....... is not recognized as an internal or external command, operable program or batch file."


Any way around this?Quote from: AVP on September 15, 2008, 10:43:00 AM
Hey guys, the ~nx example seems to work fine until I come across a folder with an ampersand (&) in it.

[...]

Any way around this?

Try quoting the string. E.g.

Code: [Select]set fold="%%~nb"
The ampersand character is called, in NT batch scripting circles, the 'poison character'. This is because it is used in the batch LANGUAGE as a command separator. In a batch, this:

Code: [Select]cls&echo %date%&echo %time%
is processed as if it were this:

Code: [Select]cls
echo %date%
echo %time%
So, therefore, this:

Code: [Select]set fold=Mom&Dad
is treated as if it were this:

Code: [Select]set fold=Mom
Dad
and the result is a message saying this:

Code: [Select]'Dad' is not recognized as an internal or external command,
operable program or batch file.
The above solution may not always work in every situation, and a good policy is to avoid using control characters in file names, (or learn VBscript!)
Thanks Dias -- the quotes do allow the ampersand. I think this will work for what I need, but if I did need the quotes removed later, am I stuck?

Btw, yes, I wish I could control what people are naming their folders, but sometimes they do PUT ampersands in them. Is there a way to rename the folder that has a ampersand into a + instead? Maybe with SET foldernew=%foldername:&=+%You can generate a VBscript and then call it to replace ampersands in a string

Code: [Select]@echo off
setlocal enabledelayedexpansion
echo Set oArgs=WScript.Arguments>%temp%\deAmp.vbs
echo MyString = oArgs(0)>>%temp%\deAmp.vbs
echo Wscript.echo (Replace (MyString, "&", "+"))>>%temp%\deAmp.vbs
for /f "delims==" %%A in ('dir /b') do (
set filename="%%A"
for /f "delims==" %%R in ('cscript /nologo %temp%\DeAmp.vbs ""!filename!""') do set deampname="%%R"
ren !filename! !deampname!
)


Quote from: AVP on September 15, 2008, 11:59:37 AM
if I did need the quotes removed later, am I stuck?

The ~ variable modifier, used by itself, dequotes a quoted string, and leaves an unquoted string unchanged.

Code: [Select]set quotedstring="a string with quotes"
for %%S in (%quotedstring%) do set unquotedstring=%%~S
echo %unquotedstring%


Thanks for all your help Dias! I may also throw up a message that tells the user "hey, stop using ampersands in your folder names" you can get current working directory and its parent folder and current folder name in vbscript
Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFS = CreateObject("Scripting.FileSystemObject")
strCurrentFolder=WshShell.CurrentDirectory
WScript.Echo strCurrentFolder
'Get parent folder
WScript.Echo objFS.GetParentFolderName(strCurrentFolder)
'Get current folder name
WScript.Echo objFS.GetFolder(strCurrentFolder).Name

3507.

Solve : Improper DOS Shutdown?

Answer»

I am using DOS on some old legacy TEST stands, and there has been some "heated" arguments as to WHETHER there is a "proper shutdown" methodology. I say that you should exit out of the running program to the "DOS Prompt" and then shutdown the system. Others say it makes no difference in DOS and just shutdown.

I am wrong? Doesn't exiting out of the program ensure that the HD is not in some unknown state that could cause a crash at power off? Or am I worrying about nothing?

Thanks ahead of time for any assistance.You are right. Sounds like you have thought this through. As you realised, exiting the running program ensures that any temp files are closed and that no disk writing is going to be taking PLACE at the moment of powering off.

Thanks for the response. Have ever read, or do you have any MS references regarding this? I am not having much luck finding "official" comments on this issue.My DOS 6.2 manual i just checked has nothing listed for shutdown...
But common sense says i agree with Dias on this.
I always use this method...There never was any documentation on this, as I recall. Not in the OS documentation anyway. The app was the king. The OS just allowed you to run APPLICATIONS, which notoriously individually managed things like printers, temp files, whatever. Powering off while an app was running was a big no-no, and you tended to see warnings about that in the manuals of apps like WordPerfect or Lotus 1-2-3.

APM and the ability to "power down" a PC from within an OS are comparatively recent things, although in fact, to be exact, when you shut down a PC from Windows you are just putting it into a QUIESCENT state, as long as the PSU is plugged into AC power. In the old 'real' MS-DOS days, the power control was a switch which actually did cut the AC power. If you were back at the OS prompt, and you could see (that's one reason why drives have activity lights) and hear that HDD and/or floppy activity had ceased, you knew it was safe to power off. Some people used to remove the floppy that they had been using first.

3508.

Solve : Execute a Command line entry from a batch file?

Answer» OKAY, firstly I am doing this to MAKE things go faster for my classwork with a program called OSP2 (remembering the command for it is the thing I'm trying to avoid).

I am PLANNING on having this in the program's directory, and the USER can enter two arguments, a sub directory and a specific jar file to use. The jar file I would like to default to demo.jar if none is entered.

Below is what I'm thinking so far from other guides on the site.

The actual command when in the prompt is:
Code: [Select]java -classpath .;demo.jar osp.OSPand is typed in the specific projects folder in the command prompt to get the desired result when using demo.jar.

I would like argument one to be the specific project name (the subfolder under projects to go into prior to executing the command) and the second argument to be the jar file name used in the command itself), if the second argument is not GIVEN, assume it is "demo."

I am using this on Windows XP Computers.

Code: [Select]cd projects/%1
if(%2) GOTO CUSTOM
java -classpath .;demo.jar osp.OSP
goto END
:CUSTOM
java -classpath .;%2.jar osp.OSP
:END
3509.

Solve : File moving batch file?

Answer»

My skill when it comes to DOS and batch files is pretty limited. I have a solution for my particular task, but I know it's fairly clunky.

Task: I have a number of files sitting in a single folder. They need to be moved to different folders on another DRIVE, depending on their filename. Specifically, the folder names are the first 8 characters of the filename up to the first '_'.

eg.

dingleberries_2_05.mpg would go into folder dinglebe

red_5_3.mpg would go into folder red

Then any files leftover (i.e. without matching folders on the other drive) just get moved into a 'leftovers' DIRECTORY where someone can deal with them. I don't want the batch file to create new directories for these files because in most cases a mismatch will mean someone has misnamed the file.

I can achieve this with a simple COPY / DELETE batch file but someone would have to manually maintain the list of valid directories, eg.:

COPY d:\nick\test01* d:\nick\test01\
DEL d:\nick\test01* /Q
COPY d:\nick\test02* d:\nick\test02\
DEL d:\nick\test02* /Q
COPY d:\nick\test03* d:\nick\test03\
DEL d:\nick\test03* /Q
COPY d:\nick\* d:\nick\leftovers\
DEL d:\nick\* /Q

I know you can set variables and do stuff with substrings - and it looks they'd allow one to do what I'm trying to do much more easily. I've had a google but can't find anything similar enough to what I want that I can work from.

Can anyone help?move red???*.??? %systemdrive%\red
move dingle???*.??? %systemdrive%\dingle
move ???*.??? %systemdrive%\leftover



the above only works in order, you are looking for file red_5_1.mpg , so red???*.??? is its equivilant, as all files named red are red_6_2.mpg , red 8_1.mpg the last LINE moves the leftover files to the leftover directory.Move is easier than the copy/delete, but I'm probably not going to be responsible for maintaining this thing and was hoping for a batch file that wouldn't need to be updated as new directories are added.

I've seen a RANGE of DOS scripts using substrings and variables that look like they'd do it but go cross-eyed trying to figure out how they work.use dir command to search out the potential directorys instead

dir dingle???*. /b


for /f "tokens=1*" %a in ('dir dingle???*. /b') do move %a C:\folder\%aIf I'm reading that right, someone would still need to update the batch file each time a new directory is added?No, because the dir command checks every directory. The for command combined with dir pretty much says "For every directory, do this."OK, let me try. I love ugly batch files. No, I really hate them!
I think what you want is a batch file the will live on and on. That it will create needed dirs by a sort of kind of file prefix thing. I don't know how batch files can extract stings, but I can write a simple program that would do that. Then I would pas the information onto the remainder of the batch file.
Remember the the old QBAIC that came with a version of DOS or Windows way back when? It still works in XP, but can not deal with long file name. But we can work AROUND that. Part of the code would be ike this:
S=INST(A$,"_") : B$=LEFT$(S-1)
It would read a TXT file with the names of all the files. It would write a new TXT file with the unique prefixes. Or something like that. Then the batch file could make DIRs from the new TXT file and copy files that match a prefix.

Is this the kind of thing you want? I have used QBASIC to do string tricks for batch files.Quote from: dslgeek on September 14, 2008, 08:23:59 PM

I think what you want is a batch file the will live on and on.

This is exactly what I'm after.

http://www.computing.net/answers/programming/mid-or-substr-batch-simulation/14516.html

Doesn't seem to be 'pure' DOS but would seem to work.

I've also seen some examples of substrings used as variables - which would seem capable of doing what I want. But I've no idea how to approach it.

But while I suck at DOS, I'm relatively comfortable with VB and I think I can write some simple script to rewrite the batch file every time a new folder is added. This would let me keep the batch file simple (i.e. a list of MOVE's).

I think I'll have a go at this first and see if I can pull it off.
3510.

Solve : Create a file using MS Dos?

Answer»

Hi,

I am trying to create a schema.ini file that contains information about all files in a directory using MS Dos. Here is what I am trying to do

Directory C:\Misc has the following tab delimited files without COLUMN headers

sample1.txt
sample2.txt
sample3.txt
sample4.txt

Now I need to create a schema.ini file using the above file names (extract file names from a directory). The new file would have the following text and would be saved as "schema.ini":

[Sample1.txt]
Format=TabDelimited
ColNameHeader=False
MaxScanRows=0
CharacterSet=ANSI
[Sample2.txt]
Format=TabDelimited
ColNameHeader=False
MaxScanRows=0
CharacterSet=ANSI
[Sample3.txt]
Format=TabDelimited
ColNameHeader=False
MaxScanRows=0
CharacterSet=ANSI
[Sample4.txt]
Format=TabDelimited
ColNameHeader=False
MaxScanRows=0
CharacterSet=ANSI

Can someone please show me how to write a ms dos code that will create this file (if dos can do this)? As far as i understand this, i need to do two THINGS: a) PASS file names in directory; b) add the standard text. I might be wrong here.

Regards

are this lines
Code: [Select]Format=TabDelimited
ColNameHeader=False
MaxScanRows=0
CharacterSet=ANSIand others are in each sample file or you want to echo them ?hello,

if by echo you mean to appear as normal text than yes, every single file name should be followed by these lines (these lines never change).here you go
Code: [Select]for /F %%a in ('dir /b path\tofiles\*.txt') do (
echo.[%%a]>>schema.ini
echo.Format=TabDelimited>>schema.ini
echo.ColNameHeader=False>>schema.ini
echo.MaxScanRows=0>>schema.ini
echo.CharacterSet=ANSI>>schema.ini
)
remember to change path to whatever you wanthello devcom,

thank you so MUCH for all your help, the code worked seamlessly, i got exactly what i was looking for.

thanks once again

regards

3511.

Solve : Find the row location of a text?

Answer»

Hi,

I am very new to MS DOS. I am trying to do the following:

I have multiple files in folder C:\Misc. I need to move all files from C:\Misc to C:\Misc\Option that have the word "Application" in the first ROW.

E.g.
File A:
User
Application

File B:
Application
Game

In this example I want to move File B from C:\Misc to C:\Misc\Option as it has the word "Application" in the first row.

Can someone please show me how to write a dos COMMAND that will do the above? I am very new to DOS and thus looking for help.

Thanks
Rohan
Quote from: rohanverma on September 06, 2008, 01:04:04 PM

the word "Application" in the first row.

I will work on this tomorrow. In the meantime, you should know that the correct word is "line", not "row".
for /f "tokens=1*" %a in ('findstr /M /I Application *') do move %a %systemdrive%\yourfolder\%a


ok , the command you want is findstr , using the /M switch to display only the filename of the files that contain a match , using the /I switch to signify that is not case-sensitive, Application is your search term, * signifys all files in the current folder , using the FOR Command , with the /F switch .. , you are looking for %a in the output of findstr /M /I Application * the next part.. of the output that is a match, move %a (the matching output filename) to %systemdrive% witch is normally C: , \yourfolder\%a , %a is the filename.. so if you had a file with Application in it called myfile.txt , %a would equal myfile.txt , so the above will copy all matching files with Application Written in it, its important to remember.. using %a in a batch file would need an additonal percentile symbol so instead in a batch file the command would look similar to this..
for /f "tokens=1*" %%a in ('findstr /M /I Application *') do move %%a %systemdrive%\yourfolder\%%adiablo, the OP specified that "application" should be in the first "row" (line) in order for the move to happen, and in FACT gave examples illustrating that if "application" was present in a file, but not in the first line, then that file should not be moved.
hello everyone,

thank you for helping me out. Yes, the word "Application" should be in first line in order to move the file. Any ideas on how I can accomplish that?

Your post seems to have gotten lost in the shuffle.

This may help you out:

Code: [Select]@echo off
setlocal enabledelayedexpansion
for %%i in (C:\Misc\*.txt) do (
set /p var=<%%i
if /i !var!==Application move %%i C:\Misc\Option\%%~nxi
)

You didn't mention an extension for your files. The code uses .txt, but it can be changed.

thanks Sidewinder, I tried using your code but it didn't work. I created a bat file with your code. Am i doing something wrong?Quote
I tried using your code but it didn't work. I created a bat file with your code. Am i doing something wrong?

Hard to tell from here. Did you re-type the code or copy/paste it? Any error messages? What are they? What extensions do your files have? The code was tested and checked out on a XP machine. Should run easily on Win2003.

Try removing the @echo off line from the batch file. You may be able to debug yourself or post the console output and we'll take a look.



PS. I tested with the FileA and FileB exactly as you posted. Is that not correct?hi sidewinder,

I tried to use your code in the command prompt but the file transfer doesn't work.

Here is your code modified for command prompt:

C:\misc\test1>for %i in (*.txt) do (set /p var=<%i if /i !var!==Application
move %i c:\va\%~nxi)

Here is what I get in the command prompt window on running the above code:

C:\misc\test1>(set /p var= if /i !var!==Application move testing.txt c:\misc\t
esting.txt 0if /i !var!==Application move testing.txt c:\misc\testing.txt

C:\misc\test1>(set /p var= if /i !var!==Application move testing2.txt c:\misc\
testing2.txt 0if /i !var!==Application move testing2.txt c:\misc\testing2.txt

It looks like the code is unable to identify if the word "Application" is in the first line or not.I KEEP telling myself to be more precise. The posted code was not meant to be run at the command prompt. It was DESIGNED as a batch file.

Quote
I created a bat file with your code.
So what happened when you ran the code as a batch file?

Code: [Select]@echo off
setlocal enabledelayedexpansion
for %%i in (C:\Misc\*.txt) do (
set /p var=<%%i
if /i !var!==Application move %%i C:\Misc\Option\%%~nxi
)

You should be able to copy and paste the code into your favorite editor. Save the script with a bat extension and run from the command prompt as scriptname.bat



thanks Sidewinder, this code worked. Now what if I had the same file but the first line had multiple columns separated by a tab how would we have to modify the code. e.g.

Application3586NameTgi

How would I change the code to use this? Your code is extremely helpful.

A big thanks once again.
As written, var takes on the value of the first line of the file, including the spaces. This works if application is always the first word and starts in the first position:

Code: [Select]@echo off
setlocal enabledelayedexpansion
for %%i in (C:\temp\*.txt) do (
set /p var=<%%i
set var=!var:~0,11!
if /i !var!==Application move %%i C:\temp\Option\%%~nxi
)

If you are scanning the line for the word application in any position, you'll need to set up a loop within the for loop to do the scan. There are other scripting languages that make this easy. Batch code, not so much.





thank you thank you thank you Sidewinder.

Your code did exactly what I was looking for, thank you so much for all your help. It works just fine.



3512.

Solve : Lock?

Answer»

Hi,

I have Windows XP but i want the command: Lock
Which only AVAILABLE on Windows 98...

How can i get this on windows XP?A little googling turned up this (Command.com Command Line Parameters and Batch Debugging Commands)

Lock: Locks a drive for low LEVEL access

Lock is an internal Win98 command. You could try a Win98 bootdisk but the lock command does not exist as a standalone module.



If your XP system uses NTFS, the lock command probably won't run. This command can corrupt or destroy your file system. Why WOULD you need it?I have a bootdisk
But the computer don't show command.exe
But i did have a W98 and in command.exe is the Lock command but i can't copy it...

My English is not very GOOD Here is command.com for W98
http://psphomebrew.axspace.com/command.txtWhat are you trying to do?

Command.com is under copyright so any reverse engineering is illegal. I'm still confused why you need lock on a XP machine.

In many years of experience, I've never known anyone who USED this command. But then again, I don't get out much.

The command.txt file appears to be an array of messages issued by command.com along with some ASCII representations of the machine code.



3513.

Solve : AOA - Help %Random%?

Answer»

As you well know %random% creates a random number between 0 and 32767.
In my formulas for combat. I think when %random% is set automatically it uses the new %random% in the next formula.

So:
Code: [SELECT]set /a OppDamage=(%random%*%OAttack%/32767)-10
set /a Damage=(%random%*%Attack%/32767)-10

set /a CHealth=%CHealth%-%OppDamage%
set /a OCHealth=%OCHealth%-%Damage%


EDIT: one formula comes back normally and one around the 20's

this switches dependent on which formula is first#

Each time I run the bat again the %Damage% or %OppDamage% is almost always the same DEPENDING on which formula is worked out before the other one.

This will better explain it:


EDIT:
I'm not sure how, but it works almost perfectly now, and works good enough for me at this precise moment, if you know why PLEASE do not hesitate to post as a permanent fix will be greatly appreciated.Not sure I understand. %random% generates a new random number each time it is encountered in the code (exception is within a for loop when special consideration must be made).

If you want the value of %random% to be the same for both formulas, save it and use the saved value in the second formula.

You also have the values of %OAttack% and %Attack% to consider when you view your results.

The little piece of doggerel will show random number generation over a wide range:

Code: [Select]@echo off
for /l %%v in (1,1,10) do (
call echo %%random%%
)

Quote from: Sidewinder on September 13, 2008, 11:42:18 AM

If you want the value of %random% to be the same for both formulas, save it and use the saved value in the second formula.

Nope, I want them to be different.
It all appears to work fine now, so thanks for your help anyway.


EDIT: it still has the same problems but it will have to do.
as it is roughly fair now anyway.The reason why you are not getting the correct random numbers is because you are not doing the right arithmetic.

To get a random number between 1 and 100 you use the modulus operator % thus:

set /a var=(%random% %% 100) + 1

Notes:

(1) % = modulus (or mod)

(N mod M) = the remainder on integer division of N by M

(2) To use a percent sign ("%") in a batch file you need to 'escape' it with another one.
(To get the effect of % you use %%).

Code: [Select]set /a OppDamage=(%random% %% %0Attack%) + 1
set /a Damage=(%random% %% %Attack%) + 1

set /a CHealth=%CHealth%-%OppDamage%
set /a OCHealth=%OCHealth%-%Damage%

CLOSES the bat file.well im always doeing this like :

Code: [Select]%random%%%%var%+1
and it worksI think that 0Attack may be a bad choice for a variable name. Set /a interprets values (including starting with a zero as an octal number.
Quote from: Dias de verano on September 14, 2008, 04:00:16 AM
I think that 0Attack may be a bad choice for a variable name. Set /a interprets values (including starting with a zero as an octal number.


Thanks but it is a capital o not a 0.Quote from: devcom on September 14, 2008, 03:58:42 AM
well im always doeing this like :

Code: [Select]%random%%%%var%+1
and it works

That works brilliantly, thanks to both of you you will receive credits.Quote from: Jacob on September 14, 2008, 04:04:21 AM
Quote from: Dias de verano on September 14, 2008, 04:00:16 AM
I think that 0Attack may be a bad choice for a variable name. Set /a interprets values (including starting with a zero as an octal number.


Thanks but it is a capital o not a 0.

It is definitely a ZERO. This is the code YOU posted, shown in monospaced font where zero is different from capital 0.

Quote from: Dias de verano on September 14, 2008, 04:13:06 AM
Quote from: Jacob on September 14, 2008, 04:04:21 AM
Quote from: Dias de verano on September 14, 2008, 04:00:16 AM
I think that 0Attack may be a bad choice for a variable name. Set /a interprets values (including starting with a zero as an octal number.


Thanks but it is a capital o not a 0.

It is definitely a ZERO. This is the code YOU posted, shown in monotype font where zero is different from capital 0.



Thank you, well it's not meant to be, because it stands for opponents attack. Thanks for pointing that out.
I have given you credits in the AOA post.Quote from: Jacob on September 14, 2008, 04:14:48 AM
well it's not meant to be

Those words are written on the gravestones of many many crashed PROGRAMS... Quote from: Dias de verano on September 14, 2008, 04:16:29 AM
Quote from: Jacob on September 14, 2008, 04:14:48 AM
well it's not meant to be

Those words are written on the gravestones of many many crashed programs...

Lucky I have you.
3514.

Solve : Why does batch file not launch the next command??

Answer»

Hi,

I'm trying to build my project and copying jar into destination with batch file.
Unfortunately after mvn clean install jar will not be copied. Why? And how can I solve this PROBLEM?
After mvn clean install there is COPY source destination in batch file, but the last one will not be run.

Thanks beforehand,
regards, sipungora.Very difficult (impossible?) to tell without viewing your code.


Code: [Select]mvn clean install
copy target\a.jar D:\srv\app /y/v
Sorry, my knowledge of maven is lacking.

Can you ensure that the jar is being written, I have read that your first line fails (here.).

Perhaps it would be better for you to address your query to one of the mvn forums here.

Good luckEauch code line ALONE can easy be run and returns a correct results. But together first line can only be run, then nothing happens. if that's the case maybe the first line hasn't finished EXECUTING before the second tries to. how about a wait inbetween the two?

Code: [Select]PING /n 5 127.0.0.1>Nul
FBWould putting both commands on one line separated by && be successful?

Quote

mvn clean install && copy target\a.jar D:\srv\app /y/v



3515.

Solve : ftp via .bat not cmd.?

Answer» FIXED myself.
Code: [SELECT]@ECHO off
FTP.EXE -s:script.txt

needed the .exe for some REASON.
3516.

Solve : Create Directory with combined name?

Answer»

Hi,
What is the way to create a directory that its name is combined of the Computer Name and the excat time?
E.G:

Folder Name: TestPCSept1020081643
While the name is combined of:
Computer Name: TestPC
Date: Sept102008
Time: 16:43
Thanks!
md "C:\Location\to DIR\" "%computername%%date%%time%

TRY that.Thanks Carbon Dudeoxide
It creates on the same LEVEL of the batch file a folder with the PC name and Month-
and inside that, a folder with the day.
E.g:

Folder Name: 'PCTestSat 09'
and inside that folder, a folder called '13'All right...

set computername=%computername%%date%%time%
md "C:\Location\to dir\" "%computername%"
md "C:\Location\to dir\%computername%\" "13"

How does that work.It does the same thing:
Creates a folder and inside the folder there is another folder with the day.
;-(Oh right, HOLD on let me have a look. (I haven't tested it )Ahah!!! How foolish of me...

set computername=%computername%%date%%time%
md C:\Location\to dir\%computername%
md C:\Location\to dir\%computername%\13

Try That.

3517.

Solve : Dos attacks??

Answer»

Hi,

What are Dos Attacks
How do you use it
And what happenA denial-of-service attack (DoS attack) or distributed denial-of-service attack (DDoS attack) is an attempt to make a computer resource unavailable to its intended users. Although the means to carry out, motives for, and targets of a DoS attack MAY vary, it generally consists of the concerted, malevolent efforts of a person or persons to prevent an Internet site or service from functioning efficiently or at all, temporarily or indefinitely. Perpetrators of DoS attacks typically target sites or services hosted on high-profile web servers such as banks, credit card payment gateways, and even DNS root servers.

One COMMON method of attack involves saturating the target (victim) machine with external communications requests, such that it cannot respond to legitimate traffic, or responds so slowly as to be rendered effectively unavailable. In general terms, DoS attacks are implemented by either forcing the targeted computer(s) to reset, or consume its resources so that it can no longer provide its intended service or obstructing the communication media between the intended users and the victim so that they can no longer communicate adequately.

Denial-of-service attacks are considered violations of the IAB's Internet Proper Use POLICY. They also commonly constitute violations of the laws of INDIVIDUAL nations.[1]http://en.wikipedia.org/wiki/Denial-of-service_attackMy ENGLISH is not very good

But there was a command for dos attacks right?WhyQuote from: Larssie111 on September 13, 2008, 06:58:13 AM

My English is not very good

But there was a command for dos attacks right?

No, and carbon check out my AOA post please. Alot of updates.
I have read it so i want to know what it is
And i have seen a command for that beforeWhere?

Also...What are your intentions.... What are intentions?

And i have read it by a topic on this site
Something with: hacking NT Quote from: Larssie111 on September 13, 2008, 07:21:06 AM
And i have read it by a topic on this site
Something with: hacking NT

Eh?
3518.

Solve : Remove dir under XP?

Answer»

Hi,

my batch file schould remove all from "my_dir" but not "my_dir". There are directories in "my_dir". They schould be also removed. I've tried this with rmdir /s/q my_dir/., but I get an error: Invalid SWITCH - ".". How can I do this without rmdir my_dir mkdir my_dir?

Thanks beforehand,
regards, sipungora.As far as I am aware the rmdir only deletes empty directories.

You would have to use deltree command which would delete everything contained with that directory.There is no deltree for Windows XP, only rmdir . I dislike writing destructive code for other users. Backup the my_dir before proceeding.

Code: [Select]@echo off
for /f "TOKENS=* delims=" %%v in ('dir /s /b /a:-d my_dir') do (
echo del /f %%v
)
for /f "tokens=* delims=" %%v in ('dir /s /b /a:d my_dir') do (
echo rd /s /q %%v
)

The code above will display what is to be deleted. When you are satisfied, remove the word echo from within each for loop.



The quick way would be to remove my_dir and immediately re-create it.Unfortunately after echo removing nothing was removed from my_dir.

The case remove my_dir and re-create my_dir is ALREADY in use. But this is not so COMFORTABLE. If I'm observing content of my_dir through the "Windows Explorer", after remove my_dir "Windows Explorer" will be always closed and I have to open it again to further observation or I must always go into the parent directory in Windows Explorer, before my_dir will be removed. have you tried del/?

FbCode: [Select]@echo off
for /f "tokens=* delims=" %%v in ('dir /s /b /a:-d my_dir') do (
del /f %%v
)
for /f "tokens=* delims=" %%v in ('dir /s /b /a:d my_dir') do (
rd /s /q %%v
)

Warning: The above code is destructive and will delete files and directories.

Quote

The case remove my_dir and re-create my_dir is already in use. But this is not so comfortable. If I'm observing content of my_dir through the "Windows Explorer", after remove my_dir "Windows Explorer" will be always closed and I have to open it again to further observation or I must always go into the parent directory in Windows Explorer, before my_dir will be removed.

If you are trying to remove files/directories why are you accessing the directory in explorer? As long as you're in explorer, why not do the deletions there? It would be a lot safer as explorer can send files/directories to the recycle bin whereas batch scripts do not.

Because in batch file I can INSERT several commands and with Windows Explorer I can only do one thing at the same time.
3519.

Solve : Time stamp?

Answer»

Hello,
I have an Access 2003 Database used to store various records. I just need to figure out how to add a time STAMP to the documents when the are printed. If I print a file at 10am, and then again at 12pm I would like to have that information on the printed page, does any ONE have an idea?Isn't this an option on headers and footers?
If they have that in Access 2003 records.It does, and have the date and time in the form and it shows up if I go to the form and view it. When I CLICK on the print button in the database, however, it only prints the date, not the time. I'm, afraid i cannot help ANYMORE, sorry.

3520.

Solve : varibles in batch file .?

Answer»

Ex. code in c for apending valuse in varible is

a =+ b;

if i try this in batch files like
path=+%%val
and if the value of val is test then

It shows like path = +testalwhats the question?APPENDING to a text file or any file you need the redirection charachter in a batch file its > so echo line>file.txt or INPUT>output.txt using a single redirection charachter would re-write all lines in the file you are appending to and REPLACE it with the new line, if you want to add multiple lines use two redirection charachters >>

echo firstline>output.txt
echo secondline>>output.txt
echo thrirdline>>output.txt
i want to append value in variable , not in file.so you just need to set a variable?

if you need multiple lines you need to set for in an array but if you want a single line you can just use the for statement


for /f "tokens=1*" %a in (mytext.file) do set a=%a


say you needed multiple lines set into variables like the output of the dir command

set c=0
for /f "tokens=1*" %a in (dir/a) do (
call set c=%%c%%+1
call set a.%%c%%=%a
)

I do something like follwing

for /f "tokens=1-10 delims=\" %%1 in ('cd') do (
set p=%%1
set c=1
:bof
if %%c==tools_v2 goto :eof
set p.%%p%%=%%c
set c=%%c%%+1
goto :bof
)
:eof
echo Path = %p%

i want to add each value of c variable in p till test is matched with the value of c

line in bold want to be change

do u understand what i want ?hi diablo416

finally i used following code and want to append valuse of g in p varibale can u help me how can i do this:



for /f "tokens=1-10 delims=\" %%1 in ('cd') do (
set p=%%1
for %%G in (%%1, %%2, %%3, %%4, %%5, %%6, %%7, %%8, %%9, %%10) do (
if %%G==test echo %p%
set p=.................
echo %%G
)

)

where i wrote echo %%g at that point i have to append value of g in p so that i can get FULL path.

3521.

Solve : network and servers?

Answer»

I Am not GOOD in dos commands, but I WANT to make a BATH file that can do the following ( if it is possible).

I do not want to map the servers.

1. Go to server ( I do have the Ip address) (if USERID and password is needed, put it in.)
2. Get the local drives free bytes.
3 put it is a text file OM my pc.


If this possible, the how do I do it.

Thank YouWhy don't you want to map the servers?I have 15 servers with between 2-7 local drives on each of them,

Can you map them, and when they are finished ,unmap them.

It is on our LAN, How do you do it then.

I have to go to each server daily and get the free bytes on each local drives on that server, I want do do it from my PC directed.

3522.

Solve : How do I get the Time since the computer started ??

Answer»

He does not explicitly state that he "wants to know uptime". He wrote...

Quote from: ALAN_BR

I believe Windows has a mSec counter timer ... Is it possible (and how) for a batch file to also access this Windows timer ?

The way he talks about "accessing the timer which starts from zero at system startup" makes me think that he wants to access the system time more than once, for comparative or record-keeping purposes rather than merely to see how long the computer has been running.

ALAN_BR, you can do away with all that systeminfo stuff. Using VBscript, you can access an uptime counter with a resolution of 10 mSec and you can get the reading into a variable in a batch file.

This script should either go in the same folder as the batch file or be placed in a folder that you name in the batch file. In my example batch I placed it in C:\utils. If it is in the same folder as the batch you can just use the bare filename.

VBTimer.vbs

Code: [Select]Wscript.Echo FormatNumber(timer*1000,0,0,0,0)
Access it in a batch file like this:

Example.bat

Code: [Select]@echo off
for /f "delims=" %%U in ('cscript //nologo c:\utils\VBTimer.vbs') do set /a uptime=%%U
echo Uptime is %uptime% milliseconds
Output:

Code: [Select]S:\Test\Vbs>Example.bat
Uptime is 47485300 milliseconds
S:\Test\Vbs>Dias - I'm out.Hi

Please note that
1. I was not offended by any comment therefore I really do not need any apology;
2. I have quite a thick skin, and a very well developed sense of humour;
3. Even if I was offended I would not stay away. My son still tries to convert me to Vista. You are like the family and friends I NEVER had - you know and use DOS. Until I accidentally stumbled across this forum I was convinced that when I died all wisdom would die with me !!!

Back to technical matters.

I told Windows XP to exclude my external drives from System Restore, but sometimes when XP woke up it forgot and reactivated. I then added prohibitions in the registry, which fixed it until my daughter got an IPOD and I was told I could install iTunes on external drive H:\. The iTunes setup.exe also thought it could go there, but half way through it aborted. I then allowed it to install on C:\ and the first thing it did was to automatically remove its residue from H:\ - which I thought was unexpectedly nice of it. I subsequently realised it had deceived me - it had also taken the opportunity to get System Restore to once more get its claws into my H:\. I am sorry but my sense of humour fails in this situation.

So I created a batch command file to determine at start-up whether Windows XP was going to stuff Restore Points into my external drives. Perfect solution.

Then Service Pack 3 got in, and that slowed down some things. In particular there was only an 80% probability that System Restore would have posted today's status before my batch file examined its contents in C:\SYSTEM~1\_RESTO~1\DRIVET~1.TXT.

That is when I came to this forum and found that I could "START" a program in /LOW priority mode, so I made my batch file invoke the status examination in low priority mode, hence it did not start to look at status until the frantic HUBBUB of start-up was finished. Perfect solution.

Then I find with SP3 there is a far higher probability that "systray" icons will be lost at start-up, so I removed some items from the start-up folder to reduce the start-up processing, and added /WAIT to my START, and the main batch command file now launches what I removed from start-up. Much better, but still not always good.

So I added diagnostic time stamps such as :-
29/08/2008 19:50:44.25 TO 19:51:09.16/19:51:10.72/19:51:11.43 19:51:14.69
30/08/2008 8:40:50.32 TO 8:41:05.11/ 8:41:12.76/ 8:41:18.08 8:41:35.27
30/08/2008 15:02:43.25 TO 15:02:59.29/15:03:01.17/15:03:02.24 15:03:09.67
30/08/2008 21:59:39.56 TO 21:59:56.02/21:59:57.85/21:59:58.98 22:00:01.13
31/08/2008 8:23:45.68 TO 8:24:00.97/ 8:24:02.57/ 8:24:03.22 8:24:20.43
31/08/2008 13:15:02.76 TO 13:15:34.76/13:15:36.36/13:15:40.16 13:15:43.36
31/08/2008 15:53:32.15 TO 15:53:45.44/15:53:47.29/15:53:48.63 15:53:51.19
31/08/2008 20:57:27.56 TO 20:57:45.22/20:57:47.70/20:57:48.41 20:57:50.50

I decided I would have a far better view of the diagnostics if they were all relative to start-up, rather than G.M.T. I saw a thread about calculating time differences, but decided that my very compact batch file would be overwhelmed with all the extra processing for all the "SUPPLEMENTARY" diagnostics. Hence my request for a counter that starts at zero on start-up.

I came back to report that I can do the job with
systeminfo | find "System Up Time" > GOTe(%1).TXT

BUT it takes about 4 seconds to do it.

With extra complications I can START a timestamp and immediately move on to do other things and start other timestamps. If I start 10 timestamps at 0.1 second intervals they all grab a number that is within 5 seconds of the first one, but they tend to swap timing order, and the subsequent spewing out and through the FIND filter takes another 40 seconds.

Dias - I love you last solution. It works. It meets all my desires.

I knew I could get whatever this register was if I coded in 'C' - but the last time I did that was on Windows 95 and I thought it would endanger XP unless I upgraded my tools. I thought any other way of coding to "get inside" Windows, such as Visual Basic, would cost money and a steep learning curve.

You make it look so simple. I would appreciate it greatly if you could post me a link so I may learn more about VB scripts.

Regards
A very happy Alan
I would appreciate a link to further information upon the use of
"Wscript.Echo FormatNumber(timer*1000,0,0,0,0)", and the many other parameters that can be evaluated.

I assume that there is a lot more information available than "timer" if only I could find a reference manual with an index. Goggle found 86,100,000 hits within 0.14 Seconds - but it would take me MUCH longer than that to find anything relevant. Searching for "Wscript.Echo" was more rewarding, BUT it all seemed to link to long articles and complex scripts - I am hoping to find some simple one line exercises that I can try out before I learn yet another completely new-to-me programming language

I now have a good diagnostic summary of timestamps showing when various start-up process complete. My original goal of timestamps relative to start-up has now been revised - some processes randomly take much longer than normal and delay everything that follows. Now I subtract each timestamp from the previous and report the duration of each process, so when a process takes longer it no longer affects subsequent results.

Regards
Alan
I'm sorry I didn't answer your previous query; the truth is I haven't got any single place I use for vbscript resources, I just tend to Google for whatever topic I need help with e.g. searching for "vbscript timer".

I'll break down that Wscript.echo line for you:

Wscript.echo ECHOES whatever follows, if you use cscript as the script engine, it uses the console.

FormatNumber works like this

Wscript.echo FormatNumber (number or expression, NumDigitsAfterDecimal, IncludeLeadingDigit, UseParensForNegativeNumbers, GroupDigits)


The 4 parameters after the number work like this. In the line you are referring to, they are all zero

NumDigitsAfterDecimal - value indicating how many places to the right of the decimal are displayed. The default value is -1, indicating that regional settings should be used. (Optional)

IncludeLeadingDigit - indicates whether or not a leading zero is displayed for FRACTIONAL values. (Optional)

-1 = True
0 = False
-2 = Use regional settings

UseParensForNegativeNumbers - indicates whether or not to place negative values within parentheses. (Optional)

-1 = True
0 = False
-2 = Use regional settings

GroupDigits - indicates whether or not numbers are grouped using the group delimiter specified in the Windows Control Panel. (Optional) (I.e. comma, space or dot for every 3 digits in numbers 1000 and over)

-1 = True
0 = False
-2 = Use regional settings

Actually the site I link to below is a very good resource with examples.

http://www.adminscripteditor.com/syntax.asp?l=v&lim=1





Thank you for the detailed explanation whcih answers all my immediate questions.

Thank you also for the link, which looks very useful for future explorations.

Regards
Alan
3523.

Solve : using wzzip in batch file?

Answer»

Hello there, first time posting here, in HOPES someone can help resolve my frustration...

I have a small batch file that I have I am using to zip a folder, then copy to a directory that is backed up nightly. However I am am not able to get the zip utility to create and add files to the zip file.

I am using wzzip, with winzip version 10. According to the help file with wzzip, I should be able to add the "-a" option in the line to add files. But this is also so assumed, so I have tried it both ways. But adding the option gives an error when the batch is ran. So this is my first clue. I also have added the wildcard *.* at the end of the line according to the reference and it is not appending the file. Here is what I have written

@echo off


start /MIN "c:\program files\winzip\wzzip" c:\backup\ffbackup\ffbackup.zip *.*

start /MIN "c:\program files\winzip\wzzip" -a c:\backup\ffbackup\ffbackup.zip *.* (causes an error in the batch if i leave this)

xcopy /s /y /v c:\backup\ffbackup\ffbackup.zip /i z:\backup\ffbackup

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "z:\backup\ffbackup\ffbackup.zip" %%e-%%f-%%g.zip

end

I am a rookie when it comes to writing the batch files, and also not too experience with wzzip. but I am able to get the files to copy and all the good jaz....any help would be appreciated!

Time was invented to prevent everything from happening at once.

Here you've got two copies of wzzip running in separate windows, a copy of xcopy running in the original window, and all the programs NEED control of ffbackup.zip.

Try slowing events down by running the job steps serially:

Code: [Select]"c:\program files\winzip\wzzip" c:\backup\ffbackup\ffbackup.zip *.*

"c:\program files\winzip\wzzip" -a c:\backup\ffbackup\ffbackup.zip *.*

xcopy /s /y /v c:\backup\ffbackup\ffbackup.zip /i z:\backup\ffbackup

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do (
rename "z:\backup\ffbackup\ffbackup.zip" %%e-%%f-%%g.zip
)

no i only wrote the following line in my previous post as an example of what else i have tried.

i dont run the batch with both lines... I have tried either one or the other...

"c:\program files\winzip\wzzip" -a c:\backup\ffbackup\ffbackup.zip *.* (causes an error in the batch if i leave this)



Quote

causes an error in the batch if i leave this

What error? Did the wzzip program issue the error? The syntax you posted is correct. I was able to duplicate your Winzip code with no problems.

well when I put the line in with he -a option it will give a message"cannot fine -a"

that throws me because I was following the instructions from the help file

and I STARTED to suspect that it was not actually appending the zip file, because the properties did not show that the file had been changed.



I added a test txt file in the directory that was supposed to be zipped, and the test file was not listed...

yea its driving me crazy, I had perused the help section that came with wzzip for a couple of days before posting here...


thank you for your help!
err, cannot find -aDOS usually takes arguments in the for /* not -* but if the documentations says so....I've tried short path names, long path names, quotes, no quotes and I cannot get your code to fail. The -a switch is the DEFAULT, so why not eliminate it?

Code: [Select]"c:\program files\winzip\wzzip" c:\backup\ffbackup\ffbackup.zip *.*

If you can, turn off echo in your batch file, run from the command prompt and post any output to the console.

I'm having a hard time fixing something that is not broke. well maybe I misunderstand what the behavior of wzzip is supposed to do.

perhaps this is a test grasshoppa

basically it still seems my batch is only copying the existing zip file (residing in \c:\backup\ffbackup\), and not creating another one and copying that...

that is ultimately what I am wanting to accomplish.
I'm confused. Are you having problems with wzzip syntax or are you getting unexpected results. There is a difference.

Quote
basically it still seems my batch is only copyinarchiveg the existing zip file (residing in \c:\backup\ffbackup\), and not creating another one and copying that...

That would DEPEND on the source files. The -a switch will add new files to the archive. Use the -f switch to replace files that are already part of the Zip file and are newer on disk. Use the -u switch to add to the archive any files that are not already in the Zip file, and replaces any files that have a more recent date on disk.

Code: [Select]"c:\program files\winzip\wzzip" -u c:\backup\ffbackup\ffbackup.zip *.*
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do (
copy /y /v c:\backup\ffbackup\ffbackup.zip %%e-%%f-%%g.zip
)
The above code produces two copies of the archive. One on c: and one in the current directory.

Code: [Select]for /f "tokens=1-5 delims=/ " %%d in ("%date%") do (
"c:\program files\winzip\wzzip" -u %%e-%%f-%%g.zip *.*
)
The above code simplifies the process, creating one zip file in the current directory.



Note to Self: In the next lifetime, come back as a dentist.


Great, I have briefly tested and think I see where you have made improvements. I will have to play with it a bit more, but you're giving me a push in the right direction.

I was under the impression that I had to put the start line in the batch to launch the app.

I hope I havent added any grey hairs, or shortened your life span any
3524.

Solve : Trademarks and Scripts?

Answer»

I am looking to run a dos script to delete a couple icons that have the trademark symbol (®) in them. When I put the name shown it says it cant find the file. How would I do this? Or I guess is it even possible?What do you mean by the "name shown"?the icon name such as guardian® test.ico is what I am referring to. I have a script that I have it find the file and delete it but I am having ISSUES with the files with that symbol.Quote from: guardian on September 10, 2008, 11:11:12 AM

guardian® test.ico is what I am referring to.

1. Is that the actual file name?

2. How did it get on your hard drive?




That is not the actual name of the file the actual name is Horizon® Practice Plus 9.5 Prod. The file did get on my system through an application that I do use but I am working on an upgrade but when I upgrade the system it leaves that file behind and I am GOING to be doing this on multiple MACHINES so i am looking to make a script to remove that file so the new one will take its place and an extra shortcut is not left behind.1. I presume there is an .ico extension?

2. Have you tried using wild cards e.g. del Horizon*.ico or del *.ico ?



its a .lnk (shortcut) and i cant use the wild card because there are other icons there that are Horizon first and then stuff after so i will get extra files.So the full name is "Horizon® Practice Plus 9.5 Prod.lnk" ?

I notice it appears to have a space. I hesitate to suggest something so obvious and basic, but have you been putting quote MARKS around the filename?


LOL yeah I am putting the quotes and yes the full name is Horizon® Practice Plus 9.5 Prod.lnkI tried to reproduce your situation. I can both create and delete a file named (by copying from your post) as you describe.

Code: [Select]D:\test>md badname

D:\test>cd badname

D:\test\badname>echo hello > test.txt

D:\test\badname>ren test.txt "Horizon® Practice Plus 9.5 Prod.lnk"

D:\test\badname>dir
Volume in drive D is DATA2
Volume Serial Number is 00CC-DEDF

Directory of D:\test\badname

10/09/2008 19:03 <DIR> ..
10/09/2008 19:03 <DIR> .
10/09/2008 19:03 8 Horizon® Practice Plus 9.5 Prod.lnk
1 File(s) 8 bytes
2 Dir(s) 127,898,386,432 bytes free

D:\test\badname>del "Horizon® Practice Plus 9.5 Prod.lnk"

D:\test\badname>

D:\test\badname>dir
Volume in drive D is DATA2
Volume Serial Number is 00CC-DEDF

Directory of D:\test\badname

10/09/2008 19:03 <DIR> ..
10/09/2008 19:03 <DIR> .
0 File(s) 0 bytes
2 Dir(s) 127,865,421,824 bytes free
We can avoid using the ® symbol because the ? wildcard only matches 1 character in an exact position...

Code: [Select]D:\test\badname>dir
Volume in drive D is DATA2
Volume Serial Number is 00CC-DEDF

Directory of D:\test\badname

10/09/2008 20:50 <DIR> ..
10/09/2008 20:50 <DIR> .
10/09/2008 20:50 8 Horizon® Practice Plus 9.5 Prod.lnk
1 File(s) 8 bytes
2 Dir(s) 126,659,215,360 bytes free

D:\test\badname>del "Horizon? Practice Plus 9.5 Prod.lnk"

D:\test\badname>dir
Volume in drive D is DATA2
Volume Serial Number is 00CC-DEDF

Directory of D:\test\badname

10/09/2008 20:50 <DIR> ..
10/09/2008 20:50 <DIR> .
0 File(s) 0 bytes
2 Dir(s) 126,656,790,528 bytes free

D:\test\badname>did you try it yet?
I have tried it and the question mark (?) did work. Thank you for all of your help.
3525.

Solve : retrieve deleted files?

Answer»

There used to be a WAY to restore/retrieve a file that was DELETED. It was in DOS, I THINK... Is it still possible?you are talking about undelete , YES you can as long as you are using a real VERSION of dos, the version in xp/vista is not the real dos

3526.

Solve : Running a CMD from RUN box in XP?

Answer»

Well first of all sorry my poor English

Well...I´m really newbie with MSDOS batch and CMD files...

I have this file:

C:\program\launcher.cmd (which doesnt need any Arguments)

And also these one:

C:\program\launched1.cmd(which needs Arguments)
C:\program\launched2.cmd(which needs Arguments)
C:\program\launched3.cmd(which needs Arguments)
C:\program\help.cmd (which needs Arguments)

Really the launcher.cmd isnt just a Console Launcher also sets all the Enviroment.An example:

Quote

::I open the Cmd.exe
C:\program>

::Now i Call my launcher
C:\program>launcher

::The Launcher:

**********LAUNCHER*****
Hi,these are the available Commands:
launched1->It UPDATES
launched2->It cleans
launched3->It kill process
Use them with the properly options, i.e:
launched2 all (it will clean all the folder)
launched2 logs (it will clean just the logs inside the folder)
If you want to see the COMMAND options type Help [Command]
Write your command here:

::Prompt appears:
C:\program>

::So i write the command with its argumment:
C:\program\launched2 log

::And the task begin
*********Cleaning Logs*******
Ok.All Logs Cleaned
::Prompt appears:
C:\program>

This was a small example.As you can see it has cleaned the Logs inside a folder.(This folder was configurated by launcher.cmd)(Also many other things are configurated by the Launcher.cmd)Which means: i cant to jump over it calling directly the launched cmd files (without touching a lot all the files)


Now i hope it´s a little bit more clear.

I want to Launch the launched.cmd files from the RUN Box in XP

Surfing the Web i learnt how to call my launcher:

C:\Windows\System32\cmd.exe /k "C:\program\launcher.cmd"

(I need "/k", otherwise cmd close as you know,but i learnt it yesterday)

But now... im stuck i think i have to use a Pipe | or something like that...but...i cant find any clue to do that.
Can u help me?Thanks

put launcher.cmd to system32 folder and in run box type launcherWell devcom...i think i have FAILED to expose my problem(maybe a matter of my poor english?)

I can launch the launcher.cmd without problems with the following sentence:

C:\Windows\System32\cmd.exe /k "C:\program\launcher.cmd"

But i want to launch launched2.cmd or launched1.cmd or launched3.cmd or....

I could use logically:
Quote
C:\Windows\System32\cmd.exe /k "C:\program\launched1.cmd"

But it doesnt work since launcher.cmd sets some global variables(some means about 1200) and other features which launched ones needs.

So i need... first to launch the launcher.cmd and then i.e launched1.cmd. All in one sentence...

I hope now it should be undestable enough...but if anyone have any doubt about how it works dont be worry about asking me.

Thanks anyway devcom so you can add this code in launcher.cmd

Code: [SELECT]start launched%1.cmd
and in run box type

Code: [Select]launcher "number of launched.cmd to run"
but you must copy launched.cmd to system32 like i said before
ofc all launched(1-3) must bee in system32 too or you can cd to them

ex of use
Code: [Select]luncher 1
3527.

Solve : Creating .bat file to open program and close multiple processes?

Answer»

I would like to make a batch file that would start one program and would also close several running PROCESSES of my choosing. I'm running Windows XP Home and am having CPU spikes that slow down the program I want in the batch file.

I don't know what some of the processes that are running are that I'd like to close, but the ones I usually notice the most in Task Manager/Processes are System, Winssnotify, iexplore, winss, MsMpEng, svchost, and crss. I'm also running Windows Live OneCare (which has no way of exiting! - help would also be appreciated if there's a way to close this app at will).

I know the basic commands to create a .bat file to open multiple programs at once:

@echo off
start "program1 title" "program1 target path"
start "program2 title" "program2 target path"

save as "all files" not text file and as a .bat

But HOW do you create a batch that closes several programs/processes while opening a program? Thanks.You can pass the programs to kill on the command line:

Code: [Select]@echo off
start "program1 title" "program1 target path"
start "program2 title" "program2 target path"

: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

You can run from the command line as: batchname System Winssnotify iexplore winss MsMpEng svchost crss

If the spikes are causing you to terminate important Windows programs, you may have other system problems. Suggest posting on the Computer viruses and SPYWARE board.Wow, that's awesome, thank you! Could you explain everything you said? Especially what each command means that you entered in. I'd really like to understand what that means.

As for my comp, I have no viruses or spyware that I'm aware of. It's a relatively NEW OS install (GOING on 3 weeks with XP after a decade of using 98) and Windows Live OneCare is installed and always running. It's identified and quarantined several viruses I've accidentally downloaded from freeware sites and the firewall is very effective.

Basically, the program I'm wanting to open in conjuction with closing several processes is Civilization 4. It eats a ton of CPU when it runs. ALTHOUGH I've heard it's pretty typical to keep getting CPU spikes on XP. It's only noticable when I run that game though, so I was thinking a killer .bat could solve that problem.

You know what else I was thinking... making another .bat that could reopen all the processes the other .bat killed - like a toggle switch. I think this could be very useful once all running processes are identified. I'm also looking at some freeware taskmon programs that will hopefully give more detailed explanations of what each process is for, where the .exe is located, what it's doing, and any conflicts. This would be very helpful in determining which processes to toggle on and off with a couple of .bat files.Quote

Wow, that's awesome

Not really. I use the same code to kill off program remnants when testing my homegrown applications. It's handy to have a closet full of snippets.

By using the shift command, the batch code sequentially moves each program name on the command line into the %1 position. Once there, it's like shooting fish in a barrel.

You can find a good free task manager here

Good luck.The coding you replied with is far too advanced for me at this time, but I'd like to learn how each snippet works. If you want, you could go over each thing in your code or tell me where I can find a detailed list of all .bat codes, strings, and puncuations and how to apply them? I've searched the net for the past couple days and have only found simple commands - like for opening multiple files at once. Thank you very much for helping me with this.Not knowing your skill level, I generally send posters to this site for learning batch code.

Considering there are only 13 or so batch instructions, batch code can be powerful stuff. My only gripe is readability and a notation straight from the cave drawings.

Good luck.
OK. I'll check out that link and see if I can create a resource toggle.bat eventually.

Also, that task manager you showed me is PERFECT! Now I know what each process is for and the path to the .exe files. I also replaced the standard taskmon with it.

Keep up the good work! Your help is very much appreciated.
3528.

Solve : Need help - excel to batch file?-?

Answer»

I need HELP please.... how can i link the data from excel to the batch file?

ex.

test.xls
Column A Column B Column C
Row1 123 456 789
Row2 321 654 987

test.bat
ABC(Column A Row1) + DEF(Column B Row1) + GHI(Column C Row1)
.......

Please can you guys help me? why do you need a batch file?
In excel go to cell D1 and type Code: [Select]=sum(A1:C1)
FBif you do need the data in a batch file then you can output a certain cell, range, or file to a text file using VBA http://www.cpearson.com/excel/ImpText.aspx and then import that to you batch file

FBActually I will use this in my work to be more accurate. i already made a batch file but it will take me for a long time to finish my work.

@echo off

:start
CLS
Echo Product Defenition
echo.

set /p siteid= Site ID:
set /p Pcode= Product Code:
set /p Bcode= Barcode:
set /p Pname= Product Description:

echo.
echo "100";"A";657309;%siteid%;"%Pcode%";1;"%Bcode%";"%Pname%";"EA";1;"EA";1;0;0
echo "100";"A";657309;%siteid%;"%Pcode%";1;"%Bcode%";"%Pname%";"EA";1;"EA";1;0;0 >> c:\docume~1\%username%\desktop\proddsc.txt
echo.
echo.
set /p add= Add more products(Y/N):
if %add%==Y goto start

pause

i don't understand what your problem is, does that code not work?

FBokay, the code work but you will input the data manually. if the data will come from excel how will i do that?

it's alright if not possible. thanks for your effort

one more question
- how will i input only numeric or letters? and max character input

thanksQuote

if the data will come from excel how will i do that

Excel spreadsheets use a proprietary file organization. Batch files can only process text files. You can use any COM aware script language (VBScript, JScript, Python, etc) to create an external script that can process the XLS file format.

You can use VBA to create an internal script that will run WITHIN the Excel application.

Good LUCK.

3529.

Solve : Scheduling application launch with AT?

Answer»
I am using AT to schedule the start of an application, but the application is not visible to the current user.

Desired scenario: In a UTILITY application, the user will be able to choose a time to launch the application again on a regular basis--for example, every Tuesday at 11PM. The application will use DOS shell AT command to schedule the task. I want this to work at least on XP and Vista, and I'm having the PROBLEM on both. (The application will be distributed as freeware or shareware to a variety of users, so hopefully the users won't need to fiddle with any settings themselves.)

Simple test scenario:

I am using this shell command--
Code: [Select]at 11:00pm "C:\Path\test.bat"substituting an APPROPRIATE time and the path to the batch file

The batch file says--
Code: [Select]@echo off
start notepad
Result: The job is scheduled successfully (on Vista, this requires running the application as Admin) and runs successfully. However, the Notepad is invisible and only shows up if I go into the Task Manager and show all users--it's a System task. How can I make this execute visibly to the current user?

Thanks!Try adding the /interactive switch to the at command line:

Code: [Select]at 5:35am /interactive c:\path\test.bat

By scheduling a batch file, you also create an instance of the shell PROGRAM (%comspec%)

Why not schedule notepad directly?

Code: [Select]at 5:35am /interactive notepad.exe


Thanks, I had overlooked the /interactive switch! I think that's it.

However, when I tried it, I was informed (on Vista) that due to security, for interactive MODE I would have to use schtasks instead.

I used schtasks, and it worked.

3530.

Solve : Need Ms-Dos 6.22 on floppies?

Answer»

Hi all,
Looking for a source to GET MS-Dos 6.22 on 1.44Mb floppies. I already have downloaded the 2.5MB setup.exe file, but need to put on floppies.

I'm restoring an old 486/33 computer NEEDED for our manufcture use.

Thanks

Ebay is a good (and legal) source. Also Amazon. I hope that is what you wanted to know, because to give any other information than that would be to encourage piracy and breach of copyright, which is against the policy of this forum.

If you have downloaded an illegal copy of a Microsoft product, then we cannot help you.


Let me check - among my older items I think I still have genuine disks for Win 3.11, and DOS 5 and 6.22.

I'll check and get back.Posting again so as to attach some pics I had .......

DOS 6.22, IBM 5 and Win 3.11

I also have a mass of other old floppies like Lotus ... can't bring myself to trash them!

[recovering disk space -- attachment deleted by admin]The setup.exe file for 6.22 is a free microsoft dowload, but the computer i'm working on only has 1.4 mb floppy drive
ThanksQuote from: MajorSci on September 04, 2008, 02:09:37 PM

The setup.exe file for 6.22 is a free microsoft dowload, but the computer i'm working on only has 1.4 mb floppy drive
Thanks

I thought tho these floppies might have been of some use?! Like - 1.4 mb floppies!

Thus avoiding the problem of the .exe you mention.Quote from: ChrisXPPro on September 04, 2008, 02:31:02 PM
Quote from: MajorSci on September 04, 2008, 02:09:37 PM
The setup.exe file for 6.22 is a free microsoft dowload, but the computer i'm working on only has 1.4 mb floppy drive
Thanks

I thought tho these floppies might have been of some use?! Like - 1.4 mb floppies!

Thus avoiding the problem of the .exe you mention.


the free download from microsoft is likely the 6.22 "Step-up" installer, which UPDATES DOS 6 to DOS 6.22.

One alternative you might want to explore is FreeDOS



ChrisXPPro, please don't tell me you had those pictures filed away under "family"

P.S: I probably would have.Quote
ChrisXPPro, please don't tell me you had those pictures filed away under "family"

Hahaha - well could well have been LOL! The "Grand PARENT's folder"

In fact I took pics of some floppy sets because I was gonna put them on ebay! I don't need to keep all my floppy stuff but sure do not want to just trash em all.Looking at the FreeDos it appears to require a CD or other DEVICE to install.
The poor old machine I'm working with has only 1.4 mb floppy.

Thankshttp://www.neowin.net/forum/lofiversion/index.php/t328254.html
3531.

Solve : xcopy command line together with wmplayer command line?

Answer»

A BIG hi to EVERYBODY as this is my first appearance in this forum!
I am struggeling with the following problem: I need to copy content from a CD to the HDD several PCs. I am using the following commandsin a batch file:
xcopy "." c:\ads/s/e/y
C:
cd\ads
name (of the respective file
Now I am trying to get win media player to play that file when loaded to the HDD.
The command line I try reads as follows:
wmplayer"c:\filename.wmv"/fullscreen
When testing the command in "run" it works perfectly. When I write it into the said batch the content is well copied to the HDD but the player does not start.
What am I doing wrong that the machine will not read the last command?
Can anybody give me a hint? HI!
Try Code: [Select] start "" "C:\path to file\wmplayer" "C:\filename.wmv" FB
Thanks FB! Unfortunately that does not work . I am sorry but I gave a false wmplayer command line . Corrected it must read:
wmplayer"c:\path to file\filename.wmv"/fullscreen
Alltogether it should copy a file from a cd to a HDD, overwrite the previous file and then play the file using wmplayer in full screen mode.
Additionally there is an autorun info ASSOCIATED reading:
autorun
open=ads.bat as the batch file is named ads.bat
which starts firstly the cd and secondly the whole process when the PC is restarted.
As said before up to the player command everything works as supposed but then there is "silence"?
Again, any hints?Why doesn't it work? error codes or what?

I don't have windows media player but i use winamp and when i use Code: [Select] start "" "c:\Program Files\Winamp\winamp.exe" "c:\Users\Public\Music\01 Faith.mp3"
it opens up winamp and plays faith by George michael.

FBWell, why it does not work I don't know. It gives the error "windows cannot find start"" when I try it in "run". When I incorporate it into the batch file and double click it, it just shows a short flick as before and the player does not startit won't work in run. Start is a DOS command... I'd suggest testing your code in command line (in run type 'cmd') and not in run.

and you seem to quote all of your code without SPACES in it. It needs to be Code: [Select]start "" "C:\...
EDIT: Also if you just run the batch file it will exit immediately after giving the error (the flicker your talking about) so to get the error goto your command line and then run the batch file and see what it says

FBFinally it seems to work. I played a bit around and used your (modified) comand line.
The code I use is:
start "" "c:\Program Files\Windows Media Player\wmplayer.exe" "c\path\file name.wmv"/fullscreen
Obviously it works. I will try it with several setups but the batch file will basically stay the same.
Thanks a million. Coming back if there are more problems .
OssiGlad it works, come back whenver you WANT!

FB

3532.

Solve : cmd path?

Answer»

when i open cmd following line APPEAR in command prompt

C:\Documents and Settings\zodehala>

i want that it is c:\>

how can i do it ? use this:
CODE: [Select]cd \or
Code: [Select]cd\or
Code: [Select]cd \ Quote from: devcom on September 07, 2008, 12:22:04 PM

use this:
Code: [Select]cd \or
Code: [Select]cd\or
Code: [Select]cd \


i know this


i want that it will be c:\> when it opened fisrtAre you OPENING cmd USING Start>Run or are you using a shortcut/hotkey or how?

What's your operating system?

If opening CMD through Start -> Run, try:
Code: [Select]cmd /k cd \If opening through a shortcut, change the starting DIRECTORY to C:\Quote from: GuruGary on September 07, 2008, 06:51:09 PM
If opening CMD through Start -> Run, try:
Code: [Select]cmd /k cd \If opening through a shortcut, change the starting directory to C:\

many many thanx
3533.

Solve : Open several links in internet explorer tabs from batch?

Answer»

Using IE7 as the default browser, the following code gets me interesting results:

start www.google.nl
start www.nu.nl
start www.symbaloo.nl
start www.ad.nl

Execution will open IE, sometimes showing the four websites in four tabs, sometimes, showing three, sometimes only www.ad.nl ... I feel www.google.nl is loaded but then replaced by www.nu.nl

As a solution, I've tried starting internet explorer WITHOUT a parameter and then afterwards using start, but then I end up with the first tab being my default homepage.

The following code will get me to open several websites in seperate windows:

start /max /b call "C:\PROGRAM Files\Mozilla Firefox\firefox.exe" www.google.nl
start /max /b call "C:\Program Files\Mozilla Firefox\firefox.exe" www.nu.nl
...

But I REALLY want to open several websites in tabs, and make sure they all open! Who can explain and help me?
i had the same problem this is how you fix it:

@echo off
start iexplore www.google.nl
ping localhost -n 2 > NUL
start www.nu.nl
ping localhost -n 2 > nul
start www.symbaloo.nl
ping localhost -n 2 > nul
start www.ad.nl


the "ping localhost -n 2 > nul" is just a harmless timer so that all the pages have time to open..

i hope that helped!
Thanks kevinwhited! Works perfectly.

3534.

Solve : Renaming a folder with user input batch file question?

Answer»

hi huys, this is my first post so a BIG hi!


I have a question for you EXPERTS, can you HELP me?

I want to use a batch file that will rename a folder with the users INPUTTED name.

so when I run the batch file it would say:

Please enter your name:

Then it would rename a folder on the local pc to the inputted name.

Any Ideas?

Thanks in advance

Macdepending on what file you want to rename you want to use the 'ren' command i.e. rename.

Code: [Select]@echo off
set /p comm=please enter your name
ren C:\...\yourfile c:\...\%comm%
pause

FBCheers FB,

I hope you have a long and happy life, win the lottery, etc

been looking for that for ages


thank you very much

Mac

3535.

Solve : How can I save output of dir in a variable??

Answer»

Hi all,

OUTPUT of DIR can be re-routed into myfile with "dir > myfile ".
How can I re-route it into a variable?

Thanks beforehand,
regards.You don't so much redirect output to a variable as to construct a variable from the pieces of the output.

Code: [Select]@echo off
for /f "delims=" %%a in ('dir c:\temp') do (
CALL set concat=%%concat%%%%a
)
echo %concat%

Be SURE to change the directory name.

Thank you, Sidewinder, very much.

You've solved all my problems, that I had with my batch file.

Best regards.

3536.

Solve : ftp deletion of folders with contents?

Answer»

Hi,

Is it possible to use ftp to delete folders with content at the remote location pls?

Thanks,

NDo you mean can you use FTP to log into a site/location and delete files? - if so then Yes.

You would need the log in details of the site/location to ACCESS through FTP, and then select them and delete.
Hi, thanks for the reply pcwizard!

The remote site has variable data which may or may not be within folder STRUCTURE(s).

I am after a DOS ftp solution WHEREBY I can script up recursive deletion(s) from a given point at the remote location.

Scripting up logging in and navigating around the remote location is already resolved. It is the ability to use DOS ftp to do the housekeeping at the far end that I am struggling with.

I suppose I COULD GET the script to execute a gui ftp client that could subsequently login and recursively delete. That route is slightly more complicated but it's going to be my fall back position if I cannot find a DOS method.

Thanks,

N

3537.

Solve : Help me? Need a command here?

Answer»

I have made a bunch of batch files recently and I'm trying to make one for school, its a computers PROJECT. It's simple.
@echo off
cls
title Internet Starter
color 0a
:start
echo Would You Like to Run Internet Explorer?
pause
start iexplore.exe
end

but what i want it to do is ASK would you like to run internet explorer then you type and y if you do and a n if you dont....do you understand?Do some research on the command
SET /P
Something like
Code: [Select]set /P Answer=Would You Like to Run Internet Explorer? Thanks Gary, im really a newb at the bat file THING. Hope this gets me a passing grade depending on which version of windows your using. You may want to look up the 'choice' command.

FBusing set /p , all you have to do after is include an if STATEMENT

@echo off
:begin
set /p a=Would you like to open internet explorer?
if "%a%"=="yes" start iexplore.exe
if "%a%"=="YES" start iexplore.exe
if "%a%"=="y" start iexplore.exe
if "%a%"=="Y" start iexplore.exe
if "%a%"=="no" Goto End
if "%a%"=="NO" Goto End
if "%a%"=="n" Goto End
:End


you dont need to include so many, but typing YES yes or y will = yes and NO no or n will mean no

3538.

Solve : Creating a batch file with commands in programs?

Answer»

Im new to this forum, so this might have been posted already. I was wondering how to make a batch file perform tasks inside programs. Its for a project which involves creating a batch file that opens sndrec32.exe and then telling the program to start recording. If its at all possible i would like to be able to minimize it to the system tray. Thanks in advance!. you cannot do this in batch, atleast not using the standard commands if you want to create a batch file wrapper for a .vbs file then its possible, check out wsh.sendkeys google itYah ok i did that, but theres nothing very clear on it. Btw did i tell you im a noob, so i need like VERY clear instructions cuz im new at .bat and .vbs files. I know basic sort of.Ok

first ill explain wsh.sendkeys, to open a new instance of sndrec32.exe you would use the following


set oShell = CreateObject("WScript.Shell")
oShell.run"sndrec32.exe"
WScript.Sleep 500
oShell.SendKeys" "


If you paste the above into notepad.. go to save, save it as all files TYPE and something.vbs , double click something.vbs and it will open sndrec32.exe and send a space bar , oShell.SendKeys" " When i open'd sndrec32.exe a minute ago, spacebar was the first key i pressed and it started recording, so the above will work

the first line is set oShell = CreateObject("Wscript.shell") , oShell is the VARIABLE and can be anything , the second line oShell.Run"sndrec32.exe" will open sndrec32.exe , YourVariable.Run"sndrec32.exe" so if you set CreateObject("Wscript.shell") as YourVariable , You could instead type YourVariable.SendKeys" " , Ok the third line.. Wscript.Sleep 500 , this causes the script to sleep for 500 millaseconds before sending the spacebar to sndrec32.exe , You need to cause the script to sleep inbetween Sending another key, because the Script may operate to fast and malfunction .. (Im Guessing this is the reason) But it will malfunction without it.. so anyways the final line, oShell.SendKeys" " , this will send the spacebar charachter to sndrec32.exe , when you take a look at sendkeys and the list of what charachters are accepted you wont see a space, because its just a blank space...

so now you want to add this to a batch file, Here is an example:

@ECHO off
set a=%temp%\sendkeys.vbs
echo set oShell = CreateObject("WScript.Shell")>%a%
echo oShell.run"sndrec32.exe">>%a%
echo WScript.Sleep 500>>%a%
echo oShell.SendKeys" " >>%a%
%a% & del /q /f %a%

ok on the first line i set %temp%\sendkeys.vbs witch is the file name as a " %a%"
On the second line i added the first line into the file with the variable , using > this is called appending to a text file, using a single redirection charachter > will add a single line and re-write any other line, so if you want to add multiple lines.. then you use two of them >> as you will notice on the FOURTH line.. this causes the text to be echo'd into the file, without rewriting everything else.. ECHO echos text on the screen.. if you dont understand open a new instance of cmd.exe , and type Echo testing and it will OUTPUT "testing" , the rest is strait forward untill the last line , %a% & del /q /f %a% , %a% a is the variable of the .vbs file, so when you type %a% its the equivilent of %temp%\sendkeys.vbs , so it starts the script in otherwords.. right after it is an ampersand , then it uses del (DELETE) , so after the script is executed , it deletes the script file.. /q is for quiet mode , and /f is for force .. so in otherwords it wont ask you "are you sure you want to delete this file"

3539.

Solve : DOS 101 quiz question?

Answer»

Hi EVERYBODY, i'm just starting to learn DOS......I know go ahead and laugh
But Im having trouble with a Question on a Quiz. sure its easy for you guys, I would be very greatful
if someone could help me out. Heres the Question and how do I do it.

Display the amount of Computer Memory using the “MEM | MORE” command. Redirect the output of the command to a text file on your “A: Drive” called “memory.txt”. What command did you use (Include drive letters and paths)?The FIRST part is easy. Just do what it says. For the second, you need to study the topic of redirection. Google "command output redirection".
Thanks Dias, But THe Quiz is Due tomorrow and its the last question.
Please don't make me begg ..........because I will. LOLDid you even look on Google? If this is how you prepare for TESTS, you deserve to flunk! If I give you the answer, and you submit it as your own work, your teacher may wrongly THINK that you are doing fine on the course, and you won't get the remedial attention and extra encouragement you so clearly need. This board does not do lazy kids homework for them.






i cant BELIVE you know enough that you know about mem |more and you dont know enough to append to a text file, i didnt even know about mem.. im not going to help you do your homework either, you can figure it out for yourself but the redirection charachter is >

3540.

Solve : need help with partition/formating hard drive?

Answer»

Hi all! I'm trying to FORMAT my hard drive and have run the fdisk first to set a primary DOS partition (just one DISK). My hard drive is 80 GB, but after successfully partitioning the disk, it only shows about 10 GB as available. Where's the rest? Tried it several times, all to the same result. Please help me do it right! Thanks in advance.From Our VAST Archives :

FDisk SIMULATION.

3541.

Solve : LAN connection through command prompt?

Answer»

hey everyone
i was reading about all the network commands DOS has and i now already that ipconfig( tells ur networks ip address) but i READ about NETSH and NCLOOKUP and i got into a pit of confusion. which one allows u to connect to another comp over ur lan?only netsh shows like a pure internal command but nclookup i think it depends according to the version of an operating system.May you try to to the /? option to learn more about the netsh commandnetsh is used to modify/set network configuration or as a diagnostic tool
nslookup is used to read the IP address or DNS name from a DNS server.

If you are looking to connect or map a drive to a remote system, use:

net use * \\remotecomputename\sharename
where the * uses the next open drive letter

or

start \\remotecomputename



oh ok thnx but how do i send data through a connection like if i want to send a file through a lan using command prompt cuz i definetly know that the "copy" command wont work.you can use the copy command, but I'll have to map a network drive first.

example;

net use T: \\ipaddress\sharename /user:username password

copy c:\sometextfile.txt T:\sometextfile.txt

but remember if you do map a drive, you have to delete it as you'll end up with lots of mapped driver all over the place. (net use T: /delete)

Blastman has a good solution, but you can also use the copy command with the UNC path which will prevent you from having to map / unmap the drive (assuming correct permissions are in place). Using his example, the same copy could be done like:
CODE: [Select]copy C:\sometextfile.txt \\ipaddress\sharenameor
Code: [Select]copy C:\sometextfile.txt \\computername\sharenamethnx for u guys helpQuote from: GuruGary on March 06, 2008, 03:43:58 PM

Blastman has a good solution, but you can also use the copy command with the UNC path which will prevent you from having to map / unmap the drive (assuming correct permissions are in place). Using his example, the same copy could be done like:
Code: [Select]copy C:\sometextfile.txt \\ipaddress\sharenameor
Code: [Select]copy C:\sometextfile.txt \\computername\sharename

Hey, why didn't I think of that!!

I suppose I'm used to working in a from admin to user world!! 2 last questions
1 is how do u do the "code" box?
and
2 is when u mean by net use u mean by the command "netsh" right?Quote from: macdad- on March 07, 2008, 06:03:42 PM
1 is how do u do the "code" box?
I assume you are referencing the "Code" box for messages in this forum? Code: [Select]Like this? There are several ways. The way I usually do it is reply to, or start a new message, then type the code in the message box, then select the code portion with your mouse and click on the "code" tag above the smiley FACES (code is the one that LOOKS like the page with the # sign on it).

Quote from: macdad- on March 07, 2008, 06:03:42 PM
2 is when u mean by net use u mean by the command "netsh" right?
No, you don't even NEED netsh. You use the net use command directly from the command prompt. Example from XP: Click Start -> All Programs -> Accessories -> Command Prompt
You end up with something like:
C:\Documents and Settings\macdad>
Enter the command like:
Code: [Select]copy C:\sometextfile.txt \\computername\sharenameor
Code: [Select]net use * \\computername\sharethnx
3542.

Solve : CALL but executre script on another server?

Answer»

Hi,
after a bit of help/advice please..

i have a series of DOS batch scripts which are "controlled" by a master script, CALLing each step as it goes

i.e call \\server1\folder\script1.bat
call \\server2\folder\script2.bat
call \\server1\folder\script3.bat

This executes all the scripts from the SERVER they are called from (i.e. server1), however in my case, script2 for example runs ISQL scripts and the server1 this runs from doesn't have SQL installed (server2 does) meaning it doesn't work....it processes but doesn't action the ISQL commands...

I can't transfer all the scripts to the other server as the 3rd party app that runs them cant see outside its own environment and even if I do another single script to call all the scripts from server2 I still have the same issue...

So my question is, is there a WAY to make script2 actually execute on Server2 (rather than Server1) (yet still run script1 and script3 on server1) ?

Cheers

PeterSmYou can use the AT command to schedule the batch file to run on a remote computer a few seconds from "now". Or use the SOON.EXE command from Microsoft (http://www.microsoft.com/downloads/details.aspx?FamilyID=CA8191E6-9EEF-4975-B51C-8D670748CA8E&displaylang=en)

Then you could do something like:
Code: [Select]call \\server1\folder\script1.bat
soon.exe \\server2 /i "\\server2\folder\script2.bat"
call \\server1\folder\script3.batyou could use pstools.

something like,

start c:\location-of-pstools-folder\psexec \\computername C:\location on remote machine of script -u USERNAME -p password

that will run whatever app you want (with whatever CREDENTIALS you require) on the remote machine but display it on yours.

I use it all the time. It's very handy.

3543.

Solve : how to execute a select statement from a batch file?

Answer»

i have windows XP, my database is sybase. I also want to know how can i make my stored procedure accept parameters from the command line.

Also has anyone START a new application and passed a file to it?

i will really appreciate it.I am familiar with SQL Server which EVOLVED from the same code base as Sybase, I GOOGLED and found this page that describes the command line interface TOOL, ISQL

http://manuals.sybase.com/onlinebooks/group-as/asg1250e/util/@Generic__BookTextView/1092

Good luck
Graham

3544.

Solve : Batch file error trapping?

Answer»

I have a batch file that copies 5 files from one folder to 10 other folders. Each coping process starts with a USER name as a label. If someone is using the files there is a delay due to sharing violation, until it reaches the LAST file in the GROUP, and then continues at the normal rate. I have tried trapping the error and sending it to the next subsequent label, but have not had any success. Can someone help me with this.

Code (Don't go nuts each step after each label is an exact duplicate except for the folder locatiion)

C:
:RWD
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.NTX F:\PRIVATE\RWD\REMOTIME\SERV_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.DBF F:\PRIVATE\RWD\REMOTIME\SERV_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.NTX F:\PRIVATE\RWD\REMOTIME\EMPL_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.DBF F:\PRIVATE\RWD\REMOTIME\EMPL_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_NAM.NTX F:\PRIVATE\RWD\REMOTIME\CLRE_NAM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_MST.NTX F:\PRIVATE\RWD\REMOTIME\CLRE_MST.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLNT_REM.DBF F:\PRIVATE\RWD\REMOTIME\CLNT_REM.DBF /Y
:LAUREL
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.NTX F:\PRIVATE\LAR\REMOTIME\SERV_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.DBF F:\PRIVATE\LAR\REMOTIME\SERV_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.NTX F:\PRIVATE\LAR\REMOTIME\EMPL_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.DBF F:\PRIVATE\LAR\REMOTIME\EMPL_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_NAM.NTX F:\PRIVATE\LAR\REMOTIME\CLRE_NAM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_MST.NTX F:\PRIVATE\LAR\REMOTIME\CLRE_MST.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLNT_REM.DBF F:\PRIVATE\LAR\REMOTIME\CLNT_REM.DBF /Y
:SARAH
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.NTX F:\PRIVATE\SEA\REMOTIME\SERV_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.DBF F:\PRIVATE\SEA\REMOTIME\SERV_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.NTX F:\PRIVATE\SEA\REMOTIME\EMPL_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.DBF F:\PRIVATE\SEA\REMOTIME\EMPL_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_NAM.NTX F:\PRIVATE\SEA\REMOTIME\CLRE_NAM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_MST.NTX F:\PRIVATE\SEA\REMOTIME\CLRE_MST.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLNT_REM.DBF F:\PRIVATE\SEA\REMOTIME\CLNT_REM.DBF /Y
:MELISSA
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.NTX F:\PRIVATE\MYL\REMOTIME\SERV_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.DBF F:\PRIVATE\MYL\REMOTIME\SERV_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.NTX F:\PRIVATE\MYL\REMOTIME\EMPL_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.DBF F:\PRIVATE\MYL\REMOTIME\EMPL_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_NAM.NTX F:\PRIVATE\MYL\REMOTIME\CLRE_NAM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_MST.NTX F:\PRIVATE\MYL\REMOTIME\CLRE_MST.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLNT_REM.DBF F:\PRIVATE\MYL\REMOTIME\CLNT_REM.DBF /Y
:MICHAEL
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.NTX F:\PRIVATE\MEC\REMOTIME\SERV_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.DBF F:\PRIVATE\MEC\REMOTIME\SERV_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.NTX F:\PRIVATE\MEC\REMOTIME\EMPL_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.DBF F:\PRIVATE\MEC\REMOTIME\EMPL_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_NAM.NTX F:\PRIVATE\MEC\REMOTIME\CLRE_NAM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_MST.NTX F:\PRIVATE\MEC\REMOTIME\CLRE_MST.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLNT_REM.DBF F:\PRIVATE\MEC\REMOTIME\CLNT_REM.DBF /Y
:PETER
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.NTX
F:\PRIVATE\PHK\REMOTIME\SERV_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.DBF F:\PRIVATE\PHK\REMOTIME\SERV_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.NTX F:\PRIVATE\PHK\REMOTIME\EMPL_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.DBF F:\PRIVATE\PHK\REMOTIME\EMPL_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_NAM.NTX F:\PRIVATE\PHK\REMOTIME\CLRE_NAM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_MST.NTX F:\PRIVATE\PHK\REMOTIME\CLRE_MST.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLNT_REM.DBF F:\PRIVATE\PHK\REMOTIME\CLNT_REM.DBF /Y
:ROSE
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.NTX F:\PRIVATE\MRV\REMOTIME\SERV_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.DBF F:\PRIVATE\MRV\REMOTIME\SERV_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.NTX F:\PRIVATE\MRV\REMOTIME\EMPL_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.DBF F:\PRIVATE\MRV\REMOTIME\EMPL_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_NAM.NTX F:\PRIVATE\MRV\REMOTIME\CLRE_NAM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_MST.NTX F:\PRIVATE\MRV\REMOTIME\CLRE_MST.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLNT_REM.DBF F:\PRIVATE\MRV\REMOTIME\CLNT_REM.DBF /Y
:TAMMY
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.NTX F:\PRIVATE\TBM\REMOTIME\SERV_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.DBF F:\PRIVATE\TBM\REMOTIME\SERV_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.NTX F:\PRIVATE\TBM\REMOTIME\EMPL_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.DBF F:\PRIVATE\TBM\REMOTIME\EMPL_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_NAM.NTX F:\PRIVATE\TBM\REMOTIME\CLRE_NAM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_MST.NTX F:\PRIVATE\TBM\REMOTIME\CLRE_MST.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLNT_REM.DBF F:\PRIVATE\TBM\REMOTIME\CLNT_REM.DBF /Y
:AMIE
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.NTX F:\PRIVATE\AEG\REMOTIME\SERV_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.DBF F:\PRIVATE\AEG\REMOTIME\SERV_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.NTX F:\PRIVATE\AEG\REMOTIME\EMPL_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.DBF F:\PRIVATE\AEG\REMOTIME\EMPL_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_NAM.NTX F:\PRIVATE\AEG\REMOTIME\CLRE_NAM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_MST.NTX F:\PRIVATE\AEG\REMOTIME\CLRE_MST.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLNT_REM.DBF F:\PRIVATE\AEG\REMOTIME\CLNT_REM.DBF /Y
:PAULA MAHONEY
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.NTX F:\PRIVATE\PMM\REMOTIME\SERV_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.DBF F:\PRIVATE\PMM\REMOTIME\SERV_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.NTX F:\PRIVATE\PMM\REMOTIME\EMPL_REM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.DBF F:\PRIVATE\PMM\REMOTIME\EMPL_REM.DBF /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_NAM.NTX F:\PRIVATE\PMM\REMOTIME\CLRE_NAM.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_MST.NTX F:\PRIVATE\PMM\REMOTIME\CLRE_MST.NTX /Y
XCOPY F:\PRIVATE\AWV\REMOTIME\CLNT_REM.DBF F:\PRIVATE\PMM\REMOTIME\CLNT_REM.DBF /Y
PAUSEYes, we can help ... but it would help us a lot if we could see your code so we know which COMMANDS and parameters you are using and the structure of the batch file.try reading 'if /?' and the promt.

%errorlevel% - should be of intrest to you.


But like my man GuruGary had said, post your code!!
OK, I see the code now. Maybe try the /C switch on your XCOPY command? Your code can be simplified a lot. Try this instead and let us know if this is any better. This should do the same thing as your entire code below, but I added the /C to XCOPY:
Code: [Select]for %%a in (RWD LAR SEA MYL MEC PHK MRV TBM AEG PMM) do (
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.NTX F:\PRIVATE\%%a\REMOTIME\ /Y /C
XCOPY F:\PRIVATE\AWV\REMOTIME\SERV_REM.DBF F:\PRIVATE\%%a\REMOTIME\ /Y /C
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.NTX F:\PRIVATE\%%a\REMOTIME\ /Y /C
XCOPY F:\PRIVATE\AWV\REMOTIME\EMPL_REM.DBF F:\PRIVATE\%%a\REMOTIME\ /Y /C
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_NAM.NTX F:\PRIVATE\%%a\REMOTIME\ /Y /C
XCOPY F:\PRIVATE\AWV\REMOTIME\CLRE_MST.NTX F:\PRIVATE\%%a\REMOTIME\ /Y /C
XCOPY F:\PRIVATE\AWV\REMOTIME\CLNT_REM.DBF F:\PRIVATE\%%a\REMOTIME\ /Y /C
)
pauseIf that still doesn't work, then let us know, and we can try an extra test on the file(s) before the copy attempt. And be sure to post any error messages that you get, or where the delay is.

3545.

Solve : how to camoflauge a bat file?

Answer»

i was wondering... how could i camoflauge a bat file... i made one but it has .bat extention.. is it possible to make it look like a txt document but that it would run as a bat file... i hope you understand what i want :p thx i dont know how to make it look like a txt document but have it run like a batch file , but if you want to make your bat run invisibly use this..

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
put that in a .vbs file , yourfile.vbs

at the command LINE use this
wscript.exe "c:\yourfile.vbs" "yourbatfile.bat"
i dont THINK it will work with a .cmd extentionI'm wondering why this needs to be accomplished... Me and my friends are doing this SORT of thing to bypass school security... the restrictions are the computers are rediculous but anyways...


If you want to do this use a batch compiler like:
Code: [Select]http://www.abyssmedia.com/quickbfc/It'll make the batch file into an exe and should bypass any restrictions on command prompt or .bat files I am sure the school security is in place for a good REASON, and we strongly discourage you from attempting to bypass your school security. If you feel there is a need to bypass it, then talk to the computer administrators so they can work with you on legitimate ways to accomplish what you need to do.Please Read the Forum Rules...we had a post like this about how to create a virus form a bat file.

all of us strongly recommend NOT to do this. ontop of that if u get caught ur going to the slammer for computer hacking.
i think i stand for everyone that we dont want to see u behind bars. so DONT DO THIS! Quote from: joebobfrank on March 08, 2008, 02:26:32 PM

Me and my friends are doing this sort of thing to bypass school security... the restrictions are the computers are rediculous but anyways...

Maybe if you paid more attention to your lessons, and less to arsing about, you'd know how to spell "ridiculous", and your GRAMMAR would be less execrable.

3546.

Solve : can u make a bat file not editable??

Answer»

i have seen some progs that convert ur BAT file to a COM file and obiviously a COM file isnt readable much less editable.
ANYWAYS i wuz wondering, i there another way to make a bat file not editable without changing it into a COM file?Well, you can attrib +r it, but that's easily defeated.yea. since folks could just open the properties of the bat file and change the attributes. any other ideas?If the file is on an NTFS partition, you can use NTFS permissions. awesome since i have win 2000 it should work
ty GuruGaryThat is secure so long as the file stays on a machine that have you Admin rights to and the user does not. But if the file is copied to another machine then the ntfs permissions can be MODIFIED and the file editted.Some "batch to exe" or "batch to com" converters merely attach a header to the batch file which contains a batch interpreter. These often only understands a subset of the batch language. You can see the text of the batch file in a hex editor.

I think that if you want to write a program that you don't want people to modify, you have to learn a proper programming language.ah i hve an idea. ill write another bat file that ask for a password to edit the file. so the second bat file will house the first bat file LIKE a vault.

3547.

Solve : deleting directories?

Answer»

im sure im just not doing something RIGHT but I want the file to DELETE the folder, not just its contents. this is what i have:

Code: [Select]del /Q %name%I think you want the RD command with /S parameter (and /Q if you won't want it to prompt). Like:
Code: [Select]rd Temp /q /sBe very careful when using the RD command with /S.thanx it works. in case you were wondering what its for its for a GAME im working on. its an option for deleting your profile. Yeah, I have a pretty MESSED up profile system lol.game programming is more fun than that. use a better LANGUAGE. i dont know better languages. i need to take a class or something.

3548.

Solve : DIR listing of files only?

Answer»

Hi,

I wonder if anyone can help me.

I NEED a DOS command that lists:

a) Files
b) Folders
c) Files & Folders

...within the current folder.

Obviously the DIR command works fine for listing folders (DIR /AD), files & folders (DIR) but I cannot work out how to list just files. I'm sure it's obvious but I cannot work it out.

Any ideas people...?

Regards

Roly
Quote from: roly on March 10, 2008, 07:29:55 AM

Hi,

I wonder if anyone can help me.

I need a DOS command that lists:

a) Files

DIR /A-D

b) Folders

DIR /AD

c) Files & Folders

DIR

use the /b switch to get a bare listing without header, footer, date info etc.

Quote
Obviously the DIR command works fine for listing folders (DIR /AD), files & folders (DIR) but I cannot work out how to list just files. I'm sure it's obvious but I cannot work it out.

To negate or reverse a switch, put a minus sign in front of it so dir /ad list folders but dir /a-d lists everything except folders (ie just files)

Also if you use the o switch eg dir /od list files and folders in date order earliest first, then dir /o-d reverses the order, same with /on etc

type dir /? at the prompt for a summary of the options.

This looks LIKE a homework question, and if it is, I am surprised your teacher did not go over all this with you already.
Hi Dias de verano,

Many thanks, it worked great. I never knew about the /A-D command... very useful indeed. The /O switch is also very useful.

Thanks a LOT for your help,

Roly.

Quote
This looks like a homework question, and if it is, I am surprised your teacher did not go over all this with you already.

haha, I'm actually almost 40 but I have not used DOS since my school DAYS I'm 55
Quote from: Dias de verano on March 10, 2008, 08:55:52 AM
I'm 55


Great, thanks for that.
3549.

Solve : Check for today's date?

Answer»

Hi, I have a simple batch file that copies a file from a server to the client. I want to check the date on the server file first and not execute if it is not today. (So the actual date will VARY and cannot be hardcoded). Can someone help me with this?The environment variable %Date% holds the current date - the modifier to environment variables to RETRIEVE the last updated time of a file is %~tI

But be aware that date manipulation and comparisons in batch files are very tricky - and they all depend on the region settings in the CONTROL panel.

GrahamHi
Thanks for the reply. I COULD use a little help with syntax.

if focusfile.zip/Date = %Date% THEN
GOTO :PROCEED
ELSE
GOTO :MESSAGE
END IF

3550.

Solve : Using a batch file to open a new command prompt and....?

Answer»

I have searched through the DOS forum to try and find an answer. I am trying to run a command line program from a batch file, including all inputs, multiple times. I have an Excel VBA sub that will create as many batch files as I need and fill them with the inputs, however what I am running into is that the program I call needs to have the command window it is in close before it is run again (outputs a few files at the close). So I have gotten my batch files to open a new command window, however the commands are still run in the original command window. I have also tried calling batch files that would open a new command window, but ran into the same problem.

Is there a way to open a new command window and execute the program and then close the new command window so that control then returns to the original command window so that it can do it all over again. I have pasted the basics of what I do have below. The variables X_ , Y_ ACTUALLY have numeric values input in by VBA prior to running.

start cmd
Prog X_1 Y_1
mkdir c:\newfolder_output\1 %CR%
move c:\outputs.* c:\newfolder_output\1 %CR%
exit %CR%

start cmd
Prog X_2 Y_2
mkdir c:\newfolder_output\2 %CR%
move c:\outputs.* c:\newfolder_output\2 %CR%
exit %CR%

My reason is that the program (Prog) does not change the output files names each time it runs, so I want to run it with new inputs and then move the outputs to a new folder and then run it again, but I do have to close the command window that it runs in each time. When I do the above code, it tries to run it all in the same command window and I get two blank command windows. Any ideas on what to do?
Thanks
StanWhat does the variable %CR% do?
Sorry, that is an environmental variable I set that performs a "carriage return" each time it is called so it is a way of hitting the enter key from the batch file. Not SURE if it is needed, but figured that it couldn't hurt. Worst case is that I end up with a few blank lines.What does it consist of?
I just created a variable using regedit by pressing cntrl-alt-ent I believe in the value field. It's symbol is a square. I have only been programming for about 2 months so I am pretty new to a lot of things. It was something I found online to help with a PREVIOUS programming issue so I was attempting to use it here in order to execute each line. I am not sure if a batch file does that anyways, but if so then it is one less thing to have to put in.You do not need it and it is probably not helping. Each line of a batch file is executed in TURN anyway.

What is the MOVE command supposed to be doing?

the move command is the dos move command that is looking for the output files from the program named Prog and then moving them to a folder that is created for that instance of running Prog.exe. This makes it possible to run Prog.exe 300 times without having to manually move the outputs each time (otherwise they are written over each time) or having to manually run Prog.exe 300 times. I need to close the command window after each execution of Prog.exe because some .dat files are written and are called for the next run. It is a painful way to run a program, but I haven't found a better one that makes it possible to run it like this.Try this

start /wait "" "Prog" X_1 Y_1
mkdir c:\newfolder_output\1
move c:\outputs\*.* c:\newfolder_output\1

start /wait "" "Prog" X_2 Y_2
mkdir c:\newfolder_output\2
move c:\outputs\*.* c:\newfolder_output\2


Ok, thanks for the help, by using the /wait command I have it working now. Also I am using variables to call up another batch file to run the variables from the first (just cuts down the file size and still lets me move the output files before it starts the next ITERATION). Thanks again for the help. I have 3 weeks left on this project and now it looks like I will get it done with some time to spare.