PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, August 19, 2022

[FIXED] Why is no string output with 'echo %var%' after using 'set var = text' command in cmd?

 August 19, 2022     batch-file, cmd, environment-variables     No comments   

Issue

I set a variable in cmd with the set command, and tried to echo it.

Here is an example:

C:\Users\Logan>set var = text

C:\Users\Logan>set var
var = text

C:\Users\Logan>echo %var%
%var%

C:\Users\Logan>

Is there a way to force the cmd to echo the variable and not the raw text?


Solution

You need to remove whitespace before and after =:

set "var=text"
echo %var%
text


Answered By - CrYoSoRe
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing