#72983 - 2003-02-06 10:36 PM
PC name from WINS, not...
|
Rocco Capra
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
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|