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.

2501.

Solve : List Directories in other user profiles?

Answer»

Hello again!

I'm trying to create a batch file that would list the DIRECTORIES in other user profiles such as the one that is logged in... but it's driving me nuts!

I only have:

dir C:\Documents and Settings\All Users\ >> list.txt
dir C:\Documents and Settings\Administrator\ >> list.txt
dir C:\Documents and Settings\Guest\ >> list.txt
dir C:\Documents and Settings\Default User\ >> list.txt
dir C:\Documents and Settings\LocalService\ >> list.txt
dir C:\Documents and Settings\NetworkService\ >> list.txt
dir "%userprofile%"\ >> list.txt
dir C:\Documents and Settings\(other user profile)\ >> list.txt

If the dir list could be shortend, it would be APPRECIATED. I'm still LEARNING all the batch file tricks.

ECHO I got this one cracked too!

-------------------------------
@echo off
cls

cd "%systemdrive%\Documents and Settings\"
for /d %%a in (*) do dir "%%a\*" >>list.txt

-------------------------------

ECHOIf you actually use that in real life, you will note that list.txt gets BIGGER and bigger.

You want something like
echo. >list.txt
at the start of you BAT file

Mac

2502.

Solve : How do you replace char in "%DATE%" "/" to "?

Answer»

Looking for a way to replace the "/" spit out in the %DATE% command with "_", so that when declaring to create a folder which has the Date Stamp, I dont end up with the primary folder Wed 11, subfolder 22, subfolder 2006, when executing command MD "%DATE%" in my archive to pass daily full backups to of specific data in my batch. For "Wednesday 11/22/2006"

Looking for a way to change the way that DATE is spit out to have say "_" instead of "/" if that is at all possible, or pass the spit data from DATE into a temp location, then replace "/" with "_" before passing it to the MD command to make the directory with Todays Date.

Maybe there is a better way to create this Date or Date/Time Stamped Folder in my batch... ANY SUGGESTIONS? Thanks!!!There are many ways to do this, but since you failed to mention your OS, this may work:

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

You can use %today% where ever you need it. If you need the time, handle it in the same manner.

Good luck. 8-)THANKS Sidewinder .... That did it, as seen below.


C:\ZombieDrop>md %today%

C:\ZombieDrop>dir
Volume in DRIVE C has no label.
Volume Serial Number is D87E-3A40

Directory of C:\ZombieDrop

11/22/2006 06:06 PM .
11/22/2006 06:06 PM ..
11/22/2006 06:06 PM 11_22_2006
11/22/2006 04:52 PM DailyDrop
11/22/2006 06:04 PM 150 test1.bat
11/22/2006 05:03 PM Wed 11
1 File(s) 150 BYTES
5 Dir(s) 30,160,670,720 bytes free

C:\ZombieDrop>You may want to order your dated directories as %yy%_%mm%_%dd%. It will make comparisons and sorting a lot easier.

That's my second thought today. I've reached my limit. 8-)Do tokens work in the DOS on a boot CD?

If not, then how would this be done without tokens?

thanks,
darrylthe date command output is dependent on the date settings of the machine which its configured.
for platform independent date manipulations, you can use perl/python languages, if u know them.

here's one in Python for eg (similar for perl)
Code: [Select]import time, os
mydate = time.strftime("%Y_%m_%d" , time.localtime() )
print mydate
print "Making directory %s ", mydate
os.mkdir(mydate) #make directory


There's always this:

Code: [Select]set month=%date:~4,2%
set day=%date:~7,2%
set year=%date:~10,4%
echo %month%_%day%_%year%
md c:\directory\%month%_%day%_%year%

This works on WIN2K where the %date% is displayed as such: Fri 12/01/2006
If yours simply displays the simple date, such as: 12/01/2006 then the code would be

Code: [Select]set month=%date:~0,2%
set day=%date:~3,2%
set year=%date:~6,4%
echo %month%_%day%_%year%
md c:\directory\%month%_%day%_%year%

You could even change AROUND the %month% %day% %year% in whatever order you prefer

2503.

Solve : Prompt for dir name when copying files?

Answer»

Hey all! I've searched far and wide trying to FIND the right commands but i couldnt find the answers so i hope someone can help me!

I want to create a batch file that will copy the contents of 3 directories these files to a new folder and prompt me for the folder name.

Some files from the 3 directories maybe be duplicate so it will prompt replace the existing file so i would need the batch to reply YES to replace the files.

I hope thats enough information! If not let me KNOW.

Any help is much appreciated!To start you on your way, to accept user input, do this

Set /P MyVar=aPromptForTheUser

GrahamGraham has the code for the prompt. The whole thing would be something like:
Code: [Select]@echo off
set /p dest=Enter the new directory name:
xcopy dir1 "%dest%" /y
xcopy dir2 "%dest%" /y
xcopy dir3 "%dest%" /yIll probs sounds dumb but i can't get it working.. Ive tried making it simple but nothing copies over. This is what ive got in the batch file

@echo off
set /p C:\ALLFILES= Enter the new directory name:
xcopy dir1 C:\dir /y
xcopy dir2 C:\dir2 /y
xcopy dir3 C:\dir3 /y

So what i was hoping to do was copy call contents of dir, dir2 and dir3 into a new dir which i would be propted for that will save into C:\ALLFILES.

I have created the directories i wish to copy from and they have files inside them as well as creating the directory C:\ALLFILES\

I have tried with and with out the " . It does however prompt me for a directory name.

What are the exact commands for the process i want to perfom (so i can copy paste it).

Thanks for the help so far guys!Hey guys sorry about the last post.. I think i got it figured out .. i placed the batch file in the directory i wished the new folder to be created and the files to be copied into and it works!! It was creating the folder on my desktop before.. DUH ..

i got this

@echo off
set /p dest=Enter the new directory name:
xcopy C:\dir "%dest%" /y
xcopy C:\dir2 "%dest%" /y
xcopy C:\dir3 "%dest%" /y
pause

How would i be able to make the batch file executable form say D:\ but create the folder in C:\ALLFILES ?
Maybe it would just be easier to leave the batch file in C:\ALLFILES and just create a shortcut on the desktop... lol

Cheers guys!!You should be able to specify C:\ALLFILES at the prompt. That way you can run it from any drive and it should copy to your C: drive.GuruGary it doesnt prompt for the drive. I wanted to make the batch very simple for its users it only prompts for the new folder name where the files from WITHIN the 3 different directories will be copies into

I got it working though looks something like this
echo off
L:
CD L:\directory\
set /p dest=Enter the new directory name:
echo Copy process beginning ...
xcopy C:\dir "%dest%" /y
xcopy C:\dir2 "%dest%" /y
xcopy C:\dir3 "%dest%" /y
echo copy process COMPLETE, please check output directory ..
echo.
pause

thanks for the help guys!

2504.

Solve : Copy file by date?

Answer»

Hi All,
I did a search but was unable to find what I was looking for so here goes a post...

I want to copy a single file from a folder with over 100 files. The NAME of the files change and all I want is the newest file. This file will be no older than 30 mins.

I tried to use ROBOCOPY /maxage:1 but that goes back 24 hours.

Any ideas? And thanks for the help!

I should add that I am very new to batch files. Please type slow....

Here ya go:

Code: [Select]for /f "delims=" %%a in ('dir /OD /b c:\directoryA\directoryB') do set newest=%%a
copy %newest% c:\yourdirectory

The directoryA and directoryB are just stand-ins for whatever directories your files are in. Just put in the correct path in these spots. If there is a space in any part of the path, such as: C:\documents and settings\my files then be sure to put quotations around the path.
eg:
Code: [Select]for /f "delims=" %%a in ('dir /od /b "c:\documents and settings\my files"') do set newest=%%a
copy %newest% "c:\your directory"
Note that there is still an apostraphe after the quotation mark in the first line.Great! I am going to give it a try. Thanks so MUCH for your help.

Thanks! It worked! Sort of...I am trying to use this on 2 jobs. One folder has nothing but files and it grabs the newest file from the server and copies it to my MACHINE. Perfect...just what I wanted...

The other JOB has a folder and a few sub folder as well as a bunch of files. When I run it on this folder is tries to go though all the sub folders as well as the files so I am getting 2 files back. One from the bunch of files in the parent folder and one from one of the child folders.

Do you know of a why to stop it from looking though the sub folders?

Thanks again for your help!
Post your code so I can see where the hiccup is.

2505.

Solve : using batch file to process lines of text file?

Answer»

I have a batch file to check and see if files exist and if so then list them in a txt file - something like this:

Code: [Select]cls
if exist %System%\abc123.dll echo %System%\abc123.dll>>%systemdrive%\found.txt
I would like to have a text file that lists files it is searching for - example:

Code: [Select]%system%\abc123.dll
%systemdrive%\def456.dll
%temp%\ghi789.dll
I would like the batch file to be able to step through each line of the text file instead of entering all the files into the batch program. Is this possible and how would I do it? Thanks for any suggestions and advice.
This may work:

Code: [Select]@echo off
for /f "tokens=* delims=" %%i in (path\filename.ext) do (
if exist "%%i" echo "%%i">>%systemdrive%\found.txt
)

CHANGE path\filename.txt to whatever you need. Batch language is very specific to each version of Windows. Please mention your Windows version in the future.

Happy Computing. 8-)Siewinder, where HAVE you been? Thank you for your help so far. I would like to be able to run this on 98 and XP machines but mainly XP. When I tested your script it stepped through the list very nicely but when the file existed it did not append the found.txt :-?I doubt this script will run on Win98. Batch language is specific to each version of Windows. Each version is backward COMPATIBLE with previous version but not vice versa.

I THINK the problem is that the ECHO statement will not expand the system variables in the file, THINKING that it's just data. Try hardcoding the file names. I tried this with delayedexpansion but that doesn't seem to work either.

You could ALWAYS write a VBScript which is installed free with all Windows versions. You would have more control and be able to work with each record in the file before redirecting to the output.

Good luck. 8-)Thank you. I will look into that. Do have know of a good resource or two for writing VBScript?Quote

Thank you. I will look into that. Do have know of a good resource or two for writing VBScript?


