Computing.Net > Forums > Programming > Batch File Input Shortcuts

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File Input Shortcuts

Reply to Message Icon

Name: jcgun
Date: April 1, 2009 at 10:27:21 Pacific
OS: Windows Vista
Subcategory: Batch
Comment:

In a batch file, i want the user to input a directory to save a file.
however, i want an option to input '#' and the directory of the batch file will be selected (using %~dp0).

i don't know how to make it so that by typing in #, it will do it.

Here is what i have so far:

:startup
title Network Users

:1
cls
@echo off
Echo This Batch File allows you to save any Command from Command Prompt
Echo as a text file.
Echo It even allows you to choose where you save it, and what it's called!!
ECHO.
ECHO.
set /p command= What Command would you like to save (full Command Prompt Line needed)?:

:2
cls
@echo off
Echo This Batch File allows you to save any Command from Command Prompt
Echo as a text file.
Echo It even allows you to choose where you save it, and what it's called!!
ECHO.
ECHO.
set /p where= Where would you like to save it?:

:3
cls
@echo off
Echo This Batch File allows you to save any Command from Command Prompt
Echo as a text file.
Echo It even allows you to choose where you save it, and what it's called!!
ECHO.
ECHO.
set /p name= What would you like to name it?:

:4
cls
@echo off
%command% > "%where%/%name%.txt"
goto 5

:5
cls
@echo off
Echo Thank You for Using!
Echo You file should be saved by now!
Echo Email me at jcgun@hotmail.co.uk!
ECHO.
set choice=
set /p choice=Press Enter to Exit:
if not '%choice%'=='' set choice=%choice:~0,1%
Echo.

:6
goto Crash



Sponsored Link
Ads by Google

Response Number 1
Name: reno
Date: April 2, 2009 at 01:41:43 Pacific
Reply:

what was the question?
and what is #??


0

Response Number 2
Name: Mechanix2Go
Date: April 2, 2009 at 02:32:34 Pacific
Reply:

Not clear about the intent, but to answer the question:

==================================
@echo off & setLocal EnableDelayedExpansion

set /p where=dir to put? use # for current dir
if !where! equ # set where=%CD%


=====================================
If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch File Input Shortcuts

Batch file input for logevent.exe www.computing.net/answers/programming/batch-file-input-for-logeventexe/15380.html

batch file input www.computing.net/answers/programming/batch-file-input/11258.html

Batch File|Input from txt file www.computing.net/answers/programming/batch-fileinput-from-txt-file-/17293.html