0

Some context:

I have an Excel Macro (.xlsm) file I've created for my company, which I'm creating a batch file for that copies it from a Network folder to a local folder for each computer/user profile that clicks the batch file. What I'm looking to do is for every user that runs the batch file, I want to append their name to a hidden notepad file in the same network folder of the original macro file. That way, whenever I revise/fix/add features to the macro, I'll have a list of all the users that are using the macro file, so I can send an email letting them know of the updates.

Note: I know how to obtain the username of the user that runs the files.

I know that you can write and append to Notepad files using a batch file, but I can't find a source that verifies whether it's possible to write to an existing hidden Notepad file. I came upon this post in my search, but that's using the C# language.

So, my question(s) are:

  • Can a batch file write/append to a hidden notepad file?
    • If so, would I use the same syntax/method that you would when writing to a visible (non-hidden) file?
    • If not, would could I go about this feat? Could I temporarily unhide a hidden file, append to it, then rehide it? Or should I go about it using a different method?
  • Is this a good method, or is there a more efficient/better way to accomplish this (keeping a list of users that have the macro file)?
Community
  • 1
  • 1
CaffeinatedMike
  • 1,537
  • 2
  • 25
  • 57
  • Can't you just ask whoever uses it (e.g. in the spreadsheet or the download instructions) to drop you an email so you can add them to a distribution list? – Matthew Strawbridge Feb 21 '16 at 19:55
  • I could, but I'd rather it be an automated task since my co-workers aren't always the most reliable/responsible. – CaffeinatedMike Feb 21 '16 at 19:57
  • Why not instead have the macro attempt to check version.txt on the network folder and notify the user if their version doesn't match the latest (if accessible)? – rojo Feb 21 '16 at 21:42
  • Because again, I don't want the end user (my co-workers) to have to do anything, in this case replace their older version file with the new one. – CaffeinatedMike Feb 21 '16 at 21:46

1 Answers1

1

You could use stream redirection operator >> and system variable with login as i recall %username%. Do echo %username%>>hiddenfile. txt

dabal
  • 410
  • 3
  • 15
  • So, it *is* possible to write to a hidden file? I know *how* to append the username, but just wasn't positive that these commands would work on a hidden file. – CaffeinatedMike Feb 21 '16 at 20:00
  • 1
    @CaffeinatedCoder why didn't you just try it before asking your question? The hidden attribute just keeps the file from being seen but we all know that we can set Windows Explorer to always show hidden files and the DIR command can also show hidden files. – Squashman Feb 21 '16 at 20:43
  • That is my fault for not trying it first, I own up to that. I don't want Windows Explorer to always show hidden files. The idea is that the end users should not see this file on the network drive. Is there a way to temporarily show the hidden files in that folder, append to that particular file, then set Windows Explorer back to not showing hidden files with the batch file? – CaffeinatedMike Feb 21 '16 at 20:54
  • But anyone can see hidden file. There is a settings that say 'always show hidden files'. – dabal Feb 21 '16 at 21:15
  • 1
    First thing I do at work is turn on Show Hidden Files (and extensions). When I dir I automatically add /a to show all files. Hidden files are really just hidden from you. –  Feb 21 '16 at 21:51
  • @CaffeinatedCoder why would you unhide the file, then append to it and then hide it again. I already explained it does not matter. You do not need to remove the hidden attribute or tell explorer to show hidden files to write to a file. TEST IT FOR CRYING OUT LOUD! – Squashman Feb 21 '16 at 22:59
  • You did not **explicitly** state that it does not matter and since I don't know I asked. If you're going to comment at least comment with something conducive such as @bgalea's comment, which does help me. There's no need for berating. I did not know how I could view all files using that `/a` would allow me to see the hidden files. Even though it doesn't directly help with the question it's something that will e useful for me in the future. And now that I know it does not matter I can accomplish my task. Thanks for the answer, could've done without all the snark though. – CaffeinatedMike Feb 21 '16 at 23:09