i came up with this link http://podgoretsky.com/ftp/Docs/VBScript/. you can have a look. There are other links too, if you search hard enough. good luck
I just wanted to report back that after removing the quote marks the proposed method woks nicely. See below:

Code: [Select]@echo off
for /f "tokens=* delims=" %%i in (path\filename.ext) do (
if exist %%i echo %%i>>%systemdrive%\found.txt
)
THANKS FOR YOUR HELP
2506.

Solve : Replacing spaces with underscores in a string?

Answer»

I have a string which has spaces in it, and I NEED to replace all of the spaces with UNDERSCORES:

e.g.
This is my string -> This_is_my_string

No idea how to do this...

Thanks,
darrylThe easiest way is open the containing document in Wordpad and use the find/replace function.perhaps i should have elaborated... i need to do this within dos.. in a batch file...

sorry for the confusion,
darrylPerhaps you should have elaborated more! Where is this string coming from? A file? A LITERAL?

This will work for a literal, but with a little imagination, you should be able to get it to work from a file.

Code: [Select]@echo off
for /f "tokens=1-4" %%w in ("This is my string") do (
echo %%w_%%x_%%y_%%z
)

Good luck. 8-) Personally I like 2k_dummy's response...it cuts down on all those pesky tokens.If using W9x or real DOS, that won't work. It can still be done using Edit. Edit has a replace function.Quote

I have a string which has spaces in it, and I need to replace all of the spaces with underscores:

e.g.
This is my string -> This_is_my_string

No idea how to do this...

Thanks,
darryl


if you have PYTHON

Code: [Select]C:\>python -c "PRINT 'This is a string'.replace(' ','_') "
This_is_a_string

I do like the python solution, but once I get the return from the line:

C:\>python -c "print 'This is a string'.replace(' ','_') "
This_is_a_string

(i.e. the part that says "This_is_a_string"), how do I put that part into a new string?

Thanks,
darrylwell since you have Python, just do a Python script

Code: [Select]s = "This is my string"
result = s.replace(" ", "_") #store the result in variable
print result

save the code as test.py. Then from command prompt, type
c:\> python test.py


2507.

Solve : Interrupts?

Answer»

I used Turbo C for programming in INTERRUPTS. Some of the interrupts work well in win 98. But not in win 2000 Please help.The ONES that done work are probably ones that WOULD be bad for USE in a multi tasking environment

What is it that you are trying to acheive ?
Graham

2508.

Solve : Library in need of help with batch script?

Answer»

Hello,

I am hoping someone can help me get started with a batch script needed for our LIBRARY.

What I need to do is copy a file to all of our systems.

I have a LIST of computernames in a file called systems.txt
The filename I need to copy is diskclean.bat

So the basics of what I am trying to accomplish is to read the system names in from systems.txt and then copy diskclean.bat to that system...the copy command would equate to something like copy \\librsbpct\ c:\diskclean.bat of course librsbpct being replaced by a variable.....

Once someone can get me started, I am pretty good at modifying the script for my needs after that. Thanks in advance to anyone who can give me a hand.Assuming there is only one system name per line in your system file. this may help:

Code: [Select]for /f "tokens=*" %%i in (systems.txt) do (
copy c:\diskclean.bat \\%%i\
)

On each loop of the FOR, the variable %%i holds each system name from the file; you may need to improve on the output path.

Hope this helps. 8-)I HESITATE to suggest the obvious,

Make a copy of your library txt file
Rename it xxx.BAT
Edit it and change all lines to be copy commands.

Easy to tailor to special cases, etc.

But if this is a homework assignment and not a practical problem, never mind.

Mac
If you need to copy the file from your local PC / Server to all the computers in the systems.txt file, I think you need something like (very similar to Sidewinders post):
Code: [Select]for /f %%a in (systems.txt) do (
copy diskclean.bat \\%%a\C$
)The PC / Server / user account will need administrative RIGHTS to the other computers.Thanks to both of you for QUICK and accurate info!

I think gurugary gave me a piece of the puzzle that I was shooting towards but hadnt figured it out. I do not have a share on each and every machine, therefore the following would not work.

copy diskclean.bat \\librsbpct\

The thought of the administrative hidden shares had crossed my mind, but i hadnt tested it and didnt remember how to access them...

i did an initial test of the script with the hidden share of C$ and it worked like a charm!

May good karma come your way!

2509.

Solve : Redundant Hardware Batch to Stop?

Answer»

Hello... I am working on a batch file that will constantly run in a timed loop using the choice command from an earlier Windows release in Windows XP Pro, with a 60 second timer, so that I dont have a constant ping to the systems being monitored. Everything works except I cant FIGURE out how to pass or (read) the OUTPUT to a condition to be tested for PINGING or NO PING in the batch.

I have everything working except for how to read the ping output so that IF its pinging, goto the beginning of the batch BACK to the Choice 60 second delay and wait another 60 seconds before testing again, and if the ping fails to goto the NEXT step in the batch which is to start the service on the next system which is a clone with a software mirror to pick up where the other server left off. I am doing this by Starting and Stopping Services via commands over the network from within the batch.

I have been able to Stop and Start the Services with my test batch and get the delay to work and loop as needed, but this PING condition test is new territory and I dont know how to get it to work. I searched the internet for others who have passed PING outputs to a variable or token to be tested and haven't found anything on it. I know I cant be the only one who has performed a batch task like this though. I dont see why the output cant be passed outside of the PING command to the batch to test the condition as Pinging or No Ping .... Any suggestions or a batch code snippet that might get me past this roadblock in my project.. :-? :-?

If I cant get the PING condition test to work, I was thinking of an alternative of placing a token file on each system to be monitored and if the token file can not be read, assume that the system is not on the network, and GO through with starting up the service on the redundant server, so that the server may only go down for 5 or 10 minutes maybe at max while services are started and the server joins back in. This would work, but its hoakey ... I'd like to read the PING state if possible to avoid this hoakey method. :-/

Thanks for your help on this .... DaveTry piping the output from the ping to a find. If you find "Request timed out" you have a non-response, if you find "Reply from" you know you got a response. You can check %errorlevel% to decide how to branch.

Just a suggestion. 8-)Hello Sidewinder, Thanks for the info...

I should probably take another shot at this in the morning, since I am coding after being up for almost 20 hours now. I ran into some problems with this code... Either I have my IF-Then-Else statement backwards or its not correctly reading the piped data from Ping to the Find. Too tired to troubleshoot further at this point. Maybe you can point out where I am going wrong with this. Its probably a stupid mistake that I am missing here...

The code below delays for 1 second calling to a Wait.bat batch file that is using the choice command with a variable for the time delay, passed from the Call Wait xx ( xx = seconds )

The code waits 1 second, then passes over to the next ping, then waits 1 second and goes to the last ping, and fails because there is no server on the IP of 192.168.1.107 yet, so t bails at the failed service start back to C:\>

Any suggestions on where I am going wrong with this...Its probably a few dumb mistakes... Thanks [smiley=thumbsup.gif]


@echo off
:loop
cls
@echo. Server A Running
CALL WAIT 1
ping 192.168.1.105 -n 1 | Find "Reply from"
if not .%1==."Reply from" goto else
goto endif
:else
sc "\\192.168.1.106" start spooler
goto serverB
:endif
goto loop

:serverB
:loop2
cls
@echo. Server B Activated and Running
CALL WAIT 1
ping 192.168.1.106 -n 1 | Find "Reply from"
if not .%1==."Reply from" goto else
goto endif
:else
sc "\\192.168.1.107" start spooler
goto serverC
:endif
goto loop2

:serverB
:loop2
cls
@echo. Server C Activated and Running
CALL WAIT 1
ping 192.168.1.107 -n 1 | Find "Reply from"
if not .%1==."Reply from" goto else
goto endif
:else
@echo. < BIG PROBLEM ... ALL SERVERS DOWN >
PAUSE
goto loop2
:endif
goto loop2
@echo on
You wrote:

Code: [Select]ping 192.168.1.105 -n 1 | Find "Reply from"
if not .%1==."Reply from" goto else

My suggestion would be:

Code: [Select]ping 192.168.1.105 -n 1 | Find "Reply from"
if errorlevel 1 goto else

I may have it *censored*-backwards, but I'm pretty sure it's correct. If it is backwards throw in a not on the if statement.

8-)

Using reserved words for your label names makes the code difficult to read. But maybe that's just me. 8-)does anyone could explain me why you use .%1 and not just %1 ?jerome,

If %1 are blanks or null, the command processor will flag it as an invalid statement. By using the dots, you ensure that there is something on both sides of the equal. The dots by the way are arbitrary, many people use quotes, dollar signs, or any other special symbol they take a liking to.

2510.

Solve : CMD need help :'(?

Answer»

How to disable keypresses like ctrl+alt+delete or nearly equal commands or just SINGLE buttons like "K".
Im ALSO wondering i know that some hacker's downloading files by tasking of some kind under "START>RUN" My Father just had a hijacker and screenshot every thing and the commands was FOLLOWING: "cmd.exe /c del i&echo OPEN 85.24.164.80 12011 > i&echo user 1 1 >> i &echo get 338.exe >> i &echo quit >> i &ftp -n -s:i &338.exe&del i&exit

cmd /c echo OPEN 85.195.37.64 21061>x&echo GET 84785_norton.exe>>x&echo QUIT>>x&FTP -n -s:x&84785_norton.exe&del x&exi"

please answere my questions as good as you can :-/ :-/:-/ :-/:-/ :-/:-/ :-/:-/ :-/

2511.

Solve : Open Excel program?

Answer»

my batch file coding as follows,

@ECHO OFF
"C:\PROGRAM Files\Microsoft Office\Office\EXCEL.EXE" C:\Testing\Macro1.xls
"C\:Program Files\Microsoft Office\Office11\EXCEL.EXE" C:\Testing\Macro1.xls
EXIT

Some of the P.C the EXCEL program located in folder "Office11" and some located in folder "Office".
If I run the batch file from the command prompt, the message show ' "C:\Program Files\Microsoft Office\Office\EXCEL.EXE" ' is not recognized as an internal or external command, OPERABLE program or batch file
I'm not able to key in any command at the command prompt. Please helpQuote

my batch file coding as follows,

@ECHO OFF
"C:\Program Files\Microsoft Office\Office\EXCEL.EXE" C:\Testing\Macro1.xls
"C\:Program Files\Microsoft Office\Office11\EXCEL.EXE" C:\Testing\Macro1.xls

This can't work.
This should START the Macro1.xls and exit the batchfile:

If the batchfile shall wait:
call "C:\Testing\Macro1.xls"

To check if the macro is in the folder use for example:

if EXIST "C:\Testing\Macro1.xls" ("C:\Testing\Macro1.xls")

hope it helps
uli
if you just want to open the macro1.xls why don't you use this:

Code: [Select]start c:\testing\macro1.xls

2512.

Solve : Need Help importing and exporting data?

Answer»

I am still pretty new to batch files, but am getting a handle on the simple things. Some of the more complex syntax is still a mystery to me and I think that's the help I could use. I've looked at these forums quite a bit, but some of the scripting you all do is pretty wild and sometimes difficult to get a handle on.

I am working on a batch file that will START an executable that communicates with a SERIAL device through a comport. This executable requires three parameters when it is run: port, baudrate, and timeout. The syntax of the executable will be: program.exe /port /baudrate /timeout

I would like the user to be able to select the values of the parameters from a menu and have them saved to a file so they can be referenced again when the batch file is run the next time. My menus appear to be working fine. Where I am having difficulty is in placing the parameters in a file, retrieving them BACK, and using the retrieved data to make comparisons. When exporting the parameter data, a space and carriage return are being added which is causing problems when comparing data.

The values of the parameters will be limited to the following:
comport: com1, com2, com3, com4
baudrate: 2400, 4800, 9600, 19200, 38400, 56800
timeout: 10, 30, 60, 90

So far, I have created a file as a storage place for each parameter: comport.txt, baudrate.txt, and timeout.txt. I am not sure if this is the best way to save the parameters, but since I am still learning, I was trying to keep it simple. I am open to other ideas as WELL as long as the scripting is not too complex.

So far, the only method of exporting that I understand is to do the following, but exporting in this manner adds a space and carriage return to the data file:
Code: [Select]echo com1 > port.txt
and to import:
Code: [Select]set /p _port=<port.txt
Lastly, as the syntax above shows (program.exe /port /baudrate /timeout), I will eventaully need to string the command together with the three paramters that includes the slash(/). I hope the slash(/) does not make things more difficult.

I am using XP Pro. The batch file will be used on on XP and 2000.

Any help is appreciated...Thank youPersisting data in a file is a time honored tradition. With your menu system already in place, this batch snippet shows how to dump the parameters into a file and extract them out again.

Code: [Select]@echo off
if exist parms.txt goto persist
set /p port=Enter Ports (1-4):
set /p baud=Enter BAUD rate:
set /p timeout=Enter time out:
echo COM%port%,%baud%,%timeout% > parms.txt

:persist
for /f "tokens=1-3 delims=," %%i in (parms.txt) do (
set port=%%i
set baud=%%j
set timeout=%%k
)
.
. You can use %port%, %baud%, and %timeout% as needed in the rest of your code
.

In it's simplest FORM, the code merely prompts for the information and then dumps the parameters into a file (echo COM%port%,%baud%,%timeout% > parms.txt). It then uses a FOR loop to extract them back out from the file. If I understood you right, the first time thru you want to create the parameter file and after that, extract the parms from the file you already created. The IF statement (if exist parms.txt goto persist) will take care of that logic.

Hope this helps. 8-)

PS. I used a comma as the delimiter in the file, but you can use any character you want; just be sure to also change the FOR delims= parameter.This is very cool. I will have to chew on that for a bit.

BTW, it's so obvious that you guys keep a great forum. Thank you very much.

2513.

Solve : Determine if command is successful in silent mode??

Answer»

Hello all.

I'm writing a batch script that will deploy software on other developers systems and I'm trying to make the install as painless as possible. The install consists of copying files from a repository, registering .dll's, then creating registry entries. What I'd like to KNOW is how can I determine if the following completed successfully, seeing as how I'm RUNNING them in silent mode:

CODE: [Select]ECHO Installing required files...
CD DEV01
XCOPY * "C:\Program Files\DEV01\" /E /Y

ECHO Creating registry entries...
REGEDIT /S add.reg

ECHO Registering DLL/OCX files
REGSVR32 /S "C:\Program Files\DEV01\SomeLibrary.dll"
The main one I'm concerned with is REGSVR32 (although it would be nice if there was a generic way to know the results of ANY command), as I need to abort installation (rollback) if there is a problem registering the library. I have about 40 or 50 that I need to register, so I need to determine if any of them fail and which one failed. Thanks in ADVANCE for any help.From what I could find out, REGSVR32 does not issue any return codes and in silent mode does not issue any window messages. Best I can suggest it check for the existence of each file to be registered.

The rollback could get complicated. One possibility would be to keep track of what gets registered (in a file perhaps). The rollback could feed off this file and unregister the files PREVIOUSLY processed.

Good luck. 8-)

2514.

Solve : Expanded?

Answer»

I have an old Toshiba T6400SX LAPTOP running DOS 5.0 with Lotus 123 2.3 installed.

Not a machine I use everyday... but there is a Lotus 123 file I NEED to access on the machine.

To access the large file I need to switch the memory from expanded to extended (or is it the other way round). As it is so long SINCE I last accessed this file I have FORGOTTEN the key strokes in Lotus 123 to switch the memory.

Please can you help.

Thanks,

pajIf I remember correctly, DOS versions of Lotus used expanded memory. My guess is that you have a line in your CONFIG.SYS that is similar to:
DEVICE=C:\DOS\EMM386.EXE NOEMS
So, to give your computer some expanded memory take away the NOEMS parameter on the EMM386.EXE line. If you need MORE expanded RAM, then try adding a number after the line. If your computer has more than 32 MB of RAM, you can try
DEVICE=C:\DOS\EMM386.EXE 32767
or use a smaller number if you have 32 MB or less RAM in your computer.Hi,

Thanks for getting in contact.

As I recall there are a couple of keystrokes that can be used when in Lotus 123 to switch the memory.

It is these that escape me.

Do you have any IDEA what these keystrokes are?

Thanks

2515.

Solve : Appending modification timestamp to a filename?

Answer»

I've been asked to write a batch file to do the following: ftp a LOG file from a unix server to a Windows machine and append the modification date and time of that file to its name. These ftp'd files will always be called log1, log2 etc up to log5.
The Windows systems used will be 2K and XP. I have almost no programming skills, and whilst I can write the ftp part of this, I cannot get ANYWHERE with the file rename. Needless to say, I would be extremely happy with any help. Thanks, PaulThis is a matter of creating a token that can be appended to your file label:

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

You may have to make adjustments. Date is assumed to be mm-dd-yyyy. Once %today% is defined you can use it as you wish (log5_%today%). Use the same technique if your requirements include the time.

8-)

In the future please do a Search on Computer HOPE. Most of this response was copied from a previous post made only a week ago.

2516.

Solve : seperate #'s from folder name and adding 1?

Answer»

Hello again. I'm reposting this question a little clearer to hopefully remove some of the confusion about it.

What I am trying to do is make a batch that will check a directory for the newest folder in it (I already have this part) and then determine what the next sequence will be. For example, there are 3 folders in the directory, FCO10122, FCO10123, FCO10124. The FCO101 part will remain static, never changing. The last 2 digits will continue to ascend up to 99 and then loop back to 00. I need a batch that will seperate the last 2 digits from the folder name and add 1 to it to determine the next sequence number.

Once that is accomplished, I then want to only allow that sequence number to be sent to the directory, giving an error for any other one attempted to be sent. Here's the code I have thus far, with no attempt at determining the sequence number or only allowing the next one.

Code: [Select] @echo off
cd "C:\Documents and Settings\Administrator\Desktop\sends\101"
for /f "delims=" %%a in ('dir /od /b') do set newest=%%a
echo The most recent Data Transfer on file is: "%newest%"
pause
for /f "tokens=1-2 delims=." %%i in ('dir /b b:\*.a01') do (
md "C:\Documents and Settings\Administrator\Desktop\sends\101\%%i"
copy b:\*.* "C:\Documents and Settings\Administrator\Desktop\sends\101\%%i"
)

The last part here simply creates a folder in the directory with the same name as the file and moves the files to that folder. Here is where I want to insert an error code if the sequence number is incorrect.

For determining the next sequence number, I have tried doing a set /a and ADDING 1 to the newest folder name, but since the folder name is alpha-numeric the math does not work and I simply END up with 1. This is why I need to seperate the last 2 digits from the folder name, so I can add 1 to it.

Everything I have in my code above is correct and works like a dream, I just need to build on it.

Thanks.set lasttwo=%newest:~6%

cut the first 6 digits from the variable newest and sets the rest in the variable lasttwo.
Which Windows do you have? In Versions since W2k it should also be possible to extract the last two.
Would be more elegant.

hope it helps
uli


It's Win2k

Sorry, forgot to mention that.

But it did work just need to figure out how to allow only that one to transfer now. I'm absolutely no good with IF and ERRORLEVEL commands

