El TecnoBaúl de Kiquenet

Kiquenet boring stories

Archive for 31 agosto 2012

Cómo activar Telnet en Windows 7

Posted by kiquenet en 31 agosto 2012

Windows 7 una de las características que por motivos de seguridad trae por defecto desactivado es el cliente de Telnet.

Para aquellos usuarios que necesitan activar Telnet en Windows 7:

  1. Abrir Panel de Control, Programas Y Características.
  2. Activar o desactivar las características de Windows.
  3. Activar la característica Cliente Telnet.
  4. Por último, aceptamos los cambios.
Anuncios

Posted in Uncategorized | Leave a Comment »

Add Farm Administrator by using STSADM

Posted by kiquenet en 28 agosto 2012

 

one day we lost access to ourSharePoint Central Administration. The reason of this was that someone deleted the BUILTIN\Administrators from the Farm Administrators group.

No problem, just add the BUILTIN\Administrators back to the Farm Administrators Group.

But how do you do this without access to the Central Administration?

Well, after some searching and googling I found a solution. You can use STSADM to add people to groups in a Site Collection and the Central Administration is just another Site Collection.

I know the suspense is killing you so here ‘s the STSADM command:

stsadm -o adduser -url http://server:12345 -userlogin BUILTIN\Administrators -useremail admin@company.com -group “Farm Administrators” -username “Administrators”

Referencias: http://www.sharepointology.com/setup/add-farm-administrator-by-using-stsadm/

 

Lo mejor es tirar de TechNet, es lo más completo http://technet.microsoft.com/es-es/library/cc303422

Desde la Administración Central de SharePoint >  Security> Manage the farm administrators group

New > Add Users

Posted in Scripts, Sharepoint | Leave a Comment »

Modificar programáticamente ProductCode de Setup Project

Posted by kiquenet en 17 agosto 2012

Existen varias alternativas:

Proyecto en VS .NET C#:

VS.NET Deployment Project Updater
http://vdprojectupdater.codeplex.com/

http://www.codeproject.com/Articles/5760/VS-NET-Deployment-Project-Version-Updater

En C# con expresiones regulares:

 

static void Main(string[] args)
{
string setupFileName = @"<Replace the path to vdproj file>";
StreamReader reader = File.OpenText(setupFileName);
string file = string.Empty;

try
{
Regex expression = new Regex(@”(?:\”"ProductCode\”" =
\”"8.){([\d\w-]+)}”);
Regex expression1 = new Regex(@”(?:\”"UpgradeCode\”" =
\”"8.){([\d\w-]+)}”);
file = reader.ReadToEnd();

file = expression.Replace(file, “\”ProductCode\” = \”8:{” +
Guid.NewGuid().ToString().ToUpper() + “}”);
file = expression1.Replace(file, “\”UpgradeCode\” = \”8:{“
+ Guid.NewGuid().ToString().ToUpper() + “}”);
}
finally
{
// Close the file otherwise the compile may not work
reader.Close();
}

TextWriter tw = new StreamWriter(setupFileName);
try
{
tw.Write(file);
}
finally
{
// close the stream
tw.Close();
}
}

Programmatically change the ‘ProductName’, ‘ProductCode’, ‘UpgradeCode’ and ‘ShortCut’ depending on build Configuration.

  1. Select the “Setup Project” in vs2005 and press F4.
  2. Change the “PostBuildEvent” towscript “$(ProjectDir)UpdateMSI.vbs” “$(BuiltOuputPath)” “$(ProjectDir)” $(Configuration).
  3. Place the UpdateMSI.vbs file in “$(ProjectDir)”.
BuiltOuputPath = Wscript.Arguments(0)

ProjectDir = Wscript.Arguments(1)

Configuration = Wscript.Arguments(2)

ProductName = "MyApplication - " &amp; Configuration

ShortcutName = "MYAPP~2|" &amp; ProductName 'Check this with orca.exe

select case Configuration

case "Debug"

UpgradeCode = "{11A3CB76-5DAC-4B9F-A993-401BE1D95A9E}"

ProductCode = "{E1BFC46C-6226-459C-BC4F-8DE17888ED62}"

case "Test"

UpgradeCode = "{B15A5EAA-FA9C-4BB7-AD68-29DAE5C95846}"

ProductCode = "{F183C852-5DBC-498C-89F1-2D6CDFF515B6}"

case "Production"

UpgradeCode = "{E14EC8A9-FA0B-47B8-84EB-4EC7ED278E7E}"

ProductCode = "{016C6EF8-A23F-4822-96B2-E0A1D74641EE}"

case Else

end select

'guid = CreateObject("Scriptlet.TypeLib").Guid

'UpgradeCode = left(guid, len(guid) - 2)

Const msiOpenDatabaseModeTransact = 1

Dim propertyKey, propertyValue

Dim installer, database, view, record

Set installer = CreateObject("WindowsInstaller.Installer")

Set db = Installer.OpenDatabase(BuiltOuputPath, msiOpenDatabaseModeTransact)

Set view = db.OpenView("UPDATE Property SET Value = '" &amp; ProductName &amp; "' WHERE Property = '" &amp; "ProductName" &amp; "'")

view.Execute

Set view = db.OpenView("UPDATE Property SET Value = '" &amp; ProductCode &amp; "' WHERE Property = '" &amp; "ProductCode" &amp; "'")

view.Execute

Set view = db.OpenView("UPDATE Property SET Value = '" &amp; UpgradeCode &amp; "' WHERE Property = '" &amp; "UpgradeCode" &amp; "'")

view.Execute

Set view = db.OpenView("UPDATE Shortcut SET Name = '" &amp; ShortcutName &amp; "' WHERE Description = 'MyApplication Application'")

view.Execute

'Set view = db.OpenView("UPDATE Upgrade SET UpgradeCode = '" &amp; UpgradeCode &amp; "'")

'view.Execute

db.Commit

Set installer = Nothing

Set db = Nothing

Set view = Nothing

Con MSBuild:

How to auto-increment assembly version using a custom MSBuild task

http://weblogs.asp.net/bradleyb/archive/2005/12/02/432150.aspx

También hay herramientas de terceros como Stampver:

http://www.elphin.com/downloads/stampver/

Referencias:

http://stackoverflow.com/questions/306233/how-to-programatically-change-a-projects-product-version

Posted in .NET, SetupProjects | Leave a Comment »

Setup Projects y scripts “uninstall”

Posted by kiquenet en 17 agosto 2012

If the user wants to uninstall the product, he can go to "Add/Remove Programs", or he can just double-click the uninstall.cmd. The contents are:

%windir%\system32\msiexec /x {CC3EB7BF-DD82-48B9-8EC5-1B0B62B6D285}

The GUID there is the ProductCode from the Setup Project in Visual Studio.

ProductCode

How can I dynamically generate a batch file that contains the ProductCode for the, at build time?

"Using Visual Studio 2005/2008, you don’t need to write any code to add a uninstall option for a Setup project (Yes I know some people can write code to do it)

1) In the Setup Project –> File System windows –> Right Click “File System on Target machine” –> add a Special Folder, select System Folder;

2) Into this system folder Add a file. Browse for msiexec.exe from local System32 folder and add it. Override default properties of this file as follows:

Condition:=Not Installed (make sure you put ‘Not Installed’ exactly like that, same case and everything), Permanent:=True, System:=True, Transitive:=True, Vital:=False.

3) Create a new shortcut under the ‘Users Program Menu’, Set Target to the System Folder which you created in the step 1. and point it’s at the msiexec.exe. Rename the shortcut to ‘Uninstall Your Application’. Set the Arguments property to /x{space}[ProductCode].

4) Build the project, ignore warning about the fact that msiexec should be excluded, DONT exclude it or the setup project wont build.

The ‘Not Installed’ condition and Permananet:=True ensure that the msiexec.exe is only placed into the system folder as part of the install IF it doesn’t aready exist, and it is not removed on an uninstall – therefore it;s pretty safe to ignore that warning and just go for it.

 

Otra opciones más enrevesadas:

1.) make your application read command line arguments, the code below is from a WPF project

public partial class App : Application

{

  void Application_Startup(object sender,StartupEventArgs e)

  {

    for(int i = 0;i != e.Args.Length;++i)

    {

      if(e.Args[i].Split(‘=’)[0].ToLower() == "/u")

      {

        string guid = e.Args[i].Split(‘=’)[1];

        string path = Environment.GetFolderPath(Environment.SpecialFolder.System);

        ProcessStartInfo uninstallProcess = new ProcessStartInfo(path+"\\msiexec.exe","/x "+guid);

        Process.Start(uninstallProcess);

        System.Windows.Application.Current.Shutdown();

      }

    }

  }

}


To add the uninstall link in the deployment project you just need to follow the steps below:

  1. Select your deployment project and go to the file system editor.
  2. Using the file system editor you navigate to the desired location of the install file.
  3. From the decired location you create a new shortcut to your primary output and name it Uninstall – or whatever else you would like.
  4. In the properties of the new shortcut you set the arguments property to /u=[ProductCode]

2.) creates an uninstall.cmd. It runs as a custom action during installation.

var fso, ts;
var ForWriting= 2;
fso = new ActiveXObject("Scripting.FileSystemObject");

var parameters = Session.Property("CustomActionData").split("|"); 
var targetDir = parameters[0];
var productCode = parameters[1];

ts = fso.OpenTextFile(targetDir + "uninstall.cmd", ForWriting, true);

ts.WriteLine("@echo off");
ts.WriteLine("goto START");
ts.WriteLine("=======================================================");
ts.WriteBlankLines(1);
ts.WriteLine(" Uninstall.cmd");
ts.WriteBlankLines(1);
ts.WriteLine("=======================================================");
ts.WriteBlankLines(1);
ts.WriteLine(":START");
ts.WriteLine("@REM The uuid is the 'ProductCode' in the Visual Studio setup project");
ts.WriteLine("%windir%\\system32\\msiexec /x " + productCode);
ts.WriteBlankLines(1);
ts.Close();

Una buena referencia para Extending VS Setup Projects:

http://www.codeproject.com/Articles/146626/Extending-Visual-Studio-Setup-Project

Gran referencia que explica en detalle los Setup Projects: PackageCode, ProductCode, UpgradeCode, herramienta Orca, etc.

http://www.simple-talk.com/dotnet/visual-studio/updates-to-setup-projects/


References:

http://stackoverflow.com/questions/1356160/in-a-visual-studio-setup-project-how-do-i-generate-an-uninstall-script

http://www.gogototo.com/how-to-add-a-uninstall-option-in-visual-studio-setup-project-without-writing-code.html

http://endofstream.com/creating-uninstaller-in-a-visual-studio-project/

Posted in .NET, SetupProjects, VisualStudio | Leave a Comment »

Paint.NET Portable using IExpress

Posted by kiquenet en 16 agosto 2012

a useful tool for compressing these files into a self-extracting executable, and it has shipped with Windows for quite some time: iexpress.exe.

Its purpose is to extract files and run a setup application, but nothing precludes it from running another application such asPaint.NET.exe. Run iexpress.exe which starts a simple wizard. The most important steps to remember are to have it executePaint.NET.exe, and to store the files using long names. The latter step will prevent the package from running on Windows 95, but the .NET Framework 2.0 which at least Paint.NET v2.62 requires isn’t supported on Windows 95 anyway.

The result was a 595 KB executable. It quickly extracts the files to a sub-directory under %TMP% and runs Paint.NET.exe. When you close Paint.NET.exe the temporary files are cleaned-up. Sure, better compression rates are likely possible using different tools but this is a good start to compress Paint.NET even more without adding extra steps to start the application.


http://hstewart.members.winisp.net/downloads/paint.net.exe

Reference:
http://blogs.msdn.com/b/heaths/archive/2006/05/11/595674.aspx

Posted in Herramientas | Leave a Comment »