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.

4001.

Solve : Using format command to make bootable floppy.?

Answer»

I am trying to FIGURE out how tocreate a bootable disk using the format command in the command line.

Please help.Win9x machines have a switch (/s I THINK) for the FORMAT command that will create a bootable floppy. There is also the SYS command that will accomplish the same thing...floppy must be formatted first.

On WinNT machines, right click the floppy drive in My Computer==>Format and make sure the option for a boot floppy is checked.

8-)I understand how to do it from the different OS's.... what I am wanting to find out.. is how do you do it from a straight DOS 6.22 machine. No, I do not have a dedicated machine running DOS 6.22. I NEED this for work. So far, I can not figure it out.

SFrom a DOS machine is EXACTLY like Win9x:

Run from the command line (prompt)

format /s /v:label drive:

Win9x is just DOS dressed in a fancy GUI or format a: /u/sNow what does the /s and the /u and the /v stand for?Please read the text under my picture, then click here.Thank you very much for all your help.If you have any other questions/problems, feel free to post again.

4002.

Solve : Using if command with find?

Answer»
Finding whether a particular string is PRESENT in a text file can be done with the help of
FIND COMMAND.

How can we use the RESULT whether a string is found or not in an IF command and perform
some commands for each case i.e when the string is found and when it is not found .

Are there any VARIABLES that can be SET using the find command for its SUCCESS or failure results ?Immediately after thefind, test errorlevel, a value of 0 means found, 1 is not found

Graham
4003.

Solve : Hot to plus two numbers in DOS??

Answer»

There is needed for an auto-incrementing version number in my software build process.
I want to place the version number(like 2.0.3.6) in a .txt file, and the txt file just has one row.
Now i want to know whether it can plus two numbers in DOS and return result?
Thinks!
Use help SET
I have extracted the relevant part below


SET /A expression
The /A switch specifies that the STRING to the right of the equal sign is a numerical expression that is evaluated. The expression EVALUATOR is pretty simple and supports the following operations, in decreasing order of precedence:

() - grouping
! ~ - - unary operators
* / % - arithmetic operators
+ - - arithmetic operators
<< >> - logical shift
& - bitwise and
^ - bitwise exclusive or
| - bitwise or
= *= /= %= += -= - assignment
&= ^= |= <<= >>=
, - expression separator

If you use any of the logical or modulus operators, you will need to enclose the expression string in quotes. Any non-numeric strings in the expression are treated as environment variable names whose values are converted to numbers before using them. If an environment variable name is specified but is not defined in the current environment, then a value of zero is used. This allows you to do arithmetic with environment variable values without having to type all those % signs to get their values. If SET /A is executed from the command line outside of a command script, then it displays the final value of the expression. The assignment operator requires an environment variable name to the left of the assignment operator. Numeric values are decimal numbers, unless prefixed by 0x for hexadecimal numbers, and 0 for octal numbers. So 0x12 is the same as 18 is the same as 022. Please note that the octal notation can be confusing: 08 and 09 are not valid numbers because 8 and 9 are not valid octal digits.

Graham

4004.

Solve : Batch file logging question?

Answer»

I am using the following to del an old log file that a batch file creates:

if exist directory\log del directory\log

What I would like to know is how to create a new log each TIME the batch file is ran with the date and time included in the file name. So I have a RUNNING COUNT of each time the batch file was ran and when it was ran.

Any help would be appreciated.This was answered:

if exist stop.log ren stop.log stop_%%c%%a%%b%%t.log

Thanks all.How to make a unique string out if %date% and %time% is described here:

http://dostips.cmdtips.com/DtCodeSnippets.php#_Toc129970589

The created string can be USED as as target file name:


Code: [SELECT]for /f "tokens=2-8 delims=/:. " %%A in ("%date%:%time: =0%") do set UNIQUE=%%C%%A%%B%%D%%E%%F%%G
ren stop.log stop_%UNIQUE%

4005.

Solve : Netpath?

Answer»

I was wondering how to netpath. I need it to remote shutdown my sisters comp, and it says I need a network path. I was curious if there is a way to make one. Any help is accepted.You... want to remotely SHUT down her comp? Just out of sheer morbid curiosity - why would you want to do this?A network path takes on the format of:

\\computername\sharename\...

The computername is whatever was defined during the OS install.

The share NAME can either be set up by the user (recommended) or you can use the administrative shares (C$, D$, etc)

UNLESS you and your sister are members of a domain, you cannot run jobs on a remote computer.

8-)What if she runs a LAN off the router in my room? Can I still make a path through the router?I would think the point of the router would be to network a bunch of computers. By defining shares on each computer, you can access those shared drives, folders, files by building a connection (net use).

For instance, if drive D is shared on a remote computer, you can build the connection to be say, drive X on your computer. You now have access to all the file and folders on drive D from the remote machine only you use drive X in accessing them. It get more COMPLICATED than this of course. Microsoft uses a simple file sharing MECHANISM which allows such sharing. To actually run jobs on a remote computer, one computer in the network needs to run Server software.

Happy Computing. 8-)

4006.

Solve : net logoff??

Answer»

I KNOW that net logoff BREAKS the connection between network connected computers but would the connection between shared drives or folders be broken??The connection will be broken to the remote MACHINE unless they are persistent (a BOOT has the same effect). Shares remain in effect (even thru a boot) until they are specifically deleted.

8-)

4007.

Solve : dos window to close after starting the program?

Answer»

hello. I have a program that does not PLAY nice with our main SQL based application CALLED automate. I have a need to stop the service and restart the service and the additional exe that allows the program to run. I have so far
@echo off
net stop "AutoMate 6"

and one to start it

@echo off
net start "AutoMate 6"
"c:\program files\automate 6\amem.exe"

The issue is I would like the DOS window to close after starting the program. Right now it remains OPEN.To close the prompt, add "exit" to the end of the batch... 8-)no joy it stays open until the app is closed...

4008.

Solve : Batch help...?

Answer»

Hi guys,

Trying to write a batch file for work which will zip the contents of a folder (.jpg snapshots from CCTV system) then delete the original if the zip exists then re name the zip with a Timestamp.

Managed to do all this using PKZIP and NAMEDATE, a small program I found on the net.. coding is...

cls
c:\batch\pkzip -a 1.zip *.jpg
IF EXIST 1.zip (del *.jpg)

c:\batch\namedate /O-1 /Y 1.zip

Not exaclty pretty but does the job. Is there anyway I cam include the PKZIP.exe and NAMEDATE in teh batch file to make it totally standalone and not RELIANT on them existing in c:\batch ?

If not is there another BETTER way to do it?

Thanks

PhilThere is no way of storing an exe in a batch file (without perhaps converting the binary to hex format, writing it out to a .hex file and using debug to recreate the original)

However you can use batch string slicing to convert %Date% into just digits and rename your zip file, getting rid of the need for namedate ... you will still have to refer to PkZip, but you could check it is there before running and stop with an appropriate error message if it doesnt.

GrahamThanks - can you point me to somewhere that explains splicing the batch date string?

PhilWithout an OS it's difficult to know if you have access to the %date% string. If you do, this may work:

Code: [Select]for /f "tokens=2-4 delims=/ " %%a in ("%date%") do set dt=%%c-%%a-%%b

You can use %dt% anywhere in your batch file as needed. You can ALSO scrunch the date without the hyphens by using set dt=%%c%%a%%b

Note: The format of the date is dependent on your local settings.

8-)Using command prompt through Win XP SP2... Regional settings are set to Spain.

CHeers!!!!If your date is day/mon/year then %%a=day, %%b=mon, %%c=year

If your date is year/mon/day then %%a=year, %%b=mon, %%c=day

Be sure to use the correct delimiter (/ or -)

There is a pattern to this madness! Once you've got the tokens, you can arrange them anyway you wish.

Good luck. 8-)

On XP, using a windows script would be much easier. You could get each discrete piece of the date directly, letting the system worry about the regional settings and the delimiters. Never used windows scripting... any pointers to it?

Thanks!

PhilOh one other thing... If i want to rename it to yesterday´s date?An easy way to get yesterday's date would be to subtract 1 from the current day. Of course nothing is that easy.....after all, what would plan on doing if today was say, Apr 1?

