Showing posts with label Techie Tips. Show all posts
Showing posts with label Techie Tips. Show all posts

Friday, June 22, 2012

Running Application/Process using System Account


Recently I ran into a situation which demanded me to run an application using the System Account. Even though it took a while, it was a delight to figure it out, thanks to Matt from SysInternal Forums.

First and foremost, let’s see what all tools we are going to use.

1.       Sc.exe - Manages a windows Service.
2.       Net.exe - Starts a Windows Service.
3.       Cmd.exe - Runs the application.

Let’s start with the Windows Calculator (calc.exe) and attempt to execute it under the System Account.

cmd /c sc create -- binPath= "cmd /c start calc" type= own type= interact & net start -- & sc delete --

So how does it work ? Lets figure it out by breaking it down.

Step 1 : Create Service
sc create -- binPath= "cmd /c start calc" type= own type= interact

Step 2 : Start Service
net start --

Step 3 : Delete Service
sc delete--

There are two variables we are using here,
a.       The Service name : --
b.      Application to Run : calc


Now lets analyze how it works.

1.       Cmd /c - This is the easiest one, allows us to pass in parameters to cmd.
2.       Sc create binPath= - The Next Step for us is to create a service entry for our application.
3.       Net start - The service has been registered, the next obvious step is to run the service. That's where use the net start command.
4.       Sc delete - Finally we delete the service

PS: The "&" is basically a new line delimiter which allows multiple commands to be combined into 1 line.

Hope that helps….



Thursday, May 13, 2010

WSH object and Usage

Following is a list of WSH objects and its typical usage. I found it extremely useful ( courtesy MSDN)



Object

What you can do with this object

WScript Object

· Set and retrieve command line arguments

· Determine the name of the script file

· Determine the host file name (wscript.exe or cscript.exe)

· Determine the host version information

· Create, connect to, and disconnect from COM objects

· Sink events

· Stop a script's execution programmatically

· Output information to the default output device (for example, a dialog box or the command line)

WshArguments Object

Access the entire set of command-line arguments

WshNamed Object

Access the set of named command-line arguments

WshUnnamed Object

Access the set of unnamed command-line arguments

WshNetwork Object

· Connect to and disconnect from network shares and network printers

· Map and unmap network shares

· Access information about the currently logged-on user

WshController Object

Create a remote script process using the Controller method CreateScript()

WshRemote Object

· Remotely administer computer systems on a computer network

· Programmatically manipulate other programs/scripts

WshRemoteError Object

Access the error information available when a remote script (a WshRemote object) terminates as a result of a script error

WshShell Object

· Run a program locally

· Manipulate the contents of the registry

· Create a shortcut

· Access a system folder

· Manipulate environment variables (such as WINDIR, PATH, or PROMPT)

WshShortcut Object

Programmatically create a shortcut

WshSpecialFolders Object

Access any of the Windows Special Folders

WshUrlShortcut Object

Programmatically create a shortcut to an Internet resource

WshEnvironment Object

Access any of the environment variables (such as WINDIR, PATH, or PROMPT)

WshScriptExec Object

Determine status and error information about a script run with Exec()

Access the StdIn, StdOut, and

Wednesday, February 03, 2010

Express IT - A Series of Technical Seminars

Cochin has always been hailed as the IT hub of Kerala for quite a long time. But sadly unlike the Technopark in Trivandrum, the Infopark has failed in conducting in IT related activities on a regular basis Of course there has been few events conducted by the KMUG , but having something on a regular basis was something that was still left desired of.

We, Tech Experts , a forum of like-minded developers and IT Specialists in Infopark are now driving an initiative to have a series of technical activities in the city, focusing primarily in Infopark companies. As a first step we are conducting technical seminars are two distinct topics , one based on Microsoft while other from the Free Software Foundation.



Wednesday, September 23, 2009

PDM Works Vault deletion error

I had uninstalled PDMWorks from my machine. Later, when i attempted to remove the vault from machine, it threw a "Conisio" dialog stating

1. "Could not delete view"
2. "Class not registered"

Fix was right there in registery. I removed following keys and that was it, i was all set .
1. HKEY_LOCAL_MACHINE\SOFTWARE\SolidWorks\Applications
2. HKEY_CURRENT_USER\SOFTWARE\SolidWorks\Applications


Tuesday, September 08, 2009

Google Doodle Solved.

Google’s “Unexplained Phenomenon” doodle which appeared on site on September 5th had caused quite a flutter in the web (though I was surprised why in the first place it was made such big news). The company has finally clarified its stand on the issue, putting in rest innumerous theories which were floated around within a short span of time.

The doodle was in honor of the Zero Wing, the Japanese video game of 1980's, which incidentally was celebrating its 20th anniversary

Sunday, June 07, 2009

Tips for buying Laptop

From the time you decide to buy a laptop to the time you actually get it in hand, there are a thousand thoughts that cross your mind. Over the last few years, a whole new generation of Notebooks has hit the market. The technological advances made by these notebooks are so much that an average user finds it scary even to understand the techno jargon let alone make up his mind. So is there an ultimate formula for choosing the right laptop, definitely not. Question of which is the best laptop that’s suits you is something that only you can answer. Once you figure out what you need from your machine depending on your usage, the choice of laptop would automatically appear before you.

Then what I am doing here writing this article? Obviously I am not trying to provide any sort of guidance, rather these are some of the thoughts I personally have based on my experiences with the new age notebooks.

Most of the buyers I have seen give so much importance on brand. But which brand is better ? If I say Sony, there would be hundreds who would argue for Dell. It is one of those questions which will never have an agreeable answer. Each person would answer it depending on his/her experience.

So I would prefer to keep my answer deceptively simple: Choose a well known brand that you believe in. Probably only point you need to keep in mind choosing a brand is the post sale services. If you are a frequent traveler, it would be always advisable to stick to a global brand to be on the safer side. Of course it goes without saying that you need to keep an eye on your budget when going for higher brands.

With first hurdle of brand crossed, palpable focus should be on the features. I would personally prefer to give priority on features in following order.

1. Intel Vs AMD.
I am not huge fan of AMD Processors and would be any day, recommend the Intel based processors. This is true despite fact the AMD processors being much cheaper and consequently bring down the laptop cost when compared to its Intel rivals. The sole reason for my loyalty to Intel is due to the fact the Intel chips consume less power when compared to AMD leading to more battery life and less overheating issues.

2. RAM, L2 Cache, Bus Speed
Have a good eye on this before you choose your machine especially RAM. The higher this number is, the better it is for you. Similarly L2 Cache and Bus Speed also hold high priority as these parameters would largely affect your performance.

3. Graphic Chipset.
One common mistake that should be avoided is overlooking this important factor. Quite often consumers are happy with the Integrated Shared memory rather than having a dedicated Graphics card and end up having their CPU power eaten when running a movie.

I am not asking everyone to go for a high end graphics card. A average user could well settle for a entry level graphics card while a graphics developer for whom 3D Max and Maya forms bread and butter should definitely opt for a higher end graphics card NVedia or any other competitor.

4. HDD Capacity.
Keep your eyes closed on this one. No matter what the size of HDD is, you will always run short. Remember this rule and don’t even bother about whether to buy a 100Gigs or 200 Gigs laptop.

5. Operating System Support.
Another key feature you need to look at is the support for different operating system. Sometime, your desired OS will not be the default one accompanying the OS, in that case make sure the platform you desire to work is supported by the Laptop. Also ensure that the drivers are readily available.

6. Screen Size.
If you are a traveler, the common sense smaller the screen, the better you are with portability.Personally, I find 15” laptops quite a hindrance when I move around or even to use it while sitting in a comfortable sofa. If you are a developer or a person who uses laptop quite often better stick to 14” widescreens laptops, but in case you are a multimedia designer you could well be comfortable with the 15” or 17” machines.

7. Wireless , Bluetooth Capability.
In this fast moving world, you just can’t afford to too far away from the internet. Whether you are in a Hotel or Airport, you would prefer to be connected to the internet. Support for wireless connectivity becomes more important under such situations.

8. Extra USB , network ports.
Gone are the days you would be happy with 2 USB ports. More ports you have, more equipped you are. This holds true in case of network ports.

9. Data Security.
If you are a person for data security holds primary importance, you should opt for higher end models. This of course would come with higher price tags.

Despite all this, always remember the Golden Rule : Read review on the model before you buy it.

Thursday, May 21, 2009

Installshield Error

Post install shield 11, the IDE would not successfully launch when run by a non-administrator and would display following error.

"InstallShield has not been initialized. InstallShield must be run at least once by a user with Administrator or Power User privileges. "

A bit of registry tweaking could help in finding solution to this problem.

All you need to do is add a key "ProjectTemplatesUpToDate" ( dword ) with value 00000001 in the following location

[HKEY_CURRENT_USER\Software\InstallShield\11.0\Professional\Project Settings]


Now you will be all set.

Friday, May 08, 2009

Clearing "saved" network passwords

Quite often we "save" passwords for frequently used network resources and later end up asking ourself, how the hell are we going to erase it ?

Unlike email or any other services, there isn't any place to remove the cached files and remove the saved password. Or do we think so ? In fact, you can do it.

Execute the following statements and you have the list you want.
"rundll32.exe keymgr.dll, KRShowKeyMgr"

Saturday, April 25, 2009

Software Craftsman Vs Industrial Programmer

Who do you want in your team ? A Software Craftsman or a Industrial Programmer ? This is question that has provoked strong reactions on both sides.

Question 1 would be who is a Software Craftsman and who is a Industrial Programmer. Let us tackle that first.

Software Craftsman is some one who thinks that software development is not just about put some dear code together, but instead strives to believe and make other believe that it is a craft. He takes pride in his code and strives to bring best of each line of code. He is in love with the code, rather than his task on hand.

Industrial Programmer, on other hand, is someone who understand the nuances of his task. His aim is to build a software that the customer would love. They take pride in delivering value to the customer rather the best.

Neither is better than other; the IT industry needs both.

Where would I put my money on, whom who would I love to have in my team : a Craftsman or Industrial Programmer ? A tricky question.

Although I do admit that it is the later who the business units prefer as they keep mouth shut and focus on "getting things done" rather than "doing it the right way", I do have my affinity more to the Software Craftsman.

For me , a Industrial Programmer may be producing "more" business , but a craftsman would produce "valuable" business. This is because the output is a program that is more complete and optimized.

There are many traits that you could find in a Craftsman's work, particularly his irresistible desire to stick to the Kiss Principle. Keep it Simple Stupid, or the KISS principle is very special for a craftsman.
There is a famous line in "The best software designs look simple, but it takes a lot of hard work to design a simple architecture."

The power of simplicity cannot be underestimated at any field, let alone coding. One could actually feel a touch of genius every time you see most baffling problems being solved with most simplest solution. This happens only because they are so strong in their basics and understanding of the language, that it helps them get best out of each line they write.

As they say, A designer knows he has arrived at perfection not when there is no longer anything to add, but when there is no longer anything to take away. The craftsman chips away their code until there is nothing to improve further.

He also understands the benefits of polygot programming and does make it a note to take the best out of each programming language. For instance, even when developing in .Net, he could go for doing bulk of coding in C# but could extract the advantages of functional programming using F#.

Now why would I would prefer a Craftsman ? Because I do believe when someone fell in love with his code, you can be ensured that each he line he writes would invaluable asset.

As the Great Albert Einstein said, "Any fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction "

Friday, March 13, 2009

Disable restart after Win update

The bothersome "Updating your computer is almost complete. You must restart your computer for the updates to take effect. Do you want to restart your computer now?" is one message most Win XP users are irritated with.

Quite often we would be engrossed in some work and this irritating dialogs start prompting you every 10 Mins.

Here is a way to disable this prompt.

Start / Run / gpedit.msc / Local Computer Policy / Computer Configuration / Administrative Templates / Windows Components / Windows Update / Re-prompt for restart with scheduled installations

You can enforce the Group Policies by “gpupdate.exe /force” command without having to restart the system

Tuesday, February 10, 2009

Expression Blend 2.0 and Silverlight 2.0

Expression Studio 2.0 which packages Expression Blend 2.0 would support only Silverlight 1.0 applications. This would happen even if your system is acquitted with Silverlight 2.0. Silverlight 2.0 is packaged along the 2.5 version of Expression Blend.

To develop Silverlight 2.0 application using Expression Blend 2.0 you would need to install "Microsoft Expression Blend™ 2 Service Pack 1". This would give you the option to develop Silverlight 2.0 from the 2.0 version of Expression Studio. Of course, you would need DotNet Framework 3.5 SP1 to go along with it.

Saturday, January 31, 2009

Access Denied for MSC files / Administrative Tools in Windows.

Recently when I tried to start any of the Administrative Tools ( .msc files ) in my system ( Windows XP Home Edition ), I encountered a strange "Access Denied" error even though I was logged in as the administrator.

It seemed strange as Administrator, I should have access to these tools and such a response seemed odd.

The problem was the .msc file types had lost it's association. So once I ensured that msc files are opened using the Microsoft Management Console or mmc.exe, I could resolve the issue in no time.

Thursday, January 29, 2009

Nant And WhiteSpaces.

Whitespace in file paths can lead to a tricky problem while writing Nant Scripts. Quite we end up with "Path not found" errors only because whitespace in the folder/file names .

Work around under such circumstances is very simple, use the 8.3 format for that particular file/folder and your script is all set.

By the way, NantBuilder is quite a handy tool.

Monday, December 01, 2008

CMYK Vs RGB in FrameMaker

I was importing a Image (JPEG) to Adobe FrameMaker when a certain image started throwing weird problems. Each time I import image, the image's color seems changed drastically.

A bit of googling and the solution seemed simple. The image was in CMYK format and i needed to change it to RGB to get it working properly in FrameMaker.

Simple, straightforward..i wonder why Adobe doesn't the same inbuilt inside the FrameMaker. Better they do.

Saturday, September 27, 2008

Missing Address Bar in Explorer for Windows Xp Home

Missing Address bar in your Windows Explorer/Internet Explorer in Windows XP Home Edition ??

Go to the following Registry key:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Toolbar

For Windows Explorer: In the right pane, locate the Explorer sub-key and open it. In the right pane, locate the ITBarLayout value. Right click this value and select Delete.

For Internet Explorer: In the right pane, locate the WebBrowser sub-key and open it. In the right pane, locate the ITBarLayout value. Right click this value and select Delete.

That's it. Restart your application and you have your address bar back.

Saturday, May 31, 2008

Modulo Operation : Microsoft vs Google

Modulo operation is something we all aware of from long time and this , infact brings out an interesting perspective on how Microsoft and Google has implemented it. Try out finding the result for following operation in C# or VB or even Windows Calculator.
"-5 mod 6"

Your result was -5 right ??? Now attempt the same in Google Calculator ?? -1 the result ??

Which is correct ? Its going to be an interesting argument. The Modulo function is definaed as the amount by which a number exceeds the largest integer multiple of the divisor that is not greater than that number.

Now if you go by that defination , - 5 * -1 would yield 5 with a remaining -1. That would explain the answer given by Google. But Microsoft's answer too can be argued.

The normal formula to calculate Mod is given by r = a - n(a/n). Now assuming Microsoft calculates this using r = a - n * abs(a/n) , then answer given by Calculator is correct.

Counter argument exists in both cases and hence it is argueable on sides of both parties about which is the correct solution.

Monday, May 26, 2008

Acer Predator : A Real Beast

Speaking about Ultimate PC's and it couldn't have got better.Just couldn't resist writing about this beast machine , awesome configuration and an equally awesome design. Acer Aspire Predator G7700 come across as ultimate gaming machine that you can dream of.











Acer Aspire G Predator G7700 specifications

Item

Description

CPU Support

Intel Core 2 Extreme or Core 2 Quad up to 133MHz FSB

Chipset

Nvidia nForce 780i SLI

System memory

Up to 8GB DDR2 1066/800MHz

Hard drives

4x SATA HDD up to 1TB
RAID 0, 1, 5, 1+0
Acer Easy-swap

Optical drives

Blu-ray SuperMulti burner
Blu-ray/HD DVD SuperMulti burner (optional)
SuperMulti burner(optional)

Graphics

3-way SLI ready
2x GeForce 9600 GT
2x GeForce 9800 GTX
2x GeForce 9800 GX2

Audio

Onboard HD 7.1 audio
Creative Sound Blaster X-Fi Platinum (optional)

Dimensions

490×430×190mm (L×H×W)

Thursday, May 15, 2008

C# coding Guidelines - An alternate naming scheme

I have always felt hard to agree with the naming schemes for variables under the "C# Coding standards", which on other grounds is a very find document.

According to Microsoft, they strictly oppose the use of Hungarian notations. Furthermore, they advise on using camelCase for naming all local, member and parameter variables. Microsoft advocate that it increases readability by supporting a consistent naming scheme throughout.

This is something I dont agree with. My argument is simple. How would one recognize between local, member and a parameter variable ?? i believe, it would have been helped readability furthur if we had naming scheme such that all 3 types of variables can be differentiated.

So what i recommend is
Local Variables : camelCase
Member Variable : "m_" or "g_" prefixed to the name
Parameter Variable : PascalCase

These are my personal views and i did find the readability much improved in this way.

Monday, March 03, 2008

Locking USB Storage in your System

I wanted prevent users from connecting a USB Storage device to my system. It wasnt as cubersome as i initially thought it would be. Microsoft had provided this wonderful KB article (823732) which give a very good explanation of the same.

There are two scenario's that needed to be thought of.
1. If USB Storage Device is not installed in your System.
2. If USB Storage device is already installed in your system.

Under the first circumstances, we can disable the access by making usbstor.inf and usbstor.pnf files under the SystemRoot directory secure from the users.

On other hand under the second circumstances , we can change the value of UsbStor in the registry to accomplish our goals.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor

Changing the value of "Start" to "4" would prevent the USB Drive from getting detected.

Thats it, you have locked up USB storage devices from being connected to your system

Friday, February 22, 2008

Setting NULL DACL for NamedPipe

When using NamedPipe, security access is major concern. By default, the created NamedPipe can be accessed only by the administrator accounts. But what if you application requires it be to accessed by a client application run in a "Limited User" account ??

This is where you need to set the security attributes. The security attributes can be set using the last parameter of CreateNamedPipe API call.

Easiest ( yet not-recommended) way of giving access to Limited User Account is setting the security Attribute using a Null DACL. ( Discretionary Access Control List ).

[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr CreateNamedPipe(
String pipeName,
uint dwOpenMode,
uint dwPipeMode,
uint nMaxInstances,
uint nOutBufferSize,
uint nInBufferSize,
uint nDefaultTimeOut,
IntPtr lpSecurityAttributes);

Point To Note : Remember, setting a NULL value to lpSecurityAttributes and setting a NULL Dacl for it is two entirely different thing. If you set a Null Value for lpSecurityAttributes , it would be mean that the pipe would be having default security privileges set by the operating system.
But when you set the value as NULL Dacl, you are saying to the operating system that the pipe can be accessed by all users in the system, ie , giving Full-Control to "Everyone" user group.

So how do you set the Null Dacl for
lpSecurityAttributes ? here is a bit of code for the same


SECURITY_DESCRIPTOR sd = new SECURITY_DESCRIPTOR();
InitializeSecurityDescriptor(ref sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(ref sd, true,IntPtr.Zero , false);
SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES();
sa.nLength = Marshal.SizeOf(typeof(SECURITY_ATTRIBUTES));

IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(sd));
Marshal.StructureToPtr(sd, ptr,true);
sa.lpSecurityDescriptor = ptr;

IntPtr retPtr = Marshal.AllocHGlobal(Marshal.SizeOf(sa));
Marshal.StructureToPtr(sa,retPtr,true);

PipeHandle = CommonFunctions.CreateNamedPipe(
PIPE_NAME,
PIPE_ACCESS_DUPLEX ,
PIPE_TYPE_MESSAGE |
PIPE_READMODE_MESSAGE |
PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES,
(uint)BUFFER_SIZE,
(uint)BUFFER_SIZE,
0,
retPtr);