Page 1 of 1 1
Topic Options
#72983 - 2003-02-06 10:36 PM PC name from WINS, not...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
Not sure where to put this but since it is a script here goes...

IF
anyone remembers me asking a while ago about getting a PC name
from an already known username without having to dig through wins,
I have come up with a solution.
ELSE
It is not a total solution yet cause it only gives the most recent
PC name that the user logged in on.
ENDIF

Anyway, It is kix, and kixwin so there is nothing to install on
your PC (as long as you have the needed files.)

These 2 lines are in the login script for everyone to run...
code:
$INIFILE='\\MANFP1NT\Public\IT\User_PC\user_pc.ini'
$RC=WriteProfileString($INIFILE,'USERNAME',@USERID,@WKSTA)

And here is the code used to query the ini file to get the PC name...
code:
BREAK ON CLS

SetConsole('hide')

$INIFILE='\\MANFP1NT\Public\IT\User_PC\user_pc.ini'

DO
DO
IF Exist('%TEMP%\output.tmp') DEL '%TEMP%\output.tmp' ENDIF
$OUTPUT='%TEMP%\output.tmp'
SHELL '%COMSPEC% /c kixwin "file://'+@CURDIR+'\_userpc1.html" > "'+$OUTPUT+'"'
$USER=ReadProfileString($OUTPUT,'PROMPT','USER')
IF($USER<>'')
$COMPUTER=ReadProfileString($INIFILE,'USERNAME',$USER)
IF($COMPUTER='')
$RETRY=MessageBox('Cannot find Computer for:'+@CRLF+@CRLF+
'[ '+Ucase($USER)+' ]'+@CRLF+@CRLF+
'Do you want to retry?',
'PCName from UserName',52,7)
ELSE
$RETRY=MessageBox('The most recent logged on PC for:'+@CRLF+@CRLF+
'[ '+Ucase($USER)+' ] = [ '+Ucase($COMPUTER)+' ]'+@CRLF+@CRLF+
'Do you want to look for another?',
'PCName from UserName',68)
ENDIF
ELSE
$RETRY=MessageBox('-----------[ User Error ]-----------'+@CRLF+
'You did not enter a UserName'+@CRLF+
'Do you want to retry?',
'PCName from UserName',20,7)
ENDIF
UNTIL($COMPUTER<>'')
UNTIL($RETRY<>6)

QUIT(0)

Here is the html file used by kixwin...
code:
<html style="width:300;height:125;system:no;help:no">
<head>
<title>PC Name</title>
<style>
body
{
background-color:#CCCCCC;<!--|637A8C|-->
margin-left:10;
margin-right:10;
margin-top:5
}
.button
{
width:75
}
</style>
</head>
<body scroll=no onload()="body_onload()">
<div align="center">
<table>
<tr><td align="center"><font color="#000000"><b>User Name:</b></font></td></tr>
<tr><td align="center"><input type=text style="width:100%" id=username></td></tr>
<tr><td align="center">
<input type=submit class=button onclick="ok.onclick()" value="OK" valign=right name=ok>
<input type=button class=button onclick="cancel.onclick()" value="Cancel" name=cancel>
</td></tr>
</div>
</body>
<script>
function body_onload()
{
var argv = new Array;
argv = window.dialogArguments.split(";");
document.all.username.value = argv[0];
window.returnValue = -1;
}
function ok.onclick()
{
window.returnValue = "[PROMPT]\nuser="+username.value;
window.close();
}
function cancel.onclick()
{
window.returnValue = -1;
window.close();
}
</script>
</html>

And last but not least (maybe)...Here it is in AutoIt.
Why you ask, cause I like the way AutoIt compiles into an exe.
Unfortunatly though no way around the darn "GOTO's"
code:
HideAutoItWin, on

START:
InputBox, USER, PC from UserName, Enter the username:
StringLen, LEN, USER
IfEqual, %LEN%, 0, GOTO, NO_USER

RETURN_PC:
IniRead, PC, \\\\MANFP1NT\\Public\\IT\\User_PC\\user_pc.ini, USERNAME, %USER%
IfEqual, PC, ERROR, GOTO, NO_PC

MsgBox, 68, --[ %USER% ]--, Last logged onto Computer:\n\n[ %PC% ]\n\nDo you want to look for another PC?\n
IfMsgBox, YES, GOTO, START
IfMsgBox, NO, GOTO, END
GOTO, END

NO_USER:
MsgBox, 20, --[ ERROR ]--, You did not enter a UserName.\nDo you want to try again?\n
IfMsgBox, YES, GOTO, START
IfMsgBox, NO, GOTO, END

NO_PC:
MsgBox, 20, --[ ERROR ]--, Cannot find PC for %USER%.\nDo you want to try again?\n
IfMsgBox, YES, GOTO, START
IfMsgBox, NO, GOTO, END

END:
Exit

RFC

Rocco

[ 06. February 2003, 22:37: Message edited by: Rocco Capra ]
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#72984 - 2003-02-07 02:29 PM Re: PC name from WINS, not...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
What no comments?

I know Jim posted his form. I should have waited
one more day to post mine, after looking at Jim's
I wouldn't have posted mine. [Frown]

Rocco
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#72985 - 2003-02-07 02:50 PM Re: PC name from WINS, not...
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I would have tried your's out if it weren't for that INI file dependency. Not about to add it to my logon just now.

But hey, looks like a sound concept without the drawbacks of WINS record uniqueness.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#72986 - 2003-02-07 03:25 PM Re: PC name from WINS, not...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
I log all users into an inventory CSV at logon also
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#72987 - 2003-02-08 03:48 AM Re: PC name from WINS, not...
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Rocco,

As far as compiling the script goes.. Did you try KiXCrypt?

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#72988 - 2003-02-10 02:17 PM Re: PC name from WINS, not...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
Kent,

I have used kixcrypt before, but still like AutoIt better. No offense Howard!

Rocco
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#72989 - 2003-02-10 02:18 PM Re: PC name from WINS, not...
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Hee, hee. Kixcrypt is Richard's baby, not Howard's.

The curse of Rich "Howie" Howarth strikes again.

Top
#72990 - 2003-02-10 03:16 PM Re: PC name from WINS, not...
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
If only I could write a program like KiXCrypt.exe... [Frown]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#72991 - 2003-02-10 08:45 PM Re: PC name from WINS, not...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
UUUUUUHHHHHHRRRRRGGGGGGG!!!!!!!

Dabnabit!

Sorry Richard!!!!!!

Rocco
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.068 seconds in which 0.035 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org