Hallo,
Een vraagje over een VBS-bestand, wat geopend wordt in CScript. Dit script heb ik van internet (microsoft) geplukt, het download automatisch updates, en installeert ze dan, het enige probleem is dat hij vraagt om toestemming om te installeren, en hij geeft steeds een melding als je het zonder opdrachtregel doet, dat is dus nog on-automatischer. Eerst het script:
Mijn vragen: hoe kan ik instellen dat het bestand niet meer vraagt om toestemming, maar automatisch installeert? Ik ben nogal een nul op programmeren.
Is het ook mogelijk om in te stellen dat de computer niet automatisch reboot na een update?
Zou het mogelijk zijn om dit script in een .bat bestandje te laten uitvoeren, dus:
en dat 'ie dus automatisch met opdrachtregel start, en dus ook aan mijn vragen voldoet?
Ik heb nl. volgend script, wat een computer helemaal schoonmaakt, zonder dat de gebruiker iets hoeft/kan doen:
er kunnen nu wat fouten inzitten, typ uit t hoofd, maar in weze werkt het perfect.
Commentaar:
Is er iets anders dan ping 127.0.0.0 om het .bat te vertragen met aangepaste tijd?
Kan ik dat vbs-bestand starten met opdrachtregel?
Dus vragen over 2 scriptjes die moeten worden samengevoegd, ik kom er niet meer uit.
Een vraagje over een VBS-bestand, wat geopend wordt in CScript. Dit script heb ik van internet (microsoft) geplukt, het download automatisch updates, en installeert ze dan, het enige probleem is dat hij vraagt om toestemming om te installeren, en hij geeft steeds een melding als je het zonder opdrachtregel doet, dat is dus nog on-automatischer. Eerst het script:
code:
1
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
| Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()
WScript.Echo "Searching for updates..." & vbCRLF
Set searchResult = _
updateSearcher.Search("IsInstalled=0 and Type='Software'")
WScript.Echo "List of applicable items on the machine:"
For I = 0 To searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
WScript.Echo I + 1 & "> " & update.Title
Next
If searchResult.Updates.Count = 0 Then
WScript.Echo "There are no applicable updates."
WScript.Quit
End If
WScript.Echo vbCRLF & "Creating collection of updates to download:"
Set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")
For I = 0 to searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
WScript.Echo I + 1 & "> adding: " & update.Title
updatesToDownload.Add(update)
Next
WScript.Echo vbCRLF & "Downloading updates..."
Set downloader = updateSession.CreateUpdateDownloader()
downloader.Updates = updatesToDownload
downloader.Download()
WScript.Echo vbCRLF & "List of downloaded updates:"
For I = 0 To searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
If update.IsDownloaded Then
WScript.Echo I + 1 & "> " & update.Title
End If
Next
Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")
WScript.Echo vbCRLF & _
"Creating collection of downloaded updates to install:"
For I = 0 To searchResult.Updates.Count-1
set update = searchResult.Updates.Item(I)
If update.IsDownloaded = true Then
WScript.Echo I + 1 & "> adding: " & update.Title
updatesToInstall.Add(update)
End If
Next
WScript.Echo vbCRLF & "Would you like to install updates now? (Y/N)"
strInput = WScript.StdIn.Readline
WScript.Echo
If (strInput = "N" or strInput = "n") Then
WScript.Quit
ElseIf (strInput = "Y" or strInput = "y") Then
WScript.Echo "Installing updates..."
Set installer = updateSession.CreateUpdateInstaller()
installer.Updates = updatesToInstall
Set installationResult = installer.Install()
'Output results of install
WScript.Echo "Installation Result: " & _
installationResult.ResultCode
WScript.Echo "Reboot Required: " & _
installationResult.RebootRequired & vbCRLF
WScript.Echo "Listing of updates installed " & _
"and individual installation results:"
For I = 0 to updatesToInstall.Count - 1
WScript.Echo I + 1 & "> " & _
updatesToInstall.Item(i).Title & _
": " & installationResult.GetUpdateResult(i).ResultCode
Next
End If |
Mijn vragen: hoe kan ik instellen dat het bestand niet meer vraagt om toestemming, maar automatisch installeert? Ik ben nogal een nul op programmeren.
Is het ook mogelijk om in te stellen dat de computer niet automatisch reboot na een update?
Zou het mogelijk zijn om dit script in een .bat bestandje te laten uitvoeren, dus:
code:
1
2
| cd [map bestand] start update.vbs |
en dat 'ie dus automatisch met opdrachtregel start, en dus ook aan mijn vragen voldoet?
Ik heb nl. volgend script, wat een computer helemaal schoonmaakt, zonder dat de gebruiker iets hoeft/kan doen:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| @echo off title Schoonmaken... start taskmgr.exe taskkill /f /im iexplore.exe taskkill /f /im winword.exe taskkill /f /im freecell.exe taskkill /f /im sol.exe taskkill /f /im explorer.exe (starten ccleaner, enz.) ping 127.0.0.0 -n 100 (delay oid werkte niet, het moest volautomatisch) @echo on cd C:\Program Files\Defraggler start df.exe C: ping 127.0.0.0 -n 500 (cd naar pad bestand en start bestand met een parameter zodat 'ie start in opdrachtprompt, welke??) @echo off start explorer.exe ping 127.0.0.0 -n 20 taskkill /f /im taskmgr.exe start iexplore.exe (locatie 'Schoonmaak voltooid'-bestand) @echo on |
er kunnen nu wat fouten inzitten, typ uit t hoofd, maar in weze werkt het perfect.
Commentaar:
Is er iets anders dan ping 127.0.0.0 om het .bat te vertragen met aangepaste tijd?
Kan ik dat vbs-bestand starten met opdrachtregel?
Dus vragen over 2 scriptjes die moeten worden samengevoegd, ik kom er niet meer uit.
2x Dell UP2716D | R9 7950X | 128GB RAM | 980 Pro 2TB x2 | RTX2070 Super
.oisyn: Windows is net zo slecht in commandline als Linux in GUI