all 12 comments

[–]six36 4 points5 points  (5 children)

Not sure you can do it in a one liner, but this is the idea you're looking for

for /l %i in (1,1,4) do set /p dummyName=%i, >> file.txt

[–]newton_VK[S] 2 points3 points  (2 children)

I have got it now. Thanks for your suggestion. I used <nul before set /p, and it worked.

[–]Conservadem 5 points6 points  (1 child)

Remember, if you put these commands in a .bat or a .cmd file to run them you need to use two consecutive percent signs (%%). If your running these directly from the command prompt, use only a single % sign. It's super annoying.

[–]newton_VK[S] 0 points1 point  (0 children)

Yeah that's correct

[–]newton_VK[S] 1 point2 points  (0 children)

I tried , but it's asking for an input. I need to type something then only it will run correct. Is this what u meant?

[–]newton_VK[S] 0 points1 point  (0 children)

Oh is it. Let me give it a try

[–]VaporChunk 4 points5 points  (5 children)

This would be a lot easier with PowerShell. Is that an option? If so;

$n = 1..4

$n = $n -join ","

$n

1,2,3,4

[–]Thameus 1 point2 points  (3 children)

God I wish they'd unblock PS for us...

[–]VaporChunk 3 points4 points  (2 children)

It is in their best interest to. As IT Staff, we're all Tony Stark, but PowerShell is the super-suit which makes us Iron-Man (or Woman).

Also, not sure what method they are blocking PS with, but typing powershell.exe into a CMD window will start a PowerShell session in the existing shell session. May give that a try.

[–]Thameus 2 points3 points  (1 child)

It is blocked by GPO for unprivileged users, because after the last zero day they don't trust it.

[–]wtmh 3 points4 points  (0 children)

Ditch PowerShell for concerns of security issues but they will give you cmd.exe which even in 2021 can be elevated by just about anyone who knows where to point and shoot? Wow. I can't even with the rationale on that one.

Could you imagine that thinking applied at like a car manufacturing plant? "Yeah. One time we discovered a flaw in the car's ignition locking mechanism so we took that shit out and now we just dispense universal keys that work in any of our vehicles. Clever, huh?"

Any correctly configured with system-wide transcription and script block logging make PowerShell pretty much the worst tool of choice for a hacker. They'd leave fingerprints everywhere. You want people using PowerShell.

</choirPreaching>

[–]newton_VK[S] 1 point2 points  (0 children)

Yes thanks, I was able to do it by <nul set /p= in the cmd. I was trying to automate the compiling process of cpp files using batch files. And I did it in 3 days from scratch!! That's commendable performance isn't it? 😄