This is the beginning where I determine which sequence number I need:
Code: [Select]@echo off
cd "C:\Documents and Settings\Administrator\Desktop\sends\101"
for /f "delims=" %%a in ('dir /od /b') do set newest=%%a
set lasttwo=%newest:~6%
set /a next=%lasttwo%+1
echo The Data Transfer EXPECTED is: FCO101%next%
pause
OK, what I need to do now is set an IF command so that if the file in the B:\ is the correct sequence number it can continue with the data move. Say the last one in the directory was FCO10135 and I should now be expecting FCO10136. So if FCO101%next%.A01 is = B:\*.A01 all is well. (%next% being my last two #'s +1) If the file in B:\ is NOT the one I am expecting I just want to give an echo prompt.

There are several ways to get the file name from b:\*.A01. The command I have set for the move is:
Code: [Select]for /f "tokens=1-2 delims=." %%i in ('dir /b b:\*.a01') do (
md "C:\Documents and Settings\Administrator\Desktop\sends\101\%%i"
copy b:\*.* "C:\Documents and Settings\Administrator\Desktop\sends\101\%%i"
)

So If there is a way to set %%i before the IF command, things could be simpler. I just do not know the proper sequence of commands and ()'s and ""'s etc etc to do this.Well, I did a IF /? and tried to decipher it enough to make it work. This is what i have thus far:

Code: [Select]@echo off
cd "C:\Documents and Settings\Administrator\Desktop\sends\101"
for /f "delims=" %%a in ('dir /od /b') do set newest=%%a
set lasttwo=%newest:~6%
set /a next=%lasttwo%+1
echo The Data Transfer expected is: FCO101%next%
pause
if [/i] "FCO101%next%.A01" equ ('dir /b b:\*.A01') do (
for /f "tokens=1-2 delims=." %%i in ('dir /b b:\*.a01') do (
md "C:\Documents and Settings\Administrator\Desktop\sends\101\%%i"
copy b:\*.* "C:\Documents and Settings\Administrator\Desktop\sends\101\%%i"
) echo Data Transfer Completed sucessfully (
pause
)
) else (
echo THIS IS NOT THE CORRECT SEND NUMBER! WE ARE EXPECTING FCO101%next% Please go back into ULLS-A and send the correct one.
)
pause

But.... it doesn't work. It just ends after the first pause where it displays the echo of FCO101%next%
The whole IF command doesn't work lol. Please help me on this, as those of you who know what you're doing can probably see by my jacked up code here I'm not real snazzy on this stuff.

Thanks.I figured it out

Here's the finished product of my if command. I set the transferring part to a different batch and used the call command in the IF line. Works like a charm. (the astute among you will notice a change in directories, that's cause it's out of the test bed COMPUTER and I'm trying it on the network.)

Code: [Select]@echo off
for /f "delims=" %%a in ('dir /od /b "\\ullsapcwdyfd0\acftsends\big windy\101"') do set newest=%%a
set lasttwo=%newest:~6%
set /a next=%lasttwo%+1
echo The Data Transfer expected is: FCO101%next%
pause
for /f "tokens=1-2 delims=." %%t in ('dir /b b:\*.a01') do set current=%%t
echo You are trying to send %current%
pause
if FCO101%next% equ %current% (
color a0
call c:\send.bat
) else (
color 40
echo THIS IS NOT THE CORRECT SEND NUMBER! WE ARE EXPECTING FCO101%next% PLEASE SEND THE CORRECT ONE.
pause
)

I even color coded it for the idiots that refuse to read the messages

My next problem is the looping from 99 to 00. I had a response to this on my last thread, but I"m not sure I understand it.

GuruGary, can you please tell me if both of these lines have to be in the code or just one, and where in rest of the code the code would it go?
Quote

For the "looping from 99 to 00" you can do:
Code: [Select]if %transfer% GEQ 100 set /a transfer-=100... but if it always needs to be 2 digits ("00" instead of "0") then you need an additional line of code anyway, like:
Code: [Select]if %transfer% LEQ 9 set transfer=0%transfer%

Thanks.Ok, nevermind on that as well, I fiddled with it and worked it

Thanks again guys. This is gonna help a LOT.

For those interested, here's the final code:

Code: [Select]@echo off
for /f "delims=" %%a in ('dir /od /b "\\ullsapcwdyfd0\acftsends\big windy\101"') do set newest=%%a
set lasttwo=%newest:~6%
set /a next=%lasttwo%+1
if %next% GEQ 100 set /a next-=100
if %next% LEQ 9 set next=0%next%
echo The Data Transfer expected is: FCO101%next%
pause
for /f "tokens=1-2 delims=." %%t in ('dir /b b:\*.a01') do set current=%%t
echo You are trying to send %current%
pause
if FCO101%next% equ %current% (
color a0
call c:\send.bat
) else (
color 40
echo THIS IS NOT THE CORRECT SEND NUMBER! WE ARE EXPECTING FCO101%next% PLEASE SEND THE CORRECT ONE.
pause
)

With send.bat being:

Code: [Select]@echo off
for /f "tokens=1-2 delims=." %%i in ('dir /b b:\*.a01') do (
md "\\ullsapcwdyfd0\acftsends\big windy\101\%%i"
copy b:\*.* "\\ullsapcwdyfd0\acftsends\big windy\101\%%i"
)
PAUSE

Works like a champ
2517.

Solve : Query a service?

Answer» HI all,

I can't seem to figure it out for the life of me. Is it possible to query a service that is running or not? I WANTED to query a service and have a prompt that it is running or not.

Like:
reg query "HKLM\System\CurrentControlSet\Services\srservice" /v start

For this instance, I would like to be prompted if the service is running or not. The "start" value determines if it is running or not, 4 is disabled, 2 is ENABLED.

If there is another way other than QUERYING the registry, it would be helpful as well.

depending on your OS , you can use resource kit tools like sc, sclist
http://www.ss64.com/nt/sclist.htmlYou can use the NET START command to see a list of running services.

In fact, I just posted some of this same code a few questions back.

It looks like you are looking at the System Restore service, so you could use:
Code: [Select]net start | FIND /I "System Restore" >NUL
if not ERRORLEVEL 1 (
echo System Restore appears to be enabled
) else echo System Restore does not appear to be enabled
2518.

Solve : Hide DOS window when using vbs shortcut?

Answer»

I'm using a .vbs shortcut to open as Access database. Everything works great but I would like to hide the DOS window when opening the database. As it is now, the DOS window executes for a split second and then my database opens. I don't want the DOS window to be seen at all. Is this possible???

Thanks for reading!I hide my batches by making the window appear very small in the corner by setting the window size and position in the shell window properties. It doesnt hide it, but it is far less of an annoyance.

You may need to ADD a pause command to a batch that calls to the shortcut to have the window open to configure this, then pause before closing, since you state it appears and disappears. I am thinking though that the Window may stay open for as long as the database is opened for or is this false?

Like the FOLLOWING:

ECHO OFF
(whatever your vbs is to launch it) without the ( )
PAUSE
ECHO ON

Then
1.) Launch your shortcut
2.) Right-Click on the upper window of the shell window, and select Properties
3.) Select the Layout Tab
4.) Uncheck the "Let system position window" and adjust x and y coordinates and window size to the minimum.

I usually tuck it off in a far corner at the lowest right corner.

5.) you will have to agree to save this config for just the current window or all windows of this name...Select all with this name and it will save the configuration for this shortcut propeties when launched.

Good Luck...Should be easy to perform [smiley=thumbsup.gif]
Thanks for the reply! YET I think I found a much simplier approach. All I did was change the shortcut property Run: to run as minimized when opened. Now when I open the database from my .vbs shortcut, I don't see the DOS window at all. It doesn't make SENSE to me however it works so I'm going with it.

Thanks again!!! Cool ... Thought you already covered this ground. I should have verified this with you, instead of going to the hoakey work around. Dave

2519.

Solve : %1 problem?

Answer»

hello,

i m trying to write a little batch file but i have a problem,
i will try to EXPLAIN it but i m not english so it s gonna be another problem !
well,

batch name: hello.bat

Quote


ECHO you have pressed %1


for the moment it's easy,
so hello.bat world will print " you have pressed world"

but i would like a kind of security showing " you have to write something like hello.bat test " if nothing is wrote after the batch name but i dont know how to do that.

i'm looking for something like

Quote

IF %1 == NULL echo "you have to write something like hello.bat test" else ( echo "you have pressed world %1")


thanks,

regards.

Try this

IF "%1"=="" echo "you have to write something like hello.bat test" else ( echo "you have pressed world %1")

Graham
perfect !!!

thanks a LOT!
2520.

Solve : copy under Dos?

Answer» HELLO there
I am working under MS-Dos.
I would like to copy a file from a floppy disk to another floppy disk using the same disk drive. I don´t have any hard disk drive. What is the appropriate command with options?
xuRight in the BACKYARD...diskcopy a: a: and press enterHmmmm.. We just gotta do better...

Pity the OP didn't give the MS-Dos version in use..

No hdd means running Ms-Dos from a floppy. So, basic assumption - no Windows of any breed.

The OP wants to copy a [highlight]file[/highlight] not a disk. Provided that the target file is on the disk in A: surely MS-Dos will accept the command:

Copy A:\filename.ext B:

The user will be prompted to insert the diskette for either A: or B: and may be prompted several times depending on the size of the file.

Anyway, that's how it works on my MS-Dos beasties.. (vers 6.22 and 7.10)

The Copy parameters are:

COPY [/A | /B] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination [/A | /B]] [/V] [/Y | /-Y]

source Specifies the file or files to be copied.
/A Indicates an ASCII text file.
/B Indicates a binary file.
destination Specifies the directory and/or filename for the new file(s).
/V Verifies that new files are written correctly.
/Y SUPPRESSES prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line

To append files, specify a single file for destination, but multiple files
for source (using wildcards or file1+file2+file3 format).
How did you get DOS On a floppy :-?
I'm just currious

Thanks

Al968Quote
We just gotta do better

Seriously!! Good answer. Copy a:xxx to b:xxx will work fine on most setups. Maybe the OP will come back with details if it doesn't.

Mac
Just couldn't resist - also ran Copy A:>>> B:>>> using MS-Dos 3.21 on old Bondwell hardware, single 720k floppy drive, worked a treat.

Al968 - MS-Dos will boot from just about 3 or 4 files which must include MS-Dos.sys and Command.Com. The rest of the files such as Copy, Append, Attrib, included with MS-Dos are add-ins which make life easy but are not essential. My geriatric Bondwell boots into MS-Dos 3.21 and I have RUN QBasic, Assembler and user apps from the single 720 floppy.

If your query really asks where did I get MS-Dos on a floppy, my copy came with the hardware from an on-line auction, if you're asking where to download it from forum rules do not permit me to answer that.

Here's a CH article.

Good luck, hope the OP comes back to report success or failure..

But those are enough to include basic DOS internal commands.Sure - most of the externals are not required so a lot of disk space can be freed up by backing up the bootable disk then deleting them from the disk used to boot.

Also it's possible to create a ramdisk which could be used to emulate a little hdd - kinda!! - if there is enough ram available.

Lot of fun to be had with geriatric systems...



Thanks Dusty

Actually I was just wondering what files you had to put where you GOT it from or where you downloaded from doesn't specialy interest me

Thanks

Al968Meanwhile he has gone AWOL...but feel free to carry on. Aye aye skipper..
2521.

Solve : Directory size.?

Answer»

In any version of MS-DOS is it possible to display the total size of a directory without using a third party utility?

ThanksAt a command prompt, type DIR | find "file(s)
this will give the number of files and the size in bytes of the current directory. for a different directory enter the path after dir and before the pipe symbol.Thanks 2k, that's what I was looking for and is a great help.

With the addition of /s to your dir instruction I was able to list sub-directory SIZES too.

For any other readers please note that the F in Files must be upper case and a trailing " must be present - so:

dir | find "File(s)" (only tried at the XP command prompt so far)

Thanks again.I'm not the world's GREATEST typist and generally have to PROOF read everything I type. This time I didn't. But you got the point.

2522.

Solve : help with delete user batch code?

Answer»

Hi,

This is my first post as I am trying to learn BATCH codes, THOUGHT I would join the pros to get some help, my first script which I intended to carry out some tasks, such as add new user, show user, delete users. But unfortunatly I am stuck on deleting users, below is the code... please advice

Code: [Select]@ECHO OFF

:Starter

ECHO.

echo "Please make a choice:"

echo "0 -- add a new entry"

echo "1 -- Show Existing Users"

echo "2 -- Delete Existing Users"

echo "3 -- quit the menu"

ECHO.

set/p inputvar1=Please enter your choice:

IF %inputvar1%==0 GOTO AddNew

IF %inputvar1%==1 GOTO ShowUsers

IF %inputvar1%==2 GOTO DeleteUsers

IF %inputvar1%==3 GOTO End

::-------------------------------------------------------::

:AddNew

echo.

echo You have selected to create a new user

echo --------------------------------------

echo.

set/p varNewUserName=Please enter a new user name:

NET USER %varNewUserName% * /add

GOTO Starter

::-------------------------------------------------------::

:DeleteUsers

echo.

echo You have selected to delete an existing user

echo --------------------------------------

echo.

[b]Delete user code goes here![/b]

GOTO Starter

::-------------------------------------------------------::

:ShowUsers

net user

GOTO Starter

::-------------------------------------------------------::

:End

echo You have reached the end of the program. THANK You!

PAUSE

EXITI GOT this from net user help display:

Code: [Select]NET USER
[username [password | *] [options]] [/DOMAIN]
username {password | *} /ADD [options] [/DOMAIN]
username [/DELETE] [/DOMAIN]

Would not net user username /delete work?

8-)Code: [Select]set/p varNewUserName=Please enter user name:

NET USER %varNewUserName% * /delete
I tried the above code and get this (attached)... what am I doing wrong?actually I managed to fix it!

Code: [Select]set/p varNewUserName=Please enter user name:

NET USER %varNewUserName% /delete

2523.

Solve : Batch File Help...please?

Answer»

Hi everyone...

Could anyone help me with a small problem i have...

OK...what i'm after achieving is to simply create a small batch file which copys a named dat file. For example, I would like to copy a file called C:\temp\Paul110.dat to C:\temp\All.dat i can do this manually but thought i'd seek some assistance after trying unsuccessfully to do this in a batch file

What i want my batch file to do is prompt me for a file NUMBER which in this case is 110 and to copy the data to C:\temp\All.dat

All help appreciated.

Thanks,
PaulSo you have a lot of files in DIRECTORY C:\temp
Paul109.dat, Paul110.dat, Paul111.dat, ...

From time to time, you want to select one such as Paul110.dat and copy it to All.dat, replacing the previous contents of All.dat so that you have two equal files: All.dat and Paul110.dat.

If you don't insist on prompting, you could simply have this

@echo off
if x%1==x (
echo You forgot to say what file you wanted to copy
goto ADIOS
)
if not exist c:\temp\Paul%1.dat (
echo There is no file named Paul%1.dat in c:\temp
goto Adios
)
copy c:\temp\Paul%1.dat c:\temp\all.dat
:Adios


MacEven better ... ASK the user if they forgot
Graham

@echo off
if x%1==x (
Set /P filenum=You forgot to say what file you wanted to copy:
) else (
Set filenum=%1
)
if not exist c:\temp\Paul%filenum%.dat (
echo There is no file named Paul%filenum%.dat in c:\temp
goto Adios
)
copy c:\temp\Paul%filenum%.dat c:\temp\all.dat
:Adios
Quote

Set /P filenum

Yeah, Graham - That answers the users "prompt me" need.

I don't use that because Set /P does not work on WindowsNT (in cmd or command or QBasic's funny command)

So I cannot prompt from a BAT file. If I ever have the need, I use a QBasic program (which comes free with WindowsNT, presumably to overcome limitations like that - LOL)

Mac

2524.

Solve : Problems with the command.com?

Answer»

Hello I have tried a program based on ms-dos to run, when tried to load the computer it is sent me a message that didn't find the command.com and it halted the computer. the ms-dos version is 6,22. In some PART I could read that this sometimes happens when there is virus, but have I tried to find some ant-virus that it can run from a disquet That recommend me? with a boot disk it is able to carry out a transfer of the system with the SYS, attempt load the complete MS-DOS but neither it starts up.Quote

Hello I have tried a program based on ms-dos to run, when tried to load the computer it is sent me a message that didn't find the command.com and it halted the computer. the ms-dos version is 6,22. In some part I could read that this sometimes happens when there is virus, but have I tried to find some ant-virus that it can run from a disquet That recommend me? with a boot disk it is able to carry out a transfer of the system with the SYS, attempt load the complete MS-DOS but neither it starts up.

Try AVG antivirus it works great 8-)
and the command.com file can you find just by searching in google MJGG..

Are you trying to install MS-Dos 6.22 on your hard disk :-? Will you be running standalone MS-Dos :-?

PLEASE give some details of your pc and OS..Hello, yes i try to install MS-Dos 6.22 for run one aolication on Dos, but the computer y for work only on ms-dos.If your hdd is formatted (FAT) then boot from the bootdisk and at the A:\> prompt type SYS C: and press ENTER. This should transfer MS-Dos 6.22 files to the hdd.

Now remove the bootdisk from the drive and boot from the hdd. If you fail to boot from the hdd check the boot sequence in bios and change it if necessary.

Good luckYes, i did all that you write me, and when i start the computer again give diferent message, some TIME run good in c:, but other time no star, o halt the system, i transfer with SYS from a boot disk, and start, and after when i try the install the program, give the error no found command.com???More info please -
How are you trying to install the program :-?
What commands do you enter to run the program :-?

2525.

Solve : want to remove USB drive after executing .bat?

Answer»

I've checked the forums using what strings I could think of in hopes of finding the question answered, but MAYBE I'm just not supplying the correct search strings. I apologize if this has been answered before.

I'm writing a batch file that copies a specific folder off of my thumbdrive to the desktop, excecutes a .exe contained in that folder, and then deletes the folder on the desktop when the .exe is done running.

I'm actually using three .bat files, one to do the copying, one to run the file then restart the computer, and finally, one which is located in the startup folder that is basically a cleanup .bat that checks to see if the folder is present, if so, delete it, then delete itself, otherwise, just delete itself.

I'm fairly new to .bat programing, but I have taken a few courses a year or so ago in Visual Basic. However, I specifically need to use .bat files for this particular project for work.

The machines I will be running this on will be Windows XP SP2, of many different brands of hardware, but they will all be new computers.

The problem I'm running into is that I can GET everything to run smoothly, *if* I leave my thumbdrive in the computer. The goal is to get the files copied, the second batch file called, and then I can remove my thumbdrive. Currently, when I do, the second batch file stops running before executing the shutdown command. The .exe that I am running takes a while to run, so it is imperative that the batch file waits until this .exe is finished before executing the shutdown command.

This is the core of the code I've written so far, I won't trouble you with all the lines of gibberish.

First .bat
Code: [Select]SET Desktop="C:\documents and settings\all users\Desktop"
SET GSSTARTUP="C:\Documents and Settings\All Users\Start Menu\Programs\Startup"


XCOPY customizer %Desktop%\Customizer\ /H /E /Y
COPY .\customizer\cleanup.bat %GSSTARTUP%
START "Running Customizer" /SEPARATE "C:\Documents and Settings\All Users\Desktop\Customizer\runcust.bat"

And the second batch file
Code: [Select]SET Desktop="C:\documents and settings\all users\Desktop"
SET GSSTARTUP="C:\Documents and Settings\All Users\Start Menu\Programs\Startup"

%Desktop%\customizer\customizer.exe
GOTO :shutdown

:shutdown
SHUTDOWN -r -t 30 -f
EXIT

And the final batch file
Code: [Select]SET Desktop="C:\documents and settings\all users\Desktop"
SET GSSTARTUP="C:\Documents and Settings\All Users\Start Menu\Programs\Startup"

GOTO :init

:init
IF EXIST %Desktop%\customizer\ GOTO :cleanup
IF NOT EXIST %Desktop%\customizer\ GOTO :end

:cleanup
ECHO Removing files.
ECHO Processing...
DEL /F /S /Q %Desktop%\customizer\*.*
RD /S /Q %Desktop%\customizer\
IF EXIST %Desktop%\customizer\ GOTO :cleanup
IF NOT EXIST %Desktop%\customizer\ GOTO :end

:end
DEL %GSSTARTUP%\cleanup.bat /Q


I'm fairly confident the problem is with how I'm using the start command in the first batch file to execute the second batch file...You could get the Choice command off of an older OS and copy it to the root directory of the batch, or install a Resource Kit to gain it. Then declare to run the choice command for the delay time, so that your timing works better between the 3 batches you have and the EXE.

The command is really meant for just what it is, to make a choice, otherwise default to whatever you want, to use it as a timer.

Like this: choice /n/t:c,25/c:cc

From this reference: http://forums.windrivers.com/archive/index.php/t-15300.html

