Jump to content

This topic is 7671 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi,

Running a shared solution on a Win XP peer-to-peer network. I want to find the network name of the computer that opened a file.

Status(CurrentHostName) will return the network name of the computer hosting the file, and I can parse out the name of the computer on which the file is stored from Status(CurrentFilePath). (Yeah, I know, it should be the same as the host name, but hey, this isn't a perfect world. People do dumb stuff.) Status(CurrentUser) will tell me the windows logon name of the user. But I need the name of the computer, not the user. How can I get this?

Thanks,

Dan

Posted

Ok, I see you guys didn't just want to make it easy on me and give me the perfect little script to do the job. smile.gif But after poking around a bit with your leads, here's what I came up with. Step one was to find out what WSH was, and then dust off my VB knowledge. Step two was to create this:




Dim objNet

Set objNet = CreateObject("WScript.NetWork") 



Dim strInfo

strInfo = "User Name is     " & objNet.UserName & vbCRLF & _

          "Computer Name is " & objNet.ComputerName & vbCRLF & _

          "Domain Name is   " & objNet.UserDomain



wscript.echo strInfo



Set objNet = Nothing                    'Destroy the Object to free the Memory



' call this program from the command line with the following:

' cscript compname.vbs>c:compname.txt

' this will direct the output to c:compname.txt



and save it as CompName.vbs. When it's called from the command prompt as indicated in the notes, I get a text file that is easy enough to read and parse in FM.

Thanks guys,

Dan

This topic is 7671 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.