News, tips, advice, support for Windows, Office, PCs & more. Tech help. No bull. We're community supported by donations from our Plus Members, and proud of it
Home icon Home icon Home icon Email icon RSS icon
  • OneDrive mapping batch-file problem?

    Posted on CWBillow Comment on the AskWoody Lounge

    Home Forums AskWoody support Windows Windows 10 Questions: Win10 OneDrive mapping batch-file problem?

    This topic contains 23 replies, has 7 voices, and was last updated by  CWBillow 2 weeks, 6 days ago.

    • Author
      Posts
    • #1877916 Reply

      CWBillow
      AskWoody Plus

      I want to map “O” to my OneDrive.

      I can do it fine if I use a batch file:
      net use o: https://d.docs.live.net/0D0CE3E008CF73CA /user:emailaccountname@emailaddress.com XXXXXXXXXXXXXXX (Password)
      (Single line in the bat file) that I execute from the desktop.

      So why, if I put it in my startup folder, does it NOT fully complete?  “My Computer” shows the drive letter, but not connected.

      I tried it running in my startup, and I tried it mapping it via My Computer / Map Network Drive.

      Neither worked — but again, the batch file executed by itself, does work.

      What is the deal here?

      Chuck Billow

    • #1877959 Reply

      joep517
      AskWoody MVP

      What are your parameters for task?

      The general tab. The triggers tab. The action tab.

      --Joe

    • #1878038 Reply

      BobbyB
      AskWoody Lounger

      Well if your Batch file works as you say then you could try GPOL on Win 7-10 Pro Versions and above and use as below.
      one-drive-batch-file-start-GPOL-20-07-19
      Otherwise use Windows Task Scheduler and point to the same Batch file either use at Logon or at start up to suit both have minimal impact on start up times, unlike One drive its self and if you don’t need it right away use 1 -15 mins delay with Sched. Task.
      I normally map One Drive as a network drive either as a desktop shortcut or network Drive but probably as you have found out it does not open right away needs a click or two when I need it.

      Attachments:
      • #1878042 Reply

        CWBillow
        AskWoody Plus

        Joe, I’m not really sure what you are asking.  That (single) line is a batch file that is part of my login script:

        net use o: https://d.docs.live.net/0D0CE3E008CF73CA /user:emailaccountname@emailaddress.com XXXXXXXXXXXXXXX (Password)

        Why would it work when executed from the desktop, but the very same file NOT work as part of my login?

        It is executed without any additional triggers or parameters.

        Chuck Billow

        • This reply was modified 3 weeks, 6 days ago by  CWBillow.
      • #1878205 Reply

        CWBillow
        AskWoody Plus

        @BobbyR:

        I tried the task Scheduler, but without any delay.  You may well be correct.  I’ll give that a shot.

        Chuck Billow

    • #1878122 Reply

      Paul T
      AskWoody MVP

      Maybe it runs before your user is fully initialised, so the mapping is lost.
      Does Event Viewer have any clues?

      cheers, Paul

      • #1878204 Reply

        CWBillow
        AskWoody Plus

        Paul, there’s a ton of stuff there, and nothing that jumps right out at me.

        Chuck Billow

    • #1878433 Reply

      access-mdb
      AskWoody MVP

      Have you seen this website? It seems to say you can reconnect at sign in so you don’t need your batch file. Other pages using “mapping drives to OneDrive” to Google have similar advice.

    • #1878621 Reply

      CWBillow
      AskWoody Plus

      access-mdb et al;

      They all say or outline the same procedures, but to no avail.

      Whether I do it as an assigned drive leter via My Computer, or run it as a batch file or vbs command at startup, the same result each time — while still, if I just double-click the vbs on the desktop, it connects right up.

      On another note, but sort of the same thing, any time I start up, all my startup processes run, but the one, to remove the “Safely remove hardware…”, only works some of the time.  So, it would seem that Paul’s theory is closest to on the mark.

      Oh well…  Thanks anyway guys.

      Chuck Billow

    • #1878629 Reply

      CWBillow
      AskWoody Plus

      BTW, I tried running the task with a delay, to no avail.  Also, sometimes when it starts up I get a Microsoft Security message box asking for login data.  The box will show

      MicrosoftAccount\cwbillow@componentics.com as the user,

      with my password below.

      If I just clik the login again, it does not work.  If, however, I delete the “MicrosotAccount\” and just use the cwbillow@componentics.com, it then logs in.

      But even if I tell it to save the login info, it doesn’t and the same thing will happen again.

      Chuck Billow

    • #1878630 Reply

      joep517
      AskWoody MVP

      Sorry Chuck. I misread your original post. Try setting up a task that executes your batch file when a user logs on.

      --Joe

    • #1878637 Reply

      CWBillow
      AskWoody Plus

      Joe, can I use “just” the vbs script by itself?

      Chuck Billow

    • #1878680 Reply

      joep517
      AskWoody MVP

      Just execute your batch file.

      --Joe

      • This reply was modified 3 weeks, 5 days ago by  joep517.
    • #1878683 Reply

      bbearren
      AskWoody MVP

      Chuck, I’m not quite sure what you’re trying to do here, but I can explain what I’ve done, and that might work for you.  I moved my OneDrive folder to a different drive.  Follow the directions in the link.  Once that is accomplished, OneDrive acts and functions just like it does in the default location.

      To add My Documents to the OneDrive folder, I use Task Scheduler running a Robocopy script daily.  Mine is C:\Windows\System32\Robocopy.exe V:\Users\bbearren\Documents W:\OneDrive\Documents /MIR /XJD /R:1 /W:1 /MT:64 /NP /LOG:V:\Users\bbearren\Desktop\DocumentsCopy.log

      It may seem like the long way around, but it works for me, and OneDrive signs on all by itself and updates without any intervention on my part.  And the log file on my desktop lets me know that everything is working as intended.

      Create a fresh drive image before making system changes, in case you need to start over!
      "The problem is not the problem. The problem is your attitude about the problem. Savvy?"—Captain Jack Sparrow
      "When you're troubleshooting, start with the simple and proceed to the complex."—M.O. Johns

      "Experience is what you get when you're looking for something else."—Sir Thomas Robert Deware

    • #1878816 Reply

      CWBillow
      AskWoody Plus

      bbearren, I admire your work in the link. What I am trying to accomplish though is a good bit simpler:

      I want to map my OneDrive internet folder to a letter — “O.”

      I have been able to do this via a batch file / VBScript residing on my desktop. The VB is simply

      Dim WShell
      Set WShell = CreateObject(“WScript.Shell”)
      WShell.Run “C:\Map-O.bat”, 0
      Set WShell = Nothing

      and the bat file is two lines:

      net use o: https://d.docs.live.net/0D0CE3E008CF73CA /user:cwbillow@componentics.com XXXXXXXXXX
      timeout 15

      of course the XXXXXXXXXX is my OneDrive password, and all is on one line, with the timeout as line two.

      Once those / that was working, I tried to have it as part of my login. Didn’t work.

      A message box would pop up asking for my login name, which showed as “MicrosoftAccount\cwbillow@componentics.com, and my password. Inoutting just my password failed, and I had to erase the MicrosoftAccount\ from the username — why this happens I have no idea, although this username is a Microsoft account.

      I have tried mapping through My Computer, which works but doesn’t “stick” after reboot or logout, no mater that I do or Ddo not select various options (lg in as different user etc,).

      I have tried adding the vbscript/bat file to my login. Nada.

      I have tried setting up a task. No go.

      Perhaps this shouldn’t matter so much, especially since running the file(s) right from my desktop works.

      But that is exactly why it does matter (to me).

      I had it working fine on my old laptop (also an HP). Not now.

      I cannot help but wonder if it isn’t some glitch or change post-Windows update that isn’t accounted for here.

      Yet at the same time I cannot believe I am the one and only user of the millions out there that wants to or has tried this.

      Anyhow, for now I just sit seething in my frustration.

      Chuck Billow

      • This reply was modified 3 weeks, 5 days ago by  CWBillow.
      • #1878829 Reply

        PKCano
        Da Boss

        I don’t mean to ask a dumb question, but……

        I have always set up my remote drives using File Explorer.
        In the menu, “Map network drive”.
        You can assign a drive letter from the pulldown.
        Folder would be the https://d.docs…..
        You can connect using different credentials (which would be the OneDrive ID and pwd)
        You can choose to reconnect at login
        There is even a wizard to help if you need it.

        Does this not work?

        Screen-Shot-2019-07-21-at-7.07.04-PM

        Attachments:
    • #1878839 Reply

      CWBillow
      AskWoody Plus

      No, that (directly via My Computer (File Explorer) then Computer / Map network Drive is how I tried to do it.  Doesn’t stick.

      Chuck Billow

    • #1879120 Reply

      joep517
      AskWoody MVP

      What settings did you use on the task when you set it up? How about exporting the task, save it somewhere, change the extension to txt, upload it here as part of a response.

      --Joe

    • #1879121 Reply

      bbearren
      AskWoody MVP

      I want to map my OneDrive internet folder to a letter — “O.”

      I have my OneDrive internet folder mapped to a letter — “W”.

      I’m getting what you want, but not using any scripting to do it.  All I do is sign in to Windows; OneDrive does all the rest.  And it sticks.

      Create a fresh drive image before making system changes, in case you need to start over!
      "The problem is not the problem. The problem is your attitude about the problem. Savvy?"—Captain Jack Sparrow
      "When you're troubleshooting, start with the simple and proceed to the complex."—M.O. Johns

      "Experience is what you get when you're looking for something else."—Sir Thomas Robert Deware

    • #1879225 Reply

      CWBillow
      AskWoody Plus

      So what the heck am I doing wrong?  Does it have anything to do with the sign-on discrepancies?

      Chuck Billow

      • #1879405 Reply

        CWBillow
        AskWoody Plus

        So, OK, bbearren, what are you doing right that I am doing wrong?

        Chuck Billow

    • #1879505 Reply

      bbearren
      AskWoody MVP

      So, OK, bbearren, what are you doing right that I am doing wrong?

      In order to move the folder, you need to unlink it first.  Follow all these instructions carefully, step-by-step.  You don’t need to add anything to your PC sign-in.  After you finish setting it up, OneDrive will start with Windows, and use your credentials to sign itself in.

      It may ask you to sign in with your Microsoft account the first time, but after that it will sign in automatically.

      HTH

      Create a fresh drive image before making system changes, in case you need to start over!
      "The problem is not the problem. The problem is your attitude about the problem. Savvy?"—Captain Jack Sparrow
      "When you're troubleshooting, start with the simple and proceed to the complex."—M.O. Johns

      "Experience is what you get when you're looking for something else."—Sir Thomas Robert Deware

      • This reply was modified 3 weeks, 5 days ago by  bbearren.
    • #1882829 Reply

      CWBillow
      AskWoody Plus

      OK, I’ll give it a shot.

      Chuck Billow

    • #1893893 Reply

      CWBillow
      AskWoody Plus

      Bbearren, since all I was trying to do was to map “O” to the network drive, and not change its location, I’ll just keep using the batch file on demand, since for whatever reason it is refusing to work at login.

      Thanks through.

      Chuck Billow

    Please follow the -Lounge Rules- no personal attacks, no swearing, and politics/religion are relegated to the Rants forum.

    Reply To: OneDrive mapping batch-file problem?

    You can use BBCodes to format your content.
    Your account can't use Advanced BBCodes, they will be stripped before saving.