Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

April 4, 2015

Edit/Add to hosts file in Windows

On Mac or Linux, this is a cinch.
sudo vi /etc/hosts

On Windows, it sucks, and you will probably run into the "You cannot modify the Hosts file" error. Here's the workaround.

Navigate to Start Menu -> All Programs -> Accessories and right-click Notepad to run it as an administrator. You may be asked for your password at this point:

Navigate to the hosts file in Windows Explorer. It is located at C:\Windows\System32\drivers\etc\hosts. Right click it, and un-select the Read-Only attribute:

Now use Notepad to navigate to the hosts file. Be sure to view All Files!


Finally, change what you need to change. When done, do not just click File -> Save, but instead do File -> Save As... and overwrite the hosts file. You may again need to specify All Files as done above, else the hosts file you modified will just be saved as a .txt copy, which does nobody any good. Lastly, after saving, remember to make the hosts file Read-Only again.

March 4, 2015

Speedfan won't run on Windows 7 startup

I use Speedfan on my Windows machine to monitor fan speeds, temperatures, voltages etc for my hardware. It is extremely lightweight, clocking in at just over 3mB of memory, and more importantly is easily integrated into other software. I use it with Rainmeter, which is a beautiful way to add widgets and skins to your desktop, and is far more customizable than the native Windows widgets. One of my widgets provides information piped in from Speedfan:


Since Speedfan has been updated to work with Windows 8 binaries, I am no longer able to just toss a shortcut into the Startup folder. It will throw the following error on login; Error <SPEEDFAN Driver Not Installed> Is SPEEDFAN service started?:


The only work-around I could get working was to set up a new task in Task Scheduler. From Action -> Create Task, you can set up a new task to run on Startup.

  • In the General tab, enter a name, and be sure to select your OS to configure for.
  • In the Triggers tab, click "New", and select "Begin the task at log on" from the dropdown menu. I suggest also adding the delay task checkbox for 30 seconds. You might need to experiment with this a little bit; if the delay is too short, Speedfan still won't start.
  • In the Actions tab, actually Start Speedfan by inputting the path to the program. If you've configured Speedfan itself to start minimized, it will; no need to specify additional arguments.
  • This is enough information to get it going, so click OK.


If configured correctly, you should see something like what is above, and on your next computer startup, Speedfan should once again be running on its own.

February 7, 2015

Installing PHP Composer globally on Windows

Composer is a dependency manager for PHP. PEAR used to be the go-to tool for managing PHP dependencies quite some time ago, but it was always cumbersome, and not much fun to use. Composer makes it very easy!

On Windows, you can use the .exe installer; note you will need PHP installed, and have the php.exe accessible. In this particular case, I will be using Cygwin shell, and have already installed PHP as a Cygwin package for it:


When installation is done, close and reopen your terminal:


You can now run the composer command from anywhere in your shell.

composer
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.0-dev

January 11, 2015

Windows Network Backup does not start anymore - blame Samsung Magician

Recently I upgraded to a new Samsung SSD. Love it. The speed boost over even a last-gen SSD is amazing. But that's not what this post is about. Since I upgraded my primary drive, it was also time for a clean Windows install. I guess some people would find this tedious, but I actually enjoy setting things up, starting from a nice clean slate. The frustration, however, was that stuff that previously just worked, now didn't.

It took a lot of headscratching trying to figure out why I was unable to set up automated backups again, using Windows backup, as outlined in a much earlier post of mine. Well, turns out the old post is still accurate and up-to-date, and that the new factor is now Samsung Magician to deal with.

It is otherwise a fantastic piece of software, one that further customizes your system for improved speed or reliability. It serves as a good reminder to enable AHCI on your motherboard if you've never used it, checks that you're using SATA6, etc. You can also run benchmarks to make sure you're squeezing the performance out of your drive. But again, that's not what this post is about.


Sure enough, after having done a prior optimize, Windows backup was turned off via Samsung Magician. But not really, because I can still access "Backup and Restore" from the Control Panel, and even set up my backup location and credentials; the damn thing just won't work.


Turns out it deactivates the Windows service, but not the GUI. Hit up your Run prompt (CMD+R) and enter services.msc:


Find "Windows Backup" in the list of services, and sure enough, it will be disabled:


Now, you can either choose to leave the Startup Type as disabled, and just start the service manually this time, but that makes no sense for automated backups, as your service already needs to be on when the backup is initiated. Set the Startup Type to automatic, start the service, and save the settings:


You should once again be able to run a scheduled Windows Backup as usual!

December 7, 2014

Opening files in Notepad++ from Cygwin

Notepad++ is an improved text editor instead of standard Vim in the command line, and especially improves upon using classic Notepad. It is superior, even if only for the syntax highlighting making things more readable. This is an alias function that seeks to implement a GUI-based text editor into Cygwin shell, and to run it as a daemon in the background, instead of seizing control over the terminal window for as long as the editor is open.

np ()
{
/cygdrive/c/Program\ Files/Notepad++/notepad++.exe `cygpath.exe -w "$*"` &
}

Note that it needs to be a function, and not a vanilla alias, because aliases don't allow interpolated arguments. What this function does is open the executable Notepad++ file, then takes a path argument that has been converted from a Cygwin path to a Windows path. $* stores the aformentioned arguments that were entered on the command line, and the & lets the process run in the background. This lets you use Notepad++ from Cygwin without having the shell wait for an exit code. See here for bash scripting info.

Reload the shell:
. ~/.bashrc

Now we can open any text file by passing the filename as an argument along with our new alias function. Instead of using vim or another editor we can simply use Notepad++ like so:
np ~/mycooltextfile.txt

You can even create text files this way - by specifying a filename that doesn't exist yet, it will be created for you!

December 5, 2014

Cygwin shell setup and bash-style tweaks

We have already seen how Cygwin can bring some great quality-of-life improvements as an alternative to using the native Windows terminal. Cygwin closely emulates a Unix shell, but there are still some differences.

The Home directory for Cygwin shell is probably not where you might think it should be. It is actually located within the Cygwin install directory (i.e. C:\Program Files\cygwin\home\User):

cd ~
pwd
/home/User

Since this isn't technically your Windows user's home directory, it will be empty, aside from config files that are used to emulate the Unix environment. As an example, you would navigate to C:\Users\User\My Documents like below (note how spaces need to be escaped by using backslashes):
cd /cygdrive/c/Users/User/My\ Documents/

Packages and programs are also not installed via command line. Instead, as explained in an earlier post, you would need to re-run the Cygwin setup.exe, which doesn't actually reinstall Cygwin from scratch, but just rebuilds it from existing packages, as well as any new ones you add during this subsequent install.

Aliases are a neat way to improve your workflow, and setting some up in Cygwin is really no different than Unix. Let's add some aliases (all config files are in the Cygwin home directory):
vi ~/.bashrc

I usually uncomment the ll, ls, la aliases, and add a few, like this function to use Notepad++ as a GUI text editor instead of using Vim in the terminal. Vim isn't great in Cygwin (feels more buggy than its Unix counterparts), so a solid GUI alternative before resorting to vanilla Notepad, is the nicer Notepad++. Anyways, you can also set up simple navigational aliases if symbolic links aren't your thing:
alias pro='cd /cygdrive/d/Projects'

You can also turn off the annoying bell beep sound the shell makes when you enter something incorrect, or try to autocomplete something that doesn't exist. In your ~/.inputrc file, uncomment or add:
set bell-style none

Reload the shell, no need to close and reopen to pull in the changes:
// These two commands are identical:
source ~/.bashrc
. ~/.bashrc

And now you can enjoy your newly added shortcuts!

November 23, 2014

Replacing Windows cmd terminal with Console2 and Cygwin shell

In my last post I set up Cygwin to emulate a UNIX environment. We now have some added features that can be used via command line, but at the end of the day, Cygwin's shell is merely being invoked from the default Windows terminal. Yuck.

Console2 is an open-source replacement for Windows' native terminal. "Features include: multiple tabs, text editor-like text selection, different background types, alpha and color-key transparency, configurable font, different window styles". So basically, it is all the goodness of UNIX terminals brought to Windows. As of the time of this writing, the last update to this software was done over a year ago, yet there are still 5000+ downloads a week from SourceForge - a great testament to its ongoing popularity.

After downloading the 32-bit package (don't bother looking for the nonexistent 64-bit version), simply extract the Console2 folder to your Program Files directory, and run the Console.exe program within. You should see something like this:


Ok... now it just looks like a windows shell inside our new terminal... which is exactly what it is, and is exactly the opposite of how Cygwin is currently running a UNIX shell inside the Windows terminal. Let's hook the two up!

Instead of invoking cmd to access the Windows terminal, you'll now be using Console2 as its replacement, so pin it, desktop it, shortcut it, whatever - you'll be using it from now on. In Console2's menu, select Edit -> Settings... and from the Console setting in the sidemenu, point the unconfigured Shell to Cygwin.bat. Note that you may have to view All Files in the Files of Type dropdown:


It also won't hurt to set up a few sane copy/paste/mouse commands, and these can be done from the Hotkeys and Hotkeys -> Mouse settings. It is strange that Console2 isn't configured out-of-the-box to select text with the mouse cursor, but this is a nice quality-of-life improvement that we take for granted on a Unix terminal. As for copy/paste shortcuts, don't choose Ctrl+C for copying. Cygwin seems unable to distinguish between the shell being process-locked versus not, so Ctrl+C cannot be used for both copying and halting - the user definition overrides the innate process-halting definition.

Close Console2 after saving your settings, and reopen it to Cygwin's glorious UNIX shell within the enhanced goodness of Console2!

November 22, 2014

Setting up Git, SVN, curl and SSH on Windows using Cygwin terminal

I have previously mentioned that on my home computer, which is a Windows-running machine, I use Cygwin shell with a Console2 terminal. I have gotten used to Unix commands and infrastructure as I use them at work, and the Windows CLI just felt... well, flat in comparison.

Cygwin and Console2 are a nice remedy to implement a familiar interface for Windows. Let's start with Cygwin.

In their own words, Cygwin is "a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows". And frankly, this is the least finicky way I've been able to use Git on Windows. A lot of other GUI-based Git interfaces are pretty bad, and it's always better practices to learn and know the command line commands. So, speaking of, once you downloaded Cygwin, you choose your install directory, as well as a downloaded packages directory - it is here that "modules" such as Git gets installed into Cygwin. Get to know and love the Packages interface in Cygwin, chances are that if you are missing a module and need to install it later, you will be running Cygwin's installation program again (which now skips right to the packages window) to add what you need.

For a first-time install, I usually kick off my setup with a few choice packages such as:

  • vim (ironically for a UNIX emulator, this is actually not enabled by default)
  • OpenSSH
  • AutoSSH
  • PHP interpreter
  • curl
  • PHP-curl
  • Git (be sure to select the ca-certificates and libsasl2 packages as well - oddly they are not chosen as dependencies (unless you install the curl package as above). See here for more info, else you'll be running into "cannot open shared object file: No such file or directory" HTTPS git errors!)
  • Git/SVN
  • lib-mcrypt

These make it convenient to run commands straight from the Cygwin shell, for example if I need to run a quick cURL call or something. The SSH client is pure command line, so no need to fiddle around with crappy Windows GUI clients or yet another terminal emulator like PuTTY.

After selecting your desired Cygwin packages, you can complete the installation, noting the prompt to install dependencies for your selected packages. I usually go back and disable a few at this point, because - for example - blanket enabling the entire PHP5 package would then enable other packages like PHP5-apache2, which then have their own dependencies like the large Apache2 package which I personally won't need at all.

After installing, you can open your Cygwin shell, and see something like this message on the first load:
Copying skeleton files.
These files are for the users to personalise their cygwin experience.

They will never be overwritten nor automatically updated.

'./.bashrc' -> '/home/User//.bashrc'
'./.bash_profile' -> '/home/User//.bash_profile'
'./.inputrc' -> '/home/User//.inputrc'
'./.profile' -> '/home/User//.profile'

User@location ~
$ |

Right now, you're probably thinking that it's nice to have a UNIX shell, but the default Windows terminal that still wraps it is not very nice. I am of the same opinion. In the next post we will spruce things up a bit with Console2, entirely replacing the vanilla cmd terminal that the Cygwin shell still defaults to, and in a future post go over some Cygwin-specific tips.

April 2, 2014

CalDAV Calendar on Synology DSM5: Locally sync Baikal with Windows eM Client

In my previous post, we set up the Baikal calendar package and added some users and blank calendars. Now let's sync it with a CalDAV client over the local home network. In my case, I will be using eM Client on Windows 7.

I don't have Outlook, and am more interested in eM Client, which seems to be one of rather few alternative standalone mail/contacts/calendar clients for Windows. For purposes of simply viewing and editing a calendar, it is overkill given all of its features, but it is easy and convenient to set up and use while troubleshooting this setup. My eventual goal is to sync the calendar hosted on my Synology box with my cellphone.

Once eM Client is installed, go to Tools -> Accounts -> New Account. From here, go to the "Calendar" dropdown, and select "CalDAV":


Fill in your info as was set up during Baikal's installation. Note that the account address URL does not contain a port number, and that the user ID that should be used is not any existing DSM user, but instead a Baikal user that was set up during the package's installation:



If all went well, you should see... absolutely nothing!:



This is because we have yet to add any info to our blank calendars. I am planning to import my Google Calendar here, so let's go grab that real quick. Select from your desired Calendar, and go to its settings page:



Here export your calendar as ICAL format by conveniently clicking the green button (don't get to say that often, lol), and then right-clicking and "Save Link As..." in the pop-up:



It's probably not a bad idea to rename the default name from basic.ics to something more meaningful, especially if you have multiple calendars to export. This will help keep track when importing them via the now-connected eM Client to our NAS. Back in eM Client, go File -> Import, and select "Import events from iCalendar (.ics)":




Once the import is complete, you should now see your previously existing Google Calendar events here. Congratulations, you just severed the tie with Google, and now have a completely private calendar that you can access over your local network! In the next post, we will sync our private calendar with a mobile device, becoming fully self-reliant.

April 1, 2014

Windows/Mac/Linux filesharing from Synology NAS accounts

This is really simple to do, but ties in with setting up proper user accounts and permissions. Remember setting up user accounts and permissions? On the final application page, check what is necessary. I have a need for all these services on this particular user account:


Now we need to actually enable file sharing with our operating system. In most cases this should already be filled in, but if it is not, take a look at Control Panel -> File Services:


Since I'm using Windows, I don't presently have a need for Mac File Service, so let's disable that for now.

You should now be able to access your NAS from Windows' Network, and should see it listed as a "computer" along with all the other devices on the network.

Windows 7 Professional Backup to Synology NAS

Lately I've been enjoying exploring my Synology NAS. I have a DS213+ that I purchased after a recent scare in which some of my PC hard drives failed. Until then, proper backups were a distant afterthought, but data preservation has since become a neurotic pastime.

Finding the right tool to perform autonomous backups was actually harder than I thought. Synology is often touted as having fantastic software to go along with their sleek hardware, but I could not put up with using Data Replicator 3, which comes with the unit. I have somewhat over 1TB of crap (I'm a digital packrat...) that I wouldn't mind hanging on to, and absolutely need incremental backup capability. Data Replicator 3 would perform a complete data replication (ha ha) and then go and delete the older backups, depending on your settings. A single backup would take many hours of dominating network bandwidth. If there was an incremental backup option hidden somewhere, I could not find it before becoming fed up, and started looking at other options.

There are lots of supposed good (and free!) options out there, but I settled on Windows Backup. Here's my experience:

  • It is already included in Windows 7, and readily available without initial setup.
  • Any version of Windows 7 can back up to a local disk, but Windows 7 Professional can back up to a network location.
  • Can run autonomously on a schedule.
  • Folders can be "cherry-picked" as needed.

This post assumes that Synology DSM has already been set up, along with proper users/groups/folder permissions. Setting up the Windows side of the coin was easy enough. Note that since we are about to set up a way to automatically back up our stuff, we need to make sure that Windows Backup is actually running properly - check this post out if Windows Backup is behaving oddly or not starting. Otherwise, hit up the Start Menu -> Backup and Restore, then select "Set up backup" to get started.


Browse to your NAS location. Do note, that to be able to backup to a network location, you need a genuine and activated copy of Windows 7. If for some reason you haven't yet activated your copy, the setup will keep failing at this step, even if your NAS is visible on the network and has correct credentials entered.



You'll see a warning saying that other people on your network might access your backup, but that's why having good user settings and permissions on your Synology's end is a good idea. 



Once your network location is shown, hit next, wait for validation, then pick what you want to back up. I'm anal retentive, so I want to pick what gets stored:



From here, go nuts with your goods. You can even include a system image if you want some way to quickly restore your computer in case of nubbery. After that, review your settings, and you're done! All that remains is the actual backup. The first backup will take the longest, but the subsequent backups are indeed incremental, and should go much faster.

Windows backup seems to store files in a compressed state in a weird folder/zipfile hierarchy that I haven't dug into too much. It does save a tiny bit of space if that's your thing, but with a 3TB drive, it really wasn't a concern for me.



All in all, Windows backup seemed to work the most intuitively, and was seamless with my Synology unit.