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.

8601.

Solve : Manipulating file/folder location in BAT files?

Answer»

All,

I hope this isn't a full-on noob question, but here goes.

I use BAT files in my "SendTo" right-click MENU to process files on our server. This LOCATION is stored in the %1 value as (example) X:\folder1\folder2\longfoldername3\file.ext. I WANT to separate the folder location of the file and the filename itself. How can I grab X:\folder1\folder2\longfoldername3 as one variable and file.ext as another variable?

THANK you for any help.

Sincerely,
Cj.Quote from: cjplay on August 28, 2007, 09:48:55 AM

This location is stored in the %1 value as (example) X:\folder1\folder2\longfoldername3\file.ext. I want to separate the folder location of the file and the filename itself. How can I grab X:\folder1\folder2\longfoldername3 as one variable and file.ext as another variable?

See FOR /?

If %1 is a filename, whether just the filename e.g. afile.ext or a path and filename eg d:\folder\subfolder\afile.ext then...

%~1 - expands %1 removing any surrounding quotes (")
%~f1 - expands %1 to a fully qualified path name
%~d1 - expands %1 to a drive letter only
%~p1 - expands %1 to a path only
%~n1 - expands %1 to a file name only
%~x1 - expands %1 to a file extension only

%~s1 - expanded path contains short names only
%~a1 - expands %1 to file attributes of file

%~t1 - expands %1 to date/time of file
%~z1 - expands %1 to size of file

These can be combined...

N.B. The file need not exist, an imaginary filename is still processed just the same, although items impossible to resolve, such as size, date/time, etc expand to blanks.

This is a folder...

Quote
S:\Backup\Test\stringlen>dir
Volume in drive S is USB_HDD
Volume Serial Number is 6C1A-995E

Directory of S:\Backup\Test\stringlen

28/08/2007 18:13 <DIR> ..
28/08/2007 18:13 <DIR> .
16/08/2007 21:38 476 sfor.cmd
16/08/2007 21:24 436 slen101.cmd
16/08/2007 21:34 43 slenFB.bas
16/08/2007 21:34 16,384 slenFB.exe
16/08/2007 21:34 16,384 stringlength.exe
28/08/2007 18:15 49 filestuff.bat
6 File(s) 33,772 bytes
2 Dir(s) 277,761,826,816 bytes free


This is filestuff.bat

Quote
@echo off
REM this is filestuff.bat
echo parameter passed %%1 is %1
echo remove quotes if needed %%~1 is %~1
echo fully qualified path %%~f1 is %~f1
echo file name %%~n1 is %~n1
echo extension %%~x1 is %~x1
echo drive letter and colon %%~d1 is %~d1
echo path only %%~p1 is %~p1
echo.
echo you want...
echo.
echo drive letter, path %%~dp1 is %~dp1
echo filename and extension %%~nx1 is %~nx1

This is the output of the command:-

filestuff "sfor.cmd" ...

Quote
parameter passed %1 is "sfor.cmd"
remove quotes if needed %~1 is sfor.cmd
fully qualified path %~f1 is S:\Backup\Test\stringlen\sfor.cmd
file name %~n1 is sfor
extension %~x1 is .cmd
drive letter and colon %~d1 is S:
path only %~p1 is \Backup\Test\stringlen\

you want...

drive letter, path %~dp1 is S:\Backup\Test\stringlen\
filename and extension %~nx1 is sfor.cmd


Holy crap thank you...
8602.

Solve : Hard drive Identifying in DOS 6.2?

Answer»

Here is the problem.
Son in law has a connor HD from MacPlus system. on which he has CV and other Thesis data that he would like to retrieve.

Has tried the MacOpener route, as well as other file openers without success.

Now as a last hope he is trying to get to this drive via DOS 6.2

Has installed the HD as a SCSI drive through ADAPTEC 2910 PCI card. with DOS drivers.


Has been able to Identify in Autoexec.bat and or Config.sys the Card.

So far he is able to get the IDE HD as C: drive identified. Nothing else on this HD except DOS 6.2

What is the line to use in Autoexec.bat and/or Config.sys to have system recognise the SCSI srive as D:\ drive and the CD rom as E:\ Drive.

I guess that what he would require is the listing of autoexec.bat and config.sys to configure recognition of the two Hard drives, and CDROM drive.

Allowing him to transfer the files from the SCSI drive to IDE and/or CDROM

Your input, assistance is greatly appreciated.

try posting this in the mac/apple section insted u should get more help from thereThis data recovery attempt needs to be done on a Mac system as that's what type of file system being used.
There are conversion programs but you risk making a mess of it and losing all the data.did as suggested.
But this is DOS oriented as not using ANYTHING but a SCSI Hard Drive, that is connected to a PCI card in a PC environment Case without any WINDOWS being loaded... only DOS 6.2..

Or am I ?

The idea is to get the files off the SCSI onto IDE and or CDROM.
Than the files can be recognized by MacOpener (licensed) and/or other converters.

As of now, through winXP, or Win98, have not been able to get the SCSI drive to be recognized. Therefore cannot read what is on drive and transfer DATA only.

In the Mac Plus, the drive functions perfectly and can see the files, which were made in WP 5.0 DOS. and have the Disks for this version.

That's the reason of going pure DOS route.

Still not sure of the method but if you insist i'll go along...are there SCSI drivers being loaded on startup on the PC ? ?Patio, yes the SCSI drivers are loaded.

But

What is the line to use in Autoexec.bat and/or Config.sys
to have system recognize the SCSI Drive as D:\ drive
CD rom as E:\ Drive.

I guess that what i am asking for is the listing of autoexec.bat and config.sys
to configure recognition of the two Hard drives, and CDrom drive.According to the boot ORDER is what will determine how DOS sees each drive designation...
To find out which is which you can from a C: prompt type D: and hit enter and then dir /p and enter again which will show each drive's contents...
This should give you a clue as to which drive is being given which letter designation.Patio

I have gone into autoexec.bat and config sys... but I am missing a command to have the Hard Drive being recognized. have been successful to recognize the CD Rom and the IDE drive... but there has to be a " device=xxxxxxxxxx" for the second.HD

When I go over I will write down the lines from these two files and re=post, to see which command is missing for recognition.

so close.... yet sooooo far.

8603.

Solve : sinister things?

Answer»

i have noticed that many PEOPLE that goes on this forum and comes to this SECTION ALWAYS has some sinister thoughts like hacking a game or hacking into the school system
others have more thoughts like hacking into a site using ip???

so im suggesting that whoever post asking for help about HACKS should be
banned hope admin u look at this postHappens a lot.
I don't think people need to be banned for the first offence though.
I'm sure the admin and moderators already have a system in place to deal with people like that, they're no different from others who break the forum rules.Quote

so im suggesting that whoever post asking for help about hacks should be
banned hope admin u look at this post

Yeah, not fair. Sometimes they don't know what they are really talking about until someone tells them.Why not re-size that sig so the goofy scrollbar isn't there ? ?OK there is one in place i cant find the post on it right now but if i find it or maybe GX or fed know where it is they might post the link



unlovedwarrior
8604.

Solve : s3 upload batch script?

Answer»

Hi,

Im looking for a batch script which will upload the directory in to amazon s3 cloud.... But i dont know how to do it... Also i need a batch script for INCREMENTAL backup, everyday it need to check the directory and its subfolder/files ACCORDING to the modification(date/time) then need to be moved to Amazon s3....

Please guide/help me on this.

Regards
PaulwintechAny TYPE of activity like this with a cloud will require FIRST off that you have drives mapped from your local machine to that of the VIRTUAL cloud. Once a drive or folder on that drive is mapped to your local machine, you can do whatever batch processes that you require.

Once the mapping is in place you can add a batch to a scheduled task on your Windows system and have it perform rolling backups etc.

8605.

Solve : Batch File to get MAC Addresses?

Answer»

Hey guys can anyone help me create a batch file that will get the mac address off multiple machines and save it to a network file?

I have a lab of 60 desktops and would LIKE to run a batch file on each machine that will find the MAC address and save it to a internal server such as \\server1\folder1\folder2\macaddress.txt

ThanksI can't help you with this but I defiantly would like to know how to do this as well I found this, it may help.Thanks for that link BC! I've been playing with:

Code: [Select]ipconfig /all|find "Physical Address">>\\district5\Common\Public\macadd.txt
for /f "tokens=2 delims=:" %%i in (\\district5\Common\Public\macadd.txt) do
@echo The MAC Address is %%i
Seems to be working fine except I don't know how to separate each entry with a BREAK line or something....I added a random number to the output file name so each file on the server would be unique. Also added the computer name to the output file so you could distinguish the MAC addresses. Otherwise you had it just about right.

Code: [Select]@echo off
for /f "tokens=2 delims=:" %%i in ('ipconfig /all ^| findstr /i "Physical Host"') do (
echo %%i >> \\server1\folder1\folder2\macadd%random%.txt
)

Good luck. you can use getmac. see getmac /? for more info.
Ahh thanks for all your help guys. I have it all setup now the way I want it and ready to deploy it tomorrow!!!

Thanks again!Quote from: ghostdog74 on January 04, 2011, 09:29:16 PM

you can use getmac. see getmac /? for more info.

Also: I think that tool would be available via a resource kit for W2K and earlier (it's included in XP Pro and up). (just checked, it's in the NT4 resource kit and no doubt is in the w2k one). I doubt they are running an OS before XP on any of the machines anyways, though.

The batch method will work with NT4 and 2000 (not as sure about NT4).

getmac would be the better solution regardless- it's designed for the very purpose required.

O yea should of mentioned its for XP and Win7 Quote from: BC_Programmer on January 04, 2011, 10:07:19 PM

The batch method will work with NT4 and 2000 (not as sure about NT4).
I may be wrong, but i see no options of ipconfig that can query a set of remote addresses. if OP has 60 desktops to process, then ipconfig may not work as well as getmac.
Here is what I ended up with and will work just fine for what were doing.


Code: [Select]echo ------------------------------------------------ >>\\server\Common\Public\getmac\MV-mac.txt
echo ------------------------------------------------ >>\\server\Common\Public\getmac\MV-mac.txt
echo %date% >>\\server\Common\Public\getmac\MV-mac.txt
echo %COMPUTERNAME% >>\\server\Common\Public\getmac\MV-mac.txt
echo %username%>>\\server\Common\Public\getmac\MV-mac.txt


ipconfig /all|find "Physical Address" >>\\server\Common\Public\getmac\MV-mac.txt
for /f "tokens=2 delims=:" %%i in (\\server\Common\Public\getmac\MV-mac.txt) do
@echo The MAC Address is %%i
Quote from: Fiala06 on January 04, 2011, 10:33:03 PM
Here is what I ended up with and will work just fine for what were doing.


Code: [Select]echo ------------------------------------------------ >>\\server\Common\Public\getmac\MV-mac.txt
echo ------------------------------------------------ >>\\server\Common\Public\getmac\MV-mac.txt
echo %date% >>\\server\Common\Public\getmac\MV-mac.txt
echo %COMPUTERNAME% >>\\server\Common\Public\getmac\MV-mac.txt
echo %username%>>\\server\Common\Public\getmac\MV-mac.txt


ipconfig /all|find "Physical Address" >>\\server\Common\Public\getmac\MV-mac.txt
for /f "tokens=2 delims=:" %%i in (\\server\Common\Public\getmac\MV-mac.txt) do
@echo The MAC Address is %%i

so you have to run it on EVERY machine ? if you have a list of ip address or computer names of those 60 machines, you can use getmac with /S to query them all without having to go to every machine and run it.Quote from: ghostdog74 on January 04, 2011, 10:28:51 PM
I may be wrong, but i see no options of ipconfig that can query a set of remote addresses. if OP has 60 desktops to process, then ipconfig may not work as well as getmac.
Quote
I have a lab of 60 desktops and would like to run a batch file on each machine
Not remote. Of course a option that means they don't have to run it on each machine would be easier. Especially since it is part of the OS's in use. (and you really only need one machine that has getmac to get the various addresses)Quote from: ghostdog74 on January 04, 2011, 10:48:30 PM
so you have to run it on EVERY machine ? if you have a list of ip address or computer names of those 60 machines, you can use getmac with /S to query them all without having to go to every machine and run it.

Well either way I have to touch them all. These are all new computers with an image I use. There all setup with DHCP so I'll have no idea what the IP's are. We need the mac address's so we can reserve address's on our servers for each INDIVIDUAL machine.

Retracted suggestion after re-reading last post.
8606.

Solve : Bat file ICALS enable inheritance?

Answer»

Hi

I'm USING this command to enable inheritance on a folder and by default "replace all child object PERMISSIONS with inheritable permsissions of this object"

isn't ENABLED so when i use this command it enables inheritance on "my folder" but not the child objects so how would i get this to apply to child objects

also . I tried inserting (OI)(CI) to try and apply to This folder, subfolders, and files and i'm still stuck its invalid when i try to insert (OI)(CI).

Code: [SELECT]ICACLS "C:\Program Files\my folder" /inheritance:e


To explain more i want to add an inheritance FLAG to my code above so it applies to sub objects and sub containers.

the command /inheritance:e enables directory inheritance so how do i add replace all child objects with inheritable permissions from this object ?

Please help me

8607.

Solve : Getkey.com Oddity?

Answer»

I'm not quite sure why this is (it hasn't happened on my other computer before) but when I use getkey.com in my code, I get a "File not found" error. It appears that the error actually comes from getkey.

Code: [Select]@echo off
REM HAVE THIS AT START OF BATCH
echo hD1X-s0P_kUHP0UxGWX4ax1y1ieimnfeinklddmemkjanmndnadmndnpbbn>getkey.com
echo hhpbbnpljhoxolnhaigidpllnbkdnhlkfhlflefblffahfUebdfahhfkokh>>getkey.com
echo l/[emailprotected]>>getkey.com

REM YOUR CODE FOLLOWS

REM example

Echo Please press a key

getkey.com

set ascii=%errorlevel%

echo You pressed key code %ascii%Here is the example code I copied from Dias, but like I said, I get the error. I've tried calling it it with 2>nul, but that doesn't work either. Any solutions?its 2011, have you considered using a better language yet?it works fine here (well, it works on a XP VM, doesn't work on my win7 due to 16-bit compat (or lack thereof)).

Is this the full problem code? (that is, with that small script do you get the error?)I get the error even by running the com file manually. What's even stranger is it works on my desktop computer (XP Home), but not my laptop (XP Pro).Would it help to put a delay loop in the code before you try to read the file which you think you wrote but may actually be still drifting through the O.S. and the disc write cache on its way onto the disc drive ?

I remember losing about 0.1% of the messages redirected to a file.
I suspected my software view of the world ignored the reality of I/O latency.
My output file was in C:\ which was 12 GB with 50% free space on a 160 GB drive.
I altered the output destination to a partition at the other extreme of the platter for maximum track travel,
and a hundredfold increase of error rate to 10% in place of 0.1% confirmed my suspicions.

I did of course try disabling the write cache, but that doubled the time taken for the computer to start up.

Alan
I ran the script multiple times, each time giving the error. Then I ran the script and ran the COM file a minute later (I forgot lol) and I got the error.I don't have getkey.
Code: [Select]Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\bat>getkey
'getkey' is not recognized as an internal or external command,
operable program or batch file.

D:\bat>Quote from: Geek-9pm on January 07, 2011, 11:22:21 PM

I don't have getkey.
Code: [Select]Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\bat>getkey
'getkey' is not recognized as an internal or external command,
operable program or batch file.

D:\bat>
you should look carefully at the batch script again.oh, YES. It does work fine.
Now I have getkey.com and now that I have it, what will I do with it?why do you want to run code that you don't understand? That is some obscure batch/DOS HACK (to hide password entry) that i, for one, would not want to maintain. Also, don't ever use batch to prompt for password. Its useless. Whoever can open the batch file can bypass this.I suggest you use START / RUN / CMD.EXE

Then make its home directory wherever your script is.

1.
Use DIR and confirm that getkey.com exists there as expected.
a) Perhaps for some reason when you ran the script the output went to a different folder / partition / drive.
b) Perhaps you have some security protection which quarantines or blocks any executable created by a batch script.

