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.

3051.

Solve : how I can shutdown a service (process) ???

Answer» Some BODY how I can SHUTDOWN a service (process) from WINDOWS 2000 with a BATCH file?

Thank you for your time and HELP.
to stop the service, Use the command
Net Stop "Service Name"

3052.

Solve : no boot filename found?

Answer»

can you help me solve this PROBLEM...and my ibm laptop says ` operating system not found`
thanx.Check that there isn't a floppy DISK in the DRIVE.What Operating System do you have installed?If you have no floppy in the drive and the CDROM is empty, and your HD lacks the root OS kernel files, you can:

Boot to the CDROM (if the BIOS allows) and do an XP repair install (if it's XP) or start to DOS and USE the SYS utility (from a Win9x CD).

With Win9x, put an 'EBD' floppy in the floppy drive and boot to it, and use the SYS command to mount the minimal kernel files.

Boot to the CDROM with a Knoppix LiveCD, and use Linux to try to repair the damaged file system.

With either option, you need to get into your HD to see if you have any files there first before deciding what to do...

3053.

Solve : removing periods from directory names?

Answer»

Well I'm just stumped. I've written plenty of batch files, but can't for the life of me figure this one out.

I have a directory named report.2004.09.09 and I need to create a batch file to remove the periods from the directory name. A NEW directory is created everyday with periods. Can anyone help me figure this out?

Thanks,
CharlieI'm running Windows98se and in a DOS window I enter the command
REN report.2004.09.09 abcdef
and the file name was changed to abcdef

or am I MISSING SOMETHING in your query?

Chris CHeres a way of solving your problem

first, pass the name of the directory to a blank text file i will call "test.txt" which has one line "report.2004.09.09"

then create a bach file called "name.bat" and put this in there
"
FOR /F "tokens=1-10 delims=." %%J IN (%1) DO SET MMDD=%%J%%K%%L%%M
SET correctdate=%MMDD%
echo %correctdate%
"
the echo is just there for you to CONFIRM that it works. instead of ECHOING it, you can just rename the direcotry with the new output

3054.

Solve : DOS command for yesterdays date?

Answer»

I want to create batch file which will create directory with name as 'yesterdays date' every day.
Can any one please help me?i'd give you an answer but a MUCH SIMPLER SOLUTION is to go to this SITE and get the batch file labeled "yesterday.bat"

http://www.robvanderwoude.com/index.html

3055.

Solve : trim the leading string from the parm?

Answer»

Hi all.
I am getting a parameter date value as %1 into the bat file as "-ap02/01/2004 riTBS981 ji7296", but all I need to get is 02/01/2004 value from the 1st parameter. Can somebody help me on this. I really appreciate the reply.

Thanks
Ashsince i had no WAY of knowing where you got the variable from, i created a file called x.txt and put your variable "-ap02/01/2004 riTBS981 ji7296" in it

then i created a batch file called test.bat:
"
FOR /F "tokens=1-10 delims=-p " %%J IN (%1) DO SET MMDD=%%K
SET correctdate=%MMDD%
ECHO %correctdate%
"

now when you run "test.bat x.txt", you should get just the date and not the unwanted JUNK

3056.

Solve : How to check a file size using DOS command??

Answer»

How to check a file size USING DOS command?
Anyone can help?The simple DOS command
DIR xxx where xxx is the file whose size you would LIKE to see DISPLAYS the name of the file and it's size.

Chris C

3057.

Solve : Absoulte referencing?

Answer»

How to display files with a certin EXTENSION in a directory using ABSOLUTE referencingI may be reading this request in too SIMPLE a FORM. I don't understand the term "Absoulte Referencing".

Enter the DOS command DIR C:\mydirect\*.txt
to find all files which end in .txt in the directory MYDIRECT.

If MYDIRECT contains subdirectories, then
DIR C:\MYDIRECT\*.txt /s
to see all occurances of .txt file in MYDIRECT and in all directories within MYDIRECT.

Chris C

3058.

Solve : Display a message in config.sys similar to echo?

Answer»

Is there any way to show a message from the config.sys FILE after or before the menu items. Similar to echo in a BATCH file??? PLEASE help really stumped here.Try using Rem or ; PRECEEDING the comment you want displayed.

Rem Ok, dummy! Make a menu choice

; Ok, dummy! Make a menu choice

To force DOS to ask if a command should be executed USE ?

DOS?=UMB
Devicehigh?=ANSI.sys

DISCLAIMER: May not work in all versions of DOS

3059.

Solve : need help,want to use dos to open network file?

Answer»

i NEED to get into WINDOWS 2000 NETWORK neighbor and CHANGE the settings, my logon doesn't work for windows
can i get in using msdos

3060.

Solve : how to use Xcopy?

Answer»

:oHow do I use xcopy to transfer operating system to slave HDD so can transfer to ANOTHER computer If you have xcopy AVAILABLE, you COULD type:
xcopy /?
which should show you all the possiblities....

GOOD Luck!

3061.

Solve : Formatted windows 98 having trouble booting?

Answer»

I've formatted my drive and when I start up, with a start up/ boot disk in A: I get an error MESSAGE "invalid system disk" Replace disk, and then press any key.

I've tried that, I tried everything and to no avail. I just can't get past that . I did the format c: and it formatted with no problems until I try to put in my 98 boot up disk. Any suggestions what this could be??? Thanks for your help.

honee.....did you use that bootdisk to do the format ?

Is your bios set to boot from the floppy or something else ?

Where did you get the bootdisk you are trying to use ?

let us know

dl65 I went through dos by pressing ctrl and getting the dos prompt. Then I just typed in format c: I tried using a boot up disk I had from before to start the computer back up and it failed so I went on bootdisk.com and downloaded some from there and they didn't WORK either.Quote

...I just typed in format c: ...


Correct command is format c: /s
You have formatted but not transferred the Operating System (the "/s").
Try sys c: which transfers the OS after formatting or reformat with /s option.
honee......I'm still not 100 % clear on what you did .....You used the old "startup/bootdisk" in the floppy drive before you removed win 98 ........by .....at the A: prompt typing " Format C: followed by Enter .......and you GOT the warning about losing all the data....do you want to continue and you anwsered yes......then it proceeded to REMOVE all contents of the hard drive. Were there any partitions on your hard drive ? Then with the "start/bootdisk" still in the floppy drive you rebooted and the bootdisk loaded and you got an A: prompt......
Please clarify .....because it doesnt sound like you have the correct boot disk ?

let us know
dl65 after the format c did you use the fdisk command...if you are have problems.....go into the bios...when your pc is booting....press the ctrl or del key and change the boot sequence by using the arrow keys...boot from cdrom....the install disk should do the rest...if not have a look here>http://www.windowsreinstall.com/win98/install98cd/index.htm
3062.

Solve : What if?

Answer»

What would HAPPEN if C:\windows\system32\CMD.exe gets deleted? Me and my FRIEND are having a bet.You try it and let us know.Will the computer even boot up windows without CMD?

And im not going to test it out myself...

3063.

Solve : Upgrade from 95 to 98????

Answer»

I normally work with XP/2000 and am not sure but is it possible to upgrade from Win 95 to 98?

I have an old Wing Commander Privateer game I want to PLAY in DOS and I am having problems with 95 that is installed on a current drive. Not able to get a copy of 95 but can get a hold of 98.
just delete the 95 os and UPLOAD 98.If I do that, then what about the DRIVERS? Do I have to go through and locate each driver for the PERIPHERALS and back up those?Win98 came in 2 versions, Upgrade and Full. Either one should install over Win95. Either way, make sure you have all necessary drivers before you do the upgrade. If it's Win98SE, it has a lot more drivers "built-in" than the first edition of Win98.

3064.

Solve : problem?

Answer»

i dont have atoexec any more, but i have XP cd , how i can get it and where to i have to but itNot sure i fully understand what you're saying. If you're trying to install xp from DOS the command is

DRIVE:\i386\winntautoexec is included when you install an OS, or you COULD just create a batch file with the classpaths

3065.

Solve : DOS Programs screw up in win2k?

Answer» OKAY, so I have this program that was made for windows 95-98, and when I run it in Win2k, it starts the program up, but the CURSOR gets stuck in the top left-hand quarter of the screen. It's KIND of ANNOYING.
3066.

Solve : Sharing?

Answer»

does SOMEBODY know the command to SHARE a FILE in a network?I KNEW that command but i FORGOT it

3067.

Solve : Error Running Program?

Answer»

Hi...I'm really confused.
I'm trying to run a program and get the below message:

It is headed up:
16 Bit MS-DOS SUBSYSTEM

The message is:
C:\NEWFOL~1\spill\duke3d\DUKE3D.EXE
C:\WINDOWS\system32\autoexec.nt. The SYSTEM is not suitable for running MS-DOS and Microsoft Windows applications. CHOOSE 'Close' to terminate the program.

All I have is a 'Close' and 'Ignore' button. Both of which shuts down the application.

I am using Windows XP.

It happens on all MS-DOS applications.
I don't know what I've changed on my pC, they where working before?

Thanks

Martyhttp://www.jsiinc.com/SUBM/tip6000/rh6042.htmYou are trying to run a DOS graphics application in a DOS window, which won't work under XP. im having the same problem i get this error saying 16 bit subsystem not COMPATIBLE with msdos or windows app please choose to close or ignore can some 1 help me ,,,tyyes me too. does xp CD has those files if it does where should i put them

3068.

Solve : Boot disc?

Answer»

I need a bootdisc (98 or xp home )with Format and Fdisc. I have been to
http://www.bootdisc.com/bootdisc.htm and found many downloads there. Can someone please tell me what is the correct download that I require.
Glenaftonglenafton.....I think if you D/l win98SE oem disk it should work for you it has fdisk and format on it as well as all the cd DRIVERS you will require. If you have any problems with that disk , E mail me and I'll send you the 9x BOOTDISK which I just used to format and reinstall win XP home ....

HOPE this helps

dl65 Good evening dl65,
Once again my thanks. Should you EVER make it to Australia I owe you a few beers.
Regards,
glenafton Thank God my xp is running ok.
My 98 was sick, so I did a boot disk then re-formatted the hard drive...

Computer re-boots and I choose ( using CD Rom support)

at the A:\> prompt....I PUT in setup.exe "nothing"

At a lost.....help!!

NHBuckIt's D:\setup or whatever the CDROM is (D, E, F, or ...?)
To find out try dir D:. If directory is listed, then CDROM is D.

3069.

Solve : Automatically closing dos window after batch run?

Answer»

Hey All,
I'm new to batch programming, I managed to write one and it works well, all I need now is a command to close the dos window after the execution of the file.......can any one help please?

I've TIED EXIT but the dos SCREEN remains open

Thanks in advanceAre you using COMMAND.COM in your DOS shortcut or CMD? I'm assuming 2K or XP, since you didn't specify an O/S. I use CMD, and my windows close when I have an EXIT in the batch file. For W98, I believe there's a box you check in the PIF to close the window upon exit.
Hi John,

Actually I don't know what I'm using (cmd/command.com) I just doulbe click the .bat file (no shortcut). I created it with notepad and changed the file extension to .bat.

I'm using nt4 with SP6, windows95, win98SE and Millenium.

I'm guessing the most basic commands will work on all windows O/S. All I'm doing is looking for a file, IF it does EXIST run an .exe on the file, IF NOT EXIST echo MESSAGES to the user on what to check for.

Except for NT4, When I use EXIT, it just says finished on the top left of the window..

I can see NT is using the \windows\system32\cmd.exe.
I had a LOOK at the properties and I can verify that the check box is marked for "close on exit".....

Hi John,

Found a solution to my problem......just use CLS as the last instruction and hey presto the window closes.

The source came from www.ericphelps.com/batch/samples/closewindow.txt, who explains the why's therefore's of using EXIT and CLS to close DOS windows....

Regards
Nathan

3070.

Solve : updating dos from 4.10.2222 to version 6.22?

Answer»

i need 6.22 for MS-dos. i have 4.10.2222 and i was WONDERING where i can update ms dos?4.10.2222 is DOS 7 from Windows 98. DOS 6.22 is the DOS from Windows 3.1. GET BOOTDISK here: http://www.bootdisk.com/

3071.

Solve : screen size?

Answer»

when i open up dos command prompt only from WINDOWS 98 start up menu it only uses about 60% of the screen and i can't FIND out how to increase the area to use the FULL screen which i really need would really like help on this problem as i have tried everything i can think of but being quite a NOVICE that is probably not a lot thanks in advanceAlt-Enter will size to full screen.tried ALT-ENTER but nothing happened any other suggestions anyoneRight CLICK MSDos prompt. Select properties, select screen tab. Set to full screen, set initial size to 50 line mode.2k Dummy tried that still have small screen dont know if it matters that it's a dell laptop would'nt have thought so but some thing should be possible

3072.

Solve : I lost my xp disk and I have a missing dos file?

Answer»

I can't PLAY my "Lemmings" game or INSTALL my photoshop program. I get an error mssg. as FOLLOWS:
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.

The solution is to take these files from the installation disk and put them on the harddrive but I lost my xp disc. Is there any other way to fix this problem?ask m$oft for a replacement disk or the makers of your pci have same prob but i have windows xp cd what files should take wnd where shoul i but themThis is what I found in the help and support in xp. After reviewing it, It doesn't say that it applies to xp. I tried it and it didn't fix my problem. It said that I didn't have a destination. I gave up temporarily. If you have success, please let me know how!!!

An Error Message Occurs When You Run an MS-DOS or 16-Bit Windows Program
Applies To
This article was previously published under Q305521
SYMPTOMS
If you try to run an MS-DOS-based or a 16-bit Windows-based or Windows Server 2003, you may receive one of the following error messages:

16-bit MS-DOS Subsystem
path to the program you are trying to run
C:\WINNT\system32\config.nt The system file is not suitable for running MS-DOS and Microsoft Windows applications. Choose 'Close' to terminate the application.

16-bit MS-DOS Subsystem
path to the program you are trying to run
config.nt The system file is not suitable for running MS-DOS and Microsoft Windows applications. Choose 'Close' to terminate the application.

16-bit MS-DOS Subsystem
path to the program you are trying to run
C:\WINNT\system32\autoexec.nt The system file is not suitable for running MS-DOS and Microsoft Windows applications. Choose 'Close' to terminate the application.
You may be prompted to either quit the program or to ignore the error message. However, both options cause the program to quit.
CAUSE
This issue can OCCUR if any of the following Windows 2000 or Windows Server 2003 files is missing, DAMAGED, or not located in the %SystemRoot%\System32 folder:
Autoexec.nt
Command.com
Config.nt

RESOLUTION
To resolve this issue, type the following commands at a command prompt to expand the Autoexec.nt, Command.com, and Config.nt files from the Windows 2000 or Windows Server 2003 installation CD-ROM to the Windows\System32 or Winnt\System32 folder. Press ENTER after you type each command. When you type these commands, replace cd-rom with the letter for your CD-ROM drive, drive_letter with the drive letter for your system partition, and system_root with the name of your Windows 2000 or Windows Server 2003 folder (this is typically either Winnt or Windows). After you type these commands, restart your computer:
expand cd-rom:\i386\config.nt_ drive_letter:\system_root\system32\config.nt

expand cd-rom:\i386\autoexec.nt_ drive_letter:\system_root\system32\autoexec.nt

expand cd-rom:\i386\command.co_ drive_letter:\system_root\system32\command.com

The information in this article applies to:
Microsoft Windows Server 2003, Standard Edition
Microsoft Windows Server 2003, Enterprise Edition
Microsoft Windows Server 2003, Datacenter Edition
Microsoft Windows 2000 Server
Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Professional
Microsoft Windows 2000 Datacenter Server
Microsoft Windows Small Business Server 2003, Premium Edition
Microsoft Windows Small Business Server 2003, Standard Edition
Last Reviewed: 10/10/2003 (5.0)
Keywords: kberrmsg kbprb KB305521

3073.

Solve : how do you wildcards in IF statements??

Answer»

Is there a way I can put wildcards into this STATEMENT...

IF %1==(where I want to put wildcards) GOTO OK

I want to make it so that if someone enters in an IP address, (in the FORMAT of *.*.*.*) then the PROGRAM will run

But it is taking the *'s literally... Is there another way?

3074.

Solve : $NtUninstall$ files?

Answer»

Can the $NtUninstall$ files in the windows dir be DELETED from DOS COMMAND line?? They don't need to removed from a command prompt but you can do it that way...
They are for uninstalling Updates so make sure the machine has no issues before dumping them...Thanks Patio, I realize what they are. I am at a school and building a batch drive to clean systems when classes change. We are charged with the removal of any nonessential files and I am trying to streamline it and prevent forgetting any steps. It has been so long since I used batch files I have forgotten the switches. GOTCHA...
I'll move this to where the batch writers hang out ...Thank you sir. While you're at it, you might as well see if you can come up with a companion script to delete the entries from ADD/REMOVE once the files are deleted Why not use CCleaner Portable?
http://www.ccleaner.com/download/buildsHi Allan, an additional situation is there are different profiles that I clean of specific folders and files but do not delete the profile, which would be the best, so I need to select specific folders and files and when the deletion process is done I RUN defrag and chkdsk. I do this in the safe mode so when it completes and REBOOTS ready for the user login. My intent is to have it run unattended after the bat file is executed leaving me available to go on to the next system. These are classrooms with 30+ systems.

3075.

Solve : For loop with incrementing variable?

Answer»

Hey guys, im trying to create a batch file that will create 5 different folders.
I also need to use an increment at the end of each folder so there will be folder1, folder2 ETC...

so in pseudocode it would be something like

a=1
initialize loop for 5 times
create folder (using md folder(place variable here))
increment variable a
loop
confirmation/error message
pause
exit

i can do this in C but making a batch file using Machine language is MUCH easier, if i knew how to do it... any help would be great..
THANK you

Khasiar.
@echo off
set num=1
:loop
md folder%num%
if %errorlevel%==0 (Echo Created Folder%num%!) else (echo ERROR FOLDER%num%)
set /a num+=1
if %num%==6 goto eof
goto loop
:eof
pause >nulCode: [Select]@echo off
FOR /L %%i IN (1,1,5) DO (
md folder%%i
echo folder%%i
)

OUTPUT:

C:\batextra>kaus.bat
folder1
folder2
folder3
folder4
folder5
___________________________

C:\batextra>cd folder1

C:\batextra\folder1>Thanks guyz, both ways worked equally fine. this will SAVE me heaps of tmie Quote

heaps of tmie

To make five folders?
I just made five e folders in 13 seconds. By hand. And I am slow
How much time did you save? From the time you did the post until you got five folders.Quote from: Geek-9pm on October 25, 2009, 09:01:51 PM

To make five folders?
I just made five e folders in 13 seconds. By hand. And I am slow
How much time did you save? From the time you did the post until you got five folders.
the only difference is, you don't want to do that , say OP's requirement is to make 5 everyday. you are definitely not going to do that by hand every day.or maybe to make 5 every 20 minutes?... that's definitely a candidate for automation.Excatly right, and SOMEDAYS the number can increase, its just sooooo much easier, thanks again guyz, you have definetly made my work days 10X easier xD
3076.

Solve : Batch program for auto detection....?

Answer»

Can we write a batch program to auto detect the USB device that is when connected to computer ?

If possible please write the code.....
Thanx in advance....
http://support.microsoft.com/kb/310575/en-us

All the following information from the above site:

"Remove and reinstall all USB controllers
To remove and reinstall all USB controllers, follow these steps:1. Click Start, and click Control Panel, and then click Performance and Maintenance.
2. Click System, and then click the Hardware tab.
3. Click the Device Manager button.
4. Expand Universal Serial Bus controllers.
5. Right-click every device under the Universal Serial Bus controllers node, and then click Uninstall to remove them one at a time.
6. Restart the computer, and then reinstall the USB controllers.
7. Plug in the removable USB storage device, and then test to make sure that the issue is resolved."

please excuse bill, he has selective hearing "auto detect the USB device"

anywho,

with a bit of googling, i COULD not find any help with pure batch, but found with vbscript
Code: [Select]strComputer = "." '(Any computer name or address)
Set wmi = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set wmiEvent = wmi.ExecNotificationQuery("select * from __InstanceOperationEvent within 1 where TargetInstance ISA 'Win32_PnPEntity' and TargetInstance.Description='USB Mass Storage Device'")
Wscript.Echo("Waiting upon usb...")
While True
Set usb = wmiEvent.NextEvent()
Select Case usb.Path_.Class
Case "__InstanceCreationEvent" WScript.Echo("USB device found")
Case "__InstanceDeletionEvent" WScript.Echo("USB device REMOVED")
Case "__InstanceModificationEvent" WScript.Echo("USB device modified")
End Select
Wend
ran from command prompt:
Code: [Select]C:\tests>cscript /nologo drivedetect.vbs
Waiting upon usb...
USB device found
USB device modified
USB device removedQuote from: BatchFileBasics on October 24, 2009, 11:12:44 AM

Bill, The Original poster has selective hearing "auto detect the USB device"



"auto detection of a USB device" means the operating system automatically detects that a device has been been plugged into a USB port.

auto does not mean "audio"

A USB port is not a drive.

Your VBS code does nothing that the operating system has not covered.
-----------------------------------------

"USB is Short for Universal Serial Bus, an EXTERNAL bus standard that supports DATA transfer rates of 12 Mbps. A single USB port can be used to connect up to 127 peripheral devices, such as mice, modems, and keyboards. USB also supports Plug-and-Play installation and hot plugging." Troll Bill is active again.... Quote from: Salmon Trout on October 24, 2009, 05:23:04 PM
Bill is active again....

Please Salmon Trout I'm not trying to cause any trouble

Please tell me what is wrong with my post and I will rewrite or delete.

Thanks for your help.

------------------------------------------------
What is wrong with any of the following? :

"auto detection of a USB device" means the operating system automatically detects that a device has been been plugged into a USB port.

auto does not mean "audio"

A USB port is not a drive.

Your VBS code does nothing that the operating system has not covered.
BillRich: read the original post. Then read your first reply. State what relevance it has. It has none.

BFC answered the question he posed Re: detecting a USB drive when it is plugged in

Quote
"auto detection of a USB device" means the operating system automatically detects that a device has been been plugged into a USB port.

Yes. Very GOOD. have a cookie.

Quote
auto does not mean "audio"
the relevance of this being? BFC was stating that you, or more precisely, observing that you read "auto-detection of USB device" and instantly went about composing a random solution involving USB, without reading the full question.


Quote
A USB port is not a drive.

Again, congratulations on stating the obvious. Oh. here's a tip!: a piece of gum is not a weasel! BFC never said anything about drives... or ports, for that matter.

Quote
Your VBS code does nothing that the operating system has not covered.
Yes. It does. Does the operating System notify Batch Files when a USB device is inseted removed? No. Batch does not lend itself to that. So he scrounged up a VBS that does. The Operating System handles it but the request was for a way to detect when this happened.thank you for your post bc

but my abbr. name is BFB not BFC Quote from: BatchFileBasics on October 25, 2009, 10:47:55 AM

but my abbr. name is BFB not BFC

So it is...



Hi dudes........

What I'm asked ? What are you doing ?

I knew when a usb device is connected to the port the operating system will automatically detect it, but i didn't asked about it.

I asked you people is that write a "manual batch program" to automatically detect the usb when connected.

But you are...............Quote from: Vikram Varaprasad on October 26, 2009, 11:56:01 PM
Hi dudes........

What I'm asked ? What are you doing ?

I knew when a usb device is connected to the port the operating system will automatically detect it, but i didn't asked about it.

I asked you people is that write a "manual batch program" to automatically detect the usb when connected.

But you are...............

BFB provided this. It is IMPOSSIBLE via a pure batch file.Thank you , then where we can write that must support my question ?

BatchFileBasics' Post answers your question the best it is possible.ok, I'l try it. If any other solutions found please intimate me.

Thanks
3077.

Solve : Find and Replace (Encryption)?

Answer»

I THINK i will not CONTINUE with this project, but I have learned a few THINGS, THANK you everyone.

3078.

Solve : Help with set command variable subsitution?

Answer»

Hi guys am a little stuck with my little batch script basically i need to replace all the spaces with %20's of a filename string ( %~n1 )
Code: [Select]ECHO on

set SENTFILE=%~nx1
set SENTFILE=%SENTFILE: =%20%

echo %SENTFILE%

pause
I've tried all sorts to make this work it just seems that I can't escape the % character anyway!
I've tried ^ %% ^^ PUTTING it in brackets quotes etc.. nothing...

Can anybody help ? I know i can do this with vbs script but i'd rather not...

AbyssUK Code: [Select]echo on

set SENTFILE=%~nx1
setlocal enabledelayedexpansion
set SENTFILE=!SENTFILE: =%%20!

echo %SENTFILE%
endlocal

pauseThanks Prince! WORKS like a CHARM!

3079.

Solve : D-E-A-D (REALMS OF *censored* 2) Death Eternity And Dieing (BATCH GAME)?

Answer»

Just announcing a new version of my batch game, called (DEAD) Death Eternity And Dieing.. its not GOING to be completely new, it will be the current version of Realms of *CENSORED* which i havent released yet, version G8 but with these added features alot of which are already completed...


-PETS , you will be able to buy three types of pets.. to hold items/Attack/Travel with you (beagle,wolf,lion) and possibly others..
-Items , Finally going to add some items..
-Inventory, You will have an inventory of items on your pet and yourself.
-Maps , Already have about 15 or so map sets within the game.. im going to complete there functions and make them purchasable..
-A Store , there will be a store.. and a few variations of it(other stores)
-A Pet Store , There will be a pet store
-Area Information, Ive already added a look command.. but there was lack of flexibility in describing the current user action, so in Area information.. It will say things like (user is sleeping here) (pet is sleeping here) (an item is here) ect..
-Additional areas, im going to finish the CASTLE.. and the mainbase will become Another castle, i might also duplicate it.. with a few other variations, like say.. Red teams castle , or Demon Class Castle , ect

Ive already added additional commands like , spawn/clone/ but you will be able to spawn things.. like (thrones) with special powers ect.. spawn a sheild ect,

-im adding an additional city in (Above the ashes) , i already had the template for a city based off the first version that i never included.. (the city of light) , its an additional three hundred areas, plus the additional areas (stores,motels, ect) that ill add later,

- The Three Current Continents, Leviathan ect.. will be completed, with there own working maps, also the part of the continents that are suppost to include residential homes but instead just crashes the game cause they arnt there.. will have the homes
the continents will all be renamed

- there will be a few new commands, to add to already long list
Sacrifice (sacrifice dead bodys)
Quaff (quaff a potion)
Inventory (already added in previous versions, but this time it will work)
Buy (buy an item)
Sell (sell an item)
Donate (donate to another user)
Pray (already added, pray for items)
Spawn (Already added, Spawn All items)
Clone (Clone Items, Clone Humans,Clone pets)
Get (get an item from the areA)
GetAll (get all items in the area)
Scroll (Use a purchased scroll)
Look (Already Added, Look Around)
Drop (Drop An Item)
Dropall (Drop all items)
SIT (Sit Down)
Stand (Stand up)



[/b]


I might also replace all SET /p Commands with choice.com , so i can have a time out timer.. and when time is up , loop back to the room and through the secondary loop (xile) , Choice.com will be included... This will Create REAL Game time, and Improve current commands like follow .. ect , because the screens can only be updated by hitting enter or hitting a key right now,

3080.

Solve : Multiple processes in ms dos?

Answer»

Hello every one

can any one tells me how to handle multiple PROCESSES in ms dos shell?

I invoke the multiple process throught any other file like make -j .In this case multiple process reading from same file and it cause an error and terminate the execution.Quote

can any one tells me how to handle multiple processes in ms dos shell

How are you accomplishing this? Both the cmd and command shell programs are single threaded. Seems more likely you have multiple shell programs, each running a process that requires the same file.

You can develop a batch file to run your tasks sequentially and prevent the file conflicts.



Quote
Seems more likely you have multiple shell programs, each running a process that requires the same file.

I invoke the processes by the help of make -j .

by the way make -j1 , solves the problem in some limites.For a very brief time I thought you had managed to get MS Dos to multitask. You're certainly not using an MS Dos shell, I suspect you are using XP Cmd.exe. The GNU Make manual says it all...

Quote
GNU `make' knows how to execute several commands at once. Normally,
`make' will execute only one command at a time, waiting for it to
finish before executing the next. However, the `-j' or `--jobs' option
tells `make' to execute many commands simultaneously.

On MS-DOS, the `-j' option has no effect, since that system doesn't
support multi-processing.


One UNPLEASANT consequence of running several commands
simultaneously is that output generated by the commands appears
whenever each command sends it, so messages from different commands may
be interspersed.
Quote
You're certainly not using an MS Dos shell, I suspect you are using XP Cmd.exe.

correct I m using xp amd.exe, so is multiprocessing wroking on xp cmd.exe? but not on ms dos?

You will understand that cmd.exe in XP is not MS-Dos or any other Dos version. Cmd.exe is not Dos, it is a dos-emulator program which runs in the Windows environment. What you see when you start cmd.exe is a window. Although Cmd.exe will accept commands which look like Dos commands they are not Dos commands but Windows XP command line commands which are shown here...

Multiprocessing (multitasking) is not allowed in either the XP Command Processor or in MS-Dos. However multiple XP Command Processor windows can be opened.

GNU Make can process more than one command simultaneously but this processing is being done by GNU Make not by Dos or the Dos emulator.

Start cmd.exe and enter the command VER - you will probably see a display such as:Quote
Microsoft Windows XP [Version 5.1.2600]
This is the Windows XP version being used. If you enter VER whilst running Dos you will see the Dos version being used.

Hope this helps.I don't think the POSIX subsystem implemented by XP has the fork() method, which is likely used by GNU make for this feature.Quote
GNU Make can process more than one command simultaneously but this processing is being done by GNU Make not by Dos or the Dos emulator.

Dusty , Yes its true , now I try to USE win bash shell for using multitasking in win32 .

Thanks for ur help and KNOWLADGE sharing.
3081.

Solve : RE:urgent doff?

Answer»

try to use doff utility to run batch script. fail
-need to find all the month, year and date . how to use the doff /mm/dd/yy function like find all the file type
\Fin__20081126.tgz -with yyyymmdate (year,month and date)


-Move D:\FW_Purge_archive>move D:\FW_Purge_archive\Fin__20081126.tgz D:\FW_Purge_archi
ve\zipfiles\2008\-11







D:\FW_Purge_archive>for /F "tokens=1-3 delims=/ " %a in ('doff mm/dd/yy -1') do
(
set mm=%a
set dd=%b
set yyyy=%c
)

D:\FW_Purge_archive>(
set mm=11
set dd=26
set yyyy=08
)

D:\FW_Purge_archive>D:

D:\FW_Purge_archive>move D:\FW_Purge_archive\Fin__20081126.tgz D:\FW_Purge_archi
ve\zipfiles\2008\-11
The system cannot find the file specified.

D:\FW_Purge_archive>pause
Press any KEY to CONTINUE . . .

3082.

Solve : Is there any command to check if the batch file has completed successfully??

Answer»

I am a beginner to MS DOS batch file programming.

I have few batch files running EVERY night. I need to send an email to people giving the report generated by the batch file. The email should be sent only after the batch file is completed successfully and have generated a successful log file in a particular directory.
I send an email attaching that log file.

How should i check whether the batch file is completed successfully?

Thanks in advance.i dont know how to check if batch has completed successfuly but here is idea

if you use
CODE: [Select]dir C:\the %ERRORLEVEL% would be set to 0 (successful)
Code: [Select]dir XXX:\the %errorlevel% would be set to 1 (not successful)&&call batchfile.bat && PerformTask

3083.

Solve : Setting an environment for a user login?

Answer»

Hi Viewer,

Is it possible to SET environment for a user who logs in to the system USING a telnet connection? I mean I want to set some environment variables for the user as per the login name. Is it possible to do that in DOS / Windows when a telnet connection is established?

Thanks,
Ravi. You'll find the file which runs when telent occuring,and of course you can CHANGE the codes inside:
Code: [Select]type "%windir%\system32\*.CMD"

Setting an environment?

There're some ways:
1. It seems as if you'll set the registry by launching reg.exe or regedit.exe,but it won't work unless you have restarted the computer.
2. wmic.exe
3.to use vbscript or javascript.

3084.

Solve : moving script in dos with different file type?

Answer»

i would like moving bacth script to move the file with DIFFRENT TYPE and different folder name.

example:
move /y e:/FW_purge_archive/zipfiles/Ter_20081104\*ter\ E:\FW_purge_archive\zipfiles\2008\2008-11

Ter_20081104 (is winzip files with Ter_YYYYMD)year month and date

i dun wan keep writing again in my coding due to the so many month in one year and date and became hard coding.

any idea for me to define and SOLVE it


Regards
Danny

My ENGLISH is poor, I don't know how to describe.

You can first use this CODE to show and check. if the result is right, cut 'echo ' from 'echo move /y "%%i\*ter" "%filepath%\!YYYY!\!YYYY!-!MM!" 2>nul', then run the batch.
Code: [Select]@echo off
set filepath=e:\FW_purge_archive\zipfiles
setlocal enableDelayedExpansion
for /d %%i in ("%filepath%\Ter_*") do (
set fp=%%i
set YYYY=!fp:~-8,4!
set MM=!fp:~-4,2!
if not exist "%filepath%\!YYYY!\!YYYY!-!MM!" md "%filepath%\!YYYY!\!YYYY!-!MM!"
echo move /y "%%i\*ter" "%filepath%\!YYYY!\!YYYY!-!MM!" 2>nul
)
setlocal disableDelayedExpansionunable to use the script.....neeed help

would like moving bacth script to move the file with diffrent type to the different folder by year and month
example:

move /y e:/FW_purge_archive/zipfiles/Ter_20081104\*ter\ E:\FW_purge_archive\zipfiles\2008\2008-11

example: File type
Ter_20081104.tgz (is winzip files with Ter_YYYYMD.tgz)year month and date
Fin_20081204.tgz

i dun wan keep writing again in my coding due to the so many month in one year and date and became hard coding.

Thank

3085.

Solve : file comparison or checklist?

Answer»

Code: [SELECT]@echo off
setlocal enabledelayedexpansion
SET today=%date:~10,4%%date:~4,2%%date:~7,2%
set count=0

for /f "tokens=3 delims=_" %%i in ('dir /o-d \output\wl_*%today%*.zip') do (
set match=n
for /f %%f in (simple.txt) do (
if %%i EQU %%f set match=y
)
if !match! EQU n (echo Lockbox: %%i ... RECEIVED -Not on list) else (echo Lockbox: %%i ... RECEIVED)
call set /a count+=1
)
echo File(s): %count%
Sweet! That worked. I'm sorry for the CONFUSION. I thought that the tokens were the number of delimiters in the file name, based upon the very first sample GIVEN. Thanks for the clarification. At least I learned something. Token is where your prize is LOCATED.

3086.

Solve : return the nth character of a string?

Answer»

Hello again,
If I want the 5th character of a string, I can pretty easily get it like this
Code: [Select]C:\>SET a=santiago
C:\>ECHO %a:~5,1%
iBut does anyone knows how to get the nth character (where n is a variable)?
Code: [Select]C:\>SET a=santiago
C:\>SET n=5
C:\>ECHO %a:~%n%,1%
santiagon%,1%Thanks in advance
SantiagoCode: [Select][quote]
If I want the 5th character of a string, I can pretty easily get it like this

C:\>SET a=santiago
C:\>ECHO %a:~5,1%

Actually that code extracts the sixth character. The 5 represents OFFSET (zero-based) not position.

This snippet duplicates your code and retrieves the sixth character. The code is written for batch file use only.

Code: [Select]@echo off
set a=Santiago
set n=5
for /l %%i in (%n%,1,%n%) do (
call set bit=%%a:~%%i,1%%
)
echo %bit%

PS. Sometimes you have to read between the lines of previously posted answers. Although the question was different, the technique is remarkably close to your request.Thanks Sidewinder,
You're TOTALLY RIGHT about the fact that 5 is an offset and not a position.
and great job for the snippet. It WORKS fine.Quote from: Sidewinder on November 25, 2008, 06:34:06 AM

for /l %%i in (%n%,1,%n%) do (
call set bit=%%a:~%%i,1%%
)

it can be simpler:
Code: [Select]for %%i in (%n%) do call set bit=%%a:~%%i,1%%
THANK you Prince_
3087.

Solve : required to work on stop and start services in a sequential order?

Answer»

I need to stop services in the FOLLOWING order
service1
service2
service3

Service 2 and service 3 should be stopped only after service1 has been stopped.
After Service 2 and 3 has been stopped, once confirmed, they have to be started and once it is DONE, service 1 has been to be started

i found the way of stopping and starting of services. i.e, using sc command. All that I could not get is implementation of logic...

Request you to provide me some help.Code: [Select]sc stop service1
sc stop service2
sc stop service3

sc start service3
sc start service2
sc start service1Actually, I am AWARE of this. But, I PLANNING to automate. That means, If I go ahead like this. With confirmation of the stoppage of service 1 only, it will stop 2 and then 3. But, I want to get it confirmed and then only stop 2 and 3. Until service 1 is topped it has to wait, check the status and then it should stop service 2 and 3 after service 1 is done.
Similarly, for start up as well.

3088.

Solve : display an exclamation mark?

Answer»

Hello there,
Just new on this forum. Hope I can find some help.
I would like to display an exclamation mark in a batch script but can't get through the problem.
Look at the following log and see if you can help me:
Code: [Select]C:\>type test1.cmd
@echo 75% discount!
C:\>test1.cmd
75 discount
C:\>type test2.cmd
@echo 75%% discount!!
C:\>test2.cmd
75% discountThanks in advance
Santiago
The problem is that both the % and ! are 'special'

Try prefixing them with ^
eg
echo 75^% discount^!

not tested, you will need to try it our
GrahamHi gpl,
Thx for your participation. Unfortunately, I forgot to mention that I tried that before.
And maybe you've not read it all, but I know how to display a percent sign (it's in the log).
Here are my guess:
Code: [Select]C:\>type test1.cmd
@echo 75% discount!
C:\>test1.cmd
75 discount
C:\>type test2.cmd
@echo 75%% discount!!
C:\>test2.cmd
75% discount
C:\>type test3.cmd
@echo 75^% discount^!
C:\>test3.cmd
75 discount75^% discount^! ?

