Windows 10: String with spaces in set /p (batch file)

Discus and support String with spaces in set /p (batch file) in Windows 10 Software and Apps to solve the problem; Hi! I would like to let a user type in things with spaces in set /p. This is the code I currently have that does not work: Code: :newdoc2 cls echo... Discussion in 'Windows 10 Software and Apps' started by evantig, May 10, 2016.

  1. evantig Win User

    String with spaces in set /p (batch file)


    Hi! I would like to let a user type in things with spaces in set /p. This is the code I currently have that does not work:

    Code: :newdoc2 cls echo What do you want to say? set saynew=%randomnum% set /p saynew= if %saynew% == %randomnum% goto newdoc2 echo "%saynew%" >%namenew% goto start[/quote] This works if saynew has no spaces, but not if it does. If I type, for example, "hello people", it will briefly say "hello was not expected at this time" and then crash. What did I do wrong? I tried putting "" around %saynew%:

    Code: echo "%saynew%" >%namenew%[/quote] but it did not work. Any ideas?

    :)
     
    evantig, May 10, 2016
    #1
  2. JipéJIPE Win User

    My file explorer user name is not compatible with the task scheduler

    I reinstalled Windows 10 to my PC with my original USB key received and after that it was automatically upgraded with the V1709 version.

    At the question "Who will use this computer", I unfortunately answered with my full name which is something like: J-P. myname (with a space before myname)

    The result is the following in the file explorer:

    C:\Users\J-P. myname and this seemed ok at that time.

    After having reinstalled all my programs and data's, everything worked fine till I created a batch file that will be launched through a task in Task Scheduler.

    The action was to start a program (batch file) located in: C:\Users\J-P. myname\Documents\mybatchfile.ffs_batch

    The task scheduler has a problem to find that batch file and blocks due to the space between the dot (.) and myname.

    The only solution I've found is to move my batch file to c:\ and it works correctly with that, but I don't like this solution.

    Thanks in advance to give me a good idea to solve that.
     
    JipéJIPE, May 10, 2016
    #2
  3. llych Win User
    E70 Bluetooth Conection with Volvo S80

    Another syntax error- if there are spaces between string of contact number, eg. +65 1234567 it will not be sent to the phonebook. Where batch of contacts were marked, conforming contacts will be sent successfully.
     
    llych, May 10, 2016
    #3
  4. evantig Win User

    String with spaces in set /p (batch file)

    If you need the whole thing, here it is:

    Code: @echo off title Text Reader color 17 goto start set randomnum=%random% :start cls title Text Reader echo Type the location of the file and the filename. Type "end" to close, or type "new" to make a new document. set /p file= if %file% == new goto newdoc if %file% == end goto end if not exist %file% goto start goto main :main cls title %file% type %file% echo. echo (End of Document) echo Press any key to go back to start... pause >nul goto start :newdoc cls title New Document echo Type a name, and location if necessary. set namenew=0 set /p namenew= if %namenew% == 0 goto newdoc :newdoc2 cls echo What do you want to say? set saynew=%randomnum% set /p saynew= if %saynew% == %randomnum% goto newdoc2 echo "%saynew%" >%namenew% goto start :end exit[/quote]
     
    evantig, May 10, 2016
    #4
Thema:

String with spaces in set /p (batch file)

Loading...
  1. String with spaces in set /p (batch file) - Similar Threads - String spaces set

  2. Batch File

    in Windows 10 Software and Apps
    Batch File: Hi, I am trying to create a batch file to determine whether a user account is signed on.I don't have enough experience to get it to @Echo it worked. Any advice please.Batch file:REM Query whether user SBackup is active@echo onsetlocal enabledelayedexpansionset...
  3. Batch Files

    in Windows 10 Gaming
    Batch Files: How do i make it that my batch file puts itself in to startup https://answers.microsoft.com/en-us/windows/forum/all/batch-files/6156404d-20d4-4f58-bee5-14629dbf7b10
  4. Batch Files

    in Windows 10 Software and Apps
    Batch Files: How do i make it that my batch file puts itself in to startup https://answers.microsoft.com/en-us/windows/forum/all/batch-files/6156404d-20d4-4f58-bee5-14629dbf7b10
  5. Batch Files

    in Windows 10 Network and Sharing
    Batch Files: How do i make it that my batch file puts itself in to startup https://answers.microsoft.com/en-us/windows/forum/all/batch-files/6156404d-20d4-4f58-bee5-14629dbf7b10
  6. Create batch files with Batch?

    in Windows 10 Software and Apps
    Create batch files with Batch?: How to create Batch and VBS files with Batch? So I write a batch file which I then convert to exe that creates new folders in a certain directory and then creates batch and VBS files with a certain content and saves them in the created folder. So it's similar to a program...
  7. Batch File

    in Windows 10 Support
    Batch File: I need a batch file to create a folder with sub folders. The sub folders will be named the current date, they will go in a folder on c drive. For example we can call the folder test and it would be in documents on c drive. Every time we run the batch file it would create a...
  8. string space corrupt

    in Windows 10 BSOD Crashes and Debugging
    string space corrupt: When using QB45 in DosBox I get "string space corrupt" How can I fix this error? https://answers.microsoft.com/en-us/windows/forum/all/string-space-corrupt/9d5f7853-617c-4ff5-96b7-968c439aabc8
  9. Deleting Lines in a Text File Given Strings From Another File Using Set-String (Powershell)

    in AntiVirus, Firewalls and System Security
    Deleting Lines in a Text File Given Strings From Another File Using Set-String (Powershell): Basically what's happening is that I have two files, one with a list of allowed users and another list of users that are actually on the desktop. What I'm trying to do is use a for loop to grab each name in the AllowedUsers.txt file, and use Select-String to find any names...
  10. Batch Program that Sends Hex String to Serial Port

    in Windows 10 Network and Sharing
    Batch Program that Sends Hex String to Serial Port: Hello, I am trying to create a simple batch program that will send a hex code (0xF5 0x00 0x01 0x02 0x02 0x01 0x06) out of COM1 at 9600 baud 8 bits No Parity 1 stop. I have tried to search up some methods already with no success. I have been able to send this code successfully...

Users found this page by searching for:

  1. set string with spaces in batch file