Computing.Net > Forums > Programming > Adding Var to Batch file

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.

Adding Var to Batch file

Reply to Message Icon

Name: AJ (by William Jimenez)
Date: October 17, 2008 at 07:14:00 Pacific
OS: Windows XP
CPU/Ram: P Dual core
Product: Dell
Comment:

Hello, I have created a batch file that amongst other things allows my users to backup up all of their My Docs to an external hard drive.

The process is a two fold. 1. there is an install.bat which copies some support files to the system32 folder, copies the actuall backup.bat to the C: drive and crates a shortcut on their desktop, it also creates folders on the external drive which will be used by the backup.bat

My problem is that I don't know which letter drive the external drive is going to be!!

I've already set a variable for the letter drive but I have to hard code it (set drive=G )So what I would like to do is somehow ask the user what letter their external drive is and then use that to go in to my backup.bat and replace my G in this case for whatever their input is.

HELP!!

Thanks in advance.

AJ



Sponsored Link
Ads by Google

Response Number 1
Name: jason.m
Date: October 17, 2008 at 07:40:47 Pacific
Reply:

Try using %~n1, This should set the variable to the first argument passed on the command line. So for your example you'd use:

Install.bat G:\

Got a problem? give www.support.com a try


0

Response Number 2
Name: klint
Date: October 17, 2008 at 07:53:48 Pacific
Reply:

set /p drive=What drive letter is your backup drive?


0

Response Number 3
Name: AJ (by William Jimenez)
Date: October 17, 2008 at 08:06:30 Pacific
Reply:

Thank you both!!

Set /P is exactly what I was looking for. :-)


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: Adding Var to Batch file

passin g parameter to batch file www.computing.net/answers/programming/passin-g-parameter-to-batch-file-/15909.html

adding keywords to jpg files? www.computing.net/answers/programming/adding-keywords-to-jpg-files/14591.html

batch file to set in schedule task www.computing.net/answers/programming/batch-file-to-set-in-schedule-task/14751.html