Jump to content

Paul

Administrators
  • Posts

    1740
  • Joined

  • Last visited

Everything posted by Paul

  1. You can do a RDP connection using PC Monitor Dashboard using the context menu. Don't get it wrong. Plugins and cloud instances are very useful when used properly. In your case you want a client side plugin which is not supported (well at least at the moment).
  2. Here is the code that gets your public IP address of the current computer: public string GetPublicIPAddress() { var request = (HttpWebRequest) WebRequest.Create("http://checkip.dyndns.org"); request.Method = "GET"; WebResponse response = null; StreamReader reader = null; try { response = request.GetResponse(); // ReSharper disable AssignNullToNotNullAttribute reader = new StreamReader(response.GetResponseStream()); // ReSharper restore AssignNullToNotNullAttribute var result = reader.ReadToEnd(); result = result.Remove(0, result.IndexOf("Address:", StringComparison.Ordinal) + 9); return result.Remove(result.IndexOf("</body>", StringComparison.Ordinal)); } catch { return "127.0.0.1"; } finally { if (reader != null) { reader.Close(); reader.Dispose(); } if (response != null) response.Close(); request.Abort(); } } Note: You may need some using statements (try pressing CTRL + . (dot) ) on the red types, or right click -> resolve -> select namespace. This code gets the IP address using a free online service that returns your IP address (http://checkip.dyndns.org). It does not return the IP address of other monitored computers . It will always be the IP address of the machine the code executes from. Good Luck, Paul.
  3. Good morning Kurt, On my last reply I've told you that code will never execute on the client side ( your laptop ) but on the system that hosts your plugin. I will post the code that will get your external IP address when I get to work.
  4. External IP is not exposed by the pc monitor api. Btw your code to execute a process was fine but microsoft decided to make a developer's life a pain while working under a windows service. If you can wait 9 hours until I wake up and I am at work I will post a method that returns your public IP address.
  5. While reading your replies made me realize you want a plugin on a computer change the bahavior and execute a process on the client computer / device. This is not supported and it is very dangerous if it would be. What if I share with you a computer that has a script that can download and execute a rootkit on your computer just by clicking on my plugin? Mobile PC Monitor doesn't do any code injection on client devices / computers. Plugins can only execute on the machines they are installed.
  6. Oops: I forgot to update the namespace on the class. Change the namespace on the new class to match yours: Plugin1 -> RemoteSupport Paul.
  7. 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.
  8. Hey Kurt, I will update your code with a working version. I will post back when I finished. Give me an hour. Thanks..
  9. 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.
  10. 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
  11. 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.
  12. It could be possible on a future version.
  13. 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.
  14. 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
  15. 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.
  16. 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.
  17. Hello, I plan on updating most of my published plugins soon. The version itself was all I needed to understand the problem. Thanks.
  18. 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.
  19. 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.
  20. 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.
  21. 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.
  22. Since your public ip has changed, the computer must be at least once online for the server to know the new ip address.
  23. System.Management.Automation Is missing. Can you please confirm you have PS 3.0 installed? Also what OS you have? Paul.
  24. 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.
  25. That's because of UAC still being active, if you are under windows 8 make sure you disable UAC from registry.
×
×
  • Create New...