Login | |
|
 |
RE: How to invoke .bat file???? - 6/28/2007 5:06:04 AM
|
|
 |
|
| |
ebgreen
Posts: 5035
Score: 31
Joined: 7/12/2005
Status: online
|
Well if you just want to know how to implement conditional logic based on text, look at the WSH documentation for: InStr If - Then Select - Case Most of the examples are based on text.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: How to invoke .bat file???? - 6/28/2007 7:32:11 AM
|
|
 |
|
| |
ebgreen
Posts: 5035
Score: 31
Joined: 7/12/2005
Status: online
|
First, if you need the contents of a file in an array you can do it like this: Dim arrFileLines Dim WshShell Dim oExec Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("C:\Scripts\New.txt", 1) arrFileLines = Split(objFile.ReadAll(), vbCrLf) objFile.Close For l = Ubound(arrFileLines) to LBound(arrFileLines) Step -1 Wscript.Echo arrFileLines(l) Next You need to remember that VBScript arrays start their numbering at 0. So the first line of the file is actaully arrFileLines(0). So try this: If arrFileLines(0)="LoadCubes ON " Then Set WshShell = wscript.createobject("Wscript.Shell") Set oExec = WshShell.Run ("c:\Scripts\RUNIT.bat") Else MsgBox "LoadCubes Value is set to OFF" End If
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: How to invoke .bat file???? - 6/29/2007 12:59:50 AM
|
|
 |
|
| |
ebgreen
Posts: 5035
Score: 31
Joined: 7/12/2005
Status: online
|
When you go through and show the lines from the file you are doing it backwards. That is what the Step - 1 does. So the line that you are interestaed in is actually the 7th line in the file. When you put it in the array since the aray starts counting at 0, you are interested in index 6. So change this line: If arrFileLines(0)="LoadCubes ON " Then To this: If arrFileLines(6)="LoadCubes ON " Then Also, the tex line looks like it has some white space at the beginning (tabs or spaces) so it will never exactly equal "LoadCubes ON " because you don't include the spaces in your test. That means that this line: If arrFileLines(6)="LoadCubes ON " Then should be something like: If arrFileLines(6)=" LoadCubes ON " Then So that the white space is part of the test.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: How to invoke .bat file???? - 7/1/2007 7:06:19 PM
|
|
 |
|
| |
4scriptmoni
Posts: 208
Score: 0
Joined: 5/3/2007
Status: offline
|
In the Part 2, set a wscript.echo "part2" so you know when its at least getting there, I think your if statement or even case is wrong, I usually do If Instr(strText, "load on") > 0 Then wscript.echo "Got it" end if hum.. i am not 100% that this would work because Instr should be used withing a string not array, but you can always do array(i)=strText do the if here. anyways check more info in InStr http://www.w3schools.com/vbscript/func_instr.asp Maybe the spaces of the array is a problem for the if statement? cheers,
_____________________________
Enterprise Microsoft Scripts Exchange, Login/Logout Monitor,TS, Monitoring, Security, AD, etc... http://www.felipeferreira.net
|
|
| |
|
|
|
|
|