Page 1 of 1 1
Topic Options
#152301 - 2005-11-26 02:29 AM Noob of the month... How can I...?
Max_Girth Offline
Lurker

Registered: 2005-09-14
Posts: 3
Loc: S.W. MI
Let me say right up front that I have no KIXtart insight, no VBS insight, and what would probably be considered only superficial batch file insight.
However, I have a batch file that does several things for me. Most involves gathering input from the user. Asking questions, setting env variables, etc...
It uses choice.exe alot, does error or condition checking, runs netdom.exe, and creates other .bat, .vbs, and .reg files using values gathered from the user.
My question is pretty straightforward, I hope...
Is there any utility that I could run a .bat file through, have it's functionality analyzed, and create a .kix file that might accomplish the same or similar tasks as the sampled .bat file?
I have been trying the "Read to learn" approach to KIXtart, and admittedly, I'm struggling.
I was hoping that if I could SEE a .kix script that accomplishes the same stuff I've so sweated my balls off on creating a .bat to do, I might get some much needed revelation.


Edited by Max_Girth (2005-11-26 02:31 AM)
_________________________
Isn't it a shame that entire families can be torn apart by something as simple as wild dogs...

Top
#152302 - 2005-11-26 02:59 AM Re: Noob of the month... How can I...?
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
Post your bat file and we can make suggestions... most of it I'm sure we can do in kix...
_________________________
(... better days ahead)

Top
#152303 - 2005-11-26 03:33 AM Re: Noob of the month... How can I...?
Max_Girth Offline
Lurker

Registered: 2005-09-14
Posts: 3
Loc: S.W. MI
You asked for it... Remenber, I'm a noob, don't laugh too hard.
As convoluted as it may be, it works...


@echo off
title SBC Computer Asset Configuration Utility --By Max Girth--
color 0a
cls
if exist %systemroot%\system32\choice.exe set path=%SystemRoot%;%SystemRoot%\system32;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\
if not exist c:\windows\choice.exe xcopy /y \\10.40.1.244\rollout\filecopy\*.exe c:\windows\ > nul
echo.
set namechanged=No
set SecChanged=No
:Settings
cls
echo ----------------------------------------------------------------------------
echo Current Computer Asset Configuration
echo ----------------------------------------------------------------------------
echo.
echo.
echo {Setting} {Value}
echo.
echo {A} User Name: %assignedto%
echo {B} Computer Asset Tag: %asset%
echo {C} Computer Serial Number: %serial%
echo {D} Monitor Asset Tag: %lcdasset%
echo {E} Monitor Serial Number: %lcdserial%
echo {F} Second Monitor Asset Tag: %lcd2asset%
echo {G} Second Monitor Serial Number: %lcd2serial%
echo {H} Local Printer Asset Number: %printerasset%
echo {I} Local Printer Serial Number: %printerserial%
echo {J} Microsoft Office Version: %office%
echo {K} Computer Name: %computername%
echo {L} Security Type: %security%
echo {M} Location: %location%
echo.
echo.
echo.
choice /c:ABCDEFGHIJKLMQ /n " Enter {A-M} to change a setting's value, or {Q} to accept and continue:"

if errorlevel 14 goto write
if not errorlevel 14 if errorlevel 13 goto location
if not errorlevel 13 if errorlevel 12 goto SecurityType
if not errorlevel 12 if errorlevel 11 goto ComputerName
if not errorlevel 11 if errorlevel 10 goto OfficeVer
if not errorlevel 10 if errorlevel 9 goto PrinterAsset
if not errorlevel 9 if errorlevel 8 goto PrinterAsset
if not errorlevel 8 if errorlevel 7 goto LCD2Asset
if not errorlevel 7 if errorlevel 6 goto LCD2Asset
if not errorlevel 6 if errorlevel 5 goto LCDAsset
if not errorlevel 5 if errorlevel 4 goto LCDAsset
if not errorlevel 4 if errorlevel 3 goto CompSerial
if not errorlevel 3 if errorlevel 2 goto CompAsset
if not errorlevel 2 if errorlevel 1 goto AssignedTo



:CompAsset
cls
echo.
echo.
echo.
set /p asset= Enter the asset tag attached to this computer {"None" if none}:
goto Settings

