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

18 May 2015

Installare font da VB/VBScript

Prende tutti i font in una cartella su un server e li installa sul client, se:
- non esistono sul client
- il file ha estensione .ttf o .otf

function GetOsName

 Dim objWMI, objItem, colItems
 Dim strComputer, VerBig, OSystem

 ' Here is where we interrogate the Operating System
 ' On Error Resume Next

 ' Get the computer name dot = this computer.
 strComputer = "."
 ' This is where WMI interrogates the operating system
 Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

 Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem",,48)

 ' Here we filter Version from the dozens of properties
 For Each objItem in colItems
  VerBig = Left(objItem.Version,3)
 Next

 ' Spot VerBig variable in previous section
 ' Note the output variable is called OSystem

 Select Case VerBig
  Case "6.2" OSystem = "8"
  Case "6.1" OSystem = "7"
  Case "6.0" OSystem = "Vista"
  Case "5.2" OSystem = "2003"
  Case "5.1" OSystem = "XP"
  Case "5.0" OSystem = "2000"
  Case "4.0" OSystem = "NT"
  'Case Else OSystem = "Unknown - probably Win 9x"
  case Else OSystem = ""
 End Select

 Set objWMI = nothing
 Set colItems = nothing

 GetOsName = OSystem

end function


function installaFont()

 ' http://www.bohack.com/2012/09/installing-fonts-on-windows-7-from-a-vbscript/

 const fileCopyOverwrite = true

 dim wShell
 dim clientDir, serverDir
 dim fs, fsoFolder, file
 dim wApp, appFolder, currentFile
 dim ext
 dim wFrom, wTo
 dim appClientFolder
 dim hoFattoQualcosa
 dim os
 dim s

 installaFont = false
 
 hoFattoQualcosa = false

 Set wShell = Wscript.CreateObject("Wscript.Shell")
 Set fs = CreateObject("Scripting.FileSystemObject")
 Set wApp = CreateObject("Shell.Application")


 clientDir = wShell.SpecialFolders("Fonts")
 serverDir = "\\your\server\path\to\Fonts"


 Set appFolder = wApp.Namespace(serverDir)
 Set fsoFolder = fs.GetFolder(serverDir)

 os = GetOsName

 For each file In fsoFolder.Files
  ' -- INSTALLA SOLO I FONT MANCANTI
  If Not fs.FileExists(clientDir & "\" & file.Name) Then
   
   Set currentFile = appFolder.ParseName(file.name)
   ext = lcase(right(currentFile, 4))

   if ext = ".ttf" or ext = ".otf" then
    select case os
     case "7"
      currentFile.InvokeVerb("Install")
      hoFattoQualcosa = true

     case "XP"
      wFrom = serverDir & "\" & currentFile
      wTo = clientDir & "\" & currentFile
  
      fs.CopyFile wFrom, wTo, fileCopyOverwrite
      hoFattoQualcosa = true

     case else
      s = ""
      s = s & "Impossibile installare il font ''" & ucase(replace(file.name, ext, "")) & "'': "
      s = s & "sistema operativo ''" & os & "'' non supportato dall'installazione."

      msgbox s, vbInformation, titoloApp
      installaFont = false
      exit function

    end select
   end if
  End If
 Next


 if hoFattoQualcosa then
  select case os
   case "XP"
   ' -- APRE LA DIRECTORY DEI FONT, ALTRIMENTI NON SONO "VISTI" DALLE APPLICAZIONI:
   ' -- FACENDO COSI', FA UN "REFRESH"
   set appClientFolder = wApp.Namespace(clientDir).self
   appClientFolder.invokeVerb("open")
   set appClientFolder = nothing
 
  end select
 end if



 Set currentFile = Nothing
 set wShell = nothing
 Set appFolder = Nothing
 Set wApp =  Nothing
 Set fsoFolder = Nothing
 Set fs = Nothing

 installaFont = true

End function


Note:
- su Win7 basta richiamare il verbo "installa"
- su WinXP non c'è tale verbo, quindi copio il file a mano nella cartella di sistema e poi la apro, per "forzare" una sorta di refresh dei font, altrimenti le applicazioni (es: Office2010) non "vedono" i nuovi font



Farina del mio sacchetto, ma basato sullo script trovato qui.

17 April 2015

Windows File Junctions, Symbolic Links and Hard Links

The Windows NTFS file system has supported some form of file and directory pointing since Windows 2000. Unfortunately each revision of Windows until Windows Vista has used a different method of implementing these pointers. So for this article I will just focus on Windows Vista and the identical Windows 7/8 implementations.

In Windows what is the difference between a short-cut, a symbolic link (sym-link) and a hard link?

A short cut is a file that points to another file. It is an antiquated pointing system from the Windows 95 era that many programs do not recognise. Short-cuts do not only use up space on the hard drive, they also break and linger behind after the target has been deleted, renamed or moved.

A symbolic link is like a short-cut but instead of being saved as a file it is registered to the hard drive partition. It does not use any disk space and all programs recognise both the link and the target. A symbolic link can point to any file or folder either locally on the computer or over a network using a SMB path.

A file hard link is a little different and can not be used over multiple partitions meaning you can not have a link on drive C: pointing to a file on drive D:. A file hard link points to and duplicates a target as a mirrored copy but the copy does not use any additional space on the hard drive partition. So 2 hard links that mirrored a 1 GB file would in total only use 1 GB on the partition rather than 3 GB. Importantly if either the hard links or the target are deleted the other links retain the data. Changes to the content of either the target or the links automatically propagate to all other items.

A junction behaves like is a hard link for directories but unlike file hard links you can create junctions that span multiple partitions. Again a directory junction and its content is stored on the hard drive partition but they do not use any additional space. Any changes to the content within either the target or the links will automatically propagate except where the target directory is deleted or renamed. In that case all hard links that point to the target will break and linger on the partition.

Microsoft Windows Vista, 7 and 8 use the command line program mklink to create links. It has 3 arguments and requires both a link name and target.

mklink /D /H /J [LINK NAME] [TARGET]

There are 4 modes for mklink which counteract each other so you can only use at most a single argument.

Supplying no arguments creates file symbolic link which is a pointer to a file.

/D creates a directory symbolic link which is a pointer to a directory.

/H creates a file hard link and is best used in situations where you need multiple mirrors of a file.

/J creates a directory junction which is a directory link that mirrors a the target directory over the same or on a different hard drive partition.

The word mirrors in this context means the live duplication of the target and the links. Any changes to the structure or the content of any files or any directories will propagate instantly to all links and to the target.

mklink /J WindowsVista C:\Windows

This command would create a directory junction WindowsVista linking (pointing) to the directory C:\Windows.


Via.

28 May 2014

Hide User Accounts on Windows 7 Logon

To hide additional user accounts on Windows & Logon Use Regedit, also works for Vista.

Hide User Accounts in windows Vista and Windows 7

Open regedit and go to
HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Winlogon

  • In the left panel, right click on Winlogon and click New and click Key.
  • Type SpecialAccounts and press Enter
  • In the left panel, right click on SpecialAccounts and click New and click Key.
  • Type UserList and press Enter.
  • In right panel of UserList, right click on a empty area and click New then click DWORD (32bit) Value.
  • Type in the name of the user account that you want to hide and press Enter.eg: Everyday Account.
  • In the right panel, right click on the user account name and click Modify.
  • To hide the user account – Type 0 and click OK. (number zero not the letter)
    Whenever you want to use the account just unhide the it by typing 1 instead of zero.

L'utente "Guest" si chiama "GuestUser" Trovato qui.

Mouse settings not saved after reboot/restart

  • Open msconfig
  • Within the System Configuration dialogue box, click the Startup tab
  • Look for any entries named KHALMNPR or similar, and uncheck the box next to them (there may only be one)
  • Click OK and restart your computer
  • After the restart, change your mouse pointer speed and restart

Occhio anche a quando si re-installano i driver del mouse, o a quando si cambia la porta USB (vengono installati nuovi driver): bisogna disabilitare nuovamente Logitech Setpoint! Trovato qui.

20 March 2014

How to pin documents directly to the Windows 7 taskbar

First, locate your file -- mine is C:\Users\Server\Desktop\foo.txt. Next, right click on your desktop and New > Shortcut. In the target, specify the program you want to execute and its path in quotes -- "C:\Windows\System32\notepad.exe". Add a space, and input the location of your file (again enclosed in quotes). The full target looks like this:

"C:\Windows\System32\notepad.exe" "C:\Users\Server\Desktop\foo.txt"

Now, give your shortcut a name -- this text will appear when you hover over your pinned taskbar icon. Before pinning, you can also right-click and choose properties if you'd like to choose a different icon for your shortcut. Once you're all done, left-click and drag the shortcut to the taskbar. That's it!


Trovato qui.

11 March 2013

Quickly Open a Command Prompt from the Windows Explorer Address Bar

Windows: Want to quickly run a command from within Windows Explorer? It turns out Windows has a built-in way to do this. Simply type in "cmd" in the address bar and it'll open the command prompt with the path to your current folder already set.


Testato su Win7, pare che su XP non funzioni. -- invece su XP ha funzionato!

Trovato qui.

28 April 2011

How to Rebuild the Icon Cache in Windows Vista and Windows 7

My earlier post Incorrect icon shown for a file type in Vista (March 31, 2008) tells you how to refresh the shell icons in Vista. In case the solution posted in that link does not help, you may want to clear the icon cache database. The icon cache can be cleared by deleting the hidden file named IconCache.db in the following location:

%userprofile%\AppData\Local

Note: %userprofile% represents the path to user profile folder.

Rebuilding the Icon Cache Database

1. Close all folder windows that are currently open.

2. Launch Task Manager using the CTRL+SHIFT+ESC key sequence, or by running taskmgr.exe.

3. In the Process tab, right-click on the Explorer.exe process and select End Process.

4. Click the End process button when asked for confirmation.

5. From the File menu of Task Manager, select New Task (Run…)

6. Type CMD.EXE, and click OK

7. In the Command Prompt window, type the commands one by one and press ENTER after each command:

CD /d %userprofile%\AppData\Local
DEL IconCache.db /a
EXIT

8. In Task Manager, click File, select New Task (Run…)

9. Type EXPLORER.EXE, and click OK.

 


 

An even easier way:

cmd /c taskkill /f /im explorer.exe && del %LocalAppData%\IconCache.db /a && explorer.exe

 

Trovato qui.

13 May 2010

COPY/XCOPY from network: restartable mode

I recently had to copy a very large file (>4GB) from a remote Windows share to my Windows 7 machine, over a very finicky connection (frequently-failing VPN over a slow Internet connection). A GUI copy didn't work because the connection dropped frequently. Then a colleague pointed me to the "copy /z" command:
/Z Copies networked files in restartable mode.
And this simple, built-in tool turned out to be the thing I needed. It was, every time, able to restart the download properly, and after a few times, it downloaded the file correctly.
A couple of tips:
  • If you interrupt the command with Ctrl-C, it will delete the portion copied so far and you'll have to restart the copy from the beginning. If you must interrupt a copy, simply terminate the network connection (it will die with an error, but leave the copied-so-far file) or close the window where the command is running.
  • When you restart it and it asks if you want to overwrite, you must answer "yes". You can also use the /Y flag.

Trovato qui.

22 March 2010

Speed Up Windows 7 Taskbar Navigation with a Registry Hack

The fundamental problem was that you needed two clicks to navigate to your document if you have two instances of a program running. Or you're stuck with hovering for what feels like an eternity.

At Windows 7 Forums I finally found a nice step in the right direction. Full post is here, but summarized below. In short, this hack causes an applications last active window to activate when you click the taskbar icon, and the next window in the second click, etc. The hover preview still works if you hover to begin with, but if you want the preview after you've click on an app's icon in the taskbar, you can Ctrl+Click to bring it back. The current default settings are the exact opposite (that is, Ctrl+Click cycles through the last active windows of an application).

  • Launch regedit.exe
  • Navigate in the left tree control to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
  • Go to Edit->New->DWORD (32-bit) Value
  • Name the value LastActiveClick
  • Hit enter to assign the value and change it to 1
  • Restart Explorer and you're good to go.

To restart Explorer without rebooting, open the Task Manager (Ctrl+Shift+Esc) and end the Explorer.exe process. Then create a new task (under "File") and paste "explorer.exe".

19 March 2010

How To Replace Notepad in Windows 7

It used to be that Notepad was a necessary evil because it started up quickly and let us catch a quick glimpse of plain text files. Now, there are a bevy of capable Notepad replacements that are just as fast, but also have great feature sets.
Before following the rest of this how-to, ensure that you’re logged into an account with Administrator access.
Note: The following instructions involve modifying some Windows system folders. Don’t mess anything up while you’re in there! If you follow our instructions closely, you’ll be fine.
Choose your replacement
There are a ton of great Notepad replacements, including Notepad2, Metapad, and Notepad++. The best one for you will depend on what types of text files you open and what you do with them. We’re going to use Notepad++ in this how-to.
The first step is to find the executable file that you’ll replace Notepad with. Usually this will be the only file with the .exe file extension in the folder where you installed your text editor. Copy the executable file to your desktop and try to open it, to make sure that it works when opened from a different folder.
In the Notepad++ case, a special little .exe file is available for the explicit purpose of replacing Notepad.If we run it from the desktop, it opens up Notepad++ in all its glory.
sshot-1
Back up Notepad
You will probably never go back once you switch, but you never know. You can backup Notepad to a special location if you’d like, but we find it’s easiest to just keep a backed up copy of Notepad in the folders it was originally located.
In Windows 7, Notepad resides in:
  • C:\Windows
  • C:\Windows\System32
  • C:\Windows\SysWOW64 in 64-bit versions only
Navigate to each of those directories and copy Notepad.
sshot-2
Paste it into the same folder.
sshot-3
If prompted, choose to Copy, but keep both files.
sshot-4
You can keep your backup as “notepad (2).exe”, but we prefer to rename it to “notepad.exe.bak”.
sshot-6
Do this for all of the folders that have Notepad (2 total for 32-bit Windows 7, 3 total for 64-bit).
Take control of Notepad and delete it
Even if you’re on an administrator account, you can’t just delete Notepad – Microsoft has made some security gains in this respect. Fortunately for us, it’s still possible to take control of a file and delete it without resorting to nasty hacks like disabling UAC.
Navigate to one of the directories that contain Notepad. Right-click on it and select Properties.
sshot-7
Switch to the Security tab, then click on the Advanced button.
sshot-8
Note that the owner of the file is a user called “TrustedInstaller”.
sshot-9
You can’t do much with files owned by TrustedInstaller, so let’s take control of it. Click the Edit… button. Select the desired owner (you could choose your own account, but we’re going to give any Administrator control) and click OK.
sshot-10
You’ll get a message that you need to close and reopen the Properties windows to edit permissions. Before doing that, confirm that the owner has changed to what you selected.
sshot-11
Click OK, then OK again to close the Properties window. Right-click on Notepad and click on Properties again.
Switch to the Security tab. Click on Edit….
sshot-12
Select the appropriate group or user name in the list at the top, then add a checkmark in the checkbox beside Full control in the Allow column.
sshot-14
Click OK, then Yes to the dialog box that pops up.
sshot-15
Click OK again to close the Properties window.
Now you can delete Notepad, by either selecting it and pressing Delete on the keyboard, or right-click on it and click Delete.
sshot-16
You’re now free from Notepad’s foul clutches!
sshot-17
Repeat this procedure for the remaining folders (or folder, on 32-bit Windows 7).
Drop in your replacement
Copy your Notepad replacement’s executable, which should still be on your desktop.
sshot-18
Browse to the two or three folders listed above and copy your .exe to those locations. If prompted for Administrator permission, click Continue.
sshot-19
If your executable file was named something other than “notepad.exe”, rename it to “notepad.exe”. Don’t be alarmed if the thumbnail still shows the old Notepad icon.
sshot-20
Double click on Notepad and your replacement should open.
sshot-21
To make doubly sure that it works, press Win+R to bring up the Run dialog box and enter “notepad” into the text field. Press enter or click OK.
sshot-22
sshot-23
Now you can allow Windows to open files with Notepad by default with little to no shame! All without restarting or having to disable UAC!