home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

Creating a logfile within vbs script

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2114
Discussions: 200,973, Posts: 2,379,785, Members: 246,336
Old April 9th, 2003, 10:50 AM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Apr 2003
Posts: 1
Wink
Creating a logfile within vbs script

I'm trying to create a logfile on a remote machine that receives errors or success's on the install or removal of software remotely.
Here is the script I have and it does work just need to add a logfile to it. Any help would be great. I'm about 1 year new to programming ie. c++, perl, vbs.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name = 'Software'")
For Each objSoftware in colSoftware
objSoftware.Uninstall()
Next
williamsr is offline   Reply With Quote
Old April 9th, 2003, 10:37 PM     #2 (permalink)
Not Really a Member
 
Join Date: Oct 2001
Posts: 25,398
Code:
Dim objFSO
dim objOutFile
Dim sWorkingFileName
Const FOR_APPENDING = 8
sWorkingFileName = "\\servername\sharename\logfilename.txt"

If objFSO.FileExists(sWorkingFileName) Then
  Set objOutFile = objFSO.OpenTextFile(sWorkingFileName, FOR_APPENDING)
Else
  Set objOutFile = objFSO.CreateTextFile(sWorkingFileName)
End If

objOutFile.WriteLine "STUFF TO LOG"
This script will check for the existence of the log, if it does exist, it will append more information. If it does not exist, it will create a new one

Welcome to TechIMO
__________________
Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.

Last edited by vass0922 : April 9th, 2003 at 10:42 PM.
vass0922 is online now   Reply With Quote
Old April 9th, 2003, 11:31 PM     #3 (permalink)
Member
 
Join Date: Sep 2002
Posts: 364
Yes welcome. We need more people in this forum!
Creosote is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Charges against non-tippers dropped.. (8)
Is It Just Me? (3060)
The disrespect of Obama by Russian .. (49)
Delete an OS (16)
Nvidia GTX 260 problem (8)
Laptop with wireless problem. (12)
Wireless Televisions. (12)
CPU fan stops spinning randomly (11)
windows vista security holes (17)
Regular Build (11)
Point and Shoot Camera Suggestions. (7)
windows 7 problem (7)
Internet Lost (5)
Multiple Restarts Required at Boot (5)
Recent Discussions
Multiple Restarts Required at Boot (5)
Point and Shoot Camera Suggestions. (7)
Delete an OS (16)
cell phone won't work (0)
Nvidia GTX 260 problem (8)
Is the PSU I received dead? (15)
Can't open Word (12)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (37)
Steam ID's, Gamertags etc... (4)
Games, Cables, PCI cards, and more fo.. (6)
Dept. of HS: NSA 'Helped' Develop Vis.. (17)
Linksys WMP54GS wireless card problem.. (5)
windows vista security holes (17)
Help getting around port 80 for camer.. (5)
Skillsoft Network+ Study Software Que.. (10)
Browsers wont load websites (3)
help me pls laptop just stopped worki.. (0)
Open With ..... Win7 (3)
Laptop with wireless problem. (12)
Internet Lost (5)
virus blocking exe. files (1)
CPU fan stops spinning randomly (11)
Modern Warfare 2: Who Bought It? (65)
Print spooler problem (16)
Kingston Bluetooth Dongle Driver (1)


All times are GMT -4. The time now is 11:15 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28