Batch file to know it's own name.
Posted: 03 Sep 2011 11:22
Hi,
I'm a bit new to batch programming.
I am trying to get a batch file to know it's own name at running time.
I can declare a variable with the file's name (like Something.bat) but I will be sending that file via email to many people.
A lot of them will receive the file and they will open it directly from their email clients, which will create a copy of my .bat in a temp folder and probably with some weird name like ~8364455.cmd
My goal is to copy the Something.bat to a local folder (which I've managed to create already) so the user can run that file whenever they need it again and have an option for going deep into their email attachments. The issue is that I don't know a way for finding out what that ~8364455.cmd filename will be so I can use any of the copy commands.
I can't just use the xcopy or some wildcard since it will copy everything in the folder.
One idea I have is to check the folder's content and copy the last modified file in there, if there is no way to accomplish the above.
Sorry if this is a repost.
Thanks in advance.
I'm a bit new to batch programming.
I am trying to get a batch file to know it's own name at running time.
I can declare a variable with the file's name (like Something.bat) but I will be sending that file via email to many people.
A lot of them will receive the file and they will open it directly from their email clients, which will create a copy of my .bat in a temp folder and probably with some weird name like ~8364455.cmd
My goal is to copy the Something.bat to a local folder (which I've managed to create already) so the user can run that file whenever they need it again and have an option for going deep into their email attachments. The issue is that I don't know a way for finding out what that ~8364455.cmd filename will be so I can use any of the copy commands.
I can't just use the xcopy or some wildcard since it will copy everything in the folder.
One idea I have is to check the folder's content and copy the last modified file in there, if there is no way to accomplish the above.
Sorry if this is a repost.
Thanks in advance.