• OneDrive mapping batch-file problem?

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

    Author
    Topic
    #1877916

    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

    Viewing 19 reply threads
    Author
    Replies
    • #1877959

      What are your parameters for task?

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

      --Joe

    • #1878038

      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.

      • #1878042

        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 5 years, 10 months ago by CWBillow.
      • #1878205

        @BobbyR:

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

        Chuck Billow

    • #1878122

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

      cheers, Paul

      • #1878204

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

        Chuck Billow

    • #1878433

      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.

      Eliminate spare time: start programming PowerShell

    • #1878621

      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

      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\cwxxx@xxx.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 cwxxx@xxx.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.

      [moderator edit: munged email address]

      Chuck Billow

    • #1878630

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

      --Joe

    • #1878637

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

      Chuck Billow

    • #1878680

      Just execute your batch file.

      --Joe

      • This reply was modified 5 years, 10 months ago by joep517.
    • #1878683

      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.

      Always create a fresh drive image before making system changes/Windows updates; you may need to start over!
      We all have our own reasons for doing the things that we do with our systems; we don't need anyone's approval, and we don't all have to do the same things.
      We were all once "Average Users".

    • #1878816

      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:cwxxx@xxx.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\cwxxx@xxx.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 5 years, 10 months ago by CWBillow.
      • #1878829

        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

    • #1878839

      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

      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

      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.

      Always create a fresh drive image before making system changes/Windows updates; you may need to start over!
      We all have our own reasons for doing the things that we do with our systems; we don't need anyone's approval, and we don't all have to do the same things.
      We were all once "Average Users".

    • #1879225

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

      Chuck Billow

      • #1879405

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

        Chuck Billow

    • #1879505

      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

      Always create a fresh drive image before making system changes/Windows updates; you may need to start over!
      We all have our own reasons for doing the things that we do with our systems; we don't need anyone's approval, and we don't all have to do the same things.
      We were all once "Average Users".

      • This reply was modified 5 years, 10 months ago by bbearren.
    • #1882829

      OK, I’ll give it a shot.

      Chuck Billow

    • #1893893

      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

    • #1915316

      I think you buried the lead, CW.

      “A message box would pop up asking for my login name, which showed as “MicrosoftAccount\cwxxx@xxx.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.”

      The real question is how do you get this to reconnect using just your e-mail and not the “MicrosoftAccount\”? Seems like a SSO issue…

      It’s the same problem I’m having… so advice on how to get “MicrosoftAccount\” gone would be most welcome.

    • #1916930

      I finally gave up on auto-reconnect.  I have a batch file icon sitting on my desktop that solves the problem of connecting.

      I think it is a question of timing, where the connection cannot take place until all other startup actions are in place.  Ah well, this works fine for the most part.

      MVP Edit: Link removed as it’s in the Original Post

    Viewing 19 reply threads
    Reply To: OneDrive mapping batch-file problem?

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

    Your information: