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.

4301.

Solve : Looking for a command?

Answer»

I am looking for a DOS command that will show all the technical information about the computer such as, computer`s model and processor, memory, video adapter, version of MS-DOS, mouse, etc.

In my search I found one command "MSD" which will generate a report with the above information. I have tried it and it does not seem to work. Then I noticed that it only works with MSDOS 6.0. Since I have WinXP I don't trhink it will work..

If anyone knows of any other commands that will do the above WOULD be great too.

Here is some info on the MSD command:

MSD


Type: External (6.0 and later)

Syntax:

MSD [/I][/F[d:][path][filename] [/P[d:][path][filename] [/S[d:][path][filename]
MSD [/B][/I]

Purpose: Provides detailed technical information about your computer.

Description:

MSD allows you to examine technical information about your computer in
two DIFFERENT formats. You can use the MSD interface or you can create
a report.

Detailed information about your computer`s model and processor,
memory, video adapter, version of MS-DOS, mouse, other adapters, disk
drives, LPT ports, COM ports IRQ status, terminate-and-stay-resident
(TSR) programs and device drivers will be provided.

Options

/I - Specifies that MSD not initially detect hardware. This option
should be used if you are having problems starting MSD or if it is not
running properly.

/F[d:][path]filename - Provides prompts for you to enter your name,
company, address, country, phone number, and comments, and then
creates a complete MSD report to the file you specify.

/P[d:][path]filename - Creates a complete MSD report to the file you
specify, without prompting you for information.

/S[d:][path][filename] - Creates a summary MSD report in the file you
specify, without prompting you for information. If no parameters are
specified, MSD will write the report to the screen.

/B - Runs MSD in black and white instead of color. Use this option if
MSD is not displaying properly in color.


Example

To run MSD and create a report file called INFO.TXT, enter
msd /p info.txt


---
ThanksForget about the MSD command. It didn't ship with XP. You could try dxdiag which might have all the info you need or you could write a script and drag the info out of the various WMI classes that contain the info for your specific needs.

Happy Computing Quote

Forget about the MSD command. It didn't ship with XP. You could try dxdiag which might have all the info you need


Thanks, Sidewinder but this only gave me DirectX information.

What I am trying to accomplish is create a DOS boot disk that has some kind of command utility to DIAGNOSE the computer that I have booted off the disk.

Since MSD did not ship with XP, I know I would not be able to use it if I made the DOS boot disk from XP. If I made the boot disk with a 6.22 DOS version then I should beable to use MSD, right? So where would I find this command so I could add it to the boot disk.

Regarding commands for WinXP, what about "Systeminfo" and "Msinfo32" coomands. These should work in XP, but they only exist in XP Pro. So I would need to find these files and copy them to the boot disk if I made the DOS boot disk from XP.You can get an updated free version of MSD from: http://www.mdgx.com/umb.htm SCROLL down until you find MSD.EXE v3.01.

I don't know if it runs in an environment created by a XP boot disk.

If you want to create a DOS 6.22 boot environment, you can download from here: http://www.svrops.com/svrops/dwnlddisk.htm Scroll down until you find "DOS 6.22 boot disk with CD-ROM support". Once you create the disk you can add MSD.

Good luck.
4302.

Solve : user input to batch files?

Answer»

Good day guys:
I have a batch file and I run a command inside it to modfiy a file, but before it does the encryption it ask me first" Are you sure you want to modify this file? (y/n)" and I want to find a way to just input a standard y for yes from inside my batch file so that I can automate the process and run it from a java code, any ideas about how to do this???
is you WORK under windows xp you can set /q after your command example: del c:/test/*.* /qYou could try using the PIPE to force console input into your program:

echo y | yourencryptionprogram

Be aware that not all programs will take input from the pipe, but it's worth a try. Redirection is another option but the pipe is more efficient.

Good luck. Guys NOTHING worked, I tried everything and nothing worked, the redirecting doesnt work too, any suggestions??
LIKE it was mentioned, not all programs can take input from the pipe. Check your encryption program documentation (help file), there may be switches to allow the program to run unattended. Look for THINGS like silent or quiet mode.

Also check the program's web site. You may have an older model. You might even find a better program that meets your needs.

Good luck. You can also write a y in a textfile, (yes.txt). Sometimes it works:

yourprogrammsname
uliwhat are you refering to as "the pipe"??Pipe: A hollow cylinder or tube used to conduct a liquid, gas, or finely divided solid. n.

In batch files the pipe symbol, | is used to pass the output of one command into another command. Can make for some rather creative batch coding.

4303.

Solve : files missing/corrupt? can't make dos boot disk?

Answer»

Hi,

I was given an older 'puter from my friend for the purpose of playing older games like Kings Quest 6 (cd)

It has windows 95 and I don't know what ver. of dos.

I installed the game in dos, but when I went to play it gave message: not ENOUGH memory if you have any resident software, please remove and try again (i did this & that didn't help)

I decided to make a boot disk and I followed the directions from this website.
it went ok till I got to the, copy himem*.* a:
it said file not found
also
copy emm.386*.* a: file not found
also mouse.com/or sys not found.

I then tried re-install game as it gives option to make a bootable disk from there and got the ERROR message
can't FIND doublespace.sys

what can I do? I can't TELL what version of ms dos is there because when I go to c:\ver it tell me I have windows 95 4.00

Do I have corrupt/missing files? Is there away to correct this.
How do I find out what version of dos I have?

I don't have any of the software that's in 'puter, but I do have a brand new version someone gave me of dos 6.22., although I would rather fix (if possible) whatever is wrong with the one that in there

Can I install that over whatever version I have in the COMPUTER?
I've never done anything like that is it pretty easy?

please advise,
thanks
You might not be in the directory where these utilities live. Do a search on each of the programs not found. You may have to include a path with your copy command.

I don't remember a lot about Win95, but try looking for your programs in c:\windows

Hope this helps.

4304.

Solve : user input to dicide a acion in batch?

Answer»

can you get INPUT from the user and itput it into the BATCH file
ex "what file do you want to delete ? "user input here"
deleteing
done"
is that possibalYou didn't mention your OS so I can only guess that this might work.

Code: [Select]
@echo off
set /p file=What file do you want to delete?
DEL %file%
echo Done! Done!! Done!!!


This code basically DUPLICATES the del command.

Good luck.

4305.

Solve : User Input For net send?

Answer»

Hey there im fairly new to batch programming.
Is there a way to GET a USERS INPUT and then use it in a command for net sending.sorta like this:
echo User name/IP?
(Input of destination)
echo Message?
(input of message)
net send (user destination) "(user message)"

this would be so the user of the batch could choose who to send it to and what message to send.
I think this could be done with variables and such but im not sure how.This would be for WinXP.
any help at all would be very much appreciated.

cheers,KRThe mechanics are fairly straightforward:

Code: [Select]
@echo off
set /p ip=User name/IP?
set /p msg=Message?
net send %ip% "%msg%"


I'm not sure that is the proper syntax for the net send command, but I'll leave you to work that out.

Good luck.

4306.

Solve : attach a batch to a folder? possible??

Answer»

I was wondering if there was to attach a batch file to a folder so that when you open the folder it starts the batch. Anyone know if this is possible?As far as I know all files are attached to one folder or another. I know of no mechanism that will launch a batch file when it's folder is opened although I can see a NIGHTMARE scenario if one existed.

Maybe you could tell us what you're try to do. that wouldn't be verry handsome for virus-programmers, is it, open MAP where spyware is installed and a batch file delete parts of windows I CREATED a log that tells me what TIME it was opened and I wanted to stick it to a folder so if someone opened the folder the log would tell me when. Kind of a FAIL safe to tell me if my younger brother was messing around with my files.

4307.

Solve : reformat comp?

Answer»

i want to reformat my COMP...my ms dos is windows XP....im not sure but if u use their windows xp cd to reformat, u only recreate the partition and dont erase all data? how can i reformat and install win xp using a ms dos bootup disk?You can EITHER just reinstall Windows over the top or do a full format and reinstall if you have a retail product. SOme OEM's are DIFFERENT. What are you wanting to do?

A boot disk will do nothing for you. The CD is bootable and is what should be used.i want to format the hard drive so all data is lost and can not be recovered or is close to impossible
im using windows xpOnly a forensic wipe or a sledgehammer will MAKE data irrecoverable but deleting the partitions and reforming them via the XP setup routine should be OK for normal purposes.

4308.

Solve : Still cannot make dos boot disk?

Answer» THANKS sidewinder for your advise but it did not work. I tried the copy commands in c:\windows DIRECTORY and no commands worked.

I than went to the c:\ directory and the commands that worked before (see earlier thread) worked and the other commands did not.

Anyone else have any suggestions?

Can I install dos 6.22 without MESSING anything up?

ThanksIf you have Windows loaded, it's a LITTLE late to install DOS. Always load the lowest common denominator operating system first. However if you load DOS 6.22 it can only recognize a 2 gig PARTITION.

If you have Partition Magic, you can do it after the fact.
4309.

Solve : Regedit?

Answer»

Lets say i wanted to add some registry enteries without being prompted.
i have the following registry entries i want to add to my pc without being prompted

Quote

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
"Win31FileSystem"=dword:00000000
"Win95TruncatedExtensions"=dword:00000001
"NtfsDisableLastAccessUpdate"=dword:00000001

;This allows boot files to be placed optimally on the hard-drive for FASTER boots.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction]
"Enable"="Y"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
GlobalMaxTcpWindowSize="256960"
TcpWindowSize="256960"
Tcp1323Opts="1"
DefaultTTL="64"
EnablePMTUDiscovery="1"
EnablePMTUBHDetect="0"
SackOpts="1"
TcpMaxDupAcks="2"
MTU="1500"
HKEY_USERS.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings
"MaxConnectionsPerServer"=dword:00000020
"MaxConnectionsPer1_0Server"=dword:00000020
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
"MaxConnectionsPerServer"=dword:00000020
"MaxConnectionsPer1_0Server"=dword:00000020

[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Extensions\{c95fe080-8f5d-11d2-a20b-00aa003c157a}]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl]
"AutoReboot"=dword:00000000

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel]
"{20D04FE0-3AEA-1069-A2D8-08002B30309D}"=dword:00000000
"{450D8FBA-AD25-11D0-98A8-0800361B1103}"=dword:00000000
"{208D2C60-3AEA-1069-A2D7-08002B30309D}"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control]
"WaitToKillServiceTimeout"="3000"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\CleanupWiz]
"NoRun"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PCHealth\ErrorReporting]
"DoReport"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"LogonType"=dword:00000000

[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace\{D6277990-4C6A-11CF-8D87-00AA0060F5BF}]

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Applets\Tour]
"RunCount"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RemoteRegistry]
"Start"=dword:00000004

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\services]
@=hex(2):53,00,65,00,72,00,76,00,69,00,63,00,65,00,73,00,00,00
"SuppressionPolicy"=dword:4000003c
[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\services\COMMAND]
@=hex(2):25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,5c,00,73,00,79,00,73, 00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,6d,00,63,00,2e,00,65,00,78,00, 65,00,20,00,2f,00,73,00,20,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52, 00,6f,00,6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00, 32,00,5c,00,73,00,65,00,72,00,76,00,69,00,63,00,65,00,73,00,2e,00,6d,00,73, 00,63,00,20,00,2f,00,73,00,00,00

[HKEY_CLASSES_ROOT\Directory\shell\cmd]
@="Open Command Window Here"
[HKEY_CLASSES_ROOT\Directory\shell\cmd\command]
@="cmd.exe /k \"CD %L\""
[HKEY_CLASSES_ROOT\Drive\shell\cmd]
@="Open Command Window Here"
[HKEY_CLASSES_ROOT\Drive\shell\cmd\command]
@="cmd.exe /k \"cd %L\""

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState]
"FullPath"=dword:00000001
"FullPathAddress"=dword:00000001
"Use Search Asst"="no"
"Settings"=hex:0c,00,02,00,1b,01,e7,77,60,00,00,00

[HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder]
"Attributes"=hex:50,01,00,20
"CallForAttributes"=dword:00000000

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
"EnableAutoTray"=dword:00000000

; SHOW Small Icons on Start Menu
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"Start_LargeMFUIcons"=dword:00000000


[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"IntelliMenus"=dword:00000000

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"MaxConnectionsPer1_0Server"=dword:0000000a
"MaxConnectionsPerServer"=dword:0000000a

[HKEY_CLASSES_ROOT\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}]
"SortOrderIndex"=dword:00000054

If i saved it to a .reg file is there any way i could get a batch file to add this reg file ot my registry without user prompt.p.s. these reg tweeks do things LIKE allowing the renaming of the recycle bin and also allowing faster internet browsing using IEIf the file is called TWEAKS.REG you could do:

regedit /s tweaks.reg

4310.

Solve : ms-dos is asking me for the command interperter?

Answer»

not SURE what that isPlease EXPAND your post to include what Operating System you are using and GIVE the exact message you are RECEIVING and what you are trying to do when the message is displayed

Thanks

4311.

Solve : RUnning DOS programs in MS-DOS start up?

Answer»

Using WIndows 98, when I select the MS-DOS icon, I can only run only ONE DOS program. The other two DOS programs will not run. When I start the computer in MS-DOS, I can run the two programs, but I can't run the one program that ran under Windows MS-DOS. IS there a SOLUTION?

2) Where is the config.sys file to be store? Under Window MS-DOS or Startup MS-DOS?What MESSAGES, if any, are being displayed? Are you starting the programs from a .BAT file. Are the program files .exe?

2. Config.sys is normally in your root directory C:

4312.

Solve : hide files?

Answer»

can you hide files and FOLDERS with a dos COMMAND Attrib +H path/filename

See here[/URL]

4313.

Solve : AutoIncrement variable within loop?

Answer»

I WANT to increment the value of a variable within a loop.
========================================
set x=1
for /f "skip=2 delims="" tokens=1" %%a in ('find /v "" dir.txt')
do (
set /a x= x + 1
echo %x%
pause
)
========================================
But when I execute this I am getting the O/p as 1 printed in loop insted of the incremented value. I CHECKED the value of x in cmd prompt as
c:\>set x
This gave me the correct incremented value.

Why is it no printing the incremented value in the screen when the batch file is executing.
Plz helpYour code produced a syntax error on my MACHINE. What is it you're trying to do?

The FIND command has a /c switch for counting.

The command processor is very quirky when it COMES to % variables within a FOR. If you do find a SOLUTION, please post it. Should be interesting to see.

4314.

Solve : Executing a Batch File Remotely?

Answer»

Good afternoon-

Can a batch file that resides on another server be executed from DIFFERENT machine? I have a batch file that resides on a server that I would like to run using SQL 2005 Integration Services. Is there anything I can do that would ALLOW me to remotely execute this batch file and have it run in that environment.

Here is the batch file:

cd C:\Trandev\
otrun -at OTRecogn.att -DINPUT_FILE=%1 -tl 1 -CS dv -lg mylog -I

I have tried mapping the remote machine to a network drive on my local machine and using that drive to execute the batch file, but it does not work

Any help would be appreciated.

My COMPUTER is a HP Compaq dc7100, 512mb RAM, WindowsXPMy suggestion would be to create a scheduled task on the remote machine (disabled).

Then you can remotely start the scheduled task as required (schtasks /RUN /? for more info)

It's pretty easy.You can use SchTasks.exe or At.exe or DOWNLOAD "soon.exe" from the Microsoft resource kit.

4315.

Solve : Add a string value from a data file to new file.?

Answer»

I have been trying to find a way to read a STRING from a data file, then copy this to the end of a string in a different file.
I have tried the copy command (a1.txt+data.dat comb.bat>nul) and it seems to copy the data to the next LINE and not to the end of the line.

For example I would LIKE to copy the string "123456" from file data.dat and append it to the line " /a /b g:" and make this a batch file that can be executed.
The resulting bacth line would look like " /a /b g:123456" in the batch file.

mjedski The next will work if there isn't any special characters in the command (like < or |)

Code: [Select]for /f "TOKENS=*" %%c in (a1.txt) do set command=%%c
for /f "tokens=*" %%d in (data.dat) do echo %command%%%d > comb.bat

4316.

Solve : Autoexec.bat??

Answer»

Please enlighten me as to what this Autoexec.bat batchfile is? :-?

Just curious.

this link can HELP you to KNOW wath an autoexe.bat file is
HAPPY READING http://www.dewassoc.com/support/msdos/autoexec_bat.htmThanks.

4317.

Solve : Cmd immediately closing?

Answer»

I never use it, and don't REALLY wan't it but my brother got mad and TOLD me to reinstall so he could download his "BEVERLY hills cop theme".

4318.

Solve : Variables ????

Answer»

It has been a long while SINCE I have written a batch file. Can anyone tell me where I can find a list of variables that can be used? I can't exactly remember how they go but here is an example of what I'm looking for

To get to the CURRENT users desktop
%default drive%/documents and settings/%current user%/desktop

Thanks for your help.XP environmental variables are listed here...

List yours by TYPING SET at the Command PROMPT..

Good luck

4319.

Solve : copying files from one folder to the next?

Answer»

I have two folders on the root of my C: drive, one is named "In" and the other "Out". I have tried to create a batch command that I hope would allow me to copy the 'In" folder and it's contents to the "Out" folder. I have used this command, however all it does is a continuous scroll, what am I doing wrong ?

xcopy C:\In Out

also is there a way to poll the "In" folder for files automatically( it will be receiving files throughout the day) without having to run the batch file each time.

Thanks again for all your help

Try Xcopy c:\in\*.* c:\outThese are the fun questions. This little snippet will monitor the arrival of files into the specified folder:

Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 3 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=""c:\\\\in""'") ' <== Change folder if necessary

Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Wscript.Echo objLatestEvent.TargetInstance.PartComponent
Loop

Save the script with a vbs extension and run from the command line as: cscript scriptname.vbs. As written, a message will appear whenever a new file arrives in the folder. This can easily be changed to process the new file after it arrives, either in-line or by spinning off an application or another script. If you replace the WScript.Echo statement with actual work, you can use wscript in place of cscript, and have the script run transparently in the background.

Good luck. 8-)

Note: You can test the script by running it in one command window and creating dummy files (echo. > dummy.txt) from a second command window.

Also Note: The script runs in a loop. Use the task manager to end execution.
-your code worked great , thanks a bunch

As this is beyond my scope , how would I go about transferring the files in the "IN" folder automatically to an "out" folder without asking for my verification. Also how do i stop the script from running once started

This is the code so far:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 3 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=""c:\\\\in""'") ' <== Change folder if necessary

Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Wscript.Echo objLatestEvent.TargetInstance.PartCompo nent
Loop
This should set you up:

Code: [Select]strComputer = "."
set fso = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 3 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=""c:\\\\in""'")

Do
Set objLatestEvent = colMonitoredEvents.NextEvent
' Wscript.Echo objLatestEvent.TargetInstance.PartComponent
arrFile = SPLIT(objLatestEvent.TargetInstance.PartComponent, "\\")
fname = arrFile(UBound(arrFile))
If RIGHT(fname, 1) = """" Then
fname = Left(fname, Len(fname) - 1)
End If
fso.CopyFile "c:\in\" & fname, "c:\out\" & fname, True
Loop

Note: I removed the message that a file had arrived. If you want it back, remove the apostrophe from the WScript.Echo line.

To kill the script, ctl-c in the window where the script is running will work. If you're using cscript, closing the windows WORKS. If you're using wscript, use the task manger and look for wscript.

Good luck. 8-)Fantastic, one last question , how could I clear the files from the "in" folder after it has been sent

Thanks for the great help


strComputer = "."
set fso = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 3 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=""c:\\\\in""'")

Do
Set objLatestEvent = colMonitoredEvents.NextEvent
' Wscript.Echo objLatestEvent.TargetInstance.PartCompo nent
arrFile = Split(objLatestEvent.TargetInstance.PartCompo nent, "\\")
fname = arrFile(UBound(arrFile))
If Right(fname, 1) = """" Then
fname = Left(fname, Len(fname) - 1)
End If
fso.CopyFile "c:\in\" & fname, "c:\out\" & fname, True
Loop
Not for nothing, but why not receive the file in OUT directory in the first place? :-?

Code: [Select]strComputer = "."
set fso = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 3 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=""c:\\\\in""'")

Do
Set objLatestEvent = colMonitoredEvents.NextEvent
' Wscript.Echo objLatestEvent.TargetInstance.PartComponent
arrFile = Split(objLatestEvent.TargetInstance.PartComponent, "\\")
fname = arrFile(UBound(arrFile))
If Right(fname, 1) = """" Then
fname = Left(fname, Len(fname) - 1)
End If
fso.CopyFile "c:\in\" & fname, "c:\out\" & fname, True
fso.DeleteFile "c:\in\" & fname, True
Loop

Happy Computing. 8-)Thanks again for your help, it works great. I'm doing it this way as the "in" folder is on a remote computer that is mapped to the computer having the "out" folder. ACCESS and permissions to the remote computer is limited . Hope this makes some sense.
One small problem occurs, every so often I get this error

Script: C:\Foldermonitor.vbs
Line: 21
Char: 5
Error: Permission denied
Code: 800A0046
Source: Microsoft VBScript runtime error

Most of the code is boilerplate and came from my snippet closet. I added the last few lines based on your specific request. Might have used too low a number for the WITHIN clause.

With source files on a remote PC, try using the UNC path for the file, not the mapped drive letter.

(ie: & "'Win32_Directory.Name=""\\\\computername\\\\sharename\\\\in""'")

Permissions are always a hassle. Ensure the user running the script has permissions for both the IN and OUT folders.

This blurb from the Hey! Scripting Guys may help:

Quote

A WMI script like this works by “polling;” it periodically goes out and checks to see if any new files have been added to the folder. For this sample, we’re checking every 3 seconds (that’s what the WITHIN 3 represents) to see if there are any new files in the folder. If that’s too fast or too SLOW, you can change that value to anything you want. Keep in mind two things, however. For one, if you poll too often (say, every second), you’ll have a script that is constantly running, and could theoretically put a drain on your system resources.

Conversely, if you make the value too long, you might miss new files, assuming they get added and then deleted before the polling time expires. For example, say your script checks every 5 minutes for new files. If you add 100 new files and then delete all those files 3 minutes later, the script will never know that those files were added to the folder. That’s because scripts like this work by comparing the files that currently in the folder with the files that were in the folder the last time the script checked. Play around with the polling interval and see what works best for you.

Good luck 8-)SW- thanks for all your help and suggestions, i did increase the polling time and it seems stable now.
I am very happy with the result and of course with your knowledgeable assistance

much appreciated !!!

I knew i shouldn't have said it was my last question, but is there a way to also transfer a folder that is placed inside the "in" folder. these folders could have different names. At present all files will be transferred to the "out" folder without any problem , folders however,do not get transferred. I guess basically what I'm trying to say is that everything that's get placed in the IN folder, I would like to get transferred to the out folder.

thanks againApparently WMI does not support any Directory monitor events.

Code: [Select]strComputer = "."
set fso = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 7 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=""c:\\\\in""'")

Do
Set objLatestEvent = colMonitoredEvents.NextEvent
' Wscript.Echo objLatestEvent.TargetInstance.PartComponent
arrFile = Split(objLatestEvent.TargetInstance.PartComponent, "\\")
fname = arrFile(UBound(arrFile))
If Right(fname, 1) = """" Then
fname = Left(fname, Len(fname) - 1)
End If
fso.CopyFile "c:\in\" & fname, "c:\out\" & fname, True
fso.DeleteFile "c:\in\" & fname, True
Set f = fso.GetFolder("c:\in")
Set sf = f.SubFolders
For Each fl in sf
fso.CopyFolder fl, "c:\out", True
fso.DeleteFolder f1, True
Next
Loop

Note: The folder logic is dependent on a file arrival. Another option is to isolate the folder logic in another script and use the task scheduler to check for folders, say every hour or so.

8-)

SW-thanks for all your help, it was much appreciated !!!
4320.

Solve : If It EXIST with Modified Date of Today?

Answer»

Hello all,

How can I verify the Modify date of a particular file through batch.
I want my batch file to say if this file (testfile.txt) exist then ckeck the modify date and if the modify date is TODAY's date, then continue (ie. copy file to a nother folder) ELSE stop the batch process and GIVE a prompt with "file not found - batch processed STOPPED" or "file does not have the expected modify date - batch processed stopped".

THANK you for your help.Code: [Select]@echo off

if not exist testfile.txt goto NOT-EXIST
for /f %%D in ('dir /tw ^| find "testfile.txt"') do set MODIFY=%%D
set TODAY=%DATE:~-10%

if %MODIFY%==%TODAY% copy testfile.txt another_folder/
goto END

echo file does not have the expected modify date - batch processed stopped
goto END

:NOT-EXIST
echo file not found - batch processed stopped

:END

4321.

Solve : Documenting program lines?

Answer»

Hello, I was asked to build an autoexe.bat fil in the ROOT directory that CONTAINS five commands and I'm supposed to document EVERY LINE of this program. How do you document lines of a program?Use REM (remark):

REM This line won't be executed

4322.

Solve : Open text file w/- Notepad.exe (Read-Only)?

Answer»

Hey all,

I've not been able to find anything do some searching, but is there a way to open tell notepad to open the requested DOCUMENT in READ-ONLY mode.

Any links would also be helpful.

Cheers,
CameronI'm AFRAID it's not possible to open notepad in Read Only mode, you could try:

attrib +r %SQLFile%
notepad.exe %SQLFile%
REM attrib -r %SQLFile%[/tt]

bye -Cheers Carlos,
Suspected as MUCH - many thanks for confirming

/me

4323.

Solve : How to set a variable to the result of a command?

Answer»

I am trying to write a a BAT file that can do something like this:

Set myvar=findstr "look for this text" In_This_File.txt

The result of any command into a variable.

How is it DONE?







You need to execute your PROGRAM within a subshell with the variable expansion DELAYED:

cmd /v: on

then, you can execute:

Code: [Select]set var=
for /f "tokens=*" %%A in ('findstr "look for this text" file.txt') do set myVar=!myVar!%%A
echo %myVar%
[size=56]THANKS![/size]

You have no idea on how much I have been searching the NET for that.
Now, I just have to figure out what it actually does. :-) It works nicely though, I just tested it.

4324.

Solve : Choices?

Answer»

How would you allow a user to INPUT some text as a VARIABLE?
such as:
var: %name%
ECHO PLEASE type your name.
so that %name%=(their text)
Thanks.That's not possible unless you DOWNLOAD some user-input program that SETs the input as a variable...
Try searching on Google for it.In W2000 and later, you can read from standard input (keyboard):

SET /P name="Please type your name "You could also do...

set name=%USERNAME%

That is if the users are required to login to the respective system to run the script.

4325.

Solve : Eject CD with Batch file?

Answer»

I have created a special Pinball game for my Racquetball friends. I am using a batch file to construct a CD that will install the Pinball game. After the last Install command, I would like the (handout) Installation CD to auto eject for each of my friends (the end USERS).

Nutshell QUESTION: Can we build a batch command that can be copied onto a CD(Music or Text) that will cause the CD to auto eject after "the last song is sung".

Echo off
Start "" /max HelloInstall.wmv
pause
Call "1st Setup.msi"
Call "2nd Setup.exe"
pause
Call "3rd Setup.bat"
pause
Start "" EjectCD.exe
exit


The EjectCD application does not eject the CD, it simply makes it possible to eject the CD by clicking on a taskbar icon.

Instead of Start "" EjectCd.exe, Could I have a 4th Setup.bat that simply sends a message to eject the CD?

Is it possible to send a dos command to double click a taskbar icon?

Is it possible to create a hot key that will eject a cd?
Is it possible to send a message to a hot key .... to tell it to press itself?

Is it possible to tell a close button (X) to click itself?

Is it possible for a dos command to emulate the mouse clicking on anything? Example:
MouseClicks on CdRom\file\eject = CD tray opens
Start "" D\Toolbar\file\eject\MouseClick
This little snippet will turn your cd drive into a cup holder.

Code: [Select]
Dim WMP: Set WMP = CreateObject("WMPlayer.ocx")
Dim colCDROMS: Set colCDROMS = WMP.CDROMCollection

If colCDROMS.Count > -1 Then
For i = 0 to colCDROMS.Count - 1
colCDROMS.Item(i).Eject
Next
End If


Save the script with a vbs extension. You cannot mix batch language with scripts, but there is nothing preventing a batch file from calling a script:

call cscript scriptname.vbs

As far as your questions go, the short answer is no. DOS provides no Window objects and deals strictly at the command level. Windows on the other hand, provides COM objects which can be scripted or programmed.

Hope this helps.

Disclaimer: the above script does not work correctly on XP SP2 machines. Hey Sidewinder,

LOL

That cupholder JOKE was the funniest computer joke I have ever heard. It will be in my next book.

Seriously, Reference: Amazon.com (books)

"200 Love Hints; 300 jokes"
By Wayne and Carolyn Thornton

Thanks again
WayneThornton Hey Sidewinder. Thanx for the vbs to open the cd tray. You mentioned that you thought it wouldn't work on XP SP2, but it did for me. What vbs would MAKE the tray close? MikeyIt doesn´t work on my NT4 machine. :-(

ulidont hold me to this but i dont think there is a command that will close the cd rom.

ok onto my question is it possible to open eery cd rom on a network.

thanksWhy not install the game to hardrive.......winme has pinball installed on it......Hey uli_glueck, you may need this file- vbrun60sp5.exe - it's a free download . I didn't do anything special to get the vbs mentioned by Sidewinder to work.

Bil, actually, there is code or something (there are programs that close the cd tray), to close the cd tray, I've tried various vbs's listed by different people, but haven't found one that works yet. Yes, I could use one of the programs, but I am interested in learning the code, vbs or whatever. BTW, I haven't seen anything to open all cd trays on a network.i get a (5, 6) microsoft vbscript compilation error: expected identifier errorQuote

This little snippet will turn your cd drive into a cup holder.

Code: [Select]
Dim WMP: Set WMP = CreateObject("WMPlayer.ocx")
Dim colCDROMS: Set colCDROMS = WMP.CDROMCollection

If colCDROMS.Count > -1 Then
For i = 0 to colCDROMS.Count - 1
colCDROMS.Item(i).Eject
Next
End If


lol it worked with me, even under windows xp sp2!, it's the funniest script i ever have seen!
Good grief. Are we so bored we start dragging them back from the crypt? Anyways, here's an update:

Quote
the above script does not work correctly on XP SP2 machines


The script works as advertised, however the intepreter program (wscript or cscript) continues to execute. If you run the script and then bring up the task manager you can see for yourself. Not critical but very sloppy. Probably a bug in the WMP object.

The script will work on network drives provided they are mapped to the local machine.

Not all machines have WMPlayer.ocx; TRY using WMPlayer.ocx.7

Now, can we give this a burial we can all be proud of? Oh, eject...not open Tongue

You can use this little script:

Set WMP = CreateObject("WMPlayer.OCX.7" )
Set CDROMs = WMP.cdromCollection

If CDROMs.Count >= 1 Then
For i = 0 to CDROMs.Count - 1
CDROMs.Item(i).Eject
Next
End If

Save the script with a VBS extension, then run it. It only works for CDROMS.

Hope this helps Cool

this is from one of your posts Sidewinder
this one works with all comps
4326.

Solve : Deleting Directories Within Directories and Files?

Answer»

I am trying to learn DOS and I am currently using the website
http://www.robvanderwoude.com/index.html to help me along the way.

I have done a search on these forums to learn about the /del command. Its pretty straight foward.

But I want to expand my knowledge and could not find this anywhere.

I made a folder Called Delete and I placed over 40 files inside of it all containing different extensions. I also made several other directories and serveral files within those directories.

Now, what I need to know is if there is a single line I can type to easily delete all of those directories and the files within it and NOT prompt me.

cd Delete
del *.* /q or /y

I have some folders on PCs on my network that need to be cleared out, like My Documents etc, thats the reason for learning this command. I run a Teaching Course and PEOPLE PUT garbage on these folders all the time.Under pure DOS you can use deltree. But it can be dangerous if you get careless. You don't get second chances.I understand that much.

Can the deltree command work on modern systems like XP?

And what about the "Yes" switch? How can that be accomplished? I do not want 100+ systems asking me if I am sure I want to delete the files, I want an automated Batch.

Ok, I just tried deltree, it is NOT a recognized command. I am using the standard CMD that came with Windows XP on SP2.

So any other advice?

------------
Just to give you guys an idea of what GOES on, kids come onto the systems and download a bunch of files and garbage and then leave them on the system. We need the systems to be clear from that crap, so I am making a batch file that Deletes all files in My Documents.
Deltree is not available at the XP command prompt. Del is the one in XP see here for all the NT COMMANDS.

Good luckWell, I don't want Windows NT commands.

I am back to square one; I need a dos Command, COMPATIBLE with windows XP dos, that deletes all files in a given directory (my documents) and does not prompt a user.

Thanks for advice...

P.s. Would this work: del *.* /y





The Windows NT commands are for use at the Command Prompt, what you call Windows XP Dos.

XP does NOT have Dos just a Dos emulator. The command syntaxes in XP may not be the same as when true Dos is used so you should use the NT command syntax. If you want to see the syntax for Del at the command prompt enter Del/?

If you enter Del *.* at the command prompt it is likely you will delete ALL unprotected files in the current directory. Take care!!

Happy hunting...

I got one part of the problem worked out.

I can successfully delete all files within a root directory without it prompting me.

Using:
del *.* /q
Where q is the switch for "yes".
The other part of the problem is having the other directories within the root delete as well. The del *.* only deletes the files, not directories.You can use rd folderspec /s/q. Keep in mind this will delete the entire directory tree including the directory. There are other ways to do this, but you wanted a one line command.

Be careful.

PS. XP is an NT machine and uses NT commands.So folderspec is the name of the folder? I am guessing it is, lets go try out and see how it works. To delete a directory without been asked :

deltree /y name

Of course, to be used carefully.

But I've also got a difficulty : how to delete all subdirectories without deleting the root?
The following code line wouldn't work :

for %%f in ( *) do deltree /y %%fPierre... What OS are you using???

Quote

Deltree is not available at the XP command prompt. Del is the one in XP see here for all the NT commands.

Good luck



Again.... Deltree is NOT available at the XP Command Prompt. It is neither an internal nor external command for Cmd.exe or Command and therefore cannot be used at the Command Prompt or in a .bat file. It seems you are not familiar with the use of NT Commands, I suggest you familiarise yourself with them before trying to follow the guides in Rob van der Woude's scripting pages. The damage you might do to system files by not understanding NT Commands defies description.

Good luckwhat about the rmdir command
4327.

Solve : save a list of file names?

Answer»

Hi,
I am a very low ability PC user and would appreciate some ABC help please.
I have a folder containing around 500 files. I want to copy the file titles to a TEXT file to use to make a database.
I know that I can get just the file names in a list and save them to a text file, but it seems very difficult and confusing to a beginer.
Could someone give me very simple step by step instructions on how to achieve that please..............
The file location is "C:\Documents and Settings\Me\My Documents\Scores\piano\sheets"
so how do I type the exact syntax to get what I want and save it to a text file.
Thanks for any help.............
frostyboy :-/The basic command would be:

Code: [Select]
dir "C:\Documents and Settings\Me\My Documents\Scores\piano\sheets" > list.txt


Run dir /? from a command prompt for a full explanation of the switches you can use to customize your list.

Good LUCK. Hi Sidewinder,
thanks for the help...........
I don't think my last post went through but not to worry I've tried again since then and still not been successful.

First I got varying distances along the path, by re-typing the path with capitals where required. But I couldn't get it to work at all with the >list.txt added.I found that by deleting the >list.txt, I could get the list to appear on screen but not save.

If I add the >list.txt, it just says file not found.

Any advice please...........and where would it save to if it worked. C:/list.txt I suppose............if so do I need to create a folder or not. I know I shouldn't really, but I cant get it to work

frostyboySorry,
If I can have the switches also to PREVENT DATE, time and file size. Dos is very difficult to get your HEAD around.........

thanks

frostyboyNow I have added the switches and got exactly what I want, on the screen, but can't get it to save..............as soon as I add "spacelist.txt" it says file not found.
frostyboyMost shell commands output to the screen. Using redirection (>) you can send the data to a file. I missed to ME in the original command.

Replace "Me" with either your signon or %username%. Either will do.

The redirected output will end up in the directory your signed on to. If you have a specific place you want it, use a path.

Code: [Select]
dir "C:\Documents and Settings\%username%\My Documents\Scores\piano\sheets" > drive:\dir1\dir2\list.txt


PS. if you found any switches you can use, include them after the dir command.

Good luck. Thank you Sidewinder,

Once I'd added the > C:\ to the code it worked a treat.

Incidentally, the Me part was actually correct, after I had a new motherboard fitted, the technician re-loaded windows for me, and signed me on as Me........I don't know how to change it now.

Success at last..............thanks a lot

.........frostyboy..............

4328.

Solve : Hacker?

Answer»

I have an awful hacker on my system and my computer company does not even know how to get them off. What they do is somehow you go to certain places to make changes so I can be in control of my computer but they grey out the areas that NEED to be checked therefore they are unavailable. Does anyone know how they do this? I am desperate to get them off. They have been on my computer now for 1yr and about 9 months. I am taking it to the sheriff's department to look into it because that is what my computer company told me to do however I have been told they won't do ANYTHING unless serious things have happened do to it. No such thing as HACKER........i would say a company has it manager how is paid to deal with this problem?


Relist your problems......does it concern your own pc?And this is your system and no one else has access to it? Or ever has? Are you RUNNING current spyware/adware/virus protection? If so,what? What kind of internet connection - modem or cable? Do you have a router ATTACHED? Is there a firewall? Can you REINSTALL Windows if you have to? What version?

Just a few details that are relevant.i would like to help with your problem but what does that have to make with DOS? what is your os by the way

4329.

Solve : Opening a cmd.exe window from a batch script.?

Answer»

Have the FOLLOWING testing script. And I'm trying to have it open a new cmd window and have it display the contents of a text file. The contents of the file at this stage are just some ramblings, but when INCORPORATED to production will contain the output of SQL Logfiles.

Any pointers with the following appreciated...

Code: [Select]@echo off

@echo.
@echo ... This is a TEST bacth job ...
@echo.
@echo.
@echo.
@echo.
@echo. Attempting to display another file in another window...
@echo.

[highlight]cmd.exe /Q /C"type c:\SOMEFILE.txt && @echo. && pause"[/highlight]

@Pause
@echo.
@echo ... End Script ...
@echo.
Cheers,
CameronUse /K in place of /CThanks for the reply.

Sadly /K made no difference.

Thinking about it a little more, I guess I could invoke NOTEPAD.exe instead. Will have a try doing that.

Many thanks for your effort.

Cheers,
CameronTry with this:

start type c:\SOMEFILE.txt

Or if you want see it with the notepad:

notepad c:\SOMEFILE.txtMany thanks for the suggestion Carlos (I saw your post only moments ago).

Have gone with the following and works really well. The script doesn't continue until the notepad applicationis closed, which keeps everything nice and neat.
Code: [Select]@echo off

@echo.
@echo ... This is a TEST bacth job ...
@echo.
@echo.
@echo.
@echo.
@echo. Attempting to display another file in another window...
@echo.

set SQLContinue=
set SQLFile=c:\SOMEFILE.txt

notepad.exe %SQLFile%

@echo.
@echo Please confirm...
set /p SQLContinue= Do you wish to continue ? [y/N] :

IF /I "%SQLContinue%" NEQ "Y" (

@echo.
@echo You have chosen NOT to continue.
@echo.
@echo Ending Script...
@echo.

sleep 5

goto :FinishRun

)

@echo.
@echo Continuing after checking %SQLFile%'s logfile.Cheers,
Cameron

4330.

Solve : I need help for my school MS-DOS exercises?

Answer»

5º Make a batch file called copier.bat that by defect copy all the files with TXT extension contained in the A: unit to the C: unit.

If we want to execute the copier.bat file followed of the name of a text file (a parameter), the batch file must copy the above mentioned text file to the C: unit.

Is thinked that the user must indicate the file path in case of that it doesn´t be in the same directory that copier.bat. TRIPLE POST


Please give a second for your previous post to show beforfe placing another identical one. . The headmaster will be along shorly.I only have these exercises to do, not MUCH more.
Thanks for your worry. But I need HEEEELPPPPPPPP!!!!!Dude, get some help. We are here to help you for your question. Not for situations like: "I have waited till the last day to start for my work for school I need quickly some FAST help, lets post it 5 times, and it will be sure al fine.Your inferences are wrong. I have stayed occupped with a lot of importants problems and I have had only time to do the FIRST exercise and I have spent 5 hours to do it.

5 hours x each problem I have yet = 25 hours.

I have no time. It´s impossible.Quote

Your inferences are wrong. I have stayed occupped with a lot of importants problems and I have had only time to do the first exercise and I have spent 5 hours to do it.

5 hours x each problem I have yet = 25 hours.

I have no time. It´s impossible.


Try to live for the next days from coke and coffie

"Try to live for the next days from coke and coffie"

You are so, so, so, fuuuunnnnny....

INSTEAD of are saying and saying nonsenses, I have made my third program in MS-DOS.

Like this:

¡¡¡Ladies and Gentleman!!! With us..... COPIER.BAT!!!!!


@ echo off
if "%1" == "" goto 1
if not "%1" == "" goto 2
:1
copy a:\*.* c:\Probe4
goto end
:2
if exist %1 copy %1 c:\Probe4
:end
echo on


Quote
"Try to live for the next days from coke and coffie"

You are so, so, so, fuuuunnnnny....

instead of are saying and saying nonsenses, I have made my third program in MS-DOS.

just shut the f**ck up your silly idiot. Stand right and walk a round arround your chair. I hope that is the number you will get for you examen. I believe for your image, you are a little Saint Anthoni´s frog. Not more. You can´t give any help to anybody.

Only you can do in life is making fun things, like jump and croaking.

Poor strange Saint Anthoni´s frog, what exude venom to all criatures around it.

Take care, and walk looking back over your shoulders....

Quote
I believe for your image, you are a little Saint Anthoni´s frog. Not more. You can´t give any help to anybody.

Only you can do in life is making fun things, like jump and croaking.

Poor strange Saint Anthoni´s frog, what exude venom to all criatures around it.

Take care, and walk looking back over your shoulders....


lol, i've ended a lot higher then you, so I wouldn't be that rude
I don't help with homework. I help with computer issues.



Had you ASKED in a different way other than, "oh please someone do all my homework for me", then I'd be glad to help.

Good luck.
4331.

Solve : scheduled event / batch file?

Answer»

Hello,
i'm not even SURE if this is possible, but is it possible to CREATE a batch file that will open a word document, PRINT it, then close the window...and set it up as a scheduled task. Please note, the printing may be optional. I know I should look this up myself but i'm pressed on time. Thank You.Use the cd\ to put yourself at the root of C:

cd program files\microsoft office\office11\winword.exe c:\print.doc

This will open a word file in word. However I don't believe you need to open it before you can print it.
You could just use the print command.

print /d:usb c:program files\microsoft office\office11\print.doc

That should print the document. Now obviously there are things you need to change because
your computers directory setup most likely differs from mine. Also you may not use USB as your
PRINTERS port.

Just make the changes that you need to so that everything is pointing in the right direction.

So type this into a notepad.

cd\
cd program files\microsoft office\office11
winword.exe c:\print.doc

print /d:usb c:program files\microsoft office\office11\print.doc

I don't think you need the part in bold. I think the print command will suffice. Then all you do is save it with the extension of .bat

Then use task scheduler to schedule it to run at specified times. Note that you may have to modify some things, as I wrote these as if I was doing them on my PC. You may need to change the USB part to something different, again it depends on your configuration.

But this should get you started and give you a good idea.

thank you very much for the reply!No problem.

4332.

Solve : moving dir and sub dir to a different dir?

Answer»

How can I move an entire directory structure to another using a BATCHFILE, lets SAY i wanted all directories, sub directories and files from c:\fold1 to be moved to c:\fold2 ..First copy, after delete:

XCOPY c:\fold1\* c:\fold2 /e /h /q /v
rd c:\fold1\* /s /q <-- beware !

P.S. for more information:
xcopy /?
rd /?

(the next don't move hidden files, and only works on W2000 and laters)
[size=16]OR[/size]

Move first files, after directories:

for %%x in (c:\fold1\*) do move %%x c:\fold2
for /d %%x in (c:\fold1\*) do move %%x c:\fold2

[size=16]OR[/size]

for /F %%x in ('dir /B c:\fold1') do move c:\fold1\%%x c:\fold2\

4333.

Solve : detect cd rom from the batch file?

Answer»

I want to detect the cd ROM drive letter from the batch file and POINT it into my file which is on a cd.I want to access the file on a cd in different systems with different cd drive letters and access my file by means of a batch file.please help me in this regardThis code search your file in all the drive letters for devices (DISK, CD-ROM USB pendrive, diskette, ...). You can remove the letter A, B (maybe C) if you are sure that the CD isn't in this drives.

Code: [Select]@echo off
set DRIVE=
for %%D in (a b c d e f g h i j k l m n o p q r s t u v w X y z) do vol %%D: >NUL 2>NUL && if exist %%D:\PathTo\MyFile.txt set DRIVE=%%D

if not defined DRIVE echo I can't find the file && goto END

type %DRIVE%:\PathTo\MyFile.txt

:END
You must change the "PathTo\MyFile.txt" for yours.
You could have a problem if exist ANOTHER path/file in other drive with the same name "PathTo\MyFile.txt", it will work with the last unit found.

P.S. You dont posted your OS, this code works for W2000 and laters.

4334.

Solve : About Dos?

Answer»

DOS written in C ?

APPLICATION software WORKED with *.bat , *.EXE , command.com written in C ?http://en.wikipedia.org/wiki/DOS

4335.

Solve : I need fast help for my school MS-DOS exercises?

Answer»

3º Make a bat file, called words.bat, that by means of an only FOR curl, show by SCREEN 15 words that have formed themselves like a result of concatenate the syllables CA, GA, PE, SO, PA with the syllables SA, LA, TA.
Have you tried www.homework.com Surely you have a textbook. ? Please I need only help to do my MS-DOs homework. I have given my explanations before in other topic.Quote

Please I need only help to do my MS-DOs homework. I have given my explanations before in other topic.

have you even gone to the lessons than you surely should can do thisYour INFERENCES are wrong. I have stayed occupped with a lot of importants problems and I have had only time to do the first exercise and I have spent 5 hours to do it. I know I could do them in TWO days, but not with only today time.

5 hours x each problem I have yet = 25 hours.

I have no time. It´s impossible.Well, I have started for the most simple.
The code I have written is

echo off
for %%A in (ca, ga, pe, so, pa) do echo %%ASA

But I need the same with la and ta in the same for.Now I have improved this code with

echo off
for %%A in (ca, ga, pe, so, pa) do echo (%%Asa, %%Ala, %%Ata)
echo on

Weeeeelllllllllll , i have finish this problem already.
The final MS-DOS code is:

¡¡¡Ladys and Gentleman!!!!


echo off
for %%A in (ca, ga, pe, so, pa) do echo %%Asa %%Ala %%Ata
echo on
Quote
Weeeeelllllllllll , i have finish this problem already.
The final MS-DOS code is:

¡¡¡Ladys and Gentleman!!!!


echo off
for %%A in (ca, ga, pe, so, pa) do echo %%Asa %%Ala %%Ata
echo on

first of al try @echo ff because when you enter echo off, it will stil say on the first line: echo is off
Harlequin :

Code: [Select]@echo off
for %%x in (CA, GA, PE, SO, PA) do (
for %%y in (SA, LA, TA) do (
echo %%x%%y
)
)

Good luck with your studies. 8-)

BLACKBERRY: You'll never get my vote for Miss Congeniality ¡¡¡by means of an only FOR curl!!!

Sidewinder, your code is so good, better than mine, but my teacher wants only on for loop and yours has two.

Today I have present my teacher all the homework made.

Thanks very much. I always learn things so good here thanks to you.

Greetings.I do nominate Sidewinder for Miss Congeniality! Quote
I do nominate Sidewinder for Miss Congeniality!


i'll vote for him
4336.

Solve : Batch at windows close?

Answer»

Hi all

I stumbled across this forum while searching for batch file help.

Heres what i want to do, when the computer shuts down i want it to first run adaware, then defrag and other programes before it actually shuts down.

Is this posible without any intervention from me, i.e how do i tell adaware to actually run without me clicking start.
Also how do i tell it to wait till adawares finished before it starts defrag, i have seen pause commands but you have to insert a time delay yourself, i want each programe to run after the other has finished.

Any help appreciated guys

You need Ad-aware Plus to use the command line switches. If you go to the DIRECTORY where adaware lives and type ad-aware /? you'll get a complete list.

Defrag can be run from the command line. Type defrag /? at any command prompt for details.

When running executables from a batch file, list them sequentially. Each will wait for the preceeding one to complete. This does not refer to batch fies executing other batch files.

The pause command is not time sensitive. The pause waits for a keystroke to be entered....for eternity if necessary

Hope this helps. 8-)Which version of Windows are you running? Windows XP Pro? Home?There is a small command line utility CALLED Launchkey that can launch applications and send keystrokes and/or mouseclicks to them. It can be operated from a batch file too. MANY apps whose interfaces aren't designed to accept keystokes will respond to the TAB, SPACE, ENTER, and arrow keys. You will also have to set the time delays for different parts of the cycle. It takes a lot of experimenting to get all the ENTRIES and delays in the right order. Getting the free version of AAW to automatically clean may not be possible with this METHOD, but you should be able to make it run thru to shutdown if the system is clean.
Rick

4337.

Solve : Create a file?

Answer»

Hi all.

I woul like to know how can I create a file without a windows or MS-Dos displays. What I need is to create a log file. When my application starts it finds a log file, if it does not exist I want the application create the file using a .bat

I try with a bat that have this line:

edit file.log

The editor is opened but I want to doit without the user see anything, I wanna create the file silently.

Can this be possible?

Im not sure exactly what you are after
If you are running a batch file, and you just want to create a file, this line creates a file of 0 bytes
REM >myfile

If you have an application, then that language will have filesystem constructs (if it doesnt then you should be able to instantiate a filesystemobject and use that to create your file

GrahamThere is the possibility of opening the .bat file minimised - please Google for info.

If you intend to use the Edit utility how will you enter any data without the user knowing :-?

Why not just check for the file and if not exist then create it in your application :-?What I need is to use the file as a log. When my application starts, it finds a log file, if doesn't exist, i want to create it without the user see anything.

I know the edit can start minimized, but I don have to write nothing, just create the file. My application use the file to write data.

My application is developed with PowerBuilder and can write, copy en read from a file but no create it.

I don't wanna have any copy of that file to copy if doesn't exists, I want to know how can I create the file with the name and extention that I WISH, without prompts, without asistance, but I dont know how.

I hope you can helme...
I think what you want is easy.
Open the BLOCK notes of windows and save the file as (name).log where you desire...


Just in case the file doesn't exist my application have to create the file. Can I use a bat file or any function of Windows to do it?

I ALREADY use the notepad to create the log file. In case I install the application in a new client, the application starts for the first time, looks for the file end if can't find it, the application can create the file.

I want to use a bat file to do it because from my application is easy to do, just writing in my code the function RUN(C:\app_path\log.bat)

If you know how to do a file in other way, please tell me how...This is mind numbing. Are you creating a log file with a .bat extension? You can create an empty (well, 3 bytes actually but who's counting?) file with:

if not exist c:\app_path\log.bat echo. > c:\app-path\log.bat

Most languages have file system functions. If you can test for the existence of a file within your application, most likely you can open the file as append or as output, whichever is appropriate. Why do you need a batch solution?

8-)Hi

Now I can create it with my application.

The bat is for run it from the app so the bat need to contain a line to create a file, for example edit logfile.log

when I run this bat the DOS launch the edit application with the file but I wanna create the file whithout see anything, silently.

comments?

What is your real goal is all of this? You have spent a lot of time beating around the bush.Use the start command with the /min switch. Be sure not to have any commands in your batch file that create a console interrupt. Batch files need the command or cmd shell to run, with START it will be minimized but not invisible.

Using a batch file to launch an application is fine in DOS. You would be better served with a Win Script to run within the Windows environment where the script will run UNNOTICED by the user.

Good luck. 8-)

Sorry man, if you think I have spent a lot of time beating around the bush just don't write cos your post don't help anybody so keep working or keep quiet with your answers.

For enybody who try help me I say thankyou...

4338.

Solve : redirecting a redirector?

Answer»

I am WONDERING if anyone out there knows how to create a 2ndry BATCH file with the < SYMBOL included.
For example the secondary batch file needs to LOOK like this:

...
format a: < 3rdFile.bat
...

I tried doing this in my 1stry batch file but it does not work:

echo format a: < 3rdFile.bat > 2ndyFile.bat

Could someone please HELP?Give this a try:

echo format a: ^< 3rd.bat > 2nd.bat

Hope this helps.

4339.

Solve : NTVDM CPU Error?

Answer»

I've been trying to run a ping check through DOS Prompt and lately i've been getting this error.

NTVDM CPU has encountered an illegal instruction.
CS:0534 IP:0000 OP:db 20 02 a2 00 Choose 'Close to terminate this application.

I used to be able to run ping checks no less then a month ago, so I don't know what's GOING on with it now. Any help is appriciated, ty.For Windows XP:

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

For Win2000 and NT

http://support.microsoft.com/kb/165214/EN-US/

Good LUCK.

4340.

Solve : FOR command challenges?

Answer»

Hi all,

I am having a hard time trying to get the FOR command to process a text file correctly. The FOR command seems to only process the left colum in my text file and not the entire line which contains more words / strings.


The Scenario:
1) Dump a list of users on this machine to a text file.
2) Compare the list with the users input criterea if users already exist or not.
3) Return the result in a SET command.



My approach:
Set all user input as individual SET statements.
Eg. USER1=%1 USER2=%2 USER3=%3 etc. etc.

Dump the CURRENT users on this machine to text file.
NET USERS >list.txt

Use the FOR command to itterate the users input with the FIND command. Export any hits if true to rslt1.txt

Any subsequent FOR commands are to to filter postive HITS from negative hits and join them into seperate SET statements.


My SOURCE code.

At the command prompt type this:
TEST.CMD John Jill Mark Jack Suzan
We will asume that Jill & Jack already exists on your system. The remainder are potential new users for creation. I suggest you cut and paste this batch an test it on your system. It does no harm. Test it on some true users accounts and some fake accounts to understand what I mean.



@echo off
set errorlevel=
PROMPT $P$G
CLS


REM Split all the requested users up into seperate variables.
REM We do this because the FIND works only with single search strings.
set user1=%1
set user2=%2
set user3=%3
set user4=%4
set user5=%5
set user6=%6
set user7=%7
set user8=%8
set user9=%9

REM Here is where we look for our user on this machine.
net users>list.txt

REM Individually test each user with the FIND command and store any HITS
REM in a text file.
FOR %%i in (%user1% %user2% %user3% %user4% %user5% %user6% %user7% %user8% %user9% ) do find /I "%%i" <list.txt >>rslt1.txt

SET EL=%ERRORLEVEL%

REM Breakdown any users already existing on this system with the
REM FOR command searching thru our earlier results from FIND.
FOR /F %%i in (rslt1.txt) do if /I "%user1%"=="%%i" (set usr1=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user2%"=="%%i" (set usr2=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user3%"=="%%i" (set usr3=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user4%"=="%%i" (set usr4=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user5%"=="%%i" (set usr5=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user6%"=="%%i" (set usr6=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user7%"=="%%i" (set usr7=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user8%"=="%%i" (set usr8=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user9%"=="%%i" (set usr9=%%i)

if /I NOT "%user1%"=="%usr1%" (set us1=%user1%)
if /I NOT "%user2%"=="%usr2%" (set us2=%user2%)
if /I NOT "%user3%"=="%usr3%" (set us3=%user3%)
if /I NOT "%user4%"=="%usr4%" (set us4=%user4%)
if /I NOT "%user5%"=="%usr5%" (set us5=%user5%)
if /I NOT "%user6%"=="%usr6%" (set us6=%user6%)
if /I NOT "%user7%"=="%usr7%" (set us7=%user7%)
if /I NOT "%user8%"=="%usr8%" (set us8=%user8%)
if /I NOT "%user9%"=="%usr9%" (set us9=%user9%)

REM Now combine the positive (already exists) users in a single list (LISTB) for easier display.
set listb=%usr1% %usr2% %usr3% %usr4% %usr5% %usr6% %usr7% %usr8% %usr9%

REM Now combine the negative (available) users in a single list (LISTA) for easier display.
set lista=%us1% %us2% %us3% %us4% %us5% %us6% %us7% %us8% %us9%

echo.
echo The errorlevel for FIND is: %EL%
echo.
if not "%EL%"=="1" goto warning
goto end

:warning
echo WARNING! Some user accounts are already in use!
echo.
if not "%listb%"==" " echo These user(s) %listb% already exists!
echo.
if not "%lista%"==" " echo You could continue to make these (new) users: %lista%
goto exit

:end
echo NOTIFICATION: You can safely use the following list to make users.
echo.
echo The user(s) %lista% does not exist. This is Good!
echo.
goto exit

:exit
set user1=
set user2=
set user3=
set user4=
set user5=
set user6=
set user7=
set user8=
set user9=
set usr1=
set usr2=
set usr3=
set usr4=
set usr5=
set usr6=
set usr7=
set usr8=
set usr9=
set us1=
set us2=
set us3=
set us4=
set us5=
set us6=
set us7=
set us8=
set us9=
set el=
set lista=
set listb=
Gustaaf,

If I can't read it, I can't answer it. Please repost this in black and white. Save the Technicolor for the movies.

Hi all,

I am having a hard time trying to get the FOR command to process a text file correctly. The FOR command seems to only process the left colum in my text file and not the entire line which contains more words / strings.


The Scenario:
1) Dump a list of users on this machine to a text file.
2) Compare the list with the users input criterea if users already exist or not.
3) Return the result in a SET command.



My approach:
Set all user input as individual SET statements.
Eg. USER1=%1 USER2=%2 USER3=%3 etc. etc.

Dump the current users on this machine to text file.
NET USERS >list.txt

Use the FOR command to itterate the users input with the FIND command. Export any hits if true to rslt1.txt

Any subsequent FOR commands are to to filter postive HITS from negative hits and join them into seperate SET statements.


My SOURCE code.

At the command prompt type this:
TEST.CMD John Jill Mark Jack Suzan
We will asume that Jill & Jack already exists on your system. The remainder are potential new users for creation. I suggest you cut and paste this batch an test it on your system. It does no harm. Test it on some true users accounts and some fake accounts to understand what I mean.



@echo off
set errorlevel=
PROMPT $P$G
cls


REM Split all the requested users up into seperate variables.
REM We do this because the FIND works only with single search strings.
set user1=%1
set user2=%2
set user3=%3
set user4=%4
set user5=%5
set user6=%6
set user7=%7
set user8=%8
set user9=%9

REM Here is where we look for our user on this machine.
net users>list.txt

REM Individually test each user with the FIND command and store any HITS
REM in a text file.
FOR %%i in (%user1% %user2% %user3% %user4% %user5% %user6% %user7% %user8% %user9% ) do find /I "%%i" >rslt1.txt

SET EL=%ERRORLEVEL%

REM Breakdown any users already existing on this system with the
REM FOR command searching thru our earlier results from FIND.
FOR /F %%i in (rslt1.txt) do if /I "%user1%"=="%%i" (set usr1=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user2%"=="%%i" (set usr2=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user3%"=="%%i" (set usr3=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user4%"=="%%i" (set usr4=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user5%"=="%%i" (set usr5=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user6%"=="%%i" (set usr6=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user7%"=="%%i" (set usr7=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user8%"=="%%i" (set usr8=%%i)
FOR /F %%i in (rslt1.txt) do if /I "%user9%"=="%%i" (set usr9=%%i)

if /I NOT "%user1%"=="%usr1%" (set us1=%user1%)
if /I NOT "%user2%"=="%usr2%" (set us2=%user2%)
if /I NOT "%user3%"=="%usr3%" (set us3=%user3%)
if /I NOT "%user4%"=="%usr4%" (set us4=%user4%)
if /I NOT "%user5%"=="%usr5%" (set us5=%user5%)
if /I NOT "%user6%"=="%usr6%" (set us6=%user6%)
if /I NOT "%user7%"=="%usr7%" (set us7=%user7%)
if /I NOT "%user8%"=="%usr8%" (set us8=%user8%)
if /I NOT "%user9%"=="%usr9%" (set us9=%user9%)

REM Now combine the positive (already exists) users in a single list (LISTB) for easier display.
set listb=%usr1% %usr2% %usr3% %usr4% %usr5% %usr6% %usr7% %usr8% %usr9%

REM Now combine the negative (available) users in a single list (LISTA) for easier display.
set lista=%us1% %us2% %us3% %us4% %us5% %us6% %us7% %us8% %us9%

echo.
echo The errorlevel for FIND is: %EL%
echo.
if not "%EL%"=="1" goto warning
goto end

:warning
echo WARNING! Some user accounts are already in use!
echo.
if not "%listb%"==" " echo These user(s) %listb% already exists!
echo.
if not "%lista%"==" " echo You could continue to make these (new) users: %lista%
goto exit

:end
echo NOTIFICATION: You can safely use the following list to make users.
echo.
echo The user(s) %lista% does not exist. This is Good!
echo.
goto exit

:exit
set user1=
set user2=
set user3=
set user4=
set user5=
set user6=
set user7=
set user8=
set user9=
set usr1=
set usr2=
set usr3=
set usr4=
set usr5=
set usr6=
set usr7=
set usr8=
set usr9=
set us1=
set us2=
set us3=
set us4=
set us5=
set us6=
set us7=
set us8=
set us9=
set el=
set lista=
set listb=I bet you get paid by the line.

Lets see. You want one file with users already defined and one file with available user names.

Code: [Select]
@echo off
net user > list.txt
if exist listA del listA
if exist listB del listB

:start
if .%1==. goto :end
find /i "%1" list.txt > nul
if errorlevel 1 goto listA
if errorlevel 0 goto listB

:listA
echo %1 >> listA
goto loop

:listB
echo %1 >> listB
goto loop

:loop
shift
goto start

:end
echo These names are available:
type listA
echo.
echo These names are in use:
type listB


Feel free to make any changes you need but this should give you an idea how to PROCEED. Now that the names are split into separate files, you can do whatever it is you need to do.

Batch files may have mystical powers but there are easier scripting languages available.

Hope this helps. I wish I was paid per line coding, but alas, its all for personal HOBBY. Thanx, the code is simple and lots more faster then my FOR statements. It works great too. Give yourself a golden star on my behalf. I had contemplated using shift to clean up the mysterious gaps in my results. But I would not have placed it in a looping fashion like you did.

But now that is out the way, what is with the FOR command not processing each line of text? Why does it only process the first word of each new line?This link may answer all your questions>>http://www.robvanderwoude.com/index.htmlI believe the /F in your for line is why you only pull the first word. Leave it out and try. You could also do "tokens=1-10 delims= " to get the first 10 words.

4341.

Solve : copy sub-directories in dos????

Answer»

I am new to dos and commands. I have managed to master COPYING FILES in a folder but was wondering if I am ABLE to copy sub-directories within a folder as WELL :-/.http://www.codeproject.com/csharp/xdirectorycopy.aspThanks for the site and your time. I found it and UNDERSTAND the xcopy /s and so on.

4342.

Solve : MS-DOS data to Excel?

Answer»

How can one take data created in an MS-DOS program and put it into excel? I have very limited EXPERIENCE with Dos, and in fact would have to have a step by step discription. I COULD use the Data, text to column, in excel, if I knew how to GET the text out of DOS so that I could copy it into excel.

Any info would be welcome Joehttp://www.kayodeok.btinternet.co.uk/favorites/kbofficeexcelhowto.htm#kbhowtoIF YOU HAVE THE NO-UPGREDE MS-DOS PLEASE
call me if you have please
tel.(347)347-9312 OR (718)724-076

4343.

Solve : autoexec.bat and config.sys help please?

Answer»

i would EQUALLY be greatful for some explanation on the function of the autoexec and config.sys and the importance of having these files.

please email at [emailprotected]
or reply to this post thanks.The CONFIG.SYS sets up your hardware components such as memory, keyboard, mouse and printer. It is read early in the boot process and configures plain vanilla DOS to your specific needs.

The AUTOEXEC.BAT sets up your software requirements and is a good place to start TSR programs, houskeeping routines and programs that need to run after every boot. This FILE is read after DOS is installed but before control is given to the user.

These files, while not REQUIRED, are used only on DOS and Win9x machines.

Hope this helps. Yes thank you. was al ittle baffeld about --> This file is read after DOS vanilla is installed but before control is given to the user.

didnt no what u ment by vanilla lol but worked it out thanks i was digging around in my game archives and found an old dos game i NEVER finished called Thunderscape, seemed to successfully install it, and it goes thru the intro and all, but when i hit the character or start game buttons, it crashes instantly back to windows ( i am running windows 98 se). The readme text says something about changing a line in the config.sys file. and the advice on this site says to do any config sys editing from win 98 by going thru start / run / sysedit which i did and found the config.sys file apparently ... but it is blank? so i tried to add the line the readme asked for, but it didn't change anytyhing. By the WAY, the line it wanted was

DEVICE=C:\DOS\EM386.EXE NOEMS

Any advice to this complete dos neophyte would be greatly appreciated, Thank you. Delete the line you inserted and insert these two lines.

DEVICE=C:\WINDOWS\HIMEM.SYS
DEVICE=C:\WINDOWS\EMM386.EXE /FRAME=NONE

Save the file and reboot.

4344.

Solve : How do you prevent the type command overflowing?

Answer»

Im MAKING a database type thing for my files and some of them go over the limit of characters that the cmd prompt can hold. ANYONE know how to prevent this?You don't! But if you really want to GET whimsical, a combination of FOR, SET (WINXP, WIN2000, NT) and ECHO just might do it.

Happy Coding.

4345.

Solve : shutdown a pc remotely on Local LAN?

Answer»

how to SHUTDOWN a PC REMOTELY on Local LAN in command prompthttp://www.chami.com/tips/windows/011697W.htmlUse FREEWARE psshutdown.exe from www.sysinternals.com
This can hybernate, shutdown or reboot the remote machine. There are other very useful tools in there, like psexec.exe that allows you to remotely launch PROGRAMS.


4346.

Solve : Power shutoff before rebooting or startup hangs?

Answer»

???Can not reboot without shutting down power. Startup will stop after Memory CHECK and CD-ROM Drive is RECOGNIZED. BIOS might be incorrectly configured because hangup is just before harddrives setup. I have OLD Award Modular BIOS v.2.51PG 08/11/97. Setting bootup order has limited selections. I can't set to >Floppy>CDROM>IDE-0 or A. E, C drives boot order. Closest selection offered is A > C > SCSI.
Starting at Windows DESKTOP, if I select in shutdown window, reboot. Startup will stop after Memory Check and CD-ROM recognition. I must always shut-off power before Windows will load. I have just INSTALLED a new hard drive, which gave me a lot of problems. I have BIOS config. to recognize hard drive, and have partitioned, formatted and copied bootable hard drive contents to new drive which I will use as new boot drive C. Has anyone had asimilar problem with startup? Please advise. I am not considering upgrading my BIOS because of the large chance of errors.

4347.

Solve : batch for copying certain extensions?

Answer»

I'm trying to create a batch that MOVES .tif images from one directory to another, after those have copied it will then copy a .dat file to the same directory. Then move on to the next directory. I'm a little confused on how I go about this because all I've done is very basic, simple batches and I'm not sure how to begin with this task.
Below is an example of my directory structure.
------------------------------------------------------------------------

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

I'm wanting the batch to go into the XXXX directory in the ProcessedBatches directory, copy every .tif file within that directory, move it to a destination directory, then copy the .dat file in the XXXX directory, move that into the destination directory, and then move on to the next directory within the root of ProcessedBatches directory and repeat the same process.

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

This may seem like an overwhelming amount of information, maybe it is. I'm not asking you to write the actual code for me (if you did i'd love you forever though.) .... I'm just looking for someone who may be able to point me in the right direction on where to begin (yes, I've browsed through the example batch files list from this website).

Thanks for any help you give me!

--drpunkerzThere are different ways to do this. Many of them less cryptic. Below is just a template to give you an idea what needs to be done.

Code: [Select]
echo off
for /d %%a in (E:\ProcessedBatches\*) do (
for /f "tokens=1-2 delims=." %%i in ('dir /b /a:-d %%a') do (
copy %%a\%%i.tif DestinationPath
)
)


Make sure the paths are correct before running. I'll let you handle the logic for the DAT file.

Hope this helps. The code you wrote out worked great but within each sub directory (i.e. 0001) it has the same naming scheme for each tif (image0001.tif, image0002.tif, etc) so this code only copies and overwrites about 20 times (one overwrite for each batch (or folder)....I added the /-Y option on the copy command so that it prompts me so that it doesn't overwrite but I have to hit n about a million times before it goes to the .dat copy process.

I'm only trying to move the tif's FIRST, dat's second, wait roughly 4 minutes, delete the first subfolder (0001 in this example) move on to subfolder 0002 and repeat the same process. Now there is only one more problem...Each subfolder could possibly start out with 0082 and go through 0XXX... It varies. If I'm not MAKING any sense please tell me. Thank you for your help

--drpunkerz
To give you a better idea of what I'm trying to do... this is the code I've created thus far. I wasn't sure how to go around the code without doing a bunch of loops to check on some parameters but it gets the job done. Now all I need to do is figure out a way to remove a certain folder name after it has copied all the tif and dat files over to E:\fnis-iamodule03 ...

Code: [Select]
@echo off
cls

:modulecheck
IF EXIST e:\fnis-iamodule03\* (
GOTO modulecheck
) ELSE (
GOTO tif
)

:tif
for /d %%a in (e:\ProcessedBatches\*) do (
for /f "tokens=1-2 delims=." %%i in ('dir /b /a:-d %%a') do (
copy %%a\%%i.tif E:\fnis-iamodule03
)
)

:dat
for /d %%b in (e:\ProcessedBatches\*) do (
for /f "tokens=1-2 delims=." %%j in ('dir /b /a:-d %%b') do (
copy %%b\%%j.dat E:\fnis-iamodule03
)
)

IF EXIST e:\ProcessedBatches\* (
GOTO modulecheck
) ELSE (
GOTO end
)

:end
echo Import Finished!
I'm a little unclear on some of your thinking, but your file looks fine. I guess I can't see what purpose those IF statements serve since the nested FOR's produce self-contained loops...one for the directories and one for the files.

To delete the folder: try using a RD before the last parenthesis of the DAT set.

If you have access to CHOICE (Win9x only) you can use that for your 4 minute timer otherwise you're SOL.

Use the /Y option on the COPY to suppress the prompts.

As batch files become more complex, Windows Script becomes a better option.

Hope this helps. Those if statements are for something I hadn't mentioned :p
Thank you a lot for your help!Now I understand. I had to do something similar to this for my photos. Each of them were numbered within their own subdirectory, but when I tried to move them into a common directory, the duplicates showed up. An added complexity was that fact that each directory had different levels of nesting.

The way to solve this was to write a recursive ROUTINE to follow each of the nested directories to their logical end before going on to the next directory.

To solve the duplicate problem, I had to keep counting each picture before I copied it and then use the count as part of the filename.

If this is what you're trying to do, I suggest a script. While writing a recursive batch file is possible, scripting, while still complex to follow, is still a better solution.

Hope this gives you some ideas. Yep. Learning perl right now :p

4348.

Solve : xcopy error routine?

Answer»

I am trying to add an error routine for using xcopy in a batch file using windowsXP & 2000 at the command prompt

ex..

if (error) goto err
xcopy x y
goto ok
err:
echo problem etc.

These are the errorlevel codes that XCOPY generates:

0 Files were copied without error.

1 No files were FOUND to copy.

2 The user pressed CTRL+C to terminate xcopy.

4 Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line.

5 Disk write error occurred.

Good luck.

PS. Wouldn't you want to check the error codes after XCOPY? .... just asking This is what I am doing..havn't used bat files or DOS in QUITE awhile. The log file gets created ok, but it just dies with 0 files

Xcopy /s/i/v/d/r/Y "c:\Documents and settings\Anna\my documents" "P:\My Documents" >> c:\bu-key.log
if errorlevel =2 goto Prob
if errorlevel =4 goto Prob
if errorlevel =5 goto Prob
cls
goto ok
Prob:
echo Xcopy had a problem....Notify Anna at ext .... for Help
echo We had a Problem >> c:\bu-key.log
pause
goto end:
ok:
echo Back-up of Key Files to Server Complete
echo Back-up ....ok >> c:\bu-key.log
end:Errorlevel checking is not what it seems. The comparision is actually equal to or GREATER than. With this in mind, reverse your error checks and lose the equal signs.

if errorlevel 5 goto Prob
if errorlevel 4 goto Prob
if errorlevel 2 goto Prob

In your case, all you need is a check for errorlevel 1 which covers 1, 2, 3, 4, and 5, but this become PROBLEMATIC if each errorlevel goes to a different label.

Hope this helps.

4349.

Solve : Batch file to move files based on date created?

Answer»

Dear users:

I want to create a start.bat file which allows me to move files that I create daily and move them onto folders based on the files date created.

I do data entry each day and I have to drag and drop my files every evening. I searched around the net and got to this place and I hope someone could help me.


Example:
File Date created
a.doc 6-07-05 12:30PM
b.doc 6-08-05 11:23AM
1.doc 6-09-05 8:30AM
2.doc 6-09-05 9:40AM

I would create a folder called "Document 6-07-05" and then move "a.doc" into it. I created "Document 6-08-05" and move all files on that date to it. I do this EVERYDAY before I GO home. Each day I created about 50-100 documents and I wish there's way for me to move it faster.

Someone wrote me this start.bat but it didn't help much. I save everything on "Today Documents" folder then at end of day I run this batch file.

@echo off
c:
cd\
md c:\"Documents Date"
cd\"Today Documents"
move *.* c:\Documents Date"
cd\
echo on

This works ok, but I have to rename the "Documents Date" to correct date. For instance, today I will run the start.bat file then go into "Documents Date" and rename to "Documents 6-09-05"

I hope you could help.

Thank you in advance,
Akia






This piece of code should work based on what you gave us.

Code: [Select]
for /f "tokens=1-4 delims=/ " %%i in ('date /t') do (
set mm=%%j
set dd=%%k
set yy=%%l
)
set TodayDir="c:\Documents %mm%-%dd%-%yy%"
c:
cd\
md %TodayDir%
cd "\Today Documents"
move *.* %TodayDir%
cd\


It would have been helpful to know your OS as not all batch commands are backward compatable.

Now that the date is available, you could use XCOPY and then delete contents of the the daily directory. Batch does not do arithmetic especially date calculations, so any previously dated files have to be done manually.

Hope this helps. Thank you so much. It worked like a charm. I have XP Prof. This is wonderful as I will run it everyday so there won't be any previous date.

Again thanks for your help.

Regards,
AkiaThere're spaces in between the date, how can I make it to read as 6-13-05 and not 06 - 13 -2005

ThanksGreg McDonald,

Are you the same person as the original poster? If not please do not piggyback on someone else's thread. Start your own post.

Actually the code works according to the specs presented and with no embedded spaces in the date. You might have missed the part where I mentioned that batch LANGUAGE is not always backward compatable.

If you NEED a two digit year, you need to use a SET statement to extract them.

If you don't need a leading zero for the months, use a conditional SET statement for Jan thru September.

Yes, Greg is my bf. Same OFFICE and thanks for the help.

4350.

Solve : XP Dates & Batch files...?

Answer»

I am trying to create a log file based on the date the batch file is run.

I have searched through your forums and have found this code:
Quote

for /f "tokens=1-4 delims=/ " %%i in ('date /t') do (
set mm=%%j
set DD=%%k
set yy=%%l
)
set TodayDir="c:\Documents %mm%-%dd%-%yy%"


Problem I am having with this code is that the variables are returning with a space on the end of the number. Instead of getting 20050613, I am getting 2005 06 13.

Is there any way to REMOVE this extra space from the variable? If I was doing this in VB it's a simple function.

Thanks for any help that you can offer.You're right. When you write the code:
Quote
for /f "tokens=1-4 delims=/ " %%i in ('date /t') do (
set mm=%%j
set dd=%%k
set yy=%%l
)
set TodayDir="c:\Documents %mm%-%dd%-%yy%"


I get the results you posted. When I write the code:
Code: [Select]
for /f "tokens=1-4 delims=/ " %%i in ('date /t') do (
set mm=%%j
set dd=%%k
set yy=%%l
)
set TodayDir="c:\Documents %mm%-%dd%-%yy%"

I get the correct result with no embedded spaces.

I notice however, when you write the code the file is 151 bytes and when I write it, it's 141 bytes!! Something is amiss. What editor are you using? What OS? And where did those 10 bytes come from?

VB has date functions that batch can never hope to duplicate. When dealing with dates or any other calculations Script is a better choice.

Hope this helps.
I am using WinXP SP2. The editor I was using was notepad.

After reading your reply, I opened a 'dos' window and tried the 'edit' command. I then tested the new batch file and it didn't have the embedded spaces. So it seems that the problem had something to do with the way that notepad was saving the file.

Thanks for all your help.. I'm trying to create a new boot drive and when I use the boot disk the program starts but it is INTERRUPTED with this message:

Command or filename not recognized
Batch files nested too deeply

Anyone know how I can UN"nest" these batch files?

Another thing, however, is that sometimes that message does not come up and the copying process begins. However that process is halted due to a file copy error.

Could these nested batch files be causing the copy error?
If not what else could it be? JelloConcoction,

Are you the same person as the original poster? If not please do not piggyback on someone else's thread. Start your own post.

Your post is too general for a specific reply. Please post your batch file.

There used to be a limit on how many levels of batch calls you could make. What OS are you using?

It's doubtful the copy problem is related, unless of course a file is missing or you are trying to use a invalid or corrupt media.

Get back to us. Oops... sorry, I didn't know...

And thanks for the help even though I can't be of anymore help since I don't know the batch file...
(I'm using WINDOWS XP)

And I'll keep your advice for the future!