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

May 04, 2017

Win10 Sucks | Repair Win10 | Fix Win10 | How to exit Rage-Mode



list of necessity:







ctrl-shift right-click taskbar item for "Restore, Move, Size, Min, Max"

ctrl-shift left-click taskbar pinned item to "RunAs Admin"

create Show Desktop shortcut with:
%windir%\explorer.exe shell:::{3080F90D-D7AD-11D9-BD98-0000947B0257}

create Logoff Shortcut with:
%windir%\System32\logoff.exe
or alternatively: 
%windir%\System32\shutdown.exe /L


~~~
seo:
Fix Windows 10
Windows 10 sucks
I hate windows 10
Repair Windows 10
Windows 10 Stupidity
Windows 10 is fucking stupid
Windows 2016 is just as fucking stupid


September 03, 2014

Reindex and Shrink a WSUS Database on 2008R2


UPDATE Feb 2022: This is obsolete. Time to upgrade to Win 2019 or newer and use these resources:
- https://github.com/samersultan/wsus-cleanup
   Which needs https://docs.microsoft.com/en-us/sql/connect/odbc/windows/release-notes-odbc-sql-server-windows?view=sql-server-ver15#178
   and https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-2017
   When scheduling it, be sure to "start in" the folder of the stored the files.
- MS best practices here: https://docs.microsoft.com/en-us/troubleshoot/mem/configmgr/windows-server-update-services-best-practices
- Further reading that i did not necessarily apply: https://www.deploymentresearch.com/fixing-wsus-when-the-best-defense-is-a-good-offense/



UPDATE Feb 2018: For Windows 2012 :
- Try this: https://community.spiceworks.com/how_to/103094-automate-wsus-cleanup
- You will need x64\msodbcsql.msi and x64\MsSqlCmdLnUtils.msi

___ Original Post for Windows 2008 R2 WSUS _________________________________________

I have a basic local WSUS install on Windows 2008 R2 Server of which the SUSDB has grown significantly. Below is the requirements and functions I found to re-index and shrink the DB.

You may wish to run the WSUS Server Cleanup Wizard prior to these step.  I often found that running the "Unused updates and update revisions" separately from the others is a good idea. I.E. i often select the 2nd,3rd,4th, and 5th options, run it, then re-run it with only the 1st option selected.
Does "Deleting unused updates" get stuck?  Try http://wininfra.net/2016/05/13/workaround-for-wsus-sql-timeout-errors/ (I had to do this once and it took days, but fixed the issue.)
   Edit: Another copy of this script: https://gist.github.com/Chris-ZA/efe09d076fabb62153ca247d834bb5b2 to be used similarly to below.
   i.e. for 2008R2: sqlcmd -S \\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -i ".\wsusDBmaintenance.sql"
   or for 2012: sqlcmd -S \\.\pipe\MICROSOFT##WID\tsql\query -i ".\wsusDBmaintenance.sql"
Now for the content...

1) How to re-index:

The re-index script was found at http://gallery.technet.microsoft.com/scriptcenter/6f8cde49-5c52-4abd-9820-f1d270ddea61

First download and install sqlncli_x64.msi and SQLServer2005_SQLCMD_x64.msi from http://www.microsoft.com/en-us/download/details.aspx?id=15748

Then copy/paste the script mentioned above into a new file named WsusDBMaintenance.sql .

Open a command prompt and change to the folder where you saved the script and execute the following command:
sqlcmd -I -i"WsusDBMaintenance.sql" -S \\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query > reindex.txt

Of course you can create a batch file with the same command in it.

This may take some time, and results will be piped into reindex.txt for your review.


2) How to shrink:

We will use the SQL 2005 Express version of "Microsoft SQL Server Management Studio".  Download and install SQLServer2005_SSMSEE_x64.msi from http://www.microsoft.com/en-us/download/details.aspx?id=8961

Open SSMSE and connect to the local database by server name: \\.\pipe\mssql$microsoft##ssee\sql\query

Locate the database named SUSDB, right click, select Tasks>Shrink>Database>OK.

This may take a significant amount of time.

My database shrunk from 16.1GB to 12.9GB.

For further disk space recovery, try my previous post http://steronius.blogspot.com/2014/05/cleanmgr-on-windows-2008-r2-active.html which reclaimed 6+GB on my WSUS server.

~~~
As always, good luck!


Please consider crypto tipping:
  

May 16, 2014

Disk Cleanup utility (CleanMgr) on Windows 2008 R2 Active Directory

Do you need 4GB+ cleaned from a Windows 2008 R2 Active Directory Domain Controller?

In the past, Windows 2008 servers infamously stored obsolete program/update backups in C:\Windows\winsxs\ and there was no safe/supported way to cleanup.  A May 2014 update now allows cleanup.  Reference: http://blogs.technet.com/b/askpfeplat/archive/2014/05/13/how-to-clean-up-the-winsxs-directory-and-free-up-disk-space-on-windows-server-2008-r2-with-new-update.aspx

To simplify this, here are the commands (specific to Windows 2008 R2 64bit):

copy %systemroot%\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe %systemroot%\System32\

copy %systemroot%\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui %systemroot%\System32\en-US\

cleanmgr.exe

Select your OS Drive, then Check-mark the Service Pack Backup Files, and continue.

You should regain 4+GB on a Domain Controller (at least that is my experience).

When run on non-domain server, the I've found the Service Pack Backup Files was always 0 bytes.  Unsure why, but your mileage may vary.

If you have a non-R2 or non-64bit, follow the 2nd link referenced (Follow option 2).

Good luck.
----------


Please consider crypto tipping:
  

March 27, 2014

Windows Server 2003 Repair Install not available solution

Windows Server 2003 Repair Install not available -- solution:

First it seems that Dell CD's do not contain the "Repair Install" option as per the Internets.

Second, you may find that the "To Repair the selected Windows installation, press "R"" option does not show up no matter what.

A hint was found here: http://www.winvistatips.com/re-windows-2003-repair-option-missing-t770031.html -- which stated :
The option to repair appears only under some conditions.
The version has to be the same build number for example.
The path in the boot.ini has to be correct.
The system hive has to be loaded and checked, [...]
So I booted the CD and chose R - recovery console.

I ran fixmbr, fixboot, and most importantly "bootcfg /rebuild" (or possibly bootcfg /scan).

bootcfg /rebuild will allow you to add the system back into the boot menu, which in turn the CD will find something to be able to "R"epair.

You may wish to see if those 3 commands allows Windows to boot on it's own.  If not, then boot the CD again and choose

Setup Windows now, Press ENTER

Then, after the F8 agreement, and it examines the disks, it should now have the option

To Repair the selected Windows installation, press "R"

If not, so sorry, you're still screwed.

--------------
Please consider crypto tipping:
  

October 17, 2013

Batch file: For each live computer in a domain, do something



Need a batch file to perform an action, executable, or script for online domain members only?

Here, for simplicity, our do-something is "echo computer-name is online":

Save the following to a batch file: (two % signs are needed in batch files, one % if at the command-prompt)


@echo off

dsquery * domainroot -filter "(&(objectCategory=Computer))" -limit 0 -attr cn > computers.txt

for /f %%i in (computers.txt) do (
   ping -n 1 -w 500 %%i | find "Lost = 0">NUL && echo %%i is online || echo %%i is offline
)

del computers.txt


This can easily be changed to work on a specific OU and skip sub-OU's (-scope onelevel):

dsquery * "OU=EXAMPLE_OU,DC=EXAMPLE,DC=COM" -filter "(&(objectCategory=Computer))" -limit 0 -attr cn -scope onelevel > computers.txt

So your do-something could be powerful when combined with commands like:
psexec.exe \\%%i some-command
or
START /B some-batch-calling-psexec.bat

You could get fancy and do multiple things by enclosing them in ( ) but separating them with &:
( echo %%i online & script.bat %%i)


So here is an example batch file that runs "gpudate /target:computer /force" on the Computers OU and it's sub OU's (This assumes you are logged in with administrative privileges):

@echo off
setlocal enableextensions enabledelayedexpansion

dsquery * "OU=Computers,DC=EXAMPLE,DC=COM" -filter "(&(objectCategory=Computer))" -limit 0 -attr cn > computers.txt

