I created a small harmless batch virus (a prank), it is finished (on a USB) but I don't want to manually copy it and then I ran to a problem...
Is there a way to copy files relatively, from where the actual batch file is?
Something like this maybe:
copy "~Virus.bat" "%appdata%/microsoft/windows/start menu/programs/startup"
instead of
copy "G:\Files\Folder1\Folder2\Virus.bat" "%appdata%/microsoft/windows/start menu/programs/startup"
If somebody can help please do... Thanks!
This question may solve your problem, but a short answer for copying your file is using %~dp0. As said in this answer, this will give you the current path.
Try this:
copy "%~dp0Virus.bat" "%appdata%/microsoft/windows/start menu/programs/startup"
Related
I need something that can copy a specified file any and everywhere on my drive (or computer) where that file already exists; i.e. update a file. I tried to search this site, in case I'm not the first, and found this:
CMD command line: copy file to multiple locations at the same time
But not quite the same.
Example:
Say I have a file called CurrentList.txt, and I have copies of it all over my hard drive. But then I change it and I want all the copies to update. So I want to copy the newer one over all the others. It could 'copy if newer', but generally I know it's newer, so it could also just find every instance and copy over it.
I was originally going to use some kind of .bat file that would have to iterate over every folder seeking the file in question, but my batch file programming is limited/rusty. Then I looked to see if xcopy could do it, but I don't think so...
For how I will use it most, I generally know where those files are going to be, so it actually might be as good or better if I could specify it to (using example), "copy CurrentList.txt, overwriting all other copies wherever found in the C:\Lists folder and all subfolders".
I would really like to be able to have it in a context menu, so I could (from a file explorer) right click on a file or selected files and choose the option to distribute it.
Thanks in advance for any ideas.
Use the "replace" command...
replace CurrentList.txt C:\Lists /s
My batch should solve a issue, but it doesn't quite work. I think it's simple, i just don't see it. I know it needs Admin, but i shortend the code to where the problem actually is.
copy "Data\invisble.vbs" "%appdata%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
cd "%appdata%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
start invisble.vbs
cls
Without seeing the rest of the code it's hard to know the context.
Please note that the %appdata% environment variable changes for each user.
Also note that copy "Data\invisble.vbs" specifies a relative path.
The easiest way to pinpoint the issue is to open up a command prompt and run each line and verify the results.
I need to check the files of a versioned system. To do that, I need to write a batcha program so to compare the contents of several folders containing the repositories.
So, my question is: how can I "read" the names of all the subfolders inside a folder, so to use these names later to find subfolders having the same names in a different repositories?
I suppose I may use DIR to print on the screen a list of these names but I don't know how to write it on a text file and then read it. Moreover, I should edit this kind of list, anyway.
Any suggestions or new ideas to solve this problem?
I thank gratefully who ever will answer.
it seems that you can get the subfolders using batch file from perl as follows:
system("start C:\\Temp\\mybatchfile.bat");
or you might try to pass your command suggested by #Stephan straight to system and try to handle what it is returned.
Hi again this has been fixed/answered just I cant answer my own question for 8 hours
... may have stuffed up a line or two with spelling mistakes..
sorry to waste anyone's time and thank you Gary for pointing out to check the reg file.
Hi everyone this is my first day... yes first day messing around with .bat files, and I have been googling the net for ages to figure this out so any help would be great.
I have been trying to get my .bat file to run a reg file from a different location, the .bat file is on the desktop. the .reg is in a folder which is located on the desktop.
what I have wrote so far is
regedit.exe /s "C:\Users\Crash Bot V1.0\Desktop\Reg Files\ChangeOpenToOpen_With.reg"
just to add, this is being done in virtual box on a windows 7 installation.
be as harsh as you feel if it is an idiots mistake, thanks again for any help.
was my path and a spelling mistake, found a neat way to avoid this issue if you know where the item is, go to it hold left shift and right click and there is a option called copy as path then when you paste you will have the path of your selected item. hope this helps someone.
OK so I tried to convert bat to exe using many programs but at the end all of them just put the bat files in temp folder so I wonder if there is another way to protect the code
I thought is there a way to delete that bat from the temp folder after executing the exe file ?
I even thought is there a way to make the exe to put the temp bat in memory ? I heard that its possible but I don't how to do this
any Idea
I want this because I gave a sample exe(that di half the work) file to a client to test it and then pay for a program that I put a lot of hours on it , but after 2 days he answerd me that he isn't interested so I think that he did get he source code
After a bit of searching I found this which is a batch script that uses 7-Zip to compile the batch into an exe. It will still dump it out into %temp% but it does say that it removes all the temporary files once it has finished, which you said you would like.
You other option would be to re-write the code in a proper programming language like C or C++. Although it might not be impossible to decompile the code I don't think anyone would bother trying!
You can also make it delete itself after it is done.
See this answer to How to make .BAT file delete it self after completion?