Hello all,
I was wondering if someone could help me with this script. I need to allow a inputbox function to allow the user to change the name of the My computer icon.
I have this code below, which changes the name of the My Computer icon to the system name... I want to let the user change it... i am going to be using it for Imaging.
Thanks in Advance...
------------------------------------------------------------------------
Name=InputBox("Enter the computer name you want")
const MY_COMPUTER = &h11&
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
objFolderItem.Name = strComputer
Page 1 of 1
Script to change My computer Icon name
#2
Posted 02 January 2008 - 08:32 PM
#3
Posted 02 January 2008 - 11:57 PM
Nice program man... very nice
...
what if i want to change some of the code.. what do i need to save the file as?
what if i want to change some of the code.. what do i need to save the file as?
#5
Posted 03 January 2008 - 01:02 PM
I am using your code and i added a network printer & join a domain option also but i keep gettin errors... maybe i am not using the Function command correctly...
can you help me buddy.. Below i have my code that i used to create vbs script to do those command, but i want to but those into your .hta file
Add Network Printer Code
-----------------------------------------
Set WshNetwork = CreateObject("WScript.Network")
strFullPath = Inputbox("Please enter the full path of your network printer here:" _
"Example:\\extremeserver01\delllase","Enter Printer Path")
strPrintSrvrPath = "\\<servername>\"
strPrinterName = Inputbox("Please enter the name of your network printer here:" _
"Example:delllase","Enter Printer Name")
If strFullPath = "" Then
strFullPath = strPrintSrvrPath & strPrinterName
End If
WshNetwork.AddWindowsPrinterConnection strFullPath
Msgbox "Printer " & strFullPath & " Installed"
Join A Domain Code
-----------------------------------------
Name = InputBox("Enter the new computer name below and click OK to Continue Example:laptop1","Rename: Step 1")
Password = "i8bobokh"
Username = "aayobi"
Set objWMIService = GetObject("Winmgmts:root\cimv2")
' Call always gets only one Win32_ComputerSystem object.
For Each objComputer in _
objWMIService.InstancesOf("Win32_ComputerSystem")
Return = objComputer.rename(Name,Password,User)
If Return <> 0 Then
WScript.Echo "Rename failed. Error = " & Err.Number
Else
WScript.Echo "Rename succeeded." & " Reboot for new name to go into effect"
End If
Next
DomainName = InputBox("Enter the Domain to join this computer to and click OK to continue","Rename: Step 1")
DomainPassword = "i8bobokh"
DomainUsername = "aayobi"
Set objWMIService = GetObject("Winmgmts:root\cimv2")
' Call always gets only one Win32_ComputerSystem object.
For Each objComputer in _
objWMIService.InstancesOf("Win32_ComputerSystem")
Return = objComputer.JoinDomainOrWorkgroup(DomainName,DomainPassword,DomainUsername)
If Return <> 0 Then
WScript.Echo "Rename failed. Error = " & Err.Number
Else
WScript.Echo "Rename succeeded." & " Reboot for new name to go into effect"
End If
Next
-------------------------------------------------
Thanks again
can you help me buddy.. Below i have my code that i used to create vbs script to do those command, but i want to but those into your .hta file
Add Network Printer Code
-----------------------------------------
Set WshNetwork = CreateObject("WScript.Network")
strFullPath = Inputbox("Please enter the full path of your network printer here:" _
"Example:\\extremeserver01\delllase","Enter Printer Path")
strPrintSrvrPath = "\\<servername>\"
strPrinterName = Inputbox("Please enter the name of your network printer here:" _
"Example:delllase","Enter Printer Name")
If strFullPath = "" Then
strFullPath = strPrintSrvrPath & strPrinterName
End If
WshNetwork.AddWindowsPrinterConnection strFullPath
Msgbox "Printer " & strFullPath & " Installed"
Join A Domain Code
-----------------------------------------
Name = InputBox("Enter the new computer name below and click OK to Continue Example:laptop1","Rename: Step 1")
Password = "i8bobokh"
Username = "aayobi"
Set objWMIService = GetObject("Winmgmts:root\cimv2")
' Call always gets only one Win32_ComputerSystem object.
For Each objComputer in _
objWMIService.InstancesOf("Win32_ComputerSystem")
Return = objComputer.rename(Name,Password,User)
If Return <> 0 Then
WScript.Echo "Rename failed. Error = " & Err.Number
Else
WScript.Echo "Rename succeeded." & " Reboot for new name to go into effect"
End If
Next
DomainName = InputBox("Enter the Domain to join this computer to and click OK to continue","Rename: Step 1")
DomainPassword = "i8bobokh"
DomainUsername = "aayobi"
Set objWMIService = GetObject("Winmgmts:root\cimv2")
' Call always gets only one Win32_ComputerSystem object.
For Each objComputer in _
objWMIService.InstancesOf("Win32_ComputerSystem")
Return = objComputer.JoinDomainOrWorkgroup(DomainName,DomainPassword,DomainUsername)
If Return <> 0 Then
WScript.Echo "Rename failed. Error = " & Err.Number
Else
WScript.Echo "Rename succeeded." & " Reboot for new name to go into effect"
End If
Next
-------------------------------------------------
Thanks again
#6
Posted 04 January 2008 - 02:27 AM
Here a suggestion about the Printer stuff you should use a ListBox With All the paths and names as values.
This would save any user errors for typing in the address and name. This HTA just adds a 100 things to a
Listbox it and when you select the item in the listbox it returns the value of the listbox selected item. The
Listbox could also use a textfile to load it information.
Here is a example of what I mean.
Save As Example_LoadListBos.hta
This would save any user errors for typing in the address and name. This HTA just adds a 100 things to a
Listbox it and when you select the item in the listbox it returns the value of the listbox selected item. The
Listbox could also use a textfile to load it information.
Here is a example of what I mean.
Save As Example_LoadListBos.hta
Quote
<!--
Created By Gunsmokingman
Friday, January 04, 2008
-->
<HTML><HEAD>
<TITLE>Example_LoadListBox</TITLE>
<HTA:APPLICATION ID='ExampleLoadListBox'
Scroll='No'
SCROLLFLAT ='No'
SingleInstance='Yes'
SysMenu='Yes'
ShowInTaskBar='No'
MaximizeButton='No'
MinimizeButton='No'
Border='Thin'
BORDERSTYLE ='complex'
INNERBORDER ='Yes'
Caption='Yes'
WindowState='Normal'
APPLICATIONNAME='Example_LoadListBox'
Icon='%SystemRoot%\explorer.exe'>
<STYLE Type="text/css">
Body
{
Font-Size:8.05pt;
Font-Weight:Bold;
Font-Family:segoeui,helvetica,verdana,arial,Poor Richard;
Color:#001254;
BackGround-Color:Transparent;
Filter:progid:DXImageTransform.Microsoft.Gradient
(StartColorStr='#fdf7f1',endColorStr='#d1cbc5');
Margin-Top:1;
Margin-Bottom:1;
Margin-Left:4;
Margin-Right:4;
Padding-Top:1;
Padding-Bottom:1;
Padding-Left:4;
Padding-Right:4;
Text-Align:Center;
Vertical-Align:Top;
Border-Top:2px Solid #cbc7c3;
Border-Bottom:3px Solid #a6a29e;
Border-Left:2px Solid #bcb8b4;
Border-Right:3px Solid #b2aeaa;
}
Select.Bx1
{
Font-Size:7.95pt;
Font-Weight:Bold;
Font-Family:segoeui,helvetica,verdana,arial,Poor Richard;
BackGround:#D9D9D9;
}
</STYLE>
<script Language="VBScript">
window.resizeTo 279,171
Dim Arrow1 : Arrow1 = Chr(160) & Chr(187) & Chr(160)
Dim Arrow2 : Arrow2 = Chr(160) & Chr(171) & Chr(160)
'-> OnLoad Event Script To Load The ListBox
Function Window_onLoad
Do Until CT = 100
CT = CT + 1
If Len(CT) = 1 Then CT = "00" & CT
If Len(CT) = 2 Then CT = "0" & CT
If Len(CT) = 3 Then CT = CT
Set objOption = Document.createElement("OPTION")
objOption.Text = Arrow1 & "Printer Name " & Arrow1 & CT
objOption.Value = Arrow1 & "Printer Path " & Arrow1 & CT
If CT Mod 2 Then
objOption.style.backgroundcolor = "#D9D9D9"
objOption.style.color = "#3A3A3A"
Else
objOption.style.backgroundcolor = "#E9E9E9"
objOption.style.color = "#235779"
End If
PrinterSelect.Add(objOption)
Loop
Exit Function
End Function
Function PrinterSelectValue()
For i = 0 to (PrinterSelect.Options.Length - 1)
If (PrinterSelect.Options(i).Selected) Then
'-> Does Nothing But To Avoid This Being Selected
If PrinterSelect.Options(i).Value = "Nothing Selected" Then
Exit For
Exit Function
Else
alert(PrinterSelect.Options(i).Value)
End If
End If
Next
Exit Function
End Function
</SCRIPT>
<BODY><DIV>Select Your Network Computer Name</Div>
<SELECT size='6.25' Name='PrinterSelect' Style='width:150pt;' Class='Bx1'
OnChange='PrinterSelectValue()'>
<OPTION Value='Nothing Selected'> « Select Your Printers Name » </Option>
</SELECT>
</BODY>
#8
Posted 07 January 2008 - 12:58 AM
I have made you a Hta that will process a text file to fill the ListBox.
1:\ Make a text file, I used Printers.txt as a example, you can included
a full path such as "C:\Some_Folder\Sub_Folder\Printers.txt"
2:\ The text inside must be in this format, I use the - this to break up the line in the script.
Save As SelectPrinters.hta
1:\ Make a text file, I used Printers.txt as a example, you can included
a full path such as "C:\Some_Folder\Sub_Folder\Printers.txt"
Quote
StrTextFile = "Printers.txt"
2:\ The text inside must be in this format, I use the - this to break up the line in the script.
Quote
Server Name - Http://www.ServerAddress.com
Save As SelectPrinters.hta
Quote
<!--
Created By Gunsmokingman Sunday, January 06, 2008
-->
<HTML><HEAD>
<TITLE>SelectPrinters</TITLE>
<HTA:APPLICATION ID='Select_Printers'
Scroll='No'
SCROLLFLAT ='No'
SingleInstance='Yes'
SysMenu='Yes'
ShowInTaskBar='No'
MaximizeButton='No'
MinimizeButton='No'
Border='Thin'
BORDERSTYLE ='complex'
INNERBORDER ='Yes'
Caption='Yes'
WindowState='Normal'
APPLICATIONNAME='SelectPrinters'
Icon='%SystemRoot%\explorer.exe'>
<STYLE Type="text/css">
Body
{
Font-Size:9.05pt;
Font-Weight:Bold;
Font-Family:Arial,Tahoma,Comic Sans MS,Segoe Ui;
Color:#001254;
BackGround-Color:Transparent;
Filter:progid:DXImageTransform.Microsoft.Gradient
(StartColorStr='#fdf7f1',endColorStr='#d1cbc5');
Margin-Top:1;
Margin-Bottom:1;
Margin-Left:4;
Margin-Right:4;
Padding-Top:1;
Padding-Bottom:1;
Padding-Left:4;
Padding-Right:4;
Text-Align:Center;
Vertical-Align:Top;
Border-Top:2px Solid #cbc7c3;
Border-Bottom:3px Solid #a6a29e;
Border-Left:2px Solid #bcb8b4;
Border-Right:3px Solid #b2aeaa;
}
Select.Bx1
{
Font-Size:7.95pt;
Font-Weight:Bold;
Font-Family:Arial,Tahoma,Comic Sans MS,Segoe Ui;
}
.Sel1
{
BackGround:#D9D9D9;
Color:#3A3A3A;
}
.Sel2
{
BackGround:#E9E9E9;
Color:#235779;
}
BUTTON
{
Cursor:Hand;
Font-Size:8.05pt;
Font-Weight:Bold;
Font-Family:Arial,Tahoma,Comic Sans MS,Segoe Ui;
Color:#002264;
Filter:progid:DXImageTransform.Microsoft.Gradient
(StartColorSTR='#bbddff',endColorSTR='#224488');
Padding-Top:1;
Padding-Bottom:2;
Margin-Left:2pt;
Margin-Right:2pt;
Border-Top:2px TransParent;
Border-Bottom:3px TransParent;
Border-Left:2px TransParent;
Border-Right:3px TransParent;
}
.B1
{
Color:#005353;
Filter:progid:DXImageTransform.Microsoft.Gradient
(StartColorSTR='#bbddff',endColorSTR='#228844');
}
</STYLE>
<script LANGUAGE='JScript'>
window.resizeTo (225,139), window.moveTo (195,175);
</SCRIPT>
<script Language="VBScript">
Const ForReading = 1
Dim C1, objOption, objTextFile, strText, StrTextFile, Ts
Dim ArrPrinter, StrPrinter, Var1, Var2, Var3
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Var3=Chr(160) & Chr(160)
'-> Place A Full Path To The Text File Here
StrTextFile = "Printers.txt"
Function Window_onLoad()
'-> Check To See If The Text File Exists
If Fso.FileExists(StrTextFile) Then
ReadTheTextFile()
BuildListBox()
Else
'-> If Missing Will Only Have One Line Of Text
Set objOption = Document.createElement("OPTION")
objOption.Text = "Missing Printer Text List"
objOption.Value = "Missing Printer Text List"
objOption.style.backgroundcolor = "#E9E9E9"
objOption.style.color = "#235779"
PrinterNumber.Add(objOption)
PrinterNumber.size="1.55"
End If
Exit Function
End Function
'-> Reads The Text File
Function ReadTheTextFile()
Set objTextFile = Fso.OpenTextFile(StrTextFile, ForReading)
strText = objTextFile.ReadAll
objTextFile.Close()
ArrPrinter = Split(strText, vbCrLf)
Exit Function
End Function
'-> Build The ListBox From The Text File
Function BuildListBox()
'-> StrPrinter = Array Each Line In The Text File Is A Value From ArrPrinter
For Each StrPrinter in ArrPrinter
'-> This Makes Sure It Process This Line Type
''' Server Name - Http://www.ServerAddress.com
If InStr(StrPrinter," - ") Then
'-> Counter
C1 = C1 + 1
'-> This Makes C1 Look Like 001, 010, 100
If Len(C1) = 1 Then C1 = "00" & C1
If Len(C1) = 2 Then C1 = "0" & C1
If Len(C1) = 3 Then C1 = C1
'-> Splits StrPrinter To Form The Next Array
Var1 = Split(StrPrinter," - ")
For Each Var2 In Var1
Set objOption = Document.createElement("OPTION")
objOption.Text = Var3 & C1 & Var3 & Var1(0)
objOption.Value = Var1(1)
If C1 Mod 2 Then
objOption.style.backgroundcolor = "#E9E9E9"
objOption.style.color = "#235779"
Else
objOption.style.backgroundcolor = "#D9D9D9"
objOption.style.color = "#3A3A3A"
End If
Next
PrinterNumber.Add(objOption)
End If
Next
Exit Function
End Function
'-> ListBox Select
Function PrinterNumberSelect()
For i = 0 to (PrinterNumber.Options.Length - 1)
If (PrinterNumber.Options(i).Selected) Then
If PrinterNumber.Options(i).Value = "Printer Number" Then
Exit For
Exit Function
Else
'-> Place Your Code In Here Start
'''' Remove This MessageBox If Not Needed
alert(PrinterNumber.Options(i).Text & vbCrlf & PrinterNumber.Options(i).Value)
'-> Place Your Code In Here End
End If
End If
Next
Exit Function
End Function
</SCRIPT>
</HEAD><BODY Scroll='No'>Select Your Printer Server Name
<SELECT size='4.55' name='PrinterNumber' style='width:131pt;' Class='Bx1'
OnChange='PrinterNumberSelect()'>
<OPTION Value='Printer Number' Class='Sel1'> Printer Server Name</OPTION>
</SELECT>
<DIV Style='Margin-Top:3pt;'>
<BUTTON ID='Btn01'
OnMouseOver='this.className="B1"'
OnMouseOut='this.className=""'
Onclick='window.close()'
Style='Width:45pt;Height:13pt;'>Close</BUTTON>
</DIV>
</BODY></HTML>
#9
Posted 08 January 2008 - 10:38 PM
Thanks for all your help... This code is helps big time.. Thanks again gunsmokingman
- ← VB launching application within its own folder
- Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
- vbs & wireless →
Share this topic:
Page 1 of 1



Help
Back to top









