Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[BTACH] 'SET Va=St' with '& ECHO' doesn't work

Featured Replies

HI,

I'm trying to get this first command line here to work but i have no luck to get it working. :(

@ECHO OFFSET "FN=FolderName" & ECHO "%FN%"PAUSE



But on separate lines i works. :crazy:

@ECHO OFFSET "FN=FolderName"ECHO "%FN%"PAUSE

Edited by Outbreaker

Try:

@ECHO OFFSETLOCAL ENABLEEXTENSIONSSET "FN=FolderName" & ECHO "%FN%"PAUSESET FN=CALL SET "FN=FolderName" & FOR /F "Tokens=2 delims==" %%A IN ('SET FN') DO ECHO "%%A"PAUSESET FN=SETLOCAL ENABLEDELAYEDEXPANSIONSET "FN=FolderName" & ECHO "!FN!"PAUSE

;)

 

jaclaz

  • Author

The first example didn't work so i used the last one but since i need to have everything in one code line i used this code below this one should work but it doesn't. :(

CMD /Q /C V:ON SET "FM=FolderName" & ECHO "!FM!"

Edited by Outbreaker

 

The first example didn't work so i used the last one but since i need to have everything in one code line i used this code below this one should work but it doesn't. :(

CMD /Q /C V:ON SET "FM=FolderName" & ECHO "!FM!"

Well, you are in the (common BTW) issue of mis-communicating, the known xyz or the chocolate covered banana:

http://homepage.ntlworld.com./jonathan.deboynepollard/FGA/put-down-the-chocolate-covered-banana.html

 

You want to reach a goal, but you do not specify it and ask a question related to a tiny bit of what you believe to be the way to reach that goal (which may or may not the "right" way) 

 

However :) try:

CMD V:ON /Q /C "SET "FN=FolderName" &FOR /F "tokens=2 delims==" %%A IN ('SET FN') DO ECHO "%%A""

jaclaz

Am I missing something?

CMD /Q/D/C "SET "FN=FolderName"&CALL ECHO;"%FN%""

If you want to actually read the output then use either:

CMD /Q/D/K "SET "FN=FolderName"&CALL ECHO;"%FN%""

or:

CMD /Q/D/C "SET "FN=FolderName"&CALL ECHO;"%FN%"&PING -n 4 127.0.0.1>NUL"

 

Am I missing something?

 

 

 

Not yet. :w00t:

 

Till now the usual screenplay has been followed to the letter:

  1. someone asks something about batch
  2. jaclaz provides a possible solution
  3. Yzöwl provides another (often better) one :yes:

at this point normally Gunsmokingman enters the scene and posts a .vbs to the same effect of the batches/snippets posted earlier, this time since the topic seems to be "strictly" batch, this might not happen :unsure: that would be a twist to the story... ;)

 

jaclaz

Strangely, I think I really am missing something!
 
...the point!

 

Why set a variable for a fraction of a second, the sole purpose of which is to output its value to a console which would have closed before reading it?

You are not missing it :no:, it simply does not exist :w00t:, the whole point of the game, when played outside common rules, is to continuously shift the actual question towards something else at each iteration.

 

Technically ;) this is often referred to as "Ninja Point" :whistle::

motivator9839607.jpg

 

The original question made some sense, but as soon as a "normal" solution (actually two) were proposed, the question became different (having no actual practical use) and I suspect that even the modified question has very little in common with the actual goal/expected result/intended use, hence the reference to the xyz issue.

 

 

jaclaz

 

The first example didn't work so i used the last one but since i need to have everything in one code line i used this code below this one should work but it doesn't. :(

CMD /Q /C V:ON SET "FM=FolderName" & ECHO "!FM!"

Something to learn from this example.

 

The command string should follow /C or /K. Not using /C or /K immediately before the command string can expect failure.

V:ON would be an invalid parameter as a leading forward slash would be expected. CMD seems to ignore V:ON and thus delayed expansion is not turned on.

The command string has more then 2 double quotes. CMD may strip outer double quotes which may leave the command string as invalid. I would add extra outer double quotes on the command string and use the /S parameter to force CMD to strip those outer double quotes to be safe.

 

This information can be viewed by using the command CMD /? .

 

Following the information I mentioned above, I would use

CMD /S /Q /V:ON /C "SET "FM=FolderName" & ECHO "!FM!""

which tests as working.

Edited by MHz

  • Author

Interesting this one works great thanks. :thumbup

For anyone who asks themselves why i need this command here is the complete command i use. ;)

CMD /S /Q /V:ON /C "SET "EmptyFolder=%ProgramFiles%\Software\temp" & PUSHD "!EmptyFolder!" && (RMDIR "!EmptyFolder!" /S /Q 2>NUL & POPD)"

This will delete everything in a folder but will not delete the Root folder (temp).  :)

I'm only not sure if i should use the /S at the beginning or not it works with both. :ph34r:

Edited by Outbreaker

...

I'm only not sure if i should use the /S at the beginning or not it works with both. :ph34r:

Not needed in your case as the command string does not start with a double quote and end with a double quote. I saw all the double quotes and considered mentioning the /S yet after I posted I noticed that the command string begins with the command Set with double quotes coming later in the string.

 

If you do have a command string starting and ending with double quotes like (omitting the CMD /Q /C stuff being shown, rather just the command string)

"path\to\file.exe" > "path\to\logfile.log"

then CMD may strip the outer double quotes following legacy conditions. So it would be executed as

path\to\file.exe" > "path\to\logfile.log

which would fail as the redirection character is now double quoted with the white space.

 

Apologies for any confusion. You can still use the /S and use extra double quotes if you want though it is not needed with your command line shown.

Interesting this one works great thanks. :thumbup

For anyone who asks themselves why i need this command here is the complete command i use. ;)

CMD /S /Q /V:ON /C "SET "EmptyFolder=%ProgramFiles%\Software\temp" & PUSHD "!EmptyFolder!" && (RMDIR "!EmptyFolder!" /S /Q 2>NUL & POPD)"

...but you're setting a variable for no reason

 

Without changing your code at all and just removing the pointless set you've shortned the command line!

CMD /S /Q /V:ON /C "PUSHD "%ProgramFiles%\Software\temp" && (RMDIR "%ProgramFiles%\Software\temp" /S /Q 2>NUL & POPD)"

...now you could even ignore the /s and /v switches and shorten it further.

I am still failing to see the actual practical use of this command, I mean is it to be included in a batch file or - as it seems - it is intended to be typed on the command line? :unsure:

 

jaclaz

  • Author

I use this command in a .inf file. ;)

11,,cmd.exe,,,"/Q /V:ON /C ""SET ""EmptyFolder=%ProgramFiles%\Software\temp"" & PUSHD ""!EmptyFolder!"" && (RMDIR ""!EmptyFolder!"" /S /Q 2>NUL & POPD)"""

Edited by Outbreaker

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.