VBScript file must Read/Write a .txt file by calling the file by URL.

kyle smyth 1 Reputation point
2022-05-16T13:27:24.177+00:00

Hi everyone,

So I have my Main.vbs file on local pc and
Slave.txt that is saved on OneDrive.

  1. Main.vbs must access Slave.txt by using URL,
  2. Read contents.
  3. Write Values.
  4. Save Slave.txt
  5. And update Local Slave.tmp file.

If there is any suggestion on how to do this please, I would be grateful.

Windows 10 Network
Windows 10 Network
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Network: A group of devices that communicate either wirelessly or via a physical connection.
2,271 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 47,966 Reputation points
    2022-05-16T14:00:56.787+00:00

    You cannot write to a file via a URL. You can read the file if it was exposed via a URL. To write to a file the host web server would need to expose an endpoint allowing write access (generally via POST) and you'd have to pass the appropriate data.

    To talk with OneDrive without using the local filesystem copy you'll have to make REST calls. The API is documented here for reading a file and here for updating a file.

    VBScript doesn't support REST directly so you'll have to create and use an instance of Microsoft.XMLHTTP. Unfortunately the code isn't trivial. Here's a link to some starter code. You'll need to replace the actual logic with the URL and data required as documented in the links given earlier.

    0 comments No comments