Archive
How to change text case in Word 2010
The “Change Case” action (portrayed by an “Aa” icon) is a useful one that is usually not noticed by Microsoft Word 2010 users (although often sought for and not spotted by many – probably because somebody misnamed the respective ribbon tab as “Home” instead of “Edit”).
It provides several options, the most useful being “UPPERCASE” and “Sentence case.”. The options are formatted as the resulting text will be converted which is I’d say a bit older practice (font selection dropdowns used to be like that in various software), since in other places like HTML styles Word 2010 shows live how the selected text (or the whole text if there’s no selection) will be converted as you move the mouse over different styles.
Launching MATLAB with no UI (headless) for remote automation
I’m sharing here an answer I just gave at:
for archiving, since this may interest fellow Roboticists
Launching MATLAB on a server without the GUI is covered thoroughly at
http://blogs.mathworks.com/desktop/2010/02/22/launching-matlab-without-the-desktop/
you should also read the user comments/discussion there
e.g. you can use
start matlab -nosplash -nodesktop –nojvm –noFigureWindows -minimize -r
"testcommand,quit"
The –noFigureWindows parameter is mentioned at
http://www.mathworks.com/help/techdoc/ref/matlabwindows.html
where it doesn’t mention –nodesktop (only the UNIX doc mentions it for X-Windows), however it seems you have to use it on Windows too, else you see the MATLAB code editor window too popup.
I’m not sure the –nojvm works at all on Windows version of MATLAB, it’s not mentioned in the official documentation URL mentioned above and also Process Monitor tool from Microsoft SysInternals shows that MATLAB still loads it’s internal Java VM’s files even with that command-line parameter provided.
If not using Java is too restrictive for your needs:
Regarding -nodesktop vs. -nojvm, there is a third
(undocumented/unsupported) option: ‘-noawt’. -noawt loads Java (thus
enabling Java I/O, data structures etc.) and just prevents Java GUI
Also note that when launching MATLAB from a WCF service, even if you set an AppPool to run the service under a custom account (say MATLABUSER) and even if you set the Matlab current directory / search path for that user (Matlab keeps them separately for each Windows user account), it keeps on ignoring them. Thus you are forced to use “-sd” deprectated command-line parameter of Matlab (mentioned at the official doc URL I sited above) to set the startup path of Matlab. In that folder you can have a “startup.m” file where you use ADDPATH command of Matlab to temprorarily update the Matlab startup path for the running Matlab process.
ADDPATH Add directory to search path.
ADDPATH DIRNAME prepends the specified directory to the current
matlabpath. Surround the DIRNAME in quotes if the name contains a
space. If DIRNAME is a set of multiple directories separated by path
separators, then each of the specified directories will be added.
ADDPATH DIR1 DIR2 DIR3 … prepends all the specified directories to
the path.
Unfortunately the “-sd” command-line parameter is deprecated, which means it could be removed in the future, but the Matlab online documentation fails to list alternatives, just says “For information about alternatives, see .” and nothing more there:
matlab -sd "startdir" specifies the startup directory for MATLAB (the current directory in MATLAB after startup). The -sd option has been deprecated. For information about alternatives, see .
BTW, instead of launching MATLAB via Windows shell command you could launch as a COM automation server:
http://www.mathworks.com/help/techdoc/matlab_external/brd0v3w.html
or via existing C API for launching MATLAB:
http://www.mathworks.com/help/techdoc/matlab_external/f29148.html
If you use this often (e.g. from a web service), it is best that you keep an instance of MATLAB in memory all the time (since Windows apps for example share code and have separate data this can spare much time by avoiding the reloading of MATLAB code into memory at every script run). That instance could be headless too (with no UI) using this command at server boot (e.g. by adding an entry at HKLM/Software/Microsoft/Windows/CurrentVersion/Run in the Windows registry using "regedit.exe"):
start matlab -nosplash -nodesktop –nojvm –noFigureWindows -minimize
Gotchas at Wait for a shelled app to finish (with/out timeout) with .NET
I came across a useful Microsoft Support sample called “How to wait for a shelled application to finish by using Visual Basic 2005 or Visual Basic .NET” at http://support.microsoft.com/kb/305368
However, note that there are several gotchas with the code supplied there (just informed Microsoft on that, hope they take notice). Also the article points to C# and to C++ versions of the sample that obviously need the same fixes
1) there’s an issue in both the first sample (wait indefinitely) and the 2nd one (wait with timeout)
‘Wait for the process window to complete loading.
p.WaitForInputIdle()
‘Wait for the process to exit.
p.WaitForExit()
Why wait for input idle first? The process might never enter idle state and exit before that. According to http://msdn.microsoft.com/en-us/library/8d7363e2(v=VS.90).aspx you might get exception from WaitForInputIdle:
| Exception | Condition |
| InvalidOperationException | The process does not have a graphical interface. -or- An unknown error occurred. The process failed to enter an idle state. -or- The process has already exited. -or- No process is associated with this Process object. |
I suppose it’s best to avoid calling WaitForInputIdle at all since you just care for WaitForExit there.
2) even WaitForExit can throw exceptions that the code should check for according to http://msdn.microsoft.com/en-us/library/fb4aw7b8.aspx
| Exception | Condition |
| Win32Exception | The wait setting could not be accessed. |
| SystemException | No process Id has been set, and a Handle from which the Id property can be determined does not exist. -or- There is no process associated with this Process object. -or- You are attempting to call WaitForExit for a process that is running on a remote computer. This method is available only for processes that are running on the local computer. |
3) The support article doesn’t mention what WaitForExit(timeout) doc (http://msdn.microsoft.com/en-us/library/fb4aw7b8.aspx) says about “infinite” timeout:
Note
In the .NET Framework version 3.5 and earlier versions, the WaitForExit overload waited for MaxValue milliseconds (approximately 24 days), not indefinitely. Also, previous versions did not wait for the event handlers to exit if the full MaxValue time was reached.
Also it seems the documentation for “WaitForExit(timeout)” doesn’t mention there’s a Timeout.Infinite constant that has the value –1 to use for such infinite timeouts (found it from the doc of Thread.Join): http://msdn.microsoft.com/en-us/library/system.threading.timeout.infinite(v=VS.90).aspx
4) The sample fails to call Close and thus keeps on spending resources for handle tracking (and “locking” those handle ids obviously although it’s not as easy as in old CPUs and OS versions to run out of handles I hope).
Quoting http://msdn.microsoft.com/en-us/library/fb4aw7b8.aspx:
When an associated process exits (that is, when it is shut down by the operation system through a normal or abnormal termination), the system stores administrative information about the process and returns to the component that had called WaitForExit. The Process component can then access the information, which includes the ExitTime, by using the Handle to the exited process.
Because the associated process has exited, the Handle property of the component no longer points to an existing process resource. Instead, the handle can be used only to access the operating system’s information about the process resource. The system is aware of handles to exited processes that have not been released by Process components, so it keeps the ExitTime and Handle information in memory until the Process component specifically frees the resources. For this reason, any time you call Start for a Process instance, call Close when the associated process has terminated and you no longer need any administrative information about it. Close frees the memory allocated to the exited process.
Also note that it could have a “Using” clause when defining the new process object (instead of Dim) instead of explicitly having to call “Process.Close” at the end to free up resources, as noted at http://msdn.microsoft.com/en-us/library/system.diagnostics.process.close(v=VS.90).aspx
The Close method causes the process to stop waiting for exit if it was waiting, closes the process handle, and clears process-specific properties. Close does not close the standard output, input, and error readers and writers in case they are being referenced externally.
Note:
The Dispose(Boolean) method calls Close. Placing the Process object in a using block disposes of resources without the need to call Close.
5) Other issue is at the 2nd sample (wait with timeout). It doesn’t mention having to call WaitForExit() again with no params after the WaitForExit(timeout) at the case where standard output has been redirected to async event handlers (should mention this case for completeness)
Quoting http://msdn.microsoft.com/en-us/library/fb4aw7b8.aspx:
When standard output has been redirected to asynchronous event handlers, it is possible that output processing will not have completed when this method returns. To ensure that asynchronous event handling has been completed, call the WaitForExit overload that takes no parameter after receiving a true from this overload. To help ensure that the Exited event is handled correctly in Windows Forms applications, set the SynchronizingObject property.
Kotsovolos: Case of a failed e-mail campaign
I recently received a promotional e-mail from an e-shop I mainly use to buy home appliances in Greece that was really funny: at the top offer there was a TV, but although the e-mail had been just sent (judging from its date/time stamp) the image already had a mark “exhausted” (out of stock) on it.
Obviously it was pulling the e-mail images from the e-shop’s web server, but it’s impossible to believe that so many clients had rushed already to buy that TV. Most probably they had too few items stocked on it, but then you don’t make that the top offer at your e-mail campaign.
Microsoft File Checksum Integrity Verifier (FCIV)
I recently came across a very useful Microsoft tool (FCIV) that can compute and store (as XML) checksums (MD5, SHA1 or both hashes) of folders/files you want and can also be used to later on verify the checksum lists to see if they’ve been tampered with.
Would be nice to have a GUI wrapper around that tool that would also cooperate with the task scheduler to run regular checks of sensitive files.
You can get FCIV from http://www.microsoft.com/download/en/details.aspx?id=11533 (after unpacking it at some folder you can checkout the tool parameters by typing fciv or fciv /? at the command line – of course you can use fciv | more to see the syntax page by page).
You can read more regarding that (unsupported) Microsoft tool at http://support.microsoft.com/kb/841290
Microsoft (R) File Checksum Integrity Verifier V2.05 README file
================================================================1.What is File Checksum Integrity Verifier (FCIV)?
2.Features.
3.Syntax.
4.Database storage format.
5.Verification.
6.History.1.What is fciv?
—————
Fciv is a command line utility that computes and verifies hashes of files.It computes a MD5 or SHA1 cryptographic hash of the content of the file.
If the file is modified, the hash is different.With fciv, you can compute hashes of all your sensitive files.
When you suspect that your system has been compromised, you can run a verification to determine which files have been modified.
You can also schedule verifications regularily.2.Features:
———–
- Hash algorithm: MD5 , SHA1 or both ( default MD5).
- Display to screen or store hash and filename in a xml file.
- Can recursively browse a directory ( ex fciv.exe c:\ -r ).
- Exception list to specify files or directories that should not be computed.
- Database listing.
- hashes and signature verifications.
- store filename with or without full path.3.Syntax:
———
Usage: fciv.exe [Commands] <Options>Commands: ( Default -add )
-add <file | dir> : Compute hash and send to output (default screen).
dir options:
-r : recursive.
-type : ex: -type *.exe.
-exc file: list of directories that should not be computed.
-wp : Without full path name. ( Default store full path)
-bp : base path. The base path is removed from the path name of each entry-list : List entries in the database.
-v : Verify hashes.
: Option: -bp basepath.-? -h -help : Extended Help.
Options:
-md5 | -sha1 | -both : Specify hashtype, default md5.
-xml db : Specify database format and name.To display the MD5 hash of a file, type fciv.exe filename
Compute hashes:
fciv.exe c:\mydir\myfile.dll
fciv.exe c:\ -r -exc exceptions.txt -sha1 -xml dbsha.xml
fciv.exe c:\mydir -type *.exe
fciv.exe c:\mydir -wp -both -xml db.xmlList hashes stored in database:
fciv.exe -list -sha1 -xml db.xmlVerifications:
fciv.exe -v -sha1 -xml db.xml
fciv.exe -v -bp c:\mydir -sha1 -xml db.xml
4.Database storage format:
————————–
xml file.The hash is stored in base 64.
<?xml version="1.0" encoding="utf-8"?>
<FCIV>
<FILE_ENTRY>
<name> </name>
<MD5> </MD5>
<SHA1> </SHA1>
</FILE_ENTRY>
</FCIV>5.Verification:
—————
You can build a hash database of your sensitive files and verify them regularily or when you suspect that your system
has been compromised.It checks each entry stored in the db and verify that the checksum was not modified.
6. History:
———–
Fciv 1.2 : Added event log.
Fciv 1.21: Fixed bad keyset error on some computers.
Fciv 1.22: Added -type option. Support up to 10 masks. *.exe *.dll …
Fciv 2.0: xml as unique storage. Added -both option.
Fciv 2.01: Exit with error code to allow detections of problem in a script.
Fciv 2.02: Improved perfs. When both alg are specified, it’s now done in one pass.
Fciv 2.03: Added -wp and -bp options. Fciv now stores full path or relatives paths.
Fciv 2.04: Removed several options to simplify it.
Fciv 2.05: Added success message if the verification did not detect any errors.
How to disable (and re-enable) Lenovo VeriFace without uninstall
I own a Lenovo IdeaPad S10-3t and I’m pretty satisfied with it (apart from the glossy screen and the bevel border arround the touchscreen that doesn’t allow you to easily touch near the screen edges – and would much prefer a NVidia GPU instead of Intel Graphics Accelerator which doesn’t support WDM1.1 btw [keep on dreaming]).
However, a very annoying thing is that it contains a security software named VeriFace (face recongition for easier login) that once you enable and let it grab your photo you can’t disable anymore without uninstalling it. So it pops up at every login screen, even after you may have started typing the password.
Microsoft Sysinternals tools to the rescue: their Autoruns tool allows you to locate and enable/disable or delete all items that can load when you boot your system or when you login etc. (unfortunately there is a multitude of ways for a process to autorun on Windows which also makes it easier for malware authors to hide their stuff).
Select the Winlogon tab, and uncheck the item described as Lenovo VeriTouch Credential Library. At next logoff/reboot you won’t see VeriFace popup again. To re-enable it later on if you’ve missed it, just check that item again using the Autoruns tool.
Note: