[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

WScript.Arguments question

Posted on 2006-10-27
2
Medium Priority
?
1,899 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

649 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