Hilfe, VB Script funktioniert nicht!
Hallo,
ich benötige bitte dringend Hilfe bei einem Script was ich schreiben soll.
Es geht hierbei um ein vbs script.
Gob gesagt:
Schleife
1. TXT Einlesen Bsp ServerListe.txt --> Diese soll Zeilenweise eingelesen werden mit einer Variable
2. Shutdown mit Variable (Servername der in der TXT steht) T:60
3. Sleep 60 sek. (wait)
do loop Schleife
Das ist der grobe Aufbau.
Ich komme jetzt an dem Punkt mit dem Shutdon nicht weiter.
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
FileName = "c:\Users\Administrator\Documents\ServerListe.txt"
Set objTextFile = objFSO.OpenTextFile(FileName, ForReading)
Do Until objTextFile.AtEndOfStream
ZeileTemp = objTextFile.Readline
wscript.echo ZeileTemp
Loop
objTextFile.Close
Bitte helft mir sonst verzweifle ich!
Danke schon mal im Vorraus.
Toerk0815
ich benötige bitte dringend Hilfe bei einem Script was ich schreiben soll.
Es geht hierbei um ein vbs script.
Gob gesagt:
Schleife
1. TXT Einlesen Bsp ServerListe.txt --> Diese soll Zeilenweise eingelesen werden mit einer Variable
2. Shutdown mit Variable (Servername der in der TXT steht) T:60
3. Sleep 60 sek. (wait)
do loop Schleife
Das ist der grobe Aufbau.
Ich komme jetzt an dem Punkt mit dem Shutdon nicht weiter.
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
FileName = "c:\Users\Administrator\Documents\ServerListe.txt"
Set objTextFile = objFSO.OpenTextFile(FileName, ForReading)
Do Until objTextFile.AtEndOfStream
ZeileTemp = objTextFile.Readline
wscript.echo ZeileTemp
Loop
objTextFile.Close
Bitte helft mir sonst verzweifle ich!
Danke schon mal im Vorraus.
Toerk0815
Please also mark the comments that contributed to the solution of the article
Content-Key: 215565
Url: https://administrator.de/contentid/215565
Printed on: April 26, 2024 at 21:04 o'clock
3 Comments
Latest comment
Hi. Was Dir noch fehlt steht zwischen den Zitaten
set objWsh = CreateObject( "WScript.Shell" )
Das machen wir so:
Filename = objWsh.ExpandEnvironmentStrings( "%userprofile%\Documents\ServerListe.txt" )
Oder noch besser sogar so - das kann dann auch mit Ordnerumleitung umgehen:
Filename = objWsh.SpecialFolders( "MyDocuments" ) & "\ServerListe.Txt"
(http://technet.microsoft.com/en-us/library/ee156616.aspx)
objWsh.Run( "shutdown -m \\" & ZeileTemp & " -t 60 -f .s" )
wscript.sleep 60000
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
set objWsh = CreateObject( "WScript.Shell" )
FileName = "c:\Users\Administrator\Documents\ServerListe.txt"
Das machen wir so:
Filename = objWsh.ExpandEnvironmentStrings( "%userprofile%\Documents\ServerListe.txt" )
Oder noch besser sogar so - das kann dann auch mit Ordnerumleitung umgehen:
Filename = objWsh.SpecialFolders( "MyDocuments" ) & "\ServerListe.Txt"
(http://technet.microsoft.com/en-us/library/ee156616.aspx)
Set objTextFile = objFSO.OpenTextFile(FileName, ForReading)
Do Until objTextFile.AtEndOfStream
ZeileTemp = objTextFile.Readline
wscript.echo ZeileTemp
Do Until objTextFile.AtEndOfStream
ZeileTemp = objTextFile.Readline
wscript.echo ZeileTemp
objWsh.Run( "shutdown -m \\" & ZeileTemp & " -t 60 -f .s" )
wscript.sleep 60000
Loop
objTextFile.Close
objTextFile.Close