Again, not tested.Check the shortcut that opens the command prompt for any parameters. Normally delayed expansion is off by default so the exclamation point should not be interpreted as any thing but an exclamation point.

The echo command is reasonably transparent however percent SYMBOLS should be doubled up to be interpreted correctly.

Code: [Select]echo 75%% discount!

C:\Temp>type test1.cmd
echo 75%% discount!
C:\Temp>test1.cmd

C:\Temp>echo 75% discount!
75% discount!

Good luck.

Thanks Carbon Dudeoxide,
Your idea was already tested in my previous post.

Thanks Sidewinder,
You're right about delayed expansion but the problem is obviously that I need it activated.

Anyway, I finally FOUND the correct answer. I LET you COUNT the carret SIGNS!
Code: [Select]C:\>ECHO @ECHO 75%% discount^^^^^^^^!> test4.cmd
C:\>type test4.cmd
@ECHO 75%% discount^^!
C:\>test4.cmd
75% discount!

3089.

Solve : Networking 98se/DOS with Microsoft 2003 server?

Answer»

I am having problems with DOS networking it will SEE the network in windows 98se but when I GO into DOS it LOSES the network connection.
Please Help!

3090.

Solve : realms of *censored* batch game new version G7 *UPDATED*?

Answer»

improvements

- the loop inbetween loops works now
- i added (garden,the center room , the document room, the teleport room, the room of time, the invention room, the room of eternal wisdom) the room of gods
- The bank is now open at specific times, since the loop inbetween loop :xile works you can move back in time ect.. its closed for the first 12 hours
-the document room displays bank records ect.. you must be "unholy" faith to enter
-the teleport room includes a continent teleporter and a teleporter to any section :
-the room of time includes a list you can move back to any spot in the game, every move is logged, only type the number involved and not your username
-the document room is lexiathan and so is the castle, theirs two castles now ones not completed and the other is only half completed, the gargoyle comes down and kills you because its not completed
-made improvements using %1 , type batchname.cmd clear to reset or batchname.cmd skip to skip the INTRO

[Saving space - attachment deleted by admin]uppinLooks very good, but confusing in some PARTS. Regarding the code it is very good.
thanks , heres another update it just fixes the bugs in the latest update and adds some improved chat FEATURES (user joined,exited,died, ect) and a new comand who to see whos playing, remember its not multiplayer yet but you can still open two instances of it and see eachother

[Saving space - attachment deleted by admin]Looking good, I will not use it as I am currently working on ACE, Advanced Combat Engine.
Expect a RELEASE in the future.ill be looking for it It will not be in the near future, but should be fairly soon, as for 'zoo' it is very good.
Bye for now.looking forward to trying it..


-UPDATE
another update to version g, i added a bank teller that talks so does the sorceress
to avoid waiting 12 hours to see the bank type hour in the portal room
the big feature i added is a follow command, its one step closer to interactive charachters, open two instances of zoo.cmd , let it load , start two new players,
in one screen type follow then type the players name inside it, it will give a breif message then return to the current room, you wont be able to move untill the other player moves, so go to the other instance of zoo.cmd , move your charachter, then in the first instance of zoo.cmd just hit enter twice .. and you will follow it , for some reason the garden seems to cause a bug , type NOTFOLLOW to stop following


[Saving space - attachment deleted by admin]if theres a bug , first try rmdir /q/s %systemdrive%\roh before you start the new zoo.cmd , if that doesnt work .. you can type the following

set V1=%systemdrive%\roh
echo follow GOTO FLL0GRB>>%V1%\v
echo FOLLOW goto FLL0GRB>>%V1%\v
echo notfollow goto FLL0OST>>%V1%\v
echo NOTFOLLOW goto FLL0OST>>%V1%\v


easyest way of bug solving is typing , zoo.cmd reset

to cleanup .uj4 and .uj3 files left behind from a game crash you can type zap updated again



follow works a little better
you can now perminately kill any user from inside the church
you can now perminately destroy (disable) any room with a (rmid) from inside the church
i added a new room, "the room of the end" basically has device that destroys the world forever" but gives a chance to continue in (above the ashes)

the church is north at the storage room, go north again on the n stone, the room of truth , say void , and in the church type iamgod

[Saving space - attachment deleted by admin]

another revised version

-follow works all the time now instead of only sometimes
-you can now summon players to your area
-you can now kill players, its perminant but not like an attack or anything
-you can now freeze players, just freeze them to there current position
-you can now undestroy rooms, unkill players ,unfreeze players

new commands
freeze
unfreeze
destroy
rebuild
kill
unkill
summon
follow
notfollow
who
zap


[Saving space - attachment deleted by admin]Zoo G7

-As well as the previous improvments from G6
-Added A Motel "Xiathan Motel" You can visit it through the teleporter XIK0022

[Saving space - attachment deleted by admin]

3091.

Solve : Create user defined directory and copy file to it?

Answer» HELLO,

I have the following case and would like to know if this can be solved using a batch file.

we have a lot of computers that are MOUNTED into trucks. EVERY now and then I would like to have a backup of the eventlog. But to save the eventlog into a specified directory the user needs to create a directory, with the registration number of the truck. Is it possible to have a batch file that can first ask the user wich name the directory needs and after that copy the eventlogs to the map with the name that has just been specified by the user?

REGARDS,
RonaldCode: [Select]@echo off
set /p Dir=Enter directory name:
:check
if exist \%Dir% goto blocked
md \%Dir%
::COPYING goes here

goto exit
:blocked
cls
set /p Dir=Directory already exists. Enter new directory name:
goto check
:exit
Ok, that asks for the directory name, then makes it at the root directory (most likely C:\, but you can change where it's going to be saved). It also checks if that directory is already made, and if so asks for a new name. The ::copying goes here is where your copy code goes. I don't know where your eventlogs are located, but just write:
Code: [Select]copy "your eventlog location" \%Dir%Hello Dark Blade,

Thanks for the answer. This is working perfect

Regards,
Ronald
3092.

Solve : using FIND instead of FINDSTR?

Answer»

Hi,

The next batch works fine in dos under 2000 or xp but I need it to run in plain dos so the FINDSTR command isn't available.
Can someone help me to work around this one?



echo off
cls

:BEGIN
SET /p number=Enter Number :
findstr /x %number% serial.txt
if ERRORLEVEL 1 GOTO BEGIN
if errorlevel 0 ECHO Number appears in serial.txt
goto BEGINNot only is the FINDSTR utility not available, neither is set /p.

Code: [Select]echo off
cls

find "%1" serial.txt
if not errorlevel 1 ECHO Number appears in serial.txt

When you run your batch file pass the argument on the command line. FIND does not have a /x switch; closest was a case sensitive search.

How is this post related to your request for a C++ solution over on the programming board?

Because I need to change my HARDWARE ( the current palmtops are rather old and discontineoud).
Most modern palmtops don't work well with dos or you need an emulator which in my experience work rather slow so if I can get this to work in c++ I can START searching for other compliant hardware.

3093.

Solve : Batch File To Open Internet Windows?

Answer»

Hi all,

Is there a way to create a batch file that will open SEVERAL internet sites and arrange them so that the windows are tiled next to each other?

For example, say I want to open 4 windows, I would like it to open with the windows arranged top-left, bottom-left, top-right, and bottom-right. I don't know if there is a way to send arguments for size and placement parameters of the windows to the start command so that they open up with the correct size and position or if there is a way to re-size and place the windows after they are open.

So far all I have figured out is how to get Firefox open and to the correct website. The /MIN tag I'm trying to use to open the window in minimized state isn't working as it STILL opens in maximized state.

start /MIN F:\"PROGRAM Files"\Mozilla\Firefox\firefox.exe http://www.google.com/


Any help in getting this figured out would be greatly appreciated.

THANKS,
-tkrScratch that, I just thought of another way to accomplish this...

I can store the two files that have the stored session files from Firefox (localstore.rdf and sessionstore.js) and use a batch file to copy the files back into the firefox Profiles folder and launch firefox when I want to load that particular configuration. I like this method better because it'll be a whole lot easier to customize the window settings.

For those that were going to help me but hadn't yet seem my post, I thank you!

-tkrHeh, a pretty inventive way of doing this. Not bad.

Thanks for posting back. Thanks Carbon Dudeoxide.

I tried it with 6 windows and it worked for the most PART, but for some reason a couple windows aren't going back where I left them. Looks like I'll have to play with it a little more.

-tkr

3094.

Solve : Deleting Files, Folders, and subfolders(Solved!)?

Answer»

I am having a bit of trouble deleting a files and folders(with files in them) and the primary target folder with my batch code. The file structure and code is below.

Any help will be appreciated!

Thanks

Code: [Select]Tree structure is like this:

PrimaryFolder
|
Files
FolderA
|
Files
FolderB
|
FolderC
|
Files
FolderD
|
Files
Files


THE CODE That doesn't WORK!

Code: [Select]@echo off

regedit /s progx.reg
call MindWS.exe
regedit /s unProgx.reg

cd C:\Users\User1\Applic~1\Folder

FOR %%F IN (%*) DO ECHO Y| cacls %%F /T /C /G Administrators:F
:Set proper attributes for directories
FOR %%F IN (%*) DO attrib -h -s -r -a %%F /S /D
:Set proper attributes for files
FOR %%F IN (%*) DO attrib -h -s -r -a %1\*.* /S /D
FOR %%F IN (%*) DO echo y|del C:\Users\User1\Applic~1\PrimaryFolder\*.*

rd C:\Users\User1\Applic~1\PrimaryFolderWell, thought I was GETTING somewhere with:

Code: [Select]deltree [path to folder]/folder /Y
But system could not find deltree

So I moved on to:

Code: [Select]rd [path to folder]/folder /S /Q
and had success.

Thanks for the help not yet GIVEN!



3095.

Solve : network administrator?

Answer»

i want to LEAN how to control the local AREA networking WOAH! INFORMATION overload! Hey guys, let's let this guy shut down our SERVERS and domains .

3096.

Solve : Can I force my batch file to open at same spot all the time??

Answer»

When my client turns on her computer it automatically launches a batch file that I created but the batch file opens up at random spot on her computer. This looks UNPROFESSIONAL. Is it possible to force a batch file to open up at a specific spot all the time when it is launch, like bottom left corner of the screen? She uses window XP.

thank you...What are you running in the Batch File, Program or Running Commands?It's just a small batch menu that can run certain application depending on the USER's request.There's only one thing you can do.create a batch file to open CMD, then cmd will open the batch file in max screen then MINIMIZE it which in theory will bring it BACK to the same place after minimization.

3097.

Solve : If not defined statement not working.?

Answer»

Okay, in one of my batch files. If the user does not put an input I WANT it to go to the same question. So here's what I'm doing.

Code: [Select]if not defined "%VARIABLE%" goto question

However it is always undefined. Or am I not using the right command for this KIND of thing.
well think of it this way, when you use the SET command, you are declaring a variable, if the variable doesnt exist then SET creates a memory area deticated to that variable.

so just because nothing was INPUTED means that its defined, usually its NUL value or 0 if nothing is set to that variableDuh, why wasn't I thinking of this before .

Code: [Select]if "%variable%"=="" goto label
Quote

Duh, why wasn't I thinking of this before

In the first post you were trying to find out if a variable existed, the second you are dealing with the value of a variable.

Your first post works with this syntax:

Code: [Select]if not defined variable goto question



Well, I just heard of using defined in an if statement. I was thinking it did a completely different thing.
3098.

Solve : Using the FOR command?

Answer»

Hello,

Looking to create a batch file to take a file and PARSE out a CERTAIN value. The files all have a similiar pattern like this...

00000,,\6442\Vol002\001\00000.tif,Y,,,0
000001,,\6442\Vol003\001\002\000001.tif,Y,,,0
000002,,\6442\Vol003\001\000002.TIF,Y,,,0
000003,,\6442\Vol003\005\004\000003.TIF,,,,

What I need is to be able to output to a text file the file name only. For example "00000.tif" for the first line of the example above.

The path of the filename are not the same and may have less or more subfolders than others, but everything else is the same.

How can I output a text file with only the file names using DOS.

Would the FOR command be useful? If so, can someone assist with a script?

Thanks guys.

00000,,\6442\Vol002\001\00000.tif,Y,,,0

is each "path" always preceded by some digits and 2 commas, and always followed by one (or more?) comma(s?)

The FOR command, and some variable modifiers, might be useful, once the above question is answered.


Yes, it can be done with the FOR command.
However, parsing strings is much easier in a programming language that does that sort of thing. It can be do in C, C++ Pascal, Java, Pearl, Ruby. And more.

There is an old program called QBASIC that is on the Windows 98 disc, I believe.
You could run it inside a batch file and it would read the file and spit out the names found between the lat "\" and the first ", " perhaps with just ten lines of code more or less.

But if you really want to us the FOR, go ahead. It gives me a headace.Quote

with just ten lines of code more or less.

How about one?

command does "that sort of thing" very well. It was designed for it. It LOVES chewing up csv files.

Took me 7 minutes. And 5 of those I was MAKING coffee.

Presuming the answer to my question above is "yes"...

Code: [Select]@echo off
set inputfile=input.txt
set outputfile=output.txt
if exist "%outputfile%" del "%outputfile%"
for /f "tokens=1-2* delims=," %%A in ( ' type "%inputfile%" ' ) do echo %%~nxB>>"%outputfile%"

input.txt:

Code: [Select]00000,,\6442\Vol002\001\00000.tif,Y,,,0
000001,,\6442\Vol003\001\002\000001.tif,Y,,,0
000002,,\6442\Vol003\001\000002.TIF,Y,,,0
000003,,\6442\Vol003\005\004\000003.TIF,,,,
output.txt:

Code: [Select]00000.tif
000001.tif
000002.TIF
000003.TIF


AAwwkk !
I have a headache!
It took your 7 Mins.

It will take me 7 days to try and understand that!
for /f

TREAT the dataset (what is in the brackets) as a series of one or more lines

"tokens=1-2* delims=,"

Treat each such line as being split (by commas) into at least 2 tokens (chunks)

%%A

Assign the first chunk of each line to the explicit loop variable %%A. The second chunk will therefore be the implicit loop variable %%B. The asterisk in the tokens/delims block means that all of the rest of the line (if there is any) will be the implicit loop variable %%C.

in ( ' type "%inputfile%" ' )

The dataset is the output of 'type inputfile'.

do echo %%~nxB

Take the second chunk of the line, (a path and filename), and extract just the file name and extension, and echo it...

>>"%outputfile%"

... to the output file

and repeat until no more lines left.
Quote from: Geek-9pm on February 02, 2009, 03:27:52 PM


If it's any help, that's what Perl does to me.
Dias DE verano,

Yes you are right on your first assumption. I will put it to the test on a very large file that I have. I very much appreciate your speedy reply to my post today.

thatguy.It works great. Sorry for the confusion. Thanks so much!
3099.

Solve : running programs form batch files?

Answer»

Yep. You need to USE quotes around the filename. UNLESS you already did...

"c:\program files\easy AVI DIVX xvid to dvd burner\easy avi divx xvid to dvd burner.exe" /?yeah i've tried that but got nothing.

I also tried doing it from a batch file i.e,
"c:\program files\easy avi divx xvid to dvd burner\easy avi divx xvid to dvd burner.exe" /? >path\avicommands.txt

but all i got was an empty txt document.Maybe it just doesn't have any batch commands?If you have a path like that and you cant use quotes, you have to do something like:
C:\Program~1\..... (i dont know the rest)
You cant have spaces in other words...with quotes it opens the program but gives nothing as a listed commands.

I would have thought that since there is a list of start (/?) commands there would have been a list of parameters for the program it's self.

maybe i'm just flogging a DEAD horse.


i'm gonna have to wait for the company that wrote the program to get back to me. They probley already have but i'm not working till wednesday and the webmail server at the office seems to be down at the mo.

I'll let you all know what happens, but thanks very much for the time and effort that you've given me.

thanks again.

blastman

3100.

Solve : Batch file that creates a schedule job?

Answer»

I created a batch file that deletes the CONTENTS of a folder but I need a batch file that creates a schedule job for this to run once a day without the user on the pc having to do anything. Can anyone help me. I looked at the forum and saw the AT command but I don't this this will help me because I can't have the user do anything.

Thanks in advance.What version of Windows? If 2000 / XP / 2003 / VISTA, you can look at the command
SCHTASKSQuote

SCHTASKS /parameter [arguments]

Description:
Enables an administrator to create, delete, query, change, run and
end scheduled tasks on a local or remote system. Replaces AT.exe.

Parameter List:
/Create Creates a new scheduled task.

/Delete Deletes the scheduled task(s).

/Query Displays all scheduled tasks.

/Change Changes the properties of scheduled task.

/Run Runs the scheduled task IMMEDIATELY.

/End Stops the currently running scheduled task.

/? Displays this help/usage.

Examples:
SCHTASKS
SCHTASKS /?
SCHTASKS /Run /?
SCHTASKS /End /?
SCHTASKS /Create /?
SCHTASKS /Delete /?
SCHTASKS /Query /?
SCHTASKS /Change /?
This looks really good and probably just what I need.

Just for an FYI
I work in the IT dept at a home OFFICE and we have computers at different sites and they are locked down with deep freeze and people in these offices cannot delete files and our help desk guy was having to log in and delete files for people and this was taking a lot of time. I suggested that we write something that would delete the contents of a folder automatically and he thought it was a great idea but told me to do it. I am NOT a programmer but I have been trying to play with this. I was able to write the batch to delete the folder contents but now he wants me to make a batch that creates the folder, then creates the schedule job. I didn't know what I was getting myself into when I made the sugestion.

Thanks for the help but I will probably need more.