Jump to content

CMD File Help


Recommended Posts

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

Link to comment
Share on other sites


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, ;)

Edited by mandrake10
Link to comment
Share on other sites

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

Link to comment
Share on other sites

Can someone please convert this:

net user %USERNAME% %PASS% /add

net localgroup %GROUP% %USERNAME% /add

net accounts /maxpwage:unlimited

to a VBScript Replacing:

%USERNAME% -> strUser

%PASS% -> strPass

%GROUP% -> strGroup

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

This is not a full script but it should help you do what you want.
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

Thanks, but that is not what i need. I guess i wasn't specific enough. Please Let me explain everyting:

I used the file Yzowl and GSM put together and tweaked it. Then i made this file:

@echo Off

TITLE User Account Creation

ECHO Create Desired amount of User Accounts with a

ECHO set Username and Password that Never Expires.

:USER

ECHO.

ECHO.

ECHO Type in Username and Password for Account

ECHO Note: Case-Sensitive

ECHO.

SET /P USERNAME=Username:

SET /P PASS=Password:

ECHO.

ECHO Your input was...

ECHO Username: %USERNAME%

ECHO Password: %PASS%

ECHO Type in YES to Change it or NO to Confirm.

:CHANGE

SET /P CHANGE=Change:

IF /I "%CHANGE%"=="YES" goto :USER

IF /I "%CHANGE%"=="Y" goto :USER

IF /I "%CHANGE%"=="NO" goto :GROUP

IF /I "%CHANGE%"=="N" goto :GROUP

ECHO Error! Please Try again (Yes/No)...

goto :CHANGE

:GROUP

ECHO.

ECHO Please Specify account User Privelages...

ECHO Note that:

ECHO 1 = Administrators

ECHO 2 = Users

ECHO 3 = Guests

SET /P GROUP=Group:

IF /I "%GROUP%"=="1" SET GROUP=Administrators

IF /I "%GROUP%"=="2" SET GROUP=Users

IF /I "%GROUP%"=="3" SET GROUP=Guests

goto :FINALISE

:FINALISE

cls

ECHO.

ECHO The Account you will create has the

ECHO following attributes:

ECHO.

ECHO Username: %USERNAME%

ECHO Password: %PASS%

ECHO Group: %GROUP%

ECHO.

:CHANGE1

ECHO Type in YES to Change it or NO to Confirm.

SET /P CHANGE1=Change:

IF /I "%CHANGE1%"=="YES" goto :USER

IF /I "%CHANGE1%"=="Y" goto :USER

IF /I "%CHANGE1%"=="NO" goto :CREATION

IF /I "%CHANGE1%"=="N" goto :CREATION

ECHO Error! Please Try again (Yes/No)...

goto :CHANGE1

:CREATION

ECHO.

ECHO Creating %USERNAME%'s Account...

net user %USERNAME% %PASS% /add

net localgroup %GROUP% %USERNAME% /add

net accounts /maxpwage:unlimited

cls

ECHO Task Completed Successfully

goto :CHOICE

:CHOICE

cls

ECHO Do you want to Create any more User Accounts?

ECHO Type in YES to create more or NO to Exit

SET /P CREATION=Change:

IF /I "%CREATION%"=="YES" goto :USER

IF /I "%CREATION%"=="Y" goto :USER

IF /I "%CREATION%"=="NO" goto :END

IF /I "%CREATION%"=="N" goto :END

:END

ECHO.

SET /P END=Press Enter to Exit...

exit

I then decided I wanted it in the same style as the HTA.

So i modded it like this:

<!-- ORIGINAL HTA AND SCRIPT BY YZOWL

HTA EDIT BY GUNSMOKINGMAN

HTA RE-EDIT BY BETA4ME -->

<HTML><HEAD>

<TITLE>User Account Creation</TITLE>

<HTA:APPLICATION

applicationname="User Account Creation"

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 strPass, strName, strGroup

'/-> TEXT BOXES SCRIPTS

Function RegEdit()

