MSFN Forum: CMD File Help - MSFN Forum

Jump to content



  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

CMD File Help User Input = Variable (Set=The User Input) Rate Topic: -----

#1 User is offline   Beta4Me 

  • Newbie
  • Group: Members
  • Posts: 27
  • Joined: 29-November 05

  Posted 03 October 2006 - 01:57 AM

The Topic title pretty much covers it but this is my problem:

I've seen this in Several CMD's but cannot understand how to do it.

I want to Ask a User to input something. Then that something becomes a variable (I think that's the word), i.e. Set Name=Something; (With Something being the User's Input).

I need to edit Reg settings after the Setup. But I want my Windows Setup to be a base setup that is customized in some parts by the user after the Setup, so it can be flexible.

Please Help me, :) , Your my only hope. Thanks in advance.

[offtopic]I hope this is in the right section.[/offtopic]


#2 User is offline   Br4tt3 

  • World famous sausage eater...
  • PipPipPipPip
  • Group: Members
  • Posts: 566
  • Joined: 20-April 04

Posted 03 October 2006 - 02:16 AM

I can only encourage u to run it from a .vbs script instead.. easier, better and more efficient IMHO, example:

Option Explicit

Dim Input, Command, WshShell

Set WshShell = WScript.CreateObject("WScript.Shell")

Input = InputBox("Application .exe name to run")
MsgBox ("You entered: " & Input)

'Exec the application of choice or whatever...
ExecApp(Input)

'******************
'* Execute Function
'******************
Function ExecApp(pstrCommand)
	Command = WshShell.Run(pstrCommand, 0, True)
End Function


Try for example: calc.exe and it will be launched.. u can then replace that with reg load or something else...

#3 User is offline   Ctrl-X 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 444
  • Joined: 29-August 06

Posted 03 October 2006 - 02:52 AM

To assign user input to an environment variable, use SET /P. For example:

SET /P INPUT=Type some input:
ECHO Your input was: %INPUT%


Type SET /? in a command prompt window for details.

#4 User is offline   mazin 

  • MSFN Addict
  • Group: Supreme Sponsor
  • Posts: 1,952
  • Joined: 12-January 04

Posted 03 October 2006 - 03:02 AM

View PostCtrl-X, on Oct 3 2006, 10:52 AM, said:

To assign user input to an environment variable, use SET /P. For example:

SET /P INPUT=Type some input:
ECHO Your input was: %INPUT%


Type SET /? in a command prompt window for details.

Yes, that easy. And the %INPUT% variable (as given by Ctrl-X) is valid during the session of your batch file
where you used SET.

In the same batch file, you can SET other variable like INPUT1, INPUT2, and so on.

#5 User is offline   Beta4Me 

  • Newbie
  • Group: Members
  • Posts: 27
  • Joined: 29-November 05

Posted 03 October 2006 - 04:30 AM

Thanks guys for your Help. Now I can have my Variables and Reg as i Like, :thumbup :thumbup :thumbup .

#6 User is offline   Beta4Me 

  • Newbie
  • Group: Members
  • Posts: 27
  • Joined: 29-November 05

Posted 04 October 2006 - 01:10 AM

Sorry to ask another Question but; Where in the registry are:
1 - Computer Name (As in the one in My Computer -> Properties -> Computer Name (Tab) -> Full Computer Name: ______)
2 - User Name (As in the one in My Computer -> Properties ->Registered to: ________) [e.g. Bob Jones]
3 - Company Name (As in the one in My Computer -> Properties ->Registered to: ________) [e.g. Bob Jones P/L]

Thanks in advance.

EDIT: My Current Files are as follows:
COMPUTERNAME.cmd

Quote

@echo off
TITLE=Post Windows Setup Customization

SET KEY=???

ECHO Type in the Name of this
ECHO Computer and then press Enter

:COMPUTERNAME
ECHO.
SET /P COMPUTERNAME=Computer Name:
ECHO Your input was: %COMPUTERNAME%
ECHO Type in YES to Change it or NO to Confirm.

:CHANGE
SET /P CHANGE=Change:
IF "%CHANGE%"=="YES" goto :COMPUTERNAME
IF "%CHANGE%"=="yes" goto :COMPUTERNAME
IF "%CHANGE%"=="Yes" goto :COMPUTERNAME
IF "%CHANGE%"=="yEs" goto :COMPUTERNAME
IF "%CHANGE%"=="yeS" goto :COMPUTERNAME
IF "%CHANGE%"=="YeS" goto :COMPUTERNAME
IF "%CHANGE%"=="YEs" goto :COMPUTERNAME
IF "%CHANGE%"=="NO" goto :REGISTRY
IF "%CHANGE%"=="no" goto :REGISTRY
IF "%CHANGE%"=="nO" goto :REGISTRY
IF "%CHANGE%"=="No" goto :REGISTRY
ECHO Error! Please Try again...
goto :CHANGE

:REGISTRY
REG ADD %KEY%
goto :END

:END
ECHO.
SET /P END=Press Enter to Exit...
exit
USERNAME.cmd

Quote

@echo off
TITLE=Post Windows Setup Customization

SET KEY=???

ECHO Type in your Name
ECHO and then press Enter

:NAME
ECHO.
SET /P NAME=Name:
ECHO Your input was: %NAME%
ECHO Type in YES to Change it or NO to Confirm.

:CHANGE
SET /P CHANGE=Change:
IF "%CHANGE%"=="YES" goto :NAME
IF "%CHANGE%"=="yes" goto :NAME
IF "%CHANGE%"=="Yes" goto :NAME
IF "%CHANGE%"=="yEs" goto :NAME
IF "%CHANGE%"=="yeS" goto :NAME
IF "%CHANGE%"=="YeS" goto :NAME
IF "%CHANGE%"=="YEs" goto :NAME
IF "%CHANGE%"=="Y" goto :NAME
IF "%CHANGE%"=="y" goto :NAME
IF "%CHANGE%"=="NO" goto :REGISTRY
IF "%CHANGE%"=="no" goto :REGISTRY
IF "%CHANGE%"=="nO" goto :REGISTRY
IF "%CHANGE%"=="No" goto :REGISTRY
IF "%CHANGE%"=="N" goto :REGISTRY
IF "%CHANGE%"=="n" goto :REGISTRY
ECHO Error! Please Try again...
goto :CHANGE

:REGISTRY
REG ADD %KEY%
goto :END

:END
ECHO.
SET /P Exit=Press Enter to Exit...
exit


COMPANYNAME.cmd

Quote

@echo off
TITLE=Post Windows Setup Customization

SET KEY=???

ECHO Type in the Name of your
ECHO Company and then press Enter

:COMPANYNAME
ECHO.
SET /P COMPANYNAME=Company Name:
ECHO Your input was: %COMPANYNAME%
ECHO Type in YES to Change it or NO to Confirm.

:CHANGE
SET /P CHANGE=Change:
IF "%CHANGE%"=="YES" goto :COMPANYNAME
IF "%CHANGE%"=="yes" goto :COMPANYNAME
IF "%CHANGE%"=="Yes" goto :COMPANYNAME
IF "%CHANGE%"=="yEs" goto :COMPANYNAME
IF "%CHANGE%"=="yeS" goto :COMPANYNAME
IF "%CHANGE%"=="YeS" goto :COMPANYNAME
IF "%CHANGE%"=="YEs" goto :COMPANYNAME
IF "%CHANGE%"=="NO" goto :REGISTRY
IF "%CHANGE%"=="no" goto :REGISTRY
IF "%CHANGE%"=="nO" goto :REGISTRY
IF "%CHANGE%"=="No" goto :REGISTRY
ECHO Error! Please Try again...
goto :CHANGE

:REGISTRY
REG ADD %KEY%
goto :END

:END
ECHO.
SET /P END=Press Enter to Exit...
exit


%KEY% in Each one is where the Appropriate Reg Entry is and the Variable set in the file is what will be Actually added as the "String Value".

EDIT 2: If it is Possible to Simplify the Stuff under :Change, any advice would be much appreciated.

This post has been edited by mandrake10: 04 October 2006 - 03:05 AM


#7 User is offline   mazin 

  • MSFN Addict
  • Group: Supreme Sponsor
  • Posts: 1,952
  • Joined: 12-January 04

Posted 04 October 2006 - 05:40 AM

I'm sorry, mandrake10. You'd better use cancerface's CreateUser utility.

#8 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 9,114
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 04 October 2006 - 07:25 AM

A couple of ideas:
 
@echo off
:CHANGE
SET /P CHANGE=Change:

For %%A in (YES YEs Yes yes yeS yES yEs YeS NO No no nO) DO IF %%A.==%CHANGE%. GOTO :Nextstep%CHANGE%
ECHO Error! Please Try again...
goto :CHANGE

:NextstepYES
REM was :COMPANYNAME
ECHO COMPANYNAME %CHANGE%
PAUSE
goto :CHANGE

:NextstepNO
REM was :REGISTRY
ECHO REGISTRY %CHANGE%
PAUSE
goto :CHANGE
 


 
@echo off
:CHANGE
SET /P CHANGE=Change:
ECHO %CHANGE% | FIND /I "YES " >nul
IF %ERRORLEVEL%==0 goto :COMPANYNAME
ECHO %CHANGE% | FIND /I "NO " >nul
IF %ERRORLEVEL%==0 goto :REGISTRY
ECHO Error! Please Try again...
goto :CHANGE

:COMPANYNAME
ECHO COMPANYNAME %CHANGE%
PAUSE
goto :CHANGE

:REGISTRY
ECHO REGISTRY %CHANGE%
PAUSE
goto :CHANGE
 


Please note that in your source you missed a couple of combination for "yEs"....

jaclaz

This post has been edited by jaclaz: 04 October 2006 - 07:26 AM


#9 User is offline   nakira 

  • Member
  • PipPip
  • Group: Members
  • Posts: 118
  • Joined: 18-July 04

Posted 04 October 2006 - 07:47 AM

IF has a switch to do case insensitive comparisons.
IF /I "blah" == "BLAH" <command>


#10 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 04 October 2006 - 11:57 AM

[quote name='nakira' post='568628' date='Oct 4 2006, 01:47 PM']IF has a switch to do case insensitive comparisons.
 
<HTML>
<HEAD>
	<TITLE>Owner Company & PC Name</TITLE>
	<HTA:APPLICATION
		applicationname="Owner Company & PC Name"
		maximizebutton="no"
		minimizebutton="no"
		scroll="no"
		showintaskbar="no"
		singleinstance="yes"
	/>
</HEAD>
<script language="VBScript">
	Sub regEdit
		strOrg = TextBox0.Value
		strName = TextBox1.Value
		strPC = TextBox2.Value
		Set oFS = CreateObject("Scripting.FileSystemObject")
		If strOrg = "" Then
			MsgBox "You need to fill in " & chr(34) & "Company" & chr(34),64,"Alert"
			document.getElementByID("textbox0").select
		ElseIf strName = "" Then
			MsgBox "You need to fill in " & chr(34) & "Owner" & chr(34),64,"Alert"
			document.getElementByID("textbox1").select
		ElseIf strPC = "" Then
			MsgBox "You need to fill in " & chr(34) & "PC Name" & chr(34),64,"Alert"
			document.getElementByID("textbox2").select
		Else
			Set strScript = oFS.OpenTextFile("Add2Reg.vbs",8,True)
			strScript.WriteLine "Set oShell = WScript.CreateObject(" & chr(34) & "WScript.Shell" & chr(34) & ")"
			strScript.WriteLine "Set oFS = CreateObject(" & chr(34) & "Scripting.FileSystemObject" & chr(34) & ")"
			strScript.WriteLine "strRoot = " & chr(34) & "HKLM" & chr(34)
			strScript.WriteLine "strOne = " & chr(34) & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\" & chr(34) & ""
			strScript.WriteLine "strTwo = " & chr(34) & "\System\CurrentControlSet\Control\ComputerName\ComputerName\" & chr(34) & ""
			strScript.WriteLine "strOrg = " & chr(34) & strOrg & chr(34)
			strScript.WriteLine "strName = " & chr(34) & strName & chr(34)
			strScript.WriteLine "strPC = " & chr(34) & strPC & chr(34)
			strScript.WriteLine "oShell.RegWrite strRoot & strOne & " & chr(34) & "RegisteredOrganization" & chr(34) & ", strOrg"
			strScript.WriteLine "oShell.RegWrite strRoot & strOne & " & chr(34) & "RegisteredOwner" & chr(34) & ", strName"
			strScript.WriteLine "oShell.RegWrite strRoot & strTwo & " & chr(34) & "ComputerName" & chr(34) & ", strPC"
			strScript.WriteLine "oFS.DeleteFile(WScript.ScriptFullName)"
			strScript.Close
			call runScript
		End If
	End Sub
	Sub runScript
		Set oShell = CreateObject("WScript.Shell")
		oShell.Run "Add2Reg.vbs"
		End Sub
	Sub reload
		window.location.reload
	End Sub
	Sub bodyLoaded()
		window.ResizeTo 402,220 ' WIDTH, HEIGHT
		TextBox0.focus()
	End Sub
</SCRIPT>
<BODY onLoad="bodyLoaded()" STYLE="font:12 pt arial; color:white;
	filter:progid:DXImageTransform.Microsoft.Gradient
	(GradientType=1, StartColorStr='#000000', EndColorStr='#00CC00')"
>
	<TABLE width="90%" border="0" cellpadding="6" align="left">
		<COLGROUP width="100%">
			<COL width="12%">
			<COL width="44%">
			<COL width="44%">
		</COLGROUP>
		<TR>
			<TD><B>&#187;&#160;Company&#160;&#58;</B></TD>
			<TD colspan="2"><input type="text" size="36" name="textbox0"></TD>
		</TR>
		<TR>
			<TD><B>&#187;&#160;Owner&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#58;</B></TD>
			<TD colspan="2"><input type="text" size="36" name="textbox1"></TD>
		</TR>
			<TD><B>&#187;&#160;PC</B>&#160;<B>Name&#160;&#160;&#58;</B></TD>
			<TD colspan="2"><input type="text" size="36" name="textbox2"></TD>
		<TR>
			<TD align="left" valign="bottom"><font color="white" size="1">Yz&#246;wl&#160;&#169;2006</font></TD>
			<TD align="right"><input type="button" value="Submit&#160;Data" name="run_button" onClick="regEdit"></TD>
			<TD align="right"><input type="button" value="Cancel" name="close_button" onClick="Self.Close"></TD>
		</TR>
	</TABLE>
</BODY> 
GSM, will probably be able to improve it too!

#11 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,020
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 04 October 2006 - 04:19 PM

Thank You Yzöwl
I have made some cosmetic changes to what you have done

Quote

<!-- ORIGINAL HTA AND SCRIPT BY YZOWL 
	 HTA RE EDIT BY GUNSMOKINGMAN -->
<HTML><HEAD>	
<TITLE>Owner Company & PC Name</TITLE>	
 <HTA:APPLICATION		
	applicationname="Owner Company & PC Name"		
	maximizebutton="no"		
	minimizebutton="no"		
	scroll="no"		
	showintaskbar="no"		
	singleinstance="yes"
	Icon="%SystemRoot%\explorer.exe">
  <STYLE type="text/css">
   Body 
	{
	  font:10.75pt; 
	  font-family: arial, Verdana, Palatino Linotype; 
	  color:#E3E3E3;
	  filter:progid:DXImageTransform.Microsoft.Gradient
	  (GradientType=0, StartColorStr='#00CC00', EndColorStr='#4E4E4E');
	  padding-top:1; 
	  padding-bottom:1; 
	  Text-Align:;
	} 
	.Button
	{ 
	  font: 8.25pt; 
	  font-family: Verdana, Palatino Linotype; 
	  color:#E1E1E1;
	  font-weight:bold; 
	  Text-Align:Center;
	  filter:progid:DXImageTransform.Microsoft.Gradient
	  (GradientType=0,StartColorStr='#d0d0d0',endColorStr='#008C80');
	  padding-top:1; 
	  padding-bottom:1; 
	  cursor:Hand; 
	  Height:19; width:93;
	  border-left: 1px Transparent; 
	  border-right: 2px Transparent;
	  border-top: 1px Transparent; 
	  border-Bottom: 2px Transparent;
	}
	.TextBackGround
	{
	  font:8.25pt; font-family: arial, Verdana, Palatino Linotype; 
	  color:#1E1E1E; 
	  font-weight:bold;
	  filter:progid:DXImageTransform.Microsoft.Gradient
	  (GradientType=0,StartColorStr='#e2ded8',EndColorStr='#e8e2de;');
	  padding-top:1; padding-bottom:1;
	  border-left: 3px Transparent;
	  border-right: 2px Transparent;
	  border-top: 3px Transparent;
	  border-Bottom: 2px Transparent;
	}
 </STYLE>
  &lt;script Language="JavaScript"> 
   var Act = new ActiveXObject("Wscript.Shell");  
   var Fso = new ActiveXObject("Scripting.FileSystemObject");
   /* CLOSE THE HTA -> */ 
   function ExitThis() { window.close();}
   /* RUN BUTTON CHANGE TEXT -> */ 
   function Button1ChangeText() { if (Run_Button.value =="Submit Data")
	{Run_Button.value ='Press To Add'
	Txt1.innerHTML= 'All Three Text Boxes Must Be Filled In. If Any<BR>' +
					'Text Box Is Not Filled In It Will Not Run The Script!' } 
	else {Run_Button.value ='Submit Data', Txt1.innerHTML= '';}}
   /* CLEAR BUTTON CHANGE TEXT -> */ 
   function Button2ChangeText() { if (Clear_Button.value =="Clear Text")
	{Clear_Button.value ='Clear All Text'} else {Clear_Button.value ='Clear Text';}}
   /* CLOSE BUTTON CHANGE TEXT -> */ 
   function Button3ChangeText() { if (Close_Button.value =="Close App")
	{Close_Button.value ='Good Bye'} else {Close_Button.value ='Close App';}}
  </SCRIPT> 
  &lt;script language="VBScript">	
   Dim strName, strOrg, strPC
 '/-> TEXT BOXES SCRIPTS
   Function RegEdit()	
	strOrg = TextBox0.Value	:  strName = TextBox1.Value :  strPC = TextBox2.Value		
	 If strOrg = "" Then			
	  window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Company" & chr(34)			
	  document.getElementByID("textbox0").select		
	 ElseIf strName = "" Then			
	  window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Owner" & chr(34),64,"Alert"			
	  document.getElementByID("textbox1").select		
	 ElseIf strPC = "" Then			
	  window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "PC Name" & chr(34),64,"Alert"			
	  document.getElementByID("textbox2").select		
	Else			
	 Set strScript = Fso.CreateTextFile("Add2Reg.vbs")			
	  strScript.WriteLine "Set Act = CreateObject(" & chr(34) & "WScript.Shell" & chr(34) & ")"			
	  strScript.WriteLine "Set Fso = CreateObject(" & chr(34) & "Scripting.FileSystemObject" & chr(34) & ")"			
	  strScript.WriteLine "strRoot = " & chr(34) & "HKLM" & chr(34)			
	  strScript.WriteLine "strOne = " & chr(34) & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\" & chr(34) & ""			
	  strScript.WriteLine "strTwo = " & chr(34) & "\System\CurrentControlSet\Control\ComputerName\ComputerName\" & chr(34) & ""			
	  strScript.WriteLine "strOrg = " & chr(34) & strOrg & chr(34)			
	  strScript.WriteLine "strName = " & chr(34) & strName & chr(34)			
	  strScript.WriteLine "strPC = " & chr(34) & strPC & chr(34)			
	  strScript.WriteLine "Act.RegWrite strRoot & strOne & " & chr(34) & "RegisteredOrganization" & chr(34) & ", strOrg"			
	  strScript.WriteLine "Act.RegWrite strRoot & strOne & " & chr(34) & "RegisteredOwner" & chr(34) & ", strName"			
	  strScript.WriteLine "Act.RegWrite strRoot & strTwo & " & chr(34) & "ComputerName" & chr(34) & ", strPC"			
	  strScript.WriteLine "Fso.DeleteFile(WScript.ScriptFullName)"			
	  strScript.Close			
	 call RunScript		
	End If	
   End Function	
 '/-> RUN NEW SCRIPT
   Function RunScript() : Act.Run("Add2Reg.vbs"), 1, True : End Function
 '/-> CLEAR THE TEXT BOXES 
   Function ClearText() : TextBox0.Value = "" : TextBox1.Value = "" : TextBox2.Value	= "" : End Function
 '/-> ON LOAD EVENT
   Function window_Onload() :  window.ResizeTo 402,220 : TextBox0.focus() :  End Function
  </SCRIPT>
  </HEAD><BODY><CENTER>
 <!-- TEXT BOX TABLE START --><TABLE width='90%' border='0' cellpadding='6'><TD>
 <!-- TEXT BOX 01 START -->
  <TABLE><TD Width='125'><B>» Company</TD><TD> :</B></TD>			
   <TD colspan="2"><Input type="text" Class='TextBackGround' size="36" name="textbox0">
  </TD></TABLE>	
 <!-- TEXT BOX 02 START -->
  <TABLE><TD Width='125'><B>» Owner</TD><TD> :</B></TD>			
   <TD colspan="2"><Input type="text" Class='TextBackGround' size="36" name="textbox1">
  </TD></TABLE>
 <!-- TEXT BOX 03 START -->
  <TABLE><TD Width='125'><B>» PC Name</TD><TD> :</B></TD>				
   <TD colspan="2"><Input type="text" Class='TextBackGround' size="36" name="textbox2"></TD>
  </TABLE></TD>
 <!-- TEXT BOX TABLE END --></TABLE>
 <!-- BUTTON TABLE START --><TABLE>
 <!-- RUN BUTTON START -->
  <TD Width='125' Align='Center'><Input type="button" Class='Button' Value="Submit Data" name="Run_Button" 
   OnMouseOver="Button1ChangeText(),this.style.color='#004f1a';" 
   OnMouseOut="Button1ChangeText(),this.style.color='#E1E1E1';" 
   onClick="RegEdit()"></TD>
 <!-- CLEAR BUTTON START -->
   <TD Width='125' Align='Center'><Input type="button" Class='Button' Value="Clear Text" name="Clear_Button" 
   OnMouseOver="Button2ChangeText(),this.style.color='#004f1a';" 
   OnMouseOut="Button2ChangeText(),this.style.color='#E1E1E1';" 
   onClick="ClearText()"></TD>	
 <!-- CLOSE BUTTON START -->
   <TD Width='125' Align='Center'><Input type="button" Class='Button' Value="Close App" name="Close_Button" 
   OnMouseOver="Button3ChangeText(),this.style.color='#004f1a';" 
   OnMouseOut="Button3ChangeText(),this.style.color='#E1E1E1';" 
   onClick="ExitThis()"></TD>			
 <!-- BUTTON TABLE END --> </TABLE></CENTER>
 <!-- YZOWL TABLE START -->
  <TABLE><TD WIDTH='300' HEIGHT='32' Style='font:8.75pt;Color:"#E1E1E1"'><SPAN ID='Txt1'></SPAN></TD>
  <TD><FONT color="#E1E1E1" size="1.25">Yzöwl ©2006</FONT></TD></TABLE>
 <!-- YZOWL TABLE END -->
  </BODY></HTML>

I have included the hta in a rar file

Attached File(s)


This post has been edited by gunsmokingman: 10 February 2007 - 09:22 AM


#12 User is offline   Beta4Me 

  • Newbie
  • Group: Members
  • Posts: 27
  • Joined: 29-November 05

Posted 05 October 2006 - 12:36 AM

Thanks guys (or girls, :angel) for your help, it is very appreciated. :thumbup
Now i hope i can help you one day.

EDIT: Hello, :hello: . Code tweaked by Mua:
<!-- ORIGINAL HTA AND SCRIPT BY YZOWL
	 HTA EDIT BY GUNSMOKINGMAN 
	 HTA RE-EDIT BY BETA4ME -->
<HTML><HEAD>	
<TITLE>Owner, Organization & PC Name</TITLE>	
 <HTA:APPLICATION		
	applicationname="Owner, Organization & PC Name"		
	maximizebutton="no"		
	minimizebutton="yes"		
	scroll="no"		
	showintaskbar="yes"		
	singleinstance="yes"
	Icon="%SystemRoot%\explorer.exe">
  <STYLE type="text/css">
   Body 
	{
	  font:10.75pt; 
	  font-family: arial, Verdana, Palatino Linotype; 
	  color:#E3E3E3;
	  filter:progid:DXImageTransform.Microsoft.Gradient
	  (GradientType=0, StartColorStr='#00CC00', EndColorStr='#4E4E4E');
	  padding-top:1; 
	  padding-bottom:1; 
	  Text-Align:;
	} 
	.Button
	{ 
	  font: 8.25pt; 
	  font-family: Verdana, Palatino Linotype; 
	  color:#E1E1E1;
	  font-weight:bold; 
	  Text-Align:Center;
	  filter:progid:DXImageTransform.Microsoft.Gradient
	  (GradientType=0,StartColorStr='#d0d0d0',endColorStr='#008C80');
	  padding-top:1; 
	  padding-bottom:1; 
	  cursor:Hand; 
	  Height:19; width:93;
	  border-left: 1px Transparent; 
	  border-right: 2px Transparent;
	  border-top: 1px Transparent; 
	  border-Bottom: 2px Transparent;
	}
	.TextBackGround
	{
	  font-family: arial, Verdana, Palatino Linotype; 
	  color:#1E1E1E; 
	  font-weight:bold;
	  filter:progid:DXImageTransform.Microsoft.Gradient (GradientType=0,StartColorStr=#e2ded8,EndColorStr=#e8e2de;
	  padding-top:1; padding-bottom:1;
	  border-left: 3px none Transparent;
	  border-right: 2px none Transparent;
	  border-top: 3px none Transparent;
	  border-Bottom: 2px none Transparent;; font-style:normal; font-variant:normal; font-size:8.25pt
	}
 </STYLE>
  <script Language="JavaScript"> 
   var Act = new ActiveXObject("Wscript.Shell");  
   var Fso = new ActiveXObject("Scripting.FileSystemObject");
   /* CLOSE THE HTA -> */ 
   function ExitThis() { window.close();}
   /* RUN BUTTON CHANGE TEXT -> */ 
   function Button1ChangeText() { if (Run_Button.value =="Submit Data")
	{Run_Button.value ='Press To Add'
	Txt1.innerHTML= 'All Three Text Boxes Must Be Filled In. <BR>If Any ' +
					'Text Box Is Not Filled In It Will Not <BR>Run The Script!' } 
	else {Run_Button.value ='Submit Data', Txt1.innerHTML= '';}}
   /* CLEAR BUTTON CHANGE TEXT -> */ 
   function Button2ChangeText() { if (Clear_Button.value =="Clear Text")
	{Clear_Button.value ='Clear Text'} else {Clear_Button.value ='Clear Text';}}
   /* CLOSE BUTTON CHANGE TEXT -> */ 
   function Button3ChangeText() { if (Close_Button.value =="Close App")
	{Close_Button.value ='Close App'} else {Close_Button.value ='Close App';}}
  </SCRIPT> 
  <script language="VBScript">	
   Dim strName, strOrg, strPC
 '/-> TEXT BOXES SCRIPTS
   Function RegEdit()	
	strOrg = TextBox0.Value	:  strName = TextBox1.Value :  strPC = TextBox2.Value		
	 If strOrg = "" Then			
	  window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Organization" & chr(34)			
	  document.getElementByID("textbox0").select		
	 ElseIf strName = "" Then			
	  window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Owner" & chr(34),64,"Alert"			
	  document.getElementByID("textbox1").select		
	 ElseIf strPC = "" Then			
	  window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "PC Name" & chr(34),64,"Alert"			
	  document.getElementByID("textbox2").select		
	Else			
	 Set strScript = Fso.CreateTextFile("Add2Reg.vbs")			
	  strScript.WriteLine "Set Act = CreateObject(" & chr(34) & "WScript.Shell" & chr(34) & ")"			
	  strScript.WriteLine "Set Fso = CreateObject(" & chr(34) & "Scripting.FileSystemObject" & chr(34) & ")"			
	  strScript.WriteLine "strRoot = " & chr(34) & "HKLM" & chr(34)			
	  strScript.WriteLine "strOne = " & chr(34) & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\" & chr(34) & ""			
	  strScript.WriteLine "strTwo = " & chr(34) & "\System\CurrentControlSet\Control\ComputerName\ComputerName\" & chr(34) & ""			
	  strScript.WriteLine "strThree = " & chr(34) & "\System\ControlSet001\Control\ComputerName\ComputerName\" & chr(34) & ""			
	  strScript.WriteLine "strFour = " & chr(34) & "\System\ControlSet002\Control\ComputerName\ComputerName\" & chr(34) & ""			
	  strScript.WriteLine "strFive = " & chr(34) & "\System\CurrentControlSet\Control\ComputerName\ActiveComputerName\" & chr(34) & ""			
	  strScript.WriteLine "strSix = " & chr(34) & "\System\ControlSet001\Control\ComputerName\ActiveComputerName\" & chr(34) & ""			
	  strScript.WriteLine "strOrg = " & chr(34) & strOrg & chr(34)			
	  strScript.WriteLine "strName = " & chr(34) & strName & chr(34)			
	  strScript.WriteLine "strPC = " & chr(34) & strPC & chr(34)			
	  strScript.WriteLine "Act.RegWrite strRoot & strOne & " & chr(34) & "RegisteredOrganization" & chr(34) & ", strOrg"			
	  strScript.WriteLine "Act.RegWrite strRoot & strOne & " & chr(34) & "RegisteredOwner" & chr(34) & ", strName"			
	  strScript.WriteLine "Act.RegWrite strRoot & strTwo & " & chr(34) & "ComputerName" & chr(34) & ", strPC"			
	  strScript.WriteLine "Act.RegWrite strRoot & strThree & " & chr(34) & "ComputerName" & chr(34) & ", strPC"			
	  strScript.WriteLine "Act.RegWrite strRoot & strFour & " & chr(34) & "ComputerName" & chr(34) & ", strPC"			
	  strScript.WriteLine "Act.RegWrite strRoot & strFive & " & chr(34) & "ComputerName" & chr(34) & ", strPC"			
	  strScript.WriteLine "Act.RegWrite strRoot & strSix & " & chr(34) & "ComputerName" & chr(34) & ", strPC"			
	  strScript.WriteLine "Fso.DeleteFile(WScript.ScriptFullName)"			
	  strScript.Close			
	 call RunScript		
	End If	
   End Function	
 '/-> RUN NEW SCRIPT AND THEN DELETE THE SCRIPT
   Function RunScript() : Act.Run("Add2Reg.vbs"), 1, True : End Function
 '/-> CLEAR THE TEXT BOXES 
   Function ClearText() : TextBox0.Value = "" : TextBox1.Value = "" : TextBox2.Value	= "" : End Function
 '/-> ON LOAD EVENT
   Function window_Onload() :  window.ResizeTo 440,260 : TextBox0.focus() :  End Function
  </SCRIPT>
  </HEAD><BODY><CENTER>
 <!-- TEXT BOX TABLE START --><TABLE width='90%' border='1' cellpadding='6'><TD>
 <!-- TEXT BOX 01 START -->
  <TABLE><TD Width='125'><B>» Organization</TD><TD> :</B></TD>			
   <TD colspan="2"><Input type="text" Class='TextBackGround' size="36" name="textbox0">
  </TD></TABLE>	
 <!-- TEXT BOX 02 START -->
  <TABLE><TD Width='125'><B>» Owner</TD><TD> :</B></TD>			
   <TD colspan="2"><Input type="text" Class='TextBackGround' size="36" name="textbox1">
  </TD></TABLE>
 <!-- TEXT BOX 03 START -->
  <TABLE><TD Width='125'><B>» PC Name</TD><TD> :</B></TD>				
   <TD colspan="2"><Input type="text" Class='TextBackGround' size="36" name="textbox2"></TD>
  </TABLE></TD>
 <!-- TEXT BOX TABLE END --></TABLE>
 <p style="margin-top: 0; margin-bottom: 0">&nbsp;</p>
 <!-- BUTTON TABLE START --><TABLE>
 <!-- RUN BUTTON START -->
  <TD Width='125' Align='Center'><Input type="button" Class='Button' Value="Submit Data" name="Run_Button" 
   OnMouseOver="Button1ChangeText(),this.style.color='#004f1a';" 
   OnMouseOut="Button1ChangeText(),this.style.color='#E1E1E1';" 
   onClick="RegEdit()"></TD>
 <!-- CLEAR BUTTON START -->
   <TD Width='125' Align='Center'><Input type="button" Class='Button' Value="Clear Text" name="Clear_Button" 
   OnMouseOver="Button2ChangeText(),this.style.color='#004f1a';" 
   OnMouseOut="Button2ChangeText(),this.style.color='#E1E1E1';" 
   onClick="ClearText()"></TD>	
 <!-- CLOSE BUTTON START -->
   <TD Width='125' Align='Center'><Input type="button" Class='Button' Value="Close App" name="Close_Button" 
   OnMouseOver="Button3ChangeText(),this.style.color='#004f1a';" 
   OnMouseOut="Button3ChangeText(),this.style.color='#E1E1E1';" 
   onClick="ExitThis()"></TD>			
 <!-- BUTTON TABLE END --> </TABLE></CENTER>
 <!-- Yzöwl TABLE START -->
  <TABLE><TD WIDTH='236' HEIGHT='47' Style='font:8.75pt;Color:"#E1E1E1"'><SPAN ID='Txt1'></SPAN></TD>
  <TD><FONT color="#E1E1E1" size="1.25">© 2006 Yzöwl. All Rights Reserved</FONT></TD></TABLE>
 <!-- Yzöwl TABLE END -->
  </BODY></HTML>

Tell me what you think!

This post has been edited by mandrake10: 06 October 2006 - 02:07 AM


#13 User is offline   Beta4Me 

  • Newbie
  • Group: Members
  • Posts: 27
  • Joined: 29-November 05

Posted 05 October 2006 - 03:34 AM

Bugger, the Reg Entries in there DON'T change the Computer Name. Org & Owner Name's work but Computer Name don't, any help please. :hello:

EDIT: NVM. The My Computer Properties shows the old Name :realmad: . But Windows actually recognizes it as the new name :huh: . Weird, huh :wacko: . Is there some-way to "Refresh" or "Update" the dialogue? Plzzzz...
EDIT 2: Even after Reboots still shows old name.

This post has been edited by mandrake10: 06 October 2006 - 12:38 AM


#14 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 9,114
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 05 October 2006 - 08:19 AM

OK, just for the record, now that everyone has had his part of fun :thumbup and hopefully mandrake10 has learned a few neat tricks, why not using a more featured, pre-made FREEWARE and OPEN SOURCE app?:
http://gravityfx.org/
http://gravityfx.org/?id=projects
http://gravityfx.org/?id=wxp

(a .NET solution, so not really useful unless you need .NET for any other more meaningful reason)

jaclaz

#15 User is offline   Beta4Me 

  • Newbie
  • Group: Members
  • Posts: 27
  • Joined: 29-November 05

Posted 06 October 2006 - 12:37 AM

View Postjaclaz, on Oct 6 2006, 12:19 AM, said:

OK, just for the record, now that everyone has had his part of fun :thumbup and hopefully mandrake10 has learned a few neat tricks, why not using a more featured, pre-made FREEWARE and OPEN SOURCE app?:
http://gravityfx.org/
http://gravityfx.org/?id=projects
http://gravityfx.org/?id=wxp

(a .NET solution, so not really useful unless you need .NET for any other more meaningful reason)

jaclaz

Thanks for that, it's got tonnes of Tweak Settings, but would take too long to use to Mod my system. If you read my posts up above; I need to Edit the Computer Name, Owner's Name & Organization's Name ONLY. My CMD's work fine, and the HTA is great (Nice GUI). It does what i need it to do no more, no less. My Reg tweaks are imported during the Windows Setup and RunOnceEx, so i do not need to tweak anything more.
If someone could answer this question:

Quote

EDIT: NVM. The My Computer Properties shows the old Name :realmad: . But Windows actually recognizes it as the new name :huh: . Weird, huh. Is there some-way to "Refresh" or "Update" the dialogue? Plzzzz...
EDIT 2: Even after Reboots still shows old name.

that is all I need :yes: , thanks... ;)

This post has been edited by mandrake10: 06 October 2006 - 12:39 AM


#16 User is offline   cancerface 

  • a n00b for life
  • PipPip
  • Group: Members
  • Posts: 135
  • Joined: 27-February 05

Posted 06 October 2006 - 02:14 AM

Hi mandrake10,
I wrote a tool that can be used to change the computer name and registered owner/organization using a GUI. In addition it can take values from an INI file where you can specify different MACs for different PCs and depending on the MAC address detected upon execution, the appropriate values will be automatically picked from the INI file. It can be found in this thread

CF

#17 User is offline   Beta4Me 

  • Newbie
  • Group: Members
  • Posts: 27
  • Joined: 29-November 05

Posted 06 October 2006 - 02:33 AM

View Postcancerface, on Oct 6 2006, 06:14 PM, said:

Hi mandrake10,
I wrote a tool that can be used to change the computer name and registered owner/organization using a GUI. In addition it can take values from an INI file where you can specify different MACs for different PCs and depending on the MAC address detected upon execution, the appropriate values will be automatically picked from the INI file. It can be found in this Thread.

CF

Thanks, this is Really Cool and I will most likely use it. But if someone can answer the question in my previous post, it will be much appreciated. :yes: Thanks, ;)

This post has been edited by mandrake10: 06 October 2006 - 02:33 AM


