question

kylesmyth-3022 avatar image
0 Votes"
kylesmyth-3022 asked cooldadtx answered

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

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

cooldadtx avatar image
0 Votes"
cooldadtx answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.