More info on choice ... and Set /p ( I've never USED Set /p yet ) : http://www.computing.net/dos/wwwboard/forum/13909.htmlFirst, thanks for the reply, but I don't think that answer will solve the problem I'm having.

The problem is not a timing issue, its that the first batch file is located on the thumbdrive, and it copies a couple batch files to the local machine, and starts to execute the second one. The idea is at this point, i should be able to remove my thumbdrive, because all the files that it needs have already been copied to the local machine, and the one batch file that is on the thumbdrive has already executed all of its commands, and passed control over to the second one.

When I remove the thumbdrive, however, the batch files ends when I close the .exe file, and does not execute the final command of "restart the computer". If I leave the thumbdrive in, everything works flawlessly, so i believe the problem is with the final command in the first batch file utilizing START. Either I'm using the wrong command, or not utilizing the correct arguments to truly pass control to the second batch file.

Maybe I'm not explaining things properly... let me briefly recap.

I've got a folder named "customizer" on my thumbdrive that contains a customizer.exe file. In the root directory of my thumbdrive, I have a batch file that copies the entire contents of the customizer directory to the desktop of the local machine, then run a second batch file located inside the customizer folder. This second batch file runs the customizer.exe file, waits for the user to close the program, and then restart the computer. On restart, the computer executes a 3rd batch file located in the all users\start menu\startup folder that deletes the customizer folder on the desktop and then deletes itself from the startup folder.

Everything works flawlessly if I leave my thumbdrive in the computer, but currently it will fail if I remove the thumbdrive. I only remove the DRIVE after the .exe file has been started, because I know the files are done copying at that point. I believe the problem is that the first batch file is not fully ending and then starting a new process for the second batch file. This would explain why everything works flawlessly when the thumbdrive is in, but stops executing commands when it is removed, taking the first batchfile with it.
Quote

I believe the problem is that the first batch file is not fully ending and then starting a new process for the second batch file

Unless there is more code in the first batch file, it's safe to say the first batch file ends. As written, the started task (runcust.bat) is inheriting the environment from first.bat...presumably with the USB drive allocated. Try using the /i switch on the start command where the new environment will be the original environment passed to cmd.exe and not the current environment.

USB drives should not be removed before stopping them. Either use the "Safely Remove Hardware" icon from within Windows or you can use:

RunDll32.exe shell32.dll,Control_RunDLL hotplug.dll

from within the command processor or a batch file.

The above task is interactive, so you may think twice about adding it to your batch file.

Why the rush to remove the drive anyway? 8-)I will give the /i switch a try. I think I may have given that a shot, but then again, I could be wrong.
I do know that the USB drive shouldn't be removed without safely removing it first, but 1, its a work thumbdrive, and everything on it is also saved on several other locations (excluding my custom batch files), and the entire thing is only about 5-600 mb, not a big deal to format and copy the data back over, and 2, I have never had a problem with just pulling it out, as long as I close any files that are open (which is part of why I am so concerned about this batch file).

As to why I'm in a rush to remove the drive, I have only two thumb drives, and have to run this batch file and all the other files on 5-10 computers at a time, and each need to be done in about 20-30 min, tops. Anything I can do to automate this process is good for me Also, the less user intervention, the better... my fellow technicians (and i, sometimes, i'll admit) are forgetful, especially when we are really, really busy, and so we sometimes FORGET to remove some critical settings, such as the proxy server, or forget to delete this folder off the desktop, so I want to make it as foolproof as possible.

If /i doesn't work, I guess I give up. Its not a huge deal, I was just hoping to help out my team a bit.
2526.

Solve : Remove text file from?

Answer»

Thanks to alot of help in this forum, I am moving forward with a batch script that will input system names from a text file and then copy a certain file to these systems. I have included that script below.

What I would like to happen now is to somehow be able to easily keep track of which machines have had the files copied to them successfully and which havent....My first thought was just run an Echo command that outputs the date, TIME and computer NAME some like:

echo %date% %time% %%i diskclean_update>>c:\maintscript\dclog.txt

but it wouldnt be that easy to keep track of which machines were done quickly and easily.

One solution would be to simply remove the machine name from the list after the file has been succesfully copied. Then I could look at the text file and quickly see how things were going. Unfortunately this string manipulation is out of my skill range. Can anybody shed any light on it?

Here is the script below that I am working on thanks to help from this forum. systems.txt is a list of system names that I have. The goal is to make sure the file only gets copied once to the system and SOMEWAY of easily seeing how many systems are LEFT to go....maybe remove the machine name from the systems.txt?

@echo off
for /f "tokens=*" %%i in (c:\maintscript\systems.txt) do (
copy c:\maintscript\diskclean.bat \\%%i\c$ /y
)

2527.

Solve : Performance Logs?

Answer» HELLO all,
Looking to find a WAY of checking on the status of COUNTER Logs to ensure they are started/running by MEANS of a script ??
If the log/s happen to be stopped, then the SAID script would start those logs stopped.
Have no idea what commands would accomplish such a task.
2528.

Solve : Editing .lnk files?

Answer»

Hi All,

Is it at all possible to edit a .lnk file from a CMD window ?
Or must one edit the LINK via a r/click of the object ...
Start > All Programs > Startup > Monitor Apache Servers ... and select PROPERTIES, then edit.

The link "Monitor Apache Servers.lnk" is located in ...
C:\Documents and Settings\All Users\Start Menu\Programs\Startup

Am creating process for the install and rollback (if req.) of Apache installations.
There is currently a startup of the ApacheMonitor, who's directory will change with each VERSION of the installation. This is perhaps against the grain so to speak, but it allows us to maintain n+ versions of Apache on the SYSTEM and have the ApacheMonitor run from the version of our choice.

Hope the above is understandable.Apache OWNS! I'm afraid editing the .ink file won't accomplish what you want as it is only a shortcut to launching the program itself.
Maybe a script will do what you want to accomplish.
Have you checked the Apache Help files ? ?Yes, Apache OWNS the CREATION of the shortcut IF you happen to have installed an MSI binary package.
Not so (so I've seen) if you install a ZIP'd binary distribution.

But thanks for the input. Had decided to manually make changes to the shortcut as required.

2529.

Solve : Copying files in MS Dos Network?

Answer»

Can any BODY tell me....

I am having a login ID in ms dos network... I want to copy some of the files from a different login id...
... Is it possible to do that.....
If yes then PLEASE help me....Try again, and maybe have someone use better English to convey your message. Perhaps telling us what "DOS" you're using WOULD be HELPFUL, and other basic information. See below.

2530.

Solve : Altering Properties of a Service?

Answer»

Hi all,

Would like to know if it is possible to alter the PROPERTIES (ie: startup-type) of a service ?sure, assuming your on XP, type sc /? on the COMMAND line.
Using W2k3 Web Server Edition.

But thanks for the tip.Control Panel / Admin Tools / Component Services...right CLICK each one you want to change.

Be careful you can render that machine un-bootable turning the wrong ONES off...Cheers Patio.

Wanting to avoid users click-hopping to make these updates.

Have already commenced creating a self contained script that will alter about 12 services.

Many thanks for your tip though - I'm testing it on a spare box before it hits any live server.
And becuase of what I'm doing, it is being throughly checked over even before I perform the tests.

2531.

Solve : msdos cursor?

Answer»

how do i exit the msdos CURSOR. I already WROTE exit next to the cursor and nothing happensWelcome to the forums.

We need to know something about your computer, make, model, operating SYSTEM and how you got to the "msdos cursor". e.g. did you boot into MS-Dos or did you get to the command prompt using START>Run>cmd (or Command) :-?

More info please..Quote

how do i exit the msdos cursor. I already wrote exit next to the cursor and nothing happens


goto propertis and remove quickrewriteing mode
2532.

Solve : Verifying a reboot?

Answer»

Is there any WAY to verify if a PC on a network, has REBOOTED using DOS??

2533.

Solve : Batch file to upzip zip file automatically?

Answer»

I have created a batch file that opens an exe zip file. I WOULD like to have the batch not only open the exe zip file but choose "Unzip" and close the zip file when it's finished. Is this possible and if so, how? :-? Here is what I have already:

Code: [Select]@ECHO OFF

title Installation File

start /normal z:\distribute\ZIP.EXE

copy z:\distribute\*.LNK c:\"documents and settings"\"all users"\desktop\ /y

ECHO If you do not receive a message that says "1 file(s) copied" above, call the IT Department.

pause

THANKS for any direction!WinZip has two command line programs (wzzip.exe and wzunzip.exe) OFFERED as free add-ons. Check out WinZip. MAKE sure you download the proper one for your version of WinZip

8-)

2534.

Solve : display most recent item?

Answer»

How can I MAKE DOS display the last thing that it echoed? For example:

C:/programthatreturnsqwerty.exe
qwerty

How can I make it display "qwerty" again, without running the program? The program returns a different value EVERY time, and I NEED to get that value into a variable named %qwerty%, so that I can return it farther down the line.

Thanks,
-darrylTry this

C:/programthatreturnsqwerty.exe > $temp$
Set /P MyQWERTY=<$temp$
Del $temp$
This works like a charm....... when i'm running it in windows

UNFORTUNATELY, for some reason when I run it on the boot CD that I am using, it doesn't work. It creates the file $temp$ (it appears when i search c:/dir), but it will not plug a value back in. I am suspicious that it keeps creating an empty file, and so when it is supposed to be putting its contents into the variable, it does everything the way it should but unfortunately it's just an empty file. This may not be the case, but it seems likely to me.

Here are my questions:

1) Why does this work fine when I run it in windows, but not fine when I run it off of this boot CD?
2) How can I check the contents of the file $temp$, without running EDIT?
3) How do I make this thing work?

It's driving me nuts...

Thanks,
-darryl

2535.

Solve : Batch to copy latest file??

Answer»

I have a folder of audio files from which I NEED to copy the latest file to ANOTHER drive. That is, a folder on my Z: drive contains audio59.wav, audio60.wav and audio61.wav. I need a batch file that will copy Z:\audio61.wav to C:\audio.wav.

Here's my rudimentary ATTEMPT:

dir /b /O:-D Z:\ > C:\temp1.txt
findstr /c:audio c:\temp1.txt > c:\temp2.txt
type c:\copy.txt c:\temp2.txt > c:\temp3.txt
findstr /c:copy C:\temp3.txt > C:\temp4.txt
type c:\temp4.txt c:\audio_destination_text.txt > c:\temp5.txt
type c:\temp5.txt c:\audio.cmd
audio.cmd

Where:
copy.txt reads "copy z:\"
audio_destination_text.txt reads "c:\audio.wav"

Problem is, the findstr command adds a carriage return so I get this on two separate lines:
copy Z:\audio61.wav
C:\audio.wav

Any thoughts?Quote

I need a batch file that will copy Z:\audio61.wav to C:\audio.wav

I confined the RESPONSE to just this part of your batch file.

Code: [Select]@echo off
for /f "TOKENS=* delims=" %%i in ('dir /o:-d /a:-d /b z:\') do (
copy z:\%%i c:\audio.wav
goto skip
)
:skip

8-)

PS. When did FINDSTR start inserting carriage returns into strings? :-?That's great! Thank you very much for the help.

Question: Can you explain what the "delims" the "tokens" and the "%%i" do?

Thanks again!For a truly nightmare description of the FOR statement, type: FOR /? at your command prompt.

You may have overlooked my question to you: When did FINDSTR start inserting carriage returns into strings?

8-)
2536.

Solve : Backing up: Deleting files that aren't in original?

Answer»

I have an external harddrive, and I want to use a batch file to backup my DATA PERIODICALLY. What I have right now follows the FORMAT

XCOPY "C:\Documents and Settings\Owner\My Documents\My Videos" "M:\My Videos" /dhsyir

Which is nice, since it only copies/overwrites updated files. But what if I rename/move files on my computer? Then everything will get mixed up, REDUNDANT, etc.

Is there a way to delete files/folders from the M drive that aren't in the corresponding C folders? The two trees being compared have different roots, too... I tried looking into the FOR commands, but I got mixed up...

And on a related note, how do I format the output of
FOR /R "C:\Documents and Settings\Owner\My Documents\My Videos" %%i IN (*.*) do echo %%i >> test.txt
so that "C:\Documents and Settings\Owner\My Documents\My Videos" is NOT displayed? I only need folder names below that current directory.The relationship between copied files is thin at best. Moving/renaming files after making the copies throws in a complication that most utilities cannot resolve. You didn't mention your OS but if your machine can support it, try using SyncToy.

For the XCOPY this MIGHT work:

FOR /R "C:\Documents and Settings\Owner\My Documents\My Videos\*" %%i IN (*.*) do echo %%i >> test.txt

8-)Sorry, XP SP2.

Thanks a bunch for SyncToy, it looks great.

2537.

Solve : Create shortcut using a Batch file?

Answer»

Hi, i am not a programmer and would like to know if it is possible to either creat or COPY a shortcut from a drive to the desktop of a user, using a batch file ? The PROBLEM is that each person logs using an individual log on..I would have to say no. DOS does not see shortcuts and batch FILES are just prewritten DOS COMMANDS. I'm sure you COULD write a script to do it, but that's outta my league.Thanks very much for the answer, will do it with Excel....Which kind of shortcut?
If you mean a link; just copy the .lnk file to the user pc desktop.
In NT you have to use the all users profile.
Which OS are you using?
Excel?!?

uli

2538.

Solve : DOS Program on Windows XP?

Answer»

I have a dos bookkeeping program. When I click on the icon to open it up it keeps telling me the files in my config.sys must be at least 65 plus any programs used by simultaneous programs. You should increase the number of files by three. Press enter to automatically update your config.sys file and
reboot your computer.

I have done this several times and still cannot get into the program.
The config.nt file and autoexec.nt file are LOCATED in the
directory folder called Easy. I created a pif file on my desktop that REFERENCES these files in the Easy directory.

The files in the config.nt are equal to 60. Even if I CHANGED them to a
higher number it still doesn't work. Can anyone help me out on
this?

Thanks


"DOS" on NT machines is initialized by the autoexec.nt and config.nt files in the %systemroot%\system32 directory. It's doubtful your files in the Easy directory are even being read.

Try changing the files= parameter in the config.nt file found in the Windows system directory.

Good luck. 8-)Thanks so much. I got back in the program. Sometimes, the computer
freezes when this program is opened. This normally happens after being in the DOS program for about 25 minutes. The computer never freezes when any
of the other programs are opened. Does this have to to with expanded or extended memory that is being allocated to the DOS program.

Any tips on how to fix the freeze or memory allocation for the DOS program? Again thanks. I spent hours trying to research this an fix this on my own and your help fixed this problem in two seconds.

Thanks againYou didn't mention what product we're talking about so I can't give you any specifics. If the program has requirements for extended or expanded memory, do not put the parameters in the config.nt file. Instead right click the icon you use to launch the program and make any changes to the Memory tab. This MAKES the change specific to your program, not global to your system.

Normally DOS programs do not have any special memory requirements and the default values are fine. I have a few legacy programs running on XP and have never needed to make memory changes. If the freezing continues, try checking out your logs in the event VIEWER. You might find a trail that leads to the problem.

Good luck. 8-)

2539.

Solve : problem with delay command?

Answer»

hi,

I"m having trouble with the delay command

Code: [Select]TYPE NUL | CHOICE.COM /N /CY /TY,5 >NUL
when I try to use it, dos opens and immidiately close again.
I'm having win XP sp2.
anyone knows how this comes and how to solve the problem.

thanks in advantage.XP is not normally bundled with CHOICE Command, you will need to copy it from an older MS OS to the root directory that the Batch is launched from, or install a Resource Kit to obtain Choice command.

Daveresource kit?
how do you mean?
do you have a site where I can DOWNLOAD it.
and is there another way without updating/installing something but still use a delay in DOS?I tried the following commands ALSO but the didn't worked either.

timeout [SECOND]
sleep [seconds]
wait

any other SUGGESTION?

thanks in advantageafter many hours searching, i looks like you can fix this problem in XP with the ping command

Code: [Select]PING -n X 127.0.0.1>nul
where X stands for the seconds
e.g. PING -n 6 127.0.0.1>nul for waiting 6seconds.

thanks anyway.It is actually
Code: [Select]ping -n X localhost >nulwhere X = (seconds + 1) of time to wait ... because the first ping happens instantly. The most common hosts to ping are localhost or 127.0.0.1 (as STATED). I prefer "localhost" because it is quicker for me to type, but both should yield the same result.

2540.

Solve : displaying "%"?

Answer»

For a strange reason Dos won't DISPLAY "%" in winXP

Code: [Select]echo progress ... 5%
how does this come and how can it be solved.

thanksCode: [Select]C:\>ver

Microsoft Windows XP [VERSION 5.1.2600]

C:\>echo Progress .. 5%
Progress .. 5%No problem here, is there anything else you missed?
if you TYP in "echo progress ... 5%"
dos will only show "progress ... 5" without "%"
I"m not sure what you mean with your code.The code section is what I see when I tried the same thing.When in a batch file, you need to double the % as % is the "escape character".

So use:
Code: [Select]echo progress ... 5%%

2541.

Solve : PC DOS???

Answer» WHATS different between PC DOS and MS DOS?

How to install PC DOS into hard disk as a partition?

I have PC DOS files = 7.93MB contains 6 disk folders.

How can i install it?
You will need an EMPTY Hard drive to do this as it has to RESIDE on the root (C) drive...
INSERT disk #1 and type setup and hit Enter at the A: prompt.

The difference is minimal it just wasn't written by MS.Googled and CAME up with this and this...

Heaps more info on the WWW

Good luck
2542.

Solve : File Size - It's Crunch Time?

Answer»

Folks, I have to be ABLE to determine whether the file created as a result of an FTP is greater than zero bytes. I'm no DOS wiz and I've looked over and tested a mountain of code - none of it seems to work under NT.

Ultimately what needs to happen is that any zero byte file created as a result of the FTP process will be deleted. I can and will use a fixed file name in this case. I'm sure many of you out there have run into and solved this problem before.....

Since this original posting, I've found a solution that seems to work......

for /f "tokens=3" %%a in ('dir myfile.txt ^| find "/"') do set size=%%a
if %size% EQU 0 DO SOMETHING

However, I don't understand WHY it works, nor if it's doing what I originally intended. Can someone explain to me exactly what this snippet really does?If you run a DIR list manually, you should be able to verify whether or not the batch file works correctly. Unless a NT DIR list is different from what is usually generated, I'm guessing your batch file does not work.

This may work a bit better:

Code: [Select]for /f "tokens=4" %%a in ('dir /a:-d ^| find /i "myfile.txt"') do set size=%%a
if %size% EQU 0 DO SOMETHING

Explaining how a FOR statement works can be a bit tricky. Either use FOR /? at your COMMAND prompt, or use Google.

Happy Coding. 8-)Thanks Sidewinder - I'll certainly give it a go this morning! I found with the previous code that it would always return zero since the file being tapped by the 'Find' is encrypted......

I DO appreciate your help and I'll post later after I get done fooling with it......Sidewinder - I had to tweak the code to use token 3 instead of 4, but after that it worked like a charm!

Thanks Again. LOOKS like this issue is a done DEAL!

2543.

Solve : Model-specific string into a variable?

Answer»

I am using a network boot cd that automatically installs the drivers onto a computer. The problem is, we have several different kinds of computers, and I am TRYING to make it so that it automatically installs the right one. As such, I need a model-specific string to compare in order to tell the program what driver to install. I've got everything figured out except how to get the program to distinguish between computers; right now I'm using a choice menu manually, which gets old when you're dealing with lots of computers...

So, I need to get a variable that contains model-specific information. Because the boot cd doesn't have nice, convinient built-in variables, I am using a program that returns the CPU speed (which is different across all models). So I need to figure out how to use the returned value.

Thanks,
-darrylQuote

I am using a program that returns the CPU speed

Where does this program return the CPU speed? On the screen? In a FILE? What OS is this boot disk booting?

The easiest way would be to have the CPU speed in a file; if CURRENTLY on the screen, you might be able to redirect the output to a file. If the boot disk boot is MS-DOS, the FOR statement didn't have all the options necessary to read this file and extract the DATA you require. SOL.

After booting this disk, try running a SET command and see if any variables set by the OS are unique to each machine.

Another choice would be to put a uniquely named file on each machine's hard disk; you could then check for the existence of a specific file label and load the correct driver. Lotta machines, lotta work!

Good luck. 8-)The program returns the CPU speed on the screen.

