Jump to content

AceInfinity

Member
  • Posts

    20
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    Canada

Posts posted by AceInfinity

  1. Here's a wait animation I wrote a while back, Only it's not based on a countdown:

    @ECHO OFF
    SETLOCAL ENABLEDELAYEDEXPANSION
    SET /A numtimes=3
    FOR /L %%G in (1,1,%numtimes%) DO (
    CALL :WaitDisplay "Please Wait"
    )
    CLS
    ECHO Done! Press any key to finish...

    PAUSE > NUL & GOTO :EOF

    :WaitDisplay
    SET string=%1
    SET string=%string:"=%
    SET dots=...

    FOR /l %%G in (1,1,3) DO (
    CLS
    ECHO !string!!dots:~0,%%G!
    PING localhost -n 2 -w 500 -l 5000 > NUL
    )

  2. Powershell is something i'm quite familiar with, but I never would have found it a while back without trying to learn about batch. Perhaps It's senseless to keep batch as a part of my background knowledge and keep with Powershell? I've made lots more with powershell for my love of it's functionality over Batch, and i've created a few commandlets of my own that I can run through a quick console to do certain tasks that save me time on my computer.

    Don't get me wrong though, batch still has some uses, but with Windows 7 where Powershell is built in by default for me, and even same with Windows 8, i'm pretty sure it will become the new batch in a little while here.

    I find Powershell lots more enjoyable though, as it can create GUI's as well if you utilize and reference the system namespaces.

  3. I don't see why you don't just use that instead.

    I have used perl, I created a file compare script in the past, which was mentioned in one of my earlier posts in this thread. But I wanted to see what I could do with batch just for personal learning experience :)

    Comparing 100 different files between themselves is better done with hashing anyway, and multithreading can barely help here really (it's very much IO-bound, unless you have a fancy SSD). Either ways, batch files don't give you that option.

    Anyway. Have fun. I don't think I can be of much help with trying to improve on something without seeing the big picture (the end goal/purpose).

    That's true, i've been told to not use MD5, so maybe an SHA1 hash version of my perl script for the file comparison? My perl script does use a hashing comparison method, but currently the only way I knew this through batch was through a program called fc.exe which I found on Windows through some searching lol.

    jaclaz told me about Comp, which I may look into next...

  4. Modified Windows files? How about running sfc /scannow? That's built in, and meant to fix precisely those kinds of problems (there's system restore too). Or otherwise, why not compare the SHA1 hash of the file with one of the online lists that already exist, or from a known good file on another machine? As for identifying malware by running fc /b on 2 files... Most people have an antivirus which seems like a far better option for that

    I don't need to endure belittling comments like this in my attempts to just try and learn something. All I want is advice, and I'll pursue the necessary steps based on feedback I've been given to improve on this. That's all I really want here...

    Please note that I already mentioned my awareness to the system file checker command, and how I was just trying to find a very quick example. The use of this thing is limited to imagination, disregarding the limits of the script itself for larger files which has also already been made well aware to me throughout this thread by several other members. I don't need to have it reiterated to me over and over, that only really just gives me a headache and adds to extra posts in this thread that give me deja vu when I find out I'm reading what's already been told to me though.

    I KNOW I'm not the greatest batch programmer, but I need some new information as well. Having it bashed into my head from criticism on how my script here is useless does not help me. It may be useless no matter what I do to this script. But I just want to learn how to improve on it so I can become better at batch.

    I'm not looking to make a masterpiece here, or the absolute best script in the world for comparing files. If I was to do that, I probably wouldn't even use batch as it's slow anyway.

    Take a look at what you've said to me below here...

    A simple byte-for-byte comparison would catch that. That's pretty easy to write in any language if it's not already built-in (you said you're using perl which has File::Compare, python has filecmp.cmp, etc). Hashing here only adds CPU load for no reason (and as Jaclaz already pointed out, MD5 is quite old and a bad idea in general, SHA1 is a common replacement for it). It also increases comparison time not only by being CPU bound, but also by forcing you to hash the whole thing, whereas when you're doing a byte-for-byte comparison you can easily quit at the first byte that's dissimilar (and it very well may be the first byte of a file that's hundreds of MBs). Using hashes is mainly useful in different scenarios, like comparing one file to a known hash i.e. when you don't have the other file on hand, or don't want to send/copy it elsewhere to compare it there (and other tasks like for password authentication obviously). Unless you want to compare a large number of files together and identify duplicates (not necessarily comparing against one specific file), in which case hashing indeed works nicely (it saves times by not having to re-read lots of files, lots of times)

    This part is something new to take into account. I already know well about password authentication and hash comparison methods, specifically used on websites for the most part to authenticate a user to a MySQL database, and either SHA1 or MD5 are most commonly used for that.

    Multi-threading is of no use here anyway. I'm not sure how you were expecting to use it, or what for. But if you try to read two or more files at once and then hashing them it's going to be quite slower, due to drastically increased seeking (except on SSDs). Unless you plan on having one thread reading the entire file (which might be huge) to RAM, and then while it hashes the other thread loads another file to RAM -- or one thread that queues files to hash in byte arrays in RAM while the other thread does the hashing. That would require TONS of RAM if there is large files (e.g. comparing two DVD9 .iso's would require more than 16GB of free RAM), and the speed gain is rather minimal vs using streams (which uses very little memory).

    What would be the purpose of comparing DVD's though? Multi-threading can be of use, it just depends on how you want to use it. As you say you could compare 100 different files on a same thread, but memory would be a factor there.

    I'm well aware of those points :)

    SHA1 is getting old indeed, but it's still "good enough" for most file comparison tasks and what's still getting used the most today, even when security is involved. Other hash algos tend to be slower and mainly overkill for this particular job here. MD5 though... I can't think of a reason I'd start on a new program/design using that in 2012.

    There's nothing wrong with MD5 in my opinion. It still works. There's tons of hashes out there, but MD5 is common in most things. If you say SHA1 is still "good enough" then I don't see a reason as to why MD5 can't be classified in the same way.

    As jaclaz said, and I myself have never came across an MD5 collision either, it's highly unlikely, and still fairly unlikely unless you look to try to match them purposely. But that would be hard to do with something like malware because you'd need to have the malicious function operational, while still trying to match an MD5, and just binding the file alone you're going to have to try to calculate how that can be done if you're binding to a windows file. This would include possible compression of that windows file to make sure that your binded malicious code matches the original filesize as well after everything is done. Not a very easy task for malicious code developers.

    It's still a VERY common and used hashing algorithm out there, so there must not be anything wrong with it. C programming language is old, but it's still used out there lots. Being old doesn't mean we're forced to the idea of change because of the fact that it's old that there must be something better out there.

  5. This kind of feedback I can respect though, now we're actually getting somewhere lol :)

    Good. :)

    JFYI, a small batch file (by mere coincidence also using FC.EXE) I just posted:

    Take into account that it is posted in a very specific thread and aimed mainly at people that do know where their towel is and it is admittedly experimental. :hello:

    jaclaz

    Thanks for that reference I will definitely take a look jaclaz :)

    Much appreciated!

    But this could be used to scan for modified Windows files or to identify malware in any case if it's been binded with an important system file and that system file has been acting up.
    Taking the scenarios above, could you explain how I would do this using your script as posted and improved upon thus far.

    Which files would I select in, for instance, system32 together with my suspect system32 file in order to start a comparison?

    narrowing the search by only comparing files of similar filesize.
    Now why would you do that in perl and not in the batch script? Based on the method you are using and the potential time it takes and, as jaclaz above states, the possibly huge output file to check that is exactly the kind of thing I'm expecting you to think about. I know that's a decision you could make yourself manually when selecting the files in your explorer window, but why accept manually when you're creating a script to save time.

    I was just trying to find a reference in a way that I could show you how it may be useful, however, maybe a utility like system file checker would be better for system files to check their file integrity, but if you saved a backup of explorer.exe somewhere, knowing that it was the factory default for that file. And you noticed odd behavior in your current explorer.exe (with non-regard towards the file size differences, if any) you could compare with the original explorer.exe that you have backed up someplace, with the one that you currently use on your system. I'm just being optimistic now, but trying to think of ideas here.

    Now why would you do that in perl and not in the batch script?

    ... Hmm' date=' actually, see now we're getting somewhere! :) Thankyou for that suggestion... That is actually something to think about, and finally a post that I can use for improving this script.

    I am personally apologizing for the past posts i've made towards you, that's all I was really looking for in a reply from you. I'm dumbfounded as to why I didn't think of this earlier, but when I made this script I had forgotten that I had made a perl version to do a similar task as well. All my Perl scripts are backed up on my external hard drive, some which are more than a year old.

    I appreciate all of the responses i've been given so far, thanks guys!

    [b']Edit: Wait... YzOwl... What about file sizes that may be the exact same but have different binary data? In the case of my perl script, I was comparing for SIMILAR file's and that's only possible if the file size is the same, otherwise it would indicate that it's a different file and the MD5 would change. In this case i'm trying to compare for DIFFERENT files, although if I limit myself to files of different file sizes, what about the files of the same size that have different binary data that i'm not scanning because I limit myself in the scan to scan for files of different sizes only?

    Also, how would you go about scanning files of mass filesizes? (Bigger files)

    In Perl I'm given the benefit of multi-threading, but i'm not sure how I could do this in batch (not multi-threading, just scanning larger files)

    ~Ace

  6. Aceinfinity,

    take it easy, man :).

    I will try to explain to you the issues with your batch and post (nothing personal, only trying to tell you plainly what may have contributed to the present misunderstanding)

    Facts:

    1. what you posted is NOT a batch file :w00t: (see below ;))
    2. it misses a simple, basic explanation of it's intended usage paradigm

    Explanation:

    If I remove from it the several lines of copyright related matters, it amounts to a handful of "normal", "common", batch commands (which can be made "better", as seen).

    It completely misses a number of checks for "sanity" and "safety" (just imagine that you compare with it two say, DVD .iso's, and you will get a bin_output\results.txt of several Gb's :ph34r:, and probably take a bit of time to run with CPU at 100%

    It cannot run from read only media (and does not provide the user for a way to choose an alternate target location), it does not check for existence of compared files, it makes no checks for runnning OS, etc., etc..

    To invoke a Copyright on something, it must be something more "substantiated", IMHO, compare with:

    http://www.copyright.gov/circs/circ61.pdf

    All in all it amounts to a quick and dirty script to quickly do something VERY specific, like:

    1. on 2K/XP and later ONLY
    2. with relatively small files only
    3. on a Read/Write device
    4. only reliable if drag 'n drop is used

    Nothing particularly "bad" about the above :), simply these things might have been specified from the beginning.

    jaclaz

    I agree, but I doubt anyone still uses earlier than Windows 2K/XP. I have a 95 machine, as well as a 98, and 2000 all 3 of which in working condition still that I haven't used for general or "real" computer use in years.

    This kind of feedback I can respect though, now we're actually getting somewhere lol :)

    I was going to iterate through the files in a directory to start off, but decided to take specific input args as files instead when I first started writing this script. I personally don't know of any other realistic built in Windows utility though that is like fc but can handle larger data though anyways. Not off the top of my head at least. Perhaps you have other suggestions on a "reference" that can be used? And i'll see what I can do to ultilize it to make a better more adaptable batch script?

    I have actually created a much better version of this in Perl, although using MD5 file checksums as my comparison and narrowing the search by only comparing files of similar filesize. I was just curious one day as to what I would be limited to if I was to do the same in batch :)

  7. Finally some advice that I can use towards the latter if I was to create a newer version now.

    Though it may be harder to copyright this new version :whistle:

    I hereby claim copyright 2012 :w00t: for the use of SHIFT /2 :ph34r:

    :lol:

    jaclaz

    lol no, that copyright is more just for the looks anyway, I personally don't care if anyone uses my scripts, or modifies them in anyway, but I can provide credits with the copyright if I ever repost it, but I doubt it, i'm already making newer projects outside of batch.

    You still don't get it AceInfinity' date=' I provided advice, Scr1ptW1zard did the job for you and jaclaz improved on Scr1ptW1zard's work.

    My questions weren't whether you could do something they were designed to lead you to the reasons why you posted the script and what your end users would use it for.

    You haven't answered it, and TBH examining the scenarios whereby the file becomes useful to others is the most important thing about posting it.

    [/quote']

    You're still on about this? I don't see what there is to "get" personally. This is my thread, if someone has any batch skills, which they should before attempting to run any batch script they find on the net then they can analyze it and figure it out. Otherwise there's this thread here where people can ask questions on how my script works if they are interested. I'm not here to cater to folks, and it's up to them whether they are willing to use the script or not. It's useful for comparing files, simple as that. If you're a developer, a troubleshooter, etc... Or just a curious Windows user, then you might find a use for it.

    I personally made this for my own use, although decided to post it out there in case anyone else found it useful because it is universal in the way it functions.

    If you just wanted to remove duplicates, then maybe MD5 hashing comparison algorithm is better. But this could be used to scan for modified Windows files or to identify malware in any case if it's been binded with an important system file and that system file has been acting up. Otherwise, again, you can choose to compare by MD5, but i'm sure the data inside the file as binary data is just as well good.

    Are you interrogating me for any specific reason? Perhaps learning how this would be useful as you cannot figure it out with putting some scenarios together on your own? I'm having a hard time understanding why you can't just let me off the hook for posting this. Nobody else had much troubles with me posting here, so it can't be as bad as you claim it to be. Even if I was to explain everything, chances are there might still be questions left unanswered as I can't put together a limitless amount of probable questions and pair them off with answers in my head. No one can.

    Take a look at the output file you get and see if there is anything in it which could be bettered for the end user' date=' how would you change the code to do that?[/quote']

    Things can ALWAYS be improved, but is this possibly not one of the reasons to why I came here for feedback? Maybe someone else could add in something that they might find useful as an addition to my script here? Who knows. But again, this was just a friendly contribution. I never intended to work on this script for others, mainly myself, but others with permission to freely edit as they wish.

    Without answering these' date=' the only real part of the script which becomes useful to us is the portion produced by Scr1ptW1zard and improved on by jaclaz. [/quote']

    That doesn't make any sense to me really. But I think the reason why i'm not getting it is because I, as a human on this earth am entitled to my own opinion and point of view, and i'm just not seeing yours. You still haven't been too helpful to me in this thread after 3 posts though that you've made. You're acting like I don't have a brain here and I can't come up with suggestions on how to improve my script on my own. However, I know for a fact that i'm not going to have the same ideas as others, which is my main intension for why I created this thread.

    I'm not intimidated by your modship here, i'm a decent member of many forums, and i'm entitled to my own thoughts. I just don't see you as such a friendly guy after seeing the differences in posts between you and the 2 other members in this thread, who can joke around, and provide me some constructive criticism on the current code that I have. Yours just seems more conceptual, yet you don't back it up with much of an explanation as to why you say such things so I can use your posts to better much in terms of my script.

    Even if I was to think of more to add to my script that could be useful to others as you suggest, what would be the point if the current code I have now might not be ethical based on the assumptions i've made from your replies previously? You still haven't answered my questions here.

    And for my main question - what WOULD you use other than fc? Seeing as how you stated that fc is NOT what you would use. I've been waiting for answers to these questions so that maybe I can at least look something up if you were to suggest anything, but I haven't been getting very far with you in this thread so far. Which is ironic, because I mainly posted to see what kind of advice you would give to me here, knowing that you have posted various batch help around the forum in the past.

  8. These last three posts are what I was looking for :) Finally some advice that I can use towards the latter if I was to create a newer version now. Thanks guys! I'll see what I can come up with, and maybe to answer this quesion Yzöwl:

    As end users we really need to ask ourselves why we want to run this file. What are we looking for from it? Are we trying to find identical files, or are we trying to find files which appear the same but aren't?

    What are the likely scenarios under which this type of comparison would be required?

    I can do both? Provide a list of files that are identical and files that might not be?

    Maybe just loop more than once, to compare not just one file to all others, but every file to each other file.

  9. BTW, you didn't tell me anything I didn't already know, I only mentioned the parameter allocation and how the file works because you hadn't. (It's a little pointless posting a file for others to use if they don't know what to do or what it does.)

    Your method of determining whether any arguments were input still seems a little convoluted.

    I know you're a good batch programmer, so no personal tension between you and me as a member, but I thought that someone may find this useful, or someone like yourself could help me improve it further.

    I'm not just a good I'm excellent.

    Why would there be tension, you asked for feedback, and I gave some!

    TBH if I were to ever come across a similar kind of problem I would be unlikely to use FC anyhow.

    Alright, you tell me all the bad things about my script, but you don't attempt to help me, you just point out that these things are bad. I can't claim that to be the kind of proper feedback that I was looking for to be honest.

    So far you're just telling me that you're absolutely "excellent" with batch, but you can't provide some help to others other than telling them that they are doing something that may not be the best method? That shows a form of arrogance at it's lowest level in my opinion, which is not a bad thing, but if you have such knowledge, can't you attempt to utilize it to provide feedback that can help others? Feedback that can be of some use to this person? You would unlikely use FC, and my method of determining whether any arguments are inputted seems "convoluted". Okay... Why then?

    You're posts don't provide any support for me, and are of zero value as of now though. It's like going to a math class, and some teacher telling you "No, that's not how you do it, try again". Well then.... "How do I do it?". That is my similar perspective here from that analogy.

  10. Some general observations:

    You say you created the file some months ago, but strangely it was copyrighted only this month!

    You say that you have used 'SHIFT' in order to allow for more than nine arguments, but 'SHIFT' appears to not exist within the code.

    Your method of determining whether any arguments were input seems a little convoluted.

    You didn't explain in enough detail what the purpose of the script was:

    It compares one file which when dropped with a bunch of others onto a batch file is allocated as the first parameter, (using luck), with every other file following it. i.e. compare 1 with 2, 1 with 3, 1 with 4 etc.

    It compares one file which when dropped with a bunch of others onto a batch file is allocated as the first parameter, (using luck), with every other file following it. i.e. compare 1 with 2, 1 with 3, 1 with 4 etc.

    No that is unfortunately wrong, you can determine what param or arg %1 is by making sure that you want to compare with the file that you use to drag the collection of files with, is the one you want as %1. I've tested, and it's determined by the file itself that you drag over the batch, which gets parsed as the first argument after %0. For example: If you have 3 files, file1, file2 and file3. If you select all of them, and drag these files over the batch file itself by dragging file3 to move the files over the batch file to be used as arguments, file3 will become argument %1.

    I updated the year in the batch file lol. :) Batch files aren't compiled, so i'm freely able to edit that if I wish. Believe it or not, I created the script in 2011 but already had the year 2012 embedded in it anyways. It really plays no role on proof for when I created it though. For all you know I could have created this script more than a year ago (assuming the batch syntax would still be fitting for the NT version available to the user), but I still have optionality to change it to the year 9999 if I wanted lol.

    My mistake though... I had a version which used SHIFT... I had it in my notepad :S but it seems I copied out this one instead. I would provide a link to where I have provided the version with, shift, but It may be against the rules, so how about I just copy the code that I have pasted on another forum here to show you the version using shift to move the input argument up by one?

    Here's my first version:

    @echo off
    title Binary File Compare - Created by AceInfinity

    set i=0
    set args=0 && for %%a in (%*) do set /a args+=1 && set "original=%1"
    if %args% lss 2 call :noArgs
    set /a args-=2

    if not exist "bin_output" md "bin_output"
    (
    echo.----------------------------------------------------------------
    echo. Binary File Comparison Script - Created by AceInfinity
    echo. Copyright 2012
    echo.----------------------------------------------------------------
    echo.
    ) > "bin_output\results.txt"

    echo Processing Binary Data...
    :start
    fc /b %original% %2 >> "bin_output\results.txt"
    shift
    set /a i+=1
    if not %i% gtr %args% goto start
    exit

    :noArgs
    echo No other input files as arguments could be found...
    echo Please specify at least 2 input files to be used for comparison
    echo. && pause
    exit

    This will use fc to compare files by their binary data with the /b flag that i've specified directly in the code. After comparing each file to the first argument as the original file in which all other arguments/parameters as files will be compared to, it creates an output text file as a log to return all of the results. If you have lots of files to compare, the buffer of the console window probably won't let you view all of the data, so it's exported to a text file instead. It may have been better to change the code to make an export of each comparison test to a new file so that the text file doesn't become too large, however I don't think anyone will be doing that, it will most likely be maybe 1-5 files.

    If you want it to export to a new file everytime i'll create a new revised script if anyone wants it that way.

    Important Note: The way parameters are defined, it basically uses the NTFS filesystem default from top to bottom I believe in the order that it places values into arguments that are sent (to my script in this case). Therefore you can't really choose which file goes where if you use the drag drop method, unless you open a command prompt and define each filepath manually. But that doesn't really matter as we know that if you select more than one file, WHILE DRAGGING THE GROUP OF FILES OVER MY BATCH SCRIPT THE ONE FILE THAT YOU USED TO DRAG THE GROUP OF SELECTED FILES IS PARSED AS THE FIRST ARGUMENT (%1)

    This may be handy for you to know, when you want to quickly compare all other selected files to a specific file of your choice.

    I DID have a video of it in use, by the video got removed, because my Youtube account was deleted a week ago when I decided to try to delete my Google account which was linked with it. And unfortunately google deleted it along with the account.

    My apologies though... I can't believe I missed that it didn't use shift. (the version of my script I posted)

    If you have troubles reading it, or using the script, then just ask me though. First script is the most updated version as I found that shift was useless if I could just use the for loop to loop through all of the values in the arg list.

    I know you're a good batch programmer, so no personal tension between you and me as a member, but I thought that someone may find this useful, or someone like yourself could help me improve it further.

    If you don't feel like providing the advice that I so kindly looked for, even after clarifying what my idea of the kind of feedback that I wanted for this script was, then kindly do not post in this thread anymore. That's all. At least i've gotten some advice on how to check for a minimum number of input args without looping and counting each which makes my script a bit faster, but as well as a couple other little things posted by other members here.

    Have a nice day

    ~Ace

  11. I created this some months ago to take inputs from dragged files as arguments/params to the batch file and loop through them with fc using shift, so that it would take in more than a max of 9 args :)

    @echo off
    SETLOCAL ENABLEEXTENSIONS
    title Binary File Compare - Created by AceInfinity
    set /a args=0 && for %%a in (%*) do ( set /a args+=1 )
    if %args% lss 2 call :noArgs

    if not exist "bin_output" md "bin_output"
    (
    echo.----------------------------------------------------------------
    echo. Binary File Comparison Script - Created by AceInfinity
    echo. Copyright 2012
    echo.----------------------------------------------------------------
    echo.
    ) > "bin_output\results.txt"

    echo Processing Binary Data...

    for %%a in (%*) do (
    if not %%a==%1 (
    fc /b %1 %%a >> "bin_output\results.txt"
    )
    )
    exit

    :noArgs
    echo No other input files as arguments could be found...
    echo Please specify at least 2 input files to be used for comparison
    echo. && pause
    exit

    Perhaps someone else might find use for it, so I thought i'd share, and accept feedback on it

  12. Thanks a lot for the link :) I have lots of spare time on my hands for computers, and I was interested in creating a full theme of my own. I'm sure if system file checker raised any issues for me I could keep a backup of the original dll in my main system drive and replace it with the custom one if needed through cmd. But i'll stay away from them at this point, since it looks like there is another method here that you've pointed out to me.

    Update: Shame :( It's not free. People don't make it easy to develop for Windows do they? lol

  13. I could only find information about packing a .theme. Which is useless to me. I want to know how to edit the visual of more advanced things for windows 7 like the explorerframe, shell32, etc...

    How do these display the visual on a Windows 7 custom theme?

  14. Yeah, I don't like going against the rules. I am a fairly active forum member, and I do enjoy this forum. Don't want to be banned or anything soon or at all for that matter haha. I have tried contributing to a few discussions. Still waiting for replies on those topics however.

    I also asked because I couldn't find where I posted it, I thought it was removed or something, so I was just going to double check :)

  15. Hey MSFN :)

    Just introducing myself here, i've been a programmer for a few years now, and I hope to learn and contribute to this community a lot!

    I'm currently involved in a lot of pretty much anything to do with computers from gaming, programming, graphics (modelling/rendering), music, customization and more. Hope to see you guys around

    ~Ace

×
×
  • Create New...