2

Is there any way to replace a space in %username% with an underscore. Within cmd.

For example:

Username: john doe

Actual Folder path for %username%: john_doe

    NET USE Z: \\server\folder\%username%\ /P:Yes
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Cerebus
  • 21
  • 3

1 Answers1

3
set "newusername=%username: =_%"

creates a new variable with the space replaced.

Magoo
  • 77,302
  • 8
  • 62
  • 84