Sunday, December 5, 2010

Issue to run command PSExec (PSTools command) over 64Bit OS

    When you execute the PSTools command PsExec over 64-Bit os
it always gives invalid path error  and not able to execute
PsExec command over 64bit os. This may happen because PsExec is copying command over it's systemdirectory and run that exe from there but in 64Bit os it directly copies content to 64-bit compatible system directory so 32bit appliaction not able to copy there so it gives path not found error.

    So for that you have to create the .cmd file and write the code as below and you have to execute command file over there and it will do rest of the things for you.

so this can work for both 64-Bit and 32-Bit also.




@echo off

if exist %WinDir%\SysWow64 cd /d %WinDir%\SysWow64

copy file://SourceHostName/SharedFolderFromSourceHost/ExenameWantToExecute

ExenameWantToExecute  ExeArguements




    Copy above code to text file and save it as .cmd file and now you can use it with the
pstools command.

Hope this will be helpful to resolve issue with 64-Bit OS.

Saturday, December 4, 2010

Cross Thread Exception







    In multi threaded application when you start you application and create one thread to preform some action in background and when you set some controls property over that thread you may be getting "Cross-Thread exception". In this case you can not set property of the control from the thread other then where it initialized.so you can set the property with the use of reflection as below.






private sub SetControlPrpertyValue(byval oControl as control, byval propcName as string,byval propValue as string) 

 If oControl.InvokeRequired Then 

oControl.Invoke(d,
Dim d As New SetControlValueCallback(AddressOf SetControlPrpertyValue)New Object() {oControl, propName, propValue}) 

Else
Dim t As Type = oControl.[GetType]() 
Dim props As PropertyInfo() = t.GetProperties()

 For Each p As PropertyInfo In props 
    If p.Name.ToUpper() = propName.ToUpper()  Then 
         p.SetValue(oControl, propValue, Nothing)
       
    End If
 Next
end
End if
End Sub

Telerik RadAjaxManager object return null on subsequent request

PageAjaxManager in second request .

It work well with first ajax request but in second request  $find("<%= PageAjaxManager.ClientID %>") return null.

This problem occurs browsers other than IE. In IE all ajax request are fired successfuly

Then set the EnablePageHeadUpdate property of PageAjaxManager as below and it will solve that issue. 


<telerik:RadAjaxManager ID="PageAjaxManager" runat="server" OnAjaxRequest="AjaxManager1_AjaxRequest" EnablePageHeadUpdate="false" EnableAJAX="True" UpdatePanelsRenderMode="Inline" >

Hope it may be helpful to resolve your issue. 

Thursday, November 18, 2010

Windows7 msg command usage

In Windows7 there is no direct command like netsend. 
Here you can use "Msg" command for same purpose. 
you can create a .bat file with following and can  use it diectly. 
@echo off
cls
echo.
set choice=
set /p choice=Enter in the target hostname or IP:
set choice1=
set /p choice1=Enter in the Message:
msg /SERVER:%choice% console %choice1%
pause

But before that you have to make sure on remote pc where you are goin to send this message has enabled the following key: 

HKLM\System\CurrentControlSet\Control\Terminal Server
Dword=AllowRemoteRPC
Value=1

Check comma separated values exist within the column having comma separated data

If you want to select records from table which having match some text in comma sperated list given by user with the values within the column of table having also data in comma seperated manner you can do query over table like below.


Select * from Table1
WHERE          exists(select val from Split([Column1],',') where val in (select val from Split(@CommaSeperatedList,',') ))

Check For 64-bit OS

Check whether current application is running over 64-bit OS or not you can check with following way 
IsWow64Process function  is from the Kernel32 windows library. 
you can call it by 

Dim blnIs64bit  As Boolean 
Dim  blnSuccess As Boolean = IsWow64Process(Process.GetCurrentProcess().Handle, blnIs64bit)

Defination for IsWow64Process is as below : 
<DllImport("kernel32.dll", SetLastError:=True, CallingConvention:=CallingConvention.Winapi)> _
Public Shared Function IsWow64Process(<[In]()> ByVal hProcess As IntPtr, <Out()> ByRef lpSystemInfo As Boolean) As Boolean
End Function