2.
Assuming that getkey exists, how big is it.
I find that by default it is exactly 137 bytes on my system - THE NON-DEFAULT ALTERNATIVE IS 274 BYTES.
By default my CMD.EXE starts life in ANSI output mode,
but when I put on the command line
CMD /U
I get Code: [Select]C:\Documents and Settings\Dad>CMD /U
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Dad>and now when this runs the script (which is still ANSI) the redirected output is in UNICODE which is twice as long.

To see the options for launching CMD.EXE invoke CMD /?
It says a lot about "extensions", and also about registry keys that control it.
Perhaps there is something special about your system that caused your script to be executed in Unicode mode.
N.B. It is possible your that when your script is executed, the system defaults may cause UNICODE/ANSI output when you execute by a double click in Windows Explorer, and the converse ANSI/UNICODE when you invoke the script from the command line of CMD.EXE launched from START / RUN.

No way will I try to run a unicode variant of getkey.com - it may give the error you have seen, or it may do unlimited damage.
A few decades AGO I had a DOS 3.ish machine with high powered tools EDLIN and DEBUG.
I was comfortable at that time to use EDLIN and DEBUG to create and adjust things like getkey.com.
I had a 1 inch thick stack of fanfolded printer listing with all the entry points into the DOS OPERATING System, and also all the special places in the BIOS.
I remember there were magic numbers that could be used with DEBUG to launch the BIOS into a format of the Hard Drive to alter the size of the sectors and the number of sectors per track - BUT I ALWAYS CHICKENED OUT.
I am astonished that the "magic numbers" that are redirected into the getkey.com file still do in Windows XP and CMD.EXE what they used to do in DOS command.com. Do all the ancient EDLIN scripts for hundreds of old COM things still work as well for XP, how about Vista and Windows 7, and what about Windows 8 ?

Alan
Quote from: ghostdog74 on January 08, 2011, 01:30:02 AM
why do you want to run code that you don't understand? That is some obscure batch/DOS hack (to hide password entry) that i, for one, would not want to maintain. Also, don't ever use batch to prompt for password. Its useless. Whoever can open the batch file can bypass this.
I used it before (on my desktop) so that the user could press a button and the script would respond depending on which button was pressed. It would work as a password type script, but not well.

@ALAN
Yes, it does exist. I check on my desktop and with DIR. It is also 137 bytes and 4,096 bytes on disk. I'm just going to restate something - It's GETKEY.COM that gives the File not found error, not the script.These are your mistakes :-
You NEVER told us what the error message was,
You never said that Getkey ISSUED the error.

I had assumed the error message was from the O.S. trying to locate GetKey and failing.

Perhaps you should post the exact message.
e.g. I have no GetKey and CMD.EXE shows me
Code: [Select]D:\_T\D3\Reg\V2>getkey
'getkey' is not recognized as an internal or external command,
operable program or batch file.
Is that the error message you get ?
Are you using CMD.EXE or COMMAND.COM ?

The other possibility is that getkey.com is using magic hex values to work its voodoo,
and it assumes that various subroutines will be accessible at certain special places.
Perhaps (as I always feared) these subroutines may be missing or in slightly different locations,
possibly as a special tweak by the Laptop maker to make way for battery power management ?

Regards
Alan
Helpmeh: can you copy a version of the getkey program as created on the machine where it works to the one where it doesn't or perform a file compare between them?


Quote from: ALAN_BR on January 08, 2011, 11:37:00 AM
You never said that Getkey ISSUED the error.

He said it in the first post
"It appears that the error actually comes from getkey."

The actual, verbatim message would certainly have been nice. Especially since saying "file not found" came from getkey is sort of vague.

Here is the dissasembly of the resulting executable(getkey.com), anyway:

Code: [Select] code SEGMENT
ASSUME CS:code, DS:code
ORG 100h

strt:

PUSH 3144h
POP AX
SUB AX,3073h
PUSH AX
POP DI
IMUL [DI+48h],DL
PUSH AX
XOR [DI+78h],DL
INC DI
PUSH DI
POP AX
XOR AL,61h
JS J00148
JNS J0014A
IMUL [DI+69h],AH
INSW
OUTSB
DB (66h)
DB (65h)
IMUL [BP+6Bh],CH
INSB
DB (64h)
DB (64h)
INSW
DB (65h)
INSW
IMUL [BP+SI+61h],CH
OUTSB
INSW
OUTSB
DB (64h)
OUTSB
POPA
DB (64h)
INSW
OUTSB
DB (64h)
OUTSB
JO J0019B
BOUND [BP+0Dh],CH
OR CH,[BX+SI+68h]
JO J001A3
BOUND [BP+70h],CH
INSB
PUSH 68h
OUTSW
J00148: JS J001B9
J0014A: INSB
OUTSB
PUSH 6961h
DB (67h)
IMUL [SI+70h],AH
INSB
INSB
OUTSB
BOUND [BP+DI+64h],CH
OUTSB
PUSH 6B6Ch
DB (66h)
PUSH 666Ch
INSB
DB (65h)
DB (66h)
BOUND [SI+66h],CH
DB (66h)
POPA
PUSH 5566h
DB (65h)
BOUND [SI+66h],AH
POPA
PUSH 6668h
IMUL [BX+6Bh],CH
PUSH 0A0Dh
INSB
DAS
PUSH CX
OUTSB
DEC BX
INC BP
INC AX
DEC AX
INC DX
XOR SS:[BX+SI+2Eh],CX
OR AX,000Ah

code ENDS
END strt


Aside from the fact that this dissassembly is probably different from the actual source assembly (particularly the lack of comments which is not surprising) It pretty difficult to read. As ghostdog said, it's pretty dumb to be accepting passwords in a batch, even if you use a tool like this. It's still in plain text after all, so anybody can get the password simply by viewing the file. Oftentimes a "defense" for this is that "well, they probably won't look in the file" That's a rather weak defense of it. Basically: the above is a mess of Assembly that only works on 16-bit operating systems or systems that can emulate 16-bit. I know this because 64-bit doesn't emulate 16-bit (except via a VM where it works fine) and it just shows a dialog saying "hey, retard, you can't run 16-bit programs on a 64-bit OS".

"But" you say- "I just want to get it working on both machines". Well, then you better learn ASM or get somebody who knows ASM to figure out what the program is doing and how the heck it's causing a "File not found" error. (and perhaps explain that error a little better, is it simply "File not found" or does it give the error ALAN_BR describes? In the latter case it's not getkey.com issuing the error at all so you've been accidentally tossing out that red herring the whole time without realizing it.


Quote
No way will I try to run a unicode variant of getkey.com - it may give the error you have seen, or it may do unlimited damage.
No MATTER how carefully crafted the ASM, the protected nature of the NTVDM (as well as the fact that it is in fact a virtualization environment) it cannot do any sort of damage. (that I can think of) in this case, the "damage" is limited to the corrupted getkey.com (which is virtually the same as the original with a null byte thrown in every while) just sorta throws the cursor AROUND randomly in the DOS window until you stop it. Which is actually pretty extraordinary, since most of the time when you run some semirandom bit of faff as code it just barfs out a illegal operation: Invalid Instruction pretty early on. It's probably because all it does is pad in a bunch of zeros which are somehow valid, or something.

