Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

Davidrsaa

Programmer
Jan 13, 2016
1
CO
Hi everybody!

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.

Code:
On Error Resume Next

Const PAGE_LOADED = 4

Set objIE = CreateObject("InternetExplorer.Application.1")
Call objIE.Navigate("[URL unfurl="true"]https://yourdomain.sharepoint.com")[/URL]

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: ""[URL unfurl="true"]https://yourcompany.sharepoint.com/Library[/URL] 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:

Code:
Set wShell=CreateObject("WScript.Shell")

NetCommand="net.exe use p: ""[URL unfurl="true"]https://yourcompany.sharepoint.com/Library[/URL] 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!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top