1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using Microsoft.SharePoint;
5
6
namespace SetAllWebTheme
7
{
8
class Program
9
{
10
static void Main(string[] args)
11
{
12
if (args.Length == 2)
13
{
14
SPSite sps = null;
15
16
try
17
{
18
sps = new SPSite(args[1]);
19
}
20
catch(Exception e)
21
{
22
Console.WriteLine(e.Message);
23
return;
24
}
25
26
if (args[0] == "list")
27
{
28
foreach (SPWeb spw in sps.AllWebs)
29
Console.Write("Web Name:{0}\nWeb Theme:{1}\nTitle:{2}\n", spw.Name, spw.Theme, spw.Title);
30
31
}
32
else
33
{
34
foreach (SPWeb spw in sps.AllWebs)
35
{
36
try
37
{
38
spw.ApplyTheme(args[0]);
39
Console.Write("应用 {0} 主题到 {1} 站\n", spw.Theme, spw.Title);
40
}
41
catch (Exception e)
42
{
43
Console.WriteLine(e.Message);
44
}
45
}
46
}
47
48
sps.Dispose();
49
}
50
else
51
{
52
Console.WriteLine("批量设置MOSS2007站点主题");
53
Console.WriteLine("作者:带电作业 (booolee)");
54
Console.WriteLine("http://booolee.cnblogs.com");
55
Console.WriteLine("用法:SetAllWebTheme arg1 arg2");
56
Console.WriteLine("arg1 为 list 时,列出指定URL中所有Web");
57
Console.WriteLine("arg1 为主题名(英文主题名)时,为将要设置的主题名");
58
Console.WriteLine("arg2 为指定站点的URL");
59
Console.WriteLine("示例:SetAllWebTheme http://sharepoint");
60
Console.WriteLine("列出http://sharepoint下所有web的摘要信息");
61
Console.WriteLine("示例:SetAllWebTheme Lichen http://sharepoint");
62
Console.WriteLine("将http://sharepoint下所有站点主题设置为Lichen");
63
}
64
65
}
66
}
67
}
68

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

我已经编译了这个工具,大家可以下载使用,免费哦~~
可以通过这个地址下载 https://files.cnblogs.com/booolee/SetAllWebTheme.rar
把这个工具复制到moss服务器上就可以了,不带参数运行就可以看到命令的用法。
其中英文主题名就是英文版moss的主题列表里的名字,这里列给大家

有了这个工具,大家就可以随时随心情的批量更换主题啦,哈哈~~
代码给大家,稍微扩展一下隔一段时间随机变换一下主题,就可以作出MOSS的主题秀了,WINDOWS有主题秀软件,MOSS也可以拥有哦~
废话时间:
昨天和老婆吵架了,其实也不是因为什么大事,今天想来真是不应该呀,在这里向老婆说声对不起,不要往心里去哦~~