-With the NTVDM, "dangerous" instructions (like directly accessing the hard disk) will cause faults and the DOS executable will be forced closed. (not always the case for 9x, though, since it truly runs on a DOS subsystem, although 9x is still pretty heady when it comes to DOS programs messing about with FAT32 or VFAT drives and complains about Long file name preservations and whatnot.
Quote
A few decades ago I had a DOS 3.ish machine with high powered tools EDLIN and DEBUG.
I wouldn't really call a cheap assembler "high power", especially compared to the various other assemblers available at the time. I'd be more inclined to say "useful" in the same way that a knife is useful to scoop ice cream when you have nothing else, whereas TASM and the other Assemblers where the Ice cream scoops. That being said, the "knife" version was free and while it's a bit annoying to use a knife to scoop ice cream it can be done. in fact on the whole it's weird(cool) that they included something like that(debug, I mean)- but it certainly was useful. Come to think of it though a lot of what people were doing with DEBUG could be just as easily done in BASICA, which was included with early versions as well. (OTOH, you can't run BASICA programs now because (for space reasons) it's default save format was binary. I couldn't remember if DEBUG let you use actual ASM or just the hexcodes- so I checked it let's you use ASM, which is useful, but only the most basic instructions... (which was enough for things like determining wether SHARE was running:

Code: [Select]N ISSHARE.COM
A 100
MOV AX,10000
INT 2F
MOV AH 4C
INT 21

R CX
9
W
Q

which you could save to a file and then save to debug.

Code: [Select]DEBUG<ISSHARE.ASM
and POOF! you have ISSHARE.COM.

Anyway, best you could do was essentially the "Magic numbers" thing. Throw values into specific memory locations, call an interrupt, and then inspect the same random locations or possibly some other set of random locations.

Thing is, it is extremely low level; even though the memory locations can be found by looking through it, these memory locations often have nothing to do with DOS itself and more to do with inspecting other programs (for example, wether SHARE is loaded). Interestingly enough, the "ISSHARE" ASM program broke fairly quickly, when MS integrated the DOS SHARE redirector right into windows for workgroups; the debug script result basically looks in specific locations that it knows that SHARE messes about with and should contain certain values, but SHARE.VXD didn't so it pretended it wasn't loaded.

Quote
I had a 1 inch thick stack of fanfolded printer listing with all the entry points into the DOS Operating System, and also all the special places in the BIOS.
Probably would have been better to get the actual manuals, rather then printing out some stuff from BBS's -I mean no offense of course, but that is a rather small stack, (no doubt useful, but perhaps too concise) and (of course your memory may have faded with time, so they may well have gotten the following correct) "DOS entry points" are called "DOS interrupts" and "special places in the BIOS" could be any number of things (but generally also BIOS interrupts) Mostly the important bits were the Interrupts, and each interrupt usually used the various Registers to perform tasks. (I have no idea how debug puts stuff in the registers, or even if it could)

Quote
I remember there were magic numbers that could be used with DEBUG to launch the BIOS into a format of the Hard Drive to alter the size of the sectors and the number of sectors per track - BUT I ALWAYS CHICKENED OUT.
Interrupt 13H. Not sure why you'd chicken out... of course it would be silly to expect a drive format to preserve the data, but the worst case scenario would probably be having to format again afterwards. (of course, if you thought that it would simply change the format without formatting the drive itself then it's a good thing you decided not too!
Quote
I am astonished that the "magic numbers" that are redirected into the getkey.com file still do in Windows XP and CMD.EXE what they used to do in DOS command.com.
pretty much all the script does is move the cursor around and accept a bit of input. the NTVDM was practically designed specifically to let 16-bit programs like that work.

Quote
Do all the ancient EDLIN scripts for hundreds of old COM things still work as well for XP, how about Vista and Windows 7, and what about Windows 8 ?
depends what they do. Any x64 (or IA-64) OS isn't going to run the COM files anyway; 32-bit versions will run them with limitations, some interrupts are entirely off-limits (such as I believe everything in 13H) in fact those were even limited to some degree by windows 9x) some others just cause the NTVDM to say the program performed an illegal operation and will be terminated. Windows 8 is purported (I doubt it though) to be 64-bit only and if that's the case it won't be able to run any 16-bit software at all.

BC, the dissembler is if little value.
We need the real source code to see what went wrong.
Does anybody else here really want the original source code?
Is it available?
8608.

Solve : Outputting the Number of Files Copied and the Total Number of Lines Copied?

Answer»

I am attempting to WRITE a batch file that copies the data in all files with the specified criteria into one file (the date is included in the filename for the example below). I would like to output to the Audit.csv file the number of files copied and the total number of lines in all of the files (not including the first line of each file). I am using Windows 7. This is what I have so far.

::GET DATE VARIABLE FROM USER
set /p dte=Enter the file date to copy as MMDDYY:

::COPY THE FILES TO COMBINED FILE
copy c:\mcr\%dte%*.* /y c:\mcr\Combined_%dte%.csv /v

::WRITE THE CURRENT DATE & TIME TO AUDIT FILE
echo %date% %time% >> c:\mcr\Audit_%dte%.csv

Quote

This is what I have so far.

And what were the results? I'm not aware of any switches for the copy command that will produce a line count. My best guess would be the bulldozer approach, manually copying each line of each file to the combined file and doing the counting along the way. It's not pretty but the logic is sound.

Code: [Select]@echo off

::Get date variable from user
::
set /p dte=Enter the file date to copy as mmddyy:

:: Start with new files
::
if exist c:\mcr\combined_%dte%.csv del c:\mcr\combined_%dte%.csv
if exist c:\mcr\audit_%dte%.csv del c:\mcr\audit_%dte%.csv

::Output each line of the files to the combined file
::
for /f "tokens=* delims=" %%i in ('dir /b c:\mcr\%dte%*.*') do (
for /f "tokens=* delims=" %%j in (c:\mcr\%dte%%%i) do (
echo %%j >> c:\mcr\Combined_%dte%.csv
set /a tLines+=1
)
set /a tFiles+=1
)

::Write the current date & time to audit file
::
echo %date% %time% %tLines% %tFiles% >> c:\mcr\audit_%dte%.csv


Quote
... and the total number of lines in all of the files (not including the first line of each file).

I wasn't sure why this was needed so I'll let you subtract the tFiles variable from the tLines variable just prior to to outputting the audit record.

If you have long file names with embedded spaces or special characters you may need to use quotes in the for statements.

Good luck.
Count the number of lines in a file; doesn't skip blank lines, or lines starting with a semicolon like FOR does

Code: [Select]For /f "tokens=1* delims=:" %%A in ( ' findstr /N /R ".*" "filename.ext" ' ) do set lines=%%A
%lines% contains the number of lines in the file


Code: [Select]@echo off
setlocal enabledelayedexpansion
if exist test.txt del test.txt
for /l %%N in (1,1,10) do echo Line %%N blablabla>>test.txt
echo.>>test.txt
echo ; line starting with a semicolon>>test.txt
for /l %%N in (13,1,20) do echo Line %%N blablabla>>test.txt
echo test.txt begin
echo --------------
type test.txt
echo --------------
echo test.txt end
echo.
for /f "tokens=1* delims=:" %%A in ('findstr /N /R ".*" "test.txt"') do set lines=%%A
echo findstr counted %lines% lines

set flines=0
for /f "delims=" %%L in (test.txt) do (
set /a flines=!flines!+1
)
echo FOR /F counted %flines% lines
echo.


Code: [Select]test.txt begin
--------------
Line 1 blablabla
Line 2 blablabla
Line 3 blablabla
Line 4 blablabla
Line 5 blablabla
Line 6 blablabla
Line 7 blablabla
Line 8 blablabla
Line 9 blablabla
Line 10 blablabla

; line starting with a semicolon
Line 13 blablabla
Line 14 blablabla
Line 15 blablabla
Line 16 blablabla
Line 17 blablabla
Line 18 blablabla
Line 19 blablabla
Line 20 blablabla
--------------
test.txt end

findstr counted 20 lines
FOR /F counted 18 lines






Sidewinder - I tried your code and entered 102510 at the prompt. Filenames are 102510_ABC and 102510_DEF.
I'm getting "The system cannot find the file c:\mcr\102510102510_ABC" and "The system cannot find the file c:\mcr\102510102510_DEF"
Any ideas as to why this is happening?Sometimes you just have to look at things from a different angle, so I turned my monitor upside down. Actually I went back to your basic structure, shamelessly stole borrowed the counting lines code from Mr. Trout, did a little tweaking and came up with a result not nearly as ugly as the first.

Code: [Select]@echo off

setlocal
set indir=c:\mcr
set outdir=c:\mcr

:: Get date variable from user
::
set /p dte=Enter the file date to copy as mmddyy:

:: Delete any PREVIOUS files
::
if exist "%outdir%\combined_%dte%.csv" del "%outdir%\combined_%dte%.csv"
if exist "%outdir%\audit_%dte%.csv" del "%outdir%\audit_%dte%.csv"

:: Copy the files to combined file
::
for /f "tokens=* delims=" %%i in ('dir /b "%indir%\%dte%*.*"') do (
type "%indir%\%%i" >> "%outdir%\combined_%dte%.csv"
set /a tFiles+=1
)

:: Count the lines
::
for /f "tokens=1* delims=:" %%i in ('findstr /N /R ".*" "%outdir%\combined_%dte%.csv"') do set tLines=%%i

:: Write the current date & time & totals to audit file
::
echo %date%,%time%,%tFiles%,%tLines% >> "%outdir%\audit_%dte%.csv"

Some of the code is left over from testing but should not create any problems.

Good luck. Sidewinder - Thank you so much. It works perfectly. And thanks to you also Salmon Trout.Sidewinder, well done, but don't forget that starting a COMMENT with the unofficial, undocumented, unsupported, DEPRECATED double colon breaks code if used inside parentheses...


8609.

Solve : Dir question?

Answer»

In DOS I have WP5.1 and have a document INSIDE that directory but that file shows up in the root directory when I pull up dir at the prompt. Why does it do that ? That file should be in the WP directory. What is WRONG ??Quote from: DAL818 on JANUARY 12, 2011, 03:30:30 PM

In DOS I have WP5.1 and have a document inside that directory but that file shows up in the root directory when I pull up dir at the prompt. Why does it do that ? That file should be in the WP directory. What is wrong ?

Two copies of WP in two locations will most likely not hurt. Which copy LOADS?
If all works well, leave alone. Ask WP support.

Quote from: DAL818 on January 12, 2011, 03:30:30 PM
In DOS I have WP5.1 and have a document inside that directory but that file shows up in the root directory when I pull up dir at the prompt. Why does it do that ? That file should be in the WP directory. What is wrong ??

Either you have two copies of the file, or you are running dir (without PARAMETERS) from within the WP5.1 directory.

8610.

Solve : Lost boot up password?

Answer»

Hi, I bought a Dell Inspiron 910 Mini from a family that the kids had put in the password and forgot what it was, great deal, I thought I could figure it out to no avail, Dell will not HELP me because IAM not the original owner and the family I bought it from wont or cant help either, is there anything I can do? ,Thank YouIs this BIOS password or Windows Password?

BIOS Password can be cleared by CMOS reset, but you would have to crack it open to get to CMOS battery.

Windows Password can be force changed with a bootable USB thumb drive with a Password Resetter using a Linux Distro. I am guessing you dont have a CD or DVD drive, so you will have to create a bootable USB drive with the password reset tool. OR reinstall Windows via External CD or DVD Drive and software or create a bootable thumb drive of say 8GB in size with the OEM disk copied to that drive if it allows with piracy protection MAYBE not allowing OEM CD or DVD to be copied to another drive.

Link below is a reset tool for Windows

http://www.pogostick.net/~pnh/ntpasswd/Hi Thanks, It is the start up password as soon as It turns on, I had to fix the ram and thought my TROUBLES were over, but surprise.Quote from: cobweb49 on January 12, 2011, 05:19:30 PM

Hi Thanks, It is the start up password as soon as It turns on, I had to fix the ram and thought my troubles were over, but surprise.

Essentially, you have bought a brick. No proof of legal ownership, no BIOS password reset. I am sure you are telling the TRUTH, of course, but I wish I had a dollar for every time I heard the "kids reset the password" story.
8611.

Solve : using " as delim?

Answer»

I want to make simple converter and what i need to do:

input file containing line:
Code: [Select]<Hotspot X="123.456" Y="31.456" Z="2.456" />output file:
Code: [Select]123.456 31.456 2.456
The way i thought would need to use " as a delim:
Code: [Select]@echo off
echo start of file > file2.xml
findstr "X=" file1.xml > tmp
for /F "tokens=2,4,6 delims=" %%G in (tmp) do ( echo %%G %%H %%I >> file2.xml)
del tmp
Is it even possible, if not how else could i do that?here's a one liner, using gawk for windows


Code: [Select]C:\test>gawk "/Hotspot/{for(i=2;i<NF;i++){ gsub(/.*=|\042/,\"\",$i);printf $i\" \"}} " file
123.456 31.456 2.456
you could replace quotes in each line that you read in with some other character that will never appear in the input text such as a dollar sign or semicolon

test.txt

Code: [Select]<Hotspot X="123.456" Y="31.456" Z="2.456" />
<Hotspot X="234.567" Y="51.952" Z="8.853" />
<Hotspot X="666.238" Y="93.532" Z="6.991" />

batch script

Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%A in (test.txt) do (
set "string=%%A"
echo input !string!
set string=!string:"=$!
for /f "tokens=1-7 delims=$" %%B in ("!string!") do (
echo output %%C %%E %%G
)
)

output

Code: [Select]input <Hotspot X="123.456" Y="31.456" Z="2.456" />
output 123.456 31.456 2.456
input <Hotspot X="234.567" Y="51.952" Z="8.853" />
output 234.567 51.952 8.853
input <Hotspot X="666.238" Y="93.532" Z="6.991" />
output 666.238 93.532 6.991One more THING if coming to replacing characters, would there be way to replace whole string of characters into single CHAR (for using few types of delimiters)?

Like i would have whole "@ "X=$"-># ... and so on.
Code: [Select]set string=!string:<Hotspot:@!
set string=!string:X=$:#!Would it be like that?

PS: i need raw windows batch, without any pluginsQuote from: drag0nius on January 14, 2011, 11:19:42 PM

One more thing if coming to replacing characters, would there be way to replace whole string of characters into single char (for using few types of delimiters)?

Like i would have whole "<Hotspot"->@ "X=$"-># ... and so on.
Code: [Select]set string=!string:<Hotspot:@!
set string=!string:X=$:#!Would it be like that?

PS: i need raw windows batch, without any plugins

The syntax for string replacement is:

Inside a loop where you are using delayed expansion (and hence using exclamation marks for variables)

Code: [Select]set string=!string:A=B!
Or elsewhere using percent signs

Code: [Select]set string=%string:A=B%
A is any sequence of one or more characters that you wish to search for in %string% and B is zero or more characters that you wish to put in A's place.

Thus if %string1% is:

I like cats

set string2=%string1:cat=dog% would result in %string2% now containing

I like dogs

Notice that I used a NEW string (string2) in the SET statement. If you use the same variable name (e.g. set string=%string:hot=cold%) the string in the variable is modified but if you use a new variable (e.g. set newstring=%oldstring:man=woman%) then a new string is formed reflecting the change and the old string is preserved.

If the replacement consists of a zero length string (i.e. nothing) then the search term is deleted so that if you did this

Code: [Select]set string1=Mary had a little lamb
set string2=%string1:little =%
then you are searching string1 for little followed by one space and replacing it with nothing (there is nothing between the equals sign and the right-hand variable DELIMITER)

and string 2 is therefore:

Mary had a lamb








Quote from: me, above
A is any sequence of one or more characters that you wish to search for in %string% and B is zero or more characters that you wish to put in A's place.

Note that if either sequence contains one or more of certain special control characters e.g. < > & % ! (there are more) then you have to take certain PRECAUTIONS to avoid the script barfing (crashing) at that point.

8612.

Solve : Batch File to Get fully qualified domain name?

Answer»

Does any one Know how to WRITE a batch FILE to get fully qualified domain NAME. Not the Hostname.
I know with ping -a option at cmd we could get fully qualified domain name.

Thank you for your help. I figured it out....
Quote from: NetRock on January 12, 2011, 04:20:23 PM

I figured it out.... ;D

Please POST the code.Domain name?I wouldn't mind getting my hands on this code too.. could ya post it?Quote from: NetRock on January 12, 2011, 04:20:23 PM
I figured it out.... ;D

Please post the code?testMaybe you should "test" your way out of here, Bill?
8613.

Solve : Run a batch file before Windows User logon?

Answer»

I run a program called PerfectDisk. essentially it is an alternative to Windows XP "Defrag". One option is to defragment metafile data on restart. My guess is that it performs this prior to loading windows services or as a service, but before the any User logon. I say this because my attempt to run a batch file from another batch file when placed in the Startup folder is too late in the boot process.

Test Code:
Code: [Select]CALL HI.BAT
ECHO Hi Out There!
pauseThis seems never to run at either restart or Shutdown/Restart



My final hope is to run a batch file(SDOS.BAT) that CALLS out an executable file(Sdelete.exe) and SDelete needs access to certain files before they are locked by Windows.

It's not imperative that it is a batch file but I do need to select multiple files/folders to securely delete. prior to login.

I suppose that doing this after windows logs off the user when shutting down is another option.

Any thoughts?





This reference will explain how and when programs are run at startup.

The Startup Control Panel will give you some limited access to the registry startup functions.

As always, practice safe PC and backup your registry before proceeding.

Normally I try not to have posters download anything, but in this case it's safer than hacking the registry and turning your PC into a brick.



Quote from: Sidewinder on January 07, 2008, 03:46:49 PM

Normally I try not to have posters download anything, but in this case it's safer than hacking the registry and turning your PC into a brick.

Been hackin' the registtry for years, so if it is necessary then we can go there.
But for now I will take your lead and read....the information on the links provided.Well,
According to the startup sequencing RunServicesOnce - This key is designed to start services when a computer boots up. These entries can also continue running even after you LOG on, but must be completed before the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce registry can start loading its programs.

This seems to be where I need to run the bat file or executable.

But since there are currently no entries I can not figure out safetly how to create one.
Sdelete may require services or functionality that has not been started when the RunServicesOnce key kicks in.

If you use regedit, find the key in the left panel, highlight it to see all existing values, right click the right panel, add a new STRING value, pick a name for your key, and in the data field enter the fully qualified path to your program.

If you use reg from the command LINE type reg add /? for details. Note: the regkey data type should be REG_SZ.

Quote
My final hope is to run a batch file(SDOS.BAT) that calls out an executable file(Sdelete.exe)

You may have to run Sdelete.exe directly without the batch wrapper. The cmd processor (required for batch files) may be unable to start this early in the boot cycle.

Quote
SDelete needs access to certain files before they are locked by Windows.

Just asking, but if Windows protects files it needs to operate, why are you deleting them?

CYA: Backup your Registry before proceeding.

Quote from: Sidewinder on January 08, 2008, 05:26:18 AM
Just asking, but if Windows protects files it needs to operate, why are you deleting them?

Many files, such as internet explorer history, the temp directory, temporary internet files should be able to clear completely, but files such as the index.dat is hard to securely delete as it is locked by the time you logon. This is just an example of some files that I would like to clean up.I apologize for restarting a 2 year old topic, but I had just a quick question regarding the software earlier posted.
Quote
The Startup Control Panel will give you some limited access to the registry startup functions.

If I were to download that and place a batch file in the RunServicesOnce or RunServices (the batch file being a custom
login file) would is disrupt the startup process of the computer and harm it?Quote from: Rilez on January 13, 2011, 08:21:56 PM
If I were to download that and place a batch file in the RunServicesOnce or RunServices (the batch file being a custom
login file) would is disrupt the startup process of the computer and harm it?

Don't know your OS but is there any reason that this login script cannot be attached to Group Policy? Otherwise this link may provide some additional information using some tools from the 2003 Resource Kit.

Good luck. My OS is Windo.ws 7 that link does help, but the question remains, if I were to put a simple batch file there to run before windows logon screen would it harm my computer. (Also, its an Acer 5532 if its important)Don't honestly know if it would harm your computer.

Call me crazy, but I thought login scripts were run after a user logged-in and it could be determined what script (if any) would run for this user.

It might help everyone if you posted the batch file.

This is the Login file. I copied from a script someone released on YouTube. (I did not create the file)
It just has simple login capabilities along with remote options (like I stated earlier).

[recovering disk space - old attachment DELETED by admin]The batch code you posted appears to be safe. There are a couple of del commands you may want to check out but nothing particularly malicious. I suspect the code would run perfectly on the author's machine, but not anybody elses. There are also references to other batch files and executables that you may or may not have on your system.

Most login scripts I have ever seen or written are used to setup a user environment (map network drives, attach printers, empty temp directories etc.) Generally they are "once and out" in that they run from top to bottom without any user intervention.

There is no reason to even try to run this script before Windows User logon. Better to put this in the startup folder; even better start over and customize it for your machine/network. You can try using this link as a template.

Good luck.

[opinion]
The batch code posted should be the poster child of what not to do when writing batch code. There are no indents, no whitespace, no comments, constructs which are difficult to follow and a menu 60 lines long. It was a mind numbing experience.
[/opinion]

Quote from: Sidewinder on January 15, 2011, 08:08:27 AM
The batch code posted should be the poster child of what not to do when writing batch code.[/opinion]

That code is about as bad as I have ever seen. Utterly without merit. It contains classics like this

Code: [Select]set /p newname="Enter new username:"
if "%newname%"=="%newname%" goto inputname
:inputname
and this

Code: [Select]goto next
:next
It is what many people do when they first discover batch scripting. They write an 882 line batch script with menus to run Notepad.


8614.

Solve : Script for launch program and close a window?

Answer»

Script for launch a program and close a window
I need to identificate correctly a window appear when I open a program. This window is not configurable in this program, so I need close it with the script.



How can I determine and force the closing of this window ?

BEST Regards
happy New Year
Code: [Select]@echo off

start pair1.bat
start pair2.bat

sleep 6

tasklist | findstr "%1"

tasklist | findstr "%1" > notepid.txt


for /f "tokens=1,2 delims= " %%i in (notepid.txt) do (
echo pid=%%j

taskkill /F /pid %%j

)

Rem We assume only pair1.bat and pair2.bat use sleep.exe
Rem We taskkill sleep.exe
Output:
C:\test>killpair.bat sleep
sleep.exe 3544 Console 1 1,000 K
sleep.exe 2340 Console 1 1,000 K
pid=3544
SUCCESS: The process with PID 3544 has been terminated.
pid=2340
SUCCESS: The process with PID 2340 has been terminated.

If I screw my eyes up I can SEE that the very fuzzy screen shot is SHOWING Autohotkey, so I am surprised the OP isn't asking in a forum specialising in that tool. Looks a bit script-kiddyish to me.

Does start and taskkill workSomething like that can usually be removed using a debugger, if you KNOW what your doing. I can't read what the message says, but I trust you that it's not a REGISTRATION prompt.

8615.

Solve : hiding a partition?

Answer»

I'm playing around with an old PC & am trying to set it up as dual boot W95b (OSR 2.1) & W98SE. I've got W95 installed to C: but need to hide C: so I can install W98 to D:

(a) is there a DOS COMMAND for hiding a partition or is the only way by installing a boot manager before W98? I've seen some instructions (see attached word doc), but it SEEMS to be for using the command prompt in more recent windows OSs - the commands weren't recognised by the DOS underlying W95b (version 4.00.1111)

(b) if the answer to that's a yes, then is it possible to run a W95/98 dual boot system without 3rd party software (boot manager)? If so could anyone point me towards any tutorials?

In case anyone's WONDERING why on earth I'd even want to bother with W95 & 98, it's partly so I can run some old programs but also as a learning exercise - I want to play around with using/controlling a PC VIA command line instead of GUI.

Cheers all

[recovering disk space - old attachment deleted by admin](a) No
(b) No

You might want to consider Microsoft Virtual PC to run the old OS's on a newer PC. I've recently done this myself & find it a better option than using an old PC. VPC is a free download. http://www.microsoft.com/windows/virtual-pc/Only way for single directional hiding would be FAT16/FAT32 & NTFS. Where NTFS would be unknown to Win 95 and Win 98 and a Win 2000 Pro or newer NT based OS like XP, Vista, or even 7 would see all. I would go with virtualization myself or if your comfortable with editing the boot.ini, you can make it dual boot. Here is more info: http://support.microsoft.com/kb/306559

8616.

Solve : Please Help! Batch File to find and replace config values urgently required?

Answer»

Quote from: hitman126 on January 20, 2011, 03:58:44 AM

There is however ONE minor problem I've noticed. The OPENING and closing ApplicationSettings tags have three sets
of empty strings appearing in the OUTPUT file, i.e. <applicationSettings>"""" and </applicationSettings>""""
Can't find the cause for it. Any help on this please?

You didn't show the opening and closing ApplicationSettings tags before. Script below contains code to ignore these.

Hey ! Are you sure about the SPACES in the urls?

example...

Quote
"WEBSERVER 1"

They don't look right to me.




Code: [Select]@echo off
setlocal enabledelayedexpansion

set inputfile=MyConfigUpdate.txt
set outputfile=MyConfigUpdate-changed.txt
if exist "%outputfile%" del "%outputfile%"

for /f "delims=" %%A in (%inputfile%) do (
set "string=%%A"
set string=!string:"=$!
set change=1
echo "!string!" | find "applicationSettings">nul && set change=0
for /f "tokens=1-6 delims=$" %%B in ("!string!") do (

set token1=%%B
set token2=%%C
set token3=%%D
set token4=%%E
set token5=%%F
set token6=%%G

REM <arg key="MyApp1Root" value="http://localhost:9005/config"/>
REM I would like to replace the word localhost with "WebServer 1",
echo !token2! | find "MyApp1Root">nul && set token4=!token4:localhost=WebServer 1!

REM <arg key="MyApp2Root" value="http://localhost:9012/config"/>
REM I would like to replace the word localhost with "AppsServer 2"
echo !token2! | find "MyApp2Root">nul && set token4=!token4:localhost=AppsServer 2!

REM <arg key="WWWRoot" value="http://DBServer:9012/config"/>
REM I would like to replace DBServer with "DatabaseServer 3"
echo !token2! | find "WWWRoot">nul && set token4=!token4:DBServer=DatabaseServer 3!
if !change! equ 1 (
echo !token1!"!token2!"!token3!"!token4!"!token5!>>%outputfile%
) else (
echo !token1!!token2!!token3!!token4!!token5!>>%outputfile%"
)

)

)

REM show results
echo %inputfile%
type "%inputfile%"
echo %outputfile%
type "%outputfile%"

Code: [Select]MyConfigUpdate.txt
<applicationSettings>
<add key="MyApp1Root" value="https://localhost:9001" />
<add key="MyApp2Root" value="http://localhost:9012" />
<add key="WWWRoot" value="http://DBServer.myCompany.com" />
<add key="app.MyTelesalesRootUrl" value="http://localhost:9501" />
<add key="app.MaximumCustomerSearchResults" value="100" />
</applicationSettings>

MyConfigUpdate-changed.txt
<applicationSettings>
<add key="MyApp1Root" value="https://WebServer 1:9001" />
<add key="MyApp2Root" value="http://AppsServer 2:9012" />
<add key="WWWRoot" value="http://DatabaseServer 3.myCompany.com" />
<add key="app.MyTelesalesRootUrl" value="http://localhost:9501" />
<add key="app.MaximumCustomerSearchResults" value="100" />
</applicationSettings>
8617.

Solve : Using path variable in FOR /R... loop?

Answer»

is there any quotes or bracket tricks to do this?

set %%PATH=C:\Users\
set %%XT=.MP3

for /r %%PATH %%I in (*%%XT) do echo %%I~nI

In this case its supposed to GIVE me LIST of mp3 files inside C:\Users\
the idea is that I can easily change it.
What it actually think is that %PATH is instead of %I, and %I is mistakeSyntax of the commands seems a BIT crazy, try:

Code: [Select]@echo off
cls
setlocal

set PATH=c:\users
set XT=.mp3

for /r "%PATH%" %%I in (*%XT%) do echo %%~nI
PATH is a system variable that is used to define folders where EXECUTABLES are stored. If you use it for something else, all your external commands won't work. Choose another name e.g. MYPATH

8618.

Solve : Perform Action Based on Hour Age of File?

Answer»

I need a DOS Script that will look at a directory for the latest file with extension XXX. It will determine how many hours old the file is. And then I will echo back a response if the the file is XX hours old. Thanks in advance. JoshWhat have you done so far?
I'm very new to scripting and other than researching a possible solution online, I have nothing. I know how to grab the most recent XXX file in the FOLDER but need to know how to evaluation the timestamp and figure an HOUR age based on current time. In what I'm seeing online it seems like DATE determination in DOS scripts is not an easy thing to do. Thanks for any information you can give me.Code: [Select]@echo off

REM Create VBScript
REM Get difference between file date and now in minutes
echo filename=wscript.arguments(0)>fileage.vbs
echo Set filesys = CreateObject("Scripting.FileSystemObject")>>fileage.vbs
echo Set Myfile = filesys.GetFile(filename)>>fileage.vbs
echo wscript.echo DateDiff("n", Myfile.DateCreated, Now())>>fileage.vbs

REM set file extension
set fileExt=.txt

REM set age limit
set agelimit=60

REM get file creation date of OLDEST file of DESIRED extension
for /f "delims=" %%A in ('dir /b /tc /o-d *%fileExt%') do set file=%%~nxA

REM Pass file name to VBScript and capture the output
For /f "delims=" %%A in ( ' cscript //nologo fileage.vbs "%file%" ' ) do set AgeInMinutes=%%A

REM Get file creation date
For /f "delims=" %%A in ( 'dir /b /tc "%file%" ' ) do set FileDate=%%~tA

echo file name %file%
echo file created %FileDate%
echo file age (min) %AgeInMinutes%

if %AgeInMinutes% LEQ %agelimit% goto UnderOrEqual
if %AgeInMinutes% GTR %agelimit% goto Over

:UnderOrEqual

REM Code here to be run if file age is less than or equal to limit
echo file is not older than %agelimit% minutes
goto end

:Over

REM Code here to be run if file age is greater than limit
echo file is older than %agelimit% minutes

:end

8619.

Solve : batch file, unzip and then rename??

Answer»

Hello All,

I am a rookie at DOS and looking for some HELP on a batch file. I have a bunch of .zip files (in same folder) that I am unzipping with PKUNZIP. I'd like to unzip each file and then rename. Each zip file contains one CSV file but the name of that CSV file is random and long. The folder only contains the zip files when I start run the batch. The SAMPLE code below worked in PART but I got messages about duplicate files and then it started renaming the first files I unzipped. I'm pretty sure this is not how you set up a loop. Your help and guidance is appreciated. Ben.


pkunzip 2001.zip
rename ??.csv 2001.csv
pkunzip 2002.zip
rename ??.csv 2002.csv
pkunzip 2003.zip
rename ??.csv 2003.csv
pkunzip 2004.zip
rename ??.csv 2004.csvAs I rememer it, pkunzip -v will tell you the content of the zip, you could capture this and then know what to rename from after extractingThanks for the info. That is beyond my KNOWLEDGE right now. When I unzip, the file name does get truncated and that name will always be random numbers. I know I NEED to do FOR... to unzip and rename a .CSV file using a wildcard but b/c I don't know the file name. Try something like

Unzipper.Bat
Code: [Select]for /f "delims=" %%A in ( 'pkunzip -v %1' ) do set ZippedName=%%A
pkunzip %1
Ren %ZippedName% %~n1.csv
Usage
Unzipper 2001.zip

Ive not tested it as I dont have pkzip / unzipThank you gpl and ffree. I tried both. I was able to get ffree's codes to work. The move gave me another idea so I tried a variation on my original idea. I had to create another folder to move the unzipped and renamed files to but it worked. However, I have to do this from 1990 to 2010. Not a big deal...just copy and paste in Notepad, but if someone can help me turn the code below into a loop, I would appreciate it and learn from it. Thank you all!


pkunzip 1990.zip
rename *.csv 1990.csv
move *.csv csvfolder
pkunzip 1991.zip
rename *.csv 1991.csv
move *.csv csvfolder

8620.

Solve : Bath file auto answer problem?

Answer»

Hi, all!
I've a such as problem: I use openssl to sign certificate signing requests.
When I use following command: openssl ca policy policy_anything -out olim.crt -infiles olim.csr I NEED to answer to questions:
1. Sign the certificate? [y/n]:
2. 1 out of 1 certificate requests certified, commit? [y/n].

To automatic answer to first question i use following on BATCH FILE:
echo y | openssl ca policy policy_anything -out olim.crt -infiles olim.csr
How do I answer second question yes?
Please HELP me...
Thanks for answersYou can try creating a response file with each answer on a separate line.

Response.txt
Code: [Select]y
y

When you run the command, as each question is prompted for, ONE line from the response file will be redirected into the program.

Code: [Select]< response.txt openssl ca policy policy_anything -out olim.crt -infiles olim.csr

Good luck. Sidewinder!
It works, thank a lot!!!
Good luck!

8621.

Solve : copy files current user on other pc?

Answer»

I am trying to make a batchfile which copy's the my documents etc. from the currently logged in user on a other pc to a server. Whatever i try the output is de current user logged in where i type this batchfile so:
set choice=
set /P choice=PC number:
if not "'%choice%'"=='' set choice=%choice:~0,99%
e:\foldername\PsExec.exe \\%choice% RoboCopy "\\%choice%\c$\users\%USERNAME%\documents" "c:\temp\corne\Mijn documenten" /s /mir /log:C:\temp\RoboCopy1.Txt
I am asked for a pcnumber and when i give that in the %username% is filled in with the currently logged in user locally and not from the pcnumber i gave in.
I have tried it several WAYS also without the PsExec but with no effect.
I KNOW this can be done with the set command or something but don'n know how?you can try running "qwinsta" using psexec.

It gives output of all loged on users. Look for console user and then when you have the username change to that users profile folder.
Quote from: subhashchy on January 23, 2011, 05:23:35 PM

you can try running "qwinsta" using psexec.

It gives output of all loged on users. Look for console user and then when you have the username change to that users profile folder.

I never heard of qwinsta but indeed you are right. When i run qwinsta the users logged in is displayed in the cmd prompt. But how di i make use of the username displayed? The batchfile must be run AUTOMATICALLY without need to SWITCH to the username. How can i do this in a batchfile?
8622.

Solve : How to make .cmd create a shortcut and write data to it?

Answer»

Im trying to make a batch or cmd make the missing or corrupt file if it does work Example:
:blm
cd data
cd links
if not exist borderlands.url (What ever the command would be here) else goto blm1
echo.File missing
echo.Recreating
pause&GT;null
echo.done
echo.Press a key to continue
pause>null
del null
goto mainmenu

This is just a PORTION of my bat file Please help MUCH appreciated
A tip: if you used >nul INSTEAD of >null you wouldn't create those files called 'null' that you have to delete.

Download shortcut.exe _ Google for it.That was not exactly what i was LOOKING for but i got me to a link that i needed to get the job Done so Thanks

8623.

Solve : External command?

Answer»

How to use external command?type command and press enterI SAID NOTHING...
...just a stupid QUESTION.

(It was not the question I wanted to ASK... an ERROR.................)Quote from: HP2 on January 26, 2011, 05:11:21 PM

I said nothing...
...just a stupid question.
(It was not the question I wanted to ask... an error.................)
You could try adding more RAM.
8624.

Solve : Need Help with Command line on making folder hidden in a bat file?

Answer»

Im trying to make a password protected folder it went fine until i tryied to rehide the folder in the .cmd heres what i got
Code: [Select]@echo off
Echo.Please Enter PASS to CONTINUE....
:action
set /p pass=Password:
set userinp=%pass:~0,100%
if /i "%pass%"=="W" goto success
echo.incorrect
goto action

:success
Echo.Welcome MillerGram
echo.To rehide Folder type hide
attrib -h -s Hidden
set /p passa=:
set userinp=%pass1:~0,100%
if /i "%passa%"=="hide" goto hide
echo.what was that?
pause>nul
cls
goto success

:hide
attrib +h /d /s Hidden
goto success
The hide shortcut dosent seem to work any IDEAS?Quote from: millergram on January 25, 2011, 06:31:17 PM

The hide shortcut dosent seem to work any ideas?

Did it ever work?

Code: [Select]@echo off
Echo.Please Enter Pass to continue....
:action
set /p pass=Password:
set userinp=%pass:~0,100%
if /i "%pass%"=="W" goto success
echo.incorrect
goto action

The user is instructed to enter 'pass', but the if statement makes a compare to 'w'. Misleading the user is not recommended.

Code: [Select]:success
Echo.Welcome MillerGram
echo.To rehide Folder type hide
attrib -h -s Hidden
set /p passa=:
set userinp=%pass1:~0,100%
if /i "%passa%"=="hide" goto hide
echo.what was that?
pause>nul
cls
goto success

If the user should actually get here (see above), nothing particularly wrong in this section, just sloppy. Using set /p allows for a prompt message; you don't need the echo command.

Code: [Select]:hide
attrib +h /d /s Hidden
goto success

This is OK for what it does.

Questions:
What are these: set userinp=%pass:~0,100%
Userinp is prompted for but never used

There is no exit point to the logic. Once the user finally gets out of the :action tag, they get stuck bouncing around the :success and :hide tags.

Using passwords in a batch file is self-defeating. At some point the code will have to compare the user input to the actual password. Anyone with an editor or knows how to use the type command will be able to see how to move around in the logic.

You might consider making your code more generic. Prompt for the folder name, test if it exists, then proceed to hide/unhide it. Lose the passwords. Keep it simple.

Just a thought.




Thank You So Much
Still Got Tons To learn
Like I DINT already know that
8625.

Solve : Please help me...?

Answer»

That still doesn't explain why you want to shut down windows. Like I SAID I have plenty of batch files that do exactly that; none of them shut down windows.Quote from: BC_Programmer on January 26, 2011, 08:00:18 PM

That still doesn't explain why you want to shut down windows. Like I said I have plenty of batch files that do exactly that; none of them shut down windows.

If it's late at night, or I'm in a rush, I want to be able to let MBam for example, run a FULL scan and then shut down once the log file opens (when it's done).

Once I start back up I will TEND to the logfiles.

Hope I got where I was going with this.

Add:
Well, shutdown, sleep, Lock, or even just log out and sleep all together, all I wanted to do is have a configurable command appropriate for doing something after that program has opened.

Nothing special.WHICH IS IT?

ONE post you're talking about making a batch file for games. the next your blathering about Malware bytes.Quote from: BC_Programmer on January 26, 2011, 09:21:49 PM
WHICH IS IT?

One post you're talking about making a batch file for games. the next your blathering about Malware bytes.

This is SPECIFICALLY for MalwareBytes!!

Good day *snoring*...
8626.

Solve : is it a bug??

Answer»

Can SOMEONE tell me what's going on with this?
If I run this from the command line by typing the file NAME, it works and prints the "yes" (assuming I press y).
Quote

C:\Documents and Settings\user\Desktop>test
y
[y]
_ans=y
yes
Press any key to continue . . .
But, if I double click the bat file to open, I get this:
Quote
y
[]
_ans=y
Press any key to continue . . .

I'm pulling my hair out trying to figure out what's wrong. The outer if statement (simplified for troubleshooting) also has something to do with it, but I need it.

Code: [Select]@echo off

IF 1==1 (
SET /P _ans=
echo [%_ans%]
SET _ans
IF /i "%_ans%" == "y" (
echo yes
)
)
pause
This may HELP. I added a prompt messages. Not sure why you wouldn't have one when requesting input. Also what is the purpose of the outer if statement?

Code: [Select]@echo off

if 1==1 (
set /p _ans=Prompt goes here:
call echo [%%_ans%%]
set _ans
call if /i "%_ans%"=="y" (
echo yes
)
)
pause


Code: [Select][quote author=Sidewinder link=topic=115488.msg771696#msg771696 date=1296228053]
what is the purpose of the outer [b]if[/b] statement?
Since the test "IF 1==1" will always be satisfied I fail to see the point of it.

What's with all that CALL stuff?


IGNORING the redundant outer IF test... phatpaul, clearly you have noticed the problem of setting and expanding VARIABLES inside parentheses, but equally clearly you are not aware of the solution - delayed expansion. Google for more information.
Code: [Select]setlocal enabledelayedexpansion
if 1==1 (
set /p _ans=Prompt goes here:
echo [!_ans!]
if /i "!_ans!"=="y" (
echo yes
)
)
8627.

Solve : List all files that have the extension .doc?

Answer»

I need help WRITING a dos command to list all the .doc files in my directory.
Thanks in advanceOS: Linux variant

Post in the BSD, Linux, and Unix forum. Quote from: Dusty on January 28, 2011, 12:33:53 AM

OS: Linux variant

Post in the BSD, Linux, and Unix forum.

They want help writing a DOS command.To run in a Linux variant?Quote from: Dusty on January 28, 2011, 12:58:24 AM
To run in a Linux variant?

I don't recall them saying that. If I was to request help with sudo or ANOTHER Linux command, would I be told to post in the windows forum simply because I have placed windows as my OS in my profile?Quote from: BC_Programmer on January 28, 2011, 03:15:16 AM
I don't recall them saying that.

Linux is his OS, but Microsoft is his homework, I think.

Quote from: SALMON Trout on January 28, 2011, 10:26:27 AM
Linux is his OS, but Microsoft is his homework, I think.
What a way to learn!
8628.

Solve : Verifying the batch file compelted successfully?

Answer»

Is there a way to check for a RETURN string after issuing commands through a bat FILE.

I am calling a cmd prompt and issuing mst commands. mst restart, mst status, and mlxi2c scan. All of these commands once issued dump output to the SCREEN and I want to query the RESPONSE before issuing the next command.

Help

8629.

Solve : Make a batch file delete in exit a.k.a when you press X on top right of screen?

Answer»

Is it even possible to make a batch file delete self when you exit USING the big x on the top right of the SCREEN?
Quote from: millergram on January 28, 2011, 10:50:14 PM

Is it even possible to make a batch file delete self when you exit using the big x on the top right of the screen?

Can a man commit SUICIDE after he has been KILLED by lightning?
Ok i get it it cant be done
Quote from: millergram on January 29, 2011, 04:00:45 PM
Ok i get it it cant be done

The problem is that when you click the X you interrupt the batch script before it finishes so that it cannot execute a line containing a command to delete itself.
8630.

Solve : Help with command line arguments?

Answer»

Hello everyone. I'm trying to create a batch file which accepts a few commandline arguments. My problem is that I do not want to check for %1 or %2 etc, but for %* which means that the user should be able to specify the arguments regardless of their order.

Code: [Select]@ECHO OFF

IF /I "%*"=="1stARG" ECHO:1stARG&&GOTO :END
IF /I "%*"=="2ndARG" ECHO:2ndARG&&GOTO :END
IF /I "%*"=="3rdARG" ECHO:3rdARG&&GOTO :END
IF /I "%*"=="4thARG" ECHO:4rdARG&&GOTO :END
IF /I "%1"=="" ECHO:NO ARGUMENT SPECIFIED&&GOTO :END
ECHO:WRONG ARGUMENT&&GOTO :END

:END
PAUSE
The problem is that this way if I use "1stARG 2ndARG" it's not being split. So I guess I have to use a FOR loop. Basically I'm trying to find the simplest way of achieving this.

Thanks in advance for any help.You mentioned FOR so I deduce this is not about MS-DOS. You should be aware that in Windows bath scripting the double ampersand (&&) is not a simple command SEPARATOR (like in Unix). It is an errorlevel test. "Command1 && command2" means "execute command1 and if the errorlevel from command1 is zero, (and only if) then execute command2". The standard command separator where you want more than 1 command on a single line is the single ampersand (&) for example command1 & command2. Also you don't need to put the colon before the label identifier in a goto statement, and using all capital letters is not compulsory.

Quote

the user should be able to specify the arguments regardless of their order

Why? You are making the script unnecessarily complicated, and batch language is very bad at this sort of thing.

However you can use FOR to split the parameters up, assuming that each contains no spaces. This example uses numbers for the FOR metavariables; if you want more than ten (0-9) you'll have to use letters. The example assumes 3 parameters are expected

Code: [Select]@echo off
for /f "tokens=1-3 delims= " %%1 in ("%*") do (
set parameter1=%%1
set parameter2=%%2
set parameter3=%%3
)
set check=0
if "%parameter1%"=="" set /a check+=1
if "%parameter2%"=="" set /a check+=1
if "%parameter3%"=="" set /a check+=1
if %check% gtr 0 echo Wrong number of parameters & goto end
echo parameter 1 is %parameter1%
echo parameter 2 is %parameter2%
echo parameter 3 is %parameter3%
:end Quote
You mentioned FOR so I deduce this is not about MS-DOS. You should be aware that in Windows bath scripting the double ampersand (&&) is not a simple command separator (like in Unix). It is an errorlevel test. "Command1 && command2" means "execute command1 and if the errorlevel from command1 is zero, (and only if) then execute command2". The standard command separator where you want more than 1 command on a single line is the single ampersand (&) for example command1 & command2. Also you don't need to put the colon before the label identifier in a goto statement, and using all capital letters is not compulsory.

I'm aware of that, I'm just used to use this and since it works for my cases I never bothered with this. Thanks for reminding it me. As for the capital letters I simply prefer them for the dos commands.

Quote
Why? You are making the script unnecessarily complicated, and batch language is very bad at this sort of thing.

Well, even so I have to use batch for this since it's the only language I'm familiar with.

Here is what I'm trying to achieve. I need to be able to parse 2 commandline arguments but without having to use them in a specific order. So I can't check for the first or the second argument specifically. There must be a way to filter all the arguments with FIND and set the two vars I need.
My situation is more like this: Accept all days as one argument and all months as another one. If none of these are used then error out. The second part is easy

I know it's difficult and that batch isn't the best way to do it, but I have to stick to it, unfortunately.Code: [Select]
@echo off
setlocal enabledelayedexpansion

set errormessage=1 day and 1 month not supplied

REM split parameters into two tokens
for /f "tokens=1-3 delims= " %%1 in ("%*") do (
set parameter1=%%1
set parameter2=%%2
)

REM check for blank arguments
set check=0
if "%parameter1%"=="" set /a check+=1
if "%parameter2%"=="" set /a check+=1
if %check% gtr 0 echo %errormessage% & goto end

REM check for 1 day and 1 month
set days=0
set months=0
for %%A in (%parameter1% %parameter2%) do (
echo %%A | FINDSTR /I "Monday Tuesday Wednesday Thursday Friday Saturday Sunday">nul && (
set /a days+=1
set day=%%A
)
echo %%A | findstr /I "January February March April May June July August September October November December">nul && (
set /a months+=1
set month=%%A
)
)
if not %days% equ 1 echo %errormessage% & goto end
if not %months% equ 1 echo %errormessage% & goto end

echo day: %day%
echo month: %month%

:end

Like I have told you 10 times already, you are the best! This is what I was looking for. Except for a minor change I need to make. I want to handle the case where no arguments are specified (or one of the two isn't) a little different, use the default values in this case (Monday/January in our example). But also keep the check for invalid arguments like it is now.

Thank you very much, without your help I would be lost in the ocean Try this

Code: [Select]@echo off
setlocal enabledelayedexpansion

set monthlist=January February March April May June July August September October November December
set daylist=Monday Tuesday Wednesday Thursday Friday Saturday Sunday
set DefaultDay=Monday
set DefaultMonth=January

REM split parameters into two tokens
for /f "tokens=1-3 delims= " %%1 in ("%*") do (
set parameter1=%%1
set parameter2=%%2
)

set days=0
set months=0
for %%A in (%parameter1% %parameter2%) do (
echo %%A | findstr /I "%daylist%">nul && (
set /a days+=1
set day=%%A
)
echo %%A | findstr /I "%monthlist%">nul && (
set /a months+=1
set month=%%A
)
)
if %days% equ 0 set day=%DefaultDay%
if %months% equ 0 set month=%DefaultMonth%

echo day: %day%
echo month: %month%
Thanks for your reply. Now, this approach is using the default values correctly and it's cleaner. But there's a problem with the FINSTR command.
If I use "Mondayy" it will return this value. I think this can be solved by using \ etc.
That's why I want to make it error out if any of the two arguments is not one of those in the list so that it doesn't use the default silently but only when one or none of the arguments is specified.Could you tell me why it is so important that the parameters need to be presented in any order?
I think I must be MISSING something, but couldn't shift be used for this in some capacity?Quote from: BC_Programmer on January 30, 2011, 10:45:20 AM
I think I must be missing something, but couldn't shift be used for this in some capacity?

Shift will get over having more than the 9 arguments allowed by the %1 to %9 parameters. Here we only have a fixed number. I am not sure if the OP is using "months" and "days" as generic examples for them, and whether there are going to be more than 2 in the finished script. We don't actually need to split %* - %1 and %2 will do just fine.


Quote from: Salmon Trout on January 30, 2011, 09:51:29 AM
Could you tell me why it is so important that the parameters need to be presented in any order?
I need to eliminate the case where someone uses the arguments in the wrong order. Currently I only have 2 arguments, but if it works I think I will be able to extent it for more

Your last code is ALMOST what I need, I just need it to check for invalid arguments and error out. I'll see if I can make FINDSTR to work only with the specific string and not any string that contains the words in the list.

Thank you very much for your help.
8631.

Solve : Sudoku glitch?

Answer»

This has REALLY GOT me stumped. I created a sudoku-solving script (still in the works) that's getting a really weird issue.

The script can successfully solve this puzzle:
Quote

4_153_68_
639____51
_7_6412_9
___152_74
782___915
14_798___
2_7486_9_
39____768
_16_735_2
(By the way, this is the answer I got when I ran the script)Quote
4 2 1 5 3 9 6 8 7
6 3 9 8 2 7 4 5 1
5 7 8 6 4 1 2 3 9
9 6 3 1 5 2 8 7 4
7 8 2 3 6 4 9 1 5
1 4 5 7 9 8 3 2 6
2 5 7 4 8 6 1 9 3
3 9 4 2 1 5 7 6 8
8 1 6 9 7 3 5 4 2

But I get a weird issue when I try this puzzle: (which can be solved, ACCORDING to http://www.sudokusolver.co.uk/)
Quote
7_4_2__96
_6_913___
2__7__58_
__62__138
_8_3_9_7_
543__82__
_58_____7
___497___
39__8_6_2
Issue:
Quote
7 _ 4 _ 2 _ _ 9 6 <-- No spots filled, even though it pauses (meaning it's done)
_ 6 _ 9 1 3 _ _ _
2 _ _ 7 _ _ 5 8 _
_ 7 6 2 _ _ 1 3 8
_ 8 _ 3 _ 9 4 7 _
5 4 3 _ _ 8 2 _ _
_ 5 8 _ _ _ _ _ 7
_ _ _ 4 9 7 _ _ _
3 9 _ _ 8 _ 6 _ 2
0,1 is in 1 <-- Should not remain for more less than a second
0,3 is in 2
0,5 is in 2
0,6 is in 3
1,0 is in 1
1,2 is in 1
1,6 is in 3
1,7 is in 3
1,8 is in 3
2,1 is in 1
2,2 is in 1
2,4 is in 2
2,5 is in 2
2,8 is in 3
3,0 is in 4
3,4 is in 5
3,5 is in 5
4,0 is in 4
4,2 is in 4
4,4 is in 5
4,8 is in 6
5,3 is in 5
5,4 is in 5
5,7 is in 6
5,8 is in 6
6,0 is in 7
6,3 is in 8
6,4 is in 8
6,5 is in 8
6,6 is in 9
6,7 is in 9
7,0 is in 7
7,1 is in 7
7,2 is in 7
7,6 is in 9
7,7 is in 9
7,8 is in 9
8,2 is in 7
8,3 is in 8
8,5 is in 8
8,7 is in 9
Press any key to continue . . .

And for some other puzzles, it messes up and says one of the numbers is "_=".
Puzzle:
Quote
4_3__9168
19_643_5_
_7_1_2_93
935_6_8_1
__28459__
8_7_2_635
26_4_7_8_
_8_216_74
7543__2_6
Result:
Quote
4 2 3 5 7 9 1 6 8
1 9 8 6 4 3 7 5 2
5 7 6 1 8 2 4 9 3
9 3 5 7 6 4 8 2 1
6 1 2 8 4 5 9 _= 7
8 4 7 9 2 1 6 3 5
2 6 1 4 5 7 3 8 9
3 8 9 2 1 6 5 7 4
7 5 4 3 9 8 2 1 6
Press any key to continue . . .

Anyway, here is the script I'm using:
Code: [Select]@echo off
setlocal enabledelayedexpansion
set line0=4_153_68_
set line1=639____51
set line2=_7_6412_9
set line3=___152_74
set line4=782___915
set line5=14_798___
set line6=2_7486_9_
set line7=39____768
set line8=_16_735_2
::set num=0
::for /f "delims=" %%A in (sudoku4.txt) do set line!num!=%%A & set /a num+=1
for /l %%L in (0,1,8) do (
for /l %%C in (0,1,8) do (
set l%%Lc%%C=!line%%L:~%%C,1!
)
)

:re
call :display
for /l %%L in (0,1,8) do (
for /l %%C in (0,1,8) do (
if !l%%Lc%%C!==_ (
set l%%Lc%%Cposs=123456789
for /l %%Z in (0,1,8) do (
for %%P in (!l%%Lc%%Z!) do (
set l%%Lc%%Cposs=!l%%Lc%%Cposs:%%P=!
)
)
for /l %%Z in (0,1,8) do (
for %%P in (!l%%Zc%%C!) do (
set l%%Lc%%Cposs=!l%%Lc%%Cposs:%%P=!
)
)
::check box
if %%L LEQ 2 (
if %%C LEQ 2 (
set box=1
) else if %%C LEQ 5 (
set box=2
) else (
set box=3
)
) else if %%L LEQ 5 (
if %%C LEQ 2 (
set box=4
) else if %%C LEQ 5 (
set box=5
) else (
set box=6
)
) else (
if %%C LEQ 2 (
set box=7
) else if %%C LEQ 5 (
set box=8
) else (
set box=9
)
)
::echo %%L,%%C is in !box!
if box==1 for %%P in (!l0c0! !l0c1! !l0c2! !l1c0! !l1c1! !l1c2! !l2c0! !l2c1! !l2c2!) do set l%%@c%%Cposs=!l%%@c%%Cposs:%%P=!
if box==2 for %%P in (!l3c0! !l3c1! !l3c2! !l4c0! !l4c1! !l4c2! !l5c0! !l5c1! !l5c2!) do set l%%@c%%Cposs=!l%%@c%%Cposs:%%P=!
if box==3 for %%P in (!l6c0! !l6c1! !l6c2! !l7c0! !l7c1! !l7c2! !l8c0! !l8c1! !l8c2!) do set l%%@c%%Cposs=!l%%@c%%Cposs:%%P=!
if box==4 for %%P in (!l0c3! !l0c4! !l0c5! !l1c3! !l1c4! !l1c5! !l2c3! !l2c4! !l2c5!) do set l%%@c%%Cposs=!l%%@c%%Cposs:%%P=!
if box==5 for %%P in (!l3c3! !l3c4! !l3c5! !l4c3! !l4c4! !l4c5! !l5c3! !l5c4! !l5c5!) do set l%%@c%%Cposs=!l%%@c%%Cposs:%%P=!
if box==6 for %%P in (!l6c3! !l6c4! !l6c5! !l7c3! !l7c4! !l7c5! !l8c3! !l8c4! !l8c5!) do set l%%@c%%Cposs=!l%%@c%%Cposs:%%P=!
if box==7 for %%P in (!l0c6! !l0c7! !l0c8! !l1c6! !l1c7! !l1c8! !l2c6! !l2c7! !l2c8!) do set l%%@c%%Cposs=!l%%@c%%Cposs:%%P=!
if box==8 for %%P in (!l3c6! !l3c7! !l3c8! !l4c6! !l4c7! !l4c8! !l5c6! !l5c7! !l5c8!) do set l%%@c%%Cposs=!l%%@c%%Cposs:%%P=!
if box==9 for %%P in (!l6c6! !l6c7! !l6c8! !l7c6! !l7c7! !l7c8! !l8c6! !l8c7! !l8c8!) do set l%%@c%%Cposs=!l%%@c%%Cposs:%%P=!
ping localhost -n 1 > nul
call :length !l%%Lc%%Cposs!
if !len!==1 (
set l%%Lc%%C=!l%%Lc%%Cposs!
goto re
)
)
)
)
pause
exit


:length
set #=%1
set len=0
:lenloop
if defined # (set #=%#:~1%&set /A len += 1&goto lenloop)
goto :eof

:display
cls
echo.
for /l %%L in (0,1,8) do (
set line=
for /l %%C in (0,1,8) do (
set line=!line! !l%%Lc%%C!
)
echo !line!
)
As you can see, it solves the puzzle in the code fairly quickly, but like I said, it doesn't work for some. I've tried 5 different puzzles, but those are the issues I get.Oh dear... a sodoku solver in

batch?

Well, the first thing that leaps out at me is that there is no way you are using all the different algorithms which are required to reliably solve sodoku puzzles. Brute force/CRME will solve some, but not all; I can't really tell but I'm pretty sure you are only doing a brute force attempt to solve, and aren't performing any checks for lone rangers or twins.

For your first "weird" issue puzzle, my program gives me this:



I have no idea if it's right or not. I'm surprised it even looks like it worked, I would have practically bet money that it either crashed or only half-filled the board- I guess I don't have a lot of faith in any of my old VB6 programs anymore...

As for your puzzle that "messes up"... it's not even a valid puzzle. the 5th column has two fours in the initial setup. the "result" still has two fours, but no doubt the fact that there were two fours has caused the equals sign issue. I wouldn't have even noticed if my program didn't PREVENT me from selecting four for the second instance . You can discount that "problem" entirely since it's not even a valid puzzle to start with.

any other problems are almost certainly because you are only using CRME (Column-Row Minigrid Elimination) and aren't dealing with Lone Rangers or twins; I gave up on mine when it couldn't complete some of the "hard" puzzles from a puzzle book; no doubt I need to implement triplets to get those to be solved problem-free.

Wow, I'm surprised I didn't realize that the puzzles were wrong originally. I realized that I wouldn't be able to solve every puzzle, but thanks for your help anyway.Here's a very good example of what you're talking about BC.
Puzzle:
Quote
__91_7_42
2_48__51_
_5149_3__
1__7632__
59__8__61
_26__9__8
96___81_7
___671924
4179___8_

Solution from the script:
Quote
6 3 9 1 5 7 8 4 2
2 7 4 8 3 6 5 1 9
8 5 1 4 9 2 3 7 6
1 4 8 7 6 3 2 9 5
5 9 _ _ 8 4 7 6 1
7 2 6 _ 1 9 4 _ 8
9 6 _ _ 4 8 1 _ 7
3 8 5 6 7 1 9 2 4
4 1 7 9 2 5 6 8 3
Press any key to continue . . .

Solution from the script (and me):
Quote
6 3 9 | 1 5 7 | 8 4 2
2 7 4 | 8 3 6 | 5 1 9
8 5 1 | 4 9 2 | 3 7 6
------|-------|------
1 4 8 | 7 6 3 | 2 9 5
5 9 3 | 2 8 4 | 7 6 1
7 2 6 | 5 1 9 | 4 3 8
------|-------|------
9 6 2 | 3 4 8 | 1 5 7
3 8 5 | 6 7 1 | 9 2 4
4 1 7 | 9 2 5 | 6 8 3
Press any key to continue . . .
Mine solved it! yay.

Sorry I'm just surprised at how well it seems to work.

What's really weird, my script should have solved the puzzle I just posted...

Quote

6 3 9 | 1 5 7 | 8 4 2
2 7 4 | 8 3 6 | 5 1 9
8 5 1 | 4 9 2 | 3 7 6
------|-------|------
1 4 8 | 7 6 3 | 2 9 5
5 9 _ | _ 8 4 | 7 6 1
7 2 6 | _ 1 9 | 4 _ 8
------|-------|------
9 6 _ | _ 4 8 | 1 _ 7
3 8 5 | 6 7 1 | 9 2 4
4 1 7 | 9 2 5 | 6 8 3
Press any key to continue . . .
8632.

Solve : Copying MANY Files from a DOS Laptop?

Answer»

Hi,

I have an old Toshiba Tecra 510CDT laptop with DOS 6.22 installed.

I mainly use this laptop for programming / coms for Legacy industrial control systems. (programs that RUN under DOS only, and need the COM port)

How can I copy / transfer all the files from this laptop to another PC for safe keeping. There are many files, and USING the Floppy will take forever!

Can a serial port transfer utility still be obtained for this purpose? (DOS one side, XP the other?)

I have a few other PCs... 95, 98, XP if anything can be run on these.

I used Laplink many moons ago, not sure if this is still available, and will it cross OS platforms?

Would REMOVING the hard-drive for cloning / copying somehow be an option? (IDE?) If so, what kit could be used?

THANKS.



DOS 6.22 has interlink as part of it, which works a lot like laplink

unfortunately, the other machine needs this installed too, maybe win 95 / 98 has this built in ? This page might be of use

http://www.kime.net/directcc/directcc31.htmFor the cloning option there's this:...

And This...Thanks gpl, thanks patio.

Patio, is that a 3.5" to 2.5" adapter (pic)Yeper...2.5 laptop to IDE adapter.....'Bout 7 Bucks...Ghost the old Toshiba laptop & store the image on the XP machine. Use Ghost Explorer to EXTRACT any file from the image.

8633.

Solve : concatenate list?

Answer» I'm using this batch file :
@dir/w %1 > c:\File_list\filelist.txt

which gives me this

Volume in drive C is OS
Volume Serial NUMBER is XXX-XXXX

Directory of C:\DELL

[.] [..] ATAPI.EXE DELLBUTN.HTM DELLCIRC.ICO
E-WTRMRK.GIF [r069r] SOL_CENT.JPG USBS3KB.REG UWAKEOFF.exe
UWAKEON.exe
8 File(s) 271,522 bytes
3 Dir(s) 130,348,281,856 bytes free

and edit it to give me something like this

C:\DELL

ATAPI.EXE
DELLBUTN.HTM
DELLCIRC.ICO
E-WTRMRK.GIF
SOL_CENT.JPG
USBS3KB.REG
UWAKEOFF.exe
UWAKEON.exe

This is an example of a small folder, I'm normally dealing with larger numbers. Is ther a quicker way to ge this, or nearer this, full path plus LIST of files with NO details.
thanks
Replace dir /w with dir /b. Iif you don't want directories (folders) to be listed USE the /a-d switch. It's all in the DIR help which you can access by opening a command window and typing DIR /?

Code: [Select]F:\Dtest>dir /w
Volume in drive F is IDE02
Volume Serial Number is E0E2-3A64

Directory of F:\Dtest

[.] [..] avih_aac.bin avih_adpcm.bin avih_jpeg_hufftables.bin
avih_mp3cbr.bin avih_ms_adpcm.bin avih_noaudio.bin avih_pcm.bin avih_ulaw.bin
copying.txt FccMap.default.ini FccMap.ini lame_enc.dll libfaad2.dll
libMAD.dll Mp4Cam2AVI.exe playlist.asx settings.ini xvidcore.dll
[_help]
18 File(s) 2,162,525 bytes
3 Dir(s) 96,652,644,352 bytes free
Code: [Select]F:\Dtest>dir /b /a-d
avih_aac.bin
avih_adpcm.bin
avih_jpeg_hufftables.bin
avih_mp3cbr.bin
avih_ms_adpcm.bin
avih_noaudio.bin
avih_pcm.bin
avih_ulaw.bin
copying.txt
FccMap.default.ini
FccMap.ini
lame_enc.dll
libfaad2.dll
libMAD.dll
Mp4Cam2AVI.exe
playlist.asx
settings.ini
xvidcore.dllThanks, I did GET as far as this but perhaps I didn't make the question clear enough.
the reference to concatenate in the subject line was to whether the file list can have the full path in the FIRST (or last) line. For instance, can I write to the file once and then with the full path only without overwriting.

C:\DELL

ATAPI.EXE
DELLBUTN.HTM
DELLCIRC.ICO
E-WTRMRK.GIF
SOL_CENT.JPG
USBS3KB.REG
UWAKEOFF.exe
UWAKEON.excreate file, overwriting any file with same name

Code: [Select]dir /b > list.txt
create file if it does not exist, append to file if it already exists

Code: [Select]dir /b >> list.txtThanks, that's what I was looking for.
8634.

Solve : The wrong language in my MS_DOS.?

Answer»

I have bought a new hard drive for my 'Medion' laptop. I put the new hard drive into the laptop, went into fdisk and partitioned the drive so I could put the recovery files into d: drive and then let the laptop program its self with the support disc. When I STARTED the laptop to program itself it start to communicate to me in German, it was using English before the new drive, I have tried to change it back to English, but every thing I try fails to work. Does anybody know whats wrong here, I would be grateful for any ideas. Thankyou. Colo.Doesn't make sense....HDD's are blank and you do NOT need the software that came with it...
Boot to your Windows CD...REMOVE the existing partition and continue with the install...
It will be automatically re-created.I just re-read your Post....the Recovery partition may be at faullt here....
Where exactly is this laptop from and how long have you had it ? ?

If need be you can borrow an MS Windows CD and do a clean install...perfectly legal...but the version and Service Packs need to match what was originally on the laptop.
You will have to re-register of course.My laptop is a Medion MM2190, It is a Windows Vista,(maybe I should have mentioned this at the start), the hard drive is 120gb, it is about three/four years old, I bought the laptop from Woolies....... Colo...Thankyou.Well, I removed the said partition and restarted the laptop with the recovery disc in, and of it went and is now working, Many thanks for your advice patio, Thankyou...Colo.... EXCELLENT....PRETTY STRANGE how that happened...

8635.

Solve : Scheduled Task That Cannot Hang?

Answer»

Would appreciate some help here. Is it possible to create a DOS Batch script that runs as a Scheduled Task (and executes Excel and ACCESS macros) so that it always exits; i.e., can never get hung? I understand that setting the scheduled task parameter that tells it to end if running longer than x hours doesn't always work. Thanks.Quote from: sumdumgai on January 25, 2011, 01:58:45 PM

I understand that setting the scheduled task parameter that tells it to end if running longer than x hours doesn't always work. Thanks.

First I've heard of this. Have you tested this out?

Both Access and Excel can execute macros when opened. Access at one time used AutoExec and Excel used Auto_Open. Check your help files specific to your versions.

The batch file does not actually execute the macros. You must open Access and Excel via the batch file, and let each application execute the starting macro.

Good luck.

Yes, I've tested this. Even when this parameter is set, if Excel (or Access) is running a macro and for instance if an error occurs that requires a user acknowledgement (like an 'OK
'), then the task remains open (and hung). You'd need the process PID or some other identifier to kill the task.If the macro throws an error, the application goes into a wait state and execution clock stops waiting for your response. VBA supports variations of the on error instruction which allows you to programmatically decide what to do when an error is thrown. I suspect the default action is to put up a window with the error message and line number.

By setting up an on error routine, you can override the default and perhaps completely ignore the error, or even shutdown the macro without halting. This link has more information.

Good luck. Quick resolution to prevent that would be an On Error Resume Next at the top of each macro routine; (and removal of any existing "On Error GOTO 0")When I saw the title I was reminded of something. Isn't asking for a program that "cannot hang" just what Alan Turing proved in 1936 couldn't be done? That is, that a general algorithm to solve the halting problem for all possible program-input pairs cannot exist.
Quote from: Salmon TROUT on February 02, 2011, 01:48:37 PM
When I saw the title I was reminded of something. Isn't asking for a program that "cannot hang" just what Alan Turing proved in 1936 couldn't be done? That is, that a general algorithm to solve the halting problem for all possible program-input pairs cannot exist.

the proof was more that it was impossible, by analyzing the code of a program, to determine wether that program "halts" and in what cases it does so. (The specific source where I read this I cannot recall- but it presented most of it's material using Pascal, and the idea was expressed by presenting pascal programs that had "halt" instructions execute in certain CONDITIONS; while it's possible for a program to determine wether another program "halted" when it was merely a "halt" instruction, the problem became INTRACTABLE as the cyclomatic complexity rose. I can't remember very much about the specifics of that particular chapter.



Of course in this case, the "hang" is only a hang in the context of a scheduled task, since it is asking for user-input.

8636.

Solve : How to change resolution and run old Windows program from batch file?

Answer»

It works! At last! Thank you so much BC and I'm sorry I got the terminology wrong. Your solution should be tagged and archived here for anyone else who RUNS into the same THING. It is an extremely useful answer to a really irritating problem.

To respond to your other point, I did try every possible option in compatibility mode but always ran into the same issue. The resolution would switch briefly but then immediately switch back and the program would END up running in a small window instead of full screen. Don't know why.

I followed your advice and used your executable with a FIND command to search for the process string. This works fine though it is not very elegant since the batch has to loop until the errorlevel CHANGES. It does what I wanted, though, so I can't complain. Thanks again.

8637.

Solve : Batch file start executable problem?

Answer»

Hi,

I am trying to get a batch file to run several installation programs; the idea is that it waits until the setup is completed then RUNS the next one. However, I’ve hit a stumbling block on running just the first installer file. I am pretty sure its something to do with the SPACES, or that it’s a UNC path. I get an error “WINDOWS cannot find appsetup.exe”.

Code: [Select]SET THISDIR="\\server\development\new installation\"
start /wait %THISDIR%appsetup.exe
echo done
pause
I tried this alternative, which didn’t work either. This one produced two DOS windows, one asking me if I want to terminate the job.

Code: [Select]start /wait "\\server\development\new installation\appsetup.exe"
echo done
pause
Neither works… can anyone HELP, please?
try this - START needs a title string for the window, but a null string (two quotes) will do.

start /wait "" "\\server\development\new installation\appsetup.exe"

Code: [Select]C:\>start /?
Starts a separate window to run a SPECIFIED program or command.

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/AFFINITY <hex affinity>] [/WAIT] [/B] [command/program]
[parameters]

"title" Title to display in window title bar.
path Starting directory.
B Start application without creating a new window. The
application has ^C handling ignored. Unless the application
enables ^C processing, ^Break is the only way to interrupt
the application.
I The new environment will be the original environment passed
to the cmd.exe and not the current environment.
MIN Start window minimized.
MAX Start window maximized.
SEPARATE Start 16-bit Windows program in separate memory space.
SHARED Start 16-bit Windows program in shared memory space.
LOW Start application in the IDLE priority class.
NORMAL Start application in the NORMAL priority class.
HIGH Start application in the HIGH priority class.
REALTIME Start application in the REALTIME priority class.
ABOVENORMAL Start application in the ABOVENORMAL priority class.
BELOWNORMAL Start application in the BELOWNORMAL priority class.
AFFINITY The new application will have the specified processor
affinity mask, expressed as a hexadecimal number.
WAIT Start application and wait for it to terminate.
command/program
If it is an internal cmd command or a batch file then
the command processor is run with the /K switch to cmd.exe.
This means that the window will remain after the command
has been run.

If it is not an internal cmd command or batch file then
it is a program and will run as either a windowed application
or a console application.

parameters These are the parameters passed to the command/program.

8638.

Solve : Dos Command?

Answer»

I get a DOS command after the start of the motherboard en read as FOLLOWS:

VLEGA is compressed
Press CTRL+ALT+DEL to restart

After that I'll get over and over the same command

What is happening, is my HARDDISK drive broken??What happened prior to this ? ?
What OS are you running ? ?
What do you MEAN by the MBoard start ? ?Does it actually say VLEGA? Not BOOTMGR or NTLDR?

8639.

Solve : Dos harddrive failure?

Answer»

I'm trying to boot an harddrive into dos 6.22, i format the harddrive after booting into dos 6.22 form a disk, i run format c:/s. after that if i reboot on the disk, a can acces the harddrive, and see the command.com, but i can't boot on the harddrive, i always receive the message "hard drive FAILURE"
What's wrong?If you ran the format then C: is empty...
The command.com is probably on the Dos disk you are using....

What are you attempting to do here ? ?Quote from: patio on February 03, 2011, 05:49:36 AM

If you ran the format then C: is empty...
...

He used the /s switch.
If I recall, doesn't that transfer system files, and make the formatted disk bootable? ... or is supposed to?

I wonder if there was some error message. That's right Willy....forgot about the /s switch...
It should indeed be bootable.

The drive may have gone South...
DLoad the Free diagnostics from the HDD manuf. site...run the long test.Quote from: patio on February 03, 2011, 07:06:55 AM
That's right Willy....forgot about the /s switch...
It should indeed be bootable.

What I was wondering, and have not taken time to look up.... way back my memory, isn't there something about DOS 6.22 and hd size limit? Was it 2GB? (and I'm assuming that the drive in question here is larger than that)
That's what I was wondering about, when I asked about error messages. I just can't remember what happens with 'large' hard drives.

Could using a 'large' hd be the poster's problem?

Quote
The drive may have gone South...
DLoad the Free diagnostics from the HDD manuf. site...run the long test.

That too.

Well he didn't mention the size...i'll guess we have to wait...

The 2G was a FAT limitation....not neccessarily confined to DOS...Quote from: patio on February 03, 2011, 08:42:19 AM
Well he didn't mention the size...i'll guess we have to wait...

The 2G was a FAT limitation....

Ah! That's it.

Quote
not neccessarily confined to DOS...


But... DOS used FAT.

Well... I don't mean to obfuscate the issue. I was reaching.. looking for possibilities.



Let's see what he has to say, when he returns. I'd still like to know if there was any error message.


Thanks


Here's the message:

Quote
i always receive the message "hard drive failure"

We:ll see...thats why i suggested HDD diagnostics.Quote from: patio on February 03, 2011, 09:04:12 AM
Here's the message:

We:ll see...thats why i suggested HDD diagnostics.

Sorry... I was referring to : "i run format c:/s" ... I wondered if that command behaved normally, or if it showed some error.


Would DOS 'lie', and report hard drive failure if it tried to boot from a hd, and only got part way through it?

And I agree... it sure can't hurt, in the process of elimination, to do the hd diagnostics.

More precision:
Hi, what I'm trying to do is to "repair" and old industrial computer from siemens running on a PLC setup.
This computer is a 386 with a phoenix 1.02 BIOS.
I try to USE an 2G hard drive.
the broken one was a 3G, larger than the configured BIOS setting TYPE 17 (40Mb), but it was working!!
i'm pretty shure tha the 3g was running in dos6.22 because a "setver" command was in the config.sys

hope it will help

I'm running this program now to repair all the "bad" sectors on a freshly formatted 20GB hard drive. It's not a free program but so far, it's fixing every bad sector. Read the User testimonials. I also used it to repair industrial PLC's (A-B).

FAT16 MAX volume size is 2GB. Your 3GB drive may have unallocated the last 1GB which is no problem.Quote from: Computer_Commando on February 03, 2011, 04:59:07 PM
FAT16 max volume size is 2GB.

specific Operating systems (DOS, win9x for example) limit FAT-16 to 2GB, because they use a 32K maximum cluster size; unsigned short (16-bit) gives us 65,536 clusters; with 32K clusters that gives us 2,147,483,648 bytes (2GB); with 64K sized clusters, it goes up to 4GB. 64K is the largest possible cluster size, and can be used by at the very least NT4 (don't know about other versions)

For the purposes being described, though, this is all irrelevant.

In fact, such limitations are wholly redundant since they successfully issued a format command. The DOS Format command isn't going to format a drive larger then capacity; and I don't think fdisk will allow you to create a partition larger then 2GB anyways.

personally I've never had much luck with the /s switch on format. I always end up using sys C:... or perhaps it's force of habit.

Quote from: gibson1965 on February 03, 2011, 01:47:52 PM
the broken one was a 3G, larger than the configured BIOS setting TYPE 17 (40Mb), but it was working!!
i'm pretty shure tha the 3g was running in dos6.22 because a "setver" command was in the config.sys

hope it will help

I think it does, gives us some context.

So If I understand this correctly, you have the "new" 2GB installed using TYPE 17?

I'd run a sys C: after booting from the floppy, just to be sure. Maybe "start over" by using fdisk and deleting all partitions and recreating them. (or, it, I should say).

the new hard drive may simply not be compatible as a Type 17; you might be able to use type 47 (user) and put in your own disk geometry; but you'd probably be better off swapping through a few different types until you get something that works reliably.

Quote from: WillyW on February 03, 2011, 09:24:04 AM
I wondered if that command behaved normally, or if it showed some error.
This- did the format complete successfully? after the format it will state "System transferred"; did this occur?

Quote
Would DOS 'lie', and report hard drive failure if it tried to boot from a hd, and only got part way through it?
No. The error is being reported by the BIOS; a MACHINE of that era would often state hard disk failure simply because it couldn't boot from the drive. (DOS doesn't report serious hard disk errors at all; usually the best you can hope for is a hang)
Quote from: BC_Programmer on February 03, 2011, 08:37:24 PM
... you might be able to use type 47 (user) and put in your own disk geometry; but you'd probably be better off swapping through a few different types until you get something that works reliably.
That's what I was going to suggest.
8640.

Solve : Run multiple command in a batch file?

Answer»

Hi all,
i need your support cause i'm a newbie about Ms Dos batch.
My problem is that i want to run into a batch, two command.
The first one has to compress a FILE and the other has to change the name of the resulting file adding a suffix.
The problem i have encountered is that only the first one works, the second one doesn't start.
Here you are the batch i have written:

Code: [Select]RAR a XXX_ -m1 -df -ep -agYYYYMMDD C:\temp\*.txt
for /F "tokens=1-2 delims=." %i in ('dir *.rar /b') do ren "%i.%j" "%i0330.%j"
If i run the second command in the MsDos prompt it works.
Thanks in advanceOne percent sign at the prompt, two in a batch file, so change all %i to %%i and all %j to %%j
WORKS...
Thanks a lot.
Can you explain me why i have to double all %? Quote from: canislupus on FEBRUARY 03, 2011, 08:33:01 AM

WORKS...
Thanks a lot.
Can you explain me why i have to double all %?

It's to do with the way the command interpreter expands variables. Using a percent sign (%) in a batch file requires that two percent signs (%%) be specified.

For example, the command to display "5%" from a batch file would be :

ECHO 5%%

A single percent sign on a line is treated as a "nul" character in a batch file. For example:

ECHO % is processed as ECHO
ECHO a%b is processed as ECHO ab

If a command contains two percent signs, the command interpreter will treat any characters between them as an environment variable to be expanded. For example, if the SET command shows that the current environment variables are

COMSPEC=C:\COMMAND.COM
PATH=C:\DOS
PROMPT=$P$G
B=C


then

ECHO %PATH% is processed as ECHO C:\DOS
ECHO a%b% is processed as ECHO aC
ECHO a%b b%a is processed as ECHO aa


If there are no characters between the two percent signs, one percent sign is stripped off and the other will remain. This is why a FOR command that echos the name of each file with a .COM extension would be

FOR %V IN (*.COM) DO ECHO %V


but if the same command is placed in a batch file, the following is required:

FOR %%V IN (*.COM) DO ECHO %%V


Perfect i have understood all.
Now i have an other problem related to the same batch.
I need to launch the for command on a file that isn't in the same directory where the batch run.
I have TRIED to modify the batch from:

Code: [Select]for /f "tokens=1-2 delims=." %%i in ('dir *.rar /b') do ren "%%i.%%j" "%%i0330.%j"
to:

Code: [Select]for /f "tokens=1-2 delims=." %%i in ('dir C:\temp\*.rar /b') do ren "%%i.%%j" "%%i0330.%%j"

But i receive the error "The System cannot find the file specified".
This time where is the problem ?

P.S. Sorry if i asked stupid thing but i am a newbie...


Code: [Select]for /f "delims=" %%i in ('dir /b C:\temp\*.rar') do ren "%%~dpnxi" "%%~dpni0330%%~xi"I apologise, the above won't work, but this should...

Code: [Select]for %%i in ("C:\temp\*.rar") do ren "%%~dpnxi" "%%~ni0330%%~xi"
explanation

FOR %%variable IN (set) DO command.

Using FOR without the /F switch and therefore no tokens/delims block, (set) can be a set of one or more files, wildcards can be used.

There are FOR variable modifiers... in this case we use ~d, (drive) ~p, (path) ~n (name) ~x (extension) so if (set) is a file or files, then:

%%~di is the drive letter (with a colon)
%%~pi is the path
%%~ni is the file name
%%~xi is the file extension (including the dot)

They can be combined so that %%~dpnxi is the full drive letter, path, name and extension of a file. You need to supply this to REN if the file in QUESTION is not in the current directory.

Type FOR /? at the prompt for the command help.




8641.

Solve : Talking to IIS 7 (Windows 7, 2008)?

Answer»

Hi,

I got the following script from the windows scripting book for windows 2003 so obviously written for IIS 6.

The rror I am getting when I run this is :

iis.vbs(13, 1) (null): 0x8004100E

This is - Syntax error.

Line 13 is - Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & wmiNS)


I THINK the problem is what I am passing on wmiNS.

I TRIED different values based on several articles I have read after a few google searches.

- GetObject("IIS://" & ComputerName & "/W3SVC")
- GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "/W3SVC")
- wmiNS = “/root/MicrosoftIISv2"

Nothing worked. I am not ABLE to find any thing. Can you please LET me know what am i doing wrong and also point me to a book/site/tutorial on using scripts on IIS 7? (MAINLY to create Application Pools, set application pool parameters, Create sites, create site specific parameters, create site specific ASP paramters, etc)

Thanks for your time

Code: [Select]Option Explicit
'On Error Resume Next
Dim strComputer
Dim wmiNS
Dim wmiQuery
Dim objWMIService
Dim colItems
Dim objItem

strComputer = "."
wmiNS = "\root\WebAdministration"
wmiQuery = "select * from CIM_Setting"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & wmiNS)

Set colItems = objWMIService.ExecQuery(wmiQuery)
For Each objItem In colItems
WScript.Echo ": " & objItem.Name
Next

Thanks,
Shiyam

8642.

Solve : Unzip Windows script?

Answer»

Hi,

I wrote the this script to unzip a zip file using windows scripting.

==============================================================================
Dim folderPath01
folderPath01 = "C:\AV\"
Call UnzipFolder(folderPath01)

FUNCTION UnzipFolder(FoldPath)

Set objShell = CreateObject( "Shell.Application" )
Set objSource = objShell.NameSpace(zipfile).Items()
Set objTarget = objShell.NameSpace(FoldPath)
intOptions = 256
objTarget.CopyHere objSource, intOptions

End Function
==============================================================================

When I run this script I get the following errors:

Object required: objShell.NameSpace(...)

I am running this on Windows 7 - 64 bit. PLEASE let me know what I am doing wrong.


Thanks,
ShiyamYou have not specified a value for zipfile

You will need to add:

zipfile = c:\PATH\myfile.zip

to your script.As Oldun has noticed, you have not given a value (needs to be full path and name of zip file) to the variable zipfile in this line therefore you got the error message described.

Set objSource = objShell.NameSpace(zipfile).Items()

Because you have made the unzipping code into a function, you need to pass the path and name of the zip file as a parameter to the function. (Did you really "write" that VBscript?) The following script will show what I mean

I have run this on Windows 7 Professional 64 bit and also XP Professional 32 bit.

Dim folderPath01
folderPath01 = "C:\AV\"
Zipfile="C:\Zipfiles\Test.zip"
Call UnzipFolder(folderPath01, Zipfile)

Function UnzipFolder(FoldPath, ZipFileName)
Set objShell = CreateObject( "Shell.Application" )
Set objSource = objShell.NameSpace(ZipFileName).Items()
Set objTarget = objShell.NameSpace(FoldPath)
intOptions = 256
objTarget.CopyHere objSource, intOptions
End Function

In addition, this method will NOT work if Compressed Folders is disabled. In that situation, you will get this message:

Path\to\script.vbs(line number, char number) (null): Unspecified error

It is simple to Google how to enable/disable Compressed Folders.

Note: As with any file copy operation using CopyHere, the second parameter for CopyHere specifies how the copy from "compressed folder" (zip file) will be carried out:

In your script this is the value (256) you have given to intOptions.


4 Do not display a progress dialog box.
8 Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.
16 Respond with "Yes to All" for any dialog box that is displayed.
64 Preserve undo information, if possible.
128 Perform the operation on files only if a wildcard file name (*.*) is specified.
256 Display a progress dialog box but do not show the file names.
512 Do not confirm the creation of a new DIRECTORY if the operation requires one to be created.
1024 Do not display a user interface if an error occurs.
2048 VBScript version 4.71. Do not copy the security attributes of the file.
4096 Only operate in the local directory. Do not operate recursively into subdirectories.
8192 VBScript version 5.0. Do not copy connected files as a GROUP. Only copy the specified files.



Wowww. Thanks Oldun and Salmon for your time.

Salmon,

Thanks a lot for your detail. I am new to windows host scripting. I am learning it from Microsoft Windows Scripting book from MS press. It is written for Windows 2003/XP. So when ever i get an error (specially the object requireed error), I tend to think its because its not available on Windows 7.

Again. I appreciate you explaining intoptions variable, as that was going to be my next question. I have no idea how you saw that coming.
I had "zipfile" variable defined on this script even though I forgot to post it, but I had two issues.

1. I did not pass that to the function as a parameter.
2. I did not have the full path "zipfile" on variable.

I have one more question. If I have the .vbs file and the .zip file on the same folder, why doesn't the relative path (i.e. just the filename (file.zip) does not work? Is there any way to acheive that?

Thanks again for the time.

Regards,
ShiyamQuote from: shiyam198 on February 06, 2011, 01:11:06 PM

Again. I appreciate you explaining intoptions variable, as that was going to be my next question. I have no idea how you saw that coming.


Oh, I just had a feeling...

also I decided it was a useful thing to mention.

Quote
I have one more question. If I have the .vbs file and the .zip file on the same folder, why doesn't the relative path (i.e. just the filename (file.zip) does not work? Is there any way to acheive that?

I imagine it does not work because the file copy routine you are calling probably requires a full path for the source folder (zip file really). If you wish to use a script's own folder path then you can get that from WScript.ScriptFullName. Surely that is in your book?

Option Explicit
Dim folderPath01
Dim Zipfile
Dim ZipfileFullPath
Dim ScriptPath
Dim ScriptFullName
Dim Objshell
Dim objSource
Dim objTarget
Dim intOptions
Dim CopyOption

ScriptFullName = WScript.ScriptFullName
ScriptPath = Left (scriptFullName, InStrRev ( scriptFullName, WScript.ScriptName) - 1)
folderPath01 = "C:\AV\"
Zipfile = "test.zip"
ZipfileFullPath = ScriptPath & Zipfile
CopyOption = 256
DummyValue = UnzipFolder(folderPath01, ZipFileFullPath, CopyOption)

Function UnzipFolder(FoldPath, ZipFileName, IntOptions)
Set objShell = CreateObject( "Shell.Application" )
Set objSource = objShell.NameSpace(ZipFileName).Items()
Set objTarget = objShell.NameSpace(FoldPath)
objTarget.CopyHere objSource, intOptions
End Function


8643.

Solve : REGEDIT in .bat file?

Answer»

Quote from: BC_Programmer on February 06, 2011, 09:30:42 AM

While I don't doubt that the circumstance is similar, I would be more likely to attribute it to somebody trying to GET a game they shouldn't be running on at least one school computer... generally FRENCH Classes aren't taught in a computer lab

Oh but they most surely are, At my school we did lot's of excercises at the computer lab Yes, in plenty of schools a room with COMPUTERS in it is used as an audiovisual resource for many subjects as well as for teaching computer related topics.

wow. That certainly explains why so many kids have trouble with their penmanship; the school I went to only had I think 7 computer labs; 2 were solely for computer courses; and 4 were "rented" by other classes. (which of course could very well be french). But generally classes like french, Math, Science/Social STUDIES, etc weren't taught in a computer lab- they were taught in a "normal" classroom.

Even then, I (as ironic as this may sound) hated it. I much preferred to write out my essays by hand; this feeling was only reinforced when the first time I did hand in a printed-out version I was accused of plagiarism . I don't think I ever handed in ANOTHER type-written essay through the rest of high school after that. Not that I felt badly about it; after all seeing the handwriting/printing of fellow students it looked like my writing might have looked in 4th grade. I liked working with computers, but I didn't like doing my work on computers (if that makes sense); for a similar reason I hated the fact that I grade 12 math required a graphing calculator; more so that it was used for nearly everything. I ended up just writing TI-BASIC programs to do my assignments for me after I understood how it was done, which somewhat defeated the purpose of the assignments themselves... I've retained most of it I think, aside from Synthetic division, since I've ended up using most of it for my programs (Trigonometry has a strong tendency to show up when it's not wanted for example)
8644.

Solve : How to re activate DOS commands in Win XP SP3??

Answer»

hey,

one program disabled all my DOS COMMANDS to be interpreted.

My system is Win XP SP3.

I can get into DOS mode via Win Run> cmd, but cannot execute any commands; when trying the reply ALWAYS:

" the command, TYPED in" is not recognized as an internal or external command, operable program or batch file

I guess the program might have updated a key in the Registry.

Any solution?

Thanks, billPlease do not DOUBLE post. Your query is answered in the WindowsXP forum

.

8645.

Solve : [need help] unzip the binary file copy /b in bat/vbs?

Answer»

hello everyone,

here i have a problem to unzip the binary file with "copy /b" in my batch file program...

ok i will explain more detail..

first i do :-
Code: [SELECT]copy /b *.jpg + *.zip result.jpg
then i rename "result.jpg" to "result.zip"

after that i use my batch file to unzip, it won't unzip the binary file... but if i zip normally without use binary file it can be unzip...
i use the code below..(just look at the "echo .......... >> unzip.vbs")



Code: [Select]copy "kin\just\result.zip" "c:\result.zip"
MD "c:\cepat"

echo pathToZipFile="c:\result.zip" >> unzip.vbs
echo extractTo="c:\cepat" >> unzip.vbs
echo.
echo set sa = CreateObject("Shell.Application") >> unzip.vbs
echo set filesInzip=sa.NameSpace(pathToZipFile).items >> unzip.vbs
echo sa.NameSpace(extractTo).CopyHere(filesInzip) >> unzip.vbs
start unzip.vbs

ping localhost -N 4 >nul
copy c:\cepat "kin\just"
ping localhost -n 4 >nul
del "kin\just\result.zip" /q /f
ping localhost -n 4 >nul
del "unzip.vbs" /q /f
ping localhost -n 2 >nul
del "c:\cepat\*" /q /f
ping localhost -n 4 >nul
rmdir "c:\cepat" /q
ping localhost -n 4 >nul
del "c:\result.zip" /q /f
thank in advance for your help....
I see that you are trying to hide files within a photo.

I would avise using .rar files for this, instead of .zip, that fixed my problem back in the days

And you shouldn't use a batch file to unzip. after renaming it to result.zip you have to right click and unzip from thereQuote from: Fareast187 on February 05, 2011, 05:30:01 PM

then i rename "result.jpg" to "result.zip"

You do realize that just remaining the file from "result.jpg" to "result.zip" doesn't make it a zipped file right? If it isn't an actual zipped file then no matter what you do you won't be able to "unzip" it.
Quote from: mroilfield on February 06, 2011, 07:33:11 AM
You do realize that just remaining the file from "result.jpg" to "result.zip" doesn't make it a zipped file right? If it isn't an actual zipped file then no matter what you do you won't be able to "unzip" it.

Read his post. You can use the COPY command with the /b switch to join a jpg and a zip together into a third file, which you can give any extension you like. If you give it a .jpg extension, a jpeg viewer will see the jpg part and display it normally. It will not see the zip part. If you change the extension to .zip, an archive manager (Winzip, WinRar, etc) will see the zip part, but not the jpg, and process it normally. Thus you could hide a zip in a jpg or vice versa.

What he does not seem to realise is that using wildcards and copying multiple jpegs and then multiple zips will not result in multiple hidden but accessible files. Only the first jpg and the first zip will be available, and only to a Zip program.

Also that unlike proper Zip archive apps, the VBS unzip ROUTINES

1. Are really "copy from compressed folder" routines, and require compressed folders to be enabled.
2. Unlike WinZip, etc, won't like the fake "compressed folder" (zip file) resulting from the copy, and will copy nothing.








Quote from: polle123 on February 06, 2011, 04:57:03 AM

I would advise using .rar files for this, instead of .zip, that fixed my problem back in the days


thank you very much...my problem solve now....i use RAR file and everything solve....
ACTUALLY im do a program security call "4 gate folder security"

like this :-
first folder do a basic security like hidden folder or partition drives
second folder do medium security like change extension of folder
third folder do hard security like desktop.ini write extension of control panel(every time someone click it, it will go to control panel, if someone rename the file it will never change)
forth folder do very hard security like hidden file inside jpg

maybe next time i'll add one more security with make a password in the rar file..


8646.

Solve : have installed ms dos but can't get cd rom drive recognized?

Answer»

Hard drive reformatted-so only MS Dps installed through old floppies. Have been UNABLE to get D drive (CD rom) to be recognized-even though the light does go on.
I have CHANGED the boot order in the BIOS and it still just goes to MSDOS and gives a C prompt.
Any ideas?Please do not start multiple threads on the same topic. I'm locking this thread.

8647.

Solve : So, I wanna automate some processes....?

Answer»

Hello,
I have a certain little command-shell program (I will call it "myPROG.exe"). This program reads an existing text file ("INPUTFILE.txt") that has a bunch of commands ... myPROG.exe follows those commands, and then spits out an output file (I will call it "LOG.txt").

This is what I type at the DOS-like 'command prompt' supplied with my copy of Win7, 64bit:
C:\ myPROG.exe INPUTFILE_1.txt > LOG_1.txt
When the program is done working (**SEE below), I have to run it again: this time with a new input file ("INPUTFILE_2.txt") with a new. So, I would type:
C:\ myPROG.exe INPUTFILE_2.txt > LOG_2.txt
Then a third...
C:\ myPROG.exe INPUTFILE_3.txt > LOG_3.txt

This process is repeated with up to 10 input files.

Is there any way to automate this process? Also, if you can tell me how to do it using Linux terminal (using the linux VERSION of this program), that would be great too.

THANK YOU!!!
-BH

P.S. -- If this is at all relevant: I know JAVA .

**I know the program is done when I open "LOG.txt" and I look at the last line of that text file -- it should SAY "--complete--"
(Actually, there is another way to tell that the program is working -- After I initially tell the program to run, I can't type at the command prompt, but once it is done, I am able to type at the command prompt again).


Quote from: bhill4 on February 08, 2011, 07:13:14 PM

Hello,
I have a certain little command-shell program (I will call it "myPROG.exe"). This program reads an existing text file ("INPUTFILE.txt") that has a bunch of commands ... myPROG.exe follows those commands, and then spits out an output file (I will call it "LOG.txt").

I hate these "hide the truth" type threads. Why do people do this? Coyly mention a "certain little program" which they "will call Myprog.exe". What's wrong with saying what it is really CALLED? Is it a dirty little secret?

I believe this thread starter may be Billrich. Just in case it isn't, the answer is, put the consecutive command lines in a text file and save it with a .bat or .CMD extension. For Linux use .sh


8648.

Solve : how to open files on cmd?

Answer»

I am a beginner and was wondering how i can open jpeg files or avi files on cmd. I would also like to know how to open folders too... What do you mean by "open" them? Make them appear in a viewer or video player? And when you say "open" a folder, do you mean open it in Windows Explorer?

To "open" a file in its default program, type its file name at the prompt and press ENTER.

To open a folder in Windows Explorer type

Start "" "c:\path\to\folder" (replace with the right path)

To open the current directory type

Start "" "%cd%"






S.T. - how come my moggy got into your image Quote from: Dusty on February 08, 2011, 01:28:39 PM

S.T. - how come my moggy got into your image

He must have been on vacation in Spain, at the Jardín Botánico in Valencia, visiting the famous colony of 50+ CATS that live there, fed by the staff and supported by donations from local people and visitors who "adopt" a cat.

Perfect! thanks salmon trout! can i use the "Start "" "c:\path\to\folder"" in a batch file to open images using windows explorer?Quote from: maymon123 on February 09, 2011, 10:02:04 AM
can i use the "Start "" "c:\path\to\folder"" in a batch file to open images using windows explorer?

Open images in Windows Explorer? What do you mean?




sorry, windows "picture and fax viewer". I would like a batch file to open a picture using that program...Quote from: maymon123 on February 09, 2011, 10:28:41 AM
sorry, windows "picture and fax viewer". I would like a batch file to open a picture using that program...

Is it the default picture viewing program?
yes
Quote from: maymon123 on February 09, 2011, 10:35:25 AM
yes

Did you do what I said above?
UMM..... i tried... but how do i NAVIGATE through folders in cmd.... i am in the c drive, so "C:\>" SHOWS up, how do i open a folder on the c drive (Documents and settings)? I want it to be "C:\documents and settings".Quote from: maymon123 on February 09, 2011, 10:49:16 AM
umm..... i tried... but how do i navigate through folders in cmd.... i am in the c drive, so "C:\>" shows up, how do i open a folder on the c drive (Documents and settings)? I want it to be "C:\documents and settings".

C:\>cd "Documents and Settings" [hit Enter]

Why do you want to do this? It seems like a lot of trouble for you.



Oohh... thats it.... sorry, i love command prompt and i haven't used my computer for a while, due to school... so i forgot everything i knew... sorry.Thanx for all the help!
8649.

Solve : prompt in bat?

Answer»

hi there,

this is what I'm trying to make into a bat, it's to run a txt file against an SQL database, the problem is, it gets as far as the third line, then brings up a PROMPT > where the line .read UpdateBS.sql is the next step . How do I get this to work please?


cd\
cd "C:\Program Files\K\BS"
SQLIte3 BS.sqb
.read UpdateBS.sql
.quit
pause


mtia
MarkI have had a VERY quick LOOK at the documentation - I think you might get somewhere with this:

create a text file containing your interactive commands:

.read UpdateBS.sql
.quit
Call it sqlcmds.txt

now on the COMMANDLINE, run this
Code: [Select]SQLIte3 BS.sqb < sqlcmds.txt
What this does is tell SQLIte3 to run with the command line param that you had (BS.sqb) - but when it prompts for interaction, ignore the keyboard and take the input from the sqlcmds.txt file, line by line as if they had been typed in.

Check out 'redirection of input' here on this site and others to understand

Good luck
Grahamthanks very much Graham, that's DONE it

MarkH,

one more question please, this was what I've been using:

cd\
cd "C:\Program Files\KA\BS"
SQLite3 BS.sqb
but some users of my programme have their installation on other drives, not the same drive as their DOS cmd default and have been having trouble. It has been suggested to me that the first line should in fact be that drive for example if it was on the E:drive

E:
cd\
cd "E:\Program Files\KA\BS"
SQLite3 BS.sqb
is this correct, will it make a difference?

mtia
Joecan someone give me an answer to this please?

mtia
JoeI would say yes to your question, joesruk. You can specify a drive and folder this way

E:
cd\
cd "Program Files\KA\BS"

or this way using cd with the /d switch

cd /d "E:\Program Files\KA\BS"

thanks guys

8650.

Solve : cmd in japanese?

Answer»

I was just WONDERING if there is any WAY to change cmd into Japanese and BACK to english...