topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Wednesday December 11, 2024, 5:44 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: for %%a in (*) do start "" "%%a"  (Read 12884 times)

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
for %%a in (*) do start "" "%%a"
« on: October 12, 2014, 02:55 PM »
What exactly does this line of batch code ? :

for %%a in (*) do start "" "%%a"


I don't recommend to use.
Collapse two times my system.

 :-[

lujomu

  • Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 40
    • View Profile
    • Donate to Member
Re: for %%a in (*) do start "" "%%a"
« Reply #1 on: October 12, 2014, 04:41 PM »
It launches EVERY file and folder in the current directory.
I.e. it runs every executable or script files, opens every other file in its respective app and opens an explorer window for every folder.

A little trick to identify what a loop actually does is to insert the word "echo" after "do". This will print out each command instead of executing it:
for %%a in (*) do echo start "" "%%a"

Hope that helps!

KynloStephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,761
    • View Profile
    • Donate to Member
Re: for %%a in (*) do start "" "%%a"
« Reply #2 on: October 12, 2014, 04:45 PM »
What exactly does this line of batch code ? :

for %%a in (*) do start "" "%%a"


I don't recommend to use.
Collapse two times my system.

 :-[

So you ran a batch file that you didn't have clue what it did?    Seems like a totally reasonable and safe things to do...lmao

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: for %%a in (*) do start "" "%%a"
« Reply #3 on: October 12, 2014, 05:18 PM »
It launches EVERY file and folder in the current directory.
I.e. it runs every executable or script files, opens every other file in its respective app and opens an explorer window for every folder.

A little trick to identify what a loop actually does is to insert the word "echo" after "do". This will print out each command instead of executing it:
for %%a in (*) do echo start "" "%%a"

Hope that helps!


But really don't go.
I try and collapse also with an execution from a folder containing eight urls and collapsed.


Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: for %%a in (*) do start "" "%%a"
« Reply #4 on: October 12, 2014, 05:37 PM »
Ejem I tried because comes in a forum for years i use, but not always
What exactly does this line of batch code ? :

for %%a in (*) do start "" "%%a"


I don't recommend to use.
Collapse two times my system.

 :-[

So you ran a batch file that you didn't have clue what it did?    Seems like a totally reasonable and safe things to do...lmao

I try because was posted in a forum i visit several years ago....

 :-[

Edvard

  • Coding Snacks Author
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 3,022
    • View Profile
    • Donate to Member
Re: for %%a in (*) do start "" "%%a"
« Reply #5 on: October 13, 2014, 08:44 PM »
 :nono2:

The best advice ever when running random code posted in a forum, is exactly as Stephen alluded to:
NEVER run code that you don't know what it is going to do.  Perhaps you wanted to run this script because you saw it as a batch-bomb of sorts, and wanted to look into how to prevent it from crashing your system.  But not knowing?... just don't do it.

For example, DON'T run this:
:s
 start "" %0
 goto s
or this:
%0|%0
until you know what it does, and how to stop it.  And now that you've seen the code, you'll be able to spot it in the wild.
You're welcome.

Vurbal

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 653
  • Mostly harmless
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: for %%a in (*) do start "" "%%a"
« Reply #6 on: October 13, 2014, 09:14 PM »
:nono2:

The best advice ever when running random code posted in a forum, is exactly as Stephen alluded to:
NEVER run code that you don't know what it is going to do.  Perhaps you wanted to run this script because you saw it as a batch-bomb of sorts, and wanted to look into how to prevent it from crashing your system.  But not knowing?... just don't do it.


At the very least run it in a vm. I can understand if you're the type of person who needs to see something in action to understand it. Given that it's both easy and free to do it safely, when somebody who ought to know better chooses to play Russian roulette, I have to think they're getting what they deserve.

I learned to say the pledge of allegiance
Before they beat me bloody down at the station
They haven't got a word out of me since
I got a billion years probation
- The MC5

Follow the path of the unsafe, independent thinker. Expose your ideas to the danger of controversy. Speak your mind and fear less the label of ''crackpot'' than the stigma of conformity.
- Thomas J. Watson, Sr

It's not rocket surgery.
- Me


I recommend reading through my Bio before responding to any of my posts. It could save both of us a lot of time and frustration.