top of page
Search
Writer's pictureJose Rodriguez

Scripting Toolbox (Building my code library)

Code and Descriptions


Over time I've amassed a bunch of txt, PDFs and doc files with commands, definitions and scripts for both Windows and Linux. On some occasions I picked some HTML, javascript and even some python along the way. I usually look for the piece of code I need and go back to work on my task or project. As a script hoarder it is easy to spend a chunk of time just looking for what I need or take a shortcut and Google it. The second option does not always yield the result I want immediately. Hence this project to organize these scripts in a single location.

So far it looks like a lot of CMD scripts will be the first blocks of code I am going to list. I'll try keep an example of the code I've used and experimented with. Some will be batch files others are individual scripts that I may use or experiment with regularly.


NOTE: This is an ongoing post. It may be updated on the same page or in other entries in the future. Thank you





Setup: Batch File

This is a standard set of scripts we put in place while preparing a kiosk system. Lin by line the batch goes the process of activating the admin privileges for the situation of activating a restore point at a remote location. Next line get the product name and serial number of the PC and display it on the command prompt. Next are for deactivating services that interrupt the proprietary software.



@echo off

net user administrator /active:yes

netsh http add urlacl url=http://+:8083/ user="Everyone"


wmic csproduct get name

wmic bios get serialnumber


sc stop "SysMain"

sc config "SysMain" start=disabled


sc stop "WSearch"

sc config "WSearch" start=disabled

pause



______________________________________


getmac: script sequence

This getmac script will help you make a list of the mac address of your network. What will be listed are the "Connection Name", "Network Adapter", "Physical (MAC) Address" and "Transport Name". On the few occasions I've worked on the actual network it was for identification purposes. Some of the equipment on the network may not be something the IT department approves of. On occasion it is necessary to check if the network slows down. A lot of times there is nothing going wrong. On that one occasion when something shows up that is different notify the network admin ASAP. Best case scenario is the IT team is trying something new. Worst case is classified as bad.


Run > cmd > getmac /v /fo list > Press ENTER


In steps:

1) Open Run window.

2) type "cmd" to get the command prompt.

3) type "getmac /v /fo list".

4) Press ENTER key to get the list of all network connections on that pc.


________________________________________________


Repair: Batch File

This was put together from different CMD scripts for the purpose of try to fix problems on most system HDDs running Windows operating systems. It will run a check disk function that will attempt to fix what it can. On it's heels it will run a Deployment Image Servicing and Management tool to check health, scan health and restore health. Finally it runs an system file checker tool to scan now to look for any issues not yet resolved on protected system files and replace corruptions with cached copies.


@echo off


chkdsk /F


DISM /Online /Cleanup-Image /CheckHealth

DISM /Online /Cleanup-Image /ScanHealth

DISM /Online /Cleanup-Image /RestoreHealth


sfc /scannow


pause


___________________________________


Scripting for IIS

Here are few script sequences that have been handy for other recent software projects I have to support. I'm using the Deployment Image Servicing and Management tool again. This time is to find a feature in Windows. Then using the same tool to enable a feature. The same tool can be used to disable features also. For the purpose of the demonstration the feature will be IIS. I found a good [tutorial] (https://www.itechguides.com/install-iis-windows-10/) if you are interested in doing this through the GUI or in PowerShell.


DISM.exe /Online /Get-Features | find "IIS"


Dism /Online /Enable-Feature /FeatureName:IIS-DefaultDocument /All


_____________________________________________________________________


3 views0 comments

Comments


bottom of page