I have two questsions.

The first being is it possible in VB to have a user input information during the file setup and have that information be used in the source code, then compiled, and then used after the setup is complete?

Say I want to have the user input their name, the user does and when the setup is complete and he/she opens the end result program their name appears as the title of the form.

Question number 2.

Is it possible to have a program, recreate itself with another name? So it's sort of like a name change?

Like say I have name1 and when I click on the .exe it will copy itself and make name2 or randomly generated letters or numbers.

Any help is appreciated.

Recommended Answers

All 11 Replies

You don't need to do this at install time, try coding the application to check for the configuration at start up and ask if not found.
You have two easy choices for Q1 Store the configuration in the registry or a configuraiton file.
VB has a simple API for storing application information in the registry.
Q2. Get the path to your program (e.g. using App.Path), and copy it to the new name. (e.g. FileCopy source, dest) if FileCopy doesn't work it's because the program itself is locking the file.
Alternative are:
Dim fso As New FileSystemObject
fso.CopyFile source, dest
or try using the Windows API function CopyFile.
Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
or in VB.NET
System.IO.File.Copy

I hope you're not trying to write a replicating virus program in VB ;-)

Alright I'll try those things out and see how it goes. Thanks!

I hope you're not trying to write a replicating virus program in VB ;-)

No the second one was for future programs, the idea is to be undetectable by a pc games anti cheating system thing.

Hmm, alright I was looking at your options for question one, and I want to have it be able to be released, and let people enter in custom data to be hard coded in, and then work w/ the program.

If you insisit on customising via the installer your work will be harder and the program won't cope if someone deletes the configuration. You will still need to write the same code within the program so it is simplyt easier to do it in one place anyway.

You could choose to write the code in a DLL which is used by both the installer and your program thus preserving the one definition rule (ODR)

I guess, I have no experience in making those, but I might not be explaining my purpose well enough. I want the program to have information put in on setup, or possibly make a program that compiles a set of code with said input data. Is this possible?

I went through what others have suggested, I think dexblack is pretty close.

First of all why would you distribute your application in the form of source code? Anyone can reuse it in that case.
Now, coming back to your question, yes both your questions are pretty much doable.
For First, you can go with storing the application settings in the config file and when the app launches it will reach from their, You can also use an encrypted registry key if you want to be in stealth mode.
For your second question, to achive the app rename feature you have to create a worker exe which will take care of this. Now, what is your criteria to rename the app? Is it one time or some other frequency?

Sorry for the late reply, the reason I just don't hand out the source code is the target group most likely doesn't have their own compilers, so I'm trying to distribute one with it. Which so far has been pretty difficult to understand.

As for the second, the app name would probably be changed more than once.

Okay.
Since you seem to be very determined on your course and I cannot convince of your folly. Here is an answer to what you are trying to achieve. Don't say you weren't warned.

First you need somewhere to write your data.
Declare a constant string or other buffer in your VB application and initialise it with a uniquely recognisable value at the start and end.
Write your application so that it parses that block expecting to find data in a particular format.
Write code in your installer that requests the information you need to put inside your program. Copy the .exe file to the new name then open it in read/write mode. Scan for the data block and fill it with your customised data. Set up your short cuts with the new name or whatever it is you wish to do with it.
No compilation at install time required.

You can also have your application do this step the first time it runs because it has read access to the .exe file it was launched from. Exactly the same procedure but this time the program itself modifies a copy of it's own binary.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.