Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System info question (on NT)

Status
Not open for further replies.

jez

Programmer
Apr 24, 2001
370
0
0
VN
Hey there,

I am wondering and I haven't been able to find it anywhere, is there a simple way to detect an OS.

I am writing a cookie killer program to run mainly on my NT5 box, but I also want it to be directly portable to NT4 and win9x machines.

So far my 'beta' version runs well on my machine, where I have hard coded the path to my 'Documents and Settings' folder, and for the win9x version I have simply hard coded the search for a cookie file name pattern to start at C:/

This so far is a bit clumsy, like breaking a wall nut with a sledge hammer, and since my own machine has the OS on the F:/ drive, but generally it's on C:/ , I was wondering if there is a way to say; search all drives for a folders called windows || winnt and that is the drive to start with for finding the cookies.

I have tried hostname(); but that is just the computer name, and Cwd gives the path of my perl file.

Also is there a 'get logged in user's username' type command?

Any pointers would be great.

Cheers

Jez

 
I think the easiest way to find the home of the windows/winnt folder is to use the ENV hash. If you say something like $path = $ENV{"PATH"} you'll find the directory you need with a little parsing. To get the name of the user executing the script, you can use the Win32::LoginName function.
Code:
use Win32;
$name = Win32::LoginName;
Hope this helps.

Tom Ragsdale
stingray@acl.lanl.gov
 
Cheers,

That is exactly what I was looking for.
I am just trying it now, but I think it should do the trick.
Thanks again,

Jez
:);-):)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top