strName = TextBox0.Value : strPass = TextBox1.Value : strGroup = TextBox2.Value

If strName = "" Then

window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Username" & chr(34)

document.getElementByID("textbox0").select

ElseIf strPass = "" Then

window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Password" & chr(34),64,"Alert"

document.getElementByID("textbox1").select

ElseIf strGroup = "" Then

window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Group" & chr(34),64,"Alert"

document.getElementByID("textbox2").select

'/-> START SCRIPT

Else

Set strScript = Fso.CreateTextFile("CreateUser.vbs")

strScript.WriteLine "Set Act = CreateObject(" & chr(34) & "WScript.Shell" & chr(34) & ")"

strScript.WriteLine "Set Fso = CreateObject(" & chr(34) & "Scripting.FileSystemObject" & chr(34) & ")"

'/-> BODY of SCRIPT

strScript.WriteLine "Fso.DeleteFile(WScript.ScriptFullName)"

strScript.Close

call RunScript

End If

End Function

'/-> FINISH SCRIPT

'/-> RUN NEW SCRIPT AND THEN DELETE THE SCRIPT

Function RunScript() : Act.Run("CreateUser.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>» Username</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>» Password</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>» Group</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"> </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>

The section in Red, is another section of the Script i Edited (more like purged) and doesn't work. I need the CMD section that is in Red to be converted to VBS to put in (i think). Substituting %USERNAME% with strUser, %PASS% with strPass, and %GROUP% with strGroup.

Thanks peeps for all your help, :thumbup .

Edited by mandrake10
Link to comment
Share on other sites

I made this hta that adds user pass password and groups.

The Thread

This is what it looks like

ManageUsers.png

The Hta Link To Down Load

Here is a re edit VBS script for the hta that does what you ask for add it to your HTA

Dim IntC, strPass, strName, strGroup
'/-> TEXT BOXES SCRIPTS
Function RegEdit()
strName = TextBox0.Value : strPass = TextBox1.Value : strGroup = TextBox2.Value
If strName = "" Then
window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Username" & chr(34)
document.getElementByID("textbox0").select
Else
IntC = 1
End If
If strPass = "" Then
window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Password" & chr(34),64,"Alert"
document.getElementByID("textbox1").select
Else
IntC = IntC + 1
End If
If strGroup = "" Then
window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Group" & chr(34),64,"Alert"
document.getElementByID("textbox2").select
Else
IntC = IntC + 1
End If
'/-> THIS IS A CHECK IT WILL ONLY GOTO MAKESCRIPT() IF IT EQUALS 3
If IntC = 3 Then MakeScript() End If
End Function
'/->
Function MakeScript()
'/-> START SCRIPT
window.alert("Preparing To Make The script")
Set strScript = Fso.CreateTextFile("CreateUser.vbs")
strScript.WriteLine "Set Act = CreateObject(" & chr(34) & "WScript.Shell" & chr(34) & ")"
strScript.WriteLine "Set Fso = CreateObject(" & chr(34) & "Scripting.FileSystemObject" & chr(34) & ")"
'/-> BODY of SCRIPT
strScript.WriteLine "Fso.DeleteFile(WScript.ScriptFullName)"
strScript.Close
call RunScript
End Function

Edited by gunsmokingman
Link to comment
Share on other sites

Thanks put it only display a Msg Box saying "Preparing Script" what i need it to do is take the Red stuff in the CMD and put it in the Red section in the HTA. But substituting the Variable names. Thanks, later days, ;) .

Link to comment
Share on other sites

Thanks put it only display a Msg Box saying "Preparing Script" what i need it to do is take the Red stuff in the CMD and put it in the Red section in the HTA. But substituting the Variable names. Thanks, later days, ;) .

It only displays that message if all 3 boxes are filled in. Try to get it to work without all 3 boxes filled in. It will pass all the varibles to MakeScript() you have to fill in that part of the script.

Link to comment
Share on other sites

Thanks put it only display a Msg Box saying "Preparing Script" what i need it to do is take the Red stuff in the CMD and put it in the Red section in the HTA. But substituting the Variable names. Thanks, later days, ;) .

