I am making a program that launches an external application, while setting the normally-set Roaming to one of my own folders.
Here is the code in BAT:
set APPDATA=data
To which 'data' is the name of the folder.
However, is there an equivalent of the 'set' code for VB?
Thanks in advance!
Ps. I am new to stackoverflow, so I apologize if I did anything wrong with my questions.
Related
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.
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 \.
I am trying to create an application in visual basic to open up a command prompt. I then want to type the word "Message" into the command prompt and have my application recognize the word "Message" and then run my application.
Any help leading me into the right direction would be greatly appreciated. Do I need to create a batch file or something else for this to work? Any advice, articles, or sample code is greatly appreciated. This is all new to me. I don't have much code, but this is what I have in visual basic:
Process.Start("cmd")
If (cmd.CommandText = "Message") Then
'calls another class to actually run the program
End If
It's the classic, good news and bad news.
The bad news is VBA can't do what you want natively. What you need to do is to call the "shell and wait" function, then capture it's output on the standard in.
This will require you to go beyond just VBA, and link into some windows guts (kernel32). The good news is that VBA makes that easy.
While I don't have source for you, a rather extensive article, with code here was referenced in this Stackoverflow Question
Hope this helps!
I have an error with some code that I have been working on for a while. I am writing a speech recognition software in Visual Basic.
grammar.Append(New Choices(System.IO.File.ReadAllLines(My.Resources.Commands)))
The above line has illegal characters in path in the InnerException. however if the line of code bellow is in place instead of the one above it will run fine.
C:\Users\oem\documents\visual studio 2010\Projects\VC\VC\CustomCommmands.txt
This will now work if the application is compiled into a exe setup and ran on a different machine.
I have looked all over Google for a answer, but none seem to work. If anyone can shed some light, it will be much appreciated.
System.IO.File.ReadAllLines is only used when you are reading a file from disk. It sounds like you have embedded the file as a resource in your program.
I don't have vb.net to test this, but this will probably work... I believe My.Resources loads the resource values directly, so you don't have to load them at all.
grammar.Append(New Choices(My.Resources.Commands))
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:)