Jump to content

Windows command


intergage
 Share

Recommended Posts

Hey, I'm pretty new here.

I'm just looking for a little help with a batch file my boss wants.

When we upgrade networks we need to copy a bunch of stuff off (Address book, Inbox, Etc..)

I made a simple copy batch but they got sick of the drive letter changing, so I said I would try and make one where it would ask you for the drive letter before it starts copying so they didn't have to edit the file on each computer.

I need help with the 'set' command.

I have never used it before and I'm completely clueless as to how it works.

I need just a little bit of code that will ask for user input, something like; "What is the drive letter? :" kinda thing.

So, I can call back on the variable through out the code rather then "E:\" I can use "Variable_name:\" kinda thing.

Thanks in advanced.

Link to comment
Share on other sites

Use something like this, it may need a little modding:

set /p drive= Enter drive letter: 
xcopy C:\files %drive%:\

%drive% will change based on the user's input, but be careful because you cannot use %drive% in ""

example of what would NOT work:

xcopy C:\file "%drive%:\Documents and Settings"

Link to comment
Share on other sites

  • 7 months later...

You bumped it, I'll now answer it.

To make this script completely useful use:

set "drive=%~d0"

This is saying that your using the drive that the script is running from, so you could even use this on your local computer because it'll just pick the C partition (or the one your using).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...