Solved

WScript.Arguments question

Posted on 2006-10-27
2
1,885 Views
Last Modified: 2013-12-25
this script will output my Arguments to a msgbox.
I'm tryingto figure out how(if there is a way) to have it save/output it to a file(txt) instead.

Thanks in advance,

'=============================================
Option Explicit
Dim vArg, aArgs(), iCount
If WScript.Arguments.Count = 0 then
MsgBox "No Arguments Supplied"
WScript.Quit
Else
ReDim aArgs(WScript.Arguments.Count - 1)
For iCount = 0 to WScript.Arguments.Count - 1
aArgs(iCount) = WScript.Arguments(iCount)
MsgBox aArgs(iCount)
Next
End If

Dim oShell, sLogEntry
Set oShell = CreateObject("WScript.Shell")
sLogEntry = "Script was run with :"
For iCount = 0 to UBound(aArgs)
sLogEntry = sLogEntry & vbCrLf & aArgs(iCount)
Next
oShell.LogEvent 4, sLogEntry
'==========================================

~Koolage
0
Comment
Question by:koolage
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 17821578
Something like...

Option Explicit

Dim vArg, aArgs(), iCount
If WScript.Arguments.Count = 0 then
    MsgBox "No Arguments Supplied"
    WScript.Quit
End If

Dim sLogEntry
sLogEntry = "Script was run with :" & vbCrLf
For iCount = 0 to WScript.Arguments.Count - 1
    sLogEntry = sLogEntry & WScript.Arguments(iCount) & vbCrLf
Next

Const ForReading = 1, ForWriting = 2
Dim fileName, fso, f
fileName = "c:\someFile.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(fileName, ForWriting, True)
f.Write(sLogEntry)  
f.Close
0
 

Author Comment

by:koolage
ID: 17834127
Thanks! just want I was  looking for.
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question