Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Why does this not work on NT4 SP6a?

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2269
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Why does this not work on NT4 SP6a?
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Why does this not work on NT4 SP6a? - 3/7/2005 2:47:05 AM   
  Invalid Character

 

Posts: 2
Score: 0
Joined: 3/7/2005
From:
Status: offline
The script creates the INI file, but does not populate it, even though the directory contains files and has a modified date. This script works on all other platforms.
_________________________________________________________

Option Explicit

Dim fso
Dim wshShell
Dim oExec
Dim sCmd
Dim sCurrentLine
Dim sStartFldr
Dim sCurrentFldr
Dim sPath
Dim sIniFile
Dim oIniFile
Dim arDateString

'* Create objects to access the file system and Windows shell
Set fso = CreateObject("Scripting.FileSystemObject")
Set wshShell = CreateObject("WScript.Shell")

'* Create an INI file called NetscapeMail.ini which the custom inventory
'* collector will be able to query.
'* I am currently creating this under C:\Program Files\Netscape but this is
'* arbitrary and may need to be moved due to security restrictions etc.
'* SK - The INI file is now created within the IS Agent cache directory. - SK
'* It is also worth noting that C:\Program Files may be called something
'* different in non-English languages so some tests may need to be carried out
'* to determine the precise location.
'* Note: the file will overwrite any previous version.

sIniFile = "C:\Program Files\Altiris\ALTIRIS AGENT\Software Delivery\{01B54EB5-3679-4C73-9E10-E169D5A5EC59}\cache\NetscapeMail.ini"
Set oIniFile = fso.CreateTextFile(sIniFile, True)

'* The script uses an associated batch file called DirFind.bat that must be
'* in the same folder as this script.
'* The batch file runs the following command:
'*
'* Dir "C:\Program Files\Netscape\Users" /AD | Find "Mail"
'*
'* The following command uses the Exec method of the WshShell object
'* to pipe the results of the above command to standard output
'* where it can be parsed to retrieve the appropriate information.
'* SK - The DirFind.bat file is placed into the Inventory Solution directory on the NS. - SK

Set oExec = WshShell.Exec("C:\Program Files\Altiris\ALTIRIS AGENT\Software Delivery\{01B54EB5-3679-4C73-9E10-E169D5A5EC59}\cache\DirFind.bat")

'* Once the above command has been run, standard output should consist
'* of a number of lines, each containing just the folder name returned.
'* Each folder name can then be queried for the size and last modified date.

Do While Not oExec.StdOut.AtEndOfStream

'* Set an object reference to the current folder name so that we can
'* extract the folder attributes

sPath = "C:\Program Files\Netscape\Users\" & oExec.StdOut.ReadLine
Set sCurrentFldr = fso.GetFolder(sPath)

oIniFile.WriteLine "[Mail]"
oIniFile.WriteLIne "Size=" & sCurrentFldr.Size
oIniFile.WriteBlankLines 1
oIniFile.WriteLine "[DateLastModified]"

'* Split DateLastModified into Date and Time components

arDateString = Split(sCurrentFldr.DateLastModified)

oIniFile.WriteLine "Date=" & arDateString(0)
oIniFile.WriteLine "Time=" & arDateString(1)
oIniFile.WriteBlankLines 1

'* Destroy the object reference
Set sCurrentFldr = Nothing

Loop

'* Close the INI file when complete

oIniFile.Close

'* Ensure that all created objects are destroyed after use
Set oIniFile = Nothing
Set oExec = Nothing
Set wshShell = Nothing
Set fso = Nothing
 
 
Post #: 1
 
 Re: Why does this not work on NT4 SP6a? - 3/7/2005 2:51:05 AM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
What version of Windows Script Host do you have on the NT4 PC? If I am not mistaken exec requires version 5.6

(in reply to Invalid Character)
 
 
Post #: 2
 
 Re: Why does this not work on NT4 SP6a? - 3/7/2005 6:11:12 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
You may want to try replace the following line:

Set oExec = WshShell.Exec("C:\Program Files\Altiris\ALTIRIS AGENT\Software
Delivery\{01B54EB5-3679-4C73-9E10-E169D5A5EC59}\cache\DirFind.bat")

with:

Set oExec = WshShell.Exec("cmd /c ""C:\Program Files\Altiris\ALTIRIS AGENT\Software Delivery\{01B54EB5-3679-4C73-9E10-E169D5A5EC59}\cache\DirFind.bat""")

(in reply to Invalid Character)
 
 
Post #: 3
 
 Re: Why does this not work on NT4 SP6a? - 3/8/2005 2:29:55 AM   
  Invalid Character

 

Posts: 2
Score: 0
Joined: 3/7/2005
From:
Status: offline
I am using 5.6.8825 on my NT machine. Using the "cmd /c" bit does not work.

The thing that seems most strange to me is that this exact script works on 9x, 2K, XP, and 2K3 machines, just not NT.

(in reply to Invalid Character)
 
 
Post #: 4
 
 Re: Why does this not work on NT4 SP6a? - 3/8/2005 2:50:37 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
and the "" don't work either ?

You might want to first determine whether the statements within the loop are actually executed and work from there.

(in reply to Invalid Character)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Why does this not work on NT4 SP6a? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts