VB Sciprt HELR!!!

Support, Discussion, Reviews
Post Reply
User avatar
cid
Way too much time!
Way too much time!
Posts: 1098
Joined: August 28, 2002, 10:17 pm
Location: Lost in my avatar
Contact:

VB Sciprt HELR!!!

Post by cid »

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?
cadalano
Way too much time!
Way too much time!
Posts: 1673
Joined: July 16, 2004, 11:02 am
Location: Royal Palm Beach, FL

Re: VB Sciprt HELR!!!

Post by cadalano »

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
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?
cadalano
Way too much time!
Way too much time!
Posts: 1673
Joined: July 16, 2004, 11:02 am
Location: Royal Palm Beach, FL

Re: VB Sciprt HELR!!!

Post by cadalano »

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
I TOLD YOU ID SHOOT! BUT YOU DIDNT BELIEVE ME! WHY DIDNT YOU BELIEVE ME?
cadalano
Way too much time!
Way too much time!
Posts: 1673
Joined: July 16, 2004, 11:02 am
Location: Royal Palm Beach, FL

Re: VB Sciprt HELR!!!

Post by cadalano »

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?
User avatar
cid
Way too much time!
Way too much time!
Posts: 1098
Joined: August 28, 2002, 10:17 pm
Location: Lost in my avatar
Contact:

Re: VB Sciprt HELR!!!

Post by cid »

Thank you sir!!
User avatar
Fash
Way too much time!
Way too much time!
Posts: 4147
Joined: July 10, 2002, 2:26 am
Gender: Male
XBL Gamertag: sylblaydis
Location: A Secure Location

Re: VB Sciprt HELR!!!

Post by Fash »

,8,1 ??... lol c64 memories!
Fash

--
Naivety is dangerous.
Post Reply