:CompSerial
cls
echo.
echo.
echo.
set /p serial= Enter the serial number or service tag from this computer:
goto Settings

:LCDAsset
cls
echo.
echo.
echo.
choice /c:NY /n " Does this workstation have an LCD (flat panel) monitor? {Y,N}:"
if errorlevel 2 goto getlcd
set lcdasset=CRT
set lcdserial=CRT
goto Settings
:getlcd
echo.
set /p lcdasset= Enter the asset tag attached to the monitor {"None" if none}:

:LCDSerial
echo.
set /p lcdserial= Enter the serial number from the monitor:
goto Settings

:LCD2Asset
cls
echo.
echo.
echo.
choice /c:NY /n " Is there a second monitor attached to this system? {Y,N}:"
if errorlevel 2 goto getlcd2
set lcd2asset=No 2nd Monitor
set lcd2serial=No 2nd Monitor
goto Settings
:getlcd2
echo.
set /p lcd2asset= Enter the asset tag attached to the second monitor:

:LCD2Serial
echo.
set /p lcd2serial= Enter the serial number from the second monitor:
goto Settings

:PrinterAsset
cls
echo.
echo.
echo.
choice /c:NY /n " Is there a local printer attached to this workstation? {Y,N}:"
if errorlevel 2 goto getprinter
set printerasset=No local printer
set printerserial=No local printer
goto Settings
:GetPrinter
echo.
set /p printerasset= Enter the asset tag attached to the printer {"None" if none}:

:PrinterSerial
echo.
set /p printerserial= Enter the serial number from the printer:
goto Settings

:OfficeVer
cls
echo.
echo.
echo.
choice /c:NY /n " Is Microsoft Office Installed Locally? {Y,N}:"
if errorlevel 2 goto installed
set Office=Not Installed
goto Settings
:Installed
set Office1=Microsoft Office
set office2=Professional
echo.
set /p Office3= What version? (2003, XP, 2000, etc...):
set Office=%office1% %office3% %office2%
goto Settings

:AssignedTo
cls
echo.
echo.
echo.
set /p firstname= Who will this computer be assigned to? {First Name only}:
echo.
set /p lastname= What is %firstname%'s last name? {Last Name only}:
set AssignedTo=%firstname% %lastname%
goto Settings

:ComputerName
cls
echo.
echo.
echo.
set /p computername= What should this computer be named? {Use UPPERCASE letters}:
set namechanged=Yes
goto Settings

:SecurityType
cls
echo.
echo.
echo.
choice /c:YN /n " Do you want %Computername% to join the HUB Domain at this time? {Y,N}:
if errorlevel 2 goto DontJoin
set SecChanged=Yes
set Security=Domain
goto Settings
:dontJoin
rem set SecChanged=No
set security=Workgroup
goto Settings

:location
cls
echo ----------------------------------------------------------------------------
echo Select the location for this computer.
echo ----------------------------------------------------------------------------
echo.
echo (A) Battle Creek, MI (H) Portage, MI (Kalamazoo)
echo (B) Beachwood, OH (I) Madisonville, IN
echo (C) Benton Harbor, MI (J) Niles, MI
echo (D) Coppell, TX (K) St. Joseph, MI
echo (E) Evansville, IN (L) Tell City, IN
echo (F) Grand Rapids, MI (M) Traverse City, MI
echo (G) Holland, MI (N) Other (Not listed)
echo.
choice /c:ABCDEFGHIJKLMN /n " Enter a letter that matches the city where this computer is being deployed:
echo.
if errorlevel 14 set /p location= Enter a City and State (City, ST)
if not errorlevel 14 if errorlevel 13 set location=Traverse City, MI
if not errorlevel 13 if errorlevel 12 set location=Tell City, IN
if not errorlevel 12 if errorlevel 11 set location=St. Joseph, MI
if not errorlevel 11 if errorlevel 10 set location=Niles, MI
if not errorlevel 10 if errorlevel 9 set location=Madisonville, IN
if not errorlevel 9 if errorlevel 8 set location=Portage, MI (Kalamazoo)
if not errorlevel 8 if errorlevel 7 set location=Holland, MI
if not errorlevel 7 if errorlevel 6 set location=Grand Rapids, MI
if not errorlevel 6 if errorlevel 5 set location=Evansville, IN
if not errorlevel 5 if errorlevel 4 set location=Coppell, TX
if not errorlevel 4 if errorlevel 3 set location=Benton Harbor, MI
if not errorlevel 3 if errorlevel 2 set location=Beachwood, OH
if not errorlevel 2 if errorlevel 1 set location=Battle Creek, MI
goto Settings


