exe running from unc

S

Samir Ibrahim

vb2008, Vista

Hi all

I had posted this question in 2 forums and still could not find an answer.

I am creating a project which will return (User Name, Domain, PC Name, IP)

I noticed after doing some tests, that some vb command works fine if the exe
is run from UNC "\\server\folder\myexe.exe" and some command gives security
warning error.

I will give you an example of what I am talking about

create 2 project

in the first project put the below in form_load and build it and put the exe
in unc path and run it from another pc (other than your development pc)
text1.Text = Environment.UserName ' Works Fine

in the second prokect put the below in form_load and do as above
text1.Text = Environment.UserDomainName ' Gives secuirity warning or error

"Unhandled exception has occurred in your application, if you click
continue, the application will ignore this error and attemp to continue. If
you click quit, the application will close immediately Index was outside the
bounds of the array"

after this error, if I pressed continue, the form will open with empty
textbox's

If I copy the exe to local hdd, the exe will run fine.

I managed to get User Name, PC Name, IP) I still cannot get the domain to
work, I had tried the below and all giving warning error
txt_Domain.Text =
My.User.CurrentPrincipal.Identity.Name.Split("\")(0).ToString '
txt_Domain.Text = Environment.UserDomainName
wsNet = CreateObject("WScript.Network")
txt_Domain.Text = wsNet.UserDomain

I am asking for 2 things

Q1: What other code I can use to get the domain name?
Q2: Why some vb code works fine from UNC and some don't? Can I add/change
something to prevent the warning from appearing?

Thanks in advance.

Samir Ibrahim
 
S

Samir Ibrahim

Hello Cor Ligthert,

Thank you for this site which contain rich and valuable information to me.

But as concern my problem, I tried the WMI and it gives correct result if I
run the exe from HDD but gives security error when run from UNC.

I had given up searching for this and raised the white flag. I will copy the
exe to each hdd and end this problem.

Thanks.

Samir Ibrahim
 
S

Stewart Berman

There are restrictions on what you can reference depending on where the executable is hosted. The
server you are referencing in the UNC is not in a zone trusted to reference the requested
information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top