Make the program run with the computer startup VB.NET? - vb.net

I want to make my program run with the computer startup in VB.NET. I know there is a lot of codes about it but why some antivirus is detected these codes as a virus when people use my program, they will think the file is a virus and I will lose my reputation so please help me (any code you have or method please put it in a comment I will test it).
I use this code:
My.Computer.Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).SetValue(Application.ProductName, Application.ExecutablePath)

#Steve describes the right way , you will not need to write any code. Just copy the .exe shortcut to the startup folder. This can be done by setup if your program has or by manually or your program can do at first runtime.
Use Environment.SpecialFolder.Startup to get the directory.
Paste shortcut there.

Related

Embedding .exe's into a VB.net application

So here's whats up,
I am a Bench Technician for an IT company. I find myself repeating the same task over and over when preforming system reloads. I want to write an application where I have all the programs for a reload in one spot, and call them by a button click event. I have tried adding them into the Resources and calling them by Environment.CurrentDirectory+"\Path" to no avail, I get " System cannot find the file specified. When the path is hard coded it works like a charm, but this will obviously not do as it needs to be able to move to any system. I am looking for a way to add the exe's I need and a generic way to call the path. I am not looking for handouts here, I have done my homework on this one and still not found a solution, If I could get someone to -point me in the right direction, it would be awesome.
Since what you have already tried is much saner and easier for the average user to work with than having the files embedded in another executable, I'll explain that method.
CurrentDirectory is where your executable is executed from, Like this:
C:\MyDir> MyOtherDir\MyProgram.exe
CurrentDirectory refers to C:\MyDir in this example.
What you need is the application directory; and according to top answer of this question the most reliable way to get that is using AppDomain.CurrentDomain.BaseDirectory
EDIT: Also consider using Path.DirectorySeparatorChar instead of \.

LabVIEW: missing block diagram

I have a two broken VIs with front panels that open fine, but I can't edit or run them, or open theis block diagrams.
One of these was made as a replacement for the first when it started to have this problem. I need to at least find out how to avoid this problem in future, so I don't lose work on bigger VIs.
I'm not sure if it makes any difference, but I very recently upgraded to LabVIEW 2013.
Thank you in advance.
This is the error I get when I try to run them:
"
VI has a bad connection to or cannot find a subVI or external routine.
This VI has a bad connection to or cannot find a subVI or external routine but
it has no block diagram to show or fix the error. You must find or correct the
subVI or external routine. Check for more information in the Explain dialog box
in Get Info.
"
Before reverting to a previous version (using dropbox) I got a different error with one of them:
"
LabVIEW: Generic error.
An error occurred loading VI 'sweep harmonics first test.vi', LabVIEW load
error code 6: Could not load the block diagram.
"
One situation how this happened.
Sometime LabVIEW crashes, and it restart. After restart, LabVIEW will ask you to recover the autosaved code.
I personally always discard those autosaved code. If you do choose to recover autosaved code, there is a chance the recovered code is corrupted. Once you save corrupted code to disk, you are probably going to lose the ability to open/save the block diagram ever again.
Having a version control system is usually a way to avoid minimize the damage when LabVIEW crashes. At worst, you loose maybe an hour worth of work.
If you can't open Block Diagram of your VI, first check the suggestion by #Rodrigo - it is most likely just a "compiled" VI, which has Block Diagram removed.
If you think there is Block Diagram inside and it is just corruped - you may contact NI support. And if you want to look deeper by yourself, extract the VI to XML using pyLabview, and look into the XML - there you can modify every single part of the VI. For example, you may start removing parts until it starts working.
I wouldn't go into manual VI editing unless you have at least a dozen of affected files though. For a single file, it will be faster to re-create it in LabVIEW instead of trying to understand the internals. If many files are affected - may be worth finding the issue in one, as other files probably have the same glitch, so you can make a script which extracts, modifies and re-creates VIs automatically.
From the sound of it, I believe what happens is that you are trying to run the VI's created as "DATA" for an executable, instead of the actual source VI's.
When you build an executable LabVIEW creates a copy of all the Top Level VI's dependencies into the support (DATA) folder which should be in the same directory as your executable.
Try opening the VI's that are marked as not having a block diagram and navigate to File>>VI Properties to check the path from which the VI is being loaded. If it's not the original VI, you can just replace it.

Running Data From External Classes

Over the past few months I have been struggling to find a way to execute external un-compiled classes from my program.
EXAMPLE:
I have a simple run button on a windows forum. When that run button is pressed I wan't to run the Main sub in run.vb. (Run.vb is not part of the program and is located in a directory)
Is their a way to do this without using .dll's?
You want to run VB.Net code as I see. There are a bunch of classes in System.CodeDom.Compiler namespace to deal with .Net source code.
See http://www.codeproject.com/Articles/5472/Compiling-NET-code-on-the-fly
There is a good example with explanation here.
If you want to run VB6 code, the only way is compiling it to dll and then dynamically load and run. Or you can use VBscript if it will suit you.
In fact, CodeDom compiles your code to dll assembly too, but keeps it in memory, so you don't need to clean up any mess after you app is dead

How to write and execute programs in terminal/command prompt?

For example:
http://www.youtube.com/watch?v=tKTZoB2Vjuk (# 5 min)
I have no idea how one would go about writing code and making it work without an IDE but it seems like a useful thing to know how to do. Thanks!
Open an editor. Edit the code. Invoke the compiler. Run the executable.
Can't say much more without further details on your part.
What they're showing in the video though is the Python REPL.

Locked Classes with VBA/VB

I want to package my classes (in VBA or VB), but I want to put a lock on them before I do so. I want the computer to return a message similar to one in the Word file attached. Can anybody point me in the right direction? There doesn’t seem to be a lot of help in this regard.
I would need something that would lock just the classes that I have made while still leaving the rest. My understanding is that the mde would compile the whole works, and therefore would not work. Is that correct?
Could you have 2 projects for 1 mdb file? Then I could allow 1 project to be locked (mine) and then the other to be open to everyone
Marty Habicht
An add-in may suit: http://msdn.microsoft.com/en-us/library/aa902693.aspx
You can create an mde and include it as a refernce in other Access applications (code window, Tools-References).
See my Add-in Tips, Hints and Gotchas page for an Access only answer.
A simple solution would be to put the classes in an mde, and then just set a reference to the MDE from the unlocked project. This will give you access to the class, while rendering your source unviewable. This won't stop a determined reverser, but I don't really think a determined reverser is in the threat model:)