It only displays that message if all 3 boxes are filled in. Try to get it to work without all 3 boxes filled in. It will pass all the varibles to MakeScript() you have to fill in that part of the script.

Sorry but I don't understand :huh: . All i want is someone to convert the Red part in CMD to a VBScript so I can use it. :yes:

Link to comment
Share on other sites

Not an answer to your latest question, but more of an example Windows NT Command Script, (batch file), which answers the original question and relates it to your current problem(s). The script may look rather long, but it does attempt to cover some error trapping which most people appear to usually ignore.

AddUsers.cmd

@ECHO OFF&SETLOCAL ENABLEEXTENSIONS&MODE 70,8&COLOR 4F
TITLE Account Creation
SET /P "TOADD= WOULD YOU LIKE TO ADD ADDITIONAL USERS (Y/N)? "
IF /I '%TOADD:~0,1% NEQ 'Y (ENDLOCAL&GOTO :EOF)
SET REGKEY="HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
SET "CNT1=0"
CLS&TITLE Account Name
ECHO/ NOTE &ECHO/ ¯¯¯¯&ECHO/
ECHO/ The First User added will be set as your Default User&ECHO/
ECHO/ It will have Administrator Account privileges&ECHO/&CLS
:ADDNAME
FOR %%? IN (NAME TIPE UTYPE PASS) DO (SET %%?=)
ECHO/ PLEASE ENTER YOUR CHOSEN ACCOUNT (LOGIN) NAME
SET /P "NAME="
IF "%NAME%" EQU "" (CLS&ECHO/ Blank Names are not accepted!
PING -n 4 LOCALHOST >NUL&CLS&GOTO ADDNAME)
CLS&ECHO/&ECHO/ THE ACCOUNT NAME YOU HAVE CHOSEN IS&ECHO/&ECHO/ %NAME%&ECHO/
ECHO/ WOULD YOU LIKE TO CHANGE IT (Y/N)?
SET /P "ANSR="
IF /I '%ANSR:~0,1% NEQ 'N (CLS& GOTO ADDNAME)
NET USER |FIND /I " %NAME% " >NUL 2>&1 &&(CLS&ECHO/
ECHO/ USER %NAME% ALREADY EXISTS&ECHO/&ECHO/ PLEASE TRY AGAIN&ECHO/
PING -n 4 LOCALHOST >NUL&CLS&GOTO ADDNAME)
CLS&TITLE Account Type
IF %CNT1% EQU 0 (SET "UTYPE=Administrator"&CLS&TITLE Account Password
GOTO ADDPASS)
:ADDTYPE
ECHO/ YOU CAN NOW CHOOSE AN ACCOUNT TYPE FOR %NAME%&ECHO/&ECHO/ Account Types
ECHO/ ¯¯¯¯¯¯¯¯¯¯¯¯¯&ECHO/&ECHO/ 1. Computer Administrator (less secure)
ECHO/ Has unrestricted access to the computer&ECHO/
ECHO/ 2. Power User (more secure)
ECHO/ Has only some restricted access to the computer&ECHO/
ECHO/ 3. Normal User (recommended)&ECHO/ Has restricted access to the computer
ECHO/
SET /P "TIPE= Please enter your an account type for %NAME% (1/2/3): "
SET "TIPE=%TIPE:~0,1%"
ECHO/%TIPE% |FINDSTR/R "[1-3]" >NUL ||(CLS&GOTO ADDTYPE)
IF %TIPE% LSS 2 (SET UTYPE=Administrator)
IF %TIPE% EQU 2 (SET UTYPE=Power User)
IF %TIPE% GTR 2 (SET UTYPE=User)
CLS&ECHO/&ECHO/ THE ACCOUNT TYPE YOU HAVE CHOSEN IS&ECHO/&ECHO/ %UTYPE%&ECHO/
ECHO/ WOULD YOU LIKE TO CHANGE IT (Y/N)?
SET /P "ANSR="
IF /I '%ANSR:~0,1% NEQ 'N (CLS&GOTO ADDTYPE)
CLS&TITLE Account Password
:ADDPASS
ECHO/ PLEASE ENTER A PASSWORD FOR %NAME%&ECHO/&ECHO/ NOTE&ECHO/ ¯¯¯¯&ECHO/
ECHO/ Passwords MUST contain a minimum of 6 characters&ECHO/
SET /P "PASS="
IF "%PASS%" EQU "" (CLS&ECHO/&ECHO/ Blank Passwords are not accepted!&ECHO/
PING -n 4 LOCALHOST >NUL&CLS&GOTO ADDPASS)
ECHO/%PASS%|FINDSTR/R "[^a-z,0-9,_,-]" >NUL &&(CLS&ECHO/
ECHO/ Some of the characters you used were not acceptable!&ECHO/
PING -n 4 LOCALHOST >NUL&CLS&GOTO ADDPASS)
CLS&ECHO/&ECHO/ THE PASSWORD YOU HAVE CHOSEN FOR %NAME% IS&ECHO/&ECHO/ %PASS%
ECHO/&ECHO/ WOULD YOU LIKE TO CHANGE IT (Y/N)?
SET /P "ANSR="
IF /I '%ANSR:~0,1% NEQ 'N (CLS&GOTO ADDPASS)
SET "CNT2=0"
:LOOP
SET /A "CNT2+=1"
CALL SET V=%%PASS:~0,%CNT2%%%
IF "%V%" NEQ "%PASS%" (GOTO LOOP)
IF %CNT2% LSS 6 (CLS&ECHO/ Minimum Password length is 6 characters&ECHO/
ECHO/ Please try again!&ECHO/&PING -n 4 LOCALHOST >NUL&CLS&GOTO ADDPASS)
CLS&TITLE Adding Account
NET USER "%NAME%" "%PASS%" /add
NET LOCALGROUP "%UTYPE%s" "%NAME%" /add
IF %CNT1% EQU 0 (CLS&CALL :DEFLOG)
CLS&SET /P "ADDMORE= WOULD YOU LIKE TO ADD ANOTHER USER (Y/N)? "
IF /I '%ADDMORE:~0,1% EQU 'Y (SET /A "CNT1+=1"&CLS&TITLE Account Name
GOTO ADDNAME)
CLS&ECHO/&ECHO/ FINISHED ADDING USERS&ECHO/ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯&ECHO/
NET ACCOUNTS /maxpwage:unlimited
PING -n 4 LOCALHOST >NUL&ENDLOCAL&GOTO :EOF
:DEFLOG
REG ADD %REGKEY% /V DefaultUserName /D "%NAME%" /F >NUL
REG ADD %REGKEY% /V DefaultPassword /D "%PASS%" /F >NUL
SET /P "AUTLOG= Would you like %NAME%s Account to Logon Automatically (Y/N)? "
IF /I '%AUTLOG:~0,1% EQU 'Y (REG ADD %REGKEY% /V AutoAdminLogon /D 1 /F >NUL)
GOTO :EOF

Link to comment
Share on other sites

I have add what you needed to this hta.

1:\ I have added a check for the password length if the password is less the six characters then it will not accept that password.

'/-> CHECK THE LENGTH OF THE PASSWORD
Length = 6
If Length <= Len(strPass) Then
IntC = IntC + 1
Else
window.alert("This password was not long enough " & strPass & vbcrlf &_
"This has only " & Len(strPass) & " characters the password needs at lest 6 characters")
TextBox1.Value = ""
Exit Function
End If

2:\ Added A Confirm Before Adding Information

'/-> START CONFIRM  
ZZ1 = window.confirm("Is This The Correct Information" & vbcrlf &_
"Ok To Add This Information" & vbcrlf & "Cancel to not add the information" & vbcrlf &_
"strPass = " & strPass & vbcrlf & "strName = " & strName & vbcrlf & "strGroup = " & strGroup)
If ZZ1 = True Then
'/-> ADD THE INFORMATION
'/-> REMOVE THESE ' FROM BELOW HERE TO MAKE ACTIVE
' Act.Run("%Comspec% /C net user %" & strName & "% %" & strPass & "% /add"), 0, True
' Act.Run("%Comspec% /C net localgroup %" & strGroup & "% %" & strName & " /add"), 0, True
' Act.Run("%Comspec% /C net accounts /maxpwage:unlimited"), 0, True
Else
ClearText()
End IF

You will have to edit the VBS script part as I have left it comment out the add user

'	Act.Run("%Comspec% /C net user %" & strName & "% %" & strPass & "% /add"), 0, True
' Act.Run("%Comspec% /C net localgroup %" strGroup "% %" & strName & " /add"), 0, True
' Act.Run("%Comspec% /C net accounts /maxpwage:unlimited"), 0, True

Save As AddUser.hta

<!-- ORIGINAL HTA AND SCRIPT BY YZOWL
HTA EDIT BY GUNSMOKINGMAN
HTA RE-EDIT BY BETA4ME -->
<HTML><HEAD>
<TITLE>User Account Creation</TITLE>
<HTA:APPLICATION
applicationname="User Account Creation"
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 IntC, Length, strPass, strName, strGroup, ZZ1
'/-> TEXT BOXES SCRIPTS
Function RegEdit()
strName = TextBox0.Value : strPass = TextBox1.Value : strGroup = TextBox2.Value
If strName = "" Then
window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Username" & chr(34)
Exit Function
Else
IntC = 1
End If
If strPass = "" Then
window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Password" & chr(34),64,"Alert"
Exit Function
Else
'/-> CHECK THE LENGTH OF THE PASSWORD
Length = 6
If Length <= Len(strPass) Then
IntC = IntC + 1
Else
window.alert("This password was not long enough " & strPass & vbcrlf &_
"This has only " & Len(strPass) & " characters the password needs at lest 6 characters")
TextBox1.Value = ""
Exit Function
End If
End If
If strGroup = "" Then
window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Group" & chr(34),64,"Alert"
Exit Function
Else
IntC = IntC + 1
End If
'/-> THIS IS A CHECK IT WILL ONLY GOTO AddUserFunction() IF IT EQUALS 3
If IntC = 3 Then AddUserFunction() End If
End Function
Function AddUserFunction()
'/-> START CONFIRM
ZZ1 = window.confirm("Is This The Correct Information" & vbcrlf &_
"Ok To Add This Information" & vbcrlf & "Cancel to not add the information" & vbcrlf &_
"strPass = " & strPass & vbcrlf & "strName = " & strName & vbcrlf & "strGroup = " & strGroup)
If ZZ1 = True Then
'/-> ADD THE INFORMATION
'/-> REMOVE THESE ' FROM BELOW HERE TO MAKE ACTIVE
' Act.Run("%Comspec% /C net user %" & strName & "% %" & strPass & "% /add"), 0, True
' Act.Run("%Comspec% /C net localgroup %" & strGroup & "% %" & strName & " /add"), 0, True
' Act.Run("%Comspec% /C net accounts /maxpwage:unlimited"), 0, True
Else
ClearText()
End IF
End Function
'/-> CLEAR THE TEXT BOXES
Function ClearText()
TextBox0.Value = "" : TextBox1.Value = "" : TextBox2.Value = ""
IntC = 0
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='95%' border='1' cellpadding='6'><TD>
<!-- TEXT BOX 01 START -->
<TABLE><TD Width='125'><B>» Username</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>» Password</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>» Group</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"> </p>
<!-- BUTTON TABLE START --><TABLE>
<!-- RUN BUTTON START -->
<TD Width='155' 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='155' 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='155' 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>

I have fixed the line that was causing the problem.

Edited by gunsmokingman
Link to comment
Share on other sites

Thanks for all your help Yzowl & Gsm. Now here's my script:

<!-- ORIGINAL HTA AND SCRIPT BY YZOWL

HTA EDIT BY GUNSMOKINGMAN

HTA RE-EDIT BY BETA4ME -->

<HTML><HEAD>

<TITLE>User Account Creation</TITLE>

<HTA:APPLICATION

applicationname="User Account Creation"

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 IntC, Length, strPass, strName, strGroup, ZZ1

'/-> TEXT BOXES SCRIPTS

Function RegEdit()

strName = TextBox0.Value : strPass = TextBox1.Value : strGroup = TextBox2.Value

If strName = "" Then

window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Username" & chr(34)

Exit Function

Else

IntC = 1

End If

If strPass = "" Then

window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Password" & chr(34),64,"Alert"

Exit Function

Else

'/-> CHECK THE LENGTH OF THE PASSWORD

Length = 6

If Length <= Len(strPass) Then

IntC = IntC + 1

Else

window.alert("This password was not long enough " & strPass & vbcrlf &_

"This has only " & Len(strPass) & " characters the password needs at lest 6 characters")

TextBox1.Value = ""

Exit Function

End If

End If

If strGroup = "" Then

window.alert "Alert" & vbcrlf & "You need to fill in " & chr(34) & "Group" & chr(34),64,"Alert"

Exit Function

Else

IntC = IntC + 1

End If

'/-> THIS IS A CHECK IT WILL ONLY GOTO AddUserFunction() IF IT EQUALS 3

If IntC = 3 Then AddUserFunction() End If

End Function

Function AddUserFunction()

'/-> START CONFIRM

ZZ1 = window.confirm("Is This The Correct Information" & vbcrlf &_

"Ok To Add This Information" & vbcrlf & "Cancel to not add the information" & vbcrlf &_

"strPass = " & strPass & vbcrlf & "strName = " & strName & vbcrlf & "strGroup = " & strGroup)

If ZZ1 = True Then

'/-> ADD THE INFORMATION

'/-> REMOVE THESE ' FROM BELOW HERE TO MAKE ACTIVE

Act.Run("%Comspec% /C net user %" & strName & "% %" & strPass & "% /add"), 0, True

Act.Run("%Comspec% /C net localgroup %" strGroup "% %" & strName & " /add"), 0, True

Act.Run("%Comspec% /C net accounts /maxpwage:unlimited"), 0, True

Else

ClearText()

End IF

End Function

'/-> CLEAR THE TEXT BOXES

Function ClearText()

TextBox0.Value = "" : TextBox1.Value = "" : TextBox2.Value = ""

IntC = 0

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='95%' border='1' cellpadding='6'><TD>

<!-- TEXT BOX 01 START -->

<TABLE><TD Width='125'><B>» Username</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>» Password</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>» Group</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"> </p>

<!-- BUTTON TABLE START -->

<p style="margin-top: 0; margin-bottom: 0"> </p>

<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>

But i get this error:

post-81045-1160382709_thumb.jpg

followed by this:

post-81045-1160382720_thumb.jpg

(As you can see this is sized wrong).

This only happens when I uncomment:

Act.Run("%Comspec% /C net user %" & strName & "% %" & strPass & "% /add"), 0, True

Act.Run("%Comspec% /C net localgroup %" strGroup "% %" & strName & " /add"), 0, True

Act.Run("%Comspec% /C net accounts /maxpwage:unlimited"), 0, True

Any Ideas?

Link to comment
Share on other sites

I missed 2 of these & in One line

Change This

Act.Run("%Comspec% /C net localgroup %" strGroup "% %" & strName & " /add"), 0, True

Change To

Act.Run("%Comspec% /C net localgroup %" & strGroup & "% %" & strName & " /add"), 0, True

Edited by gunsmokingman
Link to comment
Share on other sites

I missed 2 of these & in One line

Change This

Act.Run("%Comspec% /C net localgroup %" strGroup "% %" & strName & " /add"), 0, True

Change To

Act.Run("%Comspec% /C net localgroup %" & strGroup & "% %" & strName & " /add"), 0, True

TY. I fixed the file and they both work like a charm. Thanks for your help, mate! :thumbup

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...