:Write
if not defined AssignedTo goto AssignedTo
if not defined Asset goto CompAsset
if not defined Serial goto CompSerial
if not defined LCDAsset goto LCDAsset
if not defined LCD2Asset goto LCD2Asset
if not defined PrinterAsset goto PrinterAsset
if not defined Office goto OfficeVer
if not defined ComputerName goto ComputerName
if not defined Security goto SecurityType
if not defined location goto Location
cls
echo ----------------------------------------------------------------------------
echo Values that will be assigned to this computer
echo ----------------------------------------------------------------------------
echo.
echo.
echo User Name: %assignedto%
echo Computer Asset Tag: %asset%
echo Computer Serial Number: %serial%
echo Monitor Asset Tag: %lcdasset%
echo Monitor Serial Number: %lcdserial%
echo Second Monitor Asset Tag: %lcd2asset%
echo Second Monitor Serial Number: %lcd2serial%
echo Local Printer Asset Number: %printerasset%
echo Local Printer Serial Number: %printerserial%
echo Microsoft Office Version: %office%
echo Computer name: %computername%
echo Security type: %security%
echo Location: %location%
echo.
echo.
rem if %namechanged%==Yes echo The Computer will be renamed to %computername%
rem if %namechanged%==No echo The computer name (%computername%) will not be changed
rem if %security%==Workgroup echo The computer will not attempt to join the HUB Domain
rem if %security%==Domain echo The computer will attempt to join the HUB Domain
goto chkcorrect

:chkcorrect
choice /c:YN /n " Is the above information correct? {Y,N}:
if errorlevel 2 goto Settings
echo.
rem echo Are you SURE??? If yes, press Q to write these values to the Registry
rem echo If you need to make changes/corrections before writing, press K
rem echo.
choice /c:QK /n " Press {Q} to continue, or {K} to make changes:"
if errorlevel 2 goto Settings

:setxroutine
setx AssignedTo "%assignedto%" -m
setx Asset "%asset%" -m
setx Serial "%serial%" -m
setx LCDAsset "%lcdasset%" -m
setx LCDSerial "%lcdserial%" -m
setx LCD2Asset "%lcd2asset%" -m
setx LCD2Serial "%lcd2serial%" -m
setx PrinterAsset "%printerasset%" -m
setx PrinterSerial "%printerserial%" -m
setx Office "%office%" -m
setx ComputerName "%computername%" -m
setx Security "%security%" -m
setx Location "%location%" -m
if %security%==Workgroup goto CreateSID

:domain
rem %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rem ******* This section could be modified to use specified accounts other than mid.zrollout to join the domain
rem ******* as well as changing the location in AD to place the computer account, and specifying who the computer
rem ******* is managed by
rem set /p userd= What domain account do you want to use to join this machine?
rem set /p container= Where should the computer be added? (Fully Qualified Path to the OU -less hub.local-)
rem set /p manby= What group, or user, should this computer be managed by? (Fully qualified path -less hub.local)
set hub=,DC=Hub,DC=Local
set userd=mid.zrollout
set container=OU=Computers,OU=MID
set manby=cn=MID OU Managers,ou=Admin Account,ou=mid%hub%
rem %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


rem ******* Create a batch file (add-comp.bat) to run netdom.exe with information from above
if not exist c:\windows\hub\bat\ md c:\windows\HUB\BAT
echo @echo off> c:\windows\hub\bat\add-comp.bat
echo color 0a>> c:\windows\hub\bat\add-comp.bat
echo Title SBC Domain Registration utility --By Max Girth-->> c:\windows\hub\bat\add-comp.bat
echo cls>> c:\windows\hub\bat\add-comp.bat
echo echo ---------------------------------------------------------------------------->> c:\windows\hub\bat\add-comp.bat
echo echo Attempting to join %ComputerName% to the HUB Domain>> c:\windows\hub\bat\add-comp.bat
echo echo ---------------------------------------------------------------------------->> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo Please wait while the domain list is created...>> c:\windows\hub\bat\add-comp.bat
echo ping /n 45 127.0.0.1 ^> nul>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo Enter the password for the rollout account.>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo If you don't know this password contact Toby Bridges, Tim Cooper, or another>> c:\windows\hub\bat\add-comp.bat
echo echo member of the MID OU Managers group. You'll only get three chances!>> c:\windows\hub\bat\add-comp.bat
echo Netdom join %ComputerName% /domain:hub.local /userd:mid.zrollout /passwordd:* /ou:OU=Computers,OU=MID,DC=Hub,DC=Local ^> nul>> c:\windows\hub\bat\add-comp.bat
echo if errorlevel 1 goto addacct1>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo goto success>> c:\windows\hub\bat\add-comp.bat
echo :addacct1>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo Bad password, account locked, or domain not available. Please try again.>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo Netdom join %ComputerName% /domain:hub.local /userd:mid.zrollout /passwordd:* /ou:OU=Computers,OU=MID,DC=Hub,DC=Local ^> nul>> c:\windows\hub\bat\add-comp.bat
echo if errorlevel 1 goto addacct2>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo goto success>> c:\windows\hub\bat\add-comp.bat
echo :addacct2>> c:\windows\hub\bat\add-comp.bat
echo echo !!LAST CHANCE!! Please confirm that you are using the correct password!>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo Netdom join %ComputerName% /domain:hub.local /userd:mid.zrollout /passwordd:* /ou:OU=Computers,OU=MID,DC=Hub,DC=Local ^> nul>> c:\windows\hub\bat\add-comp.bat
echo if errorlevel 1 goto failed>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo goto success>> c:\windows\hub\bat\add-comp.bat
echo :failed>> c:\windows\hub\bat\add-comp.bat
echo color cf>> c:\windows\hub\bat\add-comp.bat
echo cls>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo Joining the domain has FAILED. ( Three strikes. You're out! )>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo The setup process is ending without joining the HUB domain!>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo This computer will remain in the workgroup environment, but can be joined to>> c:\windows\hub\bat\add-comp.bat
echo echo the domain manually at a later time if desired.>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo Press any key now to exit setup and return to Windows...>> c:\windows\hub\bat\add-comp.bat
echo pause ^> nul>> c:\windows\hub\bat\add-comp.bat
echo exit>> c:\windows\hub\bat\add-comp.bat
echo :success>> c:\windows\hub\bat\add-comp.bat
echo cls>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo WOOHOOO!!! %ComputerName% successfully joined the HUB domain!>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo The system will now reboot to complete the process>> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo echo. >> c:\windows\hub\bat\add-comp.bat
echo regedit /s c:\windows\hub\reg\mod-desc.reg>> c:\windows\hub\bat\add-comp.bat
echo echo Press any key now to reboot the system...>> c:\windows\hub\bat\add-comp.bat
echo pause ^> nul>> c:\windows\hub\bat\add-comp.bat
echo shutdown -r -f -t 3 >> c:\windows\hub\bat\add-comp.bat

rem ******* Create mod-desc.vbs
if not exist c:\windows\hub\vbs\ md c:\windows\HUB\VBS
echo ' ********************************************************************** > c:\windows\hub\vbs\mod-desc.vbs
echo ' This script modifies the AD computer object description, location, and >> c:\windows\hub\vbs\mod-desc.vbs
echo ' sets the "managed by" value to the MID OU Admins group >> c:\windows\hub\vbs\mod-desc.vbs
echo ' ********************************************************************** >> c:\windows\hub\vbs\mod-desc.vbs
echo ' >> c:\windows\hub\vbs\mod-desc.vbs
echo strContainer = "%container%" >> c:\windows\hub\vbs\mod-desc.vbs
echo strName = "%ComputerName%" >> c:\windows\hub\vbs\mod-desc.vbs
echo Const ADS_PROPERTY_CLEAR = 1 >> c:\windows\hub\vbs\mod-desc.vbs
echo Set objRootDSE = GetObject("LDAP://rootDSE") >> c:\windows\hub\vbs\mod-desc.vbs
echo If strContainer = "" Then >> c:\windows\hub\vbs\mod-desc.vbs
echo Set objItem = GetObject("LDAP://" ^& objRootDSE.Get("defaultNamingContext")) >> c:\windows\hub\vbs\mod-desc.vbs
echo Else >> c:\windows\hub\vbs\mod-desc.vbs
echo Set objItem = GetObject("LDAP://cn=" ^& strName ^& "," ^& strContainer ^& "," ^& objRootDSE.Get("defaultNamingContext")) >> c:\windows\hub\vbs\mod-desc.vbs
echo End If >> c:\windows\hub\vbs\mod-desc.vbs
echo objItem.Put "description", "%lastname%, %firstname%" >> c:\windows\hub\vbs\mod-desc.vbs
echo objItem.SetInfo >> c:\windows\hub\vbs\mod-desc.vbs
echo objItem.Put "location", "Asset %asset% %location%" >> c:\windows\hub\vbs\mod-desc.vbs
echo objItem.SetInfo >> c:\windows\hub\vbs\mod-desc.vbs
echo objItem.Put "managedBy", "%manby%" >> c:\windows\hub\vbs\mod-desc.vbs
echo objItem.SetInfo >> c:\windows\hub\vbs\mod-desc.vbs


rem ******* Create modify.bat
echo @echo off> c:\windows\hub\bat\modify.bat
echo color 0a>> c:\windows\hub\bat\modify.bat
echo title SBC AD Object Modification Utility --By Max Girth-->> c:\windows\hub\bat\modify.bat
echo cls>> c:\windows\hub\bat\modify.bat
echo echo ---------------------------------------------------------------------------->> c:\windows\hub\bat\modify.bat
echo echo Modifying object properties for %ComputerName%>> c:\windows\hub\bat\modify.bat
echo echo ---------------------------------------------------------------------------->> c:\windows\hub\bat\modify.bat
echo c:\windows\hub\vbs\mod-desc.vbs>> c:\windows\hub\bat\modify.bat
echo echo. >> c:\windows\hub\bat\modify.bat
echo ping /n 4 127.0.0.1 ^> nul>> c:\windows\hub\bat\modify.bat
echo echo Description for %ComputerName%, set to "%lastname%, %firstname%" in AD>> c:\windows\hub\bat\modify.bat
echo ping /n 4 127.0.0.1 ^> nul>> c:\windows\hub\bat\modify.bat
echo echo. >> c:\windows\hub\bat\modify.bat
echo echo Location for %ComputerName% set to "Asset %asset% %location%" in AD>> c:\windows\hub\bat\modify.bat
echo ping /n 4 127.0.0.1 ^> nul>> c:\windows\hub\bat\modify.bat
echo echo. >> c:\windows\hub\bat\modify.bat
echo echo "Managed By" for %ComputerName% set to "MID OU Managers" in AD>> c:\windows\hub\bat\modify.bat
echo ping /n 8 127.0.0.1 ^> nul>> c:\windows\hub\bat\modify.bat

rem ******* Create mod-desc.bat
echo @echo off> c:\windows\hub\bat\mod-desc.bat
echo color 0a>> c:\windows\hub\bat\mod-desc.bat
echo title SBC AD Computer Object Configuration utility --By Max Girth-->> c:\windows\hub\bat\mod-desc.bat
echo cls>> c:\windows\hub\bat\mod-desc.bat
echo echo ---------------------------------------------------------------------------->> c:\windows\hub\bat\mod-desc.bat
echo echo Launching the Active Directory Object Modification Script as %userd%>> c:\windows\hub\bat\mod-desc.bat
echo echo ---------------------------------------------------------------------------->> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo Waiting for ~60 seconds before running the script that modifies>> c:\windows\hub\bat\mod-desc.bat
echo echo the description, etc... of the computer object in Active directory.>> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo This helps ensure that the network is fully initialized, and that the>> c:\windows\hub\bat\mod-desc.bat
echo echo HUB domain is available before the script runs. If run too>> c:\windows\hub\bat\mod-desc.bat
echo echo quickly, the script will fail, without alerting us, and the object>> c:\windows\hub\bat\mod-desc.bat
echo echo description, etc... will not be updated.>> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo Thanks for being so patient!>> c:\windows\hub\bat\mod-desc.bat
echo ping /n 60 127.0.0.1 ^> nul>> c:\windows\hub\bat\mod-desc.bat
echo net localgroup "administrators" "hub\MID Users" /add ^> nul>> c:\windows\hub\bat\mod-desc.bat
echo net localgroup "administrators" "hub\MID OU Managers" /add ^> nul>> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo "MID Users" and "MID OU managers" have been added as local Administrators>> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo Enter the password for the rollout account:>> c:\windows\hub\bat\mod-desc.bat
echo call runas /user:%userd%@hub.local c:\windows\hub\bat\modify.bat ^> nul>> c:\windows\hub\bat\mod-desc.bat
echo if errorlevel 1 goto modacct2>> c:\windows\hub\bat\mod-desc.bat
echo goto modsuccess>> c:\windows\hub\bat\mod-desc.bat

echo :modsuccess>> c:\windows\hub\bat\mod-desc.bat
echo cls>> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo !!!! Setup is complete !!!!>> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo choice /c:YN /n " Would you like to refresh BGI information now? {Y,N}:">> c:\windows\hub\bat\mod-desc.bat
echo if errorlevel 2 goto nobgi>> c:\windows\hub\bat\mod-desc.bat
echo goto runbgi>> c:\windows\hub\bat\mod-desc.bat>> c:\windows\hub\bat\mod-desc.bat
echo :nobgi>> c:\windows\hub\bat\mod-desc.bat
echo echo.>> c:\windows\hub\bat\mod-desc.bat
echo Press any key now to return to Windows...
echo pause ^> nul>> c:\windows\hub\bat\mod-desc.bat
echo rd /s /q c:\docume~1\mid.zrollout@hub.local>> c:\windows\hub\bat\mod-desc.bat
echo exit>> c:\windows\hub\bat\mod-desc.bat
echo :runbgi>> c:\windows\hub\bat\mod-desc.bat
echo echo.>> c:\windows\hub\bat\mod-desc.bat
echo choice /c:Q /n " Press Q now to refresh BGI and return to to Windows...">> c:\windows\hub\bat\mod-desc.bat
echo pause ^> nul>> c:\windows\hub\bat\mod-desc.bat
echo rd /s /q c:\docume~1\mid.zrollout@hub.local>> c:\windows\hub\bat\mod-desc.bat
echo \\10.40.1.244\bgi\bgi.bat>> c:\windows\hub\bat\mod-desc.bat

echo :modacct2>> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo Bad password or domain not available. Try again!:>> c:\windows\hub\bat\mod-desc.bat
echo call runas /user:%userd%@hub.local c:\windows\hub\bat\modify.bat ^> nul>> c:\windows\hub\bat\mod-desc.bat
echo if errorlevel 1 goto modacct3>> c:\windows\hub\bat\mod-desc.bat
echo goto modsuccess>> c:\windows\hub\bat\mod-desc.bat

echo :modacct3>> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo !!LAST CHANCE!! Please confirm that you are using the correct password!>> c:\windows\hub\bat\mod-desc.bat
echo call runas /user:%userd%@hub.local c:\windows\hub\bat\modify.bat ^> nul>> c:\windows\hub\bat\mod-desc.bat
echo if errorlevel 1 goto modfail>> c:\windows\hub\bat\mod-desc.bat
echo goto modsuccess>> c:\windows\hub\bat\mod-desc.bat

echo :modfail>> c:\windows\hub\bat\mod-desc.bat
echo cls>> c:\windows\hub\bat\mod-desc.bat
echo color cf >> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo !! Modifying the Active Directory properties for %ComputerName% has failed !!>> c:\windows\hub\bat\mod-desc.bat
echo echo !! The properties for this AD object will have to be modified manually !!>> c:\windows\hub\bat\mod-desc.bat
echo echo. >> c:\windows\hub\bat\mod-desc.bat
echo echo Press any key key now to exit this script and return to windows...>> c:\windows\hub\bat\mod-desc.bat
echo pause ^> nul >> c:\windows\hub\bat\mod-desc.bat
echo exit >> c:\windows\hub\bat\mod-desc.bat



rem ******* Create a Registry file (add-comp.reg) to insert a command in the runonce key that will run add-comp.bat at next login
if not exist c:\windows\hub\reg\ md c:\windows\HUB\REG
echo Windows Registry Editor Version 5.00> c:\windows\hub\reg\add-comp.reg
echo {HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce}>> c:\windows\hub\reg\add-comp.reg
echo "Join"="c:\\windows\\hub\\bat\\add-comp.bat">> c:\windows\hub\reg\add-comp.reg


rem ******* Create a Registry file (mod-desc.reg) to insert a command in the runonce key that will run mod-desc.vbs at next login
echo Windows Registry Editor Version 5.00> c:\windows\hub\reg\mod-desc.reg
echo {HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce}>> c:\windows\hub\reg\mod-desc.reg
echo "ModifyAD"="c:\\windows\\hub\\bat\\mod-desc.bat">> c:\windows\hub\reg\mod-desc.reg


rem ******* Import add-comp.reg
regedit /s c:\windows\hub\reg\add-comp.reg

:CreateSID
cls
if %NameChanged%==No goto finish
if not exist c:\windows\hub\bat\ md c:\windows\HUB\BAT
echo @echo off> c:\windows\hub\bat\sid.bat
echo color 0a>> c:\windows\hub\bat\sid.bat
echo title SBC Post-Ghost Computer Renaming utility --By Max Girth-->> c:\windows\hub\bat\sid.bat
echo cls>> c:\windows\hub\bat\sid.bat
echo echo ---------------------------------------------------------------------------->> c:\windows\hub\bat\sid.bat
echo echo Generating a random SID and setting the Computer name to %ComputerName%>> c:\windows\hub\bat\sid.bat
echo echo ---------------------------------------------------------------------------->> c:\windows\hub\bat\sid.bat
echo echo. >> c:\windows\hub\bat\sid.bat
echo echo. >> c:\windows\hub\bat\sid.bat
echo echo Please wait while this computer's name is set to %ComputerName%>> c:\windows\hub\bat\sid.bat
echo echo. >> c:\windows\hub\bat\sid.bat
echo echo. >> c:\windows\hub\bat\sid.bat
echo echo. >> c:\windows\hub\bat\sid.bat
echo echo !!!!!!! DO NOT INTERRUPT THIS PROCESS !!!!!!!>> c:\windows\hub\bat\sid.bat
echo echo !!!!!!! IF INTERRUPTED, THE SYSTEM WILL BECOME UNSTABLE !!!!!!!>> c:\windows\hub\bat\sid.bat
echo echo. >> c:\windows\hub\bat\sid.bat
echo echo. >> c:\windows\hub\bat\sid.bat
echo echo. >> c:\windows\hub\bat\sid.bat
echo echo The system will reboot once the renaming process is complete!>> c:\windows\hub\bat\sid.bat
echo NewSid /a /d 1 %ComputerName%>> c:\windows\hub\bat\sid.bat


:finish
if %SecChanged%==Yes goto Reload
echo.
echo.
echo.
echo None of the changes being applied require a re-start. You can press {Q}
echo to return to Windows now, {K} to return to the settings screen, or {B} to
echo return to windows and refresh BackGround Information
echo.
echo.
echo.
choice /c:QKB /n " Press {Q} to exit, {K} to make changes, or {B} to exit and refresh
if errorlevel 3 \\10.40.1.244\bgi\bgi.bat
if not errorlevel 3 if errorlevel 2 goto Settings
exit


:Reload
echo.
echo.
echo.
echo Some changes made require that the system be re-started. Press {Q} when
echo you're ready to re-start, or {K} to abort and return to the settings screen
echo.
echo.
echo.
choice /c:QK /n " Press {Q} to re-start, or {K} to make changes:
if errorlevel 2 goto Settings
shutdown -r -f -t 3
_________________________
Isn't it a shame that entire families can be torn apart by something as simple as wild dogs...

Top
#152304 - 2005-11-26 03:42 AM Re: Noob of the month... How can I...?
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
ack! I asked for this? What was I thinking?

need some time to digest...
_________________________
(... better days ahead)

Top
#152305 - 2005-11-26 04:07 AM Re: Noob of the month... How can I...?
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
Code:

@echo off
title SBC Computer Asset Configuration Utility --By Max Girth--
color 0a
cls
if exist %systemroot%\system32\choice.exe set path=%SystemRoot%;%SystemRoot%\system32;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\
if not exist c:\windows\choice.exe xcopy /y \\10.40.1.244\rollout\filecopy\*.exe c:\windows\ > nul
echo.
set namechanged=No
set SecChanged=No
:Settings
cls
echo ----------------------------------------------------------------------------
echo Current Computer Asset Configuration
echo ----------------------------------------------------------------------------
echo.
echo.
echo {Setting} {Value}
echo.
echo {A} User Name: %assignedto%
echo {B} Computer Asset Tag: %asset%
echo {C} Computer Serial Number: %serial%
echo {D} Monitor Asset Tag: %lcdasset%
echo {E} Monitor Serial Number: %lcdserial%
echo {F} Second Monitor Asset Tag: %lcd2asset%
echo {G} Second Monitor Serial Number: %lcd2serial%
echo {H} Local Printer Asset Number: %printerasset%
echo {I} Local Printer Serial Number: %printerserial%
echo {J} Microsoft Office Version: %office%
echo {K} Computer Name: %computername%
echo {L} Security Type: %security%
echo {M} Location: %location%
echo.
echo.
echo.
choice /c:ABCDEFGHIJKLMQ /n " Enter {A-M} to change a setting's value, or {Q} to accept and continue:"



For Starters see...
SetTitle
Color
CLS

Should be able to get rid of choice and use Get or Gets,create a loop, and select an action to do your menu system...

Code:


? "{A} User Name: %assignedto%"
? "{B} Computer Asset Tag: %asset%"
? "{C} Computer Serial Number: %serial%"
? "{D} Monitor Asset Tag: %lcdasset%"
? "{E} Monitor Serial Number: %lcdserial%"
? "{F} Second Monitor Asset Tag: %lcd2asset%"
? "{G} Second Monitor Serial Number: %lcd2serial%"
? "{H} Local Printer Asset Number: %printerasset%"
? "{I} Local Printer Serial Number: %printerserial%"
? "{J} Microsoft Office Version: %office%"
? "{K} Computer Name: %computername%"
? "{L} Security Type: %security%"
? "{M} Location: %location%"
?
?
?


while $input<>"q"
? " Enter {A-M} to change a setting's value, or {Q} to accept and continue:"
get $input
select
case $input="a"
;do stuff
case $input="b"
;do stuff
case $input="c"
;you get the idea
endselect
loop



You might also consider writing these values to some key you create in the registry: see ReadValue and WriteValue.
_________________________
(... better days ahead)

Top
#152306 - 2005-11-26 04:23 AM Re: Noob of the month... How can I...?
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
Mind explaining why you are creating the bat and vbs files?
_________________________
(... better days ahead)

Top
#152307 - 2005-11-26 05:17 AM Re: Noob of the month... How can I...?
Max_Girth Offline
Lurker

Registered: 2005-09-14
Posts: 3
Loc: S.W. MI
The values do get set in the registry, with setx -m, later in the batch...
If the system is renamed (it usually is), then NEWSID runs, and needs a reboot.
After the reboot, if joining the domain, we need to run NETDOM.exe. Add-comp.bat handles this for me, from the runonce key...
The .vbs is for modifying the computer object description, etc..., in AD, after the join and another reboot.

Like I said... somewhat convoluted...
_________________________
Isn't it a shame that entire families can be torn apart by something as simple as wild dogs...

Top
#152308 - 2005-11-26 06:14 AM Re: Noob of the month... How can I...?
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
I'm not familiar with setx... where is it storing the values in the registry?

Regardless, you could do something like this:

Code:


$Key="HKLM\Software\YourCompanyName"


while $input<>"q"
CLS
? "{A} User Name: " + readvalue($key,"UserName")
? "{B} Computer Asset Tag: " + readvalue($key,"ComputerAssetTag")
?
?
?
? " Enter {A-M} to change a setting's value, or {Q} to accept and continue:"
get $input
select
case $input="a"
? "Enter User Name: gets $Username
if $username<>""
$=writevalue($key,"Username",$Username,"REG_SZ")
endif
case $input="b"
;do stuff
case $input="c"
;you get the idea
endselect
loop


_________________________
(... better days ahead)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.067 seconds in which 0.034 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org