Elven
05-02-2015, 12:36
Было дело спрашивал (http://forum.oszone.net/thread-275470.html) как прочитать файл на vbs в переменную. Тогда скрипт отработал свое на "ура", а теперь, почему-то не хочет. Вроде как в пьяном угаре ничего не менял, но мало ли.
В общем теперь почему-то переменная возвращает "1" (без кавычек)
Просьба указать где я не прав.
01 Option Explicit
02 Dim strSourceFile
03 Dim oShell
04 Dim objFSO
05 Dim strLine
06
07 Set oShell = WScript.CreateObject("WScript.Shell")
08
09 strSourceFile = "IP.txt"
10
11 With WScript.CreateObject("Scripting.FileSystemObject")
12 If .FileExists(strSourceFile) Then
13 With .OpenTextFile(strSourceFile)
14 Do Until .AtEndOfStream
15 strLine = .ReadLine()
16
17 oShell.Run "putty.exe"
18 WScript.Sleep 300
19 oShell.SendKeys strLine
20 WScript.Sleep 300
21 oShell.SendKeys "%g"
22 WScript.Sleep 300
23 oShell.SendKeys "{DOWN}"
24 WScript.Sleep 300
25 oShell.SendKeys "%l"
26 WScript.Sleep 300
27 oShell.SendKeys "%f" & "D:\logs\&H.log"
28 WScript.Sleep 300
29 oShell.SendKeys "%o"
30 WScript.Sleep 3000
31 oShell.SendKeys "user" & chr(13)
32 WScript.Sleep 300
33 oShell.SendKeys "P@$$w0rd" & chr(13)
34 WScript.Sleep 300
35 oShell.SendKeys "show ver | inc Serial" & chr(13)
36 WScript.Sleep 300
37 oShell.SendKeys "exit" & chr(13)
38
39
40 Loop
41
42 .Close
43 End With
44 Else
45 WScript.Echo "Can't find [" & strSourceFile & "]."
46 WScript.Quit 1
47 End If
48 End With
49
50 WScript.Quit 0
В общем теперь почему-то переменная возвращает "1" (без кавычек)
Просьба указать где я не прав.
01 Option Explicit
02 Dim strSourceFile
03 Dim oShell
04 Dim objFSO
05 Dim strLine
06
07 Set oShell = WScript.CreateObject("WScript.Shell")
08
09 strSourceFile = "IP.txt"
10
11 With WScript.CreateObject("Scripting.FileSystemObject")
12 If .FileExists(strSourceFile) Then
13 With .OpenTextFile(strSourceFile)
14 Do Until .AtEndOfStream
15 strLine = .ReadLine()
16
17 oShell.Run "putty.exe"
18 WScript.Sleep 300
19 oShell.SendKeys strLine
20 WScript.Sleep 300
21 oShell.SendKeys "%g"
22 WScript.Sleep 300
23 oShell.SendKeys "{DOWN}"
24 WScript.Sleep 300
25 oShell.SendKeys "%l"
26 WScript.Sleep 300
27 oShell.SendKeys "%f" & "D:\logs\&H.log"
28 WScript.Sleep 300
29 oShell.SendKeys "%o"
30 WScript.Sleep 3000
31 oShell.SendKeys "user" & chr(13)
32 WScript.Sleep 300
33 oShell.SendKeys "P@$$w0rd" & chr(13)
34 WScript.Sleep 300
35 oShell.SendKeys "show ver | inc Serial" & chr(13)
36 WScript.Sleep 300
37 oShell.SendKeys "exit" & chr(13)
38
39
40 Loop
41
42 .Close
43 End With
44 Else
45 WScript.Echo "Can't find [" & strSourceFile & "]."
46 WScript.Quit 1
47 End If
48 End With
49
50 WScript.Quit 0