#18 User is offline   cancerface 

  • a n00b for life
  • PipPip
  • Group: Members
  • Posts: 135
  • Joined: 27-February 05

Posted 06 October 2006 - 03:21 AM

I am using direct API calls to set the new computer name and upon reboot the correct new name is displayed.
There is also a freeware command line tool that does the same called compname.exe.

Looking at your HTA script, you change the computer name in the registry only. I am under the impression that this is not the way to change the NetBios name and that's why you end up with the old name.

CF

#19 User is offline   Beta4Me 

  • Newbie
  • Group: Members
  • Posts: 27
  • Joined: 29-November 05

Posted 06 October 2006 - 09:38 PM

Can someone please convert this:

Quote

net user %USERNAME% %PASS% /add
net localgroup %GROUP% %USERNAME% /add
net accounts /maxpwage:unlimited

to a VBScript Replacing:
%USERNAME% -> strUser
%PASS% -> strPass
%GROUP% -> strGroup

#20 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,020
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 06 October 2006 - 11:28 PM

This is not a full script but it should help you do what you want.

Quote

Dim Act : Set Act = CreateObject("Wscript.shell")
  Dim StrUser : StrUser = Act.ExpandEnvironmentStrings("%UserName%")
  Dim StrPass 
   StrPass = InputBox("Type in the password","Password")
   If StrPass <> "" Then 
	MsgBox "User Type In : " & StrPass & vbCrLf &_
		   "User Name	: " & StrUser, 0 + 32 + 4096, "Password"
   Else 
	MsgBox "Nothing was type in preparing to quit", 0 + 32 + 4096, "No Text Detected"
   End If


Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy