Batch modification using vbs

Source: Internet
Author: User

Due to permissions, some customers need to reject the status on the SharePoint site. Because the production environment does not have the database permission, they can only write a vbs to run it. The Code is as follows:

 

1 optionexplicit mandatory statement

2
3 '--------------------------------------------------------------------
4 'define
5 '--------------------------------------------------------------------
6 const delay_time = 200
7 dim emailaddress, customerid
8 emailaddress = "meiweijun@163.com"
9 customerid = "N/"
10 call main () 'call the main function
11
12 private sub main ()
13 dim OIE 'As internetexplorer. Application
14 set OIE = Createobject ("internetexplorer. application ")
15 OIE. Visible = true
16
17 dim ob1_shshell 'reads the Desktop Folder
18 set ob1_shshell = wscript. Createobject ("wscript. Shell ")
19
20
21 'read command line arguments
22 if wscript. Arguments. Count> 0 then
23 emailaddress = wscript. Arguments. Item (0)
24 end if
25
26' open a new ie window
27 call navigatewait (OIE, "about: blank ")
28 ob1_shshell. appactivate "about: blank"
29 wscript. Sleep (500)
30 call navigatewait (OIE, "http: // ")
31 'enter the email address and press the query button.
32 dim oform, dropdown1, inputbox1, button1
33' get form
34 set oformpolicoie.doc ument. Forms ("aspnetform ")
35' conditions for obtaining the Email drop-down list
36 set dropdown1=oie.doc ument. getelementsbyname ("ctl00 $ M $ g_36d820b4241932_42e6_b8a5_32d21fea0dab $ ctl12 ")
37 'get email text box
38 set inputbox1=oie.doc ument. getelementsbyname ("ctl00 $ M $ g_36d820b4241932_42e6_b8a5_32d21fea0dab $ ctl13 ")
39 'Get query button
40 set button1 = oie.doc ument. getelementsbyname ("ctl00 $ M $ g_36d820b4241932_42e6_b8a5_32d21fea0dab $ ctl74 ")
41 on error resume next
42 dropdown1 (0). selectedindex = 2' email equals
43 If err. Number> 0 then
44 call OIE. Quit ()
45 set OIE = nothing
46 end if
47 inputbox1 (0). value = emailaddress
48 button1 (0). Click
49 waitfornavigatecomplete (OIE)
50
51 'to second page
52 set oform = oie.doc ument. Forms ("aspnetform ")
53 set button1 = oie.doc ument. getelementsbyname ("ctl00 $ M $ g_4fdccc80_8665_4043_8b2d_1_d342d4967 $ ctl01 $ ctl03 $ ctl00 ")
54 button1 (0). Click
55 waitfornavigatecomplete (OIE)
56
57
58
59 'to the third page
60 dim dropdown2, dropdown3
61 set oform = oie.doc ument. Forms ("aspnetform ")
62 set dropdown1 = oie.doc ument. getelementsbyname ("ctl00 $ M $ g_9ff5ad08_cc4d_49ba_87be_8d05c894b88e $ dropdownvalidationstatus ")
63 set dropdown2 = oie.doc ument. getelementsbyname ("ctl00 $ M $ g_9ff5ad08_cc4d_49ba_87be_8d05c894b88e $ dropdownsegment ")
64 set dropdown3 = oie.doc ument. getelementsbyname ("ctl00 $ M $ g_9ff5ad08_cc4d_49ba_87be_8d05c894b88e $ dropdownstatus ")
65
66 dim School, postal
67 set schoolw.oie.doc ument. getelementsbyname ("ctl00 $ M $ g_9ff5ad08_cc4d_49ba_87be_8d05c894b88e $ txtschool ")
68 set postalpolicoie.doc ument. getelementsbyname ("ctl00 $ M $ g_9ff5ad08_cc4d_49ba_87be_8d05c894b88e $ ctl19 ")
69 set button1 = oie.doc ument. getelementsbyname ("ctl00 $ M $ g_9ff5ad08_cc4d_49ba_87be_8d05c894b88e $ ctl96 ")
70 If (School (0). value = NULL or Len (School (0). Value) <= 0) then
71 school (0). value = "Na"
72 end if
73 If (postal (0). value = NULL or Len (postal (0). Value) <= 0) then
74 postal (0). value = "Na"
75 end if
76
77 dropdown1 (0). selectedindex = 3
78 dropdown2 (0). selectedindex = 1
79 dropdown3 (0). selectedindex = 6
80 wscript. Sleep (5000)
81
82 button1 (0). Click
83 waitfornavigatecomplete (OIE)
84
85 call OIE. Quit ()
86 set OIE = nothing
87
88
89
90 end sub
91
92 '--------------------------------------------------------------------
93 'navigatewait (internetexplorer. Application, string)
94 '--------------------------------------------------------------------
95 private sub navigatewait (OIE, sturl)
96 call OIE. navigate (sturl)
97 call waitfornavigatecomplete (OIE)
98 end sub
99
100 '--------------------------------------------------------------------
101 'waitfornavigatecomplete (internetexplorer. Application)
102 '--------------------------------------------------------------------
103 private sub waitfornavigatecomplete (OIE)
104 do while (OIE. Busy)
105 call wscript. Sleep (delay_time)
106 Loop
107
108 do while (oie.doc ument. readystate <> "complete ")
109 call wscript. Sleep (delay_time)
110 Loop
111 end sub

 

In this way, the user status on the site can be modified to run unattended.

First, the code will open the website,

 

Enter the email address and click query to go to the next page.

 

Click Edit automatically to go to the next page

 

Automatically change the status to reject and click the Save button to exit IE.

 

It saves a lot of trouble for hand-edited children's shoes.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.