Acties:
  • 0 Henk 'm!

  • F.West98
  • Registratie: Juni 2009
  • Laatst online: 08:13

F.West98

Alweer 16 jaar hier

Topicstarter
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:
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


Acties:
  • 0 Henk 'm!

  • Duinkonijn
  • Registratie: Augustus 2001
  • Laatst online: 21:47

Duinkonijn

Huh?

Met het programma wscript kan je scripts starten

start C:\Windows\System32\wscripts.exe aaa.vbs //H:Wscript of Cscript

[ Voor 5% gewijzigd door Duinkonijn op 24-08-2010 22:01 ]

Het is makkelijk om iemand zijn negatieve eigenschappen te benoemen, maar kan je ook de positieve eigenschappen benoemen?


Acties:
  • 0 Henk 'm!

  • F.West98
  • Registratie: Juni 2009
  • Laatst online: 08:13

F.West98

Alweer 16 jaar hier

Topicstarter
Duinkonijn schreef op dinsdag 24 augustus 2010 @ 22:00:
Met het programma wscript kan je scripts starten

start C:\Windows\System32\wscripts.exe aaa.vbs //H:Wscript of Cscript
dus hoe moet dat precies in mijn .bat?
start (C: nogwat) (naam bestand).vbs en dan?

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


Acties:
  • 0 Henk 'm!

  • Pinooo
  • Registratie: Januari 2007
  • Laatst online: 22:17
cscript <pad+naam van vbs file>

Acties:
  • 0 Henk 'm!

  • F.West98
  • Registratie: Juni 2009
  • Laatst online: 08:13

F.West98

Alweer 16 jaar hier

Topicstarter
bedankt,

nu de vragen over de vbs-code nog...

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


Acties:
  • 0 Henk 'm!

  • Duinkonijn
  • Registratie: Augustus 2001
  • Laatst online: 21:47

Duinkonijn

Huh?

een delay of sleep kan je maken door een vbs file te starten die slaapt

of http://www.sleepcmd.com of zo iets.(geen ervaring overigens met dit programma)

wat bedoel je met regel 17
overigens begin je commentaar in cmd/bat/dos met REM

[ Voor 20% gewijzigd door Duinkonijn op 24-08-2010 23:03 ]

Het is makkelijk om iemand zijn negatieve eigenschappen te benoemen, maar kan je ook de positieve eigenschappen benoemen?


Acties:
  • 0 Henk 'm!

  • F.West98
  • Registratie: Juni 2009
  • Laatst online: 08:13

F.West98

Alweer 16 jaar hier

Topicstarter
Duinkonijn schreef op dinsdag 24 augustus 2010 @ 23:02:
een delay of sleep kan je maken door een vbs file te starten die slaapt

of http://www.sleepcmd.com of zo iets.(geen ervaring overigens met dit programma)

wat bedoel je met regel 17
overigens begin je commentaar in cmd/bat/dos met REM
maar wacht het .bat dan tot de .vbs klaar is?
dan heb ik alleen nog maar iets over de .vbs-file:
F.West98 schreef op dinsdag 24 augustus 2010 @ 21:29:
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:
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?

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


Acties:
  • 0 Henk 'm!

  • alt-92
  • Registratie: Maart 2000
  • Niet online
Je wil dus eigenlijk de Yes/No vraag vanaf regel 43 eruit hebben?

ik heb een 864 GB floppydrive! - certified prutser - the social skills of a thermonuclear device


Acties:
  • 0 Henk 'm!

  • F.West98
  • Registratie: Juni 2009
  • Laatst online: 08:13

F.West98

Alweer 16 jaar hier

Topicstarter
ja, en het automatisch rebooten als dat nodig zou zijn, dat heb ik er ook graag uit, alleen zie ik door de bomen het bos niet meer...
Gaat 'ie dan met een opdrachtregel?
Hij gaat dan in het CMD-venster Cscript uitvoeren en als 'ie klaar is gaat 'ie verder met de volgende taak...
Hoe krijg ik dan voor elkaar dat als ik zeg:
code:
1
start ccleaner.exe /AUTO
dat 'ie dan niet wacht tot 'ie klaar is?
Daarom moet ik die ping 127.0.0.0 -n ... doen...

[ Voor 32% gewijzigd door F.West98 op 25-08-2010 11:35 ]

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


Acties:
  • 0 Henk 'm!

  • TheRookie
  • Registratie: December 2001
  • Niet online

TheRookie

Nu met R1200RT

Yes/No niet vragen = Regel 44 t/m 49 verwijderen.

Het niet automatisch rebooten na een specifieke update is een command line parameter: /norestart (of /z)
Kan ook met een group policy, maar die moet per pc ingesteld zijn

wachten tot gestartte applicatie klaar is:
code:
1
2
3
4
5
6
7
8
C:\>start /?
Starts a separate window to run a specified program or command.

START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/WAIT] [/B] [command/program]
      [parameters]
    WAIT        Start application and wait for it to terminate

[ Voor 53% gewijzigd door TheRookie op 25-08-2010 11:40 . Reden: wachten ]


Acties:
  • 0 Henk 'm!

  • F.West98
  • Registratie: Juni 2009
  • Laatst online: 08:13

F.West98

Alweer 16 jaar hier

Topicstarter
TheRookie schreef op woensdag 25 augustus 2010 @ 11:37:
Yes/No niet vragen = Regel 44 t/m 49 verwijderen.

Het niet automatisch rebooten na een specifieke update is een command line parameter: /norestart (of /z)
Kan ook met een group policy, maar die moet per pc ingesteld zijn

wachten tot gestartte applicatie klaar is:
code:
1
2
3
4
5
6
7
8
C:\>start /?
Starts a separate window to run a specified program or command.

START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/WAIT] [/B] [command/program]
      [parameters]
    WAIT        Start application and wait for it to terminate
bedankt, dan wordt die ping overbodig

dus het script wordt zo?
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
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 "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

waarachter moet die /norestart dan?

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


Acties:
  • 0 Henk 'm!

  • TheRookie
  • Registratie: December 2001
  • Niet online

TheRookie

Nu met R1200RT

regel 62 moet ook nog weg.
Zie nu dat er van de Windows Update Agent API gebruik gemaakt wordt, daar ben ik verder niet bekend mee...

Acties:
  • 0 Henk 'm!

  • F.West98
  • Registratie: Juni 2009
  • Laatst online: 08:13

F.West98

Alweer 16 jaar hier

Topicstarter
ik denk zelf dat ik regel 52-53 moet verwijderen, alleen nog op zoek naar een bevesiging...

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


Acties:
  • 0 Henk 'm!

  • alt-92
  • Registratie: Maart 2000
  • Niet online
Wat let je om zelf je scripts te gaan debuggen met een editor als VBSedit ofzo?

Kom, beetje minder afwachtend mag ook :)

ik heb een 864 GB floppydrive! - certified prutser - the social skills of a thermonuclear device

Pagina: 1