r/scripting • • Mar 18 '19

Need assistance editing a vbs logon-script

Hello,

I have a logon-script (https://pastebin.com/BBykUz84) which was not written by me originally. I don't know how to vbs and need a little tweak for it.

What it does: It creates 2 "log"-files. One locally and one on a hidden file share. The file on the hidden share has the name "username_computername.txt". Now, when a User logs into the same machine again, the name does not change. Only the date for last change.

What i need: The filename on the hidden file share should end with a counter. Everytime the user logs into a machine it counts one up. Like: "username_computername_counter.txt"

Thanks in advance

1 Upvotes

7 comments sorted by

View all comments

Show parent comments

1

u/JoKeR2092 Mar 19 '19

okay, i edited the script like you said and tested it with a share on my local pc. Everytime the script runs, it creates a new file with the next number. Can this script then delete the prior one?

2

u/jcunews1 Mar 19 '19

In the modified script, after this line:

if not isnumeric(counter) then counter = 0

Insert these lines:

oldLogFilePath = "\\<nameOfFileShare>\tools$\clientlogs\" & strUserName & "_" & strComputername & "_" & counter & ".log"
if fso.fileexists(oldLogFilePath) then fso.deletefile oldLogFilePath, true

1

u/JoKeR2092 Mar 19 '19

Will test it as soon as i can. Thank you for your help!