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.

1201.

Solve : 6.22 format error?

Answer»

Does anyone know why I am getting this message?
I formatted with /B switch first to allocate room for the system files first then tried 3 times with /S to save system files to disk and keep getting this message.
What is going on here???How big is the partition size? Max partition size, 2 GB. Assuming the partition is not too big, then maybe the disk was already formatted and unformat information was saved at that time, leaving no room for a repeat.

Where it says "Proceed with format (Y/N)?", what happens if you answer "Y" to the question?

Try format c: /S /U

/U means "unconditional" which means you cannot later do an "unformat", which is rarely needed. 2047 mb.

There is no Un-format on the setup disk, I never heard of it and I didn't know you could.
Besides that, why would you, doesn't formatting a disk over-write anyway!?!

If Un-formatting a disk is possible, how do you do it, what does it do that a ZERO writer doesn't do?

I haven't tried to proceed yet because I don't want to mess up the hd.

I have tried to /S without /B first and still get the same message.

This is a brand new hd and I used the setup disk to create and format c: and install the os.
When I went to boot the machine up, it failed to load the os.
So, this is where/ how I ended up here. Can't get system files on hd to boot os.
Should I just copy the IO.sys and MSDOS.sys files from a: to c: or will that not work?

Thanks.
Unformat information is saved if you do FORMAT /S. It seems like you can't anyhow, so just do FORMAT /S

Anyhow, first try SYS C:

You say 'setup disk'. You only have one? MS-DOS install set is 3 disks.


I have all 4 floppy images from a single file I downloaded.
Microsoft MS-DOS 6.22 Plus Enhanced Tools (3.5).7z which has,
Disk 1 .img
Disk 2 .img
Disk 3 .img
Supplement disk .img

my guess by what you say "Anyhow, first try SYS C: " means it puts the system files on c: for you, idk.
SYS is used to copy the system files from one drive to another drive, allowing that drive to be bootable.

When running sys, the below files will be copied.

command.com
io.sys
msdos.sys
drvspace.binHi Noidly1

If this is a new disk as you say and you don't want anything on the disk ?

Then i would first run fdisk
Delete the partition if there is one on the drive
Create a new Fat16  partition. Dos 6.22 doesn't support Fat32.
Then install DOS from the 3 floppies

I think the error is coming from the Disk being partitioned in Fat 32 format.
 Wonders where DOS is from...Noidly1,
Most new personal computers will not let you boot  DOS 6.22 on a hard drive.
Can you provides information about how old that computer is?
Did it once have MS-DOS on it?
Thanks Salmon, I'll give that a try.

Lisa, I formatted it in FAT 16.

