Windows 7: Difference between revisions

From miki
Jump to navigation Jump to search
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Tips ==
== Tips ==
=== Miscellaneous ===
;Windows Explorer
;Windows Explorer
* Press '''shift''' then '''right click''', to get more options in context menu / SendTo folder
* Press '''shift''' then '''right click''', to get more options in context menu / SendTo folder
Line 6: Line 7:
;Change location of special shell folders (desktop, favorites, my documents)
;Change location of special shell folders (desktop, favorites, my documents)
* '''Method 1''' — Right click on the folder → properties... → ''Location'' pane → change location
* '''Method 1''' — Right click on the folder → properties... → ''Location'' pane → change location
* '''Method 2''' &mdash; Edit registry locations <tt>
* '''Method 2''' &mdash; Edit registry locations <tt>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders</tt> ([http://www.vistax64.com/tutorials/107990-personal-user-shell-folders-move-location.html]).
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders</tt> ([http://www.vistax64.com/tutorials/107990-personal-user-shell-folders-move-location.html]).
* Note there is also <tt>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders</tt>. I also update that one, but the tips does not say so.

* Note there is also <tt>
;Map network drives for ALL accounts, including administrators
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders</tt>, but apparently it does not need to be modified.
* With UAC enabled, network drives mounted by a user are not available to administrators, nor apps running with elevated privileges
* [http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/how-to-map-network-drives-for-all-users-in-windows/c8ccf50b-333e-4c30-be8e-e4031c7dd069], [http://www.winhelponline.com/blog/mapped-drives-are-not-seen-from-elevated-command-prompt-in-vista/] recommends setting a registry key to bypass that, but '''it does not work''' in my Windows 7
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLinkedConnections"=dword:00000001
* '''Best solution''', use this script to remount shares for admin at startup [http://superuser.com/questions/105173/how-to-access-network-shares-from-an-elevated-process-in-windows-7?rq=1]. Copy following file at ''C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\remount-admin.vbs''
{{hidden|1=<tt>Startup\remount-admin.vbs</tt>
([{{#filelink: remount-admin.vbs}} download])|2={{#fileanchor: remount-admin.vbs}}
<source lang="bash">
' Script from http://superuser.com/questions/105173/how-to-access-network-shares-from-an-elevated-process-in-windows-7?rq=1
'
' Automatically remount local mapped drives for administrator account, so that these shares are also available to apps
' running in elevated privileges
'

Option Explicit
Dim objNetwork, objShell
Dim strDriveLetter, strNetworkPath
Dim colDrives, intDrive, strDrives


If WScript.Arguments.length =0 Then
Set objNetwork = CreateObject("WScript.Network")
Set colDrives = objNetwork.EnumNetworkDrives

For intDrive = 0 To (colDrives.Count -1) Step 2
rem WScript.Echo colDrives.Item(intDrive) & " is mapped to: " & colDrives.Item(intDrive + 1)
If Len(strDrives) > 0 Then strDrives = strDrives & " "
strDrives = strDrives & " " & Chr(34) & colDrives.Item(intDrive) & Chr(34) & " " & Chr(34) & colDrives.Item(intDrive + 1) & Chr(34)
Next

If Len(strDrives) > 0 Then
' re-call script with elevation
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "cscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & strDrives, "", "runas", 1
Else
WScript.Echo "No drives Mapped."
End If

Else
' elevated part
Set objNetwork = CreateObject("WScript.Network")

For intDrive = 0 To (WScript.Arguments.Count - 1) Step 2
rem WScript.Echo WScript.Arguments(intDrive) & " is mapped to: " & WScript.Arguments(intDrive + 1)
On Error Resume Next ' ignore already mapped drives
objNetwork.MapNetworkDrive WScript.Arguments(intDrive), WScript.Arguments(intDrive + 1)
On Error GoTo 0
Next

End If
</source>|headerstyle=background:#ccccff;text-align:left;}}

=== Share bluetooth device between dual boot Linux and Windows ===
Reference: [http://ubuntuforums.org/showthread.php?t=1479056&p=9363229#post9363229]

The trick is to copy the bluetooth link keys from Windows into Linux:
* Pair the device with Linux first
* Then pair the device with Windows
* Boot back in Linux, and extract the bluetooth keys using <code>chntpw</code>. Edit the registry file {{file|C:\Windows\System32\config\SYSTEM}}.
:<code>aa1111111111</code> is the bluetooth device id of the device to pair as given in Windows control panel &rarr; bluetoot devices, or in Linux Bluemanager.
chntpw -e SYSTEM
> ls
> cd ControlSet001\Services\BTHPORT\Parameters\Keys
> ls
> cd aa1111111111
> ls
> hex bb2222222222
: Note that it does not work from Windows because the keys are either denied access or hidden.
* Copy the key value (remove the spaces) into file {{file|/var/lib/bluetooth/AA:11:11:11:11:11/linkkeys}}

=== Repair Laptop brightness not working or stuck ===
;Easiest
* Close the lid and open it again (make sure the laptop does not go to sleep).

;From [https://www.youtube.com/watch?v=sXgunoYnrNM]:
* Go to control panel, devices management, then go to monitors and open properties for "Generic PnP Monitors".
* In "details" pane, open property ''Hardware Ids'', and copy the value field (something like <code>MONITOR\LGD02F1</code>)
* To re-enable brightness control, run:
<source lang=winbatch>
devcon.exe -remove =MONITOR *LGD02F1*
devcon.exe -rescan
</source>
* To disable it:
<source lang=winbatch>
devcon.exe -remove =MONITOR *LGD02F1*
</source>

=== Use Caps Lock as another Escape key ===
See [http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_Windows Map caps lock to escape in Windows]. Import the registry file (Win7/Win8):
<source lang=reg>
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,3a,00,46,00,01,00,3a,00,00,00,00,00
</source>

=== Open Windows Command anywhere ===
* Open Windows File Explorer at any folder.
* Press '''Shift''', and '''right click''' anywhere on the white space in folder files area.
* Select '''Open command window here'''.

=== Stream Windows Audio to Linux server ===
We use '''[https://github.com/duncanthrax/scream Scream]''', which installs as a virtual sound card on Windows, and publishes sound as a multicast stream.

On Windows 7 (emitter):
* Install the driver in the package.
* Set the Scream (VDM) card as default playback device.

On Debian Buster (received):
* Compile Scream for Pulseaudio:
<source lang="bash">
sudo apt install libpulse-dev
mkdir build && cd build
cmake ..
make
</source>
* Make sure the port <code>4010</code> is opened in the '''firewall'''.
* Start scream:
<source lang="bash">
./scream -i enp0s31f6
</source>

== Windows script ==
=== Opening file with default application in CMD shell ===
Recommended solution is to use <code>START</code> (see [http://stackoverflow.com/questions/3729187/how-to-open-file-with-default-application-in-cmd SO] and [https://ss64.com/nt/start.html ss64.com]):
<source lang="winbatch">
START "Title" my_document.doc
</source>

;Access denied
However when the file is on an mapped drive, we get <code>access denied</code>. The solution is then to call explorer directly:
<source lang="winbatch">
explorer my_document.doc
</source>


== Cleaning up Windows 7 ==
== Cleaning up Windows 7 ==
Line 37: Line 173:
Other links for general information:
Other links for general information:
* [http://blogs.technet.com/b/askpfeplat/archive/2013/02/24/how-to-reduce-the-size-of-the-winsxs-directory-and-free-up-disk-space-on-windows-server-2012-using-features-on-demand.aspx How to Reduce the Size of the Winsxs directory and Free Up Disk Space on Windows Server 2012 Using Features on Demand]
* [http://blogs.technet.com/b/askpfeplat/archive/2013/02/24/how-to-reduce-the-size-of-the-winsxs-directory-and-free-up-disk-space-on-windows-server-2012-using-features-on-demand.aspx How to Reduce the Size of the Winsxs directory and Free Up Disk Space on Windows Server 2012 Using Features on Demand]

== Upgrading to Windows 7 SP 1 on dual boot system ==
Upgrading to Win 7 SP1 fails on dual boot system because Windows does not find the boot disk (error code XXXX).

To fix the issue, Grub must be removed.

* Boot on Windows 7 Recovery disk, and start a command prompt.
* First restore the MBR [https://superuser.com/questions/690308/is-there-a-way-to-fix-this-windows-boot-issue]: <code>bootsect /nt60 all /mbr</code>.
* Then update BCD: <code>bcdboot C:\Windows</code>
* If getting error <code>Failure when Attempting to Copy Boot Files</code>, this is because the boot partition is not marked ''Active''. To fix [https://appuals.com/how-to-fix-failure-when-attempting-to-copy-boot-files/]:
<source lang=text>
diskpart
select disk 0
list partition
select partition 1
active
</source>
* Now retry again: <code>bcdboot C:\Windows</code>

Note: maybe the three usual commands would have worked:
<source lang=text>
bootrec /fixboot
bootrec /fixmbr
bootrec /rebuildbcd
</source>

== Keyboard shortcuts ==
Aero shortcuts [http://lifehacker.com/5390086/the-master-list-of-new-windows-7-shortcuts]:
* {{kb|Win-Up}} &mdash; Maximize active window.
* {{kb|Shift-Win-Up}} &mdash; Maximize active window vertically.
* {{kb|Win-Down}} &mdash; Restore / minimize window.
* {{kb|Win-Left/Right}} &mdash; Dock the window left/right, possibly to the display on the left/right, or restore
* {{kb|Shift-Win-Left/Right}} &mdash; Move the window to the display on the left or right.
* {{kb|Win-Home}} &mdash; Clear all but active window.
* {{kb|Win-Space}} &mdash; Make all windows transparent.
* {{kb|Win-Shift-S}} &mdash; Screenshot / Snipping tool? (or use open source alternative: [https://getsharex.com ShareX]).

Latest revision as of 17:22, 18 July 2020

Tips

Miscellaneous

Windows Explorer
  • Press shift then right click, to get more options in context menu / SendTo folder
  • Enter shell:sendto to configure SendTo menu
Change location of special shell folders (desktop, favorites, my documents)
  • Method 1 — Right click on the folder → properties... → Location pane → change location
  • Method 2 — Edit registry locations HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders ([1]).
  • Note there is also HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders. I also update that one, but the tips does not say so.
Map network drives for ALL accounts, including administrators
  • With UAC enabled, network drives mounted by a user are not available to administrators, nor apps running with elevated privileges
  • [2], [3] recommends setting a registry key to bypass that, but it does not work in my Windows 7
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLinkedConnections"=dword:00000001
  • Best solution, use this script to remount shares for admin at startup [4]. Copy following file at C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\remount-admin.vbs

Share bluetooth device between dual boot Linux and Windows

Reference: [5]

The trick is to copy the bluetooth link keys from Windows into Linux:

  • Pair the device with Linux first
  • Then pair the device with Windows
  • Boot back in Linux, and extract the bluetooth keys using chntpw. Edit the registry file C:\Windows\System32\config\SYSTEM.
aa1111111111 is the bluetooth device id of the device to pair as given in Windows control panel → bluetoot devices, or in Linux Bluemanager.
chntpw -e SYSTEM

> ls
> cd ControlSet001\Services\BTHPORT\Parameters\Keys
> ls
> cd aa1111111111
> ls
> hex bb2222222222
Note that it does not work from Windows because the keys are either denied access or hidden.
  • Copy the key value (remove the spaces) into file /var/lib/bluetooth/AA:11:11:11:11:11/linkkeys

Repair Laptop brightness not working or stuck

Easiest
  • Close the lid and open it again (make sure the laptop does not go to sleep).
From [6]
  • Go to control panel, devices management, then go to monitors and open properties for "Generic PnP Monitors".
  • In "details" pane, open property Hardware Ids, and copy the value field (something like MONITOR\LGD02F1)
  • To re-enable brightness control, run:
devcon.exe -remove =MONITOR *LGD02F1*
devcon.exe -rescan
  • To disable it:
devcon.exe -remove =MONITOR *LGD02F1*

Use Caps Lock as another Escape key

See Map caps lock to escape in Windows. Import the registry file (Win7/Win8):

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,3a,00,46,00,01,00,3a,00,00,00,00,00

Open Windows Command anywhere

  • Open Windows File Explorer at any folder.
  • Press Shift, and right click anywhere on the white space in folder files area.
  • Select Open command window here.

Stream Windows Audio to Linux server

We use Scream, which installs as a virtual sound card on Windows, and publishes sound as a multicast stream.

On Windows 7 (emitter):

  • Install the driver in the package.
  • Set the Scream (VDM) card as default playback device.

On Debian Buster (received):

  • Compile Scream for Pulseaudio:
sudo apt install libpulse-dev
mkdir build && cd build
cmake ..
make
  • Make sure the port 4010 is opened in the firewall.
  • Start scream:
./scream -i enp0s31f6

Windows script

Opening file with default application in CMD shell

Recommended solution is to use START (see SO and ss64.com):

START "Title" my_document.doc
Access denied

However when the file is on an mapped drive, we get access denied. The solution is then to call explorer directly:

explorer my_document.doc

Cleaning up Windows 7

Windows 7, as any Microsoft product, comes with a lot of bloat and crap. Unfortunately design is so bad that there is no way to clean it up. Here some links to help a bit.

Best Guides

dism /online /cleanup-image /spsuperseded      # To run in admin, and in sys32

Disable hibernation

  • Disable it as follows
powercfg.exe -h off

winsxs

ctts.exe C:\Windows        # Get real size of windows folders (handle soft links / hard links)

DriverStore


Other links for general information:

Upgrading to Windows 7 SP 1 on dual boot system

Upgrading to Win 7 SP1 fails on dual boot system because Windows does not find the boot disk (error code XXXX).

To fix the issue, Grub must be removed.

  • Boot on Windows 7 Recovery disk, and start a command prompt.
  • First restore the MBR [7]: bootsect /nt60 all /mbr.
  • Then update BCD: bcdboot C:\Windows
  • If getting error Failure when Attempting to Copy Boot Files, this is because the boot partition is not marked Active. To fix [8]:
diskpart
select disk 0
list partition
select partition 1
active
  • Now retry again: bcdboot C:\Windows

Note: maybe the three usual commands would have worked:

bootrec /fixboot
bootrec /fixmbr
bootrec /rebuildbcd

Keyboard shortcuts

Aero shortcuts [9]:

  • Win-Up — Maximize active window.
  • Shift-Win-Up — Maximize active window vertically.
  • Win-Down — Restore / minimize window.
  • Win-Left/Right — Dock the window left/right, possibly to the display on the left/right, or restore
  • Shift-Win-Left/Right — Move the window to the display on the left or right.
  • Win-Home — Clear all but active window.
  • Win-Space — Make all windows transparent.
  • Win-Shift-S — Screenshot / Snipping tool? (or use open source alternative: ShareX).