michaelm702
asked on
Batch File
I want to create a batch file where I need to get a path from the user and set it as my base path. There can be three paths:
1. C:\Program Files\Test Folder1
2. C:\Test Folder2
3. Other I would Like to enter
If the user selects first 2 options then the next step is that I want to set that as my base path. If the user selects 3 then the user will enter the path and we need to capture the same and set it as base path.
1. C:\Program Files\Test Folder1
2. C:\Test Folder2
3. Other I would Like to enter
If the user selects first 2 options then the next step is that I want to set that as my base path. If the user selects 3 then the user will enter the path and we need to capture the same and set it as base path.
ASKER
I tried running the code but if I choose option 3 and enter c:\program files as my path it does not accept and if i put c:\bat it accepts. I feel the program is not accepting directory names with space in between them.
Hmmm...
2008/02/08 9:57:41 C:\>ver
Microsoft Windows XP [Version 5.1.2600]
2008/02/08 9:57:42 C:\>basep
Choose our base path.
1. C:\Program Files\Test Folder1
2. C:\Test Folder2
3. Enter your own base path.
0. Quit
Choose from 1, 2 or 3 : 3
Enter your own base path : C:\Program Files
Your BasePath is C:\Program Files
2008/02/08 9:57:50 C:\>echo %BASEPATH%
C:\Program Files
2008/02/08 9:57:58 C:\>
What OS are you running?
2008/02/08 9:57:41 C:\>ver
Microsoft Windows XP [Version 5.1.2600]
2008/02/08 9:57:42 C:\>basep
Choose our base path.
1. C:\Program Files\Test Folder1
2. C:\Test Folder2
3. Enter your own base path.
0. Quit
Choose from 1, 2 or 3 : 3
Enter your own base path : C:\Program Files
Your BasePath is C:\Program Files
2008/02/08 9:57:50 C:\>echo %BASEPATH%
C:\Program Files
2008/02/08 9:57:58 C:\>
What OS are you running?
ASKER
C:\bat>call C:\Program Files\imp.exe 'C:\Program' is not recognized as an internal or external command,
operable program or batch file.'
After getting the base directory when i call a exe file in the base folder i get the error "'C:\Program' is not recognized as an internal or external command,operable program or batch file.'"
I am using widows xp professional service pack 2
operable program or batch file.'
After getting the base directory when i call a exe file in the base folder i get the error "'C:\Program' is not recognized as an internal or external command,operable program or batch file.'"
I am using widows xp professional service pack 2
As with all filenames with spaces, you need to put a pair of " around it.
CALL "%BasePath%\imp.exe"
sort of thing.
CALL "%BasePath%\imp.exe"
sort of thing.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window