I need a vb script that will do the following
Ask a question
If they say yes
Ask another question
If they say yes
Write to a log file this echo %username%,%computername%,%time%,%date%
This can be with the msgbox variable with vbscript.
I jusy can not figure out how.
Anyone have any advice?
VB Sciprt HELR!!!
-
- Way too much time!
- Posts: 1673
- Joined: July 16, 2004, 11:02 am
- Location: Royal Palm Beach, FL
Re: VB Sciprt HELR!!!
just like this:
if msgbox("question 1?", vbYesNo)=vbYes Then
if msgbox("question 2?", vbYesNo)=vbYes Then
dim fso, outfile, wshNet
Set wshnet = CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
Set outfile = fso.OpenTextFile("C:\logfile.log", 2, 1)
outFileString = "echo %" & wshNet.username & "%,%" & wshNet.computername & "%,%" & FormatDateTime(Now, vbLongTime) & "%,%" & FormatDateTime(Date, vbShortDate) & "%"
outFile.Write outFileString
end if
end if
if msgbox("question 1?", vbYesNo)=vbYes Then
if msgbox("question 2?", vbYesNo)=vbYes Then
dim fso, outfile, wshNet
Set wshnet = CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
Set outfile = fso.OpenTextFile("C:\logfile.log", 2, 1)
outFileString = "echo %" & wshNet.username & "%,%" & wshNet.computername & "%,%" & FormatDateTime(Now, vbLongTime) & "%,%" & FormatDateTime(Date, vbShortDate) & "%"
outFile.Write outFileString
end if
end if
Last edited by cadalano on August 15, 2007, 11:42 am, edited 1 time in total.
I TOLD YOU ID SHOOT! BUT YOU DIDNT BELIEVE ME! WHY DIDNT YOU BELIEVE ME?
-
- Way too much time!
- Posts: 1673
- Joined: July 16, 2004, 11:02 am
- Location: Royal Palm Beach, FL
Re: VB Sciprt HELR!!!
reading it again, you probably need the logfile to be a running list, rather than overwriting each time.
To do that, change the OpenTextFile method to:
Set outfile = fso.OpenTextFile("C:\logfile.log", 8, 1)
and put a carriage return / line feed on your string:
outFileString = "echo %" & wshNet.username & "%,%" & wshNet.computername & "%,%" & FormatDateTime(Now, vbLongTime) & "%,%" & FormatDateTime(Date, vbShortDate) & "%" & vbCrLf
To do that, change the OpenTextFile method to:
Set outfile = fso.OpenTextFile("C:\logfile.log", 8, 1)
and put a carriage return / line feed on your string:
outFileString = "echo %" & wshNet.username & "%,%" & wshNet.computername & "%,%" & FormatDateTime(Now, vbLongTime) & "%,%" & FormatDateTime(Date, vbShortDate) & "%" & vbCrLf
I TOLD YOU ID SHOOT! BUT YOU DIDNT BELIEVE ME! WHY DIDNT YOU BELIEVE ME?
-
- Way too much time!
- Posts: 1673
- Joined: July 16, 2004, 11:02 am
- Location: Royal Palm Beach, FL
Re: VB Sciprt HELR!!!
reading it again, youre making a batch file and need the actual text "username" and "computername" probably. So i'm an idiot with the wshNet stuff. You can take it out easily and just leave a string!
I TOLD YOU ID SHOOT! BUT YOU DIDNT BELIEVE ME! WHY DIDNT YOU BELIEVE ME?