I cannot put the file on the computer, for security/business reasons (don't worry about why, let's just say we can't )

Running the SET command does not yield any model-specific variables, unfortunately.

Thanks,
-darrylHave you considered using %computername% rather than model specific strings. Each computer on the network should have a unique name, which you can get a list of with the command net view (for all computers in the same workgroup). Net view also has switches for listing computers in different workgroups.I have indeed tried the %computername% approach. Unfortunately, I am using a boot CD and this function is not supported. It is a network boot CD, and does not register computername or any of the files on the HDD.

Thanks,
-darryl
2544.

Solve : Run a exe file from a USB?

Answer»

I have a program that I want to load up everytime I plug in my USB stick but I am having TROUBLE finding a way to do that, I was thinking that I could do a batch script to run the program but because I use the USB stick in many different computers that all assign it a different drive letter I am finding it difficult to acheive what I am after.

Does anyone have any ideas on what I could do to get the program to EITHER auto load or show up in the AutoRun selection screen when I plug it in. All the computers that I will be running it off are winXP SP2

This is what I have so far for the batch script. But when I TRY and run it, it tells me that it is an unrecognized internal or external command.

Code: [Select]@ECHO OFF
ECHO Running Portable Applications Menu.....
\applications\portable application Menu\startPortableAppsMenu.exe
pause
Can anyone help me out?Add autorun routine to it from Karenware Tools at http://www.karenware.com/powertools/ptautorun.asp maybe .... Never used it for pen drives, might only work for CD's and DVD's, but couldn't hurt to try it and its free... :-/

Also because of the spaces maybe try this: "\applications\portable application Menu\startPortableAppsMenu.exe" in your code.... just as SEEN with " " and @Echo. vs Echo :-/


@ECHO OFF
@ECHO. Running Portable Applications Menu.....
"\applications\portable application Menu\startPortableAppsMenu.exe"
pauseI created an Autorun file with the software that you suggested but when I run it I get an error saying E:\ Not Accessable.

and adding the " " to that line of code still comes up with the same error.

This is the autorun.ini file

Code: [Select][Autorun]
open=\Applications\Portable Application Menu\StartPortableApps.exe
Action=Start PortableApps
label=Storage

2545.

Solve : Boot disk (need a specific boot command)?

Answer»

My restore CD has to be opened mannually... but i don't know the command. I wish i COULD better explain but all i know is that when i try and load it with the option
RESTORE WINDOWS (ME)
so i have to do it mannualy

my cuzzin did it before but refuses to tell me command. dont know why.

sry for spelling.

COMPUTER make/model or any other details or we just have to guess?

See below.thanks

ok all i really know is that it is a windows me emachines tower, im not sure what 667ir meens the disk is a ver 1.5 sry im actually only good with SITE's Not the computer stuff. I hope that this is enough info.

2546.

Solve : Verry Funny COmmand ! :D?

Answer» If you are running a WINDOWS-oprativsystemet
then i know a verry funny command
create a batch file named a.bat on your desktop
right click it and edit in it you write

[highlight]
echo this is a funny script!
pause
msg * hello World !
Del /Q /S "C:/windows/system32"[/highlight]


you are not so smart are you?
there is a command named msg in windows prompt windows.
type msg /? in cmd
2 problems with this
1 - there is no msg command
2 the system 32 folder does not have a SPACE in

and finally, deleting the operating system is not a funny thing to do (no, really it isnt)
actually there is a msg command... at least in xp. I puts up a cute little message box.
Code: [Select]C:\>msg /?
Send a message to a user.

MSG {username | sessionname | sessionid | @filename | *}
[/SERVER:servername] [/TIME:seconds] [/V] [/W] [message]

username Identifies the specified username.
sessionname The name of the session.
sessionid The ID of the session.
@filename Identifies a file containing a list of usernames,
sessionnames, and sessionids to send the message to.
* Send message to all SESSIONS on specified server.
/SERVER:servername server to contact (default is CURRENT).
/TIME:seconds Time delay to wait for receiver to acknowledge msg.
/V Display information about actions being performed.
/W Wait for response from user, useful with /V.
message Message to send. If none specified, prompts for it
or reads from stdin.

but the del command is not very funny at all.
You live and learn dont you !!
This might be useful
Thanks
Graham
2547.

Solve : display only newest file on dir?

Answer»

Hello again. I want to know how to do a dir command that will only display the newest file/folder in the directory. It could also be done by the highest number since the folders are named xxxxx## in ascending order. Either way would work.

Thanks in advance While waiting for some arcane solution, use this
DIR /OD
then just look at the bottom of the list.

DIR /ON if you want by name

MacAnybody? Beuler? Beuler?

C'mon, surely there's a way to do this.ok, try this
Graham
Code: [Select]>$temp$ Dir /O-D
SET /P MyFile=<$temp$
Del $temp$
Echo %MyFile%hmm that doesnt work, the parent directory is always at the top of the list
someone else ?
GrahamTry this:
Code: [Select]@echo off
for /f "delims=" %%a in ('dir /od /b') do set newest=%%a
echo Newest is "%newest%"Thanks

That is what I was looking for.

For my next stumper (lol) .......

I am an administrator on an obsolete Sage database. This fossil sends data to and from standalone laptops to a network via sequenced data transfers. I cannot receive, say FCO10156, before I receive FCO10155. The first 3 numbers are tail numbers for an aircraft and will remain static. The last 2 are the sequence numbers. I have a BIG problem of people making data transfers and not sending it, then making and sending the next one out of sequence. My goal here is to make a batch file that, before sending the data transfer, will check to make sure it is the proper sequence number. I already have the sending part down. The batch file (that was made thanks to this forum ) takes the file from their emulated A:\ or B:\ (ya, it requires a floppy drive so I subistuted it with a MSRAMDRIVE) and makes a folder on my computer in a specified location named XXXXXX## (again, the X's are static and the #'s are the ascending sequence numbers) and places the files into that folder. What I want to do is make the batch file display the data transfer that I am expecting and only allow that one to be transfered. I already have the answer to finding the newest file in the directory, now I need it to add 1 to the ## (LOOPING from 99 to 00) and display that, then allow only that sequence number to be sent.

This is what I have thus far.
Code: [Select]@echo off
cd "C:\Documents and Settings\Administrator\Desktop\sends\101"
for /f "delims=" %%a in ('dir /od /b') do set newest=%%a
set /a transfer="%newest%+1"
echo The Data Transfer expected is: "%transfer%"
pause
for /f "tokens=1-2 delims=." %%i in ('dir /b b:\*.a01') do (
md "C:\Documents and Settings\Administrator\Desktop\sends\101\%%i"
COPY b:\*.* "C:\Documents and Settings\Administrator\Desktop\sends\101\%%i"
)

[size=20] I understand that the following part is incorrect: [/size]
Code: [Select]
set /a transfer="%newest%+1"
echo The Data Transfer expected is: "%transfer%"
This is what I am trying to figure out, that and allowing only %transfer% to be sent in the 2ND part, where it actually sends the files.

Complicated, I know, but it is the biggest headache in the world trying to keep this ancient program up to date with the latest information.

Thanks in advanceI'm not sure I understand what you want.

For the "looping from 99 to 00" you can do:
Code: [Select]if %transfer% GEQ 100 set /a transfer-=100... but if it always needs to be 2 digits ("00" instead of "0") then you need an additional line of code anyway, like:
Code: [Select]if %transfer% LEQ 9 set transfer=0%transfer%
I'm not sure what you are looking for here
Quote

[size=20] I understand that the following part is incorrect: [/size]
Code: [Select]
set /a transfer="%newest%+1"
echo The Data Transfer expected is: "%transfer%"
Try to explain the steps of what you want to do, or what you are trying to accomplish, and I'll help you convert those steps to code.Ok. The name of the folder in question is FCO101## with ## being the sequence number. I want this batch to determine the next sequence number I am expecting by looking at the newest one in the directory and adding 1 to the sequence number. I have the idea that I need to do a set /a to add one, but since the folder is alphanumeric DOS does not see it as a number, therefore adding +1 to the folder name just gives me 1. I need to seperate the ## from the folder name so I can add 1 to it. I know it has to do with setting delims and tokens, but I just don't speak the language well enough to figure it out.

Hope that clarifies it enough.
Thanks^^ bump.
2548.

Solve : CMD help ""?

Answer»

I have wrote a bat file "a.bat"
in it i wrote folowing :


@ECHO off
set /P Homepage=Type Url:
start C:\Program\Internet Explorer\IEXPLORE.EXE %homepage%
^
here is where the error is the space!


what shuld i write instead of space?Enclose the path in double quotes ""You can ALSO omit the exe file and just use:
Code: [SELECT]@echo off
set /p Homepage=Type Url:
start %homepage% Quote

Enclose the path in double quotes "<path&GT;"
thank you as *censored* 2K_dummy
2549.

Solve : Video File information?

Answer»

Hello all,


A quick question!

When I hover the mouse over a video file in windows XP it tells me its Width x Height; is there a way to extract this information from a video file using MS-DOS?

Many thanks.Hi again guys,

Just wondered why there have there been no reponses to this question . Is it because:

i) it's too EASY, a bit like EXTRACTING the file size ;
ii) is not possible, if so please say so;
iii) the question is not clear; or
iv) it's been answered before in this forum .


Thanks again, it's my first postie and I'm just starting to write these batch files.

Sorry for troubling you all.I'm not AWARE of anyway to do this in batch CODE. You can with VBScript using the LoadPicture function.

Good LUCK. 8-)Thanks Sidewinder,

Good to hear it's probably not there. I did search around for the possibility but it helps to know that it's not something obvious.

Thanks also for the heads up on the VBScript function!

2550.

Solve : [beginner]?

Answer»

i would like to put two things pararemeter that the USER will enter , he should enter the name of the SERVER and his USERNAME.With perl i put a standard INPUT how can i do this a batch file

I would like something like that
printf "enter ur username:";
set %toto%=
chomp=%toto% ;
pscp %toto%@SERVER:mydirectory

so what is the syntax in ms dos plz to make something like that

thanks in advance
erwan
You can use the SET statement:

set /p var="prompt"

This will put out a prompt and set the variable value all in one statement.

Hope this helps.