Everything posted by Paul
-
Create plugin in Visual Studio (vb)
Hello Kurt, Add this class to your project: using System; using System.Runtime.InteropServices; namespace Plugin1 { public static class Win32 { [StructLayout(LayoutKind.Sequential)] private struct Security_Attributes { public Int32 Length; public IntPtr lpSecurityDescriptor; public Boolean bInheritHandle; } private enum Token_Type { TOKEN_PRIMARY = 1, TOKEN_IMPERSONATION = 2 } [StructLayout(LayoutKind.Sequential)] private struct Startupinfo { public Int32 cb; public String lpReserved; public String lpDesktop; public String lpTitle; public UInt32 dwX; public UInt32 dwY; public UInt32 dwXSize; public UInt32 dwYSize; public UInt32 dwXCountChars; public UInt32 dwYCountChars; public UInt32 dwFillAttribute; public UInt32 dwFlags; public short wShowWindow; public short cbReserved2; public IntPtr lpReserved2; public IntPtr hStdInput; public IntPtr hStdOutput; public IntPtr hStdError; } [StructLayout(LayoutKind.Sequential)] private struct Process_Information { public readonly IntPtr hProcess; public readonly IntPtr hThread; public readonly UInt32 dwProcessId; public readonly UInt32 dwThreadId; } private enum Security_Impersonation_Level { SECURITY_ANONYMOUS = 0, SECURITY_IDENTIFICATION = 1, SECURITY_IMPERSONATION = 2, SECURITY_DELEGATION = 3, } private const UInt32 MAXIMUM_ALLOWED = 0x2000000; private const Int32 CREATE_UNICODE_ENVIRONMENT = 0x00000400; private const Int32 NORMAL_PRIORITY_CLASS = 0x20; private const Int32 CREATE_NEW_CONSOLE = 0x00000010; [DllImport("kernel32.dll", SetLastError = true)] private static extern Boolean CloseHandle(IntPtr hSnapshot); [DllImport("kernel32.dll")] public static extern UInt32 WTSGetActiveConsoleSessionId(); [DllImport("Wtsapi32.dll")] private static extern UInt32 WTSQueryUserToken(UInt32 sessionId, ref IntPtr phToken); [DllImport("advapi32.dll", EntryPoint = "CreateProcessAsUser", SetLastError = true, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] private static extern Boolean CreateProcessAsUser( IntPtr hToken, String lpApplicationName, String lpCommandLine, ref Security_Attributes lpProcessAttributes, ref Security_Attributes lpThreadAttributes, Boolean bInheritHandle, Int32 dwCreationFlags, IntPtr lpEnvironment, String lpCurrentDirectory, ref Startupinfo lpStartupInfo, out Process_Information lpProcessInformation); [DllImport("advapi32.dll", EntryPoint = "DuplicateTokenEx")] private static extern Boolean DuplicateTokenEx( IntPtr existingTokenHandle, UInt32 dwDesiredAccess, ref Security_Attributes lpThreadAttributes, Int32 tokenType, Int32 impersonationLevel, ref IntPtr duplicateTokenHandle); [DllImport("userenv.dll", SetLastError = true)] private static extern Boolean CreateEnvironmentBlock( ref IntPtr lpEnvironment, IntPtr hToken, Boolean bInherit); [DllImport("userenv.dll", SetLastError = true)] private static extern Boolean DestroyEnvironmentBlock(IntPtr lpEnvironment); /// <summary> /// Creates the process in the interactive desktop with credentials of the logged in user. /// </summary> public static void CreateProcessAsUser(String commandLine, String workingDirectory = null) { var dwSessionId = WTSGetActiveConsoleSessionId(); var hUserToken = IntPtr.Zero; WTSQueryUserToken(dwSessionId, ref hUserToken); var sa = new Security_Attributes(); sa.Length = Marshal.SizeOf(sa); var hUserTokenDup = IntPtr.Zero; DuplicateTokenEx( hUserToken, (Int32) MAXIMUM_ALLOWED, ref sa, (Int32) Security_Impersonation_Level.SECURITY_IDENTIFICATION, (Int32) Token_Type.TOKEN_PRIMARY, ref hUserTokenDup); if (hUserTokenDup != IntPtr.Zero) { var dwCreationFlags = NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE; var pEnv = IntPtr.Zero; if (CreateEnvironmentBlock(ref pEnv, hUserTokenDup, true)) dwCreationFlags |= CREATE_UNICODE_ENVIRONMENT; else pEnv = IntPtr.Zero; // Launch the process in the client's logon session. Process_Information pi; var si = new Startupinfo(); si.cb = Marshal.SizeOf(si); si.lpDesktop = "winsta0\\default"; CreateProcessAsUser(hUserTokenDup, // client's access token null, // file to execute commandLine, // command line ref sa, // pointer to process SECURITY_ATTRIBUTES ref sa, // pointer to thread SECURITY_ATTRIBUTES false, // handles are not inheritable dwCreationFlags, // creation flags pEnv, // pointer to new environment block workingDirectory, // name of current directory ref si, // pointer to STARTUPINFO structure out pi // receives information about new process ); DestroyEnvironmentBlock(pEnv); } CloseHandle(hUserTokenDup); CloseHandle(hUserToken); } } } Then in your application delete the page command received with command received (Only use page command received for commands received from a PageItem). Use this code: public override void CommandReceived(int commandId) { if (commandId == 1) Win32.CreateProcessAsUser(@"C:\Windows\System32\mstsc /v:10.0.8.5", @"C:\Windows\System32"); } I didn't test this code on a machine with multiple sessions. I have no idea how it will manifest then. Let me know if you need further help. Paul.
-
Create plugin in Visual Studio (vb)
Hey Kurt, I will update your code with a working version. I will post back when I finished. Give me an hour. Thanks..
-
Create plugin in Visual Studio (vb)
Hello Kurt, Your code is correct however you missed two things: You should use shell execute on your processes to 'unbind' them from the parent process. Starting from windows vista a windows service cannot touch a user session unless some hardcore impersonation API calls. Basically you need to ask yourself the following questions: On which user sessions your service is supposed to run the application? What if no user is logged in? Consult these posts: http://stackoverflow.com/questions/668389/calling-createprocessasuser-from-c-sharp http://msdn.microsoft.com/en-us/library/ms682429.aspx http://blogs.msdn.com/b/alejacma/archive/2007/12/20/how-to-call-createprocesswithlogonw-createprocessasuser-in-net.aspx?Redirected=true https://blogs.msdn.com/b/thottams/archive/2006/08/11/696013.aspx?Redirected=true Let me know if you get stuck again. Good luck mate. Paul.
-
Create plugin in Visual Studio (vb)
C# public override void PageCommandReceived(int pageId, int commandId) { // your code here } VB.NET: Public Overrides Sub PageCommandReceived(ByVal pageId As Integer, ByVal commandId As Integer) // your code here End Sub
-
Create plugin in Visual Studio (vb)
Well you need to override the command received / page command received method. Consult API documentation (http://pulseway.com/api) and take a look at my other plugins as they are all opensource.
-
Create plugin in Visual Studio (vb)
It could be possible on a future version.
-
FTP from terminal or plugin?
Yes if you have a predefined bat file with something like this: ftp -i -s:"%~f0" open 192.168.1.55 FTP USERNAME FTP PASSWORD !:--- FTP commands below here --- lcd . cd data/ ascii mput "Data\h\*.txt" disconnect bye Then you just invoke the bat file.
-
Create plugin in Visual Studio (vb)
Due to request I have updated the plugin to support paged view. Both projects (VB and CS) support paged view configuration. Paul. Edit: I have fixed a mistake in the plugin. I was requiring an invalid pc monitor version. Download the new release. PaulCsiki.SystemInfoPlugin.zip
-
Create plugin in Visual Studio (vb)
Hello kurtdejaeger, Welcome to the world of programming. I understand you are a beginner so I have converted your vb script into a valid PC Monitor plugin in two (visual studio compatible) programming languages so that you can see the differences between them and maybe learn a bit from them. I hope that you will continue researching programming after you finish your first plugin. Also if you ever need help on creating a plugin please ask here and I will do my best to help you. You will find a Release folder that contains both of the plugin versions in binary format. Both of them do the same thing. Also check out API documentation that will help you get started on writing plugins. Click here. Good Luck, Paul.
-
Selective notification receipt
You can view computer specific notifications by going to the notifications page from Computer Details page. At this moment I don't think there is any way to subscribe to specific notifications only.
-
Session Control Plugin 1.3
Hello, I plan on updating most of my published plugins soon. The version itself was all I needed to understand the problem. Thanks.
-
Problem logging onto My computers web page
Also you can install PC Monitor on your desktop and use it to manage your account and computers without using up any of your computer licenses. Just install it, go to services.msc and set it's startup type to disabled.
-
Whats the best way to measure the temperature of the server room?
Well you could buy a mainboard that has a sensor on it ( system temperature ), keep it on a piece of plastic with no chassis then monitor it's system sensor with PC Monitor.
-
Request: GPU Monitoring
Hello, The tricky part with GPU monitoring is that a Windows Service cannot query the status of a GPU Adapter as far as I know. I believe this is one of the main reasons why PC Monitor doesn't currently offer support for GPU monitoring. How many render farms you got? Maybe I can find you a workaround.
-
Whats the best way to measure the temperature of the server room?
Hello, We currently use a netduino ( an arduino based io board ) which allows you to use .NET code to write logic and a cheap temperature sensors. Estimated costs < 50 USD + some time on the code ( I can help you with the code if you need ). Or you can use a product that does all that with a web interface ~140 USD. Link: http://www.controlbyweb.com/temperature . Or you can contact a home automation specialist which can setup an enterprise temperature monitoring system which can alert you via sms or email ( the ones with email cost more ). The price for these vary on the size of the project however for a small server room it can't cost more than 300 USD. Paul.
-
Wake up command not working
Since your public ip has changed, the computer must be at least once online for the server to know the new ip address.
-
PowerOfTheShell Plugin 1.5
System.Management.Automation Is missing. Can you please confirm you have PS 3.0 installed? Also what OS you have? Paul.
-
Can't start service
By any chance you changed your username and password of the account you made the PC Monitor Service impersonate? Because it's the only possible way. Just make the PC Monitor Service run as SYSTEM as default and make sure SYSTEM has access to the PC Monitor installation directory. Source.
-
Cant Install pc monitor
That's because of UAC still being active, if you are under windows 8 make sure you disable UAC from registry.
-
Cant Install pc monitor
Have you right clicked on command prompt and clicked on "Run as administrator" before typing the command?
-
Memory Usage for PCMonitorSrv
VMware server modules has high memory usage as far as I remember from testing.
-
Hardware monitoring on a Dell PowerEdge 2850
Hello Joe, PC Monitor doesn't support all hardware devices and it's constantly adding new ones. If there is nothing showed then it means that there is no supported hardware on that machine. This is normal behavior. Maybe issue a feature request asking for a label to be displayed that no supported hardware was found on the machine. I am not aware of any possible workaround this problem, however if you said it's an old server maybe it's time to upgrade . Paul.
-
Memory Usage for PCMonitorSrv
I am usually around 14mb on a production server and it gets to 40+-50 sometimes. Do you have any plugins, server modules, event log notifications, rules?
-
Starting programs from terminal
You should create a thread about this in Feature Requests.
-
Subscription for 1 server
Hello, The minimum subscription is for five computers because the free amount for non-comercial usage is five. You can't have only one licensed computer and four with non-comercial license, it doesn't make any sense. If you feel you need to contact a representative send an email to sales (at) mobilepcmonitor (dot) com .