Batch language does not easily do date/time arithmetic. It can be done but you have to jump thru hoops to get there.

Check out the Script Center for date/time techniques and much more.

Good luck. 8-)Thanks for you help guys, read through the Windows Scripting site but think for this project will stick with the batch file.

As I have to do this batch in 4 different directories I´m trying to use the call command to run the batch files from one main batch file.

The subfolders contain the following batch file... ruben-ext1.bat..

cls
c:\batch\kmra\pkzip -a Accts.zip *.jpg
IF EXIST Accts.zip (del *.jpg)

c:\batch\kmra\namedate /O-1 /Y Accts.zip
move *.zip "c:\batch\kmra\Accts\Archived"

and the main batch file is...

cls
call c:\Batch\Kmra\Accts\ruben-ext1.bat

Now if I run ruben-ext1.bat it RUNS fine and as it should but if I run it from the main batch file I get an error from PKZip (E12) nothing to do!

Anyone help?

Cheers!

Anyone?? :-?If the master routine is in the parent folder, then calling the subfolder\subbatch leaves the current (ie working) directory as the parent, the subbatch needs to either
cd to the working folder and cd to the parent after
or
always refer to the path (absolute or relative) where the files live

GrahamThanks graham, but not sure if thats my problem... reason being I changed the file in the second batch file to do another command other than pkzip and that worked fine...? Is there a known problem with PKZip and the Call command cos thats all I can think it is now....

Thanks!Where are the jpg files? Unless they are in the current directory, it's doubtful that pkzip can find them. As GPL mentioned, you need path names for excutable files unless they live in the current directory or they are on your PATH. Parameters (ie. *.jpg) also need paths if they do not exist in the current directory regardless if they exist in the PATH.

Paths can be fully qualified or relative but are needed so the OS can find all the pieces of your run unit.

Good luck. 8-)GOT IT!!!!! THANKYOU VERY MUCH!!!

Cheers guys, really appreciated!!!!!

4009.

Solve : What did I do wrong??

Answer»

I have a bunch of joke programs on my computer (NAV doesn't like it, the old codger) and some are customizable with the command prompt. I'm writing a batch file to execute these programs with these special functions.

Each time I INPUT something into the prompt (namely, a PROGRAM file) the program swears up and down the program doesn't exist. Why? What did I mess up at?

Code: [Select]@ECHO OFF
cls
ECHO This batch file will simulate a bombed program. It will place it in the startup
ECHO folder so it will run at next startup.
:begin
set choice=
set /p choice=Choose program to bomb:

IF EXIST %choice% GOTO create

ECHO Sorry, the specified program does not exist.
GOTO begin
This is only a block; ":create" does exist in the file.The batch file looks reasonable. What exactly did you type at the prompt? Drive and pathname would required unless the bomb program exists in the current directory along with the batch file. The IF EXIST will not search the PATH as would a procedure call.

Just my 2¢ worth. 8-)I knew I was in C:\Utilities, so I typed in

C:\Program FILES\Opera\Opera.exe

A quick check of my quick-launch shortcut shows the file does exist at that directory.With an embedded space in the path, you would need to quote your entry:

"C:\Program Files\Opera\Opera.exe"

8-)Thank you.

I have one other issue. I want to create batch files with another batch file. I followed the code posted here but it didn't work.

My full code:

Code: [Select]@ECHO OFF
cls
ECHO This batch file will simulate a bombed program. It will place it in the startup
ECHO folder so it will run at next startup.
:begin
set choice=
set /p choice=Choose program to bomb:

IF EXIST %choice% GOTO create

ECHO Sorry, the specified program does not exist.
GOTO begin

:create
REM - creates the batch file and writes it
ECHO @echo off > bombtemp.bat
ECHO cd \Documents and Settings\Timothy\Start Menu\Programs\Startup\ > bombtemp.bat
ECHO @echo off > bombtemp2.bat
ECHO cd \Documents and Settings\Timothy\Desktop\Desktop Games\ > bombtemp2.bat
ECHO bomb.exe '%choice%' > bombtemp2.bat
ECHO cd \utilities > bombtemp2.bat
call bombtemp.bat
del bombtemp.batYou would need to use >> for all but the first line to be outputted. This will ensure you get a new COPY of your batch file each time it runs and that the lines are appended to the file and not overwritten.

I belive the link you provided made that point. Quote

create
REM - creates the batch file and writes it
ECHO @echo off >> bombtemp.bat
ECHO cd \Documents and Settings\Timothy\Start Menu\Programs\Startup\ > bombtemp.bat
ECHO @echo off > bombtemp2.bat
ECHO cd \Documents and Settings\Timothy\Desktop\Desktop Games\ > bombtemp2.bat
ECHO bomb.exe '%choice%' >> bombtemp2.bat
ECHO cd \utilities >> bombtemp2.bat
call bombtemp.bat
del bombtemp.bat

You may have missed a few, also create needs a colon in front. I presume that bombtemp and bombtemp2 are meant to be two different files.

Code: [Select]:create
REM - creates the batch file and writes it
ECHO @echo off > bombtemp.bat
ECHO cd \Documents and Settings\Timothy\Start Menu\Programs\Startup\ >> bombtemp.bat
ECHO @echo off > bombtemp2.bat
ECHO cd \Documents and Settings\Timothy\Desktop\Desktop Games\ >> bombtemp2.bat
ECHO bomb.exe '%choice%' >> bombtemp2.bat
ECHO cd \utilities >> bombtemp2.bat
call bombtemp.bat
del bombtemp.bat

8-)OK, I revised that code. My intention is as follows:

Write a "bombtemp.bat" batch file, which includes instructions to create another batch file in the startup folder, which will execute the code.

Ideally, I should have the following in the end:

In C:\Utilities\bombtemp.bat:

Code: [Select]cd \Documents and Settings\Timothy\Start Menu\Programs\Startup\
@echo off > bombtemp2.bat
cd \Documents and Settings\Timothy\Desktop\Desktop Games\ >> bombtemp2.bat
bomb.exe '%choice%' >> bombtemp2.bat
cd \utilities >> bombtemp2.bat
In C:\Documents and Settings\Timothy\Start Menu\Programs\Startup\bombtemp2.bat:

Code: [Select]@echo off
cd \Documents and Settings\Timothy\Desktop\Desktop Games\
bomb.exe '%choice%'
cd \utilities
And that's it. I used this batch file to achieve this:

Code: [Select]@ECHO OFF
cls
ECHO This batch file will simulate a bombed program. It will place it in the startup
ECHO folder so it will run at next startup.
:begin
set choice=
set /p choice=Choose program to bomb:

IF EXIST %choice% GOTO create

ECHO Sorry, the specified program does not exist.
GOTO begin

:create
REM - creates the batch file and writes it
ECHO @echo off > bombtemp.bat
ECHO cd \Documents and Settings\Timothy\Start Menu\Programs\Startup\ >> bombtemp.bat
ECHO @echo off > bombtemp2.bat >> bombtemp.bat
ECHO cd \Documents and Settings\Timothy\Desktop\Desktop Games\ >> bombtemp2.bat >> bombtemp.bat
ECHO bomb.exe '%choice%' >> bombtemp2.bat >> bombtemp.bat
ECHO cd \utilities >> bombtemp2.bat >> bombtemp.bat
call bombtemp.bat
What I got was "bombtemp.bat" in the startup folder with this code:

Code: [Select]@echo off
cd \Documents and Settings\Timothy\Start Menu\Programs\Startup\
@echo off
cd \Documents and Settings\Timothy\Desktop\Desktop Games\
bomb.exe '"C:\Program Files\Opera\Opera.exe"'
cd \utilities
What the heck did I do wrong?Somewhere along the way this seems to have changed. In any case you need to escape certain characters to pass them thru a redirection:

^> should pass a single > to the output file
^>^> should pass a double >> to the output file

You just gotta love the brains that came up with this stuff.
4010.

Solve : command??

Answer»

Hey,

Is there a command that enables a user, while a batch file is running to ENTER a file NAME so the batch file can PROCESS it?Depends on your OS. This works on some machines:

Code: [Select]set /p fname=Enter file name:

You will be prompted with "Enter file name:"

%fname% will take on the VALUE you type in. You can USE it anywhere in your batch file where appropriate.

Hope this helps. 8-)

4011.

Solve : finding files to erase?

Answer»

Hi

I have 3 FILES in Local Settings\Temp INTERNET Files and cannot remove them in WINDOWS. When I go into DOS via a floppy I cannot find the Directory for Local Settings. Any ideas anybody?

ThanksGoogle for KillBox.

4012.

Solve : Making backup?

Answer»

Hi, I made a batch file that makes a backup folder:
Code: [Select]@echo off
del c:/backup/*.*
xcopy [highlight]c:/backup files/*.*[/highlight] c:/backup/*.*
ExitFirst of all, what files do you think are nessesary(scuse my spelling) to make a backup of?
And I was wondering if it is possible to set this batch file to complete these tasks once a day, without having to open it??
THANKS!Quote

First of all, what files do you think are nessesary(scuse my spelling) to make a backup of?
This really depends on you, probably your my doctuments folder, with your doctuments, music, videos and pictures in it.

Quote
And I was wondering if it is possible to set this batch file to complete these tasks once a day, without having to open it??

just go to Scheduled Tasks in control panel and add the select the file and set it to run once a dayI see one problem: You're going to delete these backups once a day with that code. I'd be careful about that.You may want to CHANGE the / to \ as well.thanks everyone. I'm first I,m manually going to create back up and then it will be deleted everyday and replaced!Just curious: Why do you want these backups deleted every day?because I don't want like FIFTY backup folders!!You wouldn't GET fifty folders. You'd get all the backups in C:\backup\*.* (assuming the folder already EXISTS)
4013.

Solve : shutdown???

Answer»

would this work or would you have to put "-m \\4ag4d7888" after "-f -s".
Code: [Select]@echo off
shutdown [highlight]-m \\4ag4d7888 [/highlight]-f -s
exitLooking over your PAST posts, you have yet to mention your OS or what kind of network you have.

Will this work?:

shutdown -m \\4ag4d7888 -f -s

Sure, if you have a computer named 4ag4d7888 and you're on a domain. If this is a peer-to-peer network (workgroup) then no.

Try to give us the info we need to make an informed response.

8-)I have win XP. And what do you mean by "kind of network".Networks come in FLAVORS. Domains can be defined with one computer running OS server software and acting as the domain controller (server). Remote computers can be attached to the domain either wired or wireless. This type of network is generally found in schools and business.

Peer-to-Peer networks (generally found in homes) are where remote computers also connected, wired or wirelessly but with no one computer acting as the server. Each computer in the network is a member of the same Workgroup. Home networks are used to share an internet connection. The file/device sharing is an extra bonus.

There's more to it than this of course, but this will do for now. Workgroup computers use a simple file sharing mechanism that allow you to share FILES and devices across the network. However, any one computer on the network cannot submit jobs for execution to a remote computer. Even though you can "SEE" remote files and devices, there is no path into the remote OS. For home networks this is usually enough and doesn't require any one person to act as the network adminstrator.

The books written about networks, how to set them up, and the protocols involved COULD probably fill a library. Google has reems of pages on this topic.

8-)then I have a peer-peer network!!!Then you cannot shutdown a remote computer.

4014.

Solve : Batch file question 2?

Answer»

Hey,

Here's another batch file question. How would you create a batch file that provides help for three DOS commands, each in seperate screen. The TEXT for each help screen should be stored in a seperate file. The batch file should provide for these scenarios:

1) No PARAMETERS entered
2) Available options
3) UNAVAILABLE options

If someone could help me write this, it would be appreciated.

Thanks a bunch! help already exists. Type the COMMAND, and end with /?.

Like this:

Code: [Select]type /?
GIVES you help with the type command.

4015.

Solve : batch help needed, appearance, net name......?

Answer» HI im looking for some help for batch commands

i was WONDER how i can change the appearance of the cmd window, eg if i can remove the title and scroll bar and how to sent the window and font size
im using the command net name NAMEHERE /add, i was wondering if you could make it a hidden name that doesnt appear on lists of users on the network?
and finally how to add a question at the end eg. "if you want to continue hit enter or press esc to exit"

thanks Quote
i was wondering if you could make it a hidden name that doesnt appear on lists of users on the network?
Why would you want to do that?just so it doesnt clog up the network and people can see what PCS are on the network instead of lods of "screen NAMES" coming up ASWELL
4016.

Solve : Need help.. FTP Uploader?

Answer»

I am trying to make a .BAT FILE that uploads a file when he is draged to the .bat file..

For example , i have a pic.jpg and i want to upload it just by dragin it to icon of the .bat file..
(the original idea is to use the Send To menu, by outing the bat file in the Send To folder)

My problem is: how do i make the path & FILENAME in a variable... /because if you drag a file to CMD it will give you the path...\ i want to use that path to upload..

This is what i got now: [ 2 FILES a .bat and a .dll witch is the FTP script ]

1. The conection.dll -> FTP Script for conect
Code: [Select]open ftp.host.com
username
password
cd www
put
HERE I NEED THE PATH/FILENAME
Update.txt

2. The FTPit.bat -> The trigger witch runs FTP

Code: [Select]
@ECHO OFF
title FTP QUICK UPLOADER
ECHO FTP QUICK UPLOADER
ftp -s:conection.dll
PAUSE

After dropping the file on the bat, it's file name will be available in the batch as the first ARGUMENT, i.e.
"%~1" or better "%~f1".

For ftp upload scripts you might want check this out:
http://dostips.cmdtips.com/DtCodeBatchFiles.php

DOS It Help?

4017.

Solve : Del files by date?

Answer»

I need a batch file that can delete files by date and or time, using current date/time as a gauge..any help would be appreciated....this will be used in a windows 2000 environmentDelete files from where? A single directory? A tree structure?

Quote

using current date/time as a gauge
Used how? Are you aging files?

More questions than answers. XCOPY has a date parameter. You could be super clever and extract the current date (mm-dd-yyyy) from %date% (%date% has that pesky day of week embedded), copy the files you want to keep to a temp directory, delete all the files in the current directory, then copy all the files from the temp directory back to the original directory.

On the other HAND, you could write a script. The following will age files in a tree structure, deleteting all over 30 days old:

Code: [Select]Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("c:\temp") '&LT;== change as needed
Set colSubFolders = f.SubFolders

For Each objFolder in colSubFolders
ShowFiles objFolder
Next

Sub ShowFiles(Fld)
Set k = fso.GetFolder(Fld)
Set s = k.SubFolders
Set kf = k.Files

For Each objFile In kf
If objFile.DateCreated < date - 30 Then
Wscript.Echo objFile & " " & objFile.DateCreated '<== change
End If
Next

For Each SubFolder In s
ShowFiles SubFolder
Next
End Sub

Save the script with a vbs extrnsion and run from the command line as cscript scriptname.vbs

As written, the script will list the files to be deleted. If you agree with the results change the entire WScript.Echo line to
fso.DeleteFile objFile, True. You could also change 30 to any number.

Windows has many tools that are far better than batch language. This might just be one of them.

Hope this gives you some ideas. 8-)
would this script also work in windows 2003, i TRIED it and all i get is the windows script VER. and copy write info. is there something i'm doing wrong?Without knowing what directory you pointed the script to check, it would be difficult to guess what went wrong (if anything). One possibilty would be that none of the files in the directory are over 30 days old.

Yes, the script will work on all Window versions starting with Win95C.

Note: If you left in the WScript.Echo statement, the script should have listed all files over 30 days old. If you replaced that line with the fso.DeleteFile statement, there would be no output except the copyright info.

Posting the script that you actually ran, and a DIR listing of the directory the script points to might be helpful.

Let us know. 8-)The following command would delete TheFile only when it's time stamp is equal or older than a given RemoveDate.

set TheFile=myfile.txt
set RemoveDate=03/01/2006
xcopy "%TheFile%" .. /L /D:%RemoveDate%|find "0 File(s)">NUL&&del /q "%TheFile%"


Running xcopy with option /L will only pretend to copy.
Running xcopy with option /D:<Date> will only copy files newer than a given date.
The find command would only succeed when 0 files would be copied, which means when the file is not newer than the given date.
The && ensures that the del command only executes when the find command succeeded, so to say when the file is not newer that the given date.

Hope this information is useful
4018.

Solve : deleting files?

Answer»

HI EVERYONE hope everyone is OK.

I am wondering if it is possible,


I want to be able to run a script that deletes all files within a profile folders


basically i have somthing like this setup

folder locations

\\servername\students$\2001\username\profile


ok so replacing the username with the name of that USER.

i want to be able to have a script frun through all these folders and delete everything in the profile folder.

So i was trying somthing like this


ECHO
cd \\servername\students$\2001\%FOLDERNAME%\profile
del *.*


though the %foldername% is an INVALID swtich.


Anyone know if this is possible and if so how.


any help is much appreciated.


Thanks for your time.


Chris SmallThis should werk in dos mode!:
Code: [Select]del "\\servername\students$\2001\%FOLDERNAME%\profile\*.*"
If you are wanting to make a batch file to do it, this would be the code:
Code: [Select]@echo off
del "\\servername\students$\2001\%FOLDERNAME%\profile\*.*"
exitWhat are you actually wanting to do this for??With a loop around it, the following should do what you want:
Code: [Select]set list=%temp%.\students.txt
dir /ad/b "\\servername\students$\2001\">"%list%"
for /f "usebackq tokens=*" %%a in ("%list%") do del "\\servername\students$\2001\%%a\profile\*.*"The first line defines a file student.txt that will temporary store all student names.
The second line dumps all students into student.txt, assuming that the 2001 folder only contains student folders.
The third line loops through all students listed in student.txt and cleans the profile folder.

Hope this helps

4019.

Solve : Quick Batch question?

Answer»

I'm sure this has been asked a thousand times, but I've looked on Google and the forums: How do I set the current directory as a variable?set = I believe you've mentioned that you run XP. %cd% will work equally well.

8-)Using cmd.exe within XP, %CD% returns the current directory string variable:

%ALLUSERSPROFILE%
Local - Returns the location of the All Users Profile.

%APPDATA%
Local - Returns the location where applications store data by default.

%CD%
Local - Returns the current directory string.

%CMDCMDLINE%
Local - Returns the exact command line used to start the current Cmd.exe.

%CMDEXTVERSION%
System - Returns the VERSION number of the current Command Processor Extensions.

%COMPUTERNAME%
System - Returns the name of the computer.

%COMSPEC%
System - Returns the exact path to the command shell executable.

%DATE%
System - Returns the current date. Uses the same format as the date /t command. Generated by Cmd.exe. For more information about the date command, see Date

%ERRORLEVEL%
System - Returns the error code of the most recently used command. A non zero value usually indicates an error.

%HOMEDRIVE%
System - Returns which local workstation drive letter is connected to the user's home directory. Set based on the value of the home directory. The user's home directory is specified in Local Users and Groups.

%HOMEPATH%
System - Returns the full path of the user's home directory. Set based on the value of the home directory. The user's home directory is specified in Local Users and Groups.

%HOMESHARE%
System - Returns the network path to the user's shared home directory. Set based on the value of the home directory. The user's home directory is specified in Local Users and Groups.

%LOGONSEVER%
Local - Returns the name of the domain controller that validated the current logon session.

%NUMBER_OF_PROCESSORS%
System - Specifies the number of processors installed on the computer.

%OS%
System - Returns the operating system name. Windows 2000 displays the operating system as Windows_NT.

%PATH%
System - Specifies the search path for executable files.

%PATHEXT%
System - Returns a list of the file extensions that the operating system considers to be executable.

%PROCESSOR_ARCHITECTURE%
System - Returns the chip architecture of the processor. Values: x86, IA64.

%PROCESSOR_IDENTIFIER%
System Returns a description of the processor.

%PROCESSOR_LEVEL%
System - Returns the model number of the processor installed on the computer.

%PROCESSOR_REVISION%
System - Returns the revision number of the processor.

%PROMPT%
Local - Returns the command prompt settings for the current interpreter. Generated by Cmd.exe.

%RANDOM%
System - Returns a random DECIMAL number between 0 and 32767. Generated by Cmd.exe.

%SYSTEMDRIVE%
System - Returns the drive containing the Windows XP root directory (that is, the system root).

%SYSTEMROOT%
System - Returns the location of the Windows XP root directory.

%TEMP% and %TMP%
System and User - Returns the default temporary directories that are used by applications available to users who are currently logged on. Some applications require TEMP and others require TMP.

%TIME%
System - Returns the current time. Uses the same format as the time /t command. Generated by Cmd.exe. For more information about the time command, see Time

%USERDOMAIN%
Local - Returns the name of the domain that contains the user's account.

%USERNAME%
Local - Returns the name of the user who is currently logged on.

%USERPROFILE%
Local - Returns the location of the profile for the current user.

%WINDIR%
System - Returns the location of the operating system directory.Typing %CD% gives me basically a Bad Command or File Name error.

/me forgot the ECHO... fixed now...

Instead of just making ANOTHER thread, I'll ask it here: How do I stop the thing from changing to 8.3 format? It made the current directory variable C:\Utilit~1, when it should be C:\Utilities.

My simple code for TEST.BAT was:

Code: [Select]@ECHO OFF

SET currdir=%cd%
ECHO The current directory is:
PAUSE
cls
ECHO %currdir%
And currdir became C:\Utilit~1. This is a bad thing if I want to return the user to their previous directory. It does this every time I edit a BAT file or something like that.If it helps...

Off the top of my head, and it's Saturday evening so I'm probably completely wrong, use the /k switch to launch cmd.exe:
cmd.exe /k
Try cmd /? in a command WINDOW to check.Not sure I understand the problem. When I ran your batch file, I was able to use a long directory name without a conversion to a short name.

In any case, is not c:\utilit~1 equivalent to c:\utitlities? The OS seems to think so.

8-)Hmm. It's working now. Odd. Last time I put in that ~ it gave me a error... must have spelled it wrong.

/me bangs head slowly on computer

And it never goes to 8.3 when running a batch file - just when editing it.Dilbert,

Seems that the edit.com program is old DOS school and changes the shell format to 8.3. The script content itself is innocent.
If it bothers you then use notepad instead or even BETTER download one of the cool free editors like Crimpson from http://www.crimsoneditor.com.

4020.

Solve : Error when I open DOS?

Answer»

When I open DOS, it says:

Code: [Select]C:\WINDOWS\system32\cmd.com
C:\WINDOWS\SYSTEM32\AUTOEXEC.NT. The system file is not suitable for RUNNING MS-DOS
and Microsoft Windows applications.
Choose 'Close' to terminate the application.
I need it to open!Is autoexec.nt in your system32 folder?Quote

1. Click Start, click Run, type c:\windows\repair, and then click OK.
2. Right-click autoexec.nt, and then click Copy.
3. Click Start, click Run, type c:\windows\system32, and then click OK.
4. Right-click anywhere in that folder, and then click PASTE.
5. Right-click the Autoexect.nt file that you just copied, and then click Properties.
6. Click to select Read-Only, and then click OK.
7. Repeat steps 1 through 6 to copy the Config.nt file.

http://support.microsoft.com/default.aspx?scid=kb;en-us;324767Quote
Quote
1. Click Start, click Run, type c:\windows\repair, and then click OK.
2. Right-click autoexec.nt, and then click Copy.
3. Click Start, click Run, type c:\windows\system32, and then click OK.
4. Right-click anywhere in that folder, and then click Paste.
5. Right-click the Autoexect.nt file that you just copied, and then click Properties.
6. Click to select Read-Only, and then click OK.
7. Repeat steps 1 through 6 to copy the Config.nt file.

http://support.microsoft.com/default.aspx?scid=kb;en-us;324767

Ok, I fixed that. Now, in DOS it says:

Code: [Select]Cannot execute C:\WINDOWS\SYSTEM32\CMD.COM

Memory allocation error
Cannot load COMMAND, system halted
Can i REMOVE this?If they don't already exist, add these lines to the config.nt file:

dos=high, umb
device=%SystemRoot%\system32\himem.sys
files=40
And just to be clear that is NOT DOS. It is command PROMPT. cmd.com cmd.[highlight]exe[/highlight]
4021.

Solve : MSDOS, executing param. in a Bat file?

Answer»

Hello, for compress with UPX a file, for EXAMPLE I open a msdos window and type upx.exe -o calc.exe , where calc.exe is the file to compress, I want MAKE a bat file that when I open it, it do AUTOMATIC, how I do? :s help please If you want to HARDCODE this:

batchfile.bat
Code: [Select]upx.exe -o calc.exe

If you want to make this generalized for any file:

Code: [Select]upx.exe -o %1

By GENERALIZING this, you can drag the file (ie: calc.exe) over the batch file and it will run. You can also run your batch file with a command line parameter:

batchfile calc.exe

Good luck. 8-)

4022.

Solve : Sending files using Ms-Dos?

Answer»

Does anyone know how to do that(send files to other COMPUTERS using msdos?)?How are the computers connected?Well, the only way I know is to use the net command. The procedure would include connecting to a remote COMPUTER's shared folder/drive/device then use the copy command to copy the file/files to the specified drive letter.

The syntax of the command would be similar to something LIKE this
Code: [Select]net use X: \\remotemachine\shared
copy C:\test.txt X:\
You could use replace "X" with any letter you want. Although I wouldn't recommend using any of the ones that are already assigned by Windows; A:, C:, D:, and E: are common ones. Not sure what would happen. Replace "remotemachine" with the remote machine's hostname or IP address, and "shared" with the shared resource.Are you using real DOS on both machines, or some kind of command prompt within Windows? What version?The computers are connected by the same network connection(at school). I know you can send messages to other onnected PC's- net send [domain] [message]- and I have been told before that it is similar. :exclamationAnd I am using real dos on all machines! :exclamationQuote

And I am using real dos on all machines! :exclamation
Are you sure? I find it highly unlikely that your school keeps old DOS machines around these days. I find it more likely that you are confused into thinking that cmd.exe or command.com is DOS. These are just emulators for the DOS enviroment; not the real thing.
I agree. Until he overcomes this knowledge deficit all bets are off. Oh sorry, It's probably not DOS! :-/
I think its cmd.exe.Quote
Oh sorry, It's probably not DOS! :-/
I think its cmd.exe.
Well, then then my first reply should probably work FINE. You cannot send files with "net send" although another command in the net family "net use" would probably be the way to go.thanks, it works!Could you give me an example, cos I'm not sure i'm doing it right? :-? :-/First, you would find the remote computer's hostname or IP address. There are several ways to do this.
  • Type "hostname" in a cmd.exe CONSOLE session on the other computer.
  • Press WinKey + Pause/Break then select the Computer Name tab on the other computer.
  • Type "net view" in a cmd.exe console session to see all the machine on your network/workgroup.
  • Right click My Computer, select properties, and click the Computer Name tab on the other computer.
Secondly, you would type "net view " to see the shared resources on that computer. To access these resources you must use the net use command. For example, the syntax for connecting to a shared folder called "work" on a remote computer named "cheesy" would be "net use R: \\cheesy\work". This would assign the R: to the work folder on remote machine cheesy.

IMPORTANT: You cannot connnect to any shared resource on any target computer if it isn't shared.thanks!!
4023.

Solve : Don't quite understand this??

Answer»

Code: [Select]goto label%errorlevel%

:label0
echo Program had return code 0... No error
goto end

:label1
echo Program had return code 1... Error opening file
goto end

:label2
echo Program had return code 2... Error reading file
goto endThe part where it says "goto label%errorlevel%" Does it mean that it would jump to the ":label" that has the correct errorlevel beside it? And then do whatever tasks that are underneath it? And also, The % on either side of the errorlevel, would that mean that it changes?
If I had something like this:
Code: [Select]@echo off
cls
echo Hi, my name is %1
PAUSE
myname jack
then when you press any key (at the pause part) how does it know that the variable is jack? And if I wanted to make it display, "Hi my name is jack" And then when you press any key it displays "hi, yourname is suzanne" how would you do that?

Thanks to anyone who helps!Quote

The part where it says "goto label%errorlevel%" Does it mean that it would jump to the ":label" that has the correct errorlevel beside it? And then do whatever tasks that are underneath it? And also, The % on either side of the errorlevel, would that mean that it changes?

Yes it does change. Most MS commands issue errorlevels that can be checked in a batch file. (generally 0 indicates the command completed successfully; anything else indicates it didn't....there are exceptions!). Also, the actual compare for errorlevel is equal to or greater than which can present some challenges when checking the codes.

Myname.bat
Code: [Select]@echo off
cls
echo Hi, my name is %1
pause

The %1 is a command line parameter. The number part indicates which parm from the command line to use.

myname Jack
myname Suzanne

Each TIME the batch file myname is run, the first parameter on the command line is substituted for the %1 variable.

myname Jack will output Hi, My name is Jack
myname Suzanne will output Hi, My name is Suzanne

Hope this helps a little. 8-)

PS. Any good DOS book from the library should be ABLE to EXPLAIN this and MUCH more.thanks!
4024.

Solve : COPY MYFILE.TXT %userprofile%\Desktop???

Answer»

I was on the internet, learning(TRYING to learn) about variables, but I still don't really get it. One of the examples were:
Code: [Select]COPY MYFILE.TXT [highlight]%userprofile%[/highlight]\DesktopWhat would that do? Especially the highlighted part.That would copy the file onto the username's desktop.

Variables are objects whose values can change. Very useful in BATCH and programming.Some environment variable like userprofile are preset by the operating system. To get a list of current environment variables and there values OPEN a command prompt and type:

C:>set

You will get a list of all variables.
You can set a variable like this:

C:>set MYVAR=hello user

you can then use the variable like this:

C:>echo %myvar%

which will display on the screen:

hello user

Hope this GETS you started. For more info about the set command and the cool STUFF you can do with it type:

C:>set /?

Or just look up the command reference in the internet here:

http://dostips.cmdtips.com/DosCommandRef.htm#set

Hope this helps

Finally! After all these years I finally get how to use the SET command!!! thanks!!, I get it all now!! :exclamation Quote

Some environment variable like userprofile are preset by the operating system. To get a list of current environment variables and there values open a command prompt and type:

C:>set

You will get a list of all variables.
You can set a variable like this:

C:>set myvar=hello user

you can then use the variable like this:

C:>echo %myvar%

which will display on the screen:

hello user

Hope this gets you started. For more info about the set command and the cool stuff you can do with it type:

C:>set /?

Or just look up the command reference in the internet here:

http://dostips.cmdtips.com/DosCommandRef.htm#set

Hope this helps ;)

If I did that set thing on my computer to create a variable, would it work on someone elses computer. (if not, is it possible to change it on more than 1 computer?)The SET command works only on the local machine. Keep in mind that the SET command does not list all the variables available. %date%, %time%, %cd%, %errorlevel% are all available on some machines but you won't find them in any SET listing. Generally variables that are SET, live only for the duration of the command or cmd window and variables SET in one window are not available in another command or cmd window. As always, there are ways to get around this.

8-)thanks :exclamation
4025.

Solve : Logging events in batch file?

Answer»

Hello all,

I have created a simple batch file to restart multiple services on windows 2003 server. Pretty much I am just using NET stop and start to accomplish this. What I need to know is how to copy the output in the batch file to a log.

I use the FOLLOWING to log the date and time the batch file ran but I am unsure how to log the rest:

echo %date% %time% >> log

The batch produces the following type of output:

The Tpe service is starting.
The Tpe service was started successfully.

I would like that output to be copied into the log file.

Any help would be appreciated (new to batch files)

-DaveYou should be able to do this the same way you did the echo statement, with redirection:

command parameters >> log

Beware: Command requests for input will be redirected. The user will not see the requests and the batch file will hang WAITING for input. Example:

del *.* >> log

The "Are you sure (Y/N)?" message will be sent to the log file and wait for a response. The user will not see the prompt.

Happy Computing. 8-)Thanks for the INFO.

I am still not sure what the command would be to have the log say the following:

Date here
The Tpe service is starting.
The Tpe service was started successfully.

OK. I'm confused.

Quote

I have created a simple batch file to restart multiple services on windows 2003 server. Pretty much I am just using net stop and start to accomplish this. What I need to know is how to copy the output in the batch file to a log.

I use the following to log the date and time the batch file ran but I am unsure how to log the rest:

echo %date% %time% >> log

The batch produces the following type of output:

The Tpe service is starting.
The Tpe service was started successfully.

I would like that output to be copied into the log file.

If you used net start and net stop before, can you not simply redirect these commands to the log?

net stop servicename >> log
net start servicename >> log


I'm not familiar with the TPE service but you could also use the SC start servicename and sc stop servicename

It is also possible to capture command window output but you would need a non-batch script for that.

8-)
4026.

Solve : If SIZE=0 then ...?

Answer»

Hello,

I WOULD like to test the SIZE of a file and if this size is null (if there is nothing in the TXT file) then goto a next step.
My OS is W2003

Is there any genius who knows how to do that?

Thank you.

FranckWhat is the purpose of a worthless test.
In a Win2003 environment a SCRIPT can handle this thru the FileSystemObject and the GetFile method. Batch files can process file sizes only on call or for statements not on a if.

Hope this helps.

4027.

Solve : Output a file.Need Help!?

Answer»

how to use dos command to output a file (Ofile) from another file (Ifile) by reading position 10 to 12 in Ifile where it has value of 'XXX'Is your XXX is a word?hi,

I make my question more clearly.

Actually i want to know how to use dos command to output a file (Ofile) from another file (Ifile) by extracting SPECIFIC records. The records to be extracted are those records where character position 10 to 12 (in Ifile) has a value of '123'

For example: Ifile have 3 records which are:

ABCDFG123RTE
DRSERF234TEF
ADASSD123RTZ

So now i want to extract the record which from POSTION 7- 9 HAV value 123 into Ofile, so from this CASE, Ofile will output TWO records which are:ABCDFG123RTE and ADASSD123RTZ


Thanks a lot..

4028.

Solve : Spaces in dos?

Answer»

If I were making a bat file, that would be copying a file, say the directory the file was being copied to was "C:\Theres a SPACE here". What would I put to replace the spaces, because putting just a space does not work right.Why do you want to replace the spaces, just put it in quotes and it will work.Also, you can use this, say you are in the C: drive and you want to GO to My DOCUMENTS, obviously its GOING to give you that annoying parameters thing, so on the system i have i always type

cd c:/mydocu~1

You put no space, but make sure it doesnt exceed 8 characters, (INCLUDING the ~1) and yous houldn't have any problem.You have to use dir /x to know the ~ sign.

4029.

Solve : Bat file icons?

Answer»

Is there a WAY to change the icon of a .bat file?bat FILES dont have icons.....just script.

unless you did this>http://tips.oncomputers.info/archives2003/0305/2003-may-04.htmDepends on whats available to you in the PROPERTIES dialog. In W9x, under the program tab, you can click "change icon" and use any .ico or .bmp that you have on your machine. Be careful with the .bmp's as some do not show up well with certain BACKGROUND colors.Which OS?

4030.

Solve : Windows me dos?

Answer»

In windows me my explorer shell was changed USING aston program. Something went wrong and now only a blue screen appears at boot. I was told it was possible to use a win 95 boot disk to remedy this problem. Is there someone who can tell me how to use this to access my system files and change my shell back to explorer? I believe it's located in the system.ini FILE. Thank-you for any and all help or suggestions.Try going into Safe Mode at boot (F8 before the Windows logo) and choosing System RESTORE to a point before this error began. It sounds like it was very recent.

Let us know.

Thanks for your response. Safe mode brings up a grey screen with safe mode written in every corner. Still unable to access any files. I think it needs to have the explorer shell to boot into safe mode. Thanks again, any IDEAS are welcome.Ahh, the Blue Screen of Death?The last time that I saw DOS4WinME or similar installed, the only sensible option was a complete reinstallation of ME.

It is the System.ini file you're thinking about and a working file from a VM is listed here:

CODE: [Select][keyboard]
keyboard.dll=
oemansi.bin=xlat850.bin
subtype=
type=4

[drivers32]
msacm.lhacm=lhacm.acm
VIDC.VDOM=vdowave.drv
msacm.msaudio1=msaud32.acm
msacm.sl_anet=sl_anet.acm
MSACM.imaadpcm=imaadp32.acm
MSACM.msadpcm=msadp32.acm
MSACM.msgsm610=msgsm32.acm
MSACM.msg711=msg711.acm
MSACM.trspch=tssoft32.acm
vidc.CVID=iccvid.dll
VIDC.IV31=ir32_32.dll
VIDC.IV32=ir32_32.dll
vidc.MSVC=msvidc32.dll
VIDC.MRLE=msrle32.dll
VIDC.IV50=ir50_32.dll
msacm.iac2=C:\WINDOWS\SYSTEM\IAC25_32.AX
msacm.l3acm=C:\WINDOWS\SYSTEM\L3CODECA.ACM

[NonWindowsApp]
TTInitialSizes=4 5 6 7 8 9 10 11 12 13 14 15 16 18 20 22

[power.drv]

[drivers]
wavemapper=*.drv
MSACM.imaadpcm=*.acm
MSACM.msadpcm=*.acm
wave=mmsystem.dll
midi=mmsystem.dll

[iccvid.drv]

[mciseq.drv]

[mci]
cdaudio=mcicda.drv
sequencer=mciseq.drv
waveaudio=mciwave.drv
avivideo=mciavi.drv
videodisc=mcipionr.drv
vcr=mcivisca.drv
MPEGVideo=mciqtz.drv
MPEGVideo2=mciqtz.drv

[vcache]

[MSNP32]

[Password Lists]

[386Enh]
ebios=*ebios
woafont=app850.fon
mouse=*vmouse, msmouse.vxd
device=*dynapage
device=*vcd
device=*vpd
device=*int13
keyboard=*vkd
display=*vdd,*vflatd

[boot.description]
system.drv=Standard PC
keyboard.typ=Standard 101/102-Key or Microsoft Natural Keyboard
mouse.drv=VMware Pointing Device
aspect=100,96,96
display.drv=Standard PCI Graphics Adapter (VGA)

[boot]
oemfonts.fon=vga850.fon
shell=Explorer.exe
system.drv=system.drv
drivers=mmsystem.dll power.drv
user.exe=user.exe
gdi.exe=gdi.exe
sound.drv=mmsound.drv
dibeng.drv=dibeng.dll
comm.drv=comm.drv
mouse.drv=mouse.drv
keyboard.drv=keyboard.drv
*DisplayFallback=0
fixedfon.fon=vgafix.fon
fonts.fon=vgasys.fon
386Grabber=vgafull.3gr
display.drv=pnpdrvr.drv

[TTFontDimenCache]
0 4=2 4
0 5=3 5
0 6=4 6
0 7=4 7
0 8=5 8
0 9=5 9
0 10=6 10
0 11=7 11
0 12=7 12
0 13=8 13
0 14=8 14
0 15=9 15
0 16=10 16
0 18=11 18
0 20=12 20
0 22=13 22
If you use this, only use the relevant parts!
Whether this will work or not depends on exactly which software was used. In most cases, a lot of other fundamental changes are made.Quote

In windows me my explorer shell was changed using aston program.

What is aston program? We need to get specifics on the issues.On looking, it's not a "DOS implant" for WinME but a shell replacement:
http://www.astonshell.com/astonThanks for the responses. Yes aston is a shell replacement for windows, unfortunately it is not working for me. My comp. boots to a blue screen since there is no shell to load. If I could get into my system files somehow and change the shell back to explorer I think it would work out. Any advice on how to access files on an unresponsive computer from boot would be greatly appreciated. Thanks for the advice.Use a simple [highlight]boot diskette[/highlight] which contains Edit! More software with no purpose! Bling it on home to me!
4031.

Solve : Help me!(sidewinder?)?

Answer»

I dont understand this:
Quote

In the below example the computer WOULD map the Z: DRIVE to the network PATH //computer/folder.

net use z: \\[highlight]computer[/highlight]\folder
what would you put for "computer"?
Use the remote computer's name. If you right CLICK on My Computer==>Properties==>Computer Name tab you'll get the name of your computer. Using the same method on the remote computer, you can get what to use in a net use command.

There are other ways to do this, but this keeps it simple.

What kind of network is this?

Good luck. 8-)THANKS for the help. I'm sorry but I don't know what you mean by what kind of network it is?
4032.

Solve : Re: please plsease help me?

Answer»

Double-posts will not get INFO faster.

Please REPLY to this QUESTION in the Windows Forum, FOLKS. sorry about that i didnt know where to post it

im sorryIt's OK.

4033.

Solve : Batch File Change Directory?

Answer»

Ok I'm not using DOS but I am using batch files through windows xp command prompt.

but my PROBLEMS I'm working on pertain to the command line codes.

This one I'm working on now is probably not possible so I DECIDED to bring it to you to confirm.

In my batch I want to access the current user desktop.
This is a MULTIUSER environment in which the computers and their profiles get messed up a lot.

So there are some that have a name I could use to assume it's the right one or they may have that name with .000 .001 .workstation or various other things appended to it.

So is there a WAY to have a batch file goto something LIKE

cd c:\documents and settings\current user\desktop

any ideas at all?cd c:\documents and settings\current user\desktop

Almost. Substitute %username% for "current user"

SWEEEEET thanksFrom where can i get the list of all these user specific variables. Type set on the cmd and you see all variables.

uliOops,

So silly of me. I have another question related to this kind of.

I want to run a batch file that calls two other batch files in a different directory.

But I'm using a pen drive. So on 2 different computers the drive name would be different is there a way to get it to call the current device rather than a set device path?
I'm not aware of a way to do this in batch. Even a script solution where you could equate a volume name to a drive letter is no guarantee. It would only work if the pen drives had the same volume name.

You are probably SOL on this one.

I think SUBST can come to your help.

Do a cd .
This will give you the current directory.
Parse that string to get the drive.

Now use the Subst to assign a different drive letter.
Now with this call your scripts.

What do you think?

4034.

Solve : Operators?

Answer»

How to concatenate TWO strings in DOS otherwise what is the DOS command to concatenate two strings?Simply write them together.

eg.
If you have 2 string in 'a' and 'b' variables

set C=%a%%b%

will do that.

Hope that HELPS

4035.

Solve : RMDIR help?

Answer»

Can RMDIR /S /Q use wildcards?

such as in program files

RMDIR /S /Q AOL*

to get rid of folders named like
AOL
AOL instant messsenger
AOL explorer
AOL toolbar
Is there a WAY to do that if RMDIR can't?

Using WinXPI'm not aware that wildcards can be USED on the RD command. A script COULD be HELPFUL or you could do it the old fashioned way and use the GUI.

Good luck.

4036.

Solve : How can I for directory access.?

Answer»

I need to check if I have access to a directory. I'm doing this now, by trying to create a file in that directory and then I'm checking if it exists. In Visual Studio post build event that returns an error if I have no access. I don't KNOW how to get rid of that error.To check access to a directory, why not just try to open the directory?What do you mean? I can navigate to the directory. I just can not create objects there. So my check has to figure out if I'm allowed to create folders there.It seems odd that you can access it and yet not create files. If access was denied, you'd get a message saying "Access is denied" when you TRIED to open the folder.

Are you the ADMINISTRATOR of your computer?What do you mean? On Windows you can view a folder the files in the folder, but you may not be able to let's say create a file in that folder.

I'm an Admin on my machine.I'm not entirely sure what you're trying to do here but /a:x and /d switches of the dir command used in conjunction with each other may prove USEFUL. It can be used to return all the directories in a location with chosen attributes set and redirect those results to a file or device.
The /a:-x switch will return directories with the chosen unset attributes.

The "x" above refers to the following qualifiers:

D Directory bit
R Read-only bit
H HIDDEN bit
A Archive bit
S System bit

4037.

Solve : Redirect output of a command to variable?

Answer»

The BATCH script which I POSTED works for me.

I/P
File: IP.txt
ip:127.0.0.1:SERVER1
ip:127.1.1.1:Server2
ip:1.1.1.1:Server3

O/P:
Server1 [OK]
Server2 [OK]
Server3 [Not OK]

File : Not_Ping.txt
Server3:1.1.1.1 @ Fri 10/28/2005 13:17:01.34

4038.

Solve : Using network drives in a batch file?

Answer»

Hi

I am trying to copy a file from a server using the copy command. HOWEVER DOS won't let me use \\ to reference the correct drive. The drive isn't always the same on different PC's so I can't assume it will always be H: for example.

Please help


ThanksYou can map it in your batchfile (with an usual UNUSED drive letter).
Quick and dirty:

net use y: /delete

net use y: \\share you want

xcopy ....

net use y: /delete


Or find out the correct drive with:

net use
find the drive letter to the share
put it in the copy command.

hope this helps
uli


Hi Uli

I had thought of doing it the way you suggested but I'm worried I disconnect someone's mapped drive. Is there perhaps another way?

ThanksYes it is.
If I understand right, you want to run the batch on every client and it copys a file from a server to the client.
(If it should run on the server and copy FILES to clients you just have to map the client with no worry about used drive letters. You can do it in a for LOOP.)

net use shows you the mapped drives.

find "searchitem" finds the line where the mapped drive is listed. with its drive letter.

With a for statement you can get out the drive letter and put it in the copy command.

This works for me:

net use | find "search item" >share.txt

for /f "skip=2 tokens=1 delims=:" %%a in ('find "\\server\share" share.txt') do set dl=%%a

echo %dl:~13,1%
(Replace echo against copy...)

But it depends how the output of net use command looks on your screen.
echo %dl:~13,1% Shows me one letter after the 13th letter in variable dl.
(Works on NT/W2K/XP)

hope it helps
uli


Being very new to this, it took me a little while to figure it all out but I think I've got the hang of it now.

On most PC's the drive I'm looking for is only mapped once but on a few of them it has been mapped twice. In this case my output file gets two entries, ie.

OK H: \\drive\folder Microsoft Windows Network
OK \\drive\folder Microsoft Windows Network

Because there are two lines in the file the variable gets over-written with the last line in the file. Unfortunately it's the first line that contains the letter the drive is mapped under. I've tried various techniques to edit this file using edlin and find and replace but to no avail. Do you have any suggestions?If it always looks like the example you posted, you have ":" only in the first line, which you want.

For .....do echo %1 |find ":"

And you will only get the line with ":"
To get in in variable makes a subvariable necessary....

MAYBE it is not the right way. Looks a bit strange, I wouldn´t use this myself.

Is there a drive letter which is never used? (Like y or z?)
Then you could map this driveletter.
Or can you do the mapping in the logonscript?

If you copy the file just once it is better to do it from your pc. You can map the pcs and it doesn´t matter which drive letters are used. (Thats what I do)

Sorry, but the longer I think about my suggestion from yesterday less I like it. Sorry.

uli

I agree that it probably isn't the best way to go about it but now I'm more interested in learning the techniques and commands.

I've got it all working now but have hit a snag. If I type each line into the command prompt everything works. But if I run it as a batch file it doesn't work.

The line 'net use | find ": \\driver\folder" > c:\share.txt' becomes 'net use | find ": \\driver\folder" 1>c:\share.txt'

Please help

4039.

Solve : How to del files with /q and /f?

Answer»

for some reason this doesn't work:(am I doing it wrong?)
Code: [SELECT]@echo off
del C:\Documents and Settings\User\My Documents\CCF00362006_00001 [HIGHLIGHT]/Q /f[/highlight]
exitQuote LONG FILE names:

Code: [Select]@echo off
del "C:\Documents and Settings\User\My Documents\CCF00362006_00001" /q /f
exit

8-)thanks

4040.

Solve : search for a string ina txt document using batch?

Answer»

i K now this is PROBABLY really n00b, but i was wondering how to search for a word inside a .txt document, using the if command. so far i have:

@ECHO OFF
IF NOT adam==test.txt del "test.txt"
pause

it works if the document only CONTAINS the word adam. i was wondeing if you could help me in finding a command that searches for the word not just COMPARES it. yes i have tried using findstr like,


@ECHO OFF
IF NOT findstr adam command del "test.txt"
pause

:exclamationbut then it desnt workYou were close in your example; you should check ErrorLevel after your FindStr

@ECHO OFF
findstr adam command
IF ErrorLevel 1 del "test.txt"
pause

If the text is found, errorlevel is set to 0, otherwise it is greater than 0 - 1 means not found
Grahamoh ok, thanks. i didnt really understand errorlevel so i was trying to stay away from iti tried that but it didnt work, so i changed it a but and came up with this

@ECHO OFF
findstr /i /c:adam "test.txt"
IF ErrorLevel 1 del "test.txt"
pause

this one works, if you want the text to be case SENSITIVE you dont put the /i

4041.

Solve : CAN SOMEONE PLEASE HELP ME?

Answer» HI all.

This is my 1st time here and i am a complete NOVICE with pc's so please bear with me.

I have got programs on disks that i have been able to INSTALL and un-install without any PROBLEMS before but lately, when i try to install certain programs all i get is this message....

C:\WINDOWS\SYSTEM32\AUTOEXEC.NT. The system file is not suitable for running MS-DOS and microsoft Windows applications.

Does anybody have any ideas as to why i am getting this problem

Thankyou to anyone who can help me

NikiHave a read .... It may hold the solution you are looking for ......

http://support.microsoft.com/default.aspx?scid=kb;en-us;324767


dl65 Thanks. will give it a try
4042.

Solve : dos and regedit?

Answer» UMM.. is there any way to open regedit from a command PROMPT?
The system is win2000 and its a school computer so THATS why i cant get to it thru run because run is disabled.
can anyone help?if it's a school computer you probably should LEAVE it ALONE.
4043.

Solve : Copy entire folder structure?

Answer»

Is there any DOS command that can COPY entire folder STRUCTURE from source to DESTINATION.The normal copy command
Copy \*.* \ will ignore the subdirectories within the and only copy the other files within

Thanks in advamce for any HelpUse XCOPY /E See here...Try this:

CODE: [Select]XCOPY [source] [destination] /E
Good luck. 8-)

[edit]We POSTED at the same time, Dusty and I. [/edit]

4044.

Solve : setting ip address?

Answer»

hello all, i am harish and i am NEW this board. i have got quick question about the SETTING an ip address. is there any command to set the ip address from the DOS. well, it can be floolish question. but i really dont now. but one thing i can REMEBER that. when i was working on a ROUTER simulatore i use to use a command 'winipconfig'. to set the ip address but it dosnt WORK on a phycial system. can anyone help out in this.

thank you

ssharishDo you mean networking!yes exactly

ssharish

4045.

Solve : installing cd rom in dos?

Answer»

Hey there guys,

I have a laptop that has had the hard drive recently formatted,

i need to install the cd driver to ENABLE the windows o/s to be installed

i have copied the oakcdrom.sys file to the hard drive

what do i have to do next??You would be better off going to BOOTDISK and DLoading a Win98 bootdisk, extract it to a floppy and boot from it.

The scenario you describe can be remedied by writing an autoexec.bat and config.sys file in order for those CDROM drivers to load but without knowing what HARDWARE is in that machine i wouldn't EVEN attempt it.

patio. What operating system are you loading......and the specs of the laptop is/?Thanx guys

I went to bootdisk and got the winxp boot discs

and followed that procedure

4046.

Solve : DOS networking?

Answer»

Hi all,
Lots of good info here.
I am trying to get networking up on a DOS 6.2/Windows 3.1 machine. I am using a Realtek 8139 PCI card. I think I have the right DRIVER but need help configuring config.sys/autoexec.bat files. Thanks ahead of time to any and all that can help.

Mikekc8
Do you have a INTERNET browser?I have SEVERAL COMPUTERS(XP PRO) on a server based home network.Maybe this will help>http://www.softpedia.com/get/Network-Tools/Misc-Networking-Tools/Net-Tools.shtml

win3.1 was not made for the net......just storage files/printing....I will GIVE it a look, Thanks Merlin_2

Mikekc8I got it going, Thanks to all

Mikekc8How ? ? ?

patio. I installed MS Client for dos using the driver for my nic. Then used "net use" to map a drive to my other xp machines. That mapped drive carried over to Win 3.1

Mikekc8Nice Job !

patio.

4047.

Solve : WIN XP Format c: Without the Prompt?

Answer»

Running Win XP. Is there a switch that I can put after the FORMAT C: command in a batch file please.

Something like the DELTREE /Y or RMDIR /S /Q

I have quite a few HD's to format and would like to write a batch file that I could set to run and Format 4 HD's at a time, without user input each time.

Thankyou
How are you hooking up 4 HDD's and an XP drive ? ?

patio. Didnt see that mistake, type sorry.. should be 2 HD's.

Running SATA as the main HD and want to format 2 IDE drives, so I would like to run a batch file and forget it until both are done. That is without user having to type in the Y after the Do You wish to Proceed ??

Since it is a destructive process i doubt there is a way to bypass user intervention... that's a built in safeguard.

patio. Is this a server.........remote access can do this?What is a comando for format drive c:\ ,if i only have 1 hdd ?Load the winxp INSTALL disk......follow the on-screen prompts....Quote

What is a comando for format drive c:\ ,if i only have 1 hdd ?


You cannot format C: from within C:
Travel to bootdisk . com and DLoad a bootdisk to perform what you want.

patio. Is that you flame...ANd if win is instaled on drive d:\ ?Can you please repost your question.....in the windows section......and give most data/info to your PROBLEM.....I know its a destructive process. So I take it then that there is no 'switch' that can be added to a batch file after the Format [drive] command, to automate it, instead of operator input via the keyboard.

like the DELTREE /Y or the RMDIR /S /Q

Quote
I know its a destructive process. So I take it then that there is no 'switch' that can be added to a batch file after the Format [drive] command, to automate it, instead of operator input via the keyboard.

like the DELTREE /Y or the RMDIR /S /Q



I have just checked on my BENCH test MACHINE which has a full VER. of DOS on it and there is no switch that can be added to the command line to accomplish this.

patio.
4048.

Solve : Net Sending....?

Answer»

hello, at my SCHOOL we set send, and sometimes we "net SPAM"

by pressing the up button and hitting enter a bunch of TIMES to do the last command


what i need is a bat that will automaticly net send someone like 50 times.

like we use "net send 10ParkerJ Hello"

so what EVER you make i can edit the usernamefor /L %a in (1,1,50) do net send 10ParkerJ Hello

If you want to send "Hello" to DIFFERENT users you would need a text file with all 50 names and read the file:

for /f %a in (names.txt) do net send username Hello

OR inside the parens, list each username separated by a space

for %a in (username1 username2 username3...) do net send %a Hello

For what it's worth. Or just make 1 .bat file and put there :
"net send 10ParkerJ Hello
net send 10ParkerJ Hello
net send 10ParkerJ Hello"...
so much times you want .

4049.

Solve : CanNoPass UserLoginorDesktop OnlyDarkScreenAppears?

Answer»

The computer was turning on and off again and again so I disconnected the computer from the outlet. By the NEXT day the computer had not worked normally and UNTILL now I have not FIXED the problem. My computer still turns off by itself. My computer is a Tiger, windows xp, at least 3 G of memory and 1 to 2 G proccesor. I do not know what other information you need from me to help me with my problem.
This is what happens when I turn on my computer. The screen turns black and there is a line that appears on and off on the top left corner of the screen but nothing else happens. I tryed to turning off the computer and pressing on F8 and it gives me a LIST. I do not knøw what to do after that. I am guessing that it is ms dos command menu. If you can PLEASE help me as soon as possible.You may get better responses, or indeed any, if you post in the proper section. I suggest Hardware. The DOS section is not appropriate for the expertise you seek.

4050.

Solve : I might sound like a n00b...?

Answer»

I believe there are Lynx binaries for real-mode DOS, and for CMD under Windows ... as well as the Linux TTY VERSIONS and more.I THINK you could download the Arachne DOS web browser, but I've never really USED it before though. Of course it's not a really a function of DOS that would load a webpage, it's just a program that can run in DOS.you can access a website! through a batch file!:Code: [Select]start http://www.google.caYou cannot access any website from any OS without a browser. MS DOS has no built in browser.
If you are using "DOS" WITHIN XP or NT, then that is not DOS, it is merely an emulator.If you make a batch file like this, it works:
Code: [Select]@echo off
start http://www.google.ca
exit !!!!!!!!!Quote

If you make a batch file like this, it works:
Code: [Select]@echo off
start http://www.google.ca
exit !!!!!!!!!
That's not getting a webpage in DOS that's just opening iexplore.exe (Internet Explorer), and opening google Canada.I'm outta here!


http://www.howstuffworks.com