Advertisement
Guest User

Final Script

a guest
Apr 15th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.47 KB | None | 0 0
  1.  
  2. OPTION EXPLICIT
  3.  
  4. Dim objNet, strComputer, objWMI, colitems, objItem, fso, Shell
  5.  
  6. If Instr(1, WScript.FullName, "CScript", vbTextCompare) = 0 Then
  7. Shell.Run "cscript """ & WScript.ScriptFullName & """", 1, False
  8. WScript.Quit
  9. End If
  10.  
  11. Set objNet = WScript.CreateObject("WScript.Network")
  12.  
  13. WScript.StdOut.Write "Hi " & objNet.UserName & ". Welcome to the World" & _
  14. " of Scripting and Automation. You have connected to " & objNet.UserDomain & "/" & objNet.ComputerName & _
  15. " and running "
  16. Call OS()
  17. WScript.StdOut.Write "operating system. You are running your script from "
  18. Call Directory()
  19. WScript.StdOut.Write "and the path is "
  20. Call Path()
  21. WScript.StdOut.Write "The team members are: "
  22. WScript.Echo "Brent Wright, 100424357"
  23. WScript.Echo "Matthew Alex, 100428584"
  24. WScript.Echo "Kameron Chan, 100373050"
  25. WScript.Echo "Joshua Boyer, 100427919"
  26.  
  27.  
  28.  
  29.  
  30.  
  31. Function Menu()
  32. Dim choice
  33.  
  34. WScript.StdOut.Write "Administration Scripting - Durham College" & vbCrLf
  35. WScript.StdOut.Write "------------------------------------------" & vbCrLf
  36. WScript.StdOut.Write vbCrLf & "A - Desktop Management" & vbCrLf
  37. WScript.StdOut.Write "B - Logon and Logoff" & vbCrLf
  38. WScript.StdOut.Write "C - User Management" & vbCrLf
  39. WScript.StdOut.Write "D - Disk Management" & vbCrLf
  40. WScript.StdOut.Write "E - Utilites" & vbCrLf
  41. WScript.StdOut.Write "Q - Quit from the menu" & vbCrLf
  42.  
  43. WScript.StdOut.Write "Enter your selection: "
  44. choice = WScript.StdIn.ReadLine
  45. Select Case choice
  46.  
  47. Case "a","A" 'Brent Wright
  48. WScript.Echo ""
  49. WScript.Echo ""
  50. Call functionA()
  51.  
  52. Case "b","B" 'Kameron Chan
  53. WScript.Echo ""
  54. WScript.Echo ""
  55. Call functionB()
  56.  
  57.  
  58. Case "c","C" 'Brent Wright
  59. WScript.Echo ""
  60. WScript.Echo ""
  61. Call functionC()
  62.  
  63. Case "d","D" 'Josh Boyer
  64. WScript.Echo ""
  65. WScript.Echo ""
  66. Call functionD()
  67.  
  68. Case "e","E" 'Kameron Chan/Matthew Alex
  69. WScript.Echo ""
  70. WScript.Echo ""
  71. Call functionE()
  72. Case "q","Q"
  73. Call functionQ()
  74. End Select
  75. End Function
  76. Call Menu()
  77.  
  78. Function functionA() 'Brent Wright
  79. Dim selectionA, objNet
  80. Set objNet = CreateObject("WScript.Network")
  81.  
  82. WScript.StdOut.Write "DeskTop Management" & vbCrLf
  83. WScript.StdOut.Write "----------------------" & vbCrLf
  84. WScript.StdOut.Write "A - Desktop Settings" & vbCrLf
  85. WScript.StdOut.Write "B - Shortcuts" & vbCrLf
  86. WScript.StdOut.Write "C - Events" & vbCrLf
  87. WScript.StdOut.Write "D - Scheduled Tasks" & vbCrLf
  88. WScript.StdOut.Write "Q - Exit to Main Menu" & vbCrLf
  89.  
  90. WScript.StdOut.Write "What is your selection? "
  91. selectionA = WScript.StdIn.ReadLine
  92.  
  93.  
  94.  
  95. Select Case selectionA
  96.  
  97. Case "a","A"
  98. WScript.Echo ""
  99. WScript.Echo ""
  100. Call aDesktop()
  101.  
  102. Case "b","B"
  103. WScript.Echo ""
  104. WScript.Echo ""
  105. Call aShortcut()
  106.  
  107. Case "c","C"
  108. WScript.Echo ""
  109. WScript.Echo ""
  110. Call aEvent()
  111.  
  112. Case "D"
  113. WScript.Echo ""
  114. WScript.Echo ""
  115. Call aTasks()
  116.  
  117.  
  118. Case "Q"
  119. WScript.Echo ""
  120. WScript.Echo ""
  121. Call Menu()
  122. Case else
  123. WScript.Echo "error"
  124. WScript.Echo ""
  125. WScript.Echo ""
  126.  
  127. End Select
  128. Call Menu()
  129. WScript.Echo ""
  130. End Function
  131. 'Call functionA() 'End Brent
  132.  
  133.  
  134. Function functionB() ' Kameron Chan /Matthew Alex
  135. Dim menuchoice, ans', WScript
  136. 'Set WScript = CreateObject ("WScript.Shell")
  137. ans = "y"
  138.  
  139.  
  140.  
  141. 'do
  142.  
  143.  
  144.  
  145. WScript.Echo "1. Restart a computer"
  146.  
  147. WScript.Echo "2. Logon script"
  148.  
  149. WScript.Echo "3. Logoff script"
  150.  
  151. WScript.Echo "4. Shutdown a computer"
  152.  
  153. WScript.Echo "5. Exit to the Main menu"
  154.  
  155.  
  156.  
  157. WScript.StdOut.WriteLine "Please choose an option: "
  158. menuchoice = WScript.StdIn.ReadLine
  159.  
  160. 'loop while ans = "y"
  161.  
  162.  
  163.  
  164. Select Case menuchoice
  165.  
  166. Case "1"
  167.  
  168. option1()
  169.  
  170. ans = "n"
  171.  
  172. Case "2"
  173.  
  174. option2()
  175.  
  176. ans = "n"
  177.  
  178. Case "3"
  179.  
  180. option3()
  181.  
  182. ans = "n"
  183.  
  184. Case "4"
  185.  
  186. option4()
  187.  
  188. ans = "n"
  189.  
  190. Case "5"
  191.  
  192. ans = "n"
  193.  
  194. Call Menu()
  195.  
  196. Case Else
  197.  
  198. WScript.Echo "You did not insert a value corresponding with a menu option"
  199.  
  200. ans = "y"
  201.  
  202. End Select
  203. End Function
  204. 'Call functionB()
  205.  
  206.  
  207.  
  208. Function functionC() 'Brent Wright
  209. Dim selectionC
  210.  
  211. WScript.StdOut.Write "A - Create a Group" & vbCrLf
  212. WScript.StdOut.Write "B - Create Users" & vbCrLf
  213. WScript.StdOut.Write "C - List Users" & vbCrLf
  214. WScript.StdOut.Write "D - List Groups" & vbCrLf
  215. WScript.StdOut.Write "E - Delete User" & vbCrLf
  216. WScript.StdOut.Write "F - List Inactive Users" & vbCrLf
  217. WScript.StdOut.Write "Q - Exit to Main Menu" & vbCrLf
  218.  
  219. WScript.StdOut.Write "Enter your selection: "
  220. selectionC = WScript.StdIn.ReadLine
  221.  
  222. Select Case selectionC
  223.  
  224. Case "a","A"
  225. WScript.Echo ""
  226. WScript.Echo ""
  227. Call cGroup()
  228. WScript.Echo ""
  229. WScript.Echo ""
  230.  
  231. Case "b","B"
  232. WScript.Echo ""
  233. WScript.Echo ""
  234. Dim group
  235. Call cUser(group)
  236.  
  237.  
  238. Case "c","C"
  239. WScript.Echo ""
  240. WScript.Echo ""
  241. Call cUsersList()
  242.  
  243. Case "d","D"
  244. WScript.Echo ""
  245. WScript.Echo ""
  246. Call cGroupsList()
  247.  
  248. Case "e","E"
  249. WScript.Echo ""
  250. WScript.Echo ""
  251. Call cDelete()
  252.  
  253. Case "f","F"
  254. WScript.Echo ""
  255. WScript.Echo ""
  256. Call cDisplayInactive()
  257.  
  258. Case "Q"
  259. Call Menu()
  260. WScript.Echo ""
  261. WScript.Echo ""
  262. End Select
  263. Call Menu()
  264. End Function
  265. 'Call functionC() 'End Brent
  266.  
  267.  
  268. Function functionD()
  269. dim options
  270. dim strComputer
  271.  
  272. dim objWMIservice
  273.  
  274. dim colvolumes
  275.  
  276. dim objvolume
  277.  
  278. dim oXL
  279.  
  280. dim i
  281.  
  282. dim freespace(30)
  283.  
  284. dim j
  285.  
  286. dim volname(30)
  287.  
  288. dim volsize(30)
  289.  
  290. dim freespaceperc(30)
  291.  
  292. Dim fso
  293.  
  294. Dim ObjFolder
  295.  
  296. Dim ObjFiles
  297.  
  298. Dim ObjFile
  299.  
  300.  
  301. WScript.Echo "A - Display Drive Size and Store in Excel doc"
  302.  
  303. WScript.Echo "B - Display Folder Properties and locate folders over 10mb"
  304.  
  305. WScript.Echo "Z - Exit to Main Menu"
  306.  
  307. WScript.StdOut.Write "Option: "
  308. options = WScript.StdIn.ReadLine
  309.  
  310.  
  311.  
  312. 'function declarations
  313.  
  314.  
  315.  
  316.  
  317.  
  318. Select Case options
  319.  
  320. case "A"
  321.  
  322. drivesize()
  323.  
  324. case "B"
  325.  
  326. folderprop()
  327.  
  328. case "Z"
  329.  
  330. WScript.Quit
  331.  
  332. End Select
  333.  
  334.  
  335.  
  336.  
  337.  
  338. End Function
  339. 'Call functionD()
  340.  
  341.  
  342. Function functionE()
  343.  
  344.  
  345.  
  346.  
  347. 'Variables are global
  348.  
  349. dim suboption, menuoption
  350.  
  351.  
  352.  
  353. WScript.Echo "1. Math Game"
  354.  
  355. WScript.Echo "2. Dictionary"
  356.  
  357. WScript.Echo "3. Software"
  358.  
  359. WScript.StdOut.Write "Choose an option: "
  360. menuoption = WScript.StdIn.ReadLine
  361.  
  362. Select Case menuoption
  363.  
  364. Case 1
  365.  
  366. option1()
  367.  
  368. Case 2
  369.  
  370. option2()
  371.  
  372. Case 3
  373.  
  374. option3()
  375.  
  376. End Select
  377.  
  378. Call Menu()
  379. End Function
  380. 'Call functionE()
  381. 'Math Game
  382.  
  383.  
  384.  
  385. Function option1()
  386.  
  387. dim h,s,e
  388.  
  389. WScript.Echo "What is 5 * 5 + 20 / 5?"
  390.  
  391. WScript.Echo "H - Help me S - Solve E - Exit"
  392.  
  393. suboption = WScript.StdIn.ReadLine
  394.  
  395.  
  396.  
  397. Select Case ucase(suboption)
  398.  
  399. Case "H"
  400.  
  401. help()
  402.  
  403. Case "S"
  404.  
  405. solve()
  406.  
  407. Case "E"
  408.  
  409. WScript.Quit
  410.  
  411. End Select
  412.  
  413. End Function
  414.  
  415.  
  416.  
  417. Function help()
  418.  
  419. dim objword, objdoc, objselection
  420.  
  421.  
  422.  
  423. Set objWord = CreateObject("Word.Application")
  424.  
  425. objWord.Caption = "Test Caption"
  426.  
  427. objWord.Visible = True
  428.  
  429.  
  430.  
  431. Set objDoc = objWord.Documents.Add()
  432.  
  433. Set objSelection = objWord.Selection
  434.  
  435.  
  436.  
  437. objSelection.Font.Name = "Arial"
  438.  
  439. objSelection.ParagraphFormat.Alignment=1
  440.  
  441. objSelection.Font.Underline= true
  442.  
  443. objSelection.Font.Size = "12"
  444.  
  445. objSelection.TypeText "Equipment Cost"
  446.  
  447. objSelection.Font.Underline= false
  448.  
  449. objSelection.TypeParagraph()
  450.  
  451. objSelection.ParagraphFormat.Alignment=0
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459. objSelection.TypeText"10 * 10 + 15 / 3"
  460.  
  461. WScript.Sleep 2000
  462.  
  463. objSelection.TypeParagraph()
  464.  
  465.  
  466.  
  467. objSelection.TypeText"100 + 5"
  468.  
  469. WScript.Sleep 2000
  470.  
  471. objSelection.TypeParagraph()
  472.  
  473.  
  474. objSelection.TypeText"105"
  475.  
  476. WScript.Sleep 2000
  477.  
  478. objSelection.TypeParagraph()
  479.  
  480. objDoc.SaveAs("C:\Scripts\finalprojectmathgame.docx")
  481.  
  482. WScript.Sleep 3000
  483.  
  484. objWord.Quit
  485.  
  486. 'menu()
  487.  
  488. End Function
  489.  
  490.  
  491. Function solve()
  492.  
  493. dim mathans, wshshell
  494.  
  495. WScript.Echo "Please enter your answer: "
  496.  
  497. mathans = WScript.StdIn.ReadLine
  498.  
  499. if mathans = 29 then
  500.  
  501. 'menu()
  502.  
  503. else
  504.  
  505. set WshShell = WScript.CreateObject("WScript.Shell") ' invoke applications
  506.  
  507. WshShell.Run "calc"
  508.  
  509. WshShell.AppActivate "Calculator" ' activate the calculator
  510.  
  511. WScript.Sleep 1000
  512.  
  513. WshShell.SendKeys "%2"
  514.  
  515. WshShell.SendKeys "5{*}"
  516.  
  517. WScript.Sleep 2000
  518.  
  519. WshShell.SendKeys "5"
  520.  
  521. WScript.Sleep 2000
  522.  
  523. WshShell.SendKeys "{+}"
  524.  
  525. WScript.Sleep 2000
  526.  
  527. WshShell.SendKeys "20{/}"
  528.  
  529. WScript.Sleep 2000
  530.  
  531. WshShell.SendKeys "5"
  532.  
  533. WScript.Sleep 2000
  534.  
  535. WshShell.SendKeys "{ENTER}"
  536.  
  537. WScript.Sleep 2500
  538.  
  539. wshshell.SendKeys "%{F4}"
  540.  
  541. menu()
  542.  
  543. End If
  544. End Function
  545.  
  546.  
  547.  
  548.  
  549.  
  550. 'Dictionary
  551.  
  552. Function option2()
  553.  
  554. WScript.Echo "How would you like to modify the server detials list?"
  555.  
  556. WScript.Echo "A - Add L - List D - Delete E - Exit"
  557.  
  558. suboption = WScript.StdIn.ReadLine
  559.  
  560.  
  561.  
  562.  
  563.  
  564. End Function
  565.  
  566. Dim objDict
  567.  
  568.  
  569.  
  570. Set objDict = CreateObject("Scripting.Dictionary")
  571.  
  572.  
  573.  
  574. ' fill the items in the dictionary
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582. function DisplayServerDetails(ObjDict)
  583.  
  584. Select Case ucase(suboption)
  585.  
  586. Case "A"
  587.  
  588. addentry()
  589.  
  590. Case "L"
  591.  
  592. display()
  593.  
  594. Case "D"
  595.  
  596. delentry()
  597.  
  598. Case "E"
  599.  
  600. WScript.Quit
  601.  
  602. End Select
  603.  
  604. end function
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616. Function functionQ() 'Josh Boyer
  617. dim array(9)
  618. Array(0)="Thank you for running this program"
  619.  
  620. Array(1)="Have a good summer! Program exited."
  621.  
  622. Array(2)="We hope you enjoyed our program."
  623.  
  624. Array(3)="Program exited. Thank you."
  625.  
  626. Array(4)="We appreciate that you ran the program."
  627.  
  628. Array(5)="This program was made by: Joshua Boyer, Kameron Chan, Matthew Alex and Brent Wright."
  629.  
  630. Array(6)="All of these options were made using VBScript."
  631.  
  632. Array(7)="Thank you. Have a great summer."
  633.  
  634. Array(8)="Please use this program again."
  635.  
  636. Array(9)="Thank you for executing this VBScript."
  637.  
  638. Randomize
  639.  
  640. Wscript.Echo array(Int(rnd*10))
  641.  
  642. Wscript.Sleep 2000
  643.  
  644. WScript.Quit
  645.  
  646. End Function
  647.  
  648.  
  649.  
  650. Function aDesktop 'Brent Wright
  651.  
  652. Dim WshShell, wallpaper, sleepTime, FSO, HKEY_CURRENT_USER
  653. HKEY_CURRENT_USER = &H80000001
  654.  
  655. WScript.StdOut.Write "Enter the path for the picture you want to use: "
  656. wallpaper = WScript.StdIn.ReadLine
  657. sleepTime = 30000
  658.  
  659. Set FSO = CreateObject("Scripting.FileSystemObject")
  660.  
  661. Set WshShell = WScript.CreateObject("Wscript.Shell")
  662. WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", wallpaper
  663. WScript.Sleep sleepTime
  664. WshShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters", 1, False
  665.  
  666.  
  667. strComputer = "."
  668. Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
  669. strKeyPath = "Control Panel\Desktop"
  670. objReg.CreateKey HKEY_CURRENT_USER, strKeyPath
  671. ValueName = "ScreenSaveTimeout"
  672. strValue = "300"
  673. objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, strValue
  674. Set WshShell = Nothing
  675.  
  676. End Function
  677.  
  678. Function aShortcut 'Brent Wright
  679. Dim MyShortcut, URL, favourite, deleted,objStartFolder
  680. Dim objFolder, colFiles, objFile, confirm, WSHShell, Link
  681. Dim objNet, FSO
  682. Set WSHShell = WScript.CreateObject("WScript.Shell")
  683. Set objNet = CreateObject("WScript.Network")
  684. MyShortcut = "C:\Users\" & objNet.username & "\Desktop\Computer Management.LNK"
  685. Set Link = WSHShell.CreateShortcut(MyShortcut)
  686. Link.TargetPath = ("C:\Windows\System32\compmgmt.msc")
  687. Link.WorkingDirectory =("C:\Windows\System32")
  688. Link.WindowStyle = 4
  689. Link.Save
  690.  
  691. WScript.StdOut.Write "Enter your website URL: "
  692. URL = WScript.StdIn.ReadLine
  693. Set favourite = WSHShell.CreateShortcut("C:\Users\" & objNet.UserName & "\Favorites\favourite.url")
  694. favourite.TargetPath = URL
  695. favourite.Save
  696.  
  697. WScript.StdOut.Write "Enter a shortcut to delete: "
  698. deleted = WScript.StdIn.ReadLine
  699.  
  700. WScript.StdOut.Write "Do you want to delete the shortcut?[Y/N]"
  701. confirm = WScript.StdIn.ReadLine
  702.  
  703. if confirm = "Y" then
  704. FSO.DeleteFile deleted
  705. elseif confirm = "N" then
  706. WScript.Echo "Not deleted"
  707. End If
  708.  
  709. Set FSO = CreateObject("Scripting.FileSystemObject")
  710. objStartFolder = "C:\Users\" & objNet.Username & "\Desktop"
  711.  
  712. Set objFolder = FSO.GetFolder(objStartFolder)
  713. Wscript.Echo objFolder.Path
  714.  
  715. Set colFiles = objFolder.Files
  716.  
  717. For Each objFile in colFiles
  718. If UCase(FSO.GetExtensionName(objFile.name)) = "LNK" Then
  719. Wscript.Echo objFile.Name
  720. End If
  721. Next
  722. Wscript.Echo
  723. End Function
  724.  
  725.  
  726. Function aEvent ' Brent Wright
  727.  
  728. Dim objEvent, ScriptContext, text, FSO, WshShell, strCommand
  729. Dim objWMIService, colLogFiles, objLogFile, errBackupLog
  730. Dim colLoggedEvents, loggedevent
  731. Set FSO = CreateObject("Scripting.FileSystemObject")
  732. Set WshShell = CreateObject("WScript.Shell")
  733.  
  734. strCommand = "eventcreate /T Error /ID 100 /L Shortcuts /D " & _
  735. Chr(34) & "Shortcut Created" & Chr(34)
  736. WshShell.Run strcommand
  737.  
  738. strComputer = "."
  739. Set objWMIService = GetObject("winmgmts:" _
  740. & "{impersonationLevel=impersonate,(Backup)}!\\" & _
  741. strComputer & "\root\cimv2")
  742. Set colLogFiles = objWMIService.ExecQuery _
  743. ("SELECT * FROM Win32_NTEventLogFile WHERE LogFileName='Application'")
  744. For Each objLogfile in colLogFiles
  745. errBackupLog = objLogFile.BackupEventLog("c:\scripts\application.evt")
  746. If errBackupLog <> 0 Then
  747. Wscript.Echo "The Application event log could not be backed up."
  748. Else
  749. objLogFile.ClearEventLog()
  750. End If
  751. Next
  752.  
  753. strComputer = "."
  754. Set objWMIService = GetObject("winmgmts:" _
  755. & "{impersonationLevel=impersonate,(Security)}!\\" & strComputer & "\root\cimv2")
  756.  
  757. Set colLoggedEvents = objWMIService.ExecQuery _
  758. ("Select * from Win32_NTLogEvent Where Logfile = 'Security' and CategoryString='Account Management'")
  759. For each loggedEvent in colLoggedEvents
  760. Set text = FSO.OpenTextFile("account_events.txt", 8)
  761. text.WriteLine "Security Events: " & loggedEvent.Name
  762. text.Close
  763. Next
  764. End Function
  765.  
  766. Function aTasks 'Brent Wright
  767.  
  768. Dim source, destination, copy, FSO, objWMIService, objNewJob, JobID, errJobCreated, colScheduledJobs, objJob
  769. Set FSO = CreateObject("Scripting.FileSystemObject")
  770. strComputer = "."
  771. Set objWMIService = GetObject("winmgmts:" _
  772. & "{impersonationLevel=impersonate}!\\" _
  773. & strComputer & "\root\cimv2")
  774. Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
  775. errJobCreated = objNewJob.Create _
  776. ("c:\defrag.bat", "********220000.000000-300", _
  777. True , 16, , True, JobId)
  778. If errJobCreated <> 0 Then
  779. Wscript.Echo "Error: Task creation failed"
  780. Else
  781. Wscript.Echo "Task created successfully"
  782. End If
  783.  
  784. strComputer = "."
  785. Set objWMIService = GetObject("winmgmts:" _
  786. & "{impersonationLevel=impersonate}!\\" _
  787. & strComputer & "\root\cimv2")
  788. Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
  789. errJobCreated = objNewJob.Create _
  790. ("c:\backup.bat", "********220000.000000-300", _
  791. True , 16, , True, JobId)
  792. If errJobCreated <> 0 Then
  793. Wscript.Echo "Error: Task creation failed"
  794. Else
  795. Wscript.Echo "Task created successfully"
  796. End If
  797.  
  798. strComputer = "."
  799. Set objWMIService = GetObject("winmgmts:" _
  800. & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  801.  
  802. Set colScheduledJobs = objWMIService.ExecQuery _
  803. ("Select * from Win32_ScheduledJob")
  804.  
  805. For Each objJob in colScheduledJobs
  806. Wscript.Echo "Caption: " & objJob.Caption
  807. Wscript.Echo "Command: " & objJob.Command
  808. Wscript.Echo "Days of Month: " & objJob.DaysOfMonth
  809. Wscript.Echo "Days of Week: " & objJob.DaysOfWeek
  810. Wscript.Echo "Description: " & objJob.Description
  811. Wscript.Echo "Elapsed Time: " & objJob.ElapsedTime
  812. Wscript.Echo "Install Date: " & objJob.InstallDate
  813. Wscript.Echo "Interact with Desktop: " & objJob.InteractWithDesktop
  814. Wscript.Echo "Job ID: " & objJob.JobID
  815. Wscript.Echo "Job Status: " & objJob.JobStatus
  816. Wscript.Echo "Name: " & objJob.Name
  817. Wscript.Echo "Notify: " & objJob.Notify
  818. Wscript.Echo "Owner: " & objJob.Owner
  819. Wscript.Echo "Priority: " & objJob.Priority
  820. Wscript.Echo "Run Repeatedly: " & objJob.RunRepeatedly
  821. Wscript.Echo "Start Time: " & objJob.StartTime
  822. Wscript.Echo "Status: " & objJob.Status
  823. Wscript.Echo "Time Submitted: " & objJob.TimeSubmitted
  824. Wscript.Echo "Until Time: " & objJob.UntilTime
  825. Next
  826. WScript.Echo ""
  827. WScript.Echo ""
  828. End Function
  829.  
  830.  
  831. Function option1() 'Kameron Chan
  832.  
  833. dim objShell
  834.  
  835. Set objShell = WScript.CreateObject("WScript.Shell")
  836.  
  837. objShell.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"
  838.  
  839. End Function
  840.  
  841.  
  842. Function option2() 'Kameron Chan
  843.  
  844. Dim objNetwork, objNet, colDrives, i, objWMIService, colPrinters
  845.  
  846. Set objNetwork = CreateObject("WScript.Network")
  847.  
  848. WScript.Echo "Hi" & objNetwork.UserName & ", Welcome to Windows." 'welcome message
  849.  
  850. Set objNet = CreateObject("Wscript.Network")
  851.  
  852. Set colDrives = objNetwork.EnumNetworkDrives
  853.  
  854. For i = 0 to colDrives.Count-1 Step 2
  855.  
  856. objNetwork.RemoveNetworkDrive colDrives.Item(i) 'deletes mapped drives
  857.  
  858. Next
  859.  
  860.  
  861.  
  862. Set objNet = CreateObject("WScript.Network")
  863.  
  864. strComputer = "."
  865.  
  866. Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
  867.  
  868. Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
  869.  
  870.  
  871.  
  872. 'adds three drives
  873.  
  874. Set objNetwork = CreateObject("WScript.Network")
  875.  
  876. objNetwork.MapNetworkDrive "S:", "PATH"
  877.  
  878.  
  879.  
  880. Set objNetwork = CreateObject("WScript.Network")
  881.  
  882. objNetwork.MapNetworkDrive "J:", "PATH"
  883.  
  884.  
  885.  
  886. Set objNetwork = CreateObject("WScript.Network")
  887.  
  888. objNetwork.MapNetworkDrive "R:", "PATH"
  889.  
  890. 'removes printers
  891.  
  892. For Each objPrinter in colPrinters
  893.  
  894. If objPrinter.Attributes And NETWORK Then
  895.  
  896. strPrinter = objPrinter.Name
  897.  
  898. objNet.RemovePrinterConnection strPrinter
  899.  
  900. End If
  901.  
  902. Next
  903.  
  904. ' readd printers and part d
  905.  
  906. objNetwork.AddWindowsPrinterConnection "\\server\H134"
  907.  
  908. objNetwork.AddWindowsPrinterConnection "\\server\SW214"
  909.  
  910. objNetwork.AddWindowsPrinterConnection "\\server\B221"
  911.  
  912. objNetwork.SetDefaultPrinter "\\Server\B221"
  913.  
  914.  
  915.  
  916. 'part e
  917.  
  918. Set objFSO=CreateObject("Scripting.FileSystemObject")
  919.  
  920. Set objNetwork = CreateObject("WScript.Network")
  921.  
  922. Set colPrinters = objNetwork.EnumPrinterConnections
  923.  
  924.  
  925.  
  926. ' list all the drives
  927.  
  928. wscript.echo "Current Mapped Paths"
  929.  
  930. Set colDrives=objFSO.Drives
  931.  
  932. For Each Drive In colDrives
  933.  
  934. WScript.Echo "Path: " & Drive.Path
  935.  
  936.  
  937.  
  938. WScript.Echo String(20,".") & vbCRLF
  939.  
  940. Next
  941.  
  942.  
  943.  
  944. ' print only the printer names
  945.  
  946. wscript.echo "Current Printer Assignments: " & colPrinters.Count/2 &vbCRLF
  947.  
  948. For i = 1 to colPrinters.Count - 1 Step 2
  949.  
  950. wscript.echo colPrinters.Item(i)
  951.  
  952. Next
  953.  
  954.  
  955.  
  956. ' Part f
  957.  
  958. Set objNetwork = CreateObject("Wscript.Network")
  959.  
  960. Set objShell = WScript.CreateObject("WScript.Shell")
  961.  
  962. strComputer = objNetwork.ComputerName
  963.  
  964. strUser = objNetwork.UserName
  965.  
  966.  
  967.  
  968. isAdministrator = false
  969.  
  970. 'Checks to see if current user is a admin sets isadministrator variable accordingly
  971.  
  972. Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
  973.  
  974.  
  975.  
  976. For Each objUser in objGroup.Members
  977.  
  978. If objUser.Name = strUser Then
  979.  
  980. isAdministrator = true
  981.  
  982. End If
  983.  
  984. Next
  985.  
  986.  
  987.  
  988. If isAdministrator Then
  989.  
  990. Wscript.Echo strUser & " is a local administrator."
  991.  
  992. objNetwork.AddWindowsPrinterConnection "\\server\B221" 'adds printer
  993.  
  994. objShell.Run "NET TIME" 'synchronizes time
  995.  
  996. 'Turn off the wallpaper setting
  997.  
  998. objShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", ""
  999.  
  1000.  
  1001.  
  1002. objShell.RegWrite "HKCU\Control Panel\Colors\Background", "255 255 255" 'Sets wall paper to white
  1003.  
  1004. Else
  1005.  
  1006. Wscript.Echo strUser & " is not a local administrator."
  1007.  
  1008. End If
  1009.  
  1010.  
  1011.  
  1012. ' PART G Retrieve computers IP address
  1013.  
  1014. ' strComputer = "."
  1015.  
  1016. ' Set objWMIService = GetObject( _
  1017.  
  1018. ' "winmgmts:\\" & strComputer & "\root\cimv2")
  1019.  
  1020. ' Set colNics = objWMIService.ExecQuery _
  1021.  
  1022. ' ("Select * From Win32_NetworkAdapter " _
  1023.  
  1024. ' & "Where NetConnectionID = " & _
  1025.  
  1026. ' "'Local Area Connection'")
  1027.  
  1028.  
  1029.  
  1030. ' For Each objNic in colNics
  1031.  
  1032. ' Set colNicConfigs = objWMIService.ExecQuery _
  1033.  
  1034. ' ("ASSOCIATORS OF " _
  1035.  
  1036. ' & "{Win32_NetworkAdapter.DeviceID='" & _
  1037.  
  1038. ' objNic.DeviceID & "'}" & _
  1039.  
  1040. ' " WHERE AssocClass=Win32_NetworkAdapterSetting")
  1041.  
  1042. ' For Each objNicConfig In colNicConfigs
  1043.  
  1044. ' For Each strIPAddress in objNicConfig.IPAddress
  1045.  
  1046. ' Wscript.Echo "IP Address: " & strIPAddress
  1047.  
  1048. ' Next
  1049.  
  1050. ' Next
  1051.  
  1052. ' Next
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. End Function
  1061.  
  1062.  
  1063.  
  1064. Function option3() 'Kameron Chan
  1065.  
  1066. Const NETWORK = 22
  1067.  
  1068. Dim objNetwork, objNet, objWMIService, colPrinters, strComputer, strPrinter, objPrinter
  1069.  
  1070. Set objNet = CreateObject("WScript.Network")
  1071.  
  1072. strComputer = "."
  1073.  
  1074. Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
  1075.  
  1076. Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
  1077.  
  1078.  
  1079.  
  1080. For Each objPrinter in colPrinters
  1081.  
  1082. If objPrinter.Attributes And NETWORK Then
  1083.  
  1084. strPrinter = objPrinter.Name
  1085.  
  1086. objNet.RemovePrinterConnection strPrinter
  1087.  
  1088. End If
  1089.  
  1090. Next
  1091.  
  1092. objNetwork.RemoveNetworkDrive "J:"
  1093.  
  1094. Set objNetwork = CreateObject("WScript.Network")
  1095.  
  1096. MsgBox("Hi" & objNetwork.UserName & ", You will be logged out soon")
  1097.  
  1098. End Function
  1099. Function option4() 'Kameron Chan
  1100.  
  1101. dim objShell
  1102.  
  1103. Set objShell = WScript.CreateObject("WScript.Shell")
  1104.  
  1105. objShell.Run "C:\WINDOWS\system32\shutdown.exe -t 0"
  1106.  
  1107. End Function
  1108.  
  1109.  
  1110.  
  1111. Function cGroup() 'Brent Wright
  1112. Dim group, colAccounts, objGroup, groupPass
  1113.  
  1114. group = InputBox("Enter the name of a group to create: ")
  1115.  
  1116. strComputer = "."
  1117. Set colAccounts = GetObject("WinNT://" & strComputer & "")
  1118. if lcase(trim(colAccounts.Name)) = lcase(trim(group)) then
  1119. WScript.Echo "The group is already created"
  1120. else
  1121. Set objGroup = colAccounts.Create("group", group)
  1122. objGroup.SetInfo
  1123.  
  1124. End If
  1125. End Function
  1126.  
  1127. Function cUser(group) 'Brent Wright
  1128. Dim user, pass, colAccounts, objUser, objGroup, newgroup, replacer, objNet
  1129. Set objNet = CreateObject("WScript.Network")
  1130. 'newgroup = cGroup(groupPass)
  1131. newgroup = group
  1132. Do until user = "NOMORE"
  1133. WScript.StdOut.Write "Enter a username: "
  1134. user = WScript.StdIn.ReadLine
  1135. if not user = "NOMORE" then
  1136. WScript.StdOut.Write "Enter a password: "
  1137. pass = WScript.StdIn.ReadLine
  1138. end if
  1139. strComputer = "."
  1140. Set colAccounts = GetObject("WinNT://" & strComputer & "")
  1141. Set objUser = colAccounts.Create("user", user)
  1142. Do until Len(pass) <= 8
  1143. if Len(pass) <= 8 then
  1144. objUser.SetPassword pass
  1145. objUser.SetInfo
  1146. else
  1147. WScript.Echo "That password is invalid."
  1148. WScript.StdOut.Write "Enter a password: "
  1149. pass = WScript.StdIn.ReadLine
  1150. End If
  1151. Loop
  1152. Loop
  1153. strComputer = "."
  1154. Set objGroup = GetObject("WinNT://" & objNet.ComputerName & "/" & newgroup)
  1155.  
  1156. For each objUser in colAccounts
  1157. Set objUser = GetObject("WinNT://" & objNet.ComputerName & "/" & user)
  1158. objGroup.Add(objUser.ADsPath)
  1159. Next
  1160. End Function
  1161.  
  1162. Function cUsersList 'Brent Wright
  1163. Dim FSO, colAccounts, strComputer, text, objUser, create
  1164. Set FSO = CreateObject("Scripting.FileSystemObject")
  1165. Set create = FSO.CreateTextFile("c:\scripts\user_list.txt")
  1166. Set create = nothing
  1167. strComputer = "."
  1168. Set colAccounts = GetObject("WinNT://" & strComputer & "")
  1169. colAccounts.Filter = Array("user")
  1170. For Each objUser In colAccounts
  1171. Wscript.Echo objUser.Name
  1172. Set text = FSO.OpenTextFile("c:\scripts\user_list.txt", 8)
  1173. text.WriteLine "Users: " & objUser.Name
  1174. text.Close
  1175. Next
  1176. End Function
  1177.  
  1178. Function cGroupsList 'Brent Wright
  1179. Dim strComputer, colAccounts, objGroup, FSO, text, doc
  1180. Set FSO = CreateObject("Scripting.FileSystemObject")
  1181. Set doc = FSO.CreateTextFile("c:\scripts\groups.docx")
  1182. Set doc = nothing
  1183. strComputer = "."
  1184. Set colAccounts = GetObject("WinNT://" & strComputer & "")
  1185. colAccounts.Filter = Array("group")
  1186. For Each objGroup In colAccounts
  1187. Wscript.Echo objGroup.Name
  1188. Set text = FSO.OpenTextFile("c:\scripts\groups.docx", 2)
  1189. text.WriteLine "Groups: " & objGroup.Name
  1190. text.Close
  1191. Next
  1192. End Function
  1193.  
  1194. Function cDelete() 'Brent Wright
  1195. Dim objComputer, delete, confirm, objNet
  1196. Set objNet = CreateObject("WScript.Network")
  1197. WScript.StdOut.Write "What user do you want to delete? "
  1198. delete = WScript.StdIn.ReadLine
  1199.  
  1200. WScript.StdOut.Write "Are you sure[Y/N]"
  1201. confirm = WScript.StdIn.ReadLine
  1202.  
  1203. Set objComputer = GetObject("WinNT://" & objNet.ComputerName & "")
  1204. if confirm = "Y" then
  1205. objComputer.Delete "user", delete
  1206. else
  1207. WScript.Echo "Operation Aborted"
  1208. End If
  1209. End Function
  1210.  
  1211. Function cDisplayInactive() 'Brent Wright
  1212. strComputer = "."
  1213. Dim flag, colAccounts, objUser
  1214. Const ADS_UF_ACCOUNTDISABLE = &H0002
  1215.  
  1216. Set colAccounts = GetObject("WinNT://" & strComputer & "")
  1217. colAccounts.Filter = Array("user")
  1218. For Each objUser In colAccounts
  1219. if objUser.UserFlags and ADS_UF_ACCOUNTDISABLE then
  1220. Wscript.Echo objUser.Name
  1221. WScript.Echo ""
  1222. else
  1223. end if
  1224. Next
  1225. WScript.Echo ""
  1226. WScript.Echo ""
  1227. End Function
  1228.  
  1229. Function OS() 'Brent Wright
  1230. strComputer = "."
  1231. Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
  1232. Set colItems = objWMI.ExecQuery("SELECT * FROM Win32_OperatingSystem",,48)
  1233.  
  1234. For Each objItem in colItems
  1235. Wscript.Echo objItem.Caption
  1236. Next
  1237. End Function
  1238.  
  1239. Function Directory() 'Brent Wright
  1240. Set Shell = CreateObject("WScript.Shell")
  1241. Set fso = CreateObject("Scripting.FileSystemObject")
  1242.  
  1243. Shell.CurrentDirectory = FSO.GetParentFolderName(Wscript.ScriptFullName)
  1244. WScript.Echo Shell.CurrentDirectory
  1245. End Function
  1246.  
  1247. Function Path() 'Brent Wright
  1248. Dim pathing
  1249. Set fso = CreateObject("Scripting.FileSystemObject")
  1250.  
  1251. pathing = fso.GetAbsolutePathName("finalmenu.vbs")
  1252. WScript.Echo pathing
  1253. End Function
  1254.  
  1255. Function addentry()
  1256.  
  1257. Dim SERVER, DOMAIN, LOCATION, TOTALSIZE, USERS, STATICIP, COST
  1258.  
  1259. Const SERVERDICT = 0
  1260.  
  1261. Const DOMAINDICT = 1
  1262.  
  1263. const LOCATIONDICT = 2
  1264.  
  1265. const TOTALSIZEDICT = 3
  1266.  
  1267. const USERSDICT = 4
  1268.  
  1269. const STATICIPDICT = 5
  1270.  
  1271. Const COSTDICT = 6
  1272.  
  1273. Dim objDict
  1274.  
  1275.  
  1276.  
  1277. Set objDict = CreateObject("Scripting.Dictionary")
  1278.  
  1279.  
  1280.  
  1281. WScript.StdOut.Write "Enter server name: "
  1282.  
  1283. SERVER = WScript.StdIn.ReadLine
  1284.  
  1285. WScript.StdOut.Write "Enter domain name: "
  1286.  
  1287. DOMAIN = WScript.StdIn.ReadLine
  1288.  
  1289. WScript.StdOut.Write "Enter location: "
  1290.  
  1291. LOCATION = WScript.StdIn.ReadLine
  1292.  
  1293. WScript.StdOut.Write "Enter total disk size(GB): "
  1294.  
  1295. TOTALSIZE = WScript.StdIn.ReadLine
  1296.  
  1297. WScript.StdOut.Write "Enter total users: "
  1298.  
  1299. USERS = WScript.StdIn.ReadLine
  1300.  
  1301. WScript.StdOut.Write "Enter static IP: "
  1302.  
  1303. STATICIP = WScript.StdIn.ReadLine
  1304.  
  1305. WScript.StdOut.Write "Enter cost: "
  1306.  
  1307. COST = WScript.StdIn.ReadLine
  1308.  
  1309. Dim strItemAdd(7)
  1310.  
  1311. Dim strKey
  1312.  
  1313.  
  1314.  
  1315. ' Populate the list, using phone number as the key.
  1316.  
  1317. ' Add values to temp array, then add temp array to dictionary.
  1318.  
  1319.  
  1320.  
  1321. strItemAdd(SERVERDICT) = SERVER
  1322.  
  1323. strItemAdd(DOMAINDICT) = DOMAIN
  1324.  
  1325. strItemAdd(LOCATIONDICT) = LOCATION
  1326.  
  1327. strItemAdd(TOTALSIZEDICT) = TOTALSIZE
  1328.  
  1329. strItemAdd(USERSDICT) = USERS
  1330.  
  1331. strItemAdd(STATICIPDICT) = STATICIP
  1332.  
  1333. strItemAdd(COSTDICT) = COST
  1334.  
  1335.  
  1336.  
  1337. ' key is Server Name
  1338.  
  1339. strKey = strItemAdd(SERVERDICT)
  1340.  
  1341.  
  1342.  
  1343. ' add to the dictionary where strItemAdd is an array
  1344.  
  1345. objDict.Add strKey, strItemAdd
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351. 'menu()
  1352.  
  1353. End Function
  1354.  
  1355.  
  1356.  
  1357. function display()
  1358.  
  1359. Dim n,keys,k,v,i,strItemRead, objdict
  1360.  
  1361.  
  1362.  
  1363. n = objDict.Count
  1364.  
  1365. keys = objDict.Keys()
  1366.  
  1367.  
  1368.  
  1369. for i=0 to n-1
  1370.  
  1371. k = keys(i)
  1372.  
  1373. If objDict.Exists(k) Then
  1374.  
  1375. strItemRead = objDict.Item(k)
  1376.  
  1377. Wscript.echo vbNewLine & _
  1378.  
  1379. "Server Name : " & strItemRead(0) & vbNewLine & _
  1380.  
  1381. "Domain Name : " & strItemRead(1) & vbNewLine & _
  1382.  
  1383. "Location : " & strItemRead(2) & vbNewLine & _
  1384.  
  1385. "Total Disk Size: " & strItemRead(3) & vbNewLine & _
  1386.  
  1387. "Total Users : " & strItemRead(4) & vbNewLine &_
  1388.  
  1389. "Static IP: " & strItemRead(5) & vbNewLine & _
  1390.  
  1391. "Cost: " & strItemRead(6) & vbNewLine
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397. End If
  1398.  
  1399. next
  1400.  
  1401. End function
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407. Function delentry()
  1408.  
  1409.  
  1410.  
  1411. End Function
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419. 'Software
  1420.  
  1421. Function option3()
  1422.  
  1423. WScript.Echo "What would you like to do?"
  1424.  
  1425. WScript.Echo "1. List installed software"
  1426.  
  1427. WScript.Echo "2. Delete software"
  1428.  
  1429. WScript.Echo "3. Install software"
  1430.  
  1431. suboption = WScript.StdIn.ReadLine
  1432.  
  1433.  
  1434.  
  1435. Select Case suboption
  1436.  
  1437. Case "1"
  1438.  
  1439. listsoftware()
  1440.  
  1441. Case "2"
  1442.  
  1443. delsoftware()
  1444.  
  1445. Case "3"
  1446.  
  1447. installsoftware()
  1448.  
  1449. End Select
  1450.  
  1451. end function
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457. Function listsoftware()
  1458.  
  1459. Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
  1460.  
  1461. dim strcomputer, strkey, strentry1a, strentry1b, strentry2,strentry3,strentry4,strentry5, obj reg, strsubkey, arrsubkeys
  1462.  
  1463. strComputer = "."
  1464.  
  1465. strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
  1466.  
  1467. strEntry1a = "DisplayName"
  1468.  
  1469. strEntry1b = "QuietDisplayName"
  1470.  
  1471. strEntry2 = "InstallDate"
  1472.  
  1473. strEntry3 = "VersionMajor"
  1474.  
  1475. strEntry4 = "VersionMinor"
  1476.  
  1477. strEntry5 = "EstimatedSize"
  1478.  
  1479.  
  1480.  
  1481. Set objReg = GetObject("winmgmts://" & strComputer & _
  1482.  
  1483. "/root/default:StdRegProv")
  1484.  
  1485. objReg.EnumKey HKLM, strKey, arrSubkeys
  1486.  
  1487. WScript.Echo "Installed Applications" & VbCrLf
  1488.  
  1489. For Each strSubkey In arrSubkeys
  1490.  
  1491. intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _
  1492.  
  1493. strEntry1a, strValue1)
  1494.  
  1495. If intRet1 <> 0 Then
  1496.  
  1497. objReg.GetStringValue HKLM, strKey & strSubkey, _
  1498.  
  1499. strEntry1b, strValue1
  1500.  
  1501. End If
  1502.  
  1503. If strValue1 <> "" Then
  1504.  
  1505. WScript.Echo VbCrLf & "Display Name: " & strValue1
  1506.  
  1507. End If
  1508.  
  1509. objReg.GetStringValue HKLM, strKey & strSubkey, _
  1510.  
  1511. strEntry2, strValue2
  1512.  
  1513. If strValue2 <> "" Then
  1514.  
  1515. WScript.Echo "Install Date: " & strValue2
  1516.  
  1517. End If
  1518.  
  1519. objReg.GetDWORDValue HKLM, strKey & strSubkey, _
  1520.  
  1521. strEntry3, intValue3
  1522.  
  1523. objReg.GetDWORDValue HKLM, strKey & strSubkey, _
  1524.  
  1525. strEntry4, intValue4
  1526.  
  1527. If intValue3 <> "" Then
  1528.  
  1529. WScript.Echo "Version: " & intValue3 & "." & intValue4
  1530.  
  1531. End If
  1532.  
  1533. objReg.GetDWORDValue HKLM, strKey & strSubkey, _
  1534.  
  1535. strEntry5, intValue5
  1536.  
  1537. If intValue5 <> "" Then
  1538.  
  1539. WScript.Echo "Estimated Size: " & Round(intValue5/1024, 3) & " megabytes"
  1540.  
  1541. End If
  1542.  
  1543. Next
  1544.  
  1545. End Function
  1546.  
  1547.  
  1548.  
  1549. Function delsoftware()
  1550.  
  1551. dim strcomputer, software, colSoftware, objWMIService, objSoftware
  1552.  
  1553. strComputer = "."
  1554.  
  1555. WScript.Echo "What software would you like to remove?"
  1556.  
  1557. software = WScript.StdIn.ReadLine
  1558.  
  1559. Set objWMIService = GetObject("winmgmts:" _
  1560.  
  1561. & "{impersonationLevel=impersonate}!\\" _
  1562.  
  1563. & strComputer & "\root\cimv2")
  1564.  
  1565. Set colSoftware = objWMIService.ExecQuery _
  1566.  
  1567. ("Select * from Win32_Product " _
  1568.  
  1569. & "Where Name =" & software)
  1570.  
  1571. For Each objSoftware in colSoftware
  1572.  
  1573. objSoftware.Uninstall()
  1574.  
  1575. Next
  1576.  
  1577. End Function
  1578.  
  1579.  
  1580.  
  1581. Function installsoftware()
  1582.  
  1583.  
  1584.  
  1585. End Function
  1586.  
  1587.  
  1588. function drivesize()
  1589.  
  1590. strComputer = "."
  1591.  
  1592. Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
  1593.  
  1594. Set colVolumes = objWMIService.ExecQuery("Select * from Win32_Volume")
  1595.  
  1596. For Each objVolume in colVolumes
  1597.  
  1598. Set oXL = Wscript.CreateObject("Excel.Application")
  1599.  
  1600.  
  1601.  
  1602. ' Ensure that its visible to the end-user
  1603.  
  1604. oXL.Visible = TRUE
  1605.  
  1606.  
  1607.  
  1608. ' Add a workbook
  1609.  
  1610. oXL.WorkBooks.Add
  1611.  
  1612.  
  1613.  
  1614. For i=0 to colVolumes.Count-1
  1615.  
  1616. freespace(i) = objVolume.FreeSpace / 1024
  1617.  
  1618. freespaceper(i) = objVolume.FreeSpacePercent
  1619.  
  1620. volname(i) = objVolume.VolumeName
  1621.  
  1622. volsize(i) = objVolume.VolumeSize / 1024
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628. Next
  1629.  
  1630. j = i + 2
  1631.  
  1632. oXL.Cells(1,1).Value = "Drive name:"
  1633.  
  1634. oXL.Cells(2,1).Value = "Volume size:"
  1635.  
  1636. oXL.Cells(3,1).Value = "Free space:"
  1637.  
  1638. oXL.Cells(1,j).Value = volname(i)
  1639.  
  1640. oXL.Cells(2,j).Value = volsize(i)
  1641.  
  1642. oXL.Cells(2,j).Value = freespace(i)
  1643.  
  1644. Next
  1645.  
  1646. For i = 0 to colVolumes.Count-1
  1647.  
  1648. If freespaceper > 29 then
  1649.  
  1650. WScript.Echo "Volume name: " & volname(i)
  1651.  
  1652. Else
  1653.  
  1654. WScript.Echo "All drives have less than 30% free space"
  1655.  
  1656. End If
  1657.  
  1658. Next
  1659.  
  1660. end function
  1661.  
  1662.  
  1663.  
  1664. function folderprop()
  1665.  
  1666. dim foldername, i, colFolders
  1667.  
  1668. WScript.Echo "Please enter a folder name(absolute path): "
  1669.  
  1670. foldername = WScript.StdIn.ReadLine
  1671.  
  1672. Set fso = CreateObject("Scripting.FileSystemObject")
  1673.  
  1674. Set ObjFolder = fso.GetFolder(foldername)
  1675.  
  1676. Set ObjFiles = ObjFolder.Files
  1677.  
  1678. For Each ObjFile In ObjFiles
  1679.  
  1680. WScript.Echo ObjFile.Name & String(50 - Len(ObjFile.Name), " ") & ObjFile.Path
  1681.  
  1682. Next
  1683.  
  1684. dim foldernames(100), drivename
  1685.  
  1686. strComputer = "."
  1687.  
  1688. Set objWMIService = GetObject("winmgmts:" _
  1689.  
  1690. & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  1691.  
  1692. Set colFolders = objWMIService.ExecQuery("Select * from Win32_Directory")
  1693.  
  1694. For Each objFolder in colFolders
  1695.  
  1696. for i = 0 to colFolders.Count - 1
  1697.  
  1698. foldernames(i)=objFolder.Name
  1699.  
  1700. Next
  1701.  
  1702. Next
  1703.  
  1704. WScript.Echo "Please enter the drive name: "
  1705.  
  1706. drivename = WScript.StdIn.ReadLine
  1707.  
  1708. Set objFSO = CreateObject("Scripting.FileSystemObject")
  1709.  
  1710. Set objFolder = objFSO.GetFolder(drivename)
  1711.  
  1712. foldersizemb = objFolder.Size * 1024
  1713.  
  1714. if foldersizemb > 9 then
  1715.  
  1716. for i = 0 to colFolders.Count - 1
  1717.  
  1718. WScript.Echo "Folder name: " & foldernames(i)
  1719.  
  1720. Next
  1721.  
  1722. End If
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732. end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement