Jump to content

Create a program that generates a text file output?


Recommended Posts

Posted

Hi apologies, I'm after creating a small program that when run loads up a form which when you fill in has some verification and then dumps the completed text into a text file that will be used as a set of variables for an automated build script. This file that's written by the program would be called something like variables.bat

 

I've been editing the text file manually for months but would prefer to have the program, but I've no experience in this and have no idea what I'm googling for, any pointers would be most appreciated!

 

Thanks

Posted
to be honest the closest I get to coding is php on websites, I do know a bit of powershell and vbs but that is it, I do tend to pick things up quick though!
Posted

If you know VBS, I'd write your script in that. OK it won't be as pretty as as designing a form in .NET or AutoIt or similar, but it'll get the job done :)

 

What specifically are you struggling with?

 

File IO is pretty straight forward in VBS, but I'm happy to give you pointers if you need them.

 

If it's just a general idea of where to start, personally I'd take your original text file and put tags in wherever you need to put form data (e.g. if you need a username, you could put '%USERNAME%' in the place in the text file where you need it). Then I'd read the contents of the newly created template in to my script at the start, gather all the relevant data and do a search/replace on the tags, populating them with the collected data. Finally, drop your generated text back in to a new file and job done :)

  • Thanks 1
Posted
Ah OK, stupidly I didn't think of vbs as I've started to move any scripts to powershell, I'll look and see what I can find with that, appreciate the help, been a nightmare start to the term!
Posted
stupidly I didn't think of vbs as I've started to move any scripts to powershell

I wouldn't bother with VBScript. It's an awful scripting language. :)

 

If you are already using PowerShell it doesn't make any sense at all to use VBS. PowerShell has lot of commands built-in which simply don't exist in VBScript so you'll save time and your scripts will be more concise too.

Posted
I wouldn't bother with VBScript. It's an awful scripting language. :)

 

If you are already using PowerShell it doesn't make any sense at all to use VBS. PowerShell has lot of commands built-in which simply don't exist in VBScript so you'll save time and your scripts will be more concise too.

 

If you do use powershell, Out-File "C:\File\Location.txt" -Force will set you straight. (-Append switch if you're writing to it multiple times)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...