Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Friday, 21 February 2014

Release Mapped Files from Memory

User RAMMap to identify the leaked memory if a mapped file is cause of the problem then use following to fix this immediately:

1. Highlist the Mapped file
2. From Menu select 'Empty' > 'Empty Working Sets'
3. All the locked memory should be released, press F5 to refresh see the Mapped file total moved to Standby.
4. Again select 'Empty' from Menu bar > Empty Standby
5. F5 to refresh

Saturday, 27 April 2013

How to disable firewall command line?

To Disable:
netsh firewall set opmode disable

To Enable:
netsh firewall set opmode enable

How to clear preferred IP address

How to clear preferred IP address?

Step 1. Goto Start, Run, CMD to open a command prompt.
Step 2. Reset WINSOCK entries to installation defaults: netsh winsock reset catalog
Step 3. Reset TCP/IP stack to installation defaults. netsh int ip reset reset.log
Step 4. Reboot the machine.

Thursday, 4 April 2013

Disk extended in Computer Management not showing in My Computer

If you come across a Virtual Machine running out of space and you are about to provision more space and extend it make note that extending disk from Computer Management may increase the disk space on Computer Management window but also check from My Computer to ensure disk is actually extended.

If you come across this problem where disks showing in My Computer window are not extending after a refresh then do following:
  • Allocate more space to the VM
  • run Re-Scan from Disk Management
  • use Diskpart to extend as shown in the screenshot below




Monday, 25 February 2013

Uninstall lastest installed Windows Patches

Excellent script, works every time.

-------------------
 
' Script to enumerate last applied hotfixes, and rollback

on error resume next
const forappending = 8
const forwriting=2
const forreading=1
Const dictKey  = 1
Const dictItem = 2

' **********set to 0 to get out of testmode**********
testmode=0
' ***************************************************

Logpath="C:\hotfixundo.log"

Set fso = createObject("Scripting.FileSystemObject")
set windir=fso.GetSpecialFolder(0)
call stamplog("*************************************************************")
call stamplog("Starting process, windows directory is "&windir.path)

lastdate=""
' enumerate subfolders, check date.
    For Each Subfolder in windir.SubFolders
    if instr(lcase(subfolder.name),"$ntuninstall")<>0 then
        if lastdate="" then
            lastdate=subfolder.datecreated
        end if
        if datediff("d",lastdate,subfolder.datecreated)>1 then
            lastdate=subfolder.datecreated
        end if
    end if
    Next

call stamplog("Latest date found for uninstall folder is "&lastdate)
' loop again, creating a list of directories to be targeted.

set list = CreateObject("Scripting.Dictionary")

call stamplog ("Processing the following directories:")
    For Each Subfolder in windir.SubFolders
    if instr(lcase(subfolder.name),"$ntuninstall")<>0 then
        if datediff("d",lastdate,subfolder.datecreated)<1 and datediff("d",lastdate,subfolder.datecreated)>=0 then
            list.add subfolder.datecreated,subfolder.path
            call stamplog2(subfolder.path)
        end if
    end if
    Next

' sort dictionary
sortdictionary list,dictkey

' loop through list, shell out to run spuninst for each directory, last first
for each location in list
call stamplog("Launching "& list.item(location)&"\spuninst\spuninst.exe")
err.clear
if testmode=0 then
run list.item(location)&"\spuninst\spuninst.exe /quiet /passive /norestart"
else
call stamplog("***TESTMODE - Uninstall NOT run***")
end if
next
call stamplog("Finished at "&date&" "&time)

' Stamp line of text to specified logfile
sub stamplog(text)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    (logpath, Forappending, True)
objtextfile.writeline(text)
wscript.echo (text)
objTextFile.Close
end sub

sub stamplog2(text)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    (logpath, Forappending, True)
objtextfile.writeline(text)
'wscript.echo (text)
objTextFile.Close
end sub


' Run function
Function Run (ByVal cmd)
   Dim sh: Set sh = CreateObject("WScript.Shell")
   Dim wsx: Set wsx = Sh.Exec(cmd)
   If wsx.ProcessID = 0 And wsx.Status = 1 Then
      ' (The Win98 version of VBScript does not detect WshShell.Exec errors)
      Err.Raise vbObjectError,,"WshShell.Exec failed."
      End If
   Do
      Dim Status: Status = wsx.Status
      WScript.StdOut.Write wsx.StdOut.ReadAll()
      WScript.StdErr.Write wsx.StdErr.ReadAll()
      If Status <> 0 Then Exit Do
      WScript.Sleep 10
      Loop
   Run = wsx.ExitCode
   End Function

' Runs an internal command interpreter command.
Function RunCmd (ByVal cmd)
   RunCmd = Run("%ComSpec% /c " & cmd)
   End Function

