Home / Software / Computer programming / How to store a user input as a variable?
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: How to store a user input as a variable?  (Read 425 times)
PPowerHouseK
Guest
« on: November 21, 2009, 09:09:55 AM »

Hello all,

I have returned with yet another batch problem. I need to ask the user to "enter their name" which I can then store as a %user% variable to later implement in a command.

For example after the user inputs the name, the program can then do:
Code: [Select]
cd C:\programfiles\uniquenames\%user%\home
So, I have no idea where to begin. Thanks in advance.
« Last Edit: November 21, 2009, 09:59:09 AM by PPowerHouseK » IP logged
Linux711
Adviser



Thanked: 43
Posts: 814

Certifications: List
Computer: Specs
Experience: Experienced
OS: Windows XP

Programming Blog 1
« Reply #1 on: November 21, 2009, 01:15:08 PM »

Code: [Select]
set /p user=Name:

cd C:\programfiles\uniquenames\%user%\home

I think you may have to use "%user%" (with quotes) if there are spaces, not sure.
IP logged

YouTube

"Genius is persistence, not brain power." - Me

"The pointer of a programmer is null; something must set it to love" - Me

PPowerHouseK
Guest
« Reply #2 on: November 21, 2009, 02:52:58 PM »

That was exactly what I was looking for. You have saved me so much time!

Thanks again for all the help! ;D
IP logged
Pages: [1] - (Top) Print 
Home / Software / Computer programming / How to store a user input as a variable? « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.064 seconds with 20 queries.