#204092 - 2012-01-20 10:23 AM
BGinfo display a part of the Hostname
|
arjanv
Fresh Scripter
Registered: 2010-03-11
Posts: 49
Loc: netherlands
|
Hi,
I'm using a kix script that loads bginfo.
Is it possible to display only a part of the Hostname? all our computernames are like this AA-BBB-XXX and i want only display the XXX on the desktop with bginfo.
thanks
|
Top
|
|
|
|
#204094 - 2012-01-20 02:51 PM
Re: BGinfo display a part of the Hostname
[Re: Mart]
|
arjanv
Fresh Scripter
Registered: 2010-03-11
Posts: 49
Loc: netherlands
|
one thing, i use bginfo script as a computer logon script, so the computername is displayed before the user login. do think this will work with the custom code you provided?
and i was wrong, i'm using a bat file to load bginfo.exe
|
Top
|
|
|
|
#204096 - 2012-01-20 04:01 PM
Re: BGinfo display a part of the Hostname
[Re: Mart]
|
arjanv
Fresh Scripter
Registered: 2010-03-11
Posts: 49
Loc: netherlands
|
ok thanks, i'm gona test it with kix to run bginfo. your code above, do i need to place it the same kix logonscript? and do i need to make a special BGI file, because i don't understand how your code reads the text file.
$=SetOption("Explicit","ON")
Dim $sLocalDir $sLocalDir="C:\BGInfo"
If Not Exist($sLocalDir) MD $sLocalDir EndIf
If Not Exist($sLocalDir+"\bginfo.exe") COPY @LSERVER+"\NETLOGON\bginfo\bginfo.exe" $sLocalDir EndIf
If Not Exist($sLocalDir+"\custom.bgi") COPY @LSERVER+"\NETLOGON\bginfo\custom.bgi" $sLocalDir EndIf
Run $sLocalDir+"\Bginfo.exe "+$sLocalDir+"\custom.bgi /timer:0 /silent /NOLICPROMPT /LOG:"+%TEMP%+"\bginfo.log"
|
Top
|
|
|
|
#204098 - 2012-01-20 06:35 PM
Re: BGinfo display a part of the Hostname
[Re: Mart]
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4562
Loc: USA
|
Just for fun... in batch...
set pcname=%computername:~-4%
echo %pcname%
Use Kix though... and consider replacing all your batch with kix too.
|
Top
|
|
|
|
#204099 - 2012-01-20 09:15 PM
Re: BGinfo display a part of the Hostname
[Re: Allen]
|
arjanv
Fresh Scripter
Registered: 2010-03-11
Posts: 49
Loc: netherlands
|
Just for fun... in batch...
set pcname=%computername:~-4%
echo %pcname%
Use Kix though... and consider replacing all your batch with kix too.
ok, but how to read pcname with bginfo?
|
Top
|
|
|
|
#204100 - 2012-01-20 10:49 PM
Re: BGinfo display a part of the Hostname
[Re: Mart]
|
arjanv
Fresh Scripter
Registered: 2010-03-11
Posts: 49
Loc: netherlands
|
Mart. I've tested it locally by running the kix script from command promt and it works, but when i run the script twice the computername gets double and running a third time it triples the name.
is this cause because i'm still logged on and run the script?
i'm gona test it monday at work.
|
Top
|
|
|
|
#204101 - 2012-01-21 12:30 AM
Re: BGinfo display a part of the Hostname
[Re: arjanv]
|
ShaneEP
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
You'll have to wrap the code that creates the file in an IF statement so that it doesn't create it if it already exists.
Break on
If Not Exist("Sometextfile.txt")
;Open text file. Create it when it does not exist.
$rc = Open(1, "Sometextfile.txt", 5)
;Get last three characters from @wksta.
$hostname = Right(@WKSTA, 3)
;Write to text file.
$rc = WriteLine(1, $hostname)
;Close text file.
$rc = Close(1)
Endif
|
Top
|
|
|
|
#204105 - 2012-01-23 05:11 AM
Re: BGinfo display a part of the Hostname
[Re: Mart]
|
ShaneEP
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
Honestly, I think it would be simpler if you used a registry value instead of a file. And, you wouldn't have to worry about writing over itself, or multiple entries.
Just use this line in your login script to create the registry key...$nul = WriteValue("HKCU\Software\Winternals\BGInfo", "hostname", Right(@WkSta,3), "REG_SZ") And then simple create a custom entry in bginfo that points to "HKEY_CURRENT_USER\SOFTWARE\Winternals\BGInfo\hostname"
|
Top
|
|
|
|
#204116 - 2012-01-26 09:54 AM
Re: BGinfo display a part of the Hostname
[Re: ShaneEP]
|
arjanv
Fresh Scripter
Registered: 2010-03-11
Posts: 49
Loc: netherlands
|
Honestly, I think it would be simpler if you used a registry value instead of a file. And, you wouldn't have to worry about writing over itself, or multiple entries. Just use this line in your login script to create the registry key... $nul = WriteValue("HKCU\Software\Winternals\BGInfo", "hostname", Right(@WkSta,3), "REG_SZ") And then simple create a custom entry in bginfo that points to "HKEY_CURRENT_USER\SOFTWARE\Winternals\BGInfo\hostname"
Don't think this is gona work because i use a computer logon script policy. or am i wrong?
|
Top
|
|
|
|
#204122 - 2012-01-26 05:52 PM
Re: BGinfo display a part of the Hostname
[Re: Mart]
|
arjanv
Fresh Scripter
Registered: 2010-03-11
Posts: 49
Loc: netherlands
|
do you think this will work as a computer logon policy? does kix even run with a computer logon script policy? maybe i need a batch script eventually.
|
Top
|
|
|
|
#204127 - 2012-01-26 09:57 PM
Re: BGinfo display a part of the Hostname
[Re: Allen]
|
arjanv
Fresh Scripter
Registered: 2010-03-11
Posts: 49
Loc: netherlands
|
If it is a GPO script then I believe the script will have Permissions to HKLM... that would eliminate the need to write to HLCU. okay, so i can try to change the registry path to hklm? i'm at work tomorrow and i'm gona test it.
|
Top
|
|
|
|
#204129 - 2012-01-27 10:34 AM
Re: BGinfo display a part of the Hostname
[Re: ShaneEP]
|
arjanv
Fresh Scripter
Registered: 2010-03-11
Posts: 49
Loc: netherlands
|
both provided solutions doesn't as a computer startup script. tested situation: policy - windows settings - scripts - startup > hostname.bat contents of hostname.bat are: kix32.exe hostname.kix
seems that the kix isn't running at computer startup. when using a bat script like this then it worked, but i get the fulle computername and my goal was to try only display a part of the computername.
If Exist %WINDIR%\BGInfo.bmp Del %WINDIR%\BGInfo.bmp
\\server\netlogon\bginfo\Bginfo.exe /timer:0 /silent /NOLICPROMPT \\server\NetLogon\bginfo\hostname.bgi
anyone knows a batch script to do this? or maybe vbs, i thought vbs will run directly without calling it from a batch file.
thanks
Edited by arjanv (2012-01-27 10:42 AM)
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1574 anonymous users online.
|
|
|