How to login in Office 365 from VBScript and browse through sharepoint with pascal script(?)

不想你离开。 提交于 2019-12-13 07:27:17

问题


I'm packing an Access application, This is connecting with a Sharepoint site. I'm using Inno Setup (With Pascal Scripts) for create an install package. So, I found this code for do something similar to that I want, when I run the code seems work fine: Open the browser, goes to Office 365, puts information (account and password), but just in the moment when open the cmd and after few seconds, all closes without finish the process.

On Error Resume Next

Const PAGE_LOADED = 4

Set objIE = CreateObject("InternetExplorer.Application.1")
Call objIE.Navigate("https://yourdomain.sharepoint.com")

objIE.Visible = True

Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(500) : Loop

objIE.Document.all.Login.Value = "username@yourdomain.com"
objIE.Document.all.Passwd.Value = "office365password"
objIE.Document.all.persist.checked=True

'The "Submit" button needs to be "clicked" twice in order to sign the user in
' * It appears that some javascript needs to take place behind the scenes to properly initiate the logon
Call objIE.Document.getElementById("cred_sign_in_button").click
Call objIE.Document.getElementById("cred_sign_in_button").click

WScript.Sleep(4000)

Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(500) : Loop

Set wShell=CreateObject("WScript.Shell")

NetCommand="net.exe use p: ""https://yourcompany.sharepoint.com/Library 1""  /user:username@yourdomain.com office365password"
wShell.Run "cmd.exe /C " & NetCommand, 1, True

Set wShell=Nothing

objIE.quit

Set objIE = Nothing

Seems to maybe can be here:

Set wShell=CreateObject("WScript.Shell")

NetCommand="net.exe use p: ""https://yourcompany.sharepoint.com/Library 1""  /user:username@yourdomain.com office365password"
wShell.Run "cmd.exe /C " & NetCommand, 1, True

My final aim is do the all process of login in the backstage (for code), create the connexion with 365 via (VBScript (?)), providing the credentials in the script, thereupon go a list in sharepoint site, title: (Serial Numbers(?)) where I Have a list with several numbers and checkboxes for to mark true in every install and avoid use the same number two times.

Thanks for advance!

来源:https://stackoverflow.com/questions/34756906/how-to-login-in-office-365-from-vbscript-and-browse-through-sharepoint-with-pasc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!