|
|
JabNJolt

216.52.180.252
Joined on 6/18/2008
(GMT -06:00) Central Time (US & Canada)
|
Posted: 6/18/2008 3:36:29 PM
|
|
VBScript Output As Value:
I have the following VBScript in my SIF:
Const ServerName = "SERVER1" Const FilePath = "C$\Inetpub\WWWRoot\Citrix\MetaFrame\Conf\WebInterface.conf" Const ConfigString = "HideDomainField"
Dim FileLocation, FileSysObj, ConfigFile
FileLocation = "\\" & ServerName & "\" & FilePath Set FileSysObj = CreateObject("Scripting.FileSystemObject") Set ConfigFile = FileSysObj.OpenTextFile(FileLocation, 1)
Do Until ConfigFile.AtEndOfStream CurrentLine = Trim(ConfigFile.ReadLine)
If InStr(1, CurrentLine, ConfigString, VBTextCompare) Then WScript.Echo CurrentLine Exit Do End If Loop
ConfigFile.Close Set ConfigFile = Nothing Set FileSysObj = Nothing
WScript.Quit
How do I get the output (WScript.Echo portion) to show up as the current value?
For my Modifiers I have the following checked:
Output, OutputTrim
It does not show the current value and is NOTOK because of this.
If I look at the file I am searching the value I am looking for exists.
The VBScript works when run outside of Security Expressions.
|
|
|
Mike Taber

204.8.196.2
Joined on 8/15/2007
(GMT -05:00) Eastern Time (US & Canada)
|
Posted: 6/18/2008 3:40:32 PM
|
|
Re: VBScript Output As Value:
Can you post all of the parameters that you have set in this rule?
|
Founder - Moon River Consulting, Inc.
|
|
JabNJolt

216.52.180.252
Joined on 6/18/2008
(GMT -06:00) Central Time (US & Canada)
|
Posted: 6/18/2008 3:47:56 PM
|
|
Re: VBScript Output As Value:
Here is my SIF in text format:
[Info] Version=4.0 [Rule:New Rule] CheckType=EQ Check=Script Script=HideDomainField.Vbs Modifiers=Output,OutputTrim Remote=Yes Value=HideDomainField=On Description=%Value% [Filter:Default] Rules=CheckList [Group:CheckList] New Rule=1 [Script:HideDomainField.Vbs] Const ServerName = "SERVER1" Const FilePath = "C$\Inetpub\WWWRoot\Citrix\MetaFrame\Conf\WebInterface.conf" Const ConfigString = "HideDomainField"
Dim FileLocation, FileSysObj, ConfigFile
FileLocation = "\\" & ServerName & "\" & FilePath Set FileSysObj = CreateObject("Scripting.FileSystemObject") Set ConfigFile = FileSysObj.OpenTextFile(FileLocation, 1)
Do Until ConfigFile.AtEndOfStream CurrentLine = Trim(ConfigFile.ReadLine)
If InStr(1, CurrentLine, ConfigString, VBTextCompare) Then WScript.Echo CurrentLine Exit Do End If Loop
ConfigFile.Close Set ConfigFile = Nothing Set FileSysObj = Nothing
WScript.Quit
|
|
|
Mike Taber

66.152.217.123
Joined on 8/15/2007
(GMT -05:00) Eastern Time (US & Canada)
|
Posted: 6/18/2008 9:13:06 PM
|
|
Re: VBScript Output As Value:
Do the following:
1) Set the Exe parameter as follows: EXE=cscript.exe //NoLogo %%ScriptPath%%
2) Replace references to WScript.Echo with WScript.StdOut.WriteLine
3) Don't use the path to the file as //servername/C$/pathtofile/filename. Simply specify that it is C:\filepath\file.conf
There are a few problems with what you were doing. In #1, part of the issue is that Windows typically uses WScript.exe as the default vbs execution engine. Specifying cscript.exe allows you to take the output on the StdOut output stream.
The #2 fix helps bypass the same problem and simply forces the answer to be output on StdOut.
As for #3, you're executing this on a remote machine already, as you have Remote=Yes set. So, the path to the file doesn't need to be a UNC path. It can simply be stated as C:\pathToFile\file.conf. This will help get around pathing issues. Chances are good that it wouldn't work (especially if you were using the agent), as the agent would be running as LocalSystem. This means it can't access a network resource. Even though it's technically a local resource, specifying it as a network path might not work.
I did some testing and doing those three things fixed the issue and I was able to print out the contents of my test file, after creating a dummy file and putting data in it of course.
Let me know how that works out for you.
|
Founder - Moon River Consulting, Inc.
|
|
JabNJolt

216.52.180.252
Joined on 6/18/2008
(GMT -06:00) Central Time (US & Canada)
|
Posted: 6/19/2008 11:12:45 AM
|
|
Re: VBScript Output As Value:
Worked like a charm.
Only problem now is that even though the values are matching it still says NOTOK.
I do have Output, OutputStdOut, and OutputTrim checked.
|
|
|
Mike Taber

204.8.196.2
Joined on 8/15/2007
(GMT -05:00) Eastern Time (US & Canada)
|
Posted: 6/19/2008 2:26:10 PM
|
|
Re: VBScript Output As Value:
It could be a case sensitivity issue. Does your output match exactly or is the case off a bit? There might also be an issue with spaces before or after the equals sign in the configuration file.
|
Founder - Moon River Consulting, Inc.
|
|
JabNJolt

216.52.180.252
Joined on 6/18/2008
(GMT -06:00) Central Time (US & Canada)
|
Posted: 6/19/2008 2:41:54 PM
|
|
Re: VBScript Output As Value:
The output matches exactly what the value should be. To ensure it does match up I copied the exact string from the file I am checking and used that as the value. See below:
Current:
HideDomainField=On
Desired:
HideDomainField=On
Object:
cscript.exe //NOLOGO HideDomainField.Vbs
Fix action:
Run executable or script [output,outputstdout,outputtrim]
More information:
The rule indicates that the value should not or cannot be changed directly.
The same issue is present in another SIF that uses VBScript. The value and current match up but it also shows up as NOTOK. See below:
Current:
True
Desired:
True
Object:
cscript.exe //NOLOGO SMTPRelay.Vbs
Fix action:
Run executable or script [output,outputstdout,outputtrim]
More information:
The rule indicates that the value should not or cannot be changed directly.
|
|
|
JabNJolt

216.52.180.252
Joined on 6/18/2008
(GMT -06:00) Central Time (US & Canada)
|
Posted: 6/19/2008 2:47:39 PM
|
|
Re: VBScript Output As Value:
I just tried removing the spaces surrounding the "=" sign and that did not help either.
|
|
|
Mike Taber

64.253.52.186
Joined on 8/15/2007
(GMT -05:00) Eastern Time (US & Canada)
|
Posted: 6/19/2008 2:52:55 PM
|
|
Re: VBScript Output As Value:
Any particular reason you're using the OutputStdOut modifier? I rarely, if ever use that one. I know what it does, but it doesn't seem like it would be necessary here. Perhaps using it is masking another problem.
|
Founder - Moon River Consulting, Inc.
|
|
JabNJolt

216.52.180.252
Joined on 6/18/2008
(GMT -06:00) Central Time (US & Canada)
|
Posted: 6/19/2008 3:03:01 PM
|
|
Re: VBScript Output As Value:
I was just trying the different output options to see if it helped.
If I uncheck it it does not make a difference.
Current:
HideDomainField=On
Desired:
HideDomainField=On
Object:
cscript.exe //NOLOGO HideDomainField.Vbs
Fix action:
Run executable or script [output,outputtrim]
More information:
The rule indicates that the value should not or cannot be changed directly.
|
|
|
|