views:

357

answers:

3

I want to be able to run VBScript or JScript on a server using cscript.exe to manipulate SharePoint through the object model.

For example, to update the log file location:

Microsoft.SharePoint.Administration.SPDiagnosticsService serv = new Microsoft.SharePoint.Administration.SPDiagnosticsService();
serv.LogLocation = @"E:\";
serv.Update();

Is it possible to do this?

I know I would need to run this code using a farm admin account. I don't have access to PowerShell (yet), and I don't want to have to compile dozens of small command line utilities to get this done, either.

A: 

OTTOMH, you could probably create COM-callable wrappers for the classes you need, if you have relatively simple needs. My guess is that this will be more trouble than it's worth and that some small console apps would be a better use of your time, if you can't use PowerShell.

Chris Farmer
A: 

I think the best solution in my scenario is not to use plain JScript, but JScript.NET. It is available on any computer with .NET 2.0 installed. Although I think the "Script" in JScript.NET is a bit misleading because it must be compiled before running, it looks like JScript but has the added benefit that it can interact with all .NET 2.0 compatible libraries.

Jim
A: 

Take a look at the SharePoint Web Services. It is possible to call these from VBScript and JScript. You can find more information about the SharePoint Web Services here at MSDN.

JD
As I understand it, though, the web services only offer a limited subset of the entire SharePoint API. You would be able to change the log location through the web service api, for example.
Jim
@Jim that's true. Why not just use STSADM extensions from VBScript code? It is pretty easy to write new extensions.
JD