Geek, this is an older PC I built.
ASUS A8N32-SLI
Fastest AMD Dual core 939 socket available (I don't recall the model)
4- Patriot PEP1G3200LL sticks
2- GeForce 8800 Ultra cards
3- 250 gig IDE hd's
1 dvd-rw drive

This is the first time I have run across this problem and am confused as to why this is happening.

I have been messing with this thing over the years trying to build a gaming machine with the ability to multi os for tinkering. Also, I like win 95's defrag over the others.

I learned a while back that SLI does not work in 32bit and needed XP64, which I just found a copy of a couple of months ago.

If your wondering why I am still messing with XP, I am old SCHOOL and do not like the new "Tablet" style os's. If you could look at it this way, I prefer KDE over Gnome style os's... Win 8 and 10 suck *CENSORED*!!!

As for the multi os part, I want to have DOS 6.22, Win3.11, 95, 98SE, XP, XP64 and maybe Win7 along with a few Linux distros.

BTW, my experience with computers is building them, setting them up and running them for about 25 years now, not programming them. I don't know anything about "coding" and don't have the patience or time to tap on a key-board for hours on end. j/s...

Thanks.I also use Windows XP because I can can see better on some web sites if I am running XP and not Windows 10. Hard to understand why, but XP has many more options for ease of use.

A while back a relative gave me a free Gateway computer with Windows 10on it. So I thought I could just put XP on it and do the dual boot thing. I hare being doing dual boot for years, maybe 17 years or more. I don't remember.

Anyway, I found the Gateway BIOS stops me from using XP. Because XP wants MBR and yu have to fiddle with the BIOS to allow MBR on the boot drive.

The point is that at last  I found it in the BIOS stuff and turned off the security things that got in the way. But I had to re format the disk and install everything.
This kind of stuff was documented many years ago. About 2007 maybe.
https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-and-gpt-faq
Quote

Eventually, data density for disks became too large for the MBR scheme to account for all the available data locations. Also, the layout, or format, of the MBR was designed for early computers and not flexible enough to accommodate newer disk configurations. A new partitioning method was needed so the GUID Partition Table (GPT) partitioning scheme was created.
But older operating systems can not boot directly with the GPT. At least I have never heard of anyone doing it. To the best of my knowledge yu have to disable it in BIOS and format a hard drive for MBR. The yu can put an older OS on it and make it potable.

The other method is to run an older OS inside of virtual box in Windows 7.
This might be of interest:
https://www.makeuseof.com/tag/how-to-use-virtualbox/
Quote
VirtualBox is a piece of software published by Oracle. It allows you to EMULATE an operating system on your own PC and use it like it’s running on real hardware. You’ll discover tons of uses for virtual machines.
Do yu ever use Linux? Linux takes less drive space and can also run DOS in a virtual thing.
https://www.linux.com/learn/why-when-and-how-use-virtual-machineThe error in the OP occurs for the reasons it stated. It was unable to create a format recovery file.

Either the partition is not yet formatted or is not CURRENTLY formatted to FAT16.

Unformat information is saved so that the disk can be unformatted with the UNFORMAT external command, but that only applies if the original file system is FAT16, and possibly in specific other scenarios involving the current drive contents. If it is not you receive this error and prompt- You have not indicated (as far as I can see) what happens if you answer the prompt in the affirmative or use the /U switch that Salmon Trout suggested; considering from what you've stated the drive doesn't contain anything you would want I don't see a reason to be concerned that unformat information is not being saved.I here ya Geek.
The retail mobo is old school and has the regular cmos and bios and not the new fangled setup.
I had xp on it before on another hd and it worked without a hitch till the hd took a dump on me.

What I like about it is that it has a hd boot choice you can prompt with the F8 key at boot.
Also; I have used Ranish's boot manager and it works great.
Just setup each hd with it and use F8 at boot, select the drive, then select the partition and away you go.

If memory serves me right, I remember hearing a kid some years ago had, i think it was, 51 (Fifty One) OSes on one computer. I am only looking at a dozen...

BTW, I have several versions of Ranish where one of them lets you have more than 4 partitions but is kind of flaky and makes other partition software freak out so I don't use it.

I don't know anything about a GUID Partition Table (GPT), never used it.

I have run several Linux distro's and found Debian my fav so far. in kde of coarse...

BC,
I used the DOS6.22 setup disk to fdisk the drive and format it, correct partition size and format.
I haven't tried affirming it yet but will give it a try.
Like I said B4, I don't see an un-format on the setup disk and never had B4 and don't know why anyone would when you can just re-format it anyway. j/s...


If affirming it doesn't work, I'll go ahead and use the SYS c: and give it a whirl. OK, forget the GUID stuff.Old PCs don't have it.
If you think your MS-DOS disks are corrupt, toucan download from another source. Many sites have MS-DOS 6.22 for download.
The fdisk command will let you know that you can only have 2 GB for the boot partition.

I have a 500 GBdrive with MBR. I have Windows 10 do the boot up and I can select Windows XP, Windows 7 and Windows 10.
Also, I have a very small partition for DOS 6.22, but can not boot it. Instead I boot a CD with MS-DOS on it. That small partition has to be the first and it has to be primary.
On my old Dell 755 I hit the F12 at start up and it lets me select the CD drive. Of course, when in DOS I can not see the rest of the drive. And I don't want to. Quote from: Noidly1 on January 02, 2019, 06:30:35 PM
Like I said B4, I don't see an un-format on the setup disk and never had B4 and don't know why anyone would when you can just re-format it anyway. j/s...
UNFORMAT is not on the setup disk. It is on disk 2.

The purpose of UNFORMAT is to undo a format operation that was done by accident to a drive that contains data.



1202.

Solve : zero bytes files?

Answer»

This one is for my job but I will not get paid for that but it will make my life a bit easier for me so I will PAY from my money.
It is next thing, we have an old PC with some odl software on it. And that software stops to work every fev days or weeks. Nobody knows why and how.
So I made a script which check a presence of dat_9_2_2019_18_20.log file. If script finds out that file is 0 Size and it is present in folder c:\administrator\data\dat_9_2_2019_18_20.log than it send me an email so when I see email I go to basement and RESTART that old PC.
I asked my boss many times to buy new PC and new software but he refuse he said it is to expencive and this still works good and it is my job to go now or than to reset that pc.
So I get an idea.
I can run script by task scheduler to check if that file  dat_9_2_2019_18_20.log is present and its size is 0 bytes than it restart pc automatically.
Problem is that software did not stop to work everytime when one file with 0 bytes is present, but when fev of them are in that folder. Rebooting to often is not good, because it takes about 15-25 minutes to restart PC to  work again.
So I thought if I can have a script which will START in task scheduler every 30 minutes and check folder c:\administrator\data if there are for example 5 files  or more like these
dat_9_2_2019_18_50.log 0 bytes
dat_9_2_2019_19_30.log 0 bytes
dat_9_2_2019_20_43.log 0 bytes
dat_9_2_2019_22_10.log 0 bytes
dat_9_2_2019_23_25.log 0 bytes
and all of them are empty than pc will reboot automatically. But it can reboot only 3 times after that I get an email and script stops to reboot. until I check what is going on and delete COUNTER.txt file where script write number 3 which stops script to reboot after 3 times do that.
I already have script to send an email but this counting zero bytes files and reboot, that I can't manage to work it out.
In folder c:\administrator\data\ there is about 300 files and most of them are fev Kb and some are 0 bytes, those 0 bytes I usually delete and it can be all deleted or moved to another folder after script reboot PC. But those files fev KB must stay. Problem I also see here when one file (dat_9_2_2019_23_25.log 0 bytes) and right next after that file is another full file (dat_9_2_2019_23_50.log 10Kb), than that 0 bytes file should be deleted and counter.txt put to zero 0, or deleted, to star all over again. Because that means software still works ok.
so how much for this script?1. You want to delete ALL dat*.log files that are zero bytes in size?
2. or wait until there are >= 5 such files?
3. From folder c:\administrator\data\ ?
4. You say you want to reset counter.txt to "zero 0". What does that mean? You want that exact text? The word zero, then a space, then a figure 0?
5. Where is counter.txt located?

6. A good question to ask - why are all these zero byte files being created? is this caused when the software stops for an unknown reason?

7. It is not clear if you want the PC to reboot after the deletions.





1. You want to delete ALL dat*.log files that are zero bytes in size? Yes deleted or moved to new folder, one or other, with PC reboot.
2. or wait until there are >= 5 such files?  yes soure it should wait, to count files and when 5 of them is one after another.
3. From folder c:\administrator\data\ ? yes
4. You say you want to reset counter.txt to "zero 0". What does that mean? You want that exact text? The word zero, then a space, then a figure 0? in file counter.txt script will write just a number how many times PC reboots and when find number 3 it stops to reboot. So when I delete file or change number 3 in 0 than script works again and reboot if find 5 files with 0 bytes
5. Where is counter.txt located? doesn't matter it can be in  c:\administrator

6. A good question to ask - why are all these zero byte files being created? is this caused when the software stops for an unknown reason?
yes I notice that when software stops to work all those dat****.log files are created one by another

7. It is not clear if you want the PC to reboot after the deletions. when there are 5 files with 0 bytes than files can be deleted and imediatelly after that PC reboots. It doesn't need to reboot and after that files are deleted it can be deleted with rebooting.
Quote from: Blisk on February 10, 2019, 03:29:06 AM

and when 5 of them is one after another.

This means what?
Quote from: Salmon Trout on February 10, 2019, 05:02:09 AM
This means what?

it means 5 files are created one by another with zero bytes, like this
dat_9_2_2019_18_50.log 0 bytes
dat_9_2_2019_19_30.log 0 bytes
dat_9_2_2019_20_43.log 0 bytes
dat_9_2_2019_22_10.log 0 bytes
dat_9_2_2019_23_25.log 0 bytes

 that 5 files are deleted PC should reboot after that and counter will have number 1 in counter.txt

dat_10_2_2019_00_50.log 0 bytes
dat_10_2_2019_01_30.log 0 bytes
dat_10_2_2019_02_43.log 0 bytes
dat_10_2_2019_03_10.log 0 bytes
dat_10_2_2019_04_25.log 0 bytes

 that 5 files are deleted PC should reboot after that and counter will have number 2 in counter.txt

dat_10_2_2019_05_50.log 0 bytes
dat_10_2_2019_06_30.log 0 bytes
dat_10_2_2019_06_43.log 0 bytes
dat_10_2_2019_08_10.log 0 bytes
dat_10_2_2019_09_25.log 0 bytes

 that 5 files are deleted PC should reboot after that and counter will have number 3 in counter.txt
I get an email that something is wrong and script stop to reboot PC until I delete counter.txt or change number 3 in it to 0

it can be situation like this one
dat_5_2_2019_18_50.log 10 Kbytes
dat_5_2_2019_19_30.log 0 Kbytes
dat_5_2_2019_20_43.log 10 Kbytes
dat_5_2_2019_22_10.log 0 bytes
dat_5_2_2019_23_25.log 8 Kbytes

Files with 0 bytes should be deleted and counter.txt should have 0 in it

or like this one
dat_4_2_2019_18_50.log 10 Kbytes
dat_4_2_2019_19_30.log 11 Kbytes
dat_4_2_2019_20_43.log 10 Kbytes
dat_4_2_2019_22_10.log 0 bytes
dat_4_2_2019_23_25.log 8 Kbytes

File with 0 bytes should be deleted and counter.txt should have 0 in it

But, logically any five files, listed in time order, will be "created one after another". Quote from: Salmon Trout on February 10, 2019, 06:23:53 AM
But, logically any five files, listed in time order, will be "created one after another".
Every new file is created about every ~45 minutes from last created file
and yes you are rightYour comments please:

So this is what you want?

1. Before the first run, create counter.txt and write the value 0 in it.

2. Every 30 minutes the batch will
a.   Look at folder: c:\administrator\data\
   Count how many files are 0 bytes with this name pattern:

   dat_d_m_yyyy_hh_mm.log

   NOTE: the file name changes in number of characters, if day or MONTH is greater than 9?

   So we just use file mask dat_*.log

   Is that OK?

b.   if there are fewer than 5, just delete them, leave counter alone.
   if there are 5 or more, delete them, add 1 to counter, save to counter.txt,
   if new number is 3, something is wrong, send email (how??)
   if new number is 1,2, or 3, reboot computer.
   if number is greater than 3, do not reboot computer, you will manually reset after reading email.


Your comments please:

So this is what you want?

1. Before the first run, create counter.txt and write the value 0 in it.

2. Every 30 minutes the batch will
a.   Look at folder: c:\administrator\data\
   Count how many files are 0 bytes with this name pattern:

   dat_d_m_yyyy_hh_mm.log

   NOTE: the file name changes in number of characters, if day or month is greater than 9?

   So we just use file mask dat_*.log

   Is that OK? That is exactly what is should be.

b.   if there are fewer than 5, just delete them, leave counter alone. OK
   if there are 5 or more, delete them, add 1 to counter, save to counter.txt, OK
   if new number is 3, something is wrong, send email (how??)

bmail -s mail.myserver.com -f [email protected] -t [email protected] -h -a "Check PC software may not be working" -b "" -m .\path.txt

   if new number is 1,2, or 3, reboot computer. OK
   if number is greater than 3, do not reboot computer, you will manually reset after reading email.
and delete counter.txt or change number from 3 to 0


BmailI have made a script which generates a logfile, I have tried it (manually not scheduled) with 0, then 3, then 5,5,5 zero byte files. It is still rough, but you can see what it does. You will not really see "Script exit" after "Rebooting computer" because the reboot will exit the script. If the script starts and finds the counter is 3 it just exits, (because you saw the email last time, and are coming to fix).

I will just show the logfile now, tell me what you think.

10/02/2019 21:07:30.38 Started script 
10/02/2019 21:07:30.40 Count read from file: 0 
10/02/2019 21:07:30.60 Zero size files: 0
10/02/2019 21:07:30.60 Script exit
**************************************
10/02/2019 21:07:51.28 Started script 
10/02/2019 21:07:51.30 Count read from file: 0 
10/02/2019 21:07:51.47 Zero size files: 3
10/02/2019 21:07:51.63 0 bytes dat_2019_02_10_21_07_39.log
10/02/2019 21:07:51.64 0 bytes dat_2019_02_10_21_07_40.log
10/02/2019 21:07:51.64 0 bytes dat_2019_02_10_21_07_42.log
10/02/2019 21:07:51.66 Deleting 3 0 byte files
10/02/2019 21:07:51.82 Rebooting computer
10/02/2019 21:07:51.83 Script exit
**************************************
10/02/2019 21:08:20.46 Started script 
10/02/2019 21:08:20.47 Count read from file: 0 
10/02/2019 21:08:20.71 Zero size files: 5
10/02/2019 21:08:20.88 0 bytes dat_2019_02_10_21_07_58.log
10/02/2019 21:08:20.89 0 bytes dat_2019_02_10_21_08_00.log
10/02/2019 21:08:20.91 0 bytes dat_2019_02_10_21_08_01.log
10/02/2019 21:08:20.92 0 bytes dat_2019_02_10_21_08_02.log
10/02/2019 21:08:20.94 0 bytes dat_2019_02_10_21_08_03.log
10/02/2019 21:08:20.97 Deleting 5 0 byte files
10/02/2019 21:08:21.16 Found 5 or more files
10/02/2019 21:08:21.17 Count increased to 1
10/02/2019 21:08:21.21 Rebooting computer
10/02/2019 21:08:21.22 Script exit
**************************************
10/02/2019 21:08:46.24 Started script 
10/02/2019 21:08:46.27 Count read from file: 1 
10/02/2019 21:08:46.46 Zero size files: 5
10/02/2019 21:08:46.63 0 bytes dat_2019_02_10_21_08_30.log
10/02/2019 21:08:46.65 0 bytes dat_2019_02_10_21_08_32.log
10/02/2019 21:08:46.66 0 bytes dat_2019_02_10_21_08_33.log
10/02/2019 21:08:46.68 0 bytes dat_2019_02_10_21_08_34.log
10/02/2019 21:08:46.69 0 bytes dat_2019_02_10_21_08_35.log
10/02/2019 21:08:46.72 Deleting 5 0 byte files
10/02/2019 21:08:46.93 Found 5 or more files
10/02/2019 21:08:46.94 Count increased to 2
10/02/2019 21:08:46.96 Rebooting computer
10/02/2019 21:08:46.99 Script exit
**************************************
10/02/2019 21:09:12.14 Started script 
10/02/2019 21:09:12.14 Count read from file: 2 
10/02/2019 21:09:12.34 Zero size files: 5
10/02/2019 21:09:12.53 0 bytes dat_2019_02_10_21_08_56.log
10/02/2019 21:09:12.54 0 bytes dat_2019_02_10_21_08_57.log
10/02/2019 21:09:12.56 0 bytes dat_2019_02_10_21_08_58.log
10/02/2019 21:09:12.57 0 bytes dat_2019_02_10_21_09_00.log
10/02/2019 21:09:12.59 0 bytes dat_2019_02_10_21_09_01.log
10/02/2019 21:09:12.61 Deleting 5 0 byte files
10/02/2019 21:09:12.79 Found 5 or more files
10/02/2019 21:09:12.81 Count increased to 3
10/02/2019 21:09:12.82 Sending email
10/02/2019 21:09:12.86 Script exit
**************************************
10/02/2019 21:20:22.67 Started script
10/02/2019 21:20:22.67 Count read from file: 3
10/02/2019 21:20:22.70 Counter was 3 or more
10/02/2019 21:20:22.73 Script exit
**************************************
this one will be good only in this situation
10/02/2019 21:07:51.28 Started script
10/02/2019 21:07:51.30 Count read from file: 0
10/02/2019 21:07:51.47 Zero size files: 3
10/02/2019 21:07:51.63 0 bytes dat_2019_02_10_21_07_39.log
10/02/2019 21:07:51.64 0 bytes dat_2019_02_10_21_07_40.log
10/02/2019 21:07:51.64 100 bytes dat_2019_02_10_21_07_41.log
10/02/2019 21:07:51.64 0 bytes dat_2019_02_10_21_07_42.log
10/02/2019 21:07:51.66 Deleting 3 0 byte files
10/02/2019 21:07:51.82 not Rebooting computer
10/02/2019 21:07:51.83 Script exit

in this case
10/02/2019 21:07:51.28 Started script
10/02/2019 21:07:51.30 Count read from file: 0
10/02/2019 21:07:51.47 Zero size files: 3
10/02/2019 21:07:51.63 0 bytes dat_2019_02_10_21_07_39.log
10/02/2019 21:07:51.64 0 bytes dat_2019_02_10_21_07_40.log
10/02/2019 21:07:51.64 0 bytes dat_2019_02_10_21_07_42.log
10/02/2019 21:07:51.66 not Deleting 3 0 byte files
10/02/2019 21:07:51.82 not Rebooting computer
10/02/2019 21:07:51.83 Script exit

script should leave zero bytes files and next time it runs if there is more zero files like this than it delete and reboot.

10/02/2019 21:08:20.46 Started script
10/02/2019 21:08:20.47 Count read from file: 0
10/02/2019 21:08:20.71 Zero size files: 5
10/02/2019 21:08:20.88 0 bytes dat_2019_02_10_21_07_58.log
10/02/2019 21:08:20.89 0 bytes dat_2019_02_10_21_08_00.log
10/02/2019 21:08:20.91 0 bytes dat_2019_02_10_21_08_01.log
10/02/2019 21:08:20.92 0 bytes dat_2019_02_10_21_08_02.log
10/02/2019 21:08:20.94 0 bytes dat_2019_02_10_21_08_03.log
10/02/2019 21:08:20.97 Deleting 5 0 byte files
10/02/2019 21:08:21.16 Found 5 or more files
10/02/2019 21:08:21.17 Count increased to 1
10/02/2019 21:08:21.21 Rebooting computer
10/02/2019 21:08:21.22 Script exit

if script find only 3 zero bytes files than it should leave it so next time it runs if there is 5 files of zero bytes than reboot computer, but if one of last 5 files is full and is not empty than it should delete zero bytes files and reset counter to 0counter = 0
no zero byte files


12/02/2019 20:23:13.24 Started script
12/02/2019 20:23:13.26 Count read from file: 0
12/02/2019 20:23:13.46 Zero size files: 0
12/02/2019 20:23:13.49 No 0 bytes files found; exiting
12/02/2019 20:23:13.52 Script exit
**************************************

Counter = 0
3 zero byte files


12/02/2019 20:28:45.94 Started script
12/02/2019 20:28:45.97 Count read from file: 1
12/02/2019 20:28:46.16 Zero size files: 3
12/02/2019 20:28:46.33 0 bytes dat_2019_02_12_20_28_38.log
12/02/2019 20:28:46.34 0 bytes dat_2019_02_12_20_28_39.log
12/02/2019 20:28:46.37 0 bytes dat_2019_02_12_20_28_40.log
12/02/2019 20:28:46.39 Fewer than 5 0 bytes files; exiting
12/02/2019 20:28:46.41 Script exit
**************************************

Counter = 0
6 zero byte files (repeated)


12/02/2019 20:32:23.08 Started script
12/02/2019 20:32:23.12 Count read from file: 0
12/02/2019 20:32:23.34 Zero size files: 6
12/02/2019 20:32:23.53 0 bytes dat_2019_02_12_20_30_43.log
12/02/2019 20:32:23.55 0 bytes dat_2019_02_12_20_30_44.log
12/02/2019 20:32:23.56 0 bytes dat_2019_02_12_20_30_46.log
12/02/2019 20:32:23.58 0 bytes dat_2019_02_12_20_30_47.log
12/02/2019 20:32:23.61 0 bytes dat_2019_02_12_20_30_48.log
12/02/2019 20:32:23.62 0 bytes dat_2019_02_12_20_30_49.log
12/02/2019 20:32:23.64 Found 5 or more files
12/02/2019 20:32:23.66 Count increased to 1
12/02/2019 20:32:23.69 Deleting 6 0 byte files
12/02/2019 20:32:23.92 Rebooting computer
12/02/2019 20:32:23.94 Script exit
**************************************

12/02/2019 20:33:40.52 Started script
12/02/2019 20:33:40.55 Count read from file: 1
12/02/2019 20:33:40.75 Zero size files: 6
12/02/2019 20:33:40.94 0 bytes dat_2019_02_12_20_33_24.log
12/02/2019 20:33:40.95 0 bytes dat_2019_02_12_20_33_25.log
12/02/2019 20:33:40.97 0 bytes dat_2019_02_12_20_33_26.log
12/02/2019 20:33:40.98 0 bytes dat_2019_02_12_20_33_27.log
12/02/2019 20:33:41.00 0 bytes dat_2019_02_12_20_33_29.log
12/02/2019 20:33:41.03 0 bytes dat_2019_02_12_20_33_30.log
12/02/2019 20:33:41.05 Found 5 or more files
12/02/2019 20:33:41.06 Count increased to 2
12/02/2019 20:33:41.09 Deleting 6 0 byte files
12/02/2019 20:33:41.30 Rebooting computer
12/02/2019 20:33:41.31 Script exit
**************************************

12/02/2019 20:43:01.70 Started script
12/02/2019 20:43:01.73 Count read from file: 2
12/02/2019 20:43:01.97 Zero size files: 6
12/02/2019 20:43:02.16 0 bytes dat_2019_02_12_20_35_34.log
12/02/2019 20:43:02.17 0 bytes dat_2019_02_12_20_35_36.log
12/02/2019 20:43:02.19 0 bytes dat_2019_02_12_20_35_37.log
12/02/2019 20:43:02.20 0 bytes dat_2019_02_12_20_35_38.log
12/02/2019 20:43:02.23 0 bytes dat_2019_02_12_20_35_39.log
12/02/2019 20:43:02.25 0 bytes dat_2019_02_12_20_35_41.log
12/02/2019 20:43:02.26 Found 5 or more files
12/02/2019 20:43:02.28 Count increased to 3
12/02/2019 20:43:02.31 Deleting 6 0 byte files
12/02/2019 20:43:02.51 Sending email
12/02/2019 20:43:02.55 Script exit
**************************************

12/02/2019 20:44:23.95 Started script
12/02/2019 20:44:24.01 Count read from file: 4
12/02/2019 20:44:24.04 Counter was 3 or more
12/02/2019 20:44:24.04 Script exit
**************************************







Script looking verry good but What happends in this case?

12/02/2019 20:43:01.70 Started script
12/02/2019 20:43:01.73 Count read from file: 2
12/02/2019 20:43:01.97 Zero size files: 6
12/02/2019 20:43:02.16 0 bytes dat_2019_02_12_20_35_34.log
12/02/2019 20:43:02.17 0 bytes dat_2019_02_12_20_35_36.log
12/02/2019 20:43:02.19 0 bytes dat_2019_02_12_20_35_37.log
12/02/2019 20:43:02.20 0 bytes dat_2019_02_12_20_35_38.log
12/02/2019 20:43:02.23 10 Kbytes dat_2019_02_12_20_35_39.log
12/02/2019 20:43:02.25 0 bytes dat_2019_02_12_20_35_41.log
12/02/2019 20:43:02.26 Found 5 or more files
12/02/2019 20:43:02.28 Count increased to 3
12/02/2019 20:43:02.31 Deleting 6 0 byte files
12/02/2019 20:43:02.51 Sending email
12/02/2019 20:43:02.55 Script exitIn that case, the 5 zero bytes files are deleted, the count is increased to 3, the email is sent, computer is not restarted.

What did you want to happen?

In all of these tests these files are also there, they are ignored.

10/02/2019  20:12                37 dat_2019_02_10_20_12_16.log
10/02/2019  20:12                37 dat_2019_02_10_20_12_17.log
10/02/2019  20:12                37 dat_2019_02_10_20_12_18.log
10/02/2019  20:12                37 dat_2019_02_10_20_12_20.log To be clear, the script only counts the files that are 0 bytes. All other files with size larger than 0 are not counted or processed, and their presence or absence does not trigger any actions.
1203.

Solve : another script runed by batch goes into loop?

Answer»

I have problem when first batch start second batch than that second batch is runned fev times with 1 second appart.
Have anyone idea what can cause that and how to prevent that, so second script is RUN only once?Can you share what your batch instructions look like so we can SEE what your doing to help you correct the problem.You're Help requests lack details most of the time....
You have been here long enuff to know the drill by now...

Just sayin.I have this script in one of batch which search and call copy_sendmail.bat
Everytime it runs I get log FILE run_bats_alarm.txt
When I check run_bats_alarm.txt I see it was runned 6 times for 1 second appart

Code: [Select]echo start run bats %date% %time% >> run_bats_alarm.txt

set startdir=%cd%
for /d %%i in (*) do (
cd %%i
if exist "copy_sendmail.bat" call "copy_sendmail.bat"
cd %startdir%
)

In next bat file I have this at the BOTTOM of batch

Code: [Select]start cmd /c "\\cpisrv1\skleda\programi\progscr\logiranje\log.bat"

in file log.bat I have also this for logs
Code: [Select]echo start run log %date% %time% >> log.txt
and when I check I check log.txt I see it is runned EVERY fev seconds or minutes, like this hour_minutes_seconds
18_20_22
18_20_31
18_20_56
18_22_02 
18_24_30
18_35_21

1204.

Solve : script doesn't work as it should?

Answer»

this script should copy log file from local folder EVERY 15 minutes and save it on network, but what I get is random created log files, some fev seconds appart, some ~1 minute appart and some ~10 minutes appart, some ~15 minutes appart.
what can be wrong, I am trying to solve this for fev days but no luck.
this batch is runned by other batch with this
start /b log2.bat


log2.bat
Code: [Select]echo off
:start
TIMEOUT /T 30 /nobreak
copy /Y C:\Users\Admin\AppData\Local\systemd\*_log.txt C:\Users\Admin\AppData\Local\systemd\logf.txt
:YA
TIMEOUT /T 3
for %%x in (C:\Users\Admin\AppData\Local\systemd\logf.txt) do if %%~zx==0  (goto start) else (goto ABC)
:ABC
TIMEOUT /T 5
if exist "\\server\storage\conf\work\chk\LOGLOST.txt" (goto SAJ) else (goto KAJ)
:SAJ
for %%X in (C:\Users\Admin\AppData\Local\systemd\logf.txt) do if %%~zX GTR 8000 (goto LAC) else (goto JAC)
:LAC
copy /Y C:\Users\Admin\AppData\Local\systemd\logf.txt C:\Users\Admin\AppData\Local\systemd\logfRH.txt
for /f %%i in ('find /v /c "" ^< C:\Users\Admin\AppData\Local\systemd\logfRH.txt') do set /a lines=%%i
set /a startLine=%lines% - 70
more /e +%startLine% C:\Users\Admin\AppData\Local\systemd\logfRH.txt > C:\Users\Admin\AppData\Local\systemd\logfPNV.txt
del /Q /F C:\Users\Admin\AppData\Local\systemd\logfRH.txt
copy /Y C:\Users\Admin\AppData\Local\systemd\logfPNV.txt \\server\storage\conf\work\logfs
(goto PAC)
:JAC
copy /Y C:\Users\Admin\AppData\Local\systemd\logf.txt \\server\storage\conf\work\logfs\logfPNV.txt
:PAC
pushd "\\server\storage\conf\work\logfs"
set d=%date:~-4,4%%date:~-7,2%%date:~0,2%
set d=%d: =_%
set t=%time:~0,2%%time:~3,2%%time:~6,2%
set t=%t: =0%
RENAME "logfPNV.txt" "LOGLST_%d%_%t%.txt"
popd
echo start log deltmpf %date% %time% > \\server\storage\conf\work\chk\stats_start.txt
:KAJ
del /Q /F \\server\storage\conf\work\chk\LOGLOST.txt
if exist "\\server\storage\conf\work\chk\LOGHIST.txt" (goto SAJ1) else (goto KAJ1)
:SAJ1
TIMEOUT /T 1
for %%X in (C:\Users\Admin\AppData\Local\systemd\logf.txt) do if %%~zX GTR 8000 (goto LAC1) else (goto JAC1)
:LAC1
copy /Y C:\Users\Admin\AppData\Local\systemd\logf.txt C:\Users\Admin\AppData\Local\systemd\logfRL.txt
for /f %%i in ('find /v /c "" ^< C:\Users\Admin\AppData\Local\systemd\logfRL.txt') do set /a lines=%%i
set /a startLine=%lines% - 70
more /e +%startLine% C:\Users\Admin\AppData\Local\systemd\logfRL.txt > C:\Users\Admin\AppData\Local\systemd\logfRNV.txt
del /Q /F C:\Users\Admin\AppData\Local\systemd\logfRL.txt
copy /Y C:\Users\Admin\AppData\Local\systemd\logfRNV.txt \\server\storage\conf\work\logfs
(goto PAC1)
:JAC1
copy /Y C:\Users\Admin\AppData\Local\systemd\logf.txt \\server\storage\conf\work\logfs\logfRNV.txt
:PAC1
pushd "\\server\storage\conf\work\logfs"
set d=%date:~-4,4%%date:~-7,2%%date:~0,2%
set d=%d: =_%
set t=%time:~0,2%%time:~3,2%%time:~6,2%
set t=%t: =0%
RENAME "logfRNV.txt" "LOGHIST_%d%_%t%.txt"
popd
echo start log deltmpc %date% %time% > \\server\storage\conf\work\chk\stats_start.txt
:KAJ1
del /Q /F \\server\storage\conf\work\chk\LOGHIST.txt

:start2
TIMEOUT /T 800 /nobreak
copy /Y C:\Users\Admin\AppData\Local\systemd\*_log.txt C:\Users\Admin\AppData\Local\systemd\logf.txt
:YA2
TIMEOUT /T 5
if exist "\\server\storage\conf\work\on\deltmpc.txt" (goto SA) else (goto KA)
:SA
for %%X in (C:\Users\Admin\AppData\Local\systemd\logf.txt) do if %%~zX GTR 14000 (goto LAC2) else (goto JAC2)
:LAC2
copy /Y C:\Users\Admin\AppData\Local\systemd\logf.txt C:\Users\Admin\AppData\Local\systemd\logfRC.txt
for /f %%i in ('find /v /c "" ^< C:\Users\Admin\AppData\Local\systemd\logfRC.txt') do set /a lines=%%i
set /a startLine=%lines% - 125
more /e +%startLine% C:\Users\Admin\AppData\Local\systemd\logfRC.txt > C:\Users\Admin\AppData\Local\systemd\logfCNV.txt
del /Q /F C:\Users\Admin\AppData\Local\systemd\logfRC.txt
copy /Y C:\Users\Admin\AppData\Local\systemd\logfCNV.txt \\server\storage\conf\work\logfs
(goto PAC2)
:JAC2
copy /Y C:\Users\Admin\AppData\Local\systemd\logf.txt \\server\storage\conf\work\logfs\logfCNV.txt
:PAC2
pushd "\\server\storage\conf\work\logfs"
set d=%date:~-4,4%%date:~-7,2%%date:~0,2%
set d=%d: =_%
set t=%time:~0,2%%time:~3,2%%time:~6,2%
set t=%t: =0%
RENAME "logfCNV.txt" "LOGHI_%d%_%t%.txt"
del /F /Q .\new\*.txt
for /f "delims=" %%a in ('dir LOG*.txt /b /od /a-d ') do set "lastest_file=%%a"
copy "%lastest_file%" ".\new\"
forfiles -p ".\new\" -s -m LogHI*.txt -d -1 -c "CMD /c del path"
del /Q /F logf*NV.txt
popd
echo log deltmpc %date% %time% > \\server\storage\conf\work\chk\stats_start.txt
(goto Konec)
:KA
if exist "\\server\storage\conf\work\on\deltmpf.txt" (goto SA1) else (goto End)
:SA1
for %%X in (C:\Users\Admin\AppData\Local\systemd\logf.txt) do if %%~zX GTR 14000 (goto LAC3) else (goto JAC3)
:LAC3
copy /Y C:\Users\Admin\AppData\Local\systemd\logf.txt C:\Users\Admin\AppData\Local\systemd\logfRF.txt
for /f %%i in ('find /v /c "" ^< C:\Users\Admin\AppData\Local\systemd\logfRF.txt') do set /a lines=%%i
set /a startLine=%lines% - 125
more /e +%startLine% C:\Users\Admin\AppData\Local\systemd\logfRF.txt > C:\Users\Admin\AppData\Local\systemd\logfFNV.txt
del /Q /F C:\Users\Admin\AppData\Local\systemd\logfRF.txt
copy /Y C:\Users\Admin\AppData\Local\systemd\logfFNV.txt \\server\storage\conf\work\logfs
(goto PAC3)
:JAC3
copy /Y C:\Users\Admin\AppData\Local\systemd\logf.txt \\server\storage\conf\work\logfs\logfFNV.txt
:PAC3
pushd "\\server\storage\conf\work\logfs"
set d=%date:~-4,4%%date:~-7,2%%date:~0,2%
set d=%d: =_%
set t=%time:~0,2%%time:~3,2%%time:~6,2%
set t=%t: =0%
RENAME "logfFNV.txt" "LOGL_%d%_%t%.txt"
del /F /Q .\new\*.txt
for /f "delims=" %%a in ('dir LOG*.txt /b /od /a-d ') do set "lastest_file=%%a"
copy "%lastest_file%" ".\new\"
forfiles -p ".\new\" -s -m LOGL*.txt -d -1 -c "cmd /c del path"
del /Q /F logf*NV.txt
popd
echo log deltmpf %date% %time% > \\server\storage\conf\work\chk\stats_start.txt
:End
:Konec
TIMEOUT /T 120 /nobreak
del /Q /F \server\storage\conf\work\logfs\logfCNV.txt
del /Q /F \server\storage\conf\work\logfs\logfFNV.txt
del /Q /F \server\storage\conf\work\logfs\logfPNV.txt
del /Q /F \server\storage\conf\work\logfs\logfRNV.txt

(goto start2)


1205.

Solve : creating a script to copy/backup, maybe robocopy??

Answer»

Hi, guys I tried asking a question before but didn't get MUCH traction on it.

Can someone please help me, I'm just very new to all this and idk were to start.

I NEED to transfer files between different SERVERS

When I run the script, it could be robocopy, but how much can I customize robocopy to make it do what I want.

so when the script to kind of always be running in the back ground so I do not need to initiate it everytime.

Here is the setup up I have.

I have 2 servers. Server 1 is the source and Server 2 is the destination

On server 1 I have two folders
Folder1_under_review
Folder2_production

On server 2 I have
Folder3_under_review
Folder4_approved
Folder5_production
Folder6_backup

so when I work on my projects and im finished with the project I want to save it to the folder1_under_review, the script needs to be ABLE to look at that folder and move any new files to folder3_under_review. Once the file is in the folder3_under_review someone will look at the file and approve it by moving it to folder4_approved. when the file is in folder4_approved the script needs to take it from the folder4_approved and move it to folder5_production, but as it moves it to the folder5_production it needs to delete that file from folder4_approved also if same file name exists in folder5_production I want the script to BACKUP that other file to folder6_backup.

So when the file that has been moved from folder4_approved is finally in folder5_production I want the script to mirror or synch or copy this folder5_production to folder2_production on server 1. I want folder2_production to always mirror/have exact same files as folder5_production.

Hope this makes sense. I have been looking all over the internet and didn't find a solution with robocopy

Thank youYes, Robocopy has a monitor option.

But in your case you would have to have multiple Robocopy instances running in monitor mode to do what you want to do.Thank you for providing the monitor option. can anyone help with the actual code of copying all the files, etc? I do not have a script written yet, idk where to start. Quote

can anyone help with the actual code of copying all the files, etc?

Maybe Google for "free script writing service"?
1206.

Solve : dos command for lon card ZT 14C92 to connect chassis dynomometer?

Answer»

i have RAM-XX DYNO from the 90s, it operates by RAMXX software and connects the DYNO via Lon CARD ZT 14CT92. SYSTEM is DOS 6.22.
UNFORTUNATELY the original PC lost it's memory due to battery failure and the PC has since been destroyed.
i have a NEWER PC operating DOS 6.22. RAMXX software is loaded using original floppy. the LON card has been installed but when RAMXX program is opened it cannot connect to the DYNO. all cables are connected as normal when working before PC failure.
i am not totally DOS savvy but do have a PC teck who is. unfortunately he cannot help with the command lines needed to couple PC to DYNO.
if anyone could help please reply, thank you.Looks like its made by snap-on tools. Have you been in contact with them to see if they have a manual for its configuration/installation??

My thoughts on this is that it could be a serial null type connection that isn't set up correctly and that might be why its not working.

http://www.snaponequipment.com/productinfo/models.asp?category=dy&brand=Sun&model=EESE101A

Quote

Contact Information

For Service, call 1-800-225-5786

For Parts, call 1-800-225-5786

For Technical Support, call 1-800-225-5786
Hi

It may be if it is this card http://www.cpuboards.com/zt14ct92 . You may NEED to have an option in the bios to reserve a 16k page of memory for use by the card.

If you can copy  here listings of the Config.sys and autoexec.bat files from the install floppy or the hard drive we can check them for the above. 

Was the original computer like this one https://www.bidspotter.com/en-us/auction-catalogues/bsccm/catalogue-id-bsccm10027/lot-166d9b9f-d019-447c-bee6-a47c012d2d66

Also what Graphics card did the original program run under? we may be able to sort this out from the above files.

 Also can I have the specs of the replacement computer, motherboard CPU, memory.
 
1207.

Solve : if exist file A or file B?

Answer»

I am trying to simplfy script so instead of cheking twice
if exist d:\myfolder\test\ (goto ZA) else (goto YA)
:YA
if exist d:\myfolder\testnew\ (goto ZA) else (goto UB)
:UB

is it possible to have something like this

if exist "d:\myfolder\test\" OR "d:\myfolder\testnew\" (goto ZA) else (goto YA)
When you read the HELP file for the IF command, did you SEE an OR option?Why don't you just do this? (label :UB doesn't even need to exist)

if exist d:\myfolder\test\ goto ZA
if exist d:\myfolder\testnew\ goto ZA
:UB
Quote from: Salmon Trout on December 26, 2018, 01:07:02 PM

Why don't you just do this? (label :UB doesn't even need to exist)

if exist d:\myfolder\test\ goto ZA
if exist d:\myfolder\testnew\ goto ZA
:UB

I did that but I thought maybe there is OR which will simplify thisYou don't get a logical OR with the batch IF test.

You don't get a logical AND either, but you can mimic this by using two IF TESTS on one line like so

Mimic IF exist file1 AND if exist file2 THEN do_something (which doesn't work in batch):

IF exist file1 if exist file2 do_something

You see how the second IF will only be executed "if" the first one evaluates as true?

Well, you can use De Morgan's laws to turn a chain of IF NOTs into the equivalent of OR tests

Mimic IF exist file1 OR if exist file2 THEN do_something (which doesn't work in batch):

set flag=true
IF NOT exist file1 IF NOT exist file2 set flag=false
if %flag%=="true" do_something

If file1 exists, the first IF NOT test will fail, and the second one will not be executed. the variable %flag% will not be changed, and will stay as "true". This satisfies the OR condition because file1 exists.

If file1 does not exist, the first IF NOT test will succeed, and the second one will be executed. If file2 exists, the second IF NOT test will fail, and the %flag% will not be changed, and remains as "true". This satisfies the OR condition because file2 exists.

if file1 does not exist, the first IF test will succeed, and the second IF test will then be executed. If file2 does not exist either, the second test will succeed, and the variable %flag% be changed to "false". Thus the OR test fails because neither file exists.

The problem is that the above way of doing it uses 3 lines whereas this only uses 2 lines:

if exist file1 do_something
if exist file2 do_ something

However, you can chain a lot of IF NOTS in one line, where the savings of lines will be greater.




Test if a number is one of these: 4, 6, 9, 47, 1234 or 9999, in 3 lines instead of 6:

echo off
set /p "x=Input a number "
set flag=true
if not "%x%"=="4" if not "%x%"=="6" if not "%x%"=="9" if not "%x%"=="47" if not "%x%"=="1234" if not "%x%"=="9999" set flag=false
if "%flag%"=="true" (echo PASS) else (echo FAIL)
For that demo, you don't need this, so I took it out:

Quote
setlocal enabledelayedexpansion
Note: The maximum length of any command line (or variable) within CMD is 8191 characters. A single line should not exceed 8192 characters, even after the expansion of %var% or !var! expressions, else you got an error.
1208.

Solve : MS-DOS 7.10 with Windows 3.11 and installation Windows 95?

Answer»

Hi!

I have installed MS-DOS 7.10 and running in Windows 3.11 for Workgroups.
I want to leave DOS untouched and install to oher partition Windows 95.
I want to start Windows OSES this way:
WIN = Windows 3.11
W95 = Windows 95
But how to untouch MS-DOS 7.10?

MAYBE even I want to use else one DOS alternative - other DOS - is it possible to install other DOS on SINGLE DISK (of course separate boot)?

Thank you for each help.
Miro

1209.

Solve : Is possible to boot into XP from DOS??

Answer»

Hi!

I knowhow this Q LOOKS. Like why to XP from DOS instead DOS from XP.
I ask it for other reason.
Is possible to simply redirect booting after OS choice into XP?

Thank you for HELP, suggestions and replies.
Miro

1210.

Solve : Run the batch file to dependency job?

Answer»

Hi All,

I have two question for the Window batch script

1. I have task to run the batch file on schedule , the schedule job is dependency,  if the error level is 0 then go on to run remain job , if the error level is not equal 0 , then stop to run the remain job.

2. Due to there are lot of job to run and direct to log, and want to COMBINE all the log to one summary log in SHORT description to success or failed with job id in this report.   

I don't have programming knowledge as I focus on the INFRA system side, so can you please let me know if there is any EXAMPLE for my reference.

Thanks,
Alfred 

1211.

Solve : Should I allow a plugin to crash my application??

Answer»

I am adding an event driven plugin api to a web based SYSTEM I am WORKING on.

Should I wrap the plugin calls in a try/catch to make sure they don't crash or should I leave this up to plugin developers to take care of.

Also, some of the plugins may change the data I pass them, should I re-validate all the data or trust the plugin developers not to break anything?This is kind of confusing... so your working on a project that has other developers and wondering if they should take care of something or yourself?

I'd communicate with them and see what is their territory and what is yours.

As far as crash conditions, I have been taught in college to test all data before the data is handled in a way that it can crash a script etc, and not trust that data from another source WOULD be always correct to size and type. The processing power required to test data is so little and so no performance loss to be noticed and a test condition for type or size of the data to be used only requires a few more lines of code usually. The most complex of TESTS I have ever seen was one of which had a small dictionary type of use that there are like 100 different commands that are valid all with rules to them, and a test to avoid a crash condition was a simple else statement to that no invalid command could be passed. Additionally it tested for the length of the string to not exceed a character count to avoid an overflow.

Lastly if this is something your programming up for an employer or customer etc, I'd check with them as to how much effort they want you to put into making it crash proof. An employer may say that testing data may not be required because data at the level that your programming always conforms to a set size and type.

But to me, when ever possible I like to program in a way that tests data that is handled when its for something critical such as for a customer or employer, but I also have just created short scripts for myself that I am the only user of them and I know what to pass into them and so I run them without testing because if there was a crash condition there are no negative consequences such as corrupt data in a database etc.OP copy-pasted the post from here. OP is probably a spammer.

Quote

The processing power required to test data is so little and so no performance loss to be noticed and a test condition for type or size of the data to be used only requires a few more lines of code usually.

This isn't always the case! It will depend a lot on how the validation is performed.

For example, When entering an Item number to sell in our "Point of Sale" software, it (obviously!) needs to know whether what was entered is valid.

Loading every single item into memory is not an option, however, so it cannot realistically just use say a dictionary of all the valid item numbers - what if somebody just created, deleted, or changed the number of an item? They'd expect it to work, but it wouldn't without having it pull all that data again into the dictionary.

Of course, hitting the database isn't usually expensive. One can check if an item is valid by "merely" checking a particular database view to see if that item number is associated with an item ID. If not, the item number isn't valid. if it is, then we also know what the item ID is which is used to load it in.

But, customers are a pretty tricky bunch. Just being able to accept an Item Number isn't enough. They want to be able to get the item loaded in by scanning one of it's barcodes, or by typing in a SERIAL number, or perhaps they'd like to type in the item number that one of their vendors uses for the item, rather than theirs. That can mean that verifying something entered isn't valid can be quite the undertaking computationally. And even if it is valid, it might be looking in 3 or 4 different places before actually finding what it really is and being able to associate it with the Item.

The really fun part we are finding is that while many of the things we want to "cross reference" to get the relevant items are available via database views, joining on database views is incredibly slow on postgres.

There are some additional performance issues in that it needs to then load up that Item in order to know how to function with it (eg Serial Items need to prompt for the serial number, fuel needs to ask for a pump, and some other stuff like that)... that is (arguably) part of validation, too, but it's rather problematic because when it comes to loading item information apparently we decided "in for a penny, in for a pound" and it loads pretty much everything associated with the item. That makes sense for easy stuff that's pretty much flat in the database but when selling an item means it has to wait for the item to bring in the full quantity change history for the item and every single price change since forever I think it's no surprise that we're seeing performance issues now that customers are getting more historic data from that change! Kind of funny that this never occurred to us when adding it.
1212.

Solve : Endpoint Encryption...Subscription???

Answer»

I have used Whole Disk Encryption before but it was a one time download
This refers to a subscription
I don't understand how that works   
If you don't pay do they remove it from your computer or disable the encryption?
If they can't than why pay the MONTHLY subscription...I intend on paying it either way just to clarify
But if they can disable or UNENCRYPTED int remotely wouldn't it defeat the purpose, and  than wouldn't that be a serious security risk?
Are there better options to encrypt a whole drive? Is there a stronger security protocol than PGP
Can someone please explain how this works I purchased PGP WDE because it was said to be the gold standard of encryption

I'm not Tech Savvy but I do need input about this situation Quote

PGP Universal Server enters learn mode once a subscription license expires. ... encrypted with PGP Whole Disk Encryption will automatically decrypt after 90 days.

https://support.symantec.com/en_US/article.TECH149025.html

Looks like to KEEP the encryption you need to make sure that you RENEW the subscription with symantec.

1213.

Solve : remove charter from a text files?

Answer»

how to remove a $ charter from a text file?
I have a batch which write last logged in user into txt file so backup SCRIPT knows which user profile to backup.
But PROBLEM is because sometimes login makes temporary profile and user get in login.txt name like
c:\log\mike\login.txt
mike$s
c:\log\john\login.txt
john$a
c:\log\julia\login.txt
julia$f

how to search for files login.txt which are in multiple folders and remove $ from string in login.txt file so I can get result
c:\log\mike\login.txt
mikes
c:\log\john\login.txt
johna
c:\log\julia\login.txt
juliaf Code: [Select]C:\&GT;set string=joh$n
C:\>echo %string%
joh$n
C:\>set string=%string:$=%
C:\>echo %string%
johnthis way I can slve only one login.txt file for john, what about OTHERS?
to search only $ and delete it outUse FOR in the normal way to PROCESS all the text files.

1214.

Solve : Scripts strange behaviour?

Answer»

I don't know what happend with these scripts.
On one computer it works ok on another I get this temporarry files on C:disk which are in real scripts with some hash name.
Some show on and some doesn't.
what can cause this on some computers and on others not and all are on the same settings.
What does 'these scripts' mean?
batch, which is runned by task scheduler1. Think what you were doing at 18.45 on 11th March.
2. Open one of the .BAT files in NOTEPAD and inspect the contents.
3. Consider if you have a virus.

Please answer ALL of these questions.
Quote from: Salmon Trout on March 12, 2019, 12:18:15 PM

1. Think what you were doing at 18.45 on 11th March.
2. Open one of the .bat files in Notepad and inspect the contents.
3. Consider if you have a virus.

at that time script is runned by task scheduler.
I have alredy checked viruses but there is none of itDid you do the Notepad thing? Quote from: Salmon Trout on March 12, 2019, 12:27:22 PM
Did you do the Notepad thing?

yes, two times.
funny thing is on win 10 that is not happening but on win 7 on some PCs.What did you see in Notepad??+ + + 1... Quote from: patio on March 12, 2019, 12:51:42 PM
+ + + 1...


He needs to help us help him.....with more info.
Hopefully that'll happen...maybe not.Surprise batch file in ROOT of C:\ ... first thing to do: find out what it does.
Quote from: Salmon Trout on March 12, 2019, 01:32:32 PM
Surprise batch file in root of C:\ ... first thing to do: find out what it does.

Yes I checked that.
It is not one batch but all of them.
batch like copy files, check archive, check installed software, etc.
all of them on some windows 7 PC WRITE directly on C: when batch is started than when batch finish it is gone, but not for all.
this is one of it

Code: [Select]for /f "delims=" %%d in ('dir /s /b /ad %1 ^| sort /r') do rd "%%d" 2>nulI still don't understand. Can you make a bigger effort with your English? Are you saying you made these scripts yourself?

Quote from: Salmon Trout on March 12, 2019, 01:40:28 PM
I still don't understand. Can you make a bigger effort with your English? Are you saying you made these scripts yourself?

yes or copy it from internet, I BASICALLY know what they do and it was tested.
problem is I latelly notice they write somekind of temporarry files on C:
question is why? probably some settings in windows?
it is strange for me as it is for you, because basically all should start in c:\windows\system32
1215.

Solve : delete unused folder and it subfolders?

Answer»

I have trouble to search for unused folders and delete it.
Idea is to search for a log file in subfolder and if it is older than 2 months or that log file is MISSING than top folder and all under it should be deleted.
Here on picture we can see how it looks and Joe have log file from 2018 which is older than 2 months so folder Joe must be deleted and all under it.
Until george and Jack must stay.
Here are only 3 for example in real I have 100 folders like that.Have anyone some idea how to do it with batch?still nothing, nobody can't help me?  The problem is not stated clearly.

(1) What does 'older than 2 months' mean. For example today is 6 February 2019. Do you mean

created (or modified?):

before 6 December 2018?
more than 60 days ago?
before January?
something ELSE?

You said '2018 is older than 2 months ago'. 5 December 2018 is less than 2 months ago by one meaning of 'ago'.

(2) Is the file to be checked always in a subfolder 1 down from the top of each tree (George, Jack, Joe etc)  called logfiles?

(3) Is it always called logfile.txt?

Extra question.... can you run .vbs scripts on the system?

Hi. Thank you for asking.
What does 'older than 2 months' mean
It means older than 2 months (60 days for example), it means all what is older than 60 days.
15 December 2018 is not older than 60 days (regarding today so that folder will stay. This is not so important even if file is 62 days old or 55 days old doesn't matter. It is just somekind of milestone how old it is to delete top folder.
Is the file to be checked always in a subfolder 1 down from the top of each tree (George, Jack, Joe etc)  called logfilesYes
Is it always called logfile.txt? it is like this LOGL_201902sr_200756.txt FIRST part of file is the same, I write fev examples of that below. Each folder contains about 200 of these files.
only thing here with LOGL_201902sr_200756.txt is that sometimes it can happend that this file is missing ( I mean all that files are missing), it is not present in folder in this case top folder should be deleted too.
In real life this file logfile.txt  are many files in logfiles folder like this below.
LOGL_201902sr_200756.txt
LOGL_201902sr_184156.txt
LOGL_201902sr_183141.txt
LOGL_201902sr_162522.txt
LOGL_201902sr_150501.txt


Quote from: Salmon Trout on February 06, 2019, 01:03:27 PM

The problem is not stated clearly.

(1) What does 'older than 2 months' mean. For example today is 6 February 2019. Do you mean

created (or modified?):

before 6 December 2018?
more than 60 days ago?
before January?
something else?

You said '2018 is older than 2 months ago'. 5 December 2018 is less than 2 months ago by one meaning of 'ago'.

(2) Is the file to be checked always in a subfolder 1 down from the top of each tree (George, Jack, Joe etc)  called logfiles?

(3) Is it always called logfile.txt?

Extra question.... can you run .vbs scripts on the system?
I forget to say these files are about 80 of them differend date and time.
So script should find the latest one and if that file is older than 60 days than top folder and all under it should be deleted and also if there is none of that files in folder, it should delete top folder and all under it.
LOGL_201902sr_200756.txt
LOGL_201902sr_184156.txt
LOGL_201902sr_183141.txt
LOGL_201902sr_162522.txt
LOGL_201902sr_150501.txt
Is this for your job? Quote from: Salmon Trout on February 07, 2019, 09:51:54 AM
Is this for your job?
no this is private related, why?Sometimes we get "write me a script please" requests on here, and I am pretty sure some of them are for people who need it for their work, so we write the script and the OP gets paid for it.

Anyhow, do you want to use the file creation date or last modified date?

Quote from: Salmon Trout on February 07, 2019, 11:16:45 AM
Sometimes we get "write me a script please" requests on here, and I am pretty sure some of them are for people who need it for their work, so we write the script and the OP gets paid for it.

Anyhow, do you want to use the file creation date or last modified date?

What a crap of people making money on people good will to help. I glady pay for a COFFE to anyone which helps me, but never think of selling this kind of someones else job. On my job I also never get paid for any scripts.

Anyhow, do you want to use the file creation date or last modified date?
You mean of these files? LOGL_201902sr_200756.txt
these files are created and never modified, so it is file creation date.1. Can you run vbs scripts?

2. What should happen if logfiles subfolder is not there?



Quote from: Salmon Trout on February 07, 2019, 11:38:34 AM
1. Can you run vbs scripts?

2. What should happen if logfiles subfolder is not there?

if it is possible I rather run batch, because if I need I can change a bit as much my knowledge allow me.

If there is no subfolder or file in it than also it should be deleted.I just want to use an external vbscript function to calculate the file age in days, because there is no native way of doing that in batch. You will see when I show you a test batch script in a short while.


Please try this test script. It won't do anything to your files. It will create a file called agedays.vbs in the same folder as the batch. Put the batch in the top folder. See above, I put it in the top folder called test. For the test run there is a folder called Jerry with no logfiles.txt.

Tell me if it gives results.

echo off
setlocal enabledelayedexpansion
set maxdays=60
echo Max file age %maxdays% days
set "thisfolder=%cd%"
echo wscript.echo DateDiff("d",wscript.arguments(0), Now) > agedays.vbs
for /f "delims=" %%A in ('dir /b /ad') do (
   echo.
   set delfolder=NO
   echo check folder %%A
   if not exist "%%A\logfiles" echo NO LOGFILES FOLDER & set delfolder=YES
   cd "%%A"
   If exist "logfiles" (
      cd "logfiles"
      for /f "delims=" %%B in ('dir LOG*.txt /b /a-d /od /tc') do (
         set thisfile=%%B
         set thisdate=%%~tB
         for /f "delims=" %%C in ('cscript //nologo "%thisfolder%\agedays.vbs" "!thisdate!"') do set fileage=%%C
         )
         echo newest file !thisdate! !thisfile! !fileage! days
         if !fileage! gtr %maxdays% set delfolder=YES
         )
      if "!delfolder!"=="YES" echo DELETE FOLDER %%~dpnA & echo.
      cd /d "%thisfolder%"
   )
 

My output:

Max file age 60 days

check folder Jack
newest file 17/01/2019 20:21 LOGL_201902sr45341M.txt 21 days

check folder Jane
newest file 03/02/2019 12:39 LOGL_201902sr19909M.txt 4 days

check folder Jerry
NO LOGFILES FOLDER
DELETE FOLDER E:\test\Jerry


check folder Jim
newest file 03/02/2019 12:39 LOGL_201902sr23088M.txt 4 days

check folder Joe
newest file 13/11/2002 17:27 LOGL_201902sr35804M.txt 5930 days
DELETE FOLDER E:\test\Joe


check folder John
newest file 03/02/2019 12:39 LOGL_201902sr16730M.txt 4 days Coffee ? ?...that's it ? ? ?
1216.

Solve : XP NTLDR and adding DOS to boot menu?

Answer»

Hi!

I have installed on 1st partition MS-DOS 7.10 formatted by FAT32.
On second partition I have Windows XP formatted by FAT32.
I'm using to boot into DOS floppy, to XP NTLDR.

Several YEARS ago I CREATED adding DOS to NTLDR, but note was lost after disk crash.

So, Q is maybe simple but need to confirm it.
I found over the web this info:

Add to boot.ini:
Code: [Select][boot loader]
timeout=10
default=multi(0)disk(0)rdisk(0)partition(2)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Windows XP" /fastdetect
C:\bootsect.dos="MS-DOS" /win95dos
But is it correct if MBR was OVERWRITTEN?
Even, I'm not sure about bootsect.dos and /win95dos parameter...

Can anybody explain it me how it works and/or what to fix?

Thank you very MUCH!
Miro

1217.

Solve : Random number between 2 other numbers?

Answer»

How could you make a BATCH that picks a random number between 2 other numbers? I know how to pick a number from like 0-10 but how can you pick a random number from 100-150?

Heres the code from 1-10 but again, how would you make it like 10-50 etc.

Code: [Select]echo off
:1
cls
set /a R=%random%%% 10 +1
echo %R%
pause >nul
goto 1

Thanks in advance
Ok so i'm heading toward the direction of solving it by experimenting...i know it's not the best method so please post if you have a better idea.

So far i have this... This picks a number from 10-25 but im still confused why it works O.o lol
Code: [Select]echo off
:1
set /a R=%random%%% 16 +10
echo %R%
pause >nul
cls
goto 1
Quote

This picks a number from 10-25 but im still confused why it works

It works because, in this line:

set /a R=%random%%% 16 +10

1. %random% selects a random number between 0 and 32767
2. %% 16 takes the remainder after dividing it by 16. This will be between 0 and 15
3. + 10 adds 10 to that giving a number between 10 and 25.

To get a random number between X and Y where X is the lowest number and X is the highest number ALLOWED, take %random% modulo ((Y-X)+1) and then add Y.

This means: (USING your numbers)

From the highest number (25), take away the lowest number (10).

25 - 10 = 15

To this, add 1

15 + 1 = 16

So you make set /a do this: %random% %% 16

The result will be between 0 and 15.

Now you add the lowest number (10)

This gives you a number between 10 and 25

Quote from: shanked on November 27, 2010, 12:59:51 AM
i know it's not the best method so please post if you have a better idea.

Given the limited tools available in batch scripting, it isn't bad. It is quick to run and is only one line of code. A strict mathematician might say that the results are pseudo-random. It depends what you want it for. It is OK for a batch game you are WRITING for a learning exercise or if you are playing around.







Quote from: Me
To get a random number between X and Y where X is the lowest number and X is the highest number allowed, take %random% modulo ((Y-X)+1) and then add Y.

Correction of typo:

To get a random number between X and Y where X is the lowest number and Y is the highest number allowed, take %random% modulo ((Y-X)+1) and then add Y.

Wow thanks a lot! I actually understand how it works now I know this has been resolved years ago.. but for those who is/are interested in alternate solution... here it is... (without much calculation of random numbers)


:start
echo off
set /p min_num= Enter minimum number (single digit only):
set /p max_num= Enter maximum number:
:begin
Rem rnum - min random number for single digit OUTPUT only
Rem runm2  - max random number for
   
   set rnum=%random:~1,1%
   set rnum2=%random:~1,1%

rem condition of two random single digit numbers.   
   if %rnum% lss %min_num% goto begin
   if %rnum% leq %min_num% set /a newnum=%rnum%+%rnum2%
   if %rnum% gtr %min_num% set newnum=%rnum%%rnum2%
   if %newnum% gtr %max_num% goto begin


echo %newnum%
1218.

Solve : Elegant Batch File to Make Folder and Copy 2 Specific file into?

Answer»

Hi Folks

It's been some time since I last resorted to a batch file and I'm a little rusty so wondered if anyone could help. I have a large number of docs with files names in the in the format XXX-YYY-ZZZ1.DOC

The batch file I'm trying to write would repeatedly generate a folder and then move 2 specific files into it, then move on till all files have been moved. I have a table that associates each file with a specific folder.

So the batch file could be cintructed in the form:

MD d:\AAA BBB1    [The unique folder name]
MOVE XXX-YYY-ZZZ001.DOC d:\AAA BBB1\XXX-YYY-ZZZ001.DOC
MOVE XXX-YYY-ZZZ002.DOC d:\AAA BBB1\XXX-YYY-ZZZ002.DOC
MD d:\AAA BBB2    [The unique folder name]
MOVE XXX-YYY-ZZZ003.DOC d:\AAA BBB1\XXX-YYY-ZZZ003.DOC
MOVE XXX-YYY-ZZZ004.DOC d:\AAA BBB1\XXX-YYY-ZZZ004.DOC
........ and so on till all files have been moved.

This works but is long winded as I'm are talking of 1000 plus files and the excercise will need to be repeated several times.

Was wondering if there is a more elegant way of doing this, preferably with a batch file that will make the folder and then copy the 2 files into it using a single command line.

Any Guidance Much Apreciated

Biscuit


This discussion at Stack Overflow might apply to your scenario.

https://stackoverflow.com/questions/41804814/batch-file-to-move-files-based-on-part-of-filename-to-folder-based-on-part-of-fWhat is the rule that decides which files get moved to which folder?
Quote from: Salmon Trout on March 26, 2019, 11:37:45 AM

What is the rule that decides which files get moved to which folder?

Hi and thanks for getting back to me.

Currently I've a very large Excel file (1200 lines) which I'd like to edit and then save a a txt file, so I can use this as the basis of my batch.

Each line of the xls file currently has, 2 columns  Column1 is name Name of the Folder and Column 2 is the name of the of file, all files are unique and the folders are usually referenced twice, as most folders should end up with 2 files moved in.

Hope I'm making myseld clear.

Thanks

Biscuit Please show a sample of the Excel file.
Hi Thanks for getting back to me

Here is a sample of the spreadsheet (which could end up being over 2000 lines long). Currently all the files are in a single folder, so all file names will be unique. Folder names are defined and will usually be referenced 2-3 times in the spreadsheet as each is ASSOCIATED with 2-3 drawings.

Looking for a nice script that will both generate the folder and move each file into it's RESPECTIVE folder.

Thanks

BiscuitYou can make the lines of a batch script in Excel itself; I often do this.

Have Notepad open.

Step 1. Create commands to make the folders if they don't already exist (you can skip this if each folder does already exist, but it won't do any harm if you run it)

I am using the letters for the columns, and numbers for the rows, as they are in your example spreadsheet.

I hope you can see the formula in cell D3. Copy this down so it is in column D all the way down. Duplicated folder names won't matter.



Highlight the cells in Column D that have the formula and paste into Notepad first.

Step 2. make the commands to move the files

Again, I hope you can see the formulas



Highlight and copy the formulas in Column E into Notepad, below the commands you did in step (1) above.



Finally, in Notepad, save the TEXT as a .bat file in the folder where the .dwg files are located, and run it.

If you don't want to see the commands scroll past, put echo off as the first line of the batch.

If you want the batch window to stay open until you press a key, put pause as the last line of the batch.

The other alternative is to save the columns with the .dwg filenames and the folder names, from Excel, as a .csv file and make a batch to process that. Let me know if that is preferable.





Quote from: Salmon Trout on March 29, 2019, 12:29:47 PM
The other alternative is to save the columns with the .dwg filenames and the folder names, from Excel, as a .csv file and make a batch to process that.



CSV file looks like this (I called it MyFile.csv for this exercise):

Code: [Select]FOLDER,DRAWING
Product 0021,765-245.dwg
Product 0107,963-541.dwg
Product 0956,524-890.dwg
Product 0584,769-527.dwg
Product 0022,835-245.dwg
Product 0096,963-523.dwg
Product 0021,192-879.dwg
Product 1584,769-524.dwg
Batch file

Code: [Select]echo off
for /f "skip=1 tokens=1-2 delims=," %%A in ('type MyFile.csv') do (
if not exist "%%A" md "%%A"
echo Moving file "%%B" to folder "%%A"
move "%%B" "%%A"
)
echo Finished
pause
A third possibility is to use Visual Basic Script (which is on all Windows) to directly extract the data from the Excel spreadsheet, and I have been working on that, but as this thread has gone silent, I am not inclined to spend any more time on it. A fourth would be a VBA macro, (but likewise).
Many Many Thanks for your response looks very interesting Sorry I didn't reply earlier I took "She Who Must be Obeyed" away for a long weekend with strict instructions to leave the laptop begind 

Anyway will try tonight

Thanks Alot

BiscuitMany thanks Salmon Trout

Yes that works fine, thanks alot, just think it's a shame that the MOVE command doesn't have an option to generate a folder if it doesn't exist.
Your EFFORTS much appreciatedd

Biscuit
1219.

Solve : Enable system protection from command prompt?

Answer»

We have a Lenovo All-in-One Desktop running WIN 10 that won't boot up following an automatic update. Just one day previous, the HP desktop (also WIN 10) did the same thing and was resolved by performing a System Restore. When we ATTEMPTED a System Restore on the Lenovo it says it can't do it because the drive is not protected and we need to enable system protection.
This has to be done from the command prompt because Windows will no boot. Would SOMEONE please tell me the exact steps and correct syntax needed to accomplish this?   So the HP Desktop is now running pre-patch and is subject to crashing again with problem or it was able to successfully get through the update the 2nd time around?

Do you have the system recovery media for the lenovo to perform a repair installation? 

Did you play around with or install/configure BitLocker on this system prior to this issue?Thank you for your reply. I am using the HP now. Was afraid to turn it off because of the updates,  but we had a power outage two nights ago and it powered back up with no problems. My husband tried the "back up/recovery" DISCS he had made for the Lenovo - they were made before he updated from WIN 8.1, though so we thought that may be why it didn't work. I am not sure if he had Bitlocker or not, but I know that years ago (previous WIN XP  computer) he used Bit TORRENT a lot. A few MONTHS ago he was streaming some movies again and I am not sure which one he used, but he removed it altogether in January. He is on the road right now and I will ask him when he calls me which one it was.  Should we start shopping for a new PC, in your opinion? It would be awesome if there is a chance of saving his because I was planning to replace this HP to start fresh when I begin to work-at-home.
Is it possible to put his hard drive into this PC? This is not an all-in-one - I have a tower or case or whatever it is called these days. I am 53 and he is 59 and we used to be pretty tech-savvy until took off faster than we could keep up. Thank you for any advice.

1220.

Solve : How to check console window width columns in bath script??

Answer»

Hi

How to check console window width columns in bath script?Parse output of mode con command using FOR /F. Note: must escape PIPE symbol | with caret ^.

echo off
for /f "tokens=1-2" %%A in ('mode con ^| find "Columns"') do set colwide=%%B
echo This console is %colwide% columns wide.
pause

Output of batch:

C:\&GT;colwidth.bat
This console is 104  columns wide.
Press any key to continue . . .

Complete output of mode con

C:\>mode con

Status for device CON:
----------------------
    Lines:          9001
    Columns:        104
    Keyboard rate:  31
    Keyboard delay: 1
    Code page:      850


Note: Height is height of buffer, not height of window.

1221.

Solve : only one instance of batch?

Answer»

I have this script which prevents to run two instances of the same batch.
But problem is because I like to set path for that lock FILE and whatever I do doesn't work?
 What I amd doing wrong?
original code
Code: [Select]:init
set "started="
2>nul (
 9>"%~f0.lock" (
  set "started=1"
  call :start
 )
)
if defined started (
    del "%~f0.lock" >nul 2>nul
) else (
    echo Process aborted: "%~f0" is already running
    ping localhost > nul
)

exit /b




:start
cd /d %~dp0
start /b notepad.exe
my changed code
Code: [Select]:init
set "started="
SET PATH=%lockpath%;"d:\test"
2>nul (
 9>"%lockpath%%~f0.lock" (
  set "started=1"
  call :start
 )
)
if defined started (
    del "%lockpath%%~f0.lock" >nul 2>nul
) else (
    echo Process aborted: "%lockpath%%~f0" is already running
    ping localhost > nul
)

exit /b

:start
cd /d %~dp0


start /b notepad.exe
What does variable %lockpath% contain?

if you have killed the system PATH variable by doing this Code: [Select]SET PATH=%lockpath%;"d:\test", why do you expect ping to work?

Do you know why it is a bad idea to name your own private variable "PATH"?

Did you write this script yourself or copy it from somewhere?
I have copied that script, point of that script is to alow only one instance of batch to be run.
with this I tried to make script to create lockfile in folder d:\test
Code: [Select]SET PATH=%lockpath%;"d:\test"because now script create lockfile in folder where is runned from.Any idea about path?Run this batch and consider what it tells you

echo off
Echo (1) running Ping command
echo ------------------------
ping -n 1 127.0.0.1
echo.
set PATH=blablabla
Echo (2) running Ping command
echo ------------------------
ping -n 1 127.0.0.1
pause
 

(1) running Ping command
------------------------

Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

(2) running Ping command
------------------------
'ping' is not recognized as an internal or external command,
operable PROGRAM or batch file.
Press any key to continue . . .What does that tell you?
Quote from: Salmon Trout on March 27, 2019, 12:18:36 PM

What does that tell you?
Sorry, really have no clueDid the ping command work both times?I told you WAY up above you shouldn't use a variable called PATH  or path in your scripts. Maybe you didn't read that. You didn't ask why. You don't understand anything about batch scripts, which makes it risky to run scripts you found on the web, and doubly risky to alter them when you don't know what you are doing. You could try something like this below, but maybe you would be better off actually trying to learn how to write your own scripts? or another language? People say good things about Python.

echo off
setlocal enabledelayedexpansion
echo my name is %~nx0
echo now I look for my name using Tasklist
set found=0
for /f "delims=" %%A in ('tasklist /v ^| find "cmd.exe" ^| find "%~nx0"') do set /a found+=1
echo Found this batch in Tasklist %found% time(s).
if %found% gtr 1 (
   echo Script with same name already running
   echo Exiting...
   pause
   exit
   )
REM rest of script
echo If I reached here I am the only %~nx0 running
pause

yes you are right.
I have intention to take class for powershell and learn that.
I know using path which is command is not good like using the name of the batch as some exe program in script.
I learn something but still need alot of it to learn.
thank you

when I test this notepad opens everytime when I run it but it should not.

Code: [Select]echo off
setlocal enabledelayedexpansion
echo my name is %~nx0
echo now I look for my name using Tasklist
set found=0
for /f "delims=" %%A in ('tasklist /v ^| find "cmd.exe" ^| find "%~nx0"') do set /a found+=1
echo Found this batch in Tasklist %found% time(s).
if %found% gtr 1 (
   echo Script with same name already running
   echo Exiting...
   pause
   exit
   )
notepad.exe
echo If I reached here I am the only %~nx0 running
pauseI thought you wanted a batch which would only allow one running instance of itself. Quote from: Salmon Trout on March 28, 2019, 09:54:25 AM
I thought you wanted a batch which would only allow one running instance of itself.

Yes it should run only one instance of batch but I see sometimes is runned two or more.
That's why I was searching for a script which will prevent starting another when first one already runs.
So script which I post it do that, but problem is I can't set a path where it SAVE that lock files.
When I run that script, while it is still running, if you open a new command window, and run it again, the new instance exits without starting Notepad.
Quote from: Salmon Trout on March 28, 2019, 11:43:24 AM
When I run that script, while it is still running, if you open a new command window, and run it again, the new instance exits without starting Notepad.
When I do that it opens notepad everytime.
I tested 3 times and opened 3 notepads.
1222.

Solve : Need help creating a batch file to change multiple folder icons in Win 10?

Answer»

Hey all. I recently upgraded to Win 10. On my old 7 setup, in my movie COLLECTION folder, the movie folder icons were images of the movies renamed to "folder". Everything worked well. Since the upgrade, Windows 10 crops the images named "folder" and it no longer works well. I have decided to replace the technique of using a jpg renamed "folder" to actually using icons of the movies. My issue is that I have hundreds of folders that I would like to apply this to. As of right now, I am moving the .ico into the folder, right clicking and going through he process of changing the ICON for that folder. This will take me months. I was wondering if ANYONE here has an idea for a batch file that would look in the folder for an .ico file and, if there is one, replace the default windows icon for that folder with the one I have moved in there.

I am only in the process of getting the icons as we speak. Previously on Win 7, I had jpgs in each folder and just renamed the jpgs to "Folder". Worked well, but Win 10 crops them noticeably. I was hoping to put the .ico's in each respective folder (DeviantArt has incredible ONES) to avoid having to rename them. I was looking to get a batch file to rewrite the .ini in each folder to change the regular folder icon to the new one (instead of right clicking for days).

Right now, I can right CLICK the folder, properties, customize, change icon, and browse to the movie.ico that I placed in that folder and the folder image will change. I just don't want to have to do that 1600 times to change all of the icons. I have placed each of the *.icos in their respective folder and want to change the desktop.ini file by batch, if possible. Currently, when I change the icon by the method above, the newly generated dekstop.ini file looks like this...

[.ShellClassInfo]
IconResource=D:\Movies\The Name of the Movie\The Name of the Movie.ico,0

Many thanks in advance.

1223.

Solve : Help With Creating A Batch File To Read The 2nd To Last Line Of Text?

Answer»

Hi, I need some help on creating a report file by reading the 2nd to last line of text

Here's some examples below

https://ibb.co/mTf2HnY
https://ibb.co/MZCv8dw

Basically I've tried playing around with a few formulas but none have got me the results I wanted, basically I have directories of  text files, I'm looking at the 2nd to last line of text to get the last number. It's a pain loading up all these files on notepad or notepad ++ and scrolling down to find this out when it would be easier to create a batch file to get the results for me without having to open up these files.

So I'd like to generate a text file called 'report.txt' to gather both the filename and the 2nd to last line of text. HOWEVER the text files will always be unique and there will be more than ONE in the directory. The batch file will be in the same directory as the text files so all i'll have to do is run it.

The report file needs to display

Filename1 - 2nd to last line of Text From Filename1
Filename2 - 2nd to last line of Text From Filename2
Filename3 - 2nd to last line of Text From Filename3
etc...

So It'll look something like this

208634168_4.txt - media_1175.ts
208634168_5.txt - media_1200.ts
208634168_6.txt - media_1122.ts
etc...

This is for all text files within the directory.


Thanks
So you WANT the PENULTIMATE line...


Yes

echo off
setlocal enabledelayedexpansion
if exist report.txt DEL report.txt
for %%A in (*.txt) do (
    set "lastline="
    set "thisline="
    for /f "delims=" %%B in ('type "%%A"') do (
        set lastline=!thisline!
        set thisline=%%B
        )
    echo %%A !lastline! >> report.txt
    )

Thank you very much, I appreciate your help on this one

1224.

Solve : Batch file for multi folders?

Answer»

So i want to make a .bat or .exe file on the desktop thats open up 6 Explorer windows arranged in a specific position with specific paths to folders on different drives.
My screen is 3440*1440 and i would like to split them equally.
I tried something like that:
Script:

echo off
start C:\Users\Sierr\Downloads
start Z:\
start S:\My Mod
start S:\Z Work Flow
start S:\Mod Organizer 32bit\mods\my mod\meshes\actors\character\meshes
start S:\Mod Organizer 32bit\mods\my mod\textures\actors\character\textures


But it opens only 1 folder per drive to the first folder that has a white space in it.
Also i didnt even start on arranging them.
Any ideas how i can achieve this.
I thought of using powershell But i dont really know how this works.

Powershell:

$ie1 = new-object -commandsobject Explorer.Application $ie1.navigate("D:Downloads")
$ie1.visible = $true
$ie1.top = 10
$ie1.width = 1146
$ie1.height = 720
$ie2 = new-object -comobject Explorer.Application $ie2.navigate("Z:")
$ie2.visible = $true
$ie2.top = 10
$ie2.width = 1146
$ie2.height = 720
$ie3 = new-object -comobject Explorer.Application $ie3.navigate("S:Z Work Flow")
$ie3.visible = $true
$ie3.top = 10
$ie3.width = 1146
$ie3.height = 720
$ie4 = new-object -comobject Explorer.Application $ie4.navigate("S:Modden/My Mod")
$ie4.visible = $true
$ie4.top = 10
$ie4.width = 1146
$ie4.height = 720
$ie5 = new-object -comobject Explorer.Application $ie2.navigate("S:mod organizer/mods/my mod/meshes/actor/charakter/my mod/armor")
$ie5.visible = $true
$ie5.top = 10
$ie5.width = 1146
$ie5.height = 720
$ie6 = new-object -comobject Explorer.Application $ie2.navigate("S:mod organizer/mods/my mod/textures/actor/charakter/my mod/armor")
$ie6.visible = $true
$ie6.top = 10
$ie6.width = 1146
$ie6.height = 720
$ie7.Left = $ie1.UpperLeft + $ie3.UpperMiddle + $ie5. UpperRight $ie2. LowerLeft + $ie4. LowerMiddle $ie6. LowerRight

Happy about any Help. Very basic Windows knowledge: for files or folders with spaces in the name, use double quote marks, e.g.

start "S:\My Mod" etc
Sure thats excatly WHATS i my script witout it it dosnt open any folder with it it behave like i describe it.

But Thanks for the answer Do you already have a method for doing multiple instances of Explorer?
Would you consider any method other than a batch script?
Have you considered other kinds of GUI file managers?
https://alternativeto.net/software/windows-explorer/
Quote

File Explorer, previously known as Windows Explorer, is a file manager application that is included with releases of the Microsoft Windows operating system from Windows 95 onwards. It provides a graphical user interface for accessing the file systems. It is also the component of the operating system that presents many user interface items on the monitor such as the taskbar and desktop. Controlling the computer is possible without Windows Explorer running (for example, the File | Run command in... More Info »
There are over two-dozen software things that allow more visuals options...
FreeCommander
muCommander
Explorer++
MultiCommander
Quote
Perhaps the most famous and most used Explorer alternative, MultiCommander, is the application that does it all. Like Explorer++, it provides a portable version (created by the installable version). And, like both of the previously mentioned alternatives, MultiCommander gives you a tabbed interface. (Only the tabs appear on the bottom.)

An' lots more.. Have you tried any of these o others? Thanks very much i didnt realy found any Programm thats fits my needs But i will Look into that and try them all

Simply said my main goal is to get fast to this 6 folders VISUAL sortet after i restart my PC. preferable a 1 klick solution
As it is now i have 6 links on the desktop.
After I opened them i drag an drop them to there Position.
Its not realy much work But its anoying if i do this multiple Times a dayTry Windows Manager. Not free.
http://www.desksoft.com/WindowManager.htm
Quote
WindowManager HELPS you to improve your work flow by remembering and restoring the position and size of your programs and windows. Many programs don't remember their position and size between sessions and even Windows Explorer does not restore windows to their last position under Windows 7 or higher. This is where WindowManager steps in and makes sure your windows are placed exactly where you want them every time you open them. WindowManager even allows you to lock the position and size of any window, so that it will always open at the same spot no matter where you move it. The window handling is fully customizable and you can set up special rules for your favorite or most frequently used windows. You can also make WindowManager send KEYSTROKES or mouse-clicks to a PROGRAM when its window is opened,
I have not tried it. It cost $10 and I have yet to pay this month's bills.
The batch solution offers no way to position the windows. The Powershell solution using Internet Explorer creates an object where you can position the windows. There are syntax errors in the new-object cmdlet but you have the right idea. Try using this syntax:

Code: [Select]$ie1 = (New-Object -ComObject InternetExplorer.Application).Navigate("D:\Downloads")

Another solution you can try would be to let Powershell position the windows automatically instead of you doing it manually:

Code: [Select]$shell = New-Object -ComObject Shell.Application

Invoke-Item -Path "D:\Downloads"
Invoke-Item -Path "Z:\"
Invoke-Item -Path "S:\Z Work Flow"
Invoke-Item -Path "S:\Modden\My Mod"
Invoke-Item -Path "S:\mod organizer\mods\my mod\meshes\actor\charakter\my mod\armor"
Invoke-Item -Path "S:\mod organizer\mods\my mod\textures\actor\charakter\my mod\armor"
Start-Sleep -Seconds 3

$shell.TileVertically()

Be aware this solution has a 3 second delay between the last window opened and positioning the windows. Also, the TileVertically method will tile all the open windows on your desktop.

Good luck.  Thank you very much All you for your Great Help.
I will test if i can make it work with Power Shell.

1225.

Solve : Mapping Network Drive with Bat Files?

Answer»

Could someone help me along in making a bat file to map network DRIVES when i run the bat file ?It is the same as GOING to command prompt and TYPE NET use. U just put the COMMANDS into a text file and save that file as .bat

Example:

net use z: //computer2

put the commands into a text file and save the file as a .bat file.

If u are still in doubt, u can read up on "net use" commands and bat files.

1226.

Solve : How To Move Then Delete SQL Dump File?

Answer»

I am trying to use a batch script to move a SQL dump from 1 server to a different one. The script I'm using will create the file and copy it but when I try using the MOVE command it only creates the file. I've INCLUDED the script below, any thoughts on how I can do this?

ECHO OFF

set TIMESTAMP=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%

REM Export all databases into file C:\DB Backups\backup\docuware.[year][month][day].sql
"C:\Program Files (x86)\DocuWare\Internal Database V2\bin\mysqldump.exe" --all-databases --result-file="C:\DB Backups\docuware.%TIMESTAMP%.sql" --user=admin --password=xxxxxxxx

REM Change working directory to the location of the DB dump file.
C:
CD \DB Backups

COPY "C:\DB Backups\" "E:\DW_PROD\Database Backups\



He hasn't been BACK in ALMOST 2 YEARS...Why you need a script to move file.
use robocopy it has many options to do that.

1227.

Solve : How to read first 2 bytes of selected file in DOS or command prompt by BAT?

Answer»

Hi!

I NEED to check first 2 bytes of file (no matter of type) by way using it as 1st parameter:

read_bytes.bat %1

In command prompt or DOS - best way by simple BAT file...

Can anybody help?
Thank you in advance.
MiroEasy in VBscript; hard in batch, so here is a hybrid. You need to uncomment the first red line if you want to see decimal byte values, or the second red line if you want to see hex values

echo off
echo Set fso=CreateObject("Scripting.FileSystemObject") > 2byte.vbs
echo Set f=fso.OpenTextFile("%1"):buf=f.Read(2):f.Close >> 2byte.vbs
REM You must UNCOMMENT one (only) of these lines
REM echo wscript.echo ASCb(mid(buf,1,1)) ^& "," ^& ASCb(mid(buf,2,1)) >> 2byte.vbs
REM echo wscript.echo Hex(ASCb(mid(buf,1,1))) ^& "," ^& Hex(ASCb(mid(buf,2,1))) >> 2byte.vbs
for /f "tokens=1,2 delims=," %%A in ('cscript //nologo 2byte.vbs') do (
   set byte1=%%A
   set byte2=%%B
   )
echo Byte 1 is %byte1%
echo Byte 2 is %byte2%

Examples:

Decimal

C:\>read_bytes.bat silesian.nzb
Byte 1 is 60
Byte 2 is 63

Hex

C:\>read_bytes.bat silesian.nzb
Byte 1 is 3C
Byte 2 is 3F




Works not.

Really it works only with executables, other files have incorrect values and even using quotes reports error (if were quotes removed it reports what is expected - file not found).

MiroThe Script Salmon provided works for me on seemingly any file. At least where VBScript is available.

There may be some oddities involved in terms of character encoding for certain files.

For "Pure" DOS (or the bastardized 7.1 version) If you have Access to QuickBASIC, you can use the following program:

Code: [Select]DIM FFNUM AS INTEGER
DIM READCHARS AS STRING
FFNUM = FREEFILE
OPEN COMMAND$ FOR INPUT AS #FFNUM
READCHARS = INPUT$(2,FFNUM)
CLOSE #FFNUM
PRINT ASC(READCHARS),ASC(MID$(READCHARS,2,1))

If you BUILD it then you can call the executable with the path of the file it will show the first two bytes. Unless the file is shorter than two bytes, I suppose, in which case it would crash.

Script works for me with exe, zip, XML, Excel xlsx, plain and Unicode text files. All checked using hex editor. Will give possibly unexpected results with Unicode encoded text files. You did ask for the first 2 bytesI asked first 2 bytes of file no matter of type...

MiroThat is what he gave you. He didn't MAKE it specifically work for the types he listed, he tried it with those types to verify it works with "All types".

You said "other files have incorrect values". How are you verifying the correct values? As Salmon notes, "two bytes" will not always mean "two characters". And the results from some files may not be what you expect but that is because your expectations are WRONG, not the results. EXE files for example will tend to always start with "4D 5A" (the MZ header) But a text file that starts with the text "MZ" may start with the bytes FF FE (a Byte Order Marker) or 4D 00 (the UTF-16 representation of M). Those results may be unexpected- but they are not incorrect.
1. To deal with quoted filenames, change 3rd line of batch file as in red

echo Set f=fso.OpenTextFile("%~1"):buf = f.Read(2):f.Close >> 2byte.vbs

2. OpenTextFile actually opens any file as a binary stream; f.read(n) reads the first n bytes of that stream. These bytes are stored in buf, a string or 1-D array.

3. The ASCB function....

Quote

is used with byte data contained in a string. Instead of returning the character code for the first character, AscB returns the first byte.




He's right you know... I think results can vary with your current codepage, unless you use MIDB to get the byte out of the string (as well as ASCB). Anyhow, this one uses the ADODB.Stream object.

Miro, give it a try...

echo off
echo Const adTypeBinary = 1 > 2bytes.vbs
echo filename = "%~1" >> 2bytes.vbs
echo Set BinaryStream = CreateObject("ADODB.Stream") >> 2bytes.vbs
echo BinaryStream.Type = adTypeBinary >> 2bytes.vbs
echo BinaryStream.Open >> 2bytes.vbs
echo BinaryStream.LoadFromFile FileName >> 2bytes.vbs
echo buf = BinaryStream.Read >> 2bytes.vbs
echo BinaryStream.Close >> 2bytes.vbs
REM Decimal or...
rem echo wscript.echo ASCB(MIDB(buf,1,1)) ^& "," ^& ASCB(MIDB(buf,2,1)) >> 2byte.vbs
REM Hex
echo wscript.echo Hex(ASCB(MIDB(buf,1,1))) ^& "," ^& Hex(ASCB(MIDB(buf,2,1))) >> 2bytes.vbs
for /f "tokens=1,2 delims=," %%A in ('cscript //nologo 2bytes.vbs') do (
   set byte1=%%A
   set byte2=%%B
   )
echo Byte 1 is %byte1%
echo Byte 2 is %byte2%
That works perfectly!

To all mentioned things:
I know that first code was not made for filetype and I know that files have headers and IDs, in case encoding also each character can be written differently.
When I asked no matter of type I mean always first two bytes - not characters, not other units, first two bytes of file beginning.
I was very surprised in first code that it was handled as text input, but I don't know VBScript, so I could change only few things.
Binary access is required for raw data and so is handled last version.
Quotes were problem and I see in new code that were handled by simple command line parameter.

Thank you for all your work.
Miro Quote from: MIRKOSOFT on April 25, 2019, 01:46:27 PM
I know that first code was not made for <any> filetype
It was meant to work for any file type.
I'm sorry for bad English.

I meant: It was not for filetype.

I gave into brackets any 'cause it was not for TXT, not for BMP, not for XLS, that it was for each.

I had to write: It was for each filetype - but I'm not sure if it is in English correct.

MiroBut does it work for what you want?
Yes, works and thank you very much.

MiroThat's good.
1228.

Solve : search in log for file names in folder?

Answer»

Not sure what I am doing wrong here...
WINDOWS 7 but running it as a dos batch file

have a bunch of PDFs in a folder (c:\files\*.pdf) and I want to see which of these files are not in a log file.

in the log file the messages are (once per file):
>>>log.txt
Login name is [email protected]
Attached binary file: MAY2019_1978727_E.pdf
File saved.
>>>

What I thought I would need was...

echo off
for %%f in (c:\files\*.pdf) DO (
echo %%~nxf
findstr /m %%~nxf log.txt
if %errorlevel% NEQ 0 (
echo %%~nxf was not found XXXXXXXXX
)
)


PSEUDO code...
for all the PDFs in the "files" folder
find the file name (no path header) in the log file log.txt
If the file is not in the folder
then echo the file name was not found XXXXXX

basically the log file confirms all the files that should be in the folder but looking for any PDFs that are not in the log file for some reason

I am sure it is something simple but brain stopped working after VERSION 15 and a couple of hours googling lol

thanks

You can't set + read a %...% type variable in a loop; you have to use delayed expansion and use ! instead of % around the variable name.

echo off
setlocal enabledelayedexpansion
for %%f in (c:\files\*.pdf) DO (
    echo %%~nxf
    findstr /m %%~nxf log.txt
    if !errorlevel! NEQ 0 (
        echo %%~nxf was not found XXXXXXXXX
    )
)

If you just want a console message saying whether or not a PDF file was found in the log, you can simplify the batch a lot, to one line in fact:

for %%f in (c:\files\*.pdf) do findstr %%~nxf log.txt >nul &AMP;& (echo %%~nxf found: YES) || (echo %%~nxf found: NO XXXXXXX)

Code: [Select]FAQ.pdf found: YES
faq2.pdf found: NO XXXXXXX

   Many thanks... this worked great. I just created a small batch file to call the one below and piped it to another log file and then just did a search for the XXXX... interesting tidbit... was expecting 15 and found 27 (out of 5500) so it has also found another potential issue we need to look into. Thank-you for that as well!

Quote from: Salmon Trout on May 05, 2019, 10:29:46 AM

You can't set + read a %...% type variable in a loop; you have to use delayed expansion and use ! instead of % around the variable name.

echo off
setlocal enabledelayedexpansion
for %%f in (c:\files\*.pdf) DO (
    echo %%~nxf
    findstr /m %%~nxf log.txt
    if !errorlevel! NEQ 0 (
        echo %%~nxf was not found XXXXXXXXX
    )
)

1229.

Solve : MS-DOS 7.10 and LOCK command to enable/disable direct IO access to disks?

Answer»

Hi!

I have LONGER time installed MS-DOS 7.10 and at installation I enabled drive locking.
I found software which requires direct disk access and I don't know how to unlock drives.

I TRIED:
- remove LOCK command calling from AUTOEXEC.BAT
- use command UNLOCK

Nothing helped.
Is possible to disable drive locking for enabling direct disk access?
Or even toggle enable/disable direct disk access?

Thank you for each help.
MiroYou are using the drive letter and the colon? As in unlock C:      ?

Do you get any error messages?

Yes, drive letter and colon.

No any message.
If I write not correct value it reports:Unlock not successful.

MiroHow do you know the drive is actually locked?From Our Archives...patio: Yes.

Mirkosoft: have you any deleted files in the undelete queue?

undelete /list

undelete /purge

unlock L:
(where L is your drive letter)

Note: I do not have an Win95/98 MS-DOS volume to try this on.

Look here, go down the page to the UNLOCK command notes

http://www.mdgx.com/newtip3.htm

Salmon he's usin FAT 32...it states there the procedure only works per FAT 16

Just noticed that may only apply to recovery...it sounds like you got the functionality backwards. LOCK ALLOWS direct disk access. UNLOCK disallows it, as seen by LOCK /? and UNLOCK /?.

Remember that most DOS applications are not designed to work with FAT32,  using those applications with a FAT32 drive will cause problems.He also INSISTS on usin DOS 7.1 thru all these headaches instead of finding and purchasing DOS 6.22...

Just sayin.Used application is designed for MS-DOS and Windows 3x - Windows 95...

So I think it can work with FAT32.

MiroI am finished with assisting you because you don't listen...
Best of Luck figuring things out.

1230.

Solve : Remove characters from a text file?

Answer»

Hi, been STRUGGLING to get this to work.

I have a txt file with 500 lines and growing, each LINE in the beginning has the text as the example below. I already have a batch file that joins 2 text files and one has K:\logs3\ and the other list just the files including folders.
ex. K:\logs3\test.txt

Its not a option to simple remove the FOLDER as that would create more issues and more work. Therefore is the a way to remove these charaters form the line - K:\logs3\ ?

Thanks in AdvanceManage to resolve my own problem but another issue has pop up concerning the same code.
The code below removes the FIRST 11 characters from a line in a text file. my issue now is to delete letters or characters in the middle of a text line. Example - I have C:\folder\doc - would like to remove "folder\ only and leave c:\ + doc.

think the issue might be over here - SET "line=!line:~0,11!"

Thanks in Advance



echo off &setlocal
(for /f "delims=" %%a in (list.txt) do (
    set "line=%%a"
    setlocal enabledelayedexpansion
    set "line=!line:~0,11!"
    echo(!line!
    endlocal
))>list.txt.new

1231.

Solve : name input?

Answer»

How do i do this?
(its not realy like this, but its the way i do it)

ECHO Hi *NAME* > test.txt
ECHO Bye *name* >> test.txt

but the *name* part must be defined by the USER

thxECHO Hi %1 > test.txt
ECHO Bye %1 >> test.txt

The %1 substitutes the text following the batch FILE name into the batch file, if the name of the batch file is TEST.BAT, you'd type:

TEST MYNAME

and MYNAME would be substituted for the %1 in the above statements.
But I need the user to enter the *name* into the screen, is this possible and if it possible; how?Try INPUT.ZIP from http://garbo.uwasa.fi/pc/batchutil.html, and note that there are tons of other batch utilities there too.

1232.

Solve : Control GUI options from a Batch file?

Answer»

I am RUNNING a batch file that edits the registry, but I don't want the user prompted to add the CHANGES,  I just want it to add the settings.http://jpsoft.com/tcmddes.htmAutoIt http://www.autoitscript.com/autoit3/ is the utility I use for STUFF like this.

1233.

Solve : New Windows 10 terminal?

Answer»

I wonder if anyone has tried the NEW Windows Terminal? It's in the Microsoft Store (Win 10 only). I know it's just an alpha release, but it seems fairly complete.



Very configurable; the settings are in a JSON file. I have been using JSONedit, free, at http://tomeko.net/software/JSONedit/



I find it handy to have tabs available, not only for the defaults (Powershell, cmd.exe, and any WSL installs you have), but also I have added "profiles" which leverage the WSL.exe command to have ssh logins to my Raspberry Pi, a Debian box, and my Seagate NAS.

Lots of fun playing around!
For some reason, it has never occurred to me to use the SSH that is part of the Ubuntu distribution (or really any WSL distribution) instead of PuTTY. Well, until now. The capability to add Profiles seems to be the biggest feature IMO of this new Terminal.

Of course now I'm down the rabbit hole.

I couldn't get the command line to work directly, instead it WOULD always start the distro bash itself, but not run ssh- even though the same wsl command in command prompt did in fact start SSH.

So I thought I'd create a shell script. Then decided to go a step further and use perl, so I could use the Net::SSH::Perl module Easy enough. Even found a script for it. How hard could it be?

Well, I think I almost got that bit to work- 2 hours later. down the rabbit hole to run a 8 line perl script. Just waiting on cpan to finally install Net::SSH::Perl not that I sorted out the prerequisites. Not sure why the Terminal profile isn't working to run a command directly, though.

My only real complaint about the application itself though is that the tabs are in the titlebar. I've always disliked that trend (Thanks Google Chrome...) In this case, It means moving the window requires using the area right next to the caption buttons.
Quote from: BC_Programmer on July 01, 2019, 07:44:49 AM

Of course now I'm down the rabbit hole.

Yup. A whole Saturday.

Quote
I couldn't get the command line to work directly, instead it would always start the distro bash itself, but not run ssh- even though the same wsl command in command prompt did in fact start SSH.

Note: each profile must have a unique GUID, I got mine from a web GUI generator.

Odd. I did it like this... in a profile, the "commandline" string value is like this

(you aren't using bash.exe are you? Use wsl.exe.)

-u name is your USERNAME in the wsl distro
-l name is your remote host username

wsl.exe -d Legacy -u mike -e ssh 192.168.0.5 -l mike

you have to get the wsl -d distro name right, mine is "Legacy", it's WSL Ubuntu from before the distros got in the Windows Store. Find out your name(s) by doing wsl -l at the cmd prompt. Should work, I think.

Quote
My only real complaint about the application itself though is that the tabs are in the titlebar. I've always disliked that trend (Thanks Google Chrome...) In this case, It means moving the window requires using the area right next to the caption buttons.

In the settings JSON, in the Global section, change the Boolean value showTabsInTitlebar to false

Hope this helps. Quote
wsl.exe -d Legacy -u mike -e ssh 192.168.0.5 -l mike

Everything after -e is the wsl bash command

Thanks, I think it must have been the guid, changing it worked. I imagine what happened is it ended up somehow using data from both- I think I had considered the GUID but figured it couldn't matter since it did use the new name in the drop down; but when SELECTED must have been identifying it based on GUID and therefore grabbing the command line for the standard Ubuntu profile.


Quote
In the settings JSON, in the Global section, change the Boolean value showTabsInTitlebar to false
Brilliant, my only real issue has a config!Re the GUID, that was my learning path, too. I just copied the whole WSL profile and tinkered around, but initially left the GUID the same, like you. I wish the tab text could be customised to say e.g. "Pi", Debian", "WSL", etc. but you can change the icons. As supplied the icon paths look like ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png. On my install that leads to a png in
C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.2.1715.0_x64__8wekyb3d8bbwe\ProfileIcons,
but you can make it any path you like e.g. c:\myicons\debian.png.

The ability to set a custom icon for each profile means that each tab can have its own visual identity, but what appears as tab text is inconsistent; the ssh session on the Debian machine has the Debian prompt, but the Pi retains the wsl.exe command line.
1234.

Solve : DOS inexpert needs help with one little command line?

Answer»

Hi
I'm TRYING to do a forfiles command (I think).  I want to do a listing of all files in a DIRECTORY with the dates.

I usually do DIR\s\b>>  and output to a text file.  This is great, but I would like the dates.  Ideally, I'd also like to select for certain dates, too.
I tried this, which worked great:
 Forfiles /p "a:\Directory\filename with spaces" /s /d -2006-1-3 and that worked great, though I didn't try to send the output to a text file.

I tried it like this:
 Forfiles /p "a:\Directory\filename with spaces" /s /d -2006-1-3  /C “cmd c/ echo fdate”

and like this

 Forfiles /p "a:\Directory\filename with spaces" /s  /C “cmd c/ echo fdate”

and the command line just blinked at me, uncomprehendingly.

I want the exact syntax to say "COMPUTER, please print out the CONTENTS of this directory with dates but not all the other stuff."  I don't want all the s, time, size, and other details.

It would be great if I could command it to find contents created before a date (or between dates) and print it out but I'll take the FORMER if I can get it.

The end result is to take the directory list to a spreadsheet and make it searchable and sortable and be able to sort or search documents by date.

Help?

thanks

Merry





I suspect you want the contents of a folder not the properties of a single file. Also you are referencing the a: drive which is a floppy. Is this correct?

You can try this:
Code: [Select]forfiles /p c:\Directory /s /c "cmd /c echo file,fdate"

I changed to drive letter to the system drive, but can be any valid drive on your system. If you redirect the output, it will be in csv format suitable for loading into Excel.

Good luck.

1235.

Solve : Fdisk Doubled my hard drive?

Answer»

HELLO
     I WAS PARTITIONING MY HARD DRIVE BY RUNNING FDISK COMMAND. IT DOUBLED MY HARD DRIVE. I DONT KNOW BUT ANY WAY IT DID THAT. I TRIED TO DO THAT AGAIN BUT FAILED. MY HARD DRIVE CAME TO ORIGNAL POSIOTION. CAN U TELL ME. I WANT TO DO THAT AGAIN AND DOUBLE MY HARD DRIVE.
BYE BYE
Please fix your caps lock and try again. Describe what you mean by 'doubling' your hard drive. Did it try to set up a phantom second partition the same SIZE as the primary partition that is the physical size of your drive? Or did it just set up your 20GB drive as an 8 GB and a weird second partition?HI! did you change jumpers or use different Operating system than it was before, normaly when you didn't configured hard drive properly, or BIOS Configuration or use different OS could also MEANS change of hard drive space or just sometimes motherbord can't handle the hard drive size and the only solution to that is to set drive space to a low size.

PS. TELL US WAT DID YOU DO DIFFERENT THAN BEFORE, IT COULD BE SEVERAL REASONSWhile you may have seen a phantom drive of the same capacity as your physical drive, FDISK is incapable of generating usable storage in excess of the physical capacity you have.

1236.

Solve : ms-dos boot disk?

Answer»

I have windows xp home. I found the links to make an MS-Dos boot disk and did so. My problem is that the boot disk has no CD-rom support. I would LIKE to install an earlier version of windows for those NOSTALGIC days of X-Com and the like but I can't even edit the boot disk. The edit command gives me a "Bad command" message. Any ideas?http://www.bootdisk.com has boot disks with CD support.  

As far as editing the existing boot disk, why not boot up in XP and edit it on the floppy, that way you'll have several editors to use.

1237.

Solve : prompt?

Answer»

what is prompt    

is it a abbrevi'ation  It is the command LINE in DOSThe environment variable 'prompt' is the 'label' at the front of the DOS command line.

prompt $p$g
c:\windows>

prompt Press any key to format C drive
Press any key to format C drive
(This was a popular joke back in the DOS days. Annoying, but basically harmless. No actual format would be done.)

prompt Win4.1 $p$g
Win4.1 c:\windows>

A prompt is any character group indicating the system is ready to accept a DOS command. Some attempts by DOS virii to install 'ANSI bombs' as prompts caused a little consternation back a decade ago, but most of that business is easily prevented with a virus scanning app.If you TYPE:

PROMPT /?

You'll get decent help:

Changes the cmd.exe command prompt.

PROMPT [text]

 text    Specifies a new command prompt.

Prompt can be made up of normal characters and the following special codes:

 $A   & (Ampersand)
 $B   | (pipe)
 $C   ( (Left parenthesis)
 $D   Current date
 $E   Escape code (ASCII code 27)
 $F   ) (Right parenthesis)
 $G   > (greater-than sign)
 $H   Backspace (erases previous character)
 $L   < (less-than sign)
 $N   Current drive
 $P   Current drive and path
 $Q   = (equal sign)
 $S     (space)
 $T   Current TIME
 $V   Windows 2000 version number
 $_   Carriage return and linefeed
 $$   $ (dollar sign)

If Command Extensions are enabled the PROMPT command supports
the following additional FORMATTING characters:

 $+   zero or more plus sign (+) characters depending upon the
      depth of the PUSHD directory stack, one character for each
      level pushed.

 $M   Displays the remote name ASSOCIATED with the current drive
      letter or the empty string if current drive is not a network
      drive.

1238.

Solve : Changing 'A' prompt to CD drive prompt?

Answer»

When booting with a start up disk - Win 98, Norton rescue or 'restart in MS-Dos mode'-- into the dos mode, I can get an "A" drive prompt.  I can change that to my "C" drive prompt (and also my "D" & "E" prompts as I have my hard drive partitioned into three drives).  However, I can't change it to my Zip drive ("F") or my CD drive ("G").  If there a way to do this?  The purpose being to access one of those drives to run a virus check such as Symantec's Pre-Scan available from their website (the program will not fit on 3 1/2" floppies so I have to use a R-RW CD or Zip disk.  Plus, at one time in the past when I also was running MS-Dos and Dosshell under Win 3.11 I could do all of this.  What can I do to access my Zip & CD drives after booting into Win98 dos?  Thanks for any help or references you can give me.  Tom
     PS>  When I am in windows 98 and bring up the MS-Dos Prompt program, I can access  both my hard drives and my Zip/CD drives, but not when I boot up in dos.You need to ADD some files to your startup disk (A).
oakcdrom.sys
mscdex.exe

Add line to config.sys
device=oakcdrom.sys /D:mscd001

Add line to autoexec.bat (last letter is drive letter for CD)
mscdex /D:mscd001 /M:10 /L:G

Thanks for responding,
     I did as directed:  Added oakcdrom.sys and mscdex.exe to my startup disk; plus added the lines to the config.sys/autoexe.bat files. Then I rebooted to check; both files had the added lines as directed but also had REM TShoot: above them.  
     I then put my startup disk in the A drive - with the new config.sys, autoexe.bat files along with the oakcdrom.sys and mscdex.exe files - and rebooted.
     It loaded so far and then stopped:  This is what was on the DOS screen.

Starting Windows 98

This Driver is provided by Oak Technologies, Inc.
011-91X ATAPI CD-ROM DEVICE DRIVER, REV D91XV352

Vortex Dos Audio Driver (2.000) Copyright (c) 1997,98 Aureal Semiconductor

Error#3:  WINBOOTDIR Environment variable missing, Driver not Loaded

At this point it stopped.  Should I have done it differently?  ThanksI would have to see the entire autoexec.bat and config.sys file content to judge. Why are you running an audio driver on a boot floppy?

The lines to load the CDROM drivers are valid. If you are running HIMEM.SYS and EMM386.EXE, you can also use devicehigh in config.sys and lh in autoexec.bat. For the ZIP drive, there should be a file called GUEST.EXE in your IOmegaWare package that you can run from DOS (autoexec.bat) to enable your ZIP drive.The first help from Computer_Commando above had me try putting "oakcdrom.sys " on my start up disk.  Is this the audio driver you are referring to?  

My Autoexec.bat & config.sys files at the present are as follows:

Autoexe.bat>
ECHO OFF
SET BLASTER=A220 I5 D3 T4
LH C:\WINDOWS\AU30DOS.COM
C:\WINDOWS\asp4dos.com
SET CLASSPATH=C:\PROGRA~1\PHOTOD~1.0\ADOBEC~1;"C:\Program Files\JavaSoft\JRE\1.3\lib\ext\QTJava.zip"
SET QTJAVA="C:\Program Files\JavaSoft\JRE\1.3\lib\ext\QTJava.zip"
SET Path=%Path%

Config.sys>
DEVICEHIGH=C:\WINDOWS\COMMAND\DRVSPACE.SYS /MOVE

My Autoexec.bat & config.sys files with Computer_Commando's instructions were as follows:

Autoexe.bat>
ECHO OFF
SET BLASTER=A220 I5 D3 T4
LH C:\WINDOWS\AU30DOS.COM
C:\WINDOWS\asp4dos.com

Rem TShoot:
mscdex /D:mscd001 /M:10 /L:H

SET CLASSPATH=C:\PROGRA~1\PHOTOD~1.0\ADOBEC~1;"C:\Program Files\JavaSoft\JRE\1.3\lib\ext\QTJava.zip"
SET QTJAVA="C:\Program Files\JavaSoft\JRE\1.3\lib\ext\QTJava.zip"
SET Path=%Path%

Config.sys>
DEVICEHIGH=C:\WINDOWS\COMMAND\DRVSPACE.SYS /MOVE

Rem TShoot:
device=oakcdrom.sys /D:mscd001

NOTE:  I didn't place the "Rem TShoot" in them;  that just came about when I rebooted after
adding the other changes.

My start up disk had HIMEM.SYS but not EMM386.EXE.  What is 'lh' ?  My IOmegaWare package has 'GUEST.EXE' .  What do I do with it?  Thanks, Tom
This is all you need for the config and autoexec, for the CDROM.  Start with this and nothing else and see if the CDROM is recognized.

I suspect there's a "device=" for the Zip drive; PROBABLY a line for the autoexec which will ASSIGN the drive letter.  Download "Iomega Driver for DOS" from Iomega.


config.sys
dos=high,umb
lastdrive=Z
device=himem.sys
devicehigh=oakcdrom.sys /D:mscd001


autoexec.bat
LH mscdex /D:mscd001 /M:10 /L:G
If you visit www.bootdisk.com you'll find a number of MS-DOS boot disk images that will do this for you without any editing.

1239.

Solve : can i build new external commands??

Answer»

Hi,
firstly, i'm a bit of a newbie to DOS, so sorry if this's really easy!
secondly, i've tried the FAQ pages and searching the FORUMS but i can't find an answer to my problem...

Ok, what i've been trying to do is install a Java Development Kit in Windows XP.  I usually use Linux to do this kind of stuff, so what i'd like to do is to be able to type in commands in DOS ,e.g. 'JAVAC' (that's the compiler), and for them to work regardless of which directory i'm currently in.
Here's an example:
just say i'm in directory C:\chris and i want to compile a file, HelloWorld.java.  I can compile the file if i type in:
c:\jdk1.31\bin\javac HelloWorld.java
i.e. the full path to the compiler, then the filename.
but... because i'm super lazy i just want to type:
javac HelloWorld.java

i've tried putting shortcuts in c:\windows\system32 (that's where external commands seem to be stored?) to the javac.exe program and i've even tried to copy javac.exe to there but it doesn't work (it can't find the necessary libraries).

is there anyway that i can, sort of, choose which directories i want the command PROMPT to search through to find the executable files?


many thanks for reading, it'd be amazing if someone could HELP me out...
Chris.
I think there are some environment variables (set java=c:\progra~1\java141 or something similar) you can use to aid this. Check your documentation. Include the JAVA directory in your PATH statement, as well. Set these in your DOSSTART.BAT or similar file.Sure, it's called the PATH variable.  If you put any directory you want to be searched for executables on the path, DOS will find them anywhere you invoke them from.

Note that you may need to be logged into that directory for the application to function properly, I do that by having a \BAT directory with command files to do whatever I require for a given command.  You can do many tasks with batch files in this manner.  For example, here's a handy little batch file that takes a snapshot of a directory and keeps a number of generations of it in ZIP files.  I use it when I'm developing code to keep generations.  You can also expand the number of generations just by adding more rename commands.


echo off
rem
rem This batch job does a daily backup of the current directory into
rem a subdirectory called DAYBACKS under the current directory.  If
rem the DAYBACKS subdirectory doesn't exist, it is created.
rem
if not exist daybacks\nul mkdir daybacks
cd daybacks
if not exist day1.zip goto noday1
if exist day10.zip erase day10.zip
if exist day9.zip ren day9.zip day10.zip
if exist day8.zip ren day8.zip day9.zip
if exist day7.zip ren day7.zip day8.zip
if exist day6.zip ren day6.zip day7.zip
if exist day5.zip ren day5.zip day6.zip
if exist day4.zip ren day4.zip day5.zip
if exist day3.zip ren day3.zip day4.zip
if exist day2.zip ren day2.zip day3.zip
if exist day1.zip ren day1.zip day2.zip
:noday1
if exist ..\*.bak attrib +h ..\*.bak
if exist ..\*.zip attrib +h ..\*.zip

if NOT exist c:\temp\nul md c:\temp
pkzip c:\temp\day1.zip ..\*.*
move c:\temp\day1.zip .

if exist ..\*.zip attrib -h ..\*.zip
if exist ..\*.bak attrib -h ..\*.bak
cd ..

1240.

Solve : Can I log into a network with a batch file?

Answer»

I'm trying to  USE a .bat to log into a nework.

I think I can get the LOGIN name , but how do you activate the key?

thanks

ssU have to tell me the CODE of ur batch file, so i can solve ur problem. R u using Telnet?Can you please help me to login to a FTP server using a batch file and also in a telnet server please reply to my email id [email protected] i cannot give my user name in the field can you please help meGrrr... Stop spamming! Have u ever heard of nettiquette?Hi 'The Computer Geek',

I am also trying to find out if there is a way of "auto-telneting" into a networked computer using a DOS batch file. Do you have any ideas?

Regards,
'Stuck'

1241.

Solve : Batch File - Run Next Program When 1st Complete?

Answer»

Hi,

Can anyone help with the CODE that would be required to do the following :

execute program c:\download.exe
and ONLY WHEN THIS FINISHES,
execute program c:\import.exe
end

download.exe creates a file CALLED c:\output.raw so would I need to check to see if this has stopped being created ETC or is there some other WAY I can check for download.exe FINISHING before running import.exe?

Help appreciated. Thanks.

G.Under plain MS-DOS, you can just put the two programs in the batch file one after the other, the second program won't be invoked until the first one terminates.  If this isn't what you're talking about, please be a bit clearer on what you're trying to do.
1242.

Solve : How do I Un-minimize the prompt after an user minimized it??

Answer»

My problem is quite simple
And I imagine it has a really easy way to fix it
But no matter how much I searched for it I can't find it
How do I Un-minimize the PROMPT after an user minimized it?

I'm making a simple timer routine
timeout for an hour
choice
If the user don't input anything it sends the computer to hibernation
The problem I'm facing is
Since it is a program that should stay running on the background until the timer is over its usually minimized
I just need a way to Un-minimize it when the timer runs out so that the user can decide if it wants to continue or notYou can't get a batch to de-minimize ("restore") itself without using 3rd party utilities like cmdow.exe (for example).

cmdow http://www.commandline.co.uk/

However without any addons you can make one batch (minimized) execute another (not minimized) using the START command.

echo off

if exist second.bat DEL second.bat
echo echo off >> second.bat
echo title SECOND >> second.bat
echo cls >> second.bat
echo echo. >> second.bat
echo echo ********************************** >> second.bat
echo echo * YOU HAVE 30 SECONDS TO RESPOND * >> second.bat
echo echo ********************************** >> second.bat
echo echo. >> second.bat
echo choice /T 30 /C yn /D y /M "Hibernate now Y/N? " >> second.bat
echo if "%%errorlevel%%"=="2" exit >> second.bat

REM edit out the ECHO in capital letters
REM when you are happy it works
REM or insert your hibernate command instead
echo ECHO shutdown /h /t 0 >> second.bat

REM delete these 2 lines when you have debugged
REM and are happy
echo PAUSE >> second.bat
echo exit >> second.bat

title FIRST
echo Please minimize me!
set delay=60
REM or 3600 or whatever
timeout %delay%
start "" "second.bat"
Of course you don't have to write second.bat every time. No need for a second file. Here's another method - the script is started with no command line parameter, then, after the timeout, the script starts itself again, not minimized this time, passing a parameter which makes it jump to a label where the choice, hibernate stuff happens.

echo off
if "%1"=="2" goto second
title FIRST
echo Please minimize me!
REM or 3600 or whatever
set delay=60
timeout %delay%
start "" "%~dpnx0" 2
exit

:second
title SECOND
echo **********************************
echo * YOU HAVE 30 SECONDS TO RESPOND *
echo **********************************
echo.
choice /T 30 /C yn /D y /M "Hibernate now Y/N? "
if "%errorlevel%"=="2" exit

REM edit out the ECHO in capital letters
REM when you are happy it works
REM or insert your hibernate command here
ECHO shutdown /h /t 0

REM delete these 2 lines when you have debugged
REM and are happy
pause
exit

Thank you very much Salmon Trout!
It was exactly what I NEEDED!

1243.

Solve : Copying registry from one computer to another?

Answer»

Hey, I was wondering what will happen if I'll copy one registry files from a laptop to a desktop computer, also the way I was thinking about it is go into the registry and make export file and then move it to the desktop computer with Disk-On-Key and then just use it as a backup. So, will it work fine for my desktop computer if I will do it?
(Sorry if it's not easy to understand because of my ENGLISH)Registry files work best when exported and imported between same exact hardware, as well as when same software is INSTALLED to systems. There is more in the registry than just settings for user preferences and software keys etc, there are also hardware specific keys that if you mismatch to a build can be a headache or crash.

I wouldn't import a registry from a laptop to a desktop computer because of the drastic DIFFERENCES between hardware. You can try it but be prepared to nuke the desktop by pushing a laptops registry to it.

I wouldn't be messing in the registry unless you know what your doing. EVEN myself having MANY years playing in the registry rarely go in there to make any changes and when I do its like 1 key that is changed to change the behavior of the computer or fix a problem from a dirty uninstall that left orphan entries which were causing problems with Windows thinking a program was still installed when it was uninstalled etc.

Be sure to backup all your important data to external hard drive or cloud storage, as well as have the media required to perform a clean installation back to systems before you venture into registry alterations as for you might find yourself having to rebuild the installation of Windows if you mess it up badly.Why would you want to do this ? ?
The system OS's need to be the same however if you wanna proceed...
Good LuckPS if you wanna screw aroung with registrys ERunt is the tool you want...I want to do it because I've banned in some game and in other PC's in my house I can play so I was thinking if it will let me play if I will copy one of my other computers registries.
Already tried VPN, changing my MAC address and HWID, none of these options worked for me and I am desperate because I want to play this game again. (Of course, I won't cheat again, I wouldn't make much effort just to cheat again.)Topic Closed.

1244.

Solve : If/and code?

Answer»

Is there a CODE I can use in this case?

I have set up the set /p choice codes, but this code

Code: [Select]:game
Player 1 CHOSE %p1choice%!
Player 2 chose %choose%!
if %p1choice%='1' and %choose%='2'
ECHO Player 2 wins!
does not work.

The code closes itself. So, I want to know - is there a code I can use that WORKS LIKE the "if [choice=1] and [choice=2] then echo [xyz]"You don't get logical AND operator in batch but you can simulate it with 2 IF tests on one line

You have the syntax wrong for IF tests, you need double equals signs, and if you have quotes they must be on left and right side of the == and the action you take if both tests are passed must be on the same line or in a bracket block

if '%p1choice%'=='1' if '%choose%'=='2' echo Player 2 wins!

if '%p1choice%'=='1' if '%choose%'=='2' (
    echo Player 2 wins!
)

Study batch syntax at a good site like SS64.com.

Play around at the prompt

C:\>set p=1

C:\>set q=1

C:\>set r=2

C:\>if '%p%'=='1' echo yes
yes

C:\>if '%p%'=='1' if '%q%'=='1' echo yes
yes

C:\>if '%p%'=='1' if '%q%'=='2' echo yes

C:\>if '%p%'=='1' if '%r%'=='2' echo yes
yes





Or you can do this

if '%p1choice%'=='1' (
    if '%choose%'=='2' (
        echo Player 2 wins!
    )
)

1245.

Solve : Batch file Count within folders of specific name?

Answer»

Hi All,

Can anyone help me on a Batch file code that would count a specific filename ?

I already know how to count number of files within a folder but i dont know how to incorporate it on a specific filename.

echo off
for /F %%A in ('dir ^| find "File(s)"') do set cnt=%%A

Sample Filename EGRHI-Tenant1-01061219.csv = 061219 is the date of the sales file (not the date of the day)

something like count all files ??-???-??06??19.csv

I need to count all files on a monthly basis for EXAMPLE how many files on 0619.

If theres a BLANK that would ask me what month and year the better.

Many thanks
Anyone ?There is no error checking for two digit responses to the prompts, but ILL leave that to you.

Code: [Select]echo off
set /p mm=Enter Month:
set /p yy=Enter Year:
for /f %%A in ('dir *%mm%??%yy%.csv ^| find "File(s)"') do set cnt=%%A
echo %cnt%

You can REMOVE the last line. It was used it for testing.

Happy Coding

1246.

Solve : Issue regarding variable initialization in dos script?

Answer»

Hello Gurus,
  I have script which will pull the filenames of a folder as "xyz01.csv". Then extracts the 2 digit before dot and creates folder of that NAME (Ex:01) .Then move the file into that new folder. Below is the one I WROTE. Somehow the variable is not WORKING correctly which gives the folder name incorrectly. I added the SetLocal function in the begin but does not help me.
 Any help is highly appreciated.

Thanks,



 echo off
SetLocal EnableDelayedExpansion
cls

set  SourceDir=C:\TEMp\WORK_TEST\INPUT\
set TargetDir= "C:\TEMp\WORK_TEST\OUTPUT\"

REM:::  ------------CODE FOR CSV

for %%i in (%SourceDir%*.csv) do (

    set var=%%i
    set substr6=%var:~-6,-4%
      echo !var[%%i]!
      echo !substr6!
    echo !substr6!---Extracts 6digits from end then remove the last 4


   IF EXIST %TargetDir%%substr6% (

      echo folder EXISTS
      move %%i  %TargetDir%%substr6%

   ) ELSE (

      echo folder do not
      mkdir  %TargetDir%%substr6%
      move %%i  %TargetDir%%substr6%

   )


)
Variables created within a for loop must be wrapped with ! signs not % signs. Also used the base name portion of the file name to keep it SIMPLE: set var=%%~ni

Code: [Select]echo off
SetLocal EnableDelayedExpansion
cls

set  SourceDir=C:\TEMp\WORK_TEST\INPUT\
set TargetDir= "C:\TEMp\WORK_TEST\OUTPUT\"

REM:::  ------------CODE FOR CSV

for %%i in (%SourceDir%*.csv) do (

    set var=%%~ni
    echo !var!
    set substr6=!var:~-2!
    echo !var[%%i]!
    echo !substr6!
    echo !substr6!---Extracts 6digits from end then remove the last 4


   IF EXIST %TargetDir%!substr6! (

      echo folder exists
      move %%i  %TargetDir%!substr6!

   ) ELSE (

      echo folder do not
      mkdir  %TargetDir%!substr6!
      move %%i  %TargetDir%!substr6!

   )


)

Good Luck.

1247.

Solve : print to com port?

Answer»

need help!

How,in DOS, PRINT to COM port?Use MODE.

mode com1:=9600,n,8,1,b
mode prn:=com1:


These two lines set the COM1 port to 9600 bits per SECOND, no parity, 8 data, 1 stop BIT, and binary. Substitute the string for your Diablo 630 or whatever you use on a serial port. Then the PRN: (default printer) is assigned to COM1: instead of LPT1:.

mode prn:=lpt1:

can be issued after printing to RETURN the output to your parallel printer.

If you ONLY print to the serial printer, make the first two lines part of your Autoexec.BAT file.Thank you. This is WORK!This work, bat if shange question,
How , in DOS, read/write from/to COM port?If you wish to use a text terminal on com1:, you can issue:

mode=com1:9600,n,8,1,p
mode con:=com1:


to assign con:, the default Console device, to the terminal after setting up the com port to the same settings as the terminal (I'm assuming 9600bits/sec, no parity, 8 data, 1 stop, and no timeoouts).

You would then issue

mode con:=con:

from the terminal to return control to the default console.

If you wish to communicate with a modem on the com1: serial port, run a DOS terminal program.

1248.

Solve : Add string to certain position?

Answer»

Hi all,

Long time no see 

I'd like to insert a string into position 15 in a oneliner .txt file using a batch script that utilizes Dave Benham's amazingly great repl.bat (https://www.dostips.com/forum/viewtopic.php?f=3&t=3855).
I have used repl.bat for years and it is just awesome.  Many thanks to Dave if you ever read this! 

Here's my batch script
Code: [Select]set value=add_this_string
type "file.txt"|repl.bat "(.{14})...............(.*)" "$1%value%$2" > "file.txt.new"
Problem
The above script works fine if there are already characters in position 15. It also works if position 15 and onwards consist of whitespace. However, if the line ends before pos 15 the string is not inserted.

I discovered repl.bat's successor jrepl.bat (https://www.dostips.com/forum/viewtopic.php?f=3&t=6044) just the other day but haven't found someone who has solved this problem so any help using either one of them would be of great help!

Any help would be appreciated!  My thought on this is that you will want to pad the files with added spaces for files that are under a 15 CHARACTER count. You could do this to all files if you have a bunch of them and it will just add padding to the end of the lines in the files.

Here is a similar article to what you may need to do. If it were me, I'd pad the files by 15 spaces at the end of all lines, so all files will have a 15th character to target at {14}. Reading what you said it seems as though string length in each file is not important so padded lines with spaces shouldn't mess anything up.

https://superuser.com/questions/907792/how-can-i-pad-every-line-in-a-text-file-with-a-given-number-of-spaces-with-uneve

Below is quoted from that link using the power of SED. *You will need to edit this to add however many spaced to the end of lines that you want. Below only adds 3 spaces. Unable to play with this from work COMPUTER on my break :

Quote

But if you're editing the file, sed will serve you well

Quote
sed 's/^.*$/&\ \ \ /G' some_file > some_other_file
This will add 3 spaces to the end of each line in some_file and write the output to some_other_file. Note that the spaces are ESCAPED and the ampersand serves the purpose of writing the first PATTERN to the output.
1249.

Solve : cant get out of dos?

Answer»

every time i start my computer i goes to DOS mode and command screen i type exit but it WONT LEAVE dos mode and i CANT get back to window HELP
Make sure you have windows installed 1st.

At c prompt, type dir to check your files. If u have win98 you shd have windows folder, if u have win2000 u shd have winnt folder.

can try cd windows or cd winnt and type winPossible corrupt MSDOS.SYS. You should have a line in MSDOS.SYS 'BootGUI=0' or 'BootGUI=no'. Change to read 'BootGUI=1' or 'BootGUI=Yes', as appropriate, USING a DOS text edittor.

1250.

Solve : How to close an Access Database in Dos?

Answer»

I am try to FIND a dos command to CLOSE a currently opened access database.  I am using XP.  Will TASK KILL work and if so how do I USE it