for /f %%i in (computers.txt) do (
ping -n 1 -w 500 %%i | find "Lost = 0">NUL && ( echo !time! %%i ONline, Launching... & START /B psexec.exe \\%%i -e -d -s -low gpupdate /target:computer /force ) || echo !time! %%i OFFline
)

del computers.txt
echo.

--------------

Please consider crypto tipping:
  

June 19, 2013

run commands against AD domain members via flexcommand.hta


Execute commands against AD Domain Members via web-interface.

Thanks to the article How to Force Remote Group Policy Processing, I found "flexcommand.hta" compliments of Mr. Jakob H. Heidelberg of Copenhagen, Denmark.

First, I've repaired the original for use on Windows7 and 2008 as per Mr. Eirik Andreassen's comment.

I've also edited the original to allow for larger fields including the OU dropdown box and enabled the "sub-OU's" and "alive-only" options by default. 

Download the full flexcommand.hta here or the diff patch to compare.  It has to be run with domain admin privileges and without UAC.


Here are some useful example psexec commands:

psexec.exe \\{C} -e -h -d gpupdate.exe /force

psexec.exe \\{C} -e -h -d wuauclt.exe /reportnow

psexec.exe \\{C} -e -h -d \\example.com\netlogon\WUInstall.exe /install /criteria "IsHidden=0 and IsInstalled=0 and IsAssigned=1"
(depends on WUInstall on accessible share)

Enjoy.
-----------------

Please consider crypto tipping:
  

May 17, 2013

psexec via linux



Best source for Debian derivatives: https://software.opensuse.org/package/winexe
Best source for RH derivatives: https://pkgs.org/search/?q=winexe

I often use sysinternals'  psexec during my windows management routines; however, i'd often wish i could do such from my linux desktop rather than my windows vm.  Thanks to an updated "winexe" hosted at http://sourceforge.net/p/winexe/wiki/Home/ "psexec in linux" is possible.

In your debian, or ubuntu based distro add the following repository to /etc/apt/sources.list :
deb http://repo.openpcf.org/repository/ext/openpcf/ubuntu/ precise main

Then add the repo's public key and update/install: (As of this writing, it is version 1.00 and they are developing v1.1)
wget http://repo.openpcf.org/repository/ext/openpcf/openpcf.org-repo-public-key-C6E91526.asc
sudo apt-key add ./openpcf.org-repo-public-key-C6E91526.asc
sudo apt-get update
sudo apt-get install winexe

As with the windows utility psexec.exe, the target must be configured appropriately.  Specifically read the following if necessary:
1) http://forum.sysinternals.com/psexec-could-not-start_topic3698_post11962.html#11962
2) http://jamesrayanderson.blogspot.com/2010/04/psexec-and-ports.html

Lets test it by listing processes on the target:
winexe -U USERNAME //HOSTNAMEorIP "tasklist"

The utility should ask for the password and display results:
Password for [WORKGROUP\USERNAME]:

Image Name                   PID Session Name     Session#    Mem Usage
========================= ====== ================ ======== ============
System Idle Process            0 Console                 0         28 K
System                         4 Console                 0         72 K
smss.exe                     712 Console                 0        268 K
csrss.exe                    800 Console                 0      1,488 K
winlogon.exe                 824 Console                 0      4,892 K
services.exe                 868 Console                 0      2,228 K
lsass.exe                    880 Console                 0      1,876 K
vmacthlp.exe                1084 Console                 0        152 K
svchost.exe                 1100 Console                 0      2,328 K
PresentationFontCache.exe   1168 Console                 0      1,024 K
svchost.exe                 1196 Console                 0      1,676 K
svchost.exe                 1320 Console                 0     32,768 K
svchost.exe                 1412 Console                 0      2,576 K
svchost.exe                 1436 Console                 0        368 K
svchost.exe                 1508 Console                 0      1,440 K
svchost.exe                 1568 Console                 0      1,368 K
svchost.exe                 1912 Console                 0        272 K
alg.exe                     1956 Console                 0        280 K
svchost.exe                  584 Console                 0        384 K
ramaint.exe                 1296 Console                 0        424 K
SntpClient.exe              2796 Console                 0      1,416 K
dllhost.exe                 2892 Console                 0        360 K
vmtoolsd.exe                3260 Console                 0      2,708 K
vmware-usbarbitrator.exe    3368 Console                 0        388 K
vssvc.exe                   3436 Console                 0        188 K
SDUpdSvc.exe                3488 Console                 0        800 K
dllhost.exe                 2472 Console                 0      1,040 K
logon.scr                   4080 Console                 0        252 K
csrss.exe                   4024                         1      2,340 K
winlogon.exe                 404                         1      5,684 K
[etc]

