Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Batch to save command in same directory

Hello Guys, great Forum!

I have a (i guess) easy question which is pretty hard for me to solve.

I want to use the Batch command "TASKLIST" to save the Tasklist to a USB Drive.

the Problem is:

If I use the command -> tasklist>C:\list.txt it will save the Tasklist to C:\list.txt

but i want to use the Batch on a USB drive, and if the guy puts in the USB drive (He is a little dumb) i want the batchfile to be saved automatically to the USB drive, but i dont know which Letter the USB drive get (i.e. E: or F: or D:)

how can i force the Batchfile on the USB to save the list.txt directly on the USB? Is there any possibility?
If the batch script run from USB drive then below command saves the text file to USB drive and folder batch script executed from.



Code
@Echo Off & Cls
Tasklist > list.txt

Below command ask you to enter the USB drive letter and saves the text fie to USB drive

Code
@Echo Off
:Start
Cls
@Echo.
@Echo.
@Echo Please Enter the USB Drive Letter. (X) & Set /p DriveLetter=^>
If "%DriveLetter%"=="" Goto :Start
Tasklist > %DriveLetter:~0,1%:\List.txt
(Mar 17, 2016 06:33 PM)Freebooter Wrote:  If the batch script run from USB drive then below command saves the text file to USB drive and folder batch script executed from.



Code
@Echo Off & Cls
Tasklist > list.txt

Below command ask you to enter the USB drive letter and saves the text fie to USB drive

unfortunately it dont save anything, the command seems to need a directory and thats the problem (tested WIN10)
(Mar 18, 2016 01:30 AM)FULLAUTO Wrote:  unfortunately it dont save anything, the command seems to need a directory and thats the problem (tested WIN10)
Copy the batch file to USB drive and execute the batch file from USB drive. Batch script works if you follow my instructions. I also tested on Windows 10 and batch script will run on almost all version of Windows O/S. I'm sorry i should have ask earlier do you know how to create a batch file? One second i just notice one command i should have add to batch script try below commands.

Code
@Echo Off & Cls
Cd %~dp0
Tasklist > List.txt
(Mar 18, 2016 02:17 AM)Freebooter Wrote:  Copy the batch file to USB drive and execute the batch file from USB drive. Batch script works if you follow my instructions. I also tested on Windows 10 and batch script will run on almost all version of Windows O/S. I'm sorry i should have ask earlier do you know how to create a batch file? One second i just notice one command i should have add to batch script try below commands.

Code
@Echo Off & Cls
Cd %~dp0
Tasklist > List.txt


I know how to use batches and bitches

your second command works fine and as i want it to work... thanks for your time and the very simple solution 🤝🤝🤝🤝
(Mar 18, 2016 02:38 AM)FULLAUTO Wrote:  I know how to use batches and bitches

your second command works fine and as i want it to work... thanks for your time and the very simple solution 🤝🤝🤝🤝
You are very welcome, happy to help you out.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by NarrateDec 25, 2015 02:52 AM 4 184 Dec 25, 2015 02:52 AM
Last Post: Author
by ENGR.OSMONDSep 5, 2011 12:23 PM 1 62 Sep 5, 2011 12:23 PM
Last Post: TickTockMan