Wednesday, February 22, 2012

Adding text to an Off-page reference in Visio

I am creating a Visio diagram and I need to use the Off-page reference. Unlike other shapes that I can double click to assign a text, when I double click on an Off-page reference, it redirects me to its referenced shape in another page.

So how can I add text to my Off-page reference? Here are two ways:
1) Left-click on the Off-page reference, and press the F2 key, or
2) Left-click on the Off-page reference, and click the Text command on the toolbar (Home ribbon).  Shortcut key is CTRL+2.

Also make sure that you check the "Keep shape text synchronized" option when initially creating an Off-page reference. This will ensure that changes to the text of any of the shape references will be automatically reflected to the other (avoiding possible confusion if  you happen to have a number of references).






















*joychua97

Friday, February 17, 2012

Running InstallUtil unattended

The following command runs InstallUtil.exe unattended and passing username and password:

InstallUtil.exe /unattended /username=<domain\username> /password=<password> Service.exe

IMPORTANT NOTE: The switches (username, password, etc) must be placed before the name of the service to be installed, otherwise the switches will not be used. I made this mistake so I initially thought that these switches were not working :)

Use the /? or /help switch to learn more about the other options that can be used in installing the service

InstallUtil.exe /? Service.exe

*joychua97

Redirecting output of PowerShell scripts

Now I have finished creating the first part of my PowerShell script, and I now want to create some sort of logging instead of just having the output printed on the console. So I need to redirect the output to a log file, and still see on the console what is being written to the file.

To achieve this, I used  Tee-Object as shown below. This will redirect even the error messages to the log file and continuously display the contents of the file as it is written to.


     ./samplescript "input parameters" 2>&1 | Tee-Object  "logfile.txt"


To redirect just the output to the log file and leave error messages to the console:


     ./samplescript "input parameters" > "logfile.txt"

Here are the other Windows PowerShell redirection operators:

Operator Description Example
> Redirects output to the specified file, overwritting its current contents. ./samplescript "input parameters" > "logfile.txt"
>> Appends output to the current contents of hte file. ./samplescript "input parameters" >> "logfile.txt"
2> Sends errors to the specified file. Overwritting its current contents. ./samplescript "input parameters" 2> "errorfile.txt"
2>> Appends errors to contents of the specified file. ./samplescript "input parameters" 2>> "errorfile.txt"
2>&1 Sends error messages to the success output stream ./samplescript "input parameters" 2>&1 "logfile.txt"


Reference: http://technet.microsoft.com/en-us/library/dd315283.aspx

*joychua97

Wednesday, February 15, 2012

TF.exe commands

Looking for tf.exe commands to include in my PowerShell script, and the reference in http://msdn.microsoft.com/en-US/library/1yft8zkw(v=vs.80).aspx is quite helpful.

I'll update this post with the exact commands later on :)

*joychua97

Redirecting PowerShell script output to a file

I just wanted to redirect my PowerShell script output to a file, and at the same time see what's being written to the file.

This command does the trick:
 D:\Scripts\Sample.ps1 2>&1 |Tee-Object -File D:\Logs\myScriptLog.log

Reference:
http://stackoverflow.com/questions/3822650/how-can-i-output-handbrake-output-to-both-the-screen-and-to-a-file

*joychua97

Restoring default icon for .dll files

I opened some .dll and .pdb files in Notepad, and now their icons was changed, and the recommended program is now Notepad. Not something that I want :)

To fix this, I did these steps. I think the combination of these steps worked

1) Opened regedit and browsed to HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\filetype\OpenWithList
     > Removed all values under the OpenWithList key. Retained only the (Default) value
     > Removed the UserChoice key

2) Lastly, opened up command prompt as an Administrator, and ran "assoc .dll=dllfile"

References: http://technet.microsoft.com/en-us/magazine/ee851670.aspx http://answers.microsoft.com/en-us/windows/forum/windows_vista-files/restore-default-file-icon-of-file-types-dll-and/6917a74b-2f99-44ed-86a3-7bd52d240b7e


*joychua97

Wednesday, February 8, 2012

PowerShell Cmdlets

Here are some PowerShell cmdlets that others might find helpful (as they are very much helpful to me). For more details, you may refer to http://technet.microsoft.com/en-us/library/ee156818.aspx.

Cmdlet
Usage
Example
Get-ChildItem Returns items in the specified folder Get-ChildItem $folder -include *.cs -force -recurse
Copy-Item (cpi) Copy files or folders Copy-Item $folder/$file -force -recurse
cpi $folder/$file -force -recurse
Remove-Item (ri) Delete files or folders Remove-Item $folder -force -recurse
ri $file -force
New-Item (ni) Create new files or folders New-Item $folder -type directory
ni $file -type file -force
Invoke-Item (ii) Run executable file or open a file. Alternatively prefix the script with an ampersand (&) and make sure to enclose parameters with spaces in double quotes Invoke-Item $script
ii $script
& $script "parameter1" "parameter2"
Get-Location (gl) Returns the current folder $currentDirectory = Get-Location
Set-Location (sl) Change the current folder Set-Location $newFolder
sl $newFolder


*joychua97

Running my very first PowerShell script

Ok, I browsed through the cheat sheet, and I feel that I am now ready to create my very first simple PowerShell script.

Opened up notepad to print a simple "Hello, World!" message.








Saved the file as sample.ps1, run Windows Powershell, changed my folder to where the script is, and ran sample.ps1. What I got were errors:

File C:\scripts\sample.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-
help about_signing" for more details.


And

PS C:\scripts> sample.ps1
The term 'sample.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:11
+ sample.ps1 <<<<
    + CategoryInfo          : ObjectNotFound: (sample.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException



Suggestion [3,General]: The command sample.ps1 was not found, but does exist in the current location. Windows PowerShell
 doesn't load commands from the current location by default. If you trust this command, instead type ".\sample.ps1". See
 "get-help about_Command_Precedence" for more details.
PS C:\scripts>


It turns out that running a PowerShell isn't how we're used to in running applications.  Here's how to successfully run the script:
1) Set the execution policy to RemoteSigned so you can run scripts, as the default is Restricted.
2) As  recommended by the error message above, we need to run the script indicating it's full path, or if you're in the same folder where the script is, prefix the script name with ".\"
3) Now if you want to run the script using the full path, and the path happens to have spaces (like C:\My Scripts\sample.ps1), then you'll run into the second error message above. If this is the case, make sure to enclose the full path with double quotes and prefix it with an ampersand (&).

PS C:\ scripts> & "C:\My Scripts\sample.ps1"


Reference: http://technet.microsoft.com/en-us/library/ee176949.aspx

*joychua97

Learning Windows PowerShell

Now I need to do some Windows scripting, and will have to learn Windows PowerShell. I found a good initial reference which is a cheat sheet that you can download from Developer Zone. You will have to register first (free) before you can download this pdf.



Download: http://refcardz.dzone.com/refcardz/windows-powershell

Reference: http://blogs.msdn.com/b/powershell/archive/2008/05/30/new-free-windows-powershell-quick-reference-card.aspx









*joychua97

Tuesday, February 7, 2012

Microsoft.Silverlight.CSharp.targets was not found

Here is the error that I was mentioning in my previous post.

The imported project "C:\Program Files\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

Resolution:

1) If there are multiple build servers, determine which server is being used. You can do this by queueing a new build with Logging Verbosity set to "Diagnostic". This will also show the values of the MSBuild variables.

MSBuildExtensionsPath32 = C:\Program Files (x86)\MSBuild
MSBuildExtensionsPath64 = C:\Program Files\MSBuild
MSBuildExtensionsPath = C:\Program Files (x86)\MSBuild

COMPUTERNAME = <computer name>



2) Check which variable is defined in the project (example line below) and verify if the file exists. Also check if Silverlight 4 SDK is installed in the build server.

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />


3) If the file doesn't exist, install Silverlight 4 SDK in the build server, and that should solve it. Note that the build server doesn't have Visual Studio, and the Silverlight SDK installed without problems.

*joychua97

Fixing "The Silverlight 4 SDK is not installed" error

I need to troubleshoot a build error (will have a different post once I resolve that one), so I created a sample Silverlight application. It built and ran successfully in my machine, although I got the following error when I ran a build. Note that the build server already has Silverlight 4 SDK installed.

C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.Common.targets (104): The Silverlight 4 SDK is not installed.

Looking around, they said that "Silverlight projects cannot be built by 64-bit MSBuild."

To resolve this:
1) Edit your Build Definition, and go to the Process tab
2) Expand the "3. Advanced" section and set the "MSBuild Platform" value to "x86"
3) Save the Build Definition.


Changing the MSBuild Platform to x86




















Reference: http://social.msdn.microsoft.com/Forums/en/msbuild/thread/20a742a1-b99c-4638-8590-9a9d6a95fb69


Now I can move on to the original build error that I need to work on :)

*joychua97