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.

101.

Solve : how to execute this command through batch file..????

Answer»

"setup.exe -sa -VER isolated -path "C:\tsdct\ETAS\ASCET-DIFF\V6_1_0_BETA2","C:\TSDE_Workarea\ETASData\ASCET-DIFF\V6_1_0_BETA2" -title "ASCET-DIFF V6.1.0_CS_Alpha_1_RC1" -reg 6_1_0BETA -isolated 6_1_0 -silent"

I would like to execute this command through batch FILE..PLEASE help me as i am new to this..??

Any suggestions/help would be GREATLY appreciated..Thank you in advance.
Guruprasad.If this is the WORKING command line, then literally copy the test into a file and save it with a .bat extension

102.

Solve : Do we have limitation on the length of the command line arguments..???

Answer»

Do we have limitation on the LENGTH of the command line arguments..or what would be the maximum no of characters does a command line supports..??

Please help..??

A QUICK google came up with the following http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx

There is also ANOTHER limit your should be aware of -- you can only process 9 parameters .... use the SHIFT keyword to access param 10 onwards

103.

Solve : simple batch file needs little modding?

Answer»

Hi there I need to create a batch file that will read a text document and create a file for each line of text I have one that almost works but the trouble is the lines of texts have spaces in them and it is creating a file for each section of text so if i have a line of text that reads 'I want only one file' it will create files called I, want, only, one and file the script I am using is

for /f %%i in (file.txt) do echo off> %%i

have tried

for /f %%i in (file.txt) do echo off> "%%i"

and

for /f "%%i" in (file.txt) do echo off> "%%i"

with no luck any help much apreciated.
thanks, James.Try:

echo off
for /f "delims=" %%i in (file.txt) do echo. > %%i

or if you're running it from the command prompt,

for /f "delims=" %i in (file.txt) do echo. > %i

Code: [Select]for /f "tokens=*" %%i in (file.txt) do echo %%i


echoed the list of filenames I had in the file (including spaces).

I'm pretty SURE echo off will echo nothing to the file though. Quote from: Helpmeh on March 10, 2010, 04:14:15 PM

Try:

echo off
for /f "delims=" %%i in (file.txt) do echo. > %%i

or if you're running it from the command prompt,

for /f "delims=" %i in (file.txt) do echo. > %i


HEY! That was my 3000th post!!!

Anyway, BC, wouldn't "tokens=*" and "delims=" pretty much do the same thing?C:\batch>TYPE wonker.bat
Code: [Select]echo  off
setlocal enabledelayedexpansion
for /f  "delims=" %%i in (file.txt) do (
echo %%i
set newf=%%i
echo Turn off > "!newf!.txt"
dir "!newf!.txt"
)
Output:

C:\batch> wonker.bat
wonker
 Volume in drive C has no label.
 Volume Serial Number is F4A3-D6B3

 Directory of C:\batch

03/10/2010  05:28 PM                11 wonker.txt
               1 File(s)             11 bytes
               0 Dir(s)  298,567,569,408 bytes free
hope
 Volume in drive C has no label.
 Volume Serial Number is F4A3-D6B3

 Directory of C:\batch

03/10/2010  05:28 PM                11 hope.txt
               1 File(s)             11 bytes
               0 Dir(s)  298,567,569,408 bytes free
works
 Volume in drive C has no label.
 Volume Serial Number is F4A3-D6B3

 Directory of C:\batch

03/10/2010  05:28 PM                11 works.txt
               1 File(s)             11 bytes
               0 Dir(s)  298,567,569,408 bytes free

C:\batch>

Input:


C:\batch>type  file.txt
wonker
hope
works
C:\batch>thanks to all who replied from all your suggestions I tried the easiest looking one first and with a little modding got it working perfect I ended up using

for /f "tokens=*" %%i in (file.txt) do echo off> %%i

not that its that important for me at the moment but I have in past wanted to do same thing but to MAKE folders instead of files but used to have same problem with it creating new folder for each word so thought Id SEE if this would now work same for folders so I tried

for /f "tokens=*" %%i in (file.txt) do mkdir %%i

but this still made the folders for each word any ideas why that is?

Wrap it in quotes. Like this:

"%%i"brilliant had tried similar when trying to mod my original script for making files which DIDNT work so didnt try doing same again, but it worked on that one thanks so much for all your help this forum is great, get plenty of quick succesful responses. I'm just beginning with trying to learn some basics with making scripts and have got a few ideas of scripts I would like to create so no doubt you will here from me again within the next few days.
thanks again, James.
104.

Solve : what is wrong with this?

Answer»

what is wrong with this code

ECHO  off
setlocal enabledelayedexpansion
for /f  "delims=" %%a  %%b %%c in (test.txt) do (
set newf=%%a
set newf2=%%b
set newf3=%%c
md "!newf!
cd "!newf!
echo "!newf3!" > "!newf2!.txt"
cd..
)

input

test1 test tset
test2 teste etset
test3 tester retset

output nothing

desired output
3 folders called test 1-3
in each folder file called test.txt teste.txt tester.txt
in file tset.txt etset retsetA couple issues:
1. If delims is set to "" (nul) then there will be no other tokens.
2. Only the FIRST token name is said in the command.

This WOULD be your code:

echo off
setlocal enabledelayedexpansion
for /f "delims= " %%a in (test.txt) do (
md %%a
cd %%a
echo %%c > %%b.txt
cd..
)worked to a extent
file name is %b.txt
data is %cIt is.

%? on the command prompt is %%? in a batch file. (? being a single-letter wildcard)no the name of the file CREATED was %b etc.Oh, what a silly mistake. Here is the proper code.

echo off
setlocal enabledelayedexpansion
for /f "tokens=1-3 delims= " %%a in (test.txt) do (
md %%a
cd %%a
echo %%c > %%b.txt
cd..
)THANK youAny time!

105.

Solve : how to implement int 27h or the function 31h of int 21h??

Answer»

hello everyone,
         I wonder how to implement  INT 27h or the function 31h of int 21h,or you can tell me how they work.if you have the source codes of the functions ,PLEASE paste them or you can mail them to me.thank you.You mean the interrupt codes used in MS-DOS.
http://spike.scu.edu.au/~barry/interrupts.html
Are you writing in Assembly for a DOS? Which DOS?
And are you wanting to use BIOS interrupts?
http://en.wikipedia.org/wiki/BIOS_interrupt_call
The above link gives you the some information yhou need and refers to other placews for more information.

Quote

INT 27h
The recommended call instead of this ONE is INT 21h function 31h,

http://www.delorie.com/djgpp/doc/dpmi/api/310c01.html

Hope you know what your are doing.
This is like going into a very high class restaurant and you don't see the prices. If you have to ask you can't afford it. Before you try and use these low level functions your should already have a full understanding of what they do. Otherwise you computer will crash and burn.it sounds a little crazy,but I will try.Thank you.Well, here are some samples written in C.
http://www.freshersworld.com/Directory/codes.asp?cat=C&subcat=Terminate%20but%20Stay%20Resident%20%28TSR%29
106.

Solve : Need to merge .xls files into one file?

Answer»

Have MULTIPLE .xls files - need to merge into ONE file for upload for processing.
Would like to add CODE to .bat file if possible.

Thanks Quote from: lswain on March 12, 2010, 09:55:05 AM

Have multiple .xls files - need to merge into one file for upload for processing.
Would like to add code to .bat file if possible.

The FOLLOWING example is for .txt files:


Code: [Select]echo off

dir /b a*.txt  >  all_a.txt
echo HELLO merge > merge.txt

for /f "delims="  %%i in (all_a.txt) do (
echo %%i
type  "%%i"  >> merge.txt
)
type merge.txt
Quote from: greg on March 12, 2010, 06:53:37 PM
The following example is for .txt files:
have you tried doing that way for .xls files? Quote from: ghostdog74 on March 12, 2010, 07:05:22 PM
have you tried doing that way for .xls files?

I don't have any .xls files on my machine. 

Will the the Ghostdog demostrate how to merge the .xlm files?

Thanks for you help Ghostdog.

http://software.informer.com/getfree-view-xls-data-in-notepad/

http://www.monkeyjob.com/FileMonk/FAQ/Join-Merge-XLS-Files-Excel.htm
Quote from: greg on March 12, 2010, 11:06:20 PM
I don't have any .xls files on my machine. 

Will the the Ghostdog demostrate how to merge the .xlm files?

Thanks for you help Ghostdog.

http://software.informer.com/getfree-view-xls-data-in-notepad/


xls/xlm(whatever it is) are binary files. you can't just concat the files like that. the best/correct way is to use the application( in this case, excel) to join them together, either by hand, or by use of vbscripting. Quote from: ghostdog74 on March 12, 2010, 11:20:58 PM
xls/xlm(whatever it is) are binary files. you can't just concat the files like that. the best/correct way is to use the application( in this case, excel) to join them together, either by hand, or by use of vbscripting.

Please, give us an example.
107.

Solve : Dos command to get file from url?

Answer»

I am a beginner.I want to know that can we use any dos command to download some file from a url LIKE htm ,jpg file and had a speed result ?If write a batch file ,how can i do that wget, curl.Code: [Select]C:\>wget http://iso.linuxquestions.org/download/290/2792/http/distro.ibiblio.org/tinycore_2.9.iso
--2010-03-13 13:18:41--  http://iso.linuxquestions.org/download/290/2792/http/distro.ibiblio.org/tinycore_2.9.iso
Resolving iso.linuxquestions.org... 75.126.162.205
Connecting to iso.linuxquestions.org|75.126.162.205|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/2.x/release/tinycore_2.9.iso [FOLLOWING]
--2010-03-13 13:18:41--  http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/2.x/release/tinycore_2.9.iso
Resolving distro.ibiblio.org... 152.46.7.109
Connecting to distro.ibiblio.org|152.46.7.109|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: ftp://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/2.x/release/tinycore_2.9.iso [following]
--2010-03-13 13:18:41--  ftp://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/2.x/release/tinycore_2.9.iso
           => `tinycore_2.9.iso'
Connecting to distro.ibiblio.org|152.46.7.109|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /pub/linux/distributions/tinycorelinux/2.x/release ... done.
==> SIZE tinycore_2.9.iso ... 10604544
==> PASV ... done.    ==> RETR tinycore_2.9.iso ... done.
Length: 10604544 (10M)

100%[============================================================================================================>] 10,604,544   176K/s   in 70s

2010-03-13 13:19:54 (148 KB/s) - `tinycore_2.9.iso' saved [10604544]
THX for ghostdog74 and Salmon Trout,your info is very helpful for me ONE more question,if the pc can not ABLE  or no right to INSTALL the tools.Is that possible any default dos command to dot that ?THX

108.

Solve : "Bad command or file name" during system restore?

Answer»

I have an Emachine T2542 Desktop. I'm trying to do a complete restore using the Restore CD's that came with the computer. After inserting the disk, I reboot the computer and get the FOLLOWING:

System Restore Menu/ WIndows XP
1. Restore WIndows Xp
2. Boot to command prompt from CD-ROM

Please select 1 or 2: [1,2]? 2

No matter which one I select, I get "Bad command or file name"

A:\> <<(What do I type here?)

Whenever I type something in the provided space, I get the same message. Please help.Do you have a floppyThe computer has a floppy drive, but I don't have a floppy disk to restore the computer.if you have a blank floppy than download this file run it and let the computer boot from the floppy run restore from there
http://www.allbootdisks.com/downloads/Disks/Windows_98_Boot_Disk_Download49/Automatic%20Boot%20Disk/Windows98.exe how are you supposed to run a Windows XP restore from a Windows 98 Boot disk?that error message sounds like a missing command interpreter Quote from: mat123 on March 08, 2010, 06:05:19 PM

that error message sounds like a missing command interpreter

Well it's not. Windows NT doesn't have a command interpreter that is required for boot-up.

Quote from: tom97531 on March 07, 2010, 09:19:56 AM
Whenever I type something in the provided space, I get the same message. Please help.

type "dir" and report what it says.After typing "dir" I get a very long list "country, bug, display, etc." followed by

27 files   1,422,108 bytes
0 dirs          28,672 bytes free

Do I scrap mat123's idea about the floppy? Finally got a hold of one today but seems to be a bad disk. I can get more tomorrow.Try it again.
Do NOT use the number pad.
Use the numbers at the top of the keyboard.


"Use the numbers at the top of the keyboard."


Already tried that and just tried it again. Still get "Bad command or file name".I was guessing. Bad guess.
You said you can do the 'DIR' command, so the system is there and reads your keyboard OK.
Is there an AUTOEXEC.BAT file present?'
If so, Do this: (the purple letters.)
A:>type autoexec.bat
Also:
A:>type config.sys

Maybe  that will provide a clue.
 
dir with the P switch lets you use the spacebar to scroll thru all  the info...
Usage : dir /p Enter...
Following "type autoexec.bat":

(Missing some info off top of screen), then

:Restore

echo off
ghost -clone,mode=load,src=R:\T2542.gho,dst=1 -sure -ntil

cls

ECHO.

WINDOWS XP RESTORE COMPLETE
THE HARD DISK CONTENTS HAVE BEEN RESTORED.

** STORE THIS CD-ROM IN A SAFE LOCATION! **

ECHO REMOVE THIS CD ROM FROM THE TRAY AND PRESS ANY KEY TO REBOOT THE SYSTEM..

a:\EJECTCD.exe r:

pause
a:\Reboot.exe

goto exit

:exit

A:\>

Pressing any key does nothing


Following "type config.sys":

BUFFERS=20
FILES=60
DOS=HIGH,UMB
stacks=9,256
lastdrive=z
shell=a:\command.com a:\ /p
devicehigh=ansi.sys
devicehigh=oakcdrom.sys /D:GEMCD001
REM Uncomment4UK
rem devicehigh=display.sys con=(ega,,1)
rem country=044,850,country.sys
A:\>


Following "dir /p":

ANSI SYS 9,719
AUTOEXEC BAT 2,134
CHKDSK EXE 27,968
CHOICE COM 1,754
COMMAND COM 93,040
CONFIG SYS 242
COUNTRY SYS 30,722
DEBUG EXE 20,490
DISPLAY SYS 13,207
DOSKEY COM 15,495
EDIT COM 69,854
EGA CPI 58,870
EJECTCD EXE 8,603
EM_LOCK EXE 7,729
FDISK EXE 66,060
FORMAT COM 64,247
GHOST EXE 644,976
HIMEM SYS 4,768
IO SYS 116,736
KEYB COM 12,187
KEYBOARD SYS 34,566
MODE COM 29,239
MSCDEX EXE 25,473
MSDOS SYS 9
OAKCDROM SYS 41,302
REBOOT EXE 755
SYS COM 21,943

27 FILES 1,422,108 BYTES
0 DIRS 28,672 BYTES FREETry:
A:/>TYPE AUTOEXEC.BAT|MORE

This will show contents of AUTOEXEC.BAT file in the MORE utility, press spacebar to advance a screen's information, and enter to advance a line. Quote from: Veltas on March 11, 2010, 03:53:49 AM
Try:
A:/>TYPE AUTOEXEC.BAT|MORE

Says:

Write protect error writing drive A
109.

Solve : Help me in my Batch Script?

Answer»

I have a batch script which copies the targeted files from drives, for example if I want all .doc to be copied from C Drive it copies all, the THING is I need it to copy 20, or 10 files not full .doc from C drive.

Can anyone help me in this please.

Here is the code for the script.
Code: [Select]echo off
SETLOCAL EnableDelayedExpansion
set destfolder=D:\copiedjpegs
set searchdrive="C:\"
for /f "tokens=*" %%P in ('dir %searchdrive%*.doc /s /b') do copy "%%P" %Desktop% Quote from: akki15623 on March 12, 2010, 03:25:22 PM

. . . for example if I want all .doc to be copied from C Drive it copies all, the thing is I need it to copy 20, or 10 files not full .doc from C drive.


C:\batch>type akki.bat
Code: [Select]echo off
setLocal EnableDelayedExpansion
set /a c=0
set destfolder=E:\copydoc\

for /f "delims==" %%i in ('dir c:\*.doc /s /b') do (
echo %%~nxi
set /a c+=1

echo c=!c!
if !c! GTR 9  goto  end

copy "%%i" %destfolder%
)
:end
Output:

C:\batch>akki.bat
longshot.doc
c=1
        1 file(s) copied.
longshot.doc
c=2
        1 file(s) copied.
ls.doc
c=3
        1 file(s) copied.
winword.doc
c=4
        1 file(s) copied.
winword2.doc
c=5
        1 file(s) copied.
fractions.doc
c=6
        1 file(s) copied.
third.doc
c=7
        1 file(s) copied.
twothird.doc
c=8
        1 file(s) copied.
What is My IP Address.doc
c=9
        1 file(s) copied.
aarp081009.doc
c=10
C:\batch>


E:\copydoc>dir
 
 Directory of E:\copydoc

03/12/2010  06:18 PM              .
03/12/2010  06:18 PM              ..
10/23/2009  09:25 PM            20,480 fractions.doc
03/06/2005  09:59 PM             4,195 longshot.doc
03/06/2005  09:59 PM             4,195 ls.doc
10/23/2009  08:44 PM            24,576 third.doc
10/23/2009  08:45 PM            24,576 twothird.doc
10/20/2009  11:27 AM            24,064 What is My IP Address.doc
04/14/2008  06:00 AM             4,608 winword.doc
04/14/2008  06:00 AM             1,769 winword2.doc
               8 File(s)        108,463 bytes
               2 Dir(s)  139,440,300,032 bytes free

E:\copydoc>
Quote from: greg on March 12, 2010, 05:24:21 PM

C:\batch>type akki.bat
Code: [Select]echo off
setLocal EnableDelayedExpansion
set /a c=0
set destfolder=E:\copydoc\

for /f "delims==" %%i in ('dir c:\*.doc /s /b') do (
echo %%~nxi
set /a c+=1

echo c=!c!
if !c! GTR 9  goto  end

copy "%%i" %destfolder%
)
:end


Thanks Greg, you saved my day.
110.

Solve : How to change Start type in services using batch file.?

Answer»

Hi Everyone:
I Know how to stop service using batch file,

Code: [Select]NET STOP "IPOD Service"
but I don't know yet how to change Start type  from Automatic to MANUAL using batch.
Could you give me advice, please?


I am not aware of anyway to do this with batch code, but you can create a VBScript and have it run from the command prompt:

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

Set colListOfServices = objWMIService.ExecQuery _
  ("Select * from Win32_Service Where Name = 'iPod Service'")

For Each objService in colListOfServices
rc = objService.Change( , , , , "Manual")
Next

Save the script with a VBS extension. Run from the command line as: CSCRIPT scriptname.vbs

Good LUCK.  Type sc /? at a command prompt

or

Check this link:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sc.mspx?mfr=true

111.

Solve : BIOS/DPMS DOS and bootable disk not working ????

Answer»

Ok so today i downloaded LINUX, trying to install it on my pc. I burned it to a cd and ran it on my COMPUTER, i thought it was WORKING but DPMS DOS popped up....
My system will NOT run ANY BOOTABLE disks. Even manufactured. I checked my BIOS and made sure it was set for disk. i thought maybe it was my BIOS and thought of TRYING to REINSTALL it. Im running

Emachine, 2005

intel

t5026 model motherboard.
Sorry i also forgot. WHen the dpms dos loads, it comes up as    DR-A:\ |

112.

Solve : getting dos to read firewire device?

Answer»

Hi I've not made any progress with this endeavor. I am trying to get dos to run firewire 1394b devices. Here are the codes I have tried so far and the error messages when they load at the startup.

DEVICEHIGH=C:\HIMEM.SYS /testmem:off
DOS=HIGH,UMB
DEVICEHIGH=C:\OAKCDROM.SYS /D:mscd001
DEVICE=ASPIATAP.SYS /e/v
{IOMEGA SCSI TO ATAPI INTERFACE MANAGER}
"ADAPTER NOT PRESENT"
DEVICE=ASPI1394.SYS /int/all
{IOMEGA ASPI 1394 Firewire; V. 1.06}
"Cannot find valid scsi adapter for ASPI driver"
DEVICEHIGH=C:\EMM386.EXE /NOEMS
DEVICEHIGH=C:\SMARTDRV.EXE /DOUBLE_BUFFER
FILES=30
STACKS=0,0
BUFFERS=20
LASTDRIVE=Z

THERE IS NO RECIPROCAL CODE IN AUTOEXEC.BAT. DOES ANYONE CARE TO TRY TO HELP OUT AND MAYBE PROVIDE SOME SOLID FEEDBACK WITH THIS PROBLEM?See The 3rd Post Here...Ok, I went there and used those drivers and all I got was a black screen when I tried to run it. But it would be helpful to know why DOS complains with "Adapter not present" when I try to run the  ASPIATAP.SYS file. Is it because I don't have the controller driver installed in DOS?Most likely...yes. Quote from: patio on March 01, 2010, 01:40:30 PM

See The 3rd Post Here...
The drivers shown in the 6th Post are the only ones that work for me.
Sometimes it doesn't find the drive the 1st time, so I just reboot and it will find it the 2nd time.I have temporarily suspended the firewire-dos project because of unresolved issues with those drivers. I am now trying to use dos-usb configurations. I got the Panasonic drivers USBASPI.SYS and DI1000DD.SYS in the configuration menu. It detects my usb flash drive device as EHCI, but how do I assign it a drive letter so I can get DOS to access it?  I tried DI1000DD.SYS /dh but it just said 'invalid drive specification.' I want to be able to use DOS to copy my external IDE hard drive to the partition on my pc that dos doesn't reside in. When I am done, I want it to look like C:\DOS and D:\Win2K on the internal scsi drive. Of course it will have to be formatted with Fat32 as DOS won't read NTFS. I changed the bios reading from legacy floppy to FDD but it really didn't change anything. Help,  cause I am stymied again.

Here is the configuration I am using presently.

Device=C:\Dos\usbaspi.sys e/ w/
Devicehigh=C:\Dos\DI1000DD.SYS /df

Do I need a specific line in the autoexe.bat so it will provide a drive letter?config.sys

[Menu]
menuitem=1394, 1394 Firewire Mass Storage
menuitem=usbaspi, ASPI USB Mass Storage
menudefault=usbaspi, 30

[1394]
devicehigh=\DOS\himem.sys
devicehigh=\Drivers\aspi1394.sys /int /all
devicehigh=\Drivers\di1000dd.sys

[usbaspi]
devicehigh=\DOS\himem.sys
devicehigh=\Drivers\usbaspi0.sys /norst /v /w
devicehigh=\Drivers\di1000dd.sys

[common]
dos=high,umb
lastdrive=Z
_______________________________________ ______________________________
autoexec.bat not necessary.  "di1000dd.sys" provides the drive letter.

Well after some research, I made some useful discoveries. First, I was invited to include in a batch file various usb drivers. USBASPI0.SYS; USBASPI1.SYS; USBASPI2.SYS; USBASPI3.SYS; USBASPI4.SYS so DOS can cycle through each one and use the one it chooses. The second revalation comes in the knowledge that DOS will not open any drives that are larger than 2gig. Since my cloned hard drive is over 10gig, that option is dead. Maybe I'll just end up putting LinuxMint on the extended drive instead.  Quote from: PunkA on March 06, 2010, 02:21:29 PM
...DOS will not open any drives that are larger than 2gig....
I don't know where you got that "fact", but it's not true.  I have a 60GB USB drive and it works just fine with DOS 7 (Win98SE).  I also have a USB/1394 120GB combo drive using the same DOS version.Alright, I've been wrong before. So I decided to scrap MSDOS6.22 and install 8.0 that I found on the web in winimage. I guess I am just stubborn. If anyone wants the link, just let me know. I didn't realize that your hard drive size should not be larger than 2gig to load it. DOS 6.22 is FAT16, DOS 7.1 is FAT32; that explains it.
DOS 8 is from WinME, DOS7.1 is from Win95B, Win98, Win98SE
I wouldn't use anything from WinME.  WinME didn't use DOS.

http://www.ntfs.com/ntfs_vs_fat.htm
http://en.wikipedia.org/wiki/Comparison_of_x86_DOS_operating_systemsI suffer from the same affliction as Oscar Wilde. I can resist anything except temptation. I went copied the DOS 8.0 files to my C: drive. I would still like to be allowed to access my external hard drive with its fw interface. It gives me a choice of cd rom support at the start up. But no choice for a mouse pointer.

C:\Autoexec.bat

echo off
path=C:\Windows;C:\windows\command
\hibinv.exe
call \checksr.bat
IF "%config%"=="QUICK" Go To Quick
set EXPAND=Yes
set DIRCMD=/O:N
set Lg l Drv=27* 26 Z 25 Y 24 X 23 W 22 V 21 U 20 T 19 S 18 R 17 Q 16 P 15
set Lg l Drv=%Lg l Drv % O 14 N 13 M 12 L 11 K 10 J 9 I 8 H 7 G 6 F 5 E 4 D 3 C
cls
call setramd.bat %Lg l Drv%
set temp=C:\
set tmp=C:\
path %RAMD%:\;a:\;%path%;%CDROM%:\
copy command.com %RAMD%:\  >NUL
set comspec=%RAMD%:\command.com
copy extract.exe %RAMD%:\ >NUL
copy readme.txt %RAMD%:\ >NUL
:EXT
%RAMD%:\extract /y /1 %RAMD%: ebd.cab >NUL
echo The diagnostic tools were successfully loaded to drive %RAMD%.
echo,
IF "%config%"=="NOCD+ GOTO QUIT
IF "%config%"=="Help" GOTO HELP
LH %RAMD%"\::IF MSCDEX doesn't find a drive...
IF ERRORLEVEL 1 SET CDPROB=1
cls
call help.bat
::
GOTO QUIT
:QUIT
call fixit.bat
rem clean up environment variables
set CDPROB=
set CDROM=
set Lg l Drv=
GOTO QUICK
:QUICK

C:\Config.sys

[Menu]
menuitem=HELP, Help
menuitem=CD, Start computer with CD support.
menuitem=NOCD, Start computer without CD rom support.
menuitem=QUICK, Minimal boot.
menudefault=Help,30
menucolor=7,0
[HELP]
device=Oakcdrom.sys /D:mscd001
device=btdosm.sys
device=flashpt.sys
device=aspi2dos.sys
device=aspi8dos.sys
device=aspi4dos.sys
device=aspi8u2.sys
device=aspicd.sys \D:mscd001
devicehigh=ramdrive.sys /E 2048
[CD]
device=oakcdrom.sys /D:mscd001
device=btdosm.sys
device=flashpt.sys
device=btcdrom.sys
device=aspi2dos.sys
device=aspi4dos.sys
device=aspi8dos.sys
device=aspi8u2.sys
device=aspicd.sys /D:mscd001
devicehigh=ramdrive.sys /E 2048
[NOCD]
devicehigh=ramdrive.sys /E 2048
[QUICK]
[COMMON]
files=10
buffer=10
dos=high,umb
stacks=9,256
lastdrive=z
device=display.sys con=(ega ,,1)
country=044,850, country.sys
install=mode.com con cp prepare=((850)ega.cpi)
install=mode.com con cp select=850

There was not a mouse driver included with the copied boot disk files to the C: drive so is it possible to import a driver to have mouse support? Also DOS 8.0 created a D:\ drive for diagnostic tools called D:\ MS-RAMDRIVE. These are the files it displays in D:
ATTRIB.EXE
CHKDSK.EXE
COMMAND.COM
DEBUG.EXE
EDIT.COM
EXT.EXE
EXTRACT.EXE
FORMAT.COM
HELP.BAT
MSCDEX.EXE
README.TXT
SCANDISK.EXE
SCANDISK.INI
SYS.COM


And what about the matter of getting usb and firewire detection and assigning drive letters? Will aspi1394.sys, di1000dd.sys and usbaspi.sys, still do the trick here? At least now I have FAT32 interface going.
Quote from: Computer_Commando on March 07, 2010, 03:43:11 PM
WinME didn't use DOS.

Windows ME is still based on a DOS core exactly like windows 95, 98, and 98SE. MS just hid the option to boot into MS-DOS mode.

PunkA:

Um, and what exactly would you use mouse support for... you cannot use the mouse at the prompt, just within other programs.

I have no IDEA with regards to mouse drivers; I always use mouse.com included with DOS, but since MS never ACTUALLY released any version of DOS beyond 6.22 and they are in fact hacked versions of the boot disks that are created by windows I don't know  what would be included with them.Ok, so Mr. Billy Boy decided to X the bootable version. Does that mean a hack doesn't exit to override it so that it will boot from the hdd? I checked the format and somehow it was still formatted for FAT16. Don't know how that occurred but now I will use the system bios to change it to FAT32. Quote from: PunkA on March 09, 2010, 04:27:24 PM
Ok, so Mr. Billy Boy decided to X the bootable version. Does that mean a hack doesn't exit to override it so that it will boot from the hdd?
it's not a "hack"... it's two commands-

boot to the floppy and use:
Code: [Select]format C: /s
sys C:

Additionally what I was saying had nothing to do with legal issues or anything like that, necessarily- I was just pointing out the fact that what you are using is a boot disk, and only includes the "bare necessity" external commands- no surprise that mouse.com is not considered a necessity.




Quote from: PunkA on March 09, 2010, 04:27:24 PM
Don't know how that occurred but now I will use the system bios to change it to FAT32.

no you won't.



113.

Solve : errorlevel->help for batch file?

Answer»

I'm new to adding errorlevel logic into a BATCH file and looking for some help.

The script I have runs a few SQL COMMANDS via OSQL and want to be notifyied if one step fails (for one reason or another) and echo out the issue into a file and email me.

echo on
:Step 1
: Call Backup_Database.bat to shutdown PS environment
c:
CD c:\scripts\HR83RPT
ECHO Backing Database
CALL Backup_Database.bat
PAUSE

:Step 3
:use osql to kill any active user sessions
CD c:\scripts\HR83RPT
osql -S ZVMPSESQL01 -U sa -P squamish -i c:\scripts\HR83RPT\uspkill.txt >> c:\scripts\HR83RPT\HR83RPT_refresh.txt
echo User sessions have been terminated
PAUSE

:Step 4
:use isql COMMAND to KICK off refresh executing refresh script
CD c:\scripts\HR83RPT
echo Refreshing Database
isql -S ZVMPSESQL01 -U sa -P squamish -i c:\scripts\HR83RPT\HR83RPT.sql >> c:\scripts\HR83RPT\HR83RPT_refresh.txt
echo Database Refreshed

echo %DATE% %Time% >> c:\scripts\HR83RPT\HR83RPT_refresh.txt
PAUSE

:Step 6
:Send Refresh log
CD c:\scripts\hr83rpt
echo Sending Refresh log file
CALL Refresh_Log.cmd

:error

Currently Refresh_Log.cmd above sends a list of all actions performed above and mails out to me.

Appreciate replies.

114.

Solve : Batch file needed?

Answer»

Hi


         I am not familiar with batch commands. I need HELP from you guys to create a batch file.

I am USING some kind of tool that starts Building periodically every 5 mins if there are any new files or binaries placed in that folder.
Now I need a batch file that recognises latest binaries and triggers the build.
When the job is done, then it should inform the building tool that the binaries has been tested.

Thanks
cnu


Quote from: mukku on April 22, 2010, 03:48:17 AM


I am using some kind of tool that starts Building periodically every 5 mins if there are any new files or binaries placed in that folder.


What building Tool?  Post the batch file you have created.

The OS automatically  tracks the file's name, size and creation date when a file is placed in a folder.

Use the dir command  to display the information.


C:\>dir
 Volume in drive C has no label.
 Volume Serial Number is 0652-E41D

 Directory of C:\

04/16/2010  05:05 PM              1100
06/10/2009  04:42 PM                24 autoexec.bat
06/10/2009  04:42 PM                10 config.sys
04/16/2010  08:59 PM              LaserJet517
04/17/2010  07:17 AM              Office2003SP3Changes
07/13/2009  09:37 PM              PerfLogs
04/24/2010  05:30 AM              Program Files
04/16/2010  04:19 PM              Users
04/23/2010  06:41 PM              Windows
               2 File(s)             34 bytes
               7 Dir(s)  300,943,646,720 bytes free

C:\> Quote from: mukku on April 22, 2010, 03:48:17 AM
Now I need a batch file that recognises latest binaries and triggers the build.


C:\test>type buildlog.bat
Code: [Select]echo off

if  EXIST timefile*.txt  del timefile*.txt
dir >  folderlog.txt
rem  for four times add dir info to log each time interval ( command line arg %1 )
set /a c=0
:timer
if %c%==4 goto  end
set /a c=%c% + 1
time /t > timefile%c%.txt
sleep.exe %1
time /t >> timefile%c%.txt

dir >>  folderlog.txt

type folderlog.txt
goto timer
:end

C:\test>type timefile*.txt

timefile1.txt


02:42 PM
02:43 PM

timefile2.txt


02:43 PM
02:44 PM

timefile3.txt


02:44 PM
02:45 PM

timefile4.txt


02:45 PM
02:46 PM

C:\test>
Hi, Greg!
Quote from: Salmon Trout on April 24, 2010, 02:09:04 PM
Hi, Greg!

Not again...so bill, what PROXY are you using, SINCE you can't use your ISP to get on?I voted... Quote from: patio on April 24, 2010, 03:16:34 PM
I voted...

It's our duty!why is there a poll for this topic?I wanted to vote, but I had a problem. Two problems.
There were not enough choices.
The choices available were hard to discriminate
. Quote from: Geek-9pm on April 24, 2010, 07:05:06 PM
The choices available were hard to discriminate[/i].

I'm not helping you find your glasses this time, Mr. Magoo.
115.

Solve : Storing current directory into a variable?

Answer»

I'm WORKING on a concept script that requires me to save the current directory that the script is being run from in a varible to be used later:

Example

set variable = currdir
...
...(somewhere in here it will TRAVERSE to another directory)
cp somefile %variable%/required_subdirectoryif you need the current directory then use the CD variable.

Code: [Select]set currentdir=%CD%
grimbear, don't use spaces around the equals sign in batch.
Grimbear
You might like to check the 2 commands
PUSHD
POPD

PUSHD saves the current directory when you can go off an do other processing and POPD will then return you to where you started. Quote from: wbrost on April 22, 2010, 08:20:56 AM

if you need the current directory then use the CD variable.

Code: [Select]set currentdir=%CD%

Why do that when you can just use %CD%? Quote from: Helpmeh on April 23, 2010, 04:18:00 AM
Why do that when you can just use %CD%?

because they want to use the current directory at the time they retrieve it later on when it MAY no longer actually be the current directory?

gpl caught ONTO the possible requirement the OP was after- pushd and popd.
116.

Solve : find and findstr help?

Answer»
"find" does partly what I want, and "findstr" does partly what I want.  But neither one separately provides fully what I want to accomplish.

I want to count the occurrences of string1 in a text file output.txt, only if the string is at the beginning of the line.  I do not want to see the lines scroll on the screen, only the number of occurrences.

Then I want to count the occurrences of string2 in the same file output.txt, again only at the beginning of the line and displaying only the count.

Then I want to compare the two counts, either with a visual check on the screen or with the comp command if I chose to send the results to two text FILES.  If the two counts are the same, I am okay; if not, echo an error message.

Is there a WAY to pipe find and findstr together in one statement?

I can solve the problem with the following steps, but this seems like double work for each search:


findstr/b "string1" output.txt > count1.txt
findstr/b "string2" output.txt > count2.txt
find/c "string1" count1.txt
find/c "string2" count2.txt


Thanks in advance. Code: [Select]echo off

echo cat dog horse>output.txt
echo cat dog horse>>output.txt
echo cat dog horse>>output.txt
echo cat dog horse>>output.txt
echo man girl boy>>output.txt
echo man girl boy>>output.txt
echo man girl boy>>output.txt
echo man girl boy>>output.txt
echo dog man cat>>output.txt

set string1=cat
set string2=man

setlocal enabledelayedexpansion
set count1=0
set count2=0
for /f "delims=" %%L in (output.txt) do (
echo %%L | findstr /b "%string1%">nul && set /a count1+=1
echo %%L | findstr /b "%string2%">nul && set /a count2+=1
)

if %count1% equ %count2% (
echo Counts are equal
) else (
echo Counts are not equal
)

echo Occurrences of %string1% at start of line = %count1%
echo Occurrences of %string2% at start of line = %count2%
Code: [Select]Counts are equal
Occurrences of cat at start of line = 4
Occurrences of man at start of line = 4Thanks a lot.download grep for windows and then do this

Code: [Select]C:\test>TYPE file
cat dog horse
        cat dog horse
cat dog horse
 cat dog horse
 man girl boy
         man girl boy
man girl boy
man girl boy
dog man cat

if you want to display strings "cat" or "man" (data stolen from ST),
Code: [Select]C:\test>grep -E "^[[:SPACE:]]*(cat|man)" file
cat dog horse
        cat dog horse
cat dog horse
 cat dog horse
 man girl boy
         man girl boy
man girl boy
man girl boy

to search "cat" or  "man" at beginning and display count
Code: [Select]C:\test>grep -Ec "^[[:space:]]*cat" file
4

C:\test>grep -Ec "^[[:space:]]*man" file
4

to get total count
Code: [Select]C:\test>grep -Ec "^[[:space:]]*(cat|man)" file
8
Quote from: ghostdog74 on April 22, 2010, 05:34:24 PM
download grep for windows and then do this . . .

   

Or use wc -l.

C:\>type output.txt
cat dog horse
cat dog horse
cat dog horse
cat dog horse
man girl boy
man girl boy
man girl boy
man girl boy
dog man cat

C:\>findstr "^cat"  output.txt | E:\bin\wc -l
       4

C:\>findstr "^man"  output.txt | E:\bin\wc -l
       4

C:\>
117.

Solve : Batch to rename multiple files...?

Answer»

I have a number of folders named USING a yyyymmdd format, i.e., 20100419. 

Inside each folder I have anywhere from 40 to 75 files and the individual file names are used in nearly every folder.

What I need is a batch file that will prepend the folder name (20100419) followed by a PERIOD to the front of every file name in each folder.

Can anyone HELP? Quote from: NyteOwl on April 19, 2010, 01:01:01 PM

I have a number of folders named using a yyyymmdd format, i.e., 20100419. 

What I need is a batch file that will prepend the folder name (20100419) followed by a period to the front of every file name in each folder.

dir /b  > oldname.txt
C:\20100419>type newname.bat
Code: [Select]echo off
set /p fold=%1
for /f  "delims=" %%i in (oldname.txt)  do (
copy %%i  %fold%%%i )
rem rename  %%i  %fold%%%i
rem del %%i )
C:\20100419>newname.bat  20100419
20100419
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.

C:\20100419>dir
 Volume in drive C has no label.
 Volume Serial Number is 0652-E41D

 Directory of C:\20100419

04/24/2010  04:32 PM              .
04/24/2010  04:32 PM              ..
04/24/2010  04:06 PM                 9 20100419file1.txt
04/24/2010  04:06 PM                 9 20100419file2.txt
04/24/2010  04:06 PM                 9 20100419file3.txt
04/24/2010  04:06 PM                 9 20100419file4.txt
04/24/2010  04:07 PM                 9 20100419file5.txt
04/24/2010  04:06 PM                 9 file1.txt
04/24/2010  04:06 PM                 9 file2.txt
04/24/2010  04:06 PM                 9 file3.txt
04/24/2010  04:06 PM                 9 file4.txt
04/24/2010  04:07 PM                 9 file5.txt
04/24/2010  04:31 PM               139 newname.bat
04/24/2010  04:29 PM                55 oldname.txt
              12 File(s)            284 bytes
               2 Dir(s)  300,677,402,624 bytes free

C:\20100419>1. Hi Greg!
2. I think you need to READ the question again.
Thanks for the responses, but I got the job done with an inexpensive app called Rename Maestro. 
118.

Solve : Question about error handling in bat or command files?

Answer»

I have a PROBLEM with 1 of the command file but I don’t know how to fix it yet.
And here is the script that causes the problem
Assume I have many .sql script files and I want to run in DIFFERENT schema of some database.
The next statement will dump the script to a file call MyScripts.cmd and will run it when the process on line2 is done.
MyScript.cmd looks PERFECT but the process stopped after line2 and line3 and line4 were skipped.
Could you tell me why it skipped line 3 and 4?

Line1: Echo : Before create MyScript.cmd file > MyLog.log
Line2: for %%f in (*.sql) do DoA.cmd %%f
Line3: Echo : Ready to run my script file  > MyLog.log
Line4: MyScript.cmd
Quote from: jdang67 on April 26, 2010, 09:16:12 AM


Could you tell me why it skipped line 3 and 4?


if you want to come BACK after DoA.cmd use CALL.
119.

Solve : Command freeze??

Answer» HI all,
so windows 7 killed itself for the first time on my computer to the point where windows fails to start. After LOOKING around in the recovery options I was ABLE to get a command prompt up and running so
Hi all,
windows 7 killed itself for the first time on my computer to the point where windows fails to start. After looking around in the recovery options I was able to get a command prompt up and running and began to copy my files to an external drive.

The problem I'm having is that the command prompt will copy all of the files till it gets to a big file (around 123mb) where it will the freeze. It'll show the file it had attempted to copy and viewing the drive the file will actually be there, but after that it does nothing and doesn't allow input. I really have no idea what would cause this. I've switched out external drives and nothing changed.

Here's the code:  Xcopy documents h:\backup /s

any HELP would be awesome!!
Thanks!!!

--Chris

any help would be awesome!!
Thanks!!!
If your goal is trying to recover files, Why don't you do it an easier way. Boot the computer to another (GOOD) operating system, and use the other OP to copy your data.
One of the easiest is Barts PE.
http://www.nu2.nu/pebuilder/ Quote from: Orangedog22 on April 19, 2010, 12:40:03 PM

The problem I'm having is that the command prompt will copy all of the files till it gets to a big file (around 123mb) where it will the freeze.

Check your RAM.

Shutdown all startup programs not needed.  ( start ,run [ msconfig ], click startup and disable all programs not needed.   Buy more Ram?
120.

Solve : DOS login scripts for Windows XP?

Answer»

What I'm trying to do is use a .bat file to add or remove a LOGIN script to a local user account on WINDOWS XP. I'm looking for SOMETHING I can use to display a system warning message when a specific user logs into the local computer without having to go to Local Security Settings > Security Options > Interactive login: Message TEXT for users attempting to login. This option will display the same message for all users. Is there a way to CREATE a specific message as a .bat file and use another batch file to add and remove it from a local users account login script and not have it effect all users with the same message??

121.

Solve : Another thing.?

Answer»

Well, I have another question (and it might be to hard for examples).
But, in WoW, the characters speak certrain languages, but lets say that you HEAR it, but then again, don't know it, how would that work? A parser of sorts (or thats what the dudes who rigged it up called it).
And also, another question relating to the last one, how could I maybe say something to everyone around the character, instead of just to one person.This has exactly what to with Microsoft DOS?
I meant with a chat program in batch, I know, I probably should have written that -_-.This thread could be part of a "How to ask a question that NOBODY will bother to answer" guide.
Quote from: tommyroyall on April 24, 2010, 10:48:14 PM

I meant with a chat program in batch, I know, I probably should have written that -_-.
I designed a chat program which works over the internet, although there are not many features, you can send messages to anyone. Try using FTP...it works (depending on the host) quite well (as well as a batch file can be, that is). Quote from: Helpmeh on April 25, 2010, 02:51:12 PM
I designed a chat program which works over the internet, although there are not many features, you can send messages to anyone. Try using FTP...it works (depending on the host) quite well (as well as a batch file can be, that is).

So did I. (about 5/6 years ago) but mine used TCP/IP and worked LIKE an actual chat program by SENDING packets back and forth.

It only works on windows 9x and I'm too lazy to find out why. Or release it either. I don't even know if I still have it...
122.

Solve : my for command is not working?

Answer»

could someone please tell why this does not work

echo off
setlocal enabledelayedexpansion
for /F "tokens=1-3 delims=" %%a in (REG QUERY "hklm\software\microsoft\windows nt\currentversion" /v CurrentVersion) do (
if !%%c==! goto:eof
echo %%c >>ver.txt
)

single quotes needed around command STRING
What error message do you get?
Can you explain what this does?
Orr what you expect it to do?
Code: [Select]if !%%c==! goto:eof
Have you already tried it with echo on to see what is happening?Geek, did you see my post? Did you bother to read it?
Quote from: Salmon Trout on April 24, 2010, 05:20:01 PM

Geek, did you see my post? Did you bother to read it?
Sorry I was typing when you posted .
Why does it need the single quote?
What error message do you get?
Code: [Select]the system cannot find the file regCan you explain what this does?
Code: [Select]writes the version number to ver.txtOrr what you expect it to do?
Code: [Select]create a txt file called ver.txt with the windows version numberCode:
Have you already tried it with echo on to see what is happening?
this
Code: [Select]C:\Documents and Settings\admin-matthew\Desktop>setlocal enabledelayedexpansion


C:\Documents and Settings\admin-matthew\Desktop>for /F "tokens=1-3 delims=" %a i
n (REG QUERY "hklm\software\microsoft\windows nt\currentversion" /v CurrentVersi
on) do (
if !%c == ! goto A
 echo %c  1>ver.txt
)
The system cannot find the file REG.

C:\Documents and Settings\admin-matthew\Desktop>echo teste
teste

C:\Documents and Settings\admin-matthew\Desktop>pause
Press any key to continue . . .aahhhh!
THIS IS WAY OVER MY HEAD!
Code: [Select]Examples:

  REG QUERY HKLM\Software\Microsoft\ResKit /v Version
    Displays the value of the registry value Version

  REG QUERY HKLM\Software\Microsoft\ResKit\Nt\Setup /s
    Displays all subkeys and values under the registry key Setup

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>REG QUERY HKLM\Software\Microsoft\ResKit\Nt\Setup /s

Error:  The system was unable to find the specified registry key or val

C:\>
Code: [Select]echo off
setlocal enabledelayedexpansion
for /f "skip=4 tokens=1-3" %%a in ('REG QUERY "hklm\software\microsoft\windows nt\currentversion" /v currentversion') do (
  if !%%c==! goto:eof
  echo %%c >> ver.txt
)

A few notes:

The default delimiter is a space which is how the output is delimited. Overriding it with no delimiters defeats the purpose of the delims= parameter.

You need single quotes around a command in the for statement, and double quotes around parameters with embedded spaces (ie: windows nt).

Reg Query outputs lines which are not needed, easiest to skip over.

Good luck.  Quote from: Geek-9pm on April 24, 2010, 06:21:36 PM
aahhhh!
THIS IS WAY OVER MY HEAD!
Code: [Select]Examples:

  REG QUERY HKLM\Software\Microsoft\ResKit /v Version
    Displays the value of the registry value Version

  REG QUERY HKLM\Software\Microsoft\ResKit\Nt\Setup /s
    Displays all subkeys and values under the registry key Setup

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>REG QUERY HKLM\Software\Microsoft\ResKit\Nt\Setup /s

Error:  The system was unable to find the specified registry key or val

C:\>

That's not the issue. The issue is that in a FOR LOOP, to get the output of a command, you WRAP it in ', to use a string you use " and to get the output from a file you don't use any quotes.

An example of each:
Code: [Select]rem Command
for /f "tokens=3" %%c in ('findstr  /c:price^: item.txt') do (
     commands
     commands
)
Code: [Select]rem String
for /f "tokens=1,3-5" %%A in (this sentence is very long and will not have many parts displayed after) do echo %%A %%B %%C %%D
Code: [Select]rem File
rem The for loop will preform each task for as many lines are in the file, just like any
rem other type of output.
for /f "delims=," %%b in (filename.ext) do (
     echo %%b
)thank you SIDEWINDER Quote from: Sidewinder on April 24, 2010, 06:40:51 PM
Code: [Select]echo off
setlocal enabledelayedexpansion
for /f "skip=4 tokens=1-3" %%a in ('REG QUERY "hklm\software\microsoft\windows nt\currentversion" /v currentversion') do (
  if !%%c==! goto:eof
  echo %%c >> ver.txt
)


I cannot get the above code to run correctly. I'm using windows 7.


C:\test>type  matt2.bat
echo off
setlocal enabledelayedexpansion
for /f "skip=4 tokens=1-3" %%a in ('REG QUERY "hklm\software\microsoft\windows n
t\currentversion" /v currentversion') do (
  if !%%c==! goto:eof
  echo %%c >> ver.txt
)

C:\test>matt2.bat

C:\test>type  ver.txt
The system cannot find the file specified.

C:\test>

What file cannot be found?    I tested the code as given. 

Please help.The original code is so amazingly, awfully, ridiculously, mind-boggingly wrong that I grow suspicious. It reads like code that was designed by somebody who thinks that keywords and commands are like Lego bricks that can be snapped together to produce something that works, without the snapper having to do any thinking or learning. Alternatively it reads like a piece of working batch code that somebody has deliberately edited to introduce as many glaring errors as possible. Who would do that? Somebody who starts threads as one person as then jumps in as another with an "answer". A pathetic individual like Greg/Marvin/Bill?


echo off
setlocal enabledelayedexpansion
for /f "tokens=1-3 delims=" %%a in (REG QUERY "hklm\software\microsoft\windows nt\currentversion" /v CurrentVersion) do (

                  ^                                                                                 ^
              nonsense; 3 tokens when                                            commands here need single quotes
              the delims are the start and
              end of the line?

if !%%c==! goto:eof
       ^
    Mad IF test and strange mishmash of
    loop metavariable and delayed ordinary
    variable that does not even make sense
    and a crazy goto


echo %%c >>ver.txt
         ^
and APPEND the (never to appear) result to poor little ver.txt?

)


I presume the idea is to extract the NT major and minor version numbers. Maybe running the REG command at the prompt would have been a good starting point? Anyhow, it's all nonsense anyhow, I reckon. (See above)



Salmon Trout I just can't make for loops.


marvinengland the batch file takes a second to make the file
also it is going to say 6.1 not 7 Code: [Select]echo off
set commandstring='REG QUERY "hklm\software\microsoft\windows nt\currentversion" /v currentversion'
for /f "skip=2 tokens=1-3" %%a in (%commandstring%) do set versionstring=%%c
echo %versionstring%
if "%versionstring%"=="6.1" echo Windows 7
    Quote from: mat123 on April 24, 2010, 04:44:20 PM
Would someone please tell why this does not work.


C:\test>type ver617.bat
Code: [Select]echo  off
for /f "skip=1 tokens=1-4" %%i in ('ver') do (
echo %%k %%l
set ver61=%%i %%j %%k %%l
)
echo %ver61%
if "%ver61%"=="Microsoft Windows [Version 6.1.7600]" echo Windows 7
OUTPUT:

C:\test>ver617.bat
[Version 6.1.7600]
Microsoft Windows [Version 6.1.7600]
Windows 7
C:\test>
123.

Solve : Program Rescue?

Answer»

Program Rescue
Hello!
I am again compelled to address to you for the help. Unfortunately at Russian-speaking forums do not give attention to questions connected with MS DOS.
I have a program rescue, necessary for creation and use saving diskettes. But it it is obvious not full.
At its start, the program does not suggest to create saving a diskette as well as is written in its DESCRIPTION, and at once REQUESTS what area it is necessary to correct, and as the image for corrections is not present, the program does nothing.
I long searched for a full variant of this program on the Internet, but anything could not find.
Can be at somebody there is this program and can SEND to me to the electronic address. I will be very grateful.
Or somebody knows as to SOLVE such problem?
Operational system MS DOS 6.22.
It is possible for Windows 95.
I ask to excuse me for weak knowledge of English language.Программа спасательной
Hello!
Я опять вынужден обратиться к Вам за помощью. К сожалению, на русский язык форумов не обратить внимание на вопросы, связанные с MS DOS.
У меня есть программа спасения, необходимые для создания и использования экономии дискетах. Но это очевидно не полон.
На старт, программа не предлагает создать экономии дискете, а так, как написано в описании, и сразу же просит какой области необходимо исправить, и в качестве изображения для корректировки нет, программа не делает ничего.
Я долго искал полный вариант этой программы в Интернете, но ничего не могли найти.
Может быть на кого-то есть эта программа, и можете прислать мне на электронный адрес. Я буду очень признателен.
Или кто-то знает как решить такую проблему?
Операционная система MS DOS 6.22.
Вполне возможно, для Windows 95.
Прошу извинить меня за слабого знания английского языка.
Создать на русском языке и перевод на английский
HTTP://translate.google.com/

124.

Solve : MS DOS...?

Answer»

MS Dos means Microsoft disk operating system. it was developed by microsoft IBM.It was standed operating system.DOS is still a 16-bit  operating system.in markets a VERSION of DOS CALLED DR-OpenDOS that extends MS-DOS in significant ways...

thanks.... Quote from: frankken2 on May 21, 2010, 12:51:34 AM

MS Dos means Microsoft disk operating system. it was developed by microsoft IBM.It was standed operating system.DOS is still a 16-bit  operating system.in markets a version of DOS called DR-OpenDOS that extends MS-DOS in significant ways...


After MS DOS, Windows was invented and MS DOS is not used by most people.

There is a subset of the DOS commands available  under the COMMAND prompt (CMD) of windows.
The old MS Dos is not used.  And few people drive a Model-T  ford.

Only nerds  continue to use the old dos commands. Quote from: frankken2 on May 21, 2010, 12:51:34 AM
MS Dos means Microsoft disk operating system. it was developed by microsoft IBM.It was standed operating system.DOS is still a 16-bit  operating system.in markets a version of DOS called DR-OpenDOS that extends MS-DOS in significant ways...

thanks....

More news from frankken2... the sky is blue, and when it is not "night", contains a flaming orb called "the sun", and also (when it is "night") a gentler more silvery light called luna. Another interesting fact is that bears or orsos crap in the woods! The more discreet ones do their "business" behind a tree (or in front of it, depending on your point of view)

 

Plus a load of crap (not from bears or woods however) from Marvin LUNATIC. Is frankken2 Marvin?
Quote from: frankken2 on May 21, 2010, 12:51:34 AM
thanks....
Say What?

 Windows wasn't "Invented" either. it was written.What was the point to this thread?  If the OP had said something like how MS DOS was developed from QDOS (quick and dirty operating system) it might have added something than not everyone knows.

Otherwise, I agree with ST. Quote from: rthompson80819 on May 24, 2010, 04:57:37 PM
What was the point to this thread?

Good question..I BELIEVE frankken is asking for clarification of his statement...sounds like a homework question.

But to clarify:

MS-DOS(all the versions) were 16-Bit OSs.
Windows X.X, 95, 98, ME were 16-Bit/32-Bit Hybrids(Still based upon MS-DOS)
Windows NT, 2000, XP were pure 32-Bit OSs
Windows XP(64 Bit), Vista, 7 are pure 64-Bit OSs.
Frankken:

"Windows wasn't "Invented" either. it was written."

The point is it does not matter whether Windows was  written, created or invented.

The point is Windows replaced DOS as an improved Operating System.
125.

Solve : Need Help reading a date?

Answer»

Hi,
I need to FTP a file each day. The file comes from another program with today's date in the name. I can't change the name of the file so I need a way to have the name change each day in the batch file.

So lets say todays file is

06172010bob.txt
The next day is
06182010bob.txt

Any ideas on how to change the name in the script to add todays file name when FTP'n?

Thanks

This question, in one form or another has been asked and answered numerous times. If you are in a rush, you might save time by doing a forum search.

In the meantime we need to know the format of your system date. Please run
echo %date% from the COMMAND prompt window and post the result along with your batch file.

 Sorry if this has been covered. I think I over looked it.

My machine date is like this....

Fri 06/18/2010

The file I am FTP'n is named 20100618ABCD.txt

If the name was static I would be all set to send the files but with the change of the date each day I have to edit my batch to change the file name to the date.

Thanks for your help
Your posts are contradictory. One shows the dates in the file names as mmddyyyy and the other shows the file names as yyyymmdd.

This snippet is for the mmddyyyy format:
Code: [Select]echo off
setlocal enabledelayedexpansion
for /f "tokens=2" %%v in ("%date%") do (
  set today=%%v
  set today=!today:/=!


echo %today%

This snippet is for the yyyymmdd format:
Code: [Select]echo off
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
  set today=%%l%%j%%k
)

echo %today% 

Choose which snippet meets your needs. The today variable is set to the current date. You didn't post your batch file so I can't assist there but there may be problems with the FTP environment "seeing" the cmd shell environment variables.

Good luck.  Thank you.

What I am using for the batch file is really 2 files. The first is a batch file and the 2nd is a text file.

Xfer.bat
ftp -n -s:E:\ctftp\dataxfer.txt xxx.xxx.xxx.xxx
PAUSE



dataxfer.txt

user USERNAME password
put E:\ctftp\20100618ABCD.txt
rename 20100618ABCD.txt ack
bye

I need to see the text of the transfer and found this does it for me.

Thanks again!
Quote

Choose which snippet meets your needs. The today variable is set to the current date. You didn't post your batch file so I can't assist there but there may be problems with the FTP environment "seeing" the cmd shell environment variables.

Can you give me a hand with this? I posted what I am using now but it sounds like you have a better way to do things.

Thanks
Quote from: Spoiler on June 21, 2010, 12:06:25 PM
Can you give me a hand with this? I posted what I am using now but it sounds like you have a better way to do things.

Thanks


You give me way too much credit. If what you're are using works, then it's a success story. An alternative way would be to create the dataxfer.txt file on the fly.

Code: [Select]echo off
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
  set today=%%l%%j%%k
)

>  E:\ctftp\dataxfer.txt echo username password
>> E:\ctftp\dataxfer.txt echo put E:\ctftp\%today%ABCD.txt
>> E:\ctftp\dataxfer.txt echo ren E:\ctftp\%today%ABCD.txt ack
>> E:\ctftp\dataxfer.txt echo bye

ftp -n -s:E:\ctftp\dataxfer.txt xxx.xxx.xxx.xxx
del E:\ctftp\dataxfer.txt
pause

I couldn't determine if the ABCD part of the file name was static or CHANGED from day to day. The snippet may need further tweaks.

Good luck.  Howdy,

Thanks I will give it a try and see if it works out ok. The ABCD.TXT part of the file name stays the same. The only part of the file name that changes is the date.

Thanks again.

Quote
>  E:\ctftp\dataxfer.txt echo username password

I had to make a small change so it read echo user username password

Things work great now. Thanks again for your help!

126.

Solve : Running shortcut with target?

Answer»

I need to run a shortcut or program to load so I don't have to manually access it. The file I am using is a batch file to load all my start programs in the morning. I use /pause between each program to give each one time to load so I can easily show in what ORDER I open my programs if a issue arises. It helps to be consistent.

The only problem software I have is one that has something like this:

"C:\Program Files\program1.exe" /launch "Program 2"

How in the world can I get a batch file to load it? I would even be willing to make a short cut but the short cut gives that PLUS a separate "start in" folder.

Thanks all! Quote from: armymil on June 24, 2010, 06:52:49 AM


"C:\Program Files\program1.exe" /launch "Program 2"


I have not tested the following:

( Try a different placement to the quote symbols. )

1) "C:\Program Files\program1.exe  /launch Program 2"

or
2) Use Call instead of Start.  You might call a Label and not another batch.

Good Luck

:label
"C:\Program Files\program1.exe  /launch Program 2"
I tried them both. It didnt seem to work.

The program 1 is softgrid. The program 2 is software that LOADS from it. cd C:\Program Files\Microsoft Application Virtualization Client\
call "sfttray.exe" "Program 2"
pause


This solved issue. The call feature HELPED.
127.

Solve : Batch help: search for file in profiles, then delete?

Answer»

Hey there team...Newb to the forum...from my searching around it looks like a QUITE knowledgeable group...i've got 10+ yrs in the IT/IS field, but have never really had to script anything until now (except for back in college...i know i know...don't use it you lose it)

all PCs are XP Pro

i'm trying to get a batch going that will search for a *.mht file in every profile on the PC and delete it.  when i build the PCs for everyone, they have a MHT file that all the agents use and so i always save it to the all users desktop folder.  after a long run, they have recently updated the file and i need to replace it...so it needs to be deleted from the all users and actual user's profiles on the PCs...

i start off by having the batch create a txt file that has all the *.mht file locations and then i use the "for /f" command to delete the contents of the txt file, but it can't get anywhere because the file format of the txt file is C:\Documents and Settings\...and i can't get the txt file to create the path with " " around the path.  the reason i want it gone from only the DocSettings folder is that some of the agents have requested to still have a copy of the old file...i've instructed them to save it to another folder on their hd...so i don't want to have a blanket delete

is there something that i'm missing?  a simpler way to accomplish this?  i used the same method when i created a batch for deleting all the $*unin*$ files w/no probs but it was never forced to deal with paths with spaces...this seems simple enough but for some reason i'm pulling a blank...

Code: [Select]echo off
C:
cd "\Documents and Settings"
dir /b /s *.mht > oldAppGate.txt
for /F %%i in (oldAppGate.txt) do DEL /Q %%i

this is the content of "oldAppGate.txt":
C:\Documents and Settings\Agent1\Desktop\Application Gateway1 6-20-2010.mht
C:\Documents and Settings\All Users\Desktop\Application Gateway1 6-20-2010.mht

the command window states:
Could Not Find C:\Documents
Could Not Find C:\Documents

(and yes i'm deleting the updated file...its on my test PC )

thanks!
Hi
You got it right in the CD line, paths with spaces in need quotes, try this
Code: [Select]echo off
C:
cd "\Documents and Settings"
dir /b /s *.mht > oldAppGate.txt
for /F %%i in (oldAppGate.txt) do del /q "%%i"
Note the %%i is between quotes on the last linegpl...gotcha...will try that and report back.

thanks!
lvgpl...nope!  doesn't work...still the same result as initially reported in my first post

any other thoughts?
lvcould you post the code as you have it now ? It definitely should not give the same error -- the message
Could Not Find C:\Documents
is a dead giveaway, as it is stopping at the first spaceyes, because the txt file's info doesn't have " " around the path...so when it reads the file, it will stop at C:\Documents  which is what i thought you were trying to do with the " " around %%i...but it seems to not work...?

the only thing i changed was your suggestion to add " " around %%i...see below:

Code: [Select]echo off
C:
cd "\Documents and Settings"
dir /b /s *.mht > oldAppGate.txt
for /F %%i in (oldAppGate.txt) do del /q "%%i"

pause
What might be useful is to remove the echo off line
then each command line will be echoed so that you can see it - that might HELP narrow down the problemif any line in oldappgate.txt has a space or spaces then for /f will stop at the first one (since it is one of the default token delimiters) so you need to force the delimiters to be the start and end of the line with a "delims=" block. So try this...

Code: [Select]for /F "delims=" %%i in (oldAppGate.txt) do del /q "%%i"


doh
typical schoolboy error, sorry I missed that one! Quote from: Salmon Trout on June 23, 2010, 08:59:13 AM

if any line in oldappgate.txt has a space or spaces then for /f will stop at the first one (since it is one of the default token delimiters) so you need to force the delimiters to be the start and end of the line with a "delims=" block. So try this...

Code: [Select]for /F "delims=" %%i in (oldAppGate.txt) do del /q "%%i"



awesome...that did the trick!  thanks a ton!    Quote from: gpl on June 23, 2010, 09:09:33 AM
doh
typical schoolboy error, sorry I missed that one!
no biggie!  i haven't used For /F that much so i had been scratching my head all day on that one...i felt like i was going crazy...thanks for the help just the same!so i put this script out on a network drive and i had one of the users run it...but it gives an error that it doesn't like being run from a network drive...i don't get it...i tell it to start in C:\...what i'm eventually going to do is have this batch file run when someone logs in so that its done for everyone...is there something i need to call out so that it will run over the network?  or is this going to pose a problem for me?ok...so i ran this from my PC and it worked...yet the only difference is that i have it saved in a network drive that is actually MAPPED on my PC (but not mapped on the user's PCs, yet it is a shared folder on the server)

in order for this to work, does this batch file have to be in a mapped network drive instead of a shared folder on the network?

if i just copy/paste this directly into their logon script will i have the same problems and will their lack of admin/pwer user rights cause any problems for my script?
128.

Solve : are batch file writing different in windows xp and dos 7.1?

Answer»

when i run this BAT file in windows command prompt it works fine when i run it from dos 7.1 prompt i get syntex errors
anyone know why?
thanks
Code: [Select]echo off



:start
cls
echo Input password:

IF %DATE:~0,3%==Mon goto mond
IF %DATE:~0,3%==Tue goto tues
IF %DATE:~0,3%==Wed goto wedd
IF %DATE:~0,3%==Thu goto thur
IF %DATE:~0,3%==Fri goto frid
IF %DATE:~0,3%==Sat goto sate
IF %DATE:~0,3%==Sun goto sund


Quote from: flyhigh427 on June 24, 2010, 02:17:49 AM

when i run this bat file in windows command prompt it works fine when i run it from dos 7.1 prompt i get syntex errors
anyone know why?

Because it uses the NT command extensions, namely, those allowing string manipulation.is there a way for a batch file to tell the difference between windows command and older dos versions?
yes, in your batch script, you make a MANUAL effort to check the operating system the batch file is on. EG using ver etc.
But i will tell you a BETTER way to do things. Use a PROGRAMMING language like Perl or Python (or vbscript if you are a native guy) to do your scripting stuffs. Their syntax seldom change (much) across different platforms and software version.
129.

Solve : .bat tracking program!?

Answer»

hello again!!!
just want to monitor the files/folders in our server.
is there a .bat CODE to track if a file/folder was copied/opened/explored?
or some tips to identify if a file/folder was copied/opened/explored?
any suggestion??? Monitoring  and user notification of file creation, deletion, and MODIFICATION can be scripted with VBScript using the Windows Management Instrumentation (WMI) interface. Batch code simply does not have the functionality for this task.

The events you mentioned (copied/opened/explored) cannot be trapped. I guess Microsoft doesn't deem them worthy of notice. 

If you can use a VBScript, let us know and we'll see what we can WHIP up.

 

Quote from: night-rider on June 25, 2010, 04:25:45 AM

any suggestion???

Please avoid using multiple exclamation and question marks.
 
sorry!
oic!
then what will be the code then for vbs? Quote from: night-rider link=topic=106393.msg718370#msg718370 [img
[/img]date=1277250711]
hello again!!!
just want to monitor the files/folders in our server.
is there a .bat code to track if a file/folder was copied/opened/explored?
or some tips to identify if a file/folder was copied/opened/explored?

I am confused with that. Quote from: night-rider on June 26, 2010, 12:07:03 AM

sorry!
oic!
then what will be the code then for vbs?

Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceOperationEvent WITHIN 3 WHERE " _   
        & "Targetinstance ISA 'CIM_Datafile' and " _
            & "TargetInstance.DRIVE = 'c:' And "_
      & "TargetInstance.Path= '\\temp\\'")

Do
    Set objLatestEvent = colMonitoredEvents.NextEvent()
    'WScript.Echo objLatestEvent.Path_.Class & " " & objLatestEvent.TargetInstance.Name

    Select Case objLatestEvent.Path_.Class
      Case "__InstanceCreationEvent"
      WScript.Echo "File Created: " & objLatestEvent.TargetInstance.Name
      Case "__InstanceDeletionEvent"
      WScript.Echo "File Deleted: " & objLatestEvent.TargetInstance.Name
      Case "__InstanceModificationEvent"
      WScript.Echo "File Modified: " & objLatestEvent.TargetInstance.Name
    End Select
Loop

You can change the drive and path as required. Use double backslashes. The WITHIN clause defines the time interval between snapshots. Make it too small and the script will run too often. Make it too big and you may miss some events. For example if you set it to 20 and a file creation event and file deletion event for the same file occurs within the 20 seconds, the script will not notice any change between snapshots and will not report either of the events.

Save the script with a VBS extension. Run from the command prompt as cscript scriptname.vbs. Best to run with cscript; wscript will produce popup windows which can be very annoying. Script RUNS in a loop waiting for events to happen in the directory defined in the script. If using cscript, use CTL-C to terminate the script. If using wscript, use the task manager to terminate the script.

Good luck.
130.

Solve : Write a BATCH file to open a SSH Client?

Answer»

Hello Everyone!
I'm new to these forums/batch coding so please bare with me. I'm trying to write a BATCH script that will open several SSH clients. For instance, I would SSH to open three client windows (SERVER, server2, and server3). The username and passwords are the same for all three servers.

Is this possible? I know that the command "start SshClient" will open one window, but how can I make it so that it inputs the username and PASSWORD?

I'm ALSO curious as to what some of you are using to AUTOMATE your daily tasks. Everyday, I need to open several ssh windows and figured it would be easier if this process was automated.

Thanks for your help!Maybe try:

Start SSHclient username password

Worth a shot?

131.

Solve : Shortcut creator?

Answer»

Shortcut creator.

I would like to select with a click a folder, file, program ; and applying a key combination over that selection automatically CREATE a shortkey (direct access to that folder, file, program)  in another folder or place. Usually in the windows desktop.

Better is the key combination invokes a selection table with my shortcuts definible favorite folders.

I am trying to go FASTER that the usual way :

over the file , click right BUTTON - send to - windows desktop (shortcut)

Best Regards
Nobody knows ?
and this relates to cmd how? Quote from: mat123 on June 25, 2010, 05:47:43 PM

and this relates to cmd how?

Ouwww. I understand. It's not POSSIBLE with a cmd.

I abandon.

Best Regards
What about right click - DRAG to desktop (or other place) - release right mouse button - choose "create shortcut here" from the menu that will appear?
Quote from: Salmon Trout on June 26, 2010, 12:23:31 AM
What about right click - drag to desktop (or other place) - release right mouse button - choose "create shortcut here" from the menu that will appear?


Salmon. Ewemoa from donationcoder.com have made a marvellous script. I am trying to learn autohotkey (and a little batch too). As you know I am always in the best forum like Compute Hope.
 

A script to recognized windows open and create shortkeys for that windows.
A predefined set of path where to create the selected icons in a window and other options additonally.
Additionally definible hotkeys for fastest creation.

CreateShortCutsIn from Ewemoa.

Best Regards

132.

Solve : script runs every x hours everyday?

Answer»

Hi,

I was wondering if I can get some help here.

I am trying to write a vbscript that can perform file TRANSFER to an external hard drive that is attached to the PC directly. Also, I want this script to run every half an hour everyday. I am looking for some help from anyone who might be able to help me here.

PC runs on XP Pro.

Any help would be greatly appreciated.

Thank you in advance

schtasks  /?

SCHTASKS /parameter [arguments]

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

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 on demand.

    /End            Stops the currently running scheduled task.

    /ShowSid        Shows the security identifier corresponding to a scheduled task name.

    /?              Displays this help message.

Examples:
    SCHTASKS
    SCHTASKS /?
    SCHTASKS /Run /?
    SCHTASKS /End /?
    SCHTASKS /Create /?
    SCHTASKS /Delete /?
    SCHTASKS /Query  /?
    SCHTASKS /Change /?
    SCHTASKS /ShowSid /?
SCHTASKS.EXE /CREATE /?



SCHTASKS /Create [/S system [/U username [/P [password]]]]
    [/RU username [/RP password]] /SC schedule [/MO modifier] [/D day]
    [/M months] [/I idletime] /TN taskname /TR taskrun [/ST starttime]
    [/RI interval] [ {/ET endtime | /DU duration} [/K] [/XML xmlfile] [/V1]]
    [/SD startdate] [/ED enddate] [/IT | /NP] [/Z] [/F]

Description:
    Enables an administrator to create scheduled tasks on a local or
    remote system.

Parameter List:
    /S   system        Specifies the remote system to connect to. If omitted
                       the system parameter defaults to the local system.

    /U   username      Specifies the user context under which SchTasks.exe
                       should execute.

    /P   [password]    Specifies the password for the given user context.
                       Prompts for input if omitted.

    /RU  username      Specifies the "run as" user account (user context)
                       under which the task runs. For the system account,
                       valid values are "", "NT AUTHORITY\SYSTEM"
                       or "SYSTEM".
                       For v2 tasks, "NT AUTHORITY\LOCALSERVICE" and
                       "NT AUTHORITY\NETWORKSERVICE" are also available as well
                       as the well known SIDs for all three.

    /RP  [password]    Specifies the password for the "run as" user.
                       To prompt for the password, the value must be either
                       "*" or none. This password is ignored for the
                       system account. Must be combined with either /RU or
                       /XML switch.

    /SC   schedule     Specifies the schedule frequency.
                       Valid schedule types: MINUTE, HOURLY, DAILY, WEEKLY,
                       MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE, ONEVENT.

    /MO   modifier     Refines the schedule type to allow finer control over
                       schedule recurrence. Valid values are listed in the
                       "MODIFIERS" section below.

    /D    days         Specifies the day of the week to run the task. Valid
                       values: MON, TUE, WED, THU, FRI, SAT, SUN and for
                       MONTHLY schedules 1 - 31 (days of the month).
                       Wildcard "*" specifies all days.

    /M    months       Specifies month(s) of the year. Defaults to the first
                       day of the month. Valid values: JAN, FEB, MAR, APR,
                       MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC. Wildcard "*"
                       specifies all months.

    /I    idletime     Specifies the amount of idle time to wait before
                       running a scheduled ONIDLE task.
                       Valid range: 1 - 999 minutes.

    /TN   taskname     Specifies a name which uniquely
                       identifies this scheduled task.

    /TR   taskrun      Specifies the path and file name of the program to be
                       run at the scheduled time.
                       Example: C:\windows\system32\calc.exe

    /ST   starttime    Specifies the start time to run the task. The time
                       format is HH:mm (24 hour time) for example, 14:30 for
                       2:30 PM. Defaults to current time if /ST is not
                       specified.  This option is required with /SC ONCE.

    /RI   interval     Specifies the repetition interval in minutes. This is
                       not applicable for schedule types: MINUTE, HOURLY,
                       ONSTART, ONLOGON, ONIDLE, ONEVENT.
                       Valid range: 1 - 599940 minutes.
                       If either /ET or /DU is specified, then it defaults to
                       10 minutes.

    /ET   endtime      Specifies the end time to run the task. The time format
                       is HH:mm (24 hour time) for example, 14:50 for 2:50 PM.
                       This is not applicable for schedule types: ONSTART,
                       ONLOGON, ONIDLE, ONEVENT.

    /DU   duration     Specifies the duration to run the task. The time
                       format is HH:mm. This is not applicable with /ET and
                       for schedule types: ONSTART, ONLOGON, ONIDLE, ONEVENT.
                       For /V1 tasks, if /RI is specified, duration defaults
                       to 1 hour.

    /K                 Terminates the task at the endtime or duration time.
                       This is not applicable for schedule types: ONSTART,
                       ONLOGON, ONIDLE, ONEVENT. Either /ET or /DU must be
                       specified.

    /SD   startdate    Specifies the first date on which the task runs. The
                       format is dd/mm/yyyy. Defaults to the current
                       date. This is not applicable for schedule types: ONCE,
                       ONSTART, ONLOGON, ONIDLE, ONEVENT.

    /ED   enddate      Specifies the last date when the task should run. The
                       format is dd/mm/yyyy. This is not applicable for
                       schedule types: ONCE, ONSTART, ONLOGON, ONIDLE, ONEVENT.

    /EC   ChannelName  Specifies the event channel for OnEvent triggers.

    /IT                Enables the task to run interactively only if the /RU
                       user is currently logged on at the time the job runs.
                       This task runs only if the user is logged in.

    /NP                No password is stored.  The task runs non-interactively
                       as the given user.  Only local resources are available.

    /Z                 MARKS the task for deletion after its final run.

    /XML  xmlfile      Creates a task from the task XML specified in a file.
                       Can be combined with /RU and /RP switches, or with /RP
                       alone, when task XML already contains the principal.

    /V1                Creates a task visible to pre-Vista platforms.
                       Not compatible with /XML.

    /F                 Forcefully creates the task and suppresses warnings if
                       the specified task already exists.

    /RL   level        Sets the Run Level for the job. Valid values are
                       LIMITED and HIGHEST. The default is LIMITED.

    /DELAY delaytime   Specifies the wait time to delay the running of the
                       task after the trigger is fired.  The time format is
                       mmmm:ss.  This option is only valid for schedule types
                       ONSTART, ONLOGON, ONEVENT.

    /?                 Displays this help message.


marvin/greg/bill,

just tell the OP to type SCHTASKS /? on the command line. There's no need to reproduce the WHOLE output of SCHTASKS /? here. Its a waste of space, and doesn't solve anything.[quote="OP"I am trying to write a vbscript[/quote]

What part of "vbscript" don't you understand, BillRich?

133.

Solve : Change size of command prompt window?

Answer»

through batch program, How do i change / reduce the size of running command PROMPT WINDOW?

Thanks in advance!!
the MODE command

e.g.

CODE: [Select]MODE con: cols=80 lines=50Thanks a lot DEAR Salmon Trout !!
it WORKS great.

134.

Solve : cursor help!?

Answer»

is it possible to change the cursor everytime I run my .bat file?
thanks!Do you mean real MS-DOS or a Windows command window? If Windows, click the Properties icon in the top left corner and select Small, Medium or Large.

ms dos.
make it as .bat if possible? Code: [Select]You can write a short program to modify the MS-DOS cursor. One way to do this is by creating and executing a short Debug script.
The changes made are temporary in memory. Therefore, if the goal is to have the cursor altered at all times, it will be necessary to
insert a line in the AUTOEXEC.BAT file to call the cursor program on boot.

To change the appearance of the MS-DOS cursor, enter the following at the command prompt:

Command Prompt          Enter This
--------------          ----------

C:\>                    debug <press ENTER>
-                       a100 <press ENTER>
287E:0100               mov ah,01 <press ENTER>
287E:0102               mov cx,010n <press ENTER>  (n range=1-4)
287E:0105               int 10 <press ENTER>
287E:0107               int 20 <press ENTER>
287E:0109               <press ENTER>
-                       n C:\cursor.com <press ENTER>
-                       rcx <press ENTER>
CX 0000
:                       9 <press ENTER>
-                       w <press ENTER>
Writing 00009 bytes
-                       q <press ENTER>

C:\>


Changing the value of n (1-4) will RESULT in different appearances for the cursor, where n=4 is a large cursor.
thanks! I'll try that one.
what if the image of the cursor is the that will change? Quote from: night-rider on June 22, 2010, 05:55:23 PM

what if the image of the cursor is the that will change?

Please write that in English
Quote from: Salmon Trout on June 23, 2010, 12:05:33 AM
Please write that in English

I am GUESSING this is what he wants:

"What if I want the image of the cursor to change?"The DOS cursor is just another text character; usually a block or an underscore; it possible to configure how many PIXELS are lit on a row-byrow basis. There is no "image".
oopzzz! sorry for the wrong gramming^^
what if the image of the cursor is the one that will change?
sorry again!!! I was mistakened.
I THOUGHT CURSOR IS THE MOUSE POINTER???
commonly a ARROW image Quote from: night-rider on June 24, 2010, 03:24:07 AM
oopzzz! sorry for the wrong gramming^^
what if the image of the cursor is the one that will change?
sorry again!!! I was mistakened.
I THOUGHT CURSOR IS THE MOUSE POINTER???
commonly a ARROW image
Quote from: Salmon Trout on June 19, 2010, 12:43:47 AM
Do you mean real MS-DOS or a Windows command window?
any suggestion pls...You want to change the DEFAULT Windows cursor from an arrow to something else? Why?
to add unique feature everytime I run my system.Then get and install a cursor editor program, or look at the cursor options in Control Panel.
so there's no possibility to change it through a .bat code? RUNS ONLY WHEN I RUN MY .EXE
135.

Solve : HELP Batch File?

Answer»

Hello everybody,
I need your help with a batch file for my stage.
What im tryng do is the next:
____________________________________
if date/t equal 29-06-2010
execute a command  (example md "folder")
if not exit
____________________________________

I need this in .bat file, help me.

Thank you for all.if /i %date%==Tue 06/29/2010 md folder
exit Quote from: mat123 on June 28, 2010, 06:21:16 PM

if /i %date%==Tue 06/29/2010 md folder
exit
First off, that won't work, guaranteed. Improper syntax. Secondly, tendencia, we need to know what is printed EXACTLY on the SCREEN when you run echo %date% at the command prompt (cmd.exe). Quote from: tendencia on June 28, 2010, 06:17:37 PM

if date/t equal 29-06-2010
execute a command  (example md "folder")
if not exit


C:\test>type  tend.bat
Code: [Select]echo off

if  "%date%"=="Mon 06/28/2010" echo folder
if  "%date%"=="Mon 06/28/2010" md folder
date /t
rem Mon 06/28/2010

DIR folder
Output:

C:\test>tend.bat
folder
Mon 06/28/2010
  Directory of C:\test\folder

06/28/2010  07:55 PM              .
06/28/2010  07:55 PM              ..
               0 File(s)              0 bytes
               2 Dir(s)  294,527,905,792 bytes free

C:\test>
136.

Solve : change size of Notepad window?

Answer»

I am opening a notepad file from my batch file program,
but it opens in the full screen/in random size mode,
How do i set the notepad file to open in the required size only,

----
start c:\program_results.txt
----

Thanks in advance!! Quote from: Yogesh123 on June 25, 2010, 06:55:30 AM

I am opening a notepad file from my batch file program,
but it opens in the full screen/in random size mode,
How do i set the notepad file to open in the required size only,


Open only the notepad  window, right click on open spot of the taskbar and choose "Tile Windows VERTICALLY" ( Make sure only one window is open when you do the above.)

Windows will remember the window size your prefer for notepad.

Dear marvinengland,
the question is,
How do i restrict the size or set to the required size only?
Quote from: Yogesh123 on June 25, 2010, 07:20:42 AM
Dear marvinengland,
the question is,
How do i restrict the size or set to the required size only?


Control the Window   
 
--------------------------------------------------------------------------------
 
 <<<"You can control the location and size of a window with  the Title bar buttons,  (Win98, WinXP) or  (Vista) and by  dragging with your mouse. The shape of the mouse pointer tells you what action will take place when you drag. We have already used the  Vertical Resize on the taskbar. Here is a list to remind you of the possible shapes when resizing or moving.">>>

 http://www.jegsworks.com/Lessons/win/basics/step-controlwindow.htm



how to control this notepad window size using batch scripting,
Using command lineSet size and position with mouse, close Notepad.

Open Notepad

It remembers size and position
Dear Salmon Trout,
How to set the notepad window to the required size using command line/ batch scripting,

like setting the command prompt window using,
mode con lines=1
mode con cols=56Google for cmdow.exe
with start you can include mode so you can do just this, you shouldnt have to google a third party prog , I'm Unsure of the PROPER syntax but you can experiment with mode try typing mode 120,30 Quote from: dnthns87 on June 29, 2010, 07:31:08 AM
with start you can include mode so you can do just this, you shouldnt have to google a third party prog , I'm Unsure of the proper syntax but you can experiment with mode try typing mode 120,30

Mode can set the size of a command window, but how does that help you set the size of a Notepad window?

Quote
I'm Unsure of the proper syntax

Maybe you should have waited until you were sure?


yes,
I checked it,
MODE doesn't work to set notepad window size,

any other alternate pls... Quote from: Yogesh123 on July 02, 2010, 01:31:18 AM
yes,
I checked it,
MODE doesn't work to set notepad window size,

any other alternate pls...

Why does it matter?

You have been given several solutions.


Click the middle ICON at the top right to control window size. One click and the size is CHANGED.  Drag the the top left corner of the window to the size you need.

All  the suggestions given in this thread solve the window size problem.

Again, why does it matter?
Quote from: marvinengland on July 02, 2010, 06:49:17 AM
Again, why does it matter?

He wants to set the size directly from the batch file when notepad starts.

Quote from: BC_Programmer on July 02, 2010, 10:26:45 AM
"He wants to set the size directly from the batch file when notepad starts."

So, how does Yogesh123  set the notepad window size from a batch file? Quote from: marvinengland on July 02, 2010, 11:26:56 AM
So, how does Yogesh123  set the notepad window size from a batch file?

Quote from: Salmon Trout on June 29, 2010, 06:01:22 AM
Google for cmdow.exe

137.

Solve : Creating a password protect batch file with a batch file?

Answer»

Hey everyone, I'm fairly new at programming at everything, but I'm trying to learn, so bear with me.

I created a batch file, for fun, to shut down a computer in 60 seconds, but creates a text file and a second password protected batch file to ABORT the shutdown.

This is the code I've used.

Code: [Select]ECHO OFF
MODE CON: COLS=70 LINES=6
TITLE Shutdown - By Matt
START C:\Windows\System32\shutdown.exe -s -t 60 -c "Shutting Down"
ECHO Warning! Your computer will shutdown in 60 seconds! > shutdown.txt
ECHO. >> shutdown.txt
ECHO To abort, run the "abort" batch file on your desktop. >> shutdown.txt
ECHO echo off > abort.bat
ECHO MODE CON: COLS=20 LINES=5 >> abort.bat
ECHO title abort >> abort.bat
ECHO color 9B >> abort.bat
ECHO :Start >> abort.bat
ECHO cls >> abort.bat
ECHO set /p password="Password: " >> abort.bat
ECHO if "%password%"=="qwerty" goto :correct >> abort.bat
ECHO goto :Start >> abort.bat
ECHO :correct >> abort.bat
ECHO cls >> abort.bat
ECHO echo Password correct! >> abort.bat
ECHO C:\Windows\System32\shutdown.exe -a >> abort.bat
ECHO pause \nul >> abort.bat
ECHO exit >> abort.bat
START C:\Users\%USERNAME%\Desktop\shutdown.txt
COLOR 9B
ECHO.
ECHO --------------------------------------------------------------------
ECHO Run abort.bat and enter the password
ECHO Now press any key to delete the two files created by this batch file.
ECHO --------------------------------------------------------------------
ECHO.
PAUSE
DEL C:\Users\%USERNAME%\Desktop\shutdown.txt
DEL C:\Users\%USERNAME%\Desktop\abort.bat
EXIT
It shuts down properly, creates and opens the text file properly, but I run into problems with the second batch file.

This is the code it puts into the second batch file:

Code: [Select]echo off
MODE CON: COLS=20 LINES=5
title abort
color 9B
:Start
cls
set /p password="Password: "
if ""=="qwerty" goto :correct
goto :Start
:correct
cls
echo Password correct!
C:\Windows\System32\shutdown.exe -a
pause \nul
exit
The password portion of the file won't rune because it doesn't add Code: [Select]%password% into it.

Does anybody know of a way to make it add that into the second batch file, or a second way of writing a password command that will work?

Thanks,
- MattI wrote a complete explanation of why you had this result and how to avoid it BUT I had second thoughts. I deleted it. This sounds like a PRANK.


What do you mean a prank?

Please help me find a way to fix this? I'm just learning and created a file to test my knowledge.Solved Thanks to "mat123".

Thanks so much.

The solution was to put %%password%% instead of just %password%. Quote from: MattPwns on July 02, 2010, 02:13:15 PM

What do you mean a prank?

Please help me find a way to fix this? I'm just learning and created a file to test my knowledge.

A prank is where you put a script on somebody elses computer for a joke to see their alarm and surprise. So that you pwn them. (Your name tells me a lot)

Way to help a prankster mat123.
but, it would show them how to stop it...

I created this to test my knowledge as i said before, and now i am trying to find a wait for it to start automatically after 10 minutes or something.

Ill probably put a new batch file into the startup folder, and run wait command of some SORT then open this one.

Again bro, it's just for fun and personal USE.
138.

Solve : rename directory with wildcards?

Answer»

hi,
i've got directory with names like hello world_1, hello world_2, hello world_3, hello world_(n+1)

how do i move and delete these directories?Your title says "rename", and the body of your post says "move" and "delete". Which one of these three things do you want to do?
Quote from: nuttynibbles on July 01, 2010, 08:33:32 AM


I've got directory with names like hello world_1, hello world_2, hello world_3, hello world_(n+1)

How do delete these directories?


C:\&GT;rd /?
Removes (deletes) a directory.

RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path

    /S      Removes all directories and files in the specified directory
            in addition to the directory itself.  Used to remove a directory
            tree.

    /Q      Quiet mode, do not ask if ok to remove a directory tree with /S

C:\>dir  /AD  /s  Hello*

C:\>rd /S Hello*hey Salmon Trout,

im sorry, my bad.

i actually wanted to delete those files. but i assume deleting/rename or moving would be using similar approach.

one reason is because i wanted to rename the directory (hello world_1 to hello_world_1) before deleting. i thought it would be easier if i can delete a directory where the name has no spaces
hi marvinengland,

i tried rd /S hello* but it returns "The filename, directory name, or volume label syntax is incorrect."

remembering that the directory name has a space in between (hello world_1, hello world_2...)

i did a search that it says ms dos do not accept wildcard. Quote from: nuttynibbles on July 01, 2010, 07:13:53 PM
hi marvinengland,

i tried rd /S hello* but it returns "The filename, directory name, or volume label syntax is incorrect."

remembering that the directory name has a space in between (hello world_1, hello world_2...)

Use the dir command  and find the files  and then rd.  cd  to root  ( cd \ )

C:\test>cd \

C:\>

C:\>dir /AD /s  Ho*
 Volume in drive C has no label.
 Volume Serial Number is 0652-E41D

 Directory of C:\06-07-2010\JoanPic

01/02/2009  05:15 PM              HOLLEN Trip 2005
01/02/2009  05:15 PM              Hollen Trip 6 Mos
               0 File(s)              0 bytes


C:\>rd /s  "hello world"
hello world, Are you sure (Y/N)? y
The system cannot find the file specified.im sorry marvinengland but i dun quite UNDERSTAND your latest reply  Hi all,

i managed to delete the directories using a bat file with the following script:
Code: [Select]echo off
setlocal enableextensions enabledelayedexpansion
set /a "x = 1"
:while1
    if %x% leq 331253 (
    echo %x%
        rmdir "E:\hello world_%x%"
        set /a "x = x + 1"
        goto :while1
    )
endlocal Quote from: nuttynibbles on July 02, 2010, 04:08:32 AM
Hi all,

i managed to delete the directories using a bat file with the following script:
Code: [Select]echo off
setlocal enableextensions enabledelayedexpansion
set /a "x = 1"
:while1
    if %x% leq 331253 (
    echo %x%
        rmdir "E:\hello world_%x%"
        set /a "x = x + 1"
        goto :while1
    )
endlocal

excellent code.  Looks like code written by Sidewinder.
If you wrote the code, you did not need help.


Quote from: nuttynibbles on July 02, 2010, 04:08:32 AM
C:\test>dir /AD  /b  hello*
hello world1
hello world2
hello world3
hello world4

C:\test>type  nib.bat
echo off
set /a x=1
:while1
rem echo  "hello world%x%"
dir   "hello world%x%" | findstr  "hello"
rem rd  "hello world%x%"
set /a x=%x% + 1
if %x% LEQ 4 goto :while1

Output:

C:\test>nib.bat
 Directory of C:\test\hello world1
 Directory of C:\test\hello world2
 Directory of C:\test\hello world3
 Directory of C:\test\hello world4

C:\test>type  nib.bat
echo off
set /a x=1
:while1
rem echo  "hello world%x%"
rem dir   "hello world%x%" | findstr  "hello"
rd  "hello world%x%"
set /a x=%x% + 1
if %x% LEQ 4 goto :while1

Output:

C:\test> nib.bat
C:\test>dir hello*
 Volume in drive C has no label.
 Volume Serial Number is 0652-E41D

 Directory of C:\test

Directory  Not Found

C:\test>that seems to work but it takes almost ten minutes
this stops it after numeric folders no longer exist

echo off
setlocal enableextensions enabledelayedexpansion
set /a "x = 1"
:while1
    if %x% leq 331253 (
          echo %x%
        if not exist "E:\hello world_%x%\nul" goto exit
        rmdir "E:\hello world_%x%"
        set /a "x = x + 1"
        goto :while1
    )
:exit
endlocalOne LINE of code.

Code: [Select]for /f "delims=" %%D in ('dir /b /ad "hello world_*"') do rd /s /q "%%D"
139.

Solve : for loop deliminator question?

Answer»

can i have a for loop so every character is assigned a diffrent %%X
for ex
123456 becomes %%a=1 %%B=2 %%c=3 %%d=4 %%a=e %%f=6No you can't. The FOR command cannot separate a STRING into characters. If you let US know what you are TRYING to do somebody might be able to suggest a method, or were you just curious?
just curiousYou have to give the FOR command one or more "delimiters", to use when deciding when one token ends and the next one begins. Delimiters can bethe line start and end, one or more characters.

You could have "delims=." and then for could read a.b.c.d.e etc and separate them out into tokens.
You can insert the delimiters with one for statement and then parse the new string with another for statement. The question is why? Tokens as opposed to variables only live as long as the for loop. Seems like a lot of work for so little payoff.

Code: [Select]echo off

setlocal enabledelayedexpansion
set str=123456

for /l %%v in (0,1,5) do (
  set string=!string!!str:~%%v,1!-

 
for /f "tokens=1-6 delims=-" %%a in ("!string!") do (
  echo %%a %%b %%c %%d %%e %%f


I used a DASH (-) as the delimiter, but it is arbitrary. Just don't use any character that has special meaning in batch language.

Good luck.  You would need to know the string length in advance, and I am not sure what advantage putting the characters into loop metavariables would have over the ordinary sltring slicing methods. In essence the code above takes about 6 lines to slice the string into 6 characters just so you can... slice it into 6 characters.
Quote from: mat123 on June 26, 2010, 08:32:56 AM

can i have a for loop so every character is assigned a diffrent %%X
for ex
123456 becomes %%a=1 %%b=2 %%c=3 %%d=4 %%a=e %%f=6

as i have always suggested, if you want to do various programming tasks easily and productively, such as this one you mentioned, use a good programming language.

Example in Python
Code: [Select]# python
Python 2.6.2 (r262:71600, Aug 21 2009)
Type "help", "copyright", "credits" or "license" for more information.
>>> my_string="abcdefg"
>>> list(my_string)
['a', 'b', 'c', 'd', 'e', 'f', 'g']
>>>

Now you have all your individual characters separated. Easy isn't it?
140.

Solve : decompressed files automation?

Answer»

I have a huge amount of zip and rar files I need to reorganize.

I would like an interactive batch file for :


***** First rule ******
1. Scan a folder or drive to locate all rar and zip files that contains only a single folder, and unzip that compressed file in the same folder that the compressed file.
2. Delete the initial compressed file

Best Regards



You can search for a certain file type by using DIR

To Search out all .rar files in the current folder type dir /a *.rar /b to search out all .rar files in the current folder and all subfolders type dir /a *.rar /b /s. To Unzip / Decompress the files i RECOMMEND using 7Zip As it INCLUDES a command line tool, you can download it here www.7-zip.org, ID also recommend putting the hole thing in a for loop.

For /F "tokens=1*" %%a in ('dir /a *.rar /b /s') do (
      7z e "%%a%%b"
)


Okis.
Thank you very much.
The problem is extract and decide.

Best Regards

141.

Solve : no boot drive?

Answer»

Hello everyone, I just bought a dell 8300 from some one off the INTERNET and the computer was working fine when they showed it to me but when I got it home I tried to defragment the hard drive and it started so I leftr it alone when I came back to it it had a black screen and said no boot drive, it also said press f1 for help and f2 to view system, I kept trying to re-boot with no sucess Please HelpPossibly the hard drive has failed. I hope you didn't pay a LOT for it?
If it has a floppy drive, download a boot image from bootdisk.com *
You will need to run the program to unpack the files on to a floppy disk, now you should be able to start up the pc.

you may be able to run a check disk, or scan disk and repair it, but most likely you will have to beg, borrow or BUY a new disk - these are pretty cheap

If you have a WINDOWS installation disk, you should be able to boot from that too
good luck
Graham
* Im ASSUMING that as you are posting, you have access to another pc

142.

Solve : For Loop + Set Command need helps?

Answer»

Hi All,

Currently run a small project and need a bit help on the DOS programming.... Please advice!

Have a text file contain the following lines:
StrFile.txt
ABC12345:0000121
ABC12345:0000122
ABC12345:0000123
ABC22345:0012121
ABC22345:0021212
ABC32345:1212123
ABC32346:2123333
.....

Hope can transform it into:
ABC12345:0000121:0000122:0000123
ABC22345:0012121:0021212
ABC32345:1212123
ABC32346:2123333

======================================================
Set tmpString=
Set tmp=

FOR /F "tokens=1,2 delims=:" %%i IN (StrFile.txt) DO (
   if %%i EQU %tmp% (
      SET tmp=%%i
      SET tmpString=%tmpString%:%%j
   ) ELSE (
      ECHO %tmpString% >> output.txt
      SET tmp=%%i
      SET tmpString=%%i:%%j
   )
)  

after running this batch file, get an error result...... :-(
C:\>Group.cmd
C:\>Set tmpString=
C:\>Set tmp=
The syntax of the command is incorrect.
C:\>   if %i EQU  (

It seem something wrong with my For Loop.


It's not the FOR loop that is the problem, I would say the problem is more that you have not thought enough about the logic of the process that you want to do. ALSO (crucially) you do not KNOW enough about batch file syntax, mainly delayed expansion of variables. (Google it) But also how IF tests work.

It seems to me that what you want to is this:

process a text file laid out like this

a:1
a:2
a:3
b:1
b:2
c:3
d:2

etc

and you want to take all the lines with the same first part and make them into 1 line starting with the first part and then all of the second parts in order separated by colons thus

a:1:2:3
b:1:2
c:3
d:2

However your code is always going to fail, not because of the FOR command itself, but because the first time around the loop your VARIABLE %tmp% is going to be blank and the IF test is in the FORMAT IF v1 EQU v2. Because v2 expands to nothing the test becomes

IF v1 EQU

that is, no right hand side. This is a violation and caused your error.

you can avoid this by doing something like this

IF "v1" EQU "v2"

But it is always better to get the logic right before you start coding! It is no good having half an idea of how your script will work and hoping that it will get fixed in the editor! (This is the most IMPORTANT point in this post.)

You need to get the first line of the text file before you do any loop stuff. You can use set /p to get the first line.

The code below appears to do what you want.

Code: [Select]echo off
setlocal enabledelayedexpansion

REM you may not need this but
REM it seemed appropriate
if exist output.txt del output.txt

set /p firstline=<Strfile.txt
FOR /F "tokens=1,2 delims=:" %%i IN ("%firstline%") DO set token1=%%i&set token2=%%j
set buildline=%token1%:%token2%
set teststring=%token1%
FOR /F "skip=1 tokens=1,2 delims=:" %%i IN (StrFile.txt) DO (
   if %%i EQU !teststring! (
      SET buildline=!buildline!:%%j
   ) ELSE (
      ECHO !buildline!>>output.txt
      SET teststring=%%i
      SET buildline=%%i:%%j
   )

essentially the logic of the script is:

the input file has lines which follow the format part:part2. It is required, for each sequence of one or more lines starting with the same part1, to produce one line which starts with part1, then a colon, then however many part2s there are, separated by colons. The script would do something like this:

Look at the first line of the input file. Get part1 and part2 into separate variables. Start building the first output line using part1, a colon and part2.

Now, for each line after that, until the end of the input file is reached:

Get part1 and part2 into separate variables. Check if part1 has changed since the previously read input line. If it has not changed, add a colon and part2 to the output line. If part1 has changed, write the output line to the output file in append mode, and then start a new output line using the new part1, a colon and part2.
OP , get a good file processing tool like gawk (for windows), and use this one liner

Code: [Select]c:\> gawk -F":" "{a[$1]=a[$1]\":\"$2}END{for(i in a) print i a[i]}" file
ABC32346:2123333
ABC22345:0012121:0021212
ABC12345:0000121:0000122:0000123
ABC32345:1212123

Of course, if you have Perl/Python, they can do the job with ease as well.
I made a typo before.

essentially the logic of the script is:

the input file has lines which follow the format part1:part2. It is required, for each sequence of one or more lines starting with the same part1, to produce one line which starts with part1, then a colon, then however many part2s there are, separated by colons. The script would do something like this:

Look at the first line of the input file. Get part1 and part2 into separate variables. Start building the first output line using part1, a colon and part2.

Now, for each line after that, until the end of the input file is reached:

Get part1 and part2 into separate variables. Check if part1 has changed since the previously read input line. If it has not changed, add a colon and part2 to the output line. If part1 has changed, write the output line to the output file in append mode, and then start a new output line using the new part1, a colon and part2.They say pride comes before a fall - and I was so concerned with delivering a lecture that I didn't see that my code has one big flaw, namely that it only outputs a line when the first part of the input line changes. if an input file just consists of one line, or of multiple lines with the same first part, then it would never output anything. This should be a lesson to me. I will fix it it tomorrow. because we are just now going to watch a film, "Villa Amalia" with Isabelle Huppert. And drink some red wine.

Code: [Select]
Echo Off
Setlocal Enabledelayedexpansion
Set True=1
Set False=0
If Exist Output.Txt Del Output.Txt

Set /P Firstline=<Strfile.Txt

For /F "Tokens=1,2 Delims=:" %%I In ("%Firstline%") Do (
   Set Part1=%%I
   Set Part2=%%J
   )

Set Buildline=%Part1%:%Part2%
Set Teststring=%Part1%
Set Writeflag=%False%
Set Changed=%False%

For /F "Skip=1 Tokens=1,2 Delims=:" %%I In (Strfile.Txt) Do (
   Set Part1=%%I
   Set Part2=%%J
   If Not !Part1! Equ !Teststring! Set Changed=%True%
   If !Changed! Equ %True% (
      Echo !Buildline!>>Output.Txt
      Set Teststring=!Part1!
      Set Buildline=!Part1!:!Part2!
      Set Writeflag=%True%
      Set Changed=%False%
   ) Else (
      Set Buildline=!Buildline!:!Part2!
      Set Writeflag=%False%
   )
)
 
If %Writeflag% Equ %False% Echo !Buildline!>>Output.Txt

Echo.
Echo Input File:
Type Strfile.Txt
Echo.
Echo Output File:
Type Output.Txt
Echo.
Pause

here's my output

Code: [Select]C:\test>test.bat

Input File:
ABC12345:0000121
ABC12345:0000122
ABC12345:0000123
ABC22345:0012121
ABC22345:0021212
ABC32345:1212123
ABC32346:2123333

Output File:
ABC12345:0000121:0000122:0000123
ABC22345:0012121:0021212
ABC32345:1212123

ABC32346:2123333 is missing.. or what have i done wrong?Thanks Man!

Your guidance will be appreciated. Thank you!
Since I am not good at programing.... it took some time to understand the code...kekek

143.

Solve : batch file editing itself help.?

Answer»

Ok so I want to have a batch file on my computer that when run it copies all the files from one location to another as a form of backup.

I can easily accomplish this with xcopy and it's attributes. I then plan to have this batch file run via window's scheduled tasks.

My problem is that I want the batch file to only copy files and folders changed since the last time the batch file was run. I know I would use the /d:mm-dd-yyyy attribute to do this. The problem is I am having trouble wrapping my head around how to have the batch file edit itself to change the date it was last run. I was originally trying to have it overwrite itself with echo but the problem is that if I do that it will eventually run out...

How do I get a batch file to edit one little part of itself?

thanks, sharfUse schtasks  to schedule the batch file

C:>  schtasks  /?

for the options and directionssharf, you don't have to have the batch file edit itself. Just get it, after running xcopy, to write the date to a named text file in the same folder, overwriting the old version (if it is present) and then next time it is run it picks the previous run date from that file, and uses it for the xcopy command, and then writes the new date to that file, ready for the next time.

Ignore marvinengland who has (once again!) misunderstood the question.
Then what do I do to write/get the file?Or you could get a batch to REPLACE its own first line using FOR like this

Code: [Select]set DateAndTime=26/06/2010-21:14:00.31
echo off
set thisbatchname=%~nx0
echo old date and time %DateAndTime%
pause
echo set DateAndTime=%date%-%time%>newfile.txt
for /f "skip=1 delims=" %%L in (%thisbatchname%) do (
    echo %%L>>newfile.txt
    )
move /y "%thisbatchname%" "tempname.bat" & ren "newfile.txt" "%thisbatchname%" & del "tempname.bat"

Quote from: sharf on June 26, 2010, 02:00:24 PM

Then what do I do to write/get the file?

I do not know what your local date format is, but basically you can do it like this

Code: [Select]echo off

REM write
set today=%date%
echo %today%>old-date.txt

REM read
set /p olddate=<old-date.txt
echo the old date was %olddate%




Yeah...I'm not that fantastic at batch files...never DONE more than the basic stuff with them.

What I want is a batch file to do this:
It will be in local disk C: named backup.bat

Then...
Code: [Select]xcopy C:\ D:\ /D:06-25-2010/K/H/R/Y/E/V/S/Exclude:C:\Windows\
And that will be run every friday by task schedular. The problem is, I don't want it to waste time copying files that have already been copied and have not been changed since the last backup. This is why I want the batch file (or something else) to keep track of the date (which is in MM-DD-YYYY format) but I don't know how to go about doing this...I kind of understand what you said, can you explain it a little clearer in terms of my batch file?

Thanks a lot, sharfthis should work (note i have not tested this  )

Code: [Select]echo off
if not exist lastrun.txt goto copy
for /f "tokens=1-3" %%a in (lastrun.txt) do (
set OMM=%%a
set ODD=%%b
set OYY=%%c
)
set DD=%date:~7,2%
set MM=%date:~4,2%
set YY=%date:~10,4%
if %YY% LSS %OYY% goto exit
if %MM% LSS %OMM% if %YY% GTR %OYY% goto copy
if %MM% GTR %OMM% goto copy
if %MM% EQU %OMM% if %DD% GTR %ODD% goto copy
goto exit
:copy
echo.%MM% %DD% %YY% > lastrun.txt
xcopy C:\ D:\ /D:%MM%-%DD%-%YY% /K /H /R /Y /E /V /S /Exclude:C:\Windows\
:exit
exitlol it just tries to start and shuts down (after creating lastrun.text) which is blank.On its first run lastrun.txt won't exist so it will go to the :copy label, but it won't know the values of %MM% %DD% %YY% which are defined after the goto, so the /D: parameter wiull be blank so the xcopy command will crash


Quote
note i have not tested this

Indeed.

Does it every time though.Please show what you get when you type this at the command prompt

Code: [Select]echo %date%fixed it
Code: [Select]echo off
if not exist lastrun.txt goto copy
for /f "tokens=1-3" %%a in (lastrun.txt) do (
set OMM=%%a
set ODD=%%b
set OYY=%%c
)
set DD=%date:~7,2%
set MM=%date:~4,2%
set YY=%date:~10,4%
if %YY% LSS %OYY% goto exit
if %MM% LSS %OMM% if %YY% GTR %OYY% goto copy
if %MM% GTR %OMM% goto copy
if %MM% EQU %OMM% if %DD% GTR %ODD% goto copy
goto exit
:copy
set DD=%date:~7,2%
set MM=%date:~4,2%
set YY=%date:~10,4%
echo.%MM% %DD% %YY% > lastrun.txt
xcopy C:\ D:\ /D:%MM%-%DD%-%YY%/K/H/R/Y/E/V/S/Exclude:C:\windows\
pause
:exit
exit
Even "fixed" it still does the same thing.

When I echo date I get "Sun 06/27/2010"I am not SURE why you need all this stuff. I don't think it does anything USEFUL. In any case the %OMM% %ODD% %OYY% variables aren't actually used for anything.

Code: [Select]if %YY% LSS %OYY% goto exit
if %MM% LSS %OMM% if %YY% GTR %OYY% goto copy
if %MM% GTR %OMM% goto copy
if %MM% EQU %OMM% if %DD% GTR %ODD% goto copy
As the script stands, the first time it is run, lastrun.txt does not exist, so the batch writes todays' month, day and year values into lastrun.txt. Then it uses those same values (!) for xcopy's "copy files newer than" date. When it is run later, the lastrun.txt exists, and the earlier date is read, but is not used for anything.

Why don't you just create a starter lastrun.txt in Notepad, with a suitable date earlier than now, e.g.

06-25-2010

and save it in the folder where the batch script is

then just use this

Code: [Select]echo off
for /f "tokens=1-3 delims=" %%a in (lastrun.txt) do set lastdate=%%a
xcopy C:\ D:\ /D:%lastdate%/K/H/R/Y/E/V/S/Exclude:C:\windows\
set DD=%date:~7,2%
set MM=%date:~4,2%
set YY=%date:~10,4%
echo %MM%-%DD%-%YY%>lastrun.txt
144.

Solve : vbscript or powershell??

Answer»

HI all,

I have recently been INTRODUCED to scripting and was wondering, which would be more advantageous to learn?

I am AWARE that you can run vbscripts in powershell.

Thanks

VBSCRIPT is available from win9x. powershell is newer. what ever it is, learn both. Quote from: veloce77 on June 23, 2010, 09:25:56 AM

HI all,

I have recently been introduced to scripting and was wondering, which would be more advantageous to learn?

I am aware that you can run vbscripts in powershell.

Thanks



For me, Powershell is a lot easier to understand than VBScript. Plus, powershell is PROBABLY looking to replace a lot of the functions that batch/vbs stand for so newer technology is always good to learn.thanks for all responses guys
145.

Solve : Create a PDF File in FileMaker?

Answer»

I'm looking for DOS code to create a PDF in FileMaker

Any help will be very much appreciated!

Amram Chayim eirinbergWhat VERSION of FileMaker are you running? Quote from: Amram Chayim Eirinberg on JUNE 25, 2010, 05:14:20 AM

I'm looking for DOS code to create a PDF in FileMaker

Any help will be very much appreciated!

Amram Chayim eirinberg

C:\test&GT;type ab.bat
Code: [Select]echo off
"C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe"
C:\test>ab.bat
C:\test>
 
 marvin/bill/greg,
OP says "create", not read. ACROBAT reader, does not create PDF. it just enable you to read PDFS.marvin I appreciated your help, but as ghostdog74 said I need to "create" a PDF based on a FileMaker record. Quote from: macdad- on June 25, 2010, 05:55:06 AM
What version of FileMaker are you running?

macdad- I am using FileMaker11, Apparently there's a bug and you cannot create PDFs in FileMaker11 to be saved on a Network server.I found out that it isn't possible to create a PDF in FileMaker from command-line.Thanks macdad-
146.

Solve : batch file best for repeated text entry??

Answer»

I would like to use a hot key to ENTER the FOLLOWING code into a forum post message box.  Would a batch file be the way to do it?  If so, what is the code? 

Code: [Select][table  bgcolor=lightgreen width=600 height=300 style="border:5px double darkblue"][tr][td ][color=black]

my text here

[/color][/td][/tr][/table]
My objective is to EASILY use different backgrounds for my posts.  This code does work in other forums.  I didn't know if it would be inappropriate to use it here, so I didn't.

Batch wouldn't be the way to do it. I suggest getting a program called AutoHotkey.

For example, all you have to do is modify this code and save it as a .AHK file (after you've installed AutoHotkey).

;This code will insert text when you press WIN+Q
#q::
send LINE 1 {ENTER} ; {ENTER} creates a new line
send LINE 2 {ENTER}
send [TESTING] {Enter} ; Just watch what you put in between brackets (especially curly ones like { )
return

Double-Click the newly-created AHK file and when you're ready, press WIN+Q to ACTIVATE the commands.

147.

Solve : Organizing files by filename into separate folders?

Answer»

Any help on this issue would be greatly appreciated.  I have been running 100s of tests on a PRODUCT and the results end up in one folder.

The results are stored with the FILE name Test_Report["Part NUMBER"]["Time of test"]["Date of test"].html

I want to make a batch file that will organize the reports by part number into folders labeled with the part number and date.  The part numbers range from 6 numbers to a combination of letters, symbols and numbers up to 15 characters long. 

If you can help that would be awesome.is there any characters Part Number,Time of test, and Date of test


ex
Part Number-Time of test-Date of testJust those brackets

An example would be:

Test_Report[53010N0-10SD-00][6 15 11 AM][7 1 2010].htmlWill there ever be report files which have the same part number but different dates?
Yes that is possible, so the batch file will have to look at both the date and part number to SORT it properly.  I hadn't thought of that, thanks for bringing it to my attentionSo if these files existed

Test_Report[53010N0-10SD-00][6 15 11 AM][7 1 2010].html

Test_Report[53010N0-10SD-00][6 15 11 AM][6 30 2010].html

You would want them in 2 separate folders, called

53010N0-10SD-00 7 1 2010

and

53010N0-10SD-00 6 30 2010

is that right?

Any padding ( e.g. m d yyyy to mm dd yyyy) or desires about white space (e.g. convert to dashes?)

Yes that is exactly what I want. The same formatting of the date is fine. Maybe the date can be inside brackets to not get confused with the part number Code: [Select]echo off
setlocal enabledelayedexpansion
for /f "delims=" %%A in ('dir /b Test_Report[*.html') do (
set filename=%%A
for /f "tokens=1-4 delims=[]" %%B in ("!filename!") do (
set FolderName=%%C (%%E^)
if not exist "!FolderName!" md "!FolderName!"
     move "!filename!" "!foldername!"
)
)
echo All files processed
pause

Thank you so much! It WORKED like a charm.  You just saved me from manually sorting through 500+ files

148.

Solve : Any Real Tutorial for DOS/BATCH?

Answer»

Hello,
            first post in this forum: although i h' learn't a little bit of DOS and making bat files (still practicing/using in Virtual BOX): and its not too hard finding Tutorial's for BAT and DOS cmds.
           
    But i just wanted some pointers from experienced DOS Users a sure and quick method to learn making BAT and DOS cmds ( i know only a fraction of DOS cmd's ) i really want to learn to use the switches/parameters that are necessary for making BAT files.  Its would be a great help.
     
This command will transfer the batch file to the users startup folder where %username% is a username variable that the batch file will work out and all you have to do is change "file-name.bat to the name of your batch file

copy "file-name.bat" "%systemdrive%\users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"or

Code: [Select]
copy %0.bat "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup"


Which will actually work if the users profile folder is on another drive such as a second partition or a drive as well as in a networked environment where the profile folder is often mapped to a network drive.

Either way, it seems completely irrelevant to what the original post was requesting.


Floppyman: Personally, my first forays into batch were with MS-DOS 3.21 and a RELATIVELY ancient book "running MS-DOS" which thankfully was "updated and revised to include the new MS-DOS 3.21!". I've later learned there are versions of the book for DOS 5 and 6 as well by the same author- revisions, I imagine.

After that, it was simply building upon what I already knew- shortly after I was able to get a copy of DOS 6, and I learned about the various new command switches; for example, dir, in DOS 3.21, only had the /w switch, so it was quite a lesson to learn how to sort a directory listing based on filename- iirc something like "dir | sort /+16" which sorted starting at the 16-th COLUMN; but after they added the various /o (sorting) switches to DOS it became essentially a built-in feature. These new features were well documented in a small help program that DOS installed in C:\DOS- "help.exe" (or maybe it was help.com) whatever it was, it was a early text-based hypertext document that listed all the various commands and their syntax as well as config.sys commands (rather redundant today). Nowadays, as you noted, there are a lot of sites that are dedicated to documenting various batch tricks and tips. It still better to look through the actual /? help for each command though.  OK BC_Programmer: i guess their is no shortcut to it.
             PRACTICE and more practice is the only thing to get more acquainted with DOS and Batch.  It will take quite some time:

149.

Solve : Dos Print?

Answer»

Hi All,

This is Ravi, we are buy a NEW computer Hp COMPAQ make we are using dos print but that new system doesn't have LPT port, so i have purchased LPT to USB, and also LPT slot card and installed that but still i am facing the same problem, what can i do?

give me suggestion please Unfortunately, DOS does not SUPPORT USB.

But can you provide the following information:

The model of the computer.
The Operating System you are running.

Thank you,
Nick(macdad-)Why are you trying to print in DOS?  Do you have custom software?

How much do you need to print?

There are ways to print from DOS using USB connections.  Google DOS to USB connections.  But I've got to think there are other ways to do the same thing.Thanks for replay,

Model: Compaq Presario CQ3253IX P C.
Configuration: Intel\l Core 2 duo Processor 2.93/ 2 GB DDR3 Ram/
                       320 GB HDD/ DVD Writer/Compaq Key Board & Mouse/
                       18.5 “Compaq Monitor/ DOS.                                             
O S                : Widows XP S/P2
Software       : EX Next Gena ration.

Ex next Gena ration software is Accounts software we want only Dos Prints. Quote from: rthompson80819 on June 28, 2010, 09:53:28 PM

Why are you trying to print in DOS?  Do you have custom software?

How much do you need to print?

There are ways to print from DOS using USB connections.  Google DOS to USB connections.  But I've got to think there are other ways to do the same thing.

True their are USB drivers for DOS that can ALLOW for Printing over USB.

And I have found a DOS utility that can redirect the DOS printing from LPT to USB:
http://www.dos2usb.com/


Abbarla,

Is the printer you are printing to use a USB port or LPT port?Is the printer you are printing to use a USB port or LPT port?


Hi I am using USB Port..
150.

Solve : command prompt in WinfowsCE?

Answer»

how do you get a command prompt (or "DOS" window) in Windows CE 4.2, 5, and 6?
These are embedded systems, customized on devices during development, so a command prompt might not be available on all devices running the above versions.
I hope that someone has been able to get a command prompt, and could give details of the PROCEDURE and the device(s) on which that worked?
Also,  do you KNOW of a command reference for Windows CE?
sorry for typo in title, not sure how to correct it?Google for Windows CE 5.0 Command Prompt

This seems promising.

Good luck.I had googled the topic before starting the thread; what I'm focusing on here, is  how to get the command prompt as a user, from within an installed WinCE device , not a a programmer doing a build (if ever possible?)
I had READ on some threads that users were able to intercept the BOOT process and get some of that functionality, unfortunately it was in passing, not enough details and I did not have the chance to ask further about it then.
Hoping someone has done something like that; I know it may be dependent on the device so I'm interested to know which device it is possible on, and how to do it.  It won't be a PC on which WinCE runs in EMULATION; it will be a device on which WinCE was burned-in as the original OS: netbook, wifi tablet, GPS travel guide, etc.