Need a "Share This Drive" batch file

Discussion in 'Computer Support' started by DRS.Usenet@sengsational.com, Mar 9, 2005.

  1. Guest

    Okay guys, this has to be easy, but it's been so long since I used DOS
    scripts....

    I want to end-up with this being sent to the OS:
    net share aName=c:\some\dir\that\keeps\changing

    in a batch file, I know I've got "c:\some\dir\..." through the CD.

    Since I don't remember syntax or even concept, I tried:
    net share aName= | cd
    and:
    net share aName= < cd
    and:
    %cd%<cd
    net share obc=%cd%
    and:
    cd|%cd%
    net share obc=%cd%

    And I've only shown the few of them that didn't work!

    Sooooo..... WITHOUT hard-coding the path, can someone please tell me
    what the batch file would look like? Even if you had to create
    environment variables or even a little file.

    --Dale--
    , Mar 9, 2005
    #1
    1. Advertising

  2. Guest

    On 9 Mar 2005 06:26:38 -0800, wrote:

    |> Okay guys, this has to be easy, but it's been so long since I used DOS
    |> scripts....
    |>
    |> I want to end-up with this being sent to the OS:
    |> net share aName=c:\some\dir\that\keeps\changing

    Use Setx to create a variable, then using the variable with net share?

    Setx.exe is included in the NT resource kit (works under XP), and as I
    understand it you could create a path through a redirect from another
    dos command, then use setx to create a variable from that path.

    --
    , Mar 9, 2005
    #2
    1. Advertising

  3. °Mike° Guest

    Try:

    @ECHO OFF
    NET SHARE aName=%1 /Y>nul

    and call the batch file with the directory as a parameter.
    Eg., if you named the batch file sharedrive.bat, use:

    sharedrive "c:\some\dir\that\keeps\changing"


    On 9 Mar 2005 06:26:38 -0800, in
    <>
    scrawled:

    >Okay guys, this has to be easy, but it's been so long since I used DOS
    >scripts....
    >
    >I want to end-up with this being sent to the OS:
    >net share aName=c:\some\dir\that\keeps\changing
    >
    >in a batch file, I know I've got "c:\some\dir\..." through the CD.
    >
    >Since I don't remember syntax or even concept, I tried:
    >net share aName= | cd
    >and:
    >net share aName= < cd
    >and:
    >%cd%<cd
    >net share obc=%cd%
    >and:
    >cd|%cd%
    >net share obc=%cd%
    >
    >And I've only shown the few of them that didn't work!
    >
    >Sooooo..... WITHOUT hard-coding the path, can someone please tell me
    >what the batch file would look like? Even if you had to create
    >environment variables or even a little file.
    >
    >--Dale--


    --
    Basic computer maintenance
    http://uk.geocities.com/personel44/maintenance.html
    °Mike°, Mar 9, 2005
    #3
  4. Guest

    °Mike° wrote:
    > Try:
    >
    > @ECHO OFF
    > NET SHARE aName=%1 /Y>nul
    >
    > and call the batch file with the directory as a parameter.
    > Eg., if you named the batch file sharedrive.bat, use:
    >
    > sharedrive "c:\some\dir\that\keeps\changing"


    Thanks for the idea Mike, but that's not exactly what I'm looking for.
    Looking back on my post, it's not really obvious, but CD / current
    directory is really the crux of it.

    I didn't want to type the path... that was the whole problem. The path
    literally traverses the entire screen, starting from c:> on the left.
    The chances of typing that right are about nill, and I didn't want to
    fiddle around with finding something in the temp folder and doing the
    copy paste thing. The background is that this batch file would be
    deployed (copied) to various temp folders while a program is active in
    that temp folder. I wanted to be able to just drop into the temp
    folder dejure (one end of the wormhole is stable, and I could reach it
    using explorer), double click the batch file, then have all of my
    programs that use that specific share name work.

    The need actually passed by putting the main thing I needed consistent
    access to up at a stable bit of directory structure... so urgency
    deminished. But I'll remember to try setx.exe if the need arises
    again.

    --Dale--
    , Mar 17, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gerard Bok

    Re: Ability to send an email message from within a batch file

    Gerard Bok, Sep 8, 2004, in forum: Microsoft Certification
    Replies:
    0
    Views:
    576
    Gerard Bok
    Sep 8, 2004
  2. BatchFile Bob

    Batch File Delete?

    BatchFile Bob, Jun 18, 2004, in forum: MCSE
    Replies:
    4
    Views:
    6,602
    adamavich
    Aug 1, 2006
  3. Gavin
    Replies:
    4
    Views:
    8,513
  4. Tom

    Batch File - Renaming File with DATE

    Tom, Mar 3, 2007, in forum: Computer Support
    Replies:
    11
    Views:
    7,811
  5. lbbss

    Batch file to backup one Doc file?

    lbbss, Mar 23, 2010, in forum: Computer Support
    Replies:
    10
    Views:
    515
    sandy58
    Mar 23, 2010
Loading...

Share This Page