When running programs that take parameters, remember to use quotes.
Lets test this by running a ping-to-self on the target.  Execute the utility including quotation marks:
winexe -U USERNAME //HOSTNAMEorIP "ping -n 1 127.0.0.1"

The above produces:
Password for [WORKGROUP\USERNAME]:

Pinging 127.0.0.1 with 32 bytes of data:

Reply from 127.0.0.1: bytes=32 time<1ms ttl=128
Ping statistics for 127.0.0.1:
    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

For domain accounts, i've found that you need to escape your domain username in this fashion: (notice the double-slashed username )
winexe -U DOMAIN\\username //HOSTNAMEorIP "commandline"

Be warned though, as also true with psexec, your password may be passed as plain text over the network.

~~~
As always, Good Luck!

Please consider crypto tipping:
  

March 15, 2013

Windows Commandline Super Tools

Make your win-management job easier with these command-line super tools:

Swiss Knife Tool
Kixtart
SysInternals Suite
Win Server 2003 resource Kit Tools
CygWin
GnuWin
--------------
Please consider crypto tipping:
  

January 05, 2013

Open .URL files in Linux


EDIT:  Comments to this post have very nice solutions, honorable mention goes to Trogdor's 3rd post using bash -c "cat %f | grep URL | cut -d'=' -f2 | xargs firefox &" but first place goes to Christian Schmidt for his grep 'URL=' < "$1" | cut -d'=' -f2 | xargs -n1 xdg-open .

That said, here is my original post (which may be worth it just for the gnome association circus):
-----------------------

I've a ton of .URL files, created by drag-and-drop from Mozilla Firefox within MS-Windows.  These files are not automatically usable in Linux, which really sucks.  Googling did provide the solution though, and here I'll share my notes:

Create a script named open-url.sh (i like to store my scripts in ~/scripts/) containing the following:
#!/bin/sh
# opens Windows .URL files in your default browser
# requires: xdg-open sed grep xargs
sed 's/^BASEURL=/URL=/' "$1" | grep -m 1 '^URL=' | sed 's/^URL=//' | sed 's/\r//' | xargs xdg-open

Now make it executable with chmod +x open-url.sh

Now you can associate .URL files with the script.  This might be the hard part, as I did fight with it in gnome; however, XFCE was straight forward.

If you are having particular problems in gnome, my notes report the following:
Duplicate the file /usr/share/applications/firefox.desktop into /usr/share/applications/web-link.desktop, and edit the latter to point to the script you created.

Edit: You may consider using ~/.local/share/applications/ instead. I've found it's easier for gnome to find the new .desktop here.

Edit: be sure to give it an appropriate Name= and GenericName=

Then associate the .URL files with the web-link.desktop file.

Edit: Possibly the best way to associate in gnome3 is right-click the file and "Open Other" choosing the new name you've given with the Name= from the .desktop previously edited. THEN, most importantly, right click the file again, then choose properties, and highlight the new name and click "Set as Default".

Additionally, even though Firefox was my default browser, my environment insisted on opening with Chromium.  I was forced to manipulate the xdg-open command.  Below are commands that may help you: xdg-open
xdg-settings get default-web-browser
xdg-settings set default-web-browser firefox.desktop
There is some chance, you may need to look into gnome-open or gvfs-open.

Edit: You can do OSX .webloc files too with the following script:
#!/bin/sh
# opens OSX .webloc files in your favourite browser
# requires: grep awk xdg-open
# or edit for similar like gnome-open
grep string "$1" | awk -F\> '{print $2}' | awk -F\< '{print $1}' | xargs xdg-open


You may wish to read http://steronius.blogspot.com/search/label/xdg-mime%20default for setting mime-types.

Good luck.
~~~

Please consider crypto tipping: