![]() |
|
[Shell] Loops - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Shell] Loops (/showthread.php?tid=4727315) |
Loops - Deevez - Mar 12, 2015 Hello! So I was making a batch file last night, and had a quick thought. Within the code for a loop ":label code code code goto label" It is an infinite loops. But is there a way, or is it even possible to, make the loop happen a certain amount of times? Let's say I want to open three .txt's. I understand I can do "start notepad.exe" three times, but is it at all realistic to make a loop, that opens it once, happen three times, then end? Thanks to anything helpful. * - Ventriloquism - Mar 12, 2015 If I think I'm understanding you correctly, try this :) Code @echo offThe previous code was with user inputs...but if you want to do it automatically use this one: Code @echo offLet me know if you need me to explain anything 🤝 * - Deevez - Mar 12, 2015 Quote: That's exactly what I'm looking for. Works perfectly. Thank you a bunch! * - Ventriloquism - Mar 12, 2015 (Mar 12, 2015 10:37 AM)Deevez Wrote: That's exactly what I'm looking for. Works perfectly. Thank you a bunch! Hey no problem. Let me know if you need anything else 🎉 * - Deevez - Mar 12, 2015 (Mar 12, 2015 10:40 AM)WhoHacksAnymore Wrote: Hey no problem. Let me know if you need anything else 🎉 There is one thing I guess I could I ask. I've seen this done on a Console App. Now, I say "Console App" because I'm unsure if this was even in Batch or if it was made in VB or something. But this one program, upon the command on "stats", it told you all of your computer's stats, such as: CPU usage, RAM, and stuff like that. Do you by any chance know if that also is possible? * - WOLGA - Mar 12, 2015 (Mar 12, 2015 11:23 AM)Deevez Wrote: There is one thing I guess I could I ask. I've seen this done on a Console App. Now, I say "Console App" because I'm unsure if this was even in Batch or if it was made in VB or something. But this one program, upon the command on "stats", it told you all of your computer's stats, such as: CPU usage, RAM, and stuff like that. Do you by any chance know if that also is possible? You might be looking for WMIC. Open command prompt and type in Code wmic /?That might help you get started. * - Deevez - Mar 12, 2015 Quote: I'll definitely try this out. Thanks a bunch! * - Ventriloquism - Mar 12, 2015 Yeah agreed. This looks like a job for WMIC * - Deevez - Mar 12, 2015 That helped a lot. Thanks a lot guys! * - annikk.exe - Mar 12, 2015 Another method of looping: Code @echo offAlso since nobody fully explained the wmic approach, the following commands are useful: Code wmic baseboard list briefMore types of information are available. wmic /? will show you all the different things that are available. Basically all the CAPS names, that don't start with a forward slash (/). * - Deevez - Mar 13, 2015 Always here to explain things for people, Annikk. Haha, thanks! |