mbeyer Posted June 21, 2006 Share Posted June 21, 2006 I'm sure this is a dumb question, but here goes anyway. I am new to scripting so bare with me. I am trying ot write a script that will print the computer name as well as the username. We do a lot of automated installs here at my company and there are a lot of laptop builds. Sometimes it gets comfusing when your done so we print out the info of who the laptop will go to. I would like to write a script that will automatically get the username and computer name and then print it automatically. Can anyone help me? Link to comment Share on other sites More sharing options...
Xenobiologist Posted June 21, 2006 Share Posted June 21, 2006 HI, have a look at @ComputerName, @UserName and maybe #include <File.au3> _FilePrint ( $s_File [, $i_Show] ) So long, Mega Hope that helps. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
ChrisL Posted June 21, 2006 Share Posted June 21, 2006 (edited) Download the beta version of Autoit and use this... $file = FileOpen (@tempdir & "\printout.txt",2) FileWriteLine ($file,@Computername) FileWriteLine ($file,@userName) FileClose ($file) _FilePrint (@tempdir & "\printout.txt") Func _FilePrint($s_File, $i_Show = @SW_HIDE) Local $a_Ret = DllCall("shell32.dll", "long", "ShellExecute", _ "hwnd", 0, _ "string", "print", _ "string", $s_File, _ "string", "", _ "string", "", _ "int", $i_Show) If $a_Ret[0] > 32 And Not @error Then Return 1 Else SetError($a_Ret[0]) Return 0 EndIf EndFunc ;==>_FilePrint Edited June 21, 2006 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
LostUser Posted June 21, 2006 Share Posted June 21, 2006 I'm sure this is a dumb question, but here goes anyway. I am new to scripting so bare with me. I am trying ot write a script that will print the computer name as well as the username. We do a lot of automated installs here at my company and there are a lot of laptop builds. Sometimes it gets comfusing when your done so we print out the info of who the laptop will go to. I would like to write a script that will automatically get the username and computer name and then print it automatically. Can anyone help me?If you are using Novell for your login names, @UserName will not work, it only pulls the username logged in to the local windows workstation...at least from what I've seen.If you need to get a novell username, you can pull it from HKCU\volatile environment\username. This gives you the user name as it is shown in NDS. Under this same key there is also NWusername. I'm not sure what the difference is as they seem to show the same name. One may not update if you re-login without logging out.You can also pull it from HKLM\SOFTWARE\Novell\Location Profiles\Services\{1E6CEEA1-FB73-11CF-BD76-00001B27DA23}\Default\username. This shows the username as it is typed in for authentication to NDS. Be open minded but not gullible.A hammer sees everything as a nail ... so don't be A tool ... be many tools. Link to comment Share on other sites More sharing options...
mbeyer Posted June 21, 2006 Author Share Posted June 21, 2006 Download the beta version of Autoit and use this... $file = FileOpen (@tempdir & "\printout.txt",2) FileWriteLine ($file,@Computername) FileWriteLine ($file,@userName) FileClose ($file) _FilePrint (@tempdir & "\printout.txt") Func _FilePrint($s_File, $i_Show = @SW_HIDE) Local $a_Ret = DllCall("shell32.dll", "long", "ShellExecute", _ "hwnd", 0, _ "string", "print", _ "string", $s_File, _ "string", "", _ "string", "", _ "int", $i_Show) If $a_Ret[0] > 32 And Not @error Then Return 1 Else SetError($a_Ret[0]) Return 0 EndIf EndFunc ;==>_FilePrintthat script worked pefectly. I dont quite understand it all but it worked. I am still trying to figure out each line of code. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now