|
Your looking for the Environment class and it's SetEnvironmentVariable method. Make sure that you pass EnvironmentVariableTarget.Machine for the third parameter and the system should get updated with the new variable. You can then launch a new CMD prompt to check if it worked.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave.
Thanks for your reply, but it is exactly what I did. And it is true that you can see, and access the variable, when a new cmd.exe is spawned from as ex. "Run" in the start menu.
But if you call your program from the current cmd.exe shell, you can not see, nor access the variable from this shell, since it seems that you are in some kind of "static" environment, which is not renewed when the program is run.
Rgds,
Preben
|
|
|
|
|
OK, I see what you're doing now. No, there is no way to update the environment of a process from the "master environment" once that process has launched. You can update the environment and see the changes, but not using the EnvironmentVariableTarget.Machine . You have to change that to read EnvironmentVariableTarget.Process .
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Guys,
I'm developing a small dll in vb2005 to handle my app licensing.
Based on requirements put forward by my, god bless him, supervisor I need to retrieve the processor and HD serials and use those to authenticate product installations.
I know that's an ugly way of doing things but considering that most if not all CD protection software out there are cracked and a simple serial/activation key system can be easily abused I'm not protesting this too much.
Anyway, I got the basic functions to retrieve the serials and handle encryption/decryption thanks to an excellent post by Tomy Emden (http://www.codeproject.com/useritems/Crypto.asp[^]).
My main problem now is when i run this app to test serial retrieval, on other PC's, I get a security message with a lot of nonsense about required admin authorisation and .NET config tools etc. The message box also got lots of details along the lines of: System.Security.SecurityException: That assembly does not allow partially trusted callers.
So my question is from the security and permissions standpoint what must I have or do in order to get the info I need with minimal hassle for the end user.
Is there some code that needs to be included in order to bypass this sort of messages (non-malicious code of course )?
Do you I need certificates etc.?
Basically if some one could push me in the right direction or explain the things I need to consider I would really appreciate it.
Regards
Alex
BTW: Thanks for reading this long ass post!
The perfect code is always in your head...it just a matter of how hard you bang your head against the wall to get it out!
|
|
|
|
|
I had to do the same thing recently and I settled on the volume serial no ( which will change on a reformat, but at least doesn't need admin rights to access )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian
To be honest I wanted to settle for this myself but then again that increases the 'hassle factor'. From my experience customers reformat drives more often that they change them let alone change part of the system.
Besides using just a volume serial gives you one point of reference whereas proc mobo ram and HD manufacturer assigned serials give you a way of reducing headaches. Say only 2 out of 4 match the app can still function.
I could put admin rights as a requirement for the app but that option is reserved for when I hit the rock bottom and dig into 50 feet of crap .
I appreciate your response but still would like to get more info on this issue.
The perfect code is always in your head...it just a matter of how hard you bang your head against the wall to get it out!
|
|
|
|
|
Yes, I have to admit that I wanted to go the HDD serial route, but I couldn't find a way to make it happen, and our needs were somewhat specific, such that the compromises you mention were regarded as being not a problem.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian,
I played with the .net settings and tools and then read stuff from here (www.informit.com[^]) and there (msdn.microsoft.com[^]) and it all became clear as mud .
The reason my test app didn't function was because it was run from the server (ie permission set Intranet) hence the ugly security exceptions. However, the actual application is intended to be run locally thus requiring the user to be an admin on the local pc is not that much to ask considering that the application my app extends has that requirement anyway.
Once again thanks for your time Christian
Regards
Alex
The perfect code is always in your head...it just a matter of how hard you bang your head against the wall to get it out!
|
|
|
|
|
Hi
How can i edit the legend of the graph in the crystal report.
I cant find any option for the same
Please Help me.
Thanx
Riyaz Zujer Patanwala
I.T.Programmer
Al Jaber Energy Services
P.O.Box 47467
Abu Dhabi
U.A.E.
|
|
|
|
|
I have an MDI form where I set the following Handler in Form_Load
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException
If I throw an exception in the MDI form the exception gets handled by CurrentDomain_UnhandledException
But, If I load a child form and throw an exception from the child form the excpetion does not get handled by CurrentDomain_UnhandledException
So, Is the child form running in a different AppDomain then the MDI form. How can I get this to work or does this not work the way I thought it would.
Here is my form load which is also in the MDI form
f = New formDesignErrorsList<br />
f.Tag = formname<br />
f.Text = f.Text<br />
f.MdiParent = Me<br />
f.Show()
Thanks
-- modified at 22:46 Wednesday 23rd August, 2006
|
|
|
|
|
mtone wrote: Is the child form running in a different AppDomain then the MDI form.
No, it's not. It's all in the same AppDomain.
What's the exception that's not getting handled?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
In the Main (MDI) form My test is just trowing an new exception. Here is gets handled by CurrentDomain_UnhandledException and ultimatly ends up in The EventLog
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
AddHandler Application.ThreadException, AddressOf ApplicationThreadException<br />
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException<br />
Throw New Exception("This is a test")<br />
End Sub
If I put the same Throw New Exception("This is a test") in the onload event of the mdi child it does not get handled nor does it make it to the event log. If I set a break point I can see that CurrentDomain_UnhandledException is never called.
Thanks
Joe
|
|
|
|
|
Well, I did this and it did what was expected of it:
' Form1
Private Sub Form1_Load(blah, blah) Handles Me.Load
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExceptionHandler
Dim c As New Form2
c.MdiParent = Me
c.Show()
End Sub
Private Sub UnhandledExceptionHandler(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)
Debug.WriteLine("Unhandled Exception!!")
End Sub
' Form2
Private Sub Form2_Load(blah, blah) Handles Me.Load
Throw New Exception("Yikes!")
End Sub
The exceptions don't make it to the event log because there's nothing telling the app to log them. But, the exception was caught by the UnhandledExceptionHandler.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks Dave
I have the code that writes to the event log in another function I am using the Enterprise Library to handle the event logging. Well, the event log was not the problem just a way for me to see the exception followed the proper route. I will keep looking at it, so long as I know it should work.
|
|
|
|
|
In my testing, there is a problem with using the UnhandledException event. It doesn't get fired unless the code is running under the debugger! Go figure...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
i had found my error which is the DATE cause the problem...
anyway to update my DATE field?? will it becasue of the format? because i found out that my vb when i put"NOW" it will include the time with it. But with my access i had set it as DATE only.
Date= " & "'" & ddate.Text & "'" & _
Here my full coding:
DB.Execute "update DONO set NO=" & "'" & dono.Text & "'" & _
",Date= " & "'" & ddate.Text & "'" & _
",Customer=" & "'" & Combo1.Text & "'" & _
",Description =" & "'" & ddes.Text & "'" & _
",Total =" & "'" & temptotal.Caption & "'" & _
",BillTerm=" & "'" & dterm.Text & "'" & _
" where [dono] = " & "'" & userin & "'"
|
|
|
|
|
It depends on what database you are using.
Mike Lasseter
|
|
|
|
|
i'm using microsoft access
|
|
|
|
|
For using dates in access you will need to use # around the date instead of '.
Example: #8/23/06#
Mike Lasseter
|
|
|
|
|
not working
here coding:
",Date= " & "'" & "#" & ddate.Text & "#" & "'" & _
even i put it as ",Date= " & "'#" & ddate.Text & "#'" & _
not working too
|
|
|
|
|
",Date= " & "'" & "#" & ddate.Text & "#" & "'" & _
even i put it as ",Date= " & "'#" & ddate.Text & "#'" & _
The above lines equate to the same sting to send to the database. Both of which have ' around the date still. You don't need the single quotes for dates in access.
Use the following:
",Date= " & "#" & ddate.Text & "#" & _
Mike Lasseter
|
|
|
|
|
|
Standard question #1:
What do you mean by "not working"?
Standard question #2:
What error message do you get?
You are probably using a date format that the database doesn't recognise.
---
b { font-weight: normal; }
|
|
|
|
|
pls refer to mr_lasseter response , i have try many way of those format. but when i save a new record it able to save it but when update , which mean edit the old record then have problem.
|
|
|
|
|
Guffa's questions are valid. From the last attempt that you made:
Standard question #1:
What do you mean by "not working"?
Standard question #2:
What error message do you get?
|
|
|
|