First, some hints to Prac 3.Task 3.2 Prac 3.Task 3.2: retrieve Domain name, Computer name, and User name Domain name, Computer name, and User name (currently logged on as a user are different concepts. See the output below: /* retrieve Domain name, Computer name, and User name */ Set onetwork = CreateObject("WScript.Network" strdomain = onetwork.userdomain ' set objdomain = GetObject("WinNT://" & strdomain strcomputer = onetwork.computername ' set objcomputer = GetObject("WinNT://" & strcomputer ' objcomputer.getinfo struser = onetwork.username WScript.echo "Domain name: " & strdomain & VbCr & "Computer name: " _ & strcomputer & VbCr & "User name: " & struser Multiple accounts can be created on a computer or different users can logon to the same machine. The Domain name and Computer name are kept unchanged, while the User name changes with different accounts. Domain name means a User Group; Computer name is to identify a terminal; User name is for individual account who logs on the machine.
But on a personal computer without group settings, Domain name and Computer name could be the same: Computer Name can be typically found by right-clicking My Computer, then click Properties, then tab the Computer Name. Computer Name should have a corresponding IP address (in the setting of IP protocol.
We now introduce some systems administration tasks by using the Windows batch files. These are for your information only. 1. Windows startup programs can be managed via different ways. For your interest only. 1 Using UI utilities e.g. Run msconfig.exe program or search 'system configuration' and then start it.
Switch to Startup tab, you can freely enable or disable a program's auto-launch at Windows startup 2 Using commandline script (batch operations or vbs etc to touch the Windows registry directly Here are listed all startup programs for local computer: [HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] And here are listed all startup programs for current user: [HKCU\Software\Microsoft\Windows\CurrentVersion\Run] For instance, in order to disable Skype auto-launch at Windows startup, you can run the command: reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v Skype /f
2. Create directory structure of installed application This is for your interest only. Source at http://www.catonrug.net/, where search for "Create directory structure of installed application". Type in the following code and name it as CreateDirStructureInstalledApplications.cmd. Please note that, running this batch file requires auxiliary utilities in the SAP auxiliary utilities.zip; unzip it place all files in the same working folder as CreateDirStructureInstalledApplications.cmd. This code will list all program names into folders; inside each folder, a log file %computername%.log will be created; inside the log file there will be version number of application. @echo off setlocal EnableDelayedExpansion set path=%path%;%~dp0 set l=%~dp0 set u=microsoft\windows\currentversion\uninstall if "%ProgramFiles(x86%"=="" ( set sw=hklm\software set tokens=7 goto x86 :x64 echo 64-BIT APPS: set sw=hklm\software set tokens=7 for /f "tokens=%tokens% delims=\" %%a in ('^ reg query "%sw%\%u%" ^ grep "CurrentVersion.*Uninstall"' do ( reg query "%sw%\%u%\%%a" /v DisplayName > nul 2>&1 if!errorlevel!==0 ( reg query "%sw%\%u%\%%a" /v DisplayName > nul 2>&1 if!errorlevel!==0 for /f "tokens=*" %%b in ('^ reg query "%sw%\%u%\%%a" /v DisplayName ^ grep "DisplayName" ^ sed "s/reg_sz\ DisplayName//g" ^ sed "s/^[ \t]*//g"' do if not %%b=="" set name=%%b reg query "%sw%\%u%\%%a" /v DisplayVersion > nul 2>&1 if!errorlevel!==0 for /f "tokens=*" %%c in ('^ reg query "%sw%\%u%\%%a" /v DisplayVersion ^ grep "DisplayVersion" ^ sed "s/reg_sz\ DisplayVersion//g" ^ sed "s/^[ \t]*//g"' do if not %%c=="" set version=%%c echo!name!!version! if not exist "%l%\!name!" md "%l%\!name!" echo!version! > "%l%\!name!\%computername%.log"
set sw=hklm\software\wow6432node set tokens=8 :x86 echo 32-BIT APPS: for /f "tokens=%tokens% delims=\" %%a in ('^ reg query "%sw%\%u%" ^ grep "CurrentVersion.*Uninstall"' do ( reg query "%sw%\%u%\%%a" /v DisplayName > nul 2>&1 if!errorlevel!==0 ( reg query "%sw%\%u%\%%a" /v DisplayName > nul 2>&1 if!errorlevel!==0 for /f "tokens=*" %%b in ('^ reg query "%sw%\%u%\%%a" /v DisplayName ^ grep "DisplayName" ^ sed "s/reg_sz\ DisplayName//g" ^ sed "s/^[ \t]*//g"' do if not %%b=="" set name=%%b reg query "%sw%\%u%\%%a" /v DisplayVersion > nul 2>&1 if!errorlevel!==0 for /f "tokens=*" %%c in ('^ reg query "%sw%\%u%\%%a" /v DisplayVersion ^ grep "DisplayVersion" ^ sed "s/reg_sz\ DisplayVersion//g" ^ sed "s/^[ \t]*//g"' do if not %%c=="" set version=%%c echo!name!!version! if not exist "%l%\!name!" md "%l%\!name!" echo!version! > "%l%\!name!\%computername%.log" endlocal
3. Howto systeminfo For your interest only. Source at http://www.catonrug.net/. Of course you can check the system information from the Control Panel. However, you can also use command script to automatically retrieve the system information. Type in the following code and name it as howtosysteminfo.cmd. Please note that, running this batch file requires auxiliary utilities in the SAP auxiliary utilities.zip. Unzip it place all files in the same working folder as howtosysteminfo.cmd. Then run howtosysteminfo.cmd and retrieve the system info. @echo off setlocal EnableDelayedExpansion set path=%path%;%~dp0 set tab= systeminfo awk "/Host Name/;/OS Name/;/System Model/;/System Type/;/Total Physical Memory/" echo Locally installed printers: for /F "tokens=7 delims=\" %%p in ('^ reg query "HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers"' do echo %tab%%%p ipconfig all grep v "^$" reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName ^ find "Windows XP" > nul 2>&1 if not!errorlevel!==0 set r=/r gpresult %r% /user DOMAINNAME\% username% endlocal pause
4. Kill process in windows This may be useful during the lab. I'm not sure whether we are allowed to copy nircmd.exe to %systemroot%\system32 on lab computers though. If not, ignore this activity. Copy nircmd.exe to %systemroot%\system32. Then you can use the command like this: nircmd killprocess Wscript.exe nircmd killprocess javaw.exe
5. List installed programs in cmd window For your interest only. Source at http://www.catonrug.net/ Type in the following code and name it as ListInstalledPrograms.cmd, then run it. It may take a short while to retrieve the information. You can also redirect the output to a file. @echo off setlocal EnableDelayedExpansion set U=Microsoft\Windows\CurrentVersion\Uninstall set dn=displayname set pdn=parentdisplayname set dv=displayversion if exist "%temp%\pcx64.log" del "%temp%\pcx64.log" if exist "%temp%\pcx86.log" del "%temp%\pcx86.log" if "%ProgramFiles(x86%"=="" ( set SW=HKLM\SOFTWARE set tokens=7 goto x86 :x64 echo 64-BIT APPS: set SW=HKLM\SOFTWARE set tokens=7 FOR /F "tokens=%tokens% delims=\" %%A IN ('reg query "%SW%\%U%"' DO ( reg query "%SW%\%U%\%%A" /v %dn% > nul 2>&1 if!errorlevel!==0 ( reg query "%SW%\%U%\%%A" find /V "%pdn%" find "%dn%" > nul 2>&1 if!errorlevel!==0 echo %%A; >> "%temp%\pcx64.log" for /F "tokens=1 delims=;" %%A in ('type "%temp%\pcx64.log"' do ( echo %%A reg query "%SW%\%U%\%%A" /v "%dn%" find "%dn%" reg query "%SW%\%U%\%%A" /v "%dv%" > nul 2>&1 if!errorlevel!==0 reg query "%SW%\%U%\%%A" /v "%dv%" find "%dv%" set SW=HKLM\SOFTWARE\Wow6432Node set tokens=8
:x86 echo 32-BIT APPS: FOR /F "tokens=%tokens% delims=\" %%A IN ('reg query "%SW%\%U%"' DO ( reg query "%SW%\%U%\%%A" /v %dn% > nul 2>&1 if!errorlevel!==0 ( reg query "%SW%\%U%\%%A" find /V "%pdn%" find "%dn%" > nul 2>&1 if!errorlevel!==0 echo %%A; >> "%temp%\pcx86.log" for /F "tokens=1 delims=;" %%A in ('type "%temp%\pcx86.log"' do ( echo %%A reg query "%SW%\%U%\%%A" /v "%dn%" find "%dn%" reg query "%SW%\%U%\%%A" /v "%dv%" > nul 2>&1 if!errorlevel!==0 reg query "%SW%\%U%\%%A" /v "%dv%" find "%dv%" endlocal
6. Prompt for numbers in windows batch file For your interest only. Source at http://www.catonrug.net/ Type in the following code and name it as promptnumbers.cmd, then run it. @echo off echo Hello. Lets make a sum of two numbers. set /p first=type a first number: set /p second=type a second number: set /a together=first+second echo %together% pause