' Sort function
Function SortDictionary(objDict,intSort)
  ' declare our variables
  Dim strDict()
  Dim objKey
  Dim strKey,strItem
  Dim X,Y,Z

  ' get the dictionary count
  Z = objDict.Count

  ' we need more than one item to warrant sorting
  If Z > 1 Then
    ' create an array to store dictionary information
    ReDim strDict(Z,2)
    X = 0
    ' populate the string array
    For Each objKey In objDict
        strDict(X,dictKey)  = CStr(objKey)
        strDict(X,dictItem) = CStr(objDict(objKey))
        X = X + 1
    Next

    ' perform a a shell sort of the string array
    For X = 0 to (Z - 2)
      For Y = X to (Z - 1)
        If StrComp(strDict(X,intSort),strDict(Y,intSort),vbTextCompare) > 0 Then
            strKey  = strDict(X,dictKey)
            strItem = strDict(X,dictItem)
            strDict(X,dictKey)  = strDict(Y,dictKey)
            strDict(X,dictItem) = strDict(Y,dictItem)
            strDict(Y,dictKey)  = strKey
            strDict(Y,dictItem) = strItem
        End If
      Next
    Next

    ' erase the contents of the dictionary object
    objDict.RemoveAll

    ' repopulate the dictionary with the sorted information
    For x=(z-1) to 0 step -1
'    For X = 0 to (Z - 1)
      objDict.Add strDict(X,dictKey), strDict(X,dictItem)
    Next

  End If

End Function

Tuesday, 22 January 2013

Active Directory Health Check Script

netdom query fsmo > C:\temp\HealthCheck_FSMO_roles.txt
Dcdiag.exe /v > c:\temp\HealthCheck_dcdiag.txt
Dcdiag.exe /q > c:\temp\HealthCheck_dcdiag_erroronly.txt
Netdiag.exe /v > c:\temp\HealthCheck_Netdiag.txt
Netsh dhcp show server > c:\temp\HealthCheck_dhcp.txt
Repadmin /showreps > c:\temp\HealthCheck_rep_partners.txt
repadmin /replsum /errorsonly > c:\temp\HealthCheck_rep_erroronly.txt

Thursday, 10 January 2013

Mastering icacls.exe in 15 mins



http://www.bohack.com/wp-content/uploads/2009/12/icacls-gui.jpg


 icacls [path] [TABLE 1] [TABLE 2] domain\user:[TABLE 3] [TABLE 4]
[TABLE 5]

examples
icacls E:\Home Directories\%userDir%" /grant:r "MYDOMAIN\%userDir%":(OI)(CI)F
icacls Sales_Folder /grant FileAdmins:(D,WDAC)
icacls * /grant accountName:(NP)(RX) /T
-----------------------------------------


TABLE 1

/grant will grant user permissions or the add option in the GUI.
/remove will remove the user from the DACL and is equivalent to
 the remove option in the GUI.

Note: /remove:g will remove only grants for the user 
      and /remove:d will remove only denys for the user.

/deny is equivalent to the deny column in the GUI 
 and should always be used cautiously.
/setowner is a handy little command which allows you to change 
 the ownership of a file or folder to another user; 
 this is similar to the linux chown command.
/findsid which finds entries in a DACL for a specified SID or user.
/setintegritylevel is a bit out of the scope of this article 
 and may be in a future article.


-----------------------------------------
TABLE 2
/inheritance:e to enable same as a check box in the GUI.
/inheritance:d to disable and copy the permissions 
 from the parent same as the GUI.
/inheritance:r to disable and remove the 
 current permissions again same as the GUI.
-----------------------------------------
TABLE 3
This folder only
This folder, subfolders and files (OI)(CI)
This folder and subfolders (CI)
This folder and files (OI)
Subfolders and files only (OI)(CI)(NP)(IO)
Subfolders only (CI)(IO)
Files only (OI)(IO)
-----------------------------------------
TABLE 4
Simple Permissions

Full Control (F)
Modify (M)
Read & Execute (RX)
List Folder Contents (X,RD,RA,REA,RC)
Read (R)
Write (W)

Advanced Permissions

Full Control (F)
Traverse folder / execute file (X)
List folder / read data (RD)
Read attributes (RA)
Read extended attributes (REA)
Create file / write data (WD)
Create folders / append data (AD)
Write attributes (WA)
Write extended attributes (WEA)
Delete subfolders and files (DC)
Delete (D)
Read permissions (RC)
Change permissions (WDAC)
Take ownership (WO)
-------------------------------------------
TABLE 5
 /T  Traverse all subfolders to match files/directories. 
   
   /C  Continue on file errors (access denied)  Error messages are still displayed.
  
   /L  Perform the operation on a symbolic link itself, not its target.

   /Q  Quiet - supress success messages.

Tuesday, 27 November 2012

How to access Cached Credentials - Windows XP - Vista - 7



Start > Run > OR  Windows Key + R

rundll32.exe keymgr.dll, KRShowKeyMgr