10 Replies - 3400 Views - Last Post: 18 September 2007 - 06:26 PM Rate Topic: -----

#1 salohcin   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 06-September 07

mini project advice and suggestion needed on how to start it

Post icon  Posted 10 September 2007 - 06:42 PM

I have a project on my hand which is needed to be written in vb.net, which is to create a vb.net installer to install client and host.The host will have the ability to shutdown all host computer in the network ,lock the computers in screensaver mode and also prevent user from typing during locked screensaver mode.moreover in the host installer the script will check for input from keyboard and mouse if there not input for more than 2hrs it will auto shutdown.Client installer will load on startup but however host will be able to start the program when he deem it needed. I hoping someone will point me in the right way with references and webs with tutorial on achieving this as most web has tutorials but not to the point where i needed it. I would also like if guidelines how how am i to start this project.references to books will be greatly welcomed.Thx in advance and for your time in reading this

Is This A Good Question/Topic? 0
  • +

Replies To: mini project advice and suggestion needed on how to start it

#2 m2s87   User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: mini project advice and suggestion needed on how to start it

Posted 11 September 2007 - 08:50 AM

I think Einstein quoted something like "Do simplify to the limit that could be done, but not more".

Client should do:
* shut down computer when needed
* block keyboard input when needed
* start with computer boot up (!?)
* reset (2 hour timer) delay on any motion / key press
* connect to any/some data source set by master and act based on it

Master should do:
* enumerate clients [*]
* set properties of any/some data source

Extra stuff to think about:
* encryptions/password
* how the data source is accessed (internet/local network [*])

[*]= it could be quite a task, in case of weird local area networking

You could probably think of more elements, but it should get you started. And you hardly need books, if you have Google. :D
Was This Post Helpful? 0
  • +
  • -

#3 salohcin   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 06-September 07

Re: mini project advice and suggestion needed on how to start it

Posted 11 September 2007 - 06:48 PM

I was thinking of using database to store all network IPs when pinged,then issues them to shutdown using vb to issue command prompt shutdown command but however i am unable to find materials for command to stop keyboard inputs, for the 2 hrs of no mouse/keyboard i was thinking of using if else loop to check for any input then timer will restart on detecting of input but i don't know the code for checking of input.Local network will most likely be a lan network.I have no idea on how i going to program my master at all.I have thought of using a login to check if it the master or it the clients logging in thus all have the same program but the password will determine if the user is master or client.
Was This Post Helpful? 0
  • +
  • -

#4 salohcin   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 06-September 07

Re: mini project advice and suggestion needed on how to start it

Posted 12 September 2007 - 01:02 AM

i know what i need to do but the problem is i don't know how to even start doing since all this is possible but how to implent them is the problem though i understand i would like to know where can all the information in regard to the code that i need to write cause writing is justing writing but it the understanding that i also need to know as there are hardly any articles online on the matters i am suppose
Was This Post Helpful? 0
  • +
  • -

#5 salohcin   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 06-September 07

Re: mini project advice and suggestion needed on how to start it

Posted 12 September 2007 - 01:14 AM

oh btw i am using visual basic 2005
Was This Post Helpful? 0
  • +
  • -

#6 m2s87   User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: mini project advice and suggestion needed on how to start it

Posted 12 September 2007 - 07:51 AM

Well, if you do not know how, make a way (that works of course). The easiest way would be to use code blocks already optimized for any use, also know as MS windows API. If your unfamiliar with this (try start learning - reading a lot), if you still have problems try using http://www.pinvoke.net/,

If you need to create methods, to do something like "detect what are the key states(also mouse keys) and when are thy changed", you can build them from smaller pieces, like timer+some Input state API. Sometimes you could find whole pieces you need, like shut down (system32/ExitWindowsEx). Communicating with database, that exist somewhere on the network, should even have native support in the VB:net 8+ (or 2005 and newer) and you do not need to use API to do that.

So create a database, where you store the information. Create a connection to it. Add few functions that does use OS API to do stuff and connect to database to change values when needed and thats it.
Was This Post Helpful? 0
  • +
  • -

#7 salohcin   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 06-September 07

Re: mini project advice and suggestion needed on how to start it

Posted 12 September 2007 - 11:14 PM

cur_x = System.Windows.Forms.Cursor.Position.X * 65535 / System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
cur_y = System.Windows.Forms.Cursor.Position.Y * 65535 / System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
While (movement = False Or keyboard = False)
cur_x_now = System.Windows.Forms.Cursor.Position.X * 65535 / System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
cur_y_now = System.Windows.Forms.Cursor.Position.Y * 65535 / System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height

If (cur_x_now <> cur_x) Then
movement = True
ElseIf (cur_y_now <> cur_y) Then
movement = True

End If

End While

i manage to do my mouse movement in the code above but however i can't create the same type for my keydown event mind if you can help me?
Was This Post Helpful? 0
  • +
  • -

#8 salohcin   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 06-September 07

Re: mini project advice and suggestion needed on how to start it

Posted 16 September 2007 - 05:45 PM

sorry if i bump a old post but can i get some help regarding keyboard if each key press it will reset the timer?
i am am to do the mouse with timer but i have problems with the keyboard
Was This Post Helpful? 0
  • +
  • -

#9 salohcin   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 06-September 07

Re: mini project advice and suggestion needed on how to start it

Posted 16 September 2007 - 11:59 PM

Big problem with code everything i send the blockinput code the program will hang and all inputs will be blocked thus unable to fix it btw how to change the code to accept further inputs only if blockinput was send in the first place? Need guidance



Imports System.net
Imports System.IO
Imports System.Net.Sockets
Imports System.Threading
Imports System.Windows.Forms
Public Class Form1
	Inherits System.Windows.Forms.Form
	Declare Function BlockInput Lib "User32" (ByVal fBlockIt As Boolean) As Boolean

#Region " Windows Form Designer generated code "

	Public Sub New()
		MyBase.New()

		'This call is required by the Windows Form Designer.
		InitializeComponent()

		'Add any initialization after the InitializeComponent() call

	End Sub

	'Form overrides dispose to clean up the component list.
	Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
		If disposing Then
			If Not (components Is Nothing) Then
				components.Dispose()
			End If
		End If
		MyBase.Dispose(disposing)
	End Sub

	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer

	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.  
	'Do not modify it using the code editor.
	Friend WithEvents Label1 As System.Windows.Forms.Label
	Friend WithEvents btnClose As System.Windows.Forms.Button
	Friend WithEvents btnHide As System.Windows.Forms.Button
	Friend WithEvents NotifyIcon1 As System.Windows.Forms.NotifyIcon
	Friend WithEvents Label4 As System.Windows.Forms.Label
	Friend WithEvents lblMYIP As System.Windows.Forms.Label
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Me.components = New System.ComponentModel.Container
		Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
		Me.Label1 = New System.Windows.Forms.Label
		Me.btnClose = New System.Windows.Forms.Button
		Me.btnHide = New System.Windows.Forms.Button
		Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon(Me.components)
		Me.lblMYIP = New System.Windows.Forms.Label
		Me.Label4 = New System.Windows.Forms.Label
		Me.SuspendLayout()
		'
		'Label1
		'
		Me.Label1.Location = New System.Drawing.Point(48, 0)
		Me.Label1.Name = "Label1"
		Me.Label1.Size = New System.Drawing.Size(288, 32)
		Me.Label1.TabIndex = 73
		Me.Label1.Text = "This application must be run on clients. You can then perform shutdown, reboot &&" & _
			" logoff operation on clients."
		'
		'btnClose
		'
		Me.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.System
		Me.btnClose.Location = New System.Drawing.Point(208, 152)
		Me.btnClose.Name = "btnClose"
		Me.btnClose.Size = New System.Drawing.Size(75, 23)
		Me.btnClose.TabIndex = 74
		Me.btnClose.Text = "&Close"
		'
		'btnHide
		'
		Me.btnHide.FlatStyle = System.Windows.Forms.FlatStyle.System
		Me.btnHide.Location = New System.Drawing.Point(120, 152)
		Me.btnHide.Name = "btnHide"
		Me.btnHide.Size = New System.Drawing.Size(75, 23)
		Me.btnHide.TabIndex = 75
		Me.btnHide.Text = "&Hide"
		'
		'NotifyIcon1
		'
		Me.NotifyIcon1.Text = "Remote Shutdown"
		Me.NotifyIcon1.Visible = True
		'
		'lblMYIP
		'
		Me.lblMYIP.Location = New System.Drawing.Point(144, 40)
		Me.lblMYIP.Name = "lblMYIP"
		Me.lblMYIP.Size = New System.Drawing.Size(136, 23)
		Me.lblMYIP.TabIndex = 77
		'
		'Label4
		'
		Me.Label4.Location = New System.Drawing.Point(56, 40)
		Me.Label4.Name = "Label4"
		Me.Label4.Size = New System.Drawing.Size(88, 23)
		Me.Label4.TabIndex = 76
		Me.Label4.Text = "My IP Address:"
		'
		'Form1
		'
		Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
		Me.ClientSize = New System.Drawing.Size(386, 184)
		Me.ControlBox = False
		Me.Controls.Add(Me.lblMYIP)
		Me.Controls.Add(Me.Label4)
		Me.Controls.Add(Me.btnHide)
		Me.Controls.Add(Me.btnClose)
		Me.Controls.Add(Me.Label1)
		Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
		Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
		Me.MaximizeBox = False
		Me.Name = "Form1"
		Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
		Me.Text = "Remote Client [Remote Shutdown, Logoff, Reboot Example]"
		Me.ResumeLayout(False)

	End Sub

#End Region
	Dim trlisten As Thread
	Dim trShutdown As Thread
	Dim trReboot As Thread
	Dim trLogOff As Thread
	Dim trBInput As Thread
	Dim trUnBInput As Thread

	Sub shutdown()
		Dim t As Single
		Dim objWMIService, objComputer As Object
		'Now get some privileges
		objWMIService = GetObject("Winmgmts:{impersonationLevel=impersonate,(Debug,Shutdown)}")
		For Each objComputer In objWMIService.InstancesOf("Win32_OperatingSystem")

			t = objComputer.Win32Shutdown(8 + 4, 0)

			If t <> 0 Then
				'Error occurred!!!
			Else
				'Shutdown your system
			End If
		Next
	End Sub
	Sub reboot()
		Dim t As Single
		Dim objWMIService, objComputer As Object
		'Now get some privileges
		objWMIService = GetObject("Winmgmts:{impersonationLevel=impersonate,(Debug,Shutdown)}")
		For Each objComputer In objWMIService.InstancesOf("Win32_OperatingSystem")

			t = objComputer.Win32Shutdown(2 + 4, 0)

			If t <> 0 Then
				'Error occurred!!!
			Else
				'Reboot your system
			End If
		Next
	End Sub
	Sub logoff()
		Dim t As Single
		Dim objWMIService, objComputer As Object
		'Now get some privileges
		objWMIService = GetObject("Winmgmts:{impersonationLevel=impersonate,(Debug,Shutdown)}")
		For Each objComputer In objWMIService.InstancesOf("Win32_OperatingSystem")

			t = objComputer.Win32Shutdown(0, 0)

			If t <> 0 Then
				'Error occurred!!!
			Else
				'LogOff your system
			End If
		Next
	End Sub
	Sub binput()

		Dim t As Single
		Dim objWMIService, objComputer As Object
		'Now get some privileges
		objWMIService = GetObject("Winmgmts:{impersonationLevel=impersonate,(Debug,Shutdown)}")
		For Each objComputer In objWMIService.InstancesOf("Win32_OperatingSystem")

			t = objComputer.BlockInput(True)<<<=== problem here if i don't use objcomputer the code will not work



			If t <> 0 Then
				'Error occurred!!!
			Else
				'Reboot your system
			End If
		Next
	End Sub
	Sub unbinput()

		Dim t As Single
		Dim objWMIService, objComputer As Object
		'Now get some privileges
		objWMIService = GetObject("Winmgmts:{impersonationLevel=impersonate,(Debug,Shutdown)}")
		For Each objComputer In objWMIService.InstancesOf("Win32_OperatingSystem")

			t = objComputer.BlockInput(False)

			If t <> 0 Then
				'Error occurred!!!
			Else
				'Reboot your system
			End If
		Next
	End Sub
	Sub ListenToServer()
		'Try

		Dim LISTENING As Boolean
		Dim localhostAddress As IPAddress = ipAddress.Parse(ipAddress.ToString)
		Dim port As Integer = 63000	  '' PORT ADDRESS
		''''''''''' making socket tcpList ''''''''''''''''
		Dim tcpList As New TcpListener(localhostAddress, port)
		Try
			tcpList.Start()
			LISTENING = True

			Do While LISTENING

				Do While tcpList.Pending = False And LISTENING = True
					' Yield the CPU for a while.
					Thread.Sleep(10)
				Loop
				If Not LISTENING Then Exit Do

				Dim tcpCli As TcpClient = tcpList.AcceptTcpClient()
				'ListBox1.Items.Add("Data from " & "128.10.20.63")
				Dim ns As NetworkStream = tcpCli.GetStream
				Dim sr As New StreamReader(ns)
				''''''''' get data from client '''''''''''''''
				Dim receivedData As String = sr.ReadLine()
				If receivedData = "###SHUTDOWN###" Then
					trShutdown = New Thread(AddressOf shutdown)
					trShutdown.Start()
				End If
				If receivedData = "###REBOOT###" Then
					trReboot = New Thread(AddressOf reboot)
					trReboot.Start()
				End If
				If receivedData = "###LOGOFF###" Then
					trLogOff = New Thread(AddressOf logoff)
					trLogOff.Start()
				End If
				If receivedData = "###BlockInput###" Then
					trBInput = New Thread(AddressOf binput)
					trBInput.Start()
				End If
				If receivedData = "###UnBlockInput###" Then
					trUnBInput = New Thread(AddressOf unbinput)
					trUnBInput.Start()
				End If

				Dim returnedData As String = "###OK###" '& " From Server"
				Dim sw As New StreamWriter(ns)
				sw.WriteLine(returnedData)
				sw.Flush()
				sr.Close()
				sw.Close()
				ns.Close()
				tcpCli.Close()
			Loop
			tcpList.Stop()
		Catch ex As Exception
			'error
			LISTENING = False
		End Try
	End Sub
	Dim ipAddress As IPAddress = Dns.Resolve(Dns.GetHostName()).AddressList(0)

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		NotifyIcon1.Icon = Me.Icon
		lblMYIP.Text = ipAddress.ToString
		trlisten = New Thread(AddressOf ListenToServer)
		trlisten.Start()
	End Sub

	Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
		NotifyIcon1.Visible = False
		End
	End Sub

	Private Sub btnHide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHide.Click
		NotifyIcon1.Visible = True
		Me.Hide()
	End Sub


	Private Sub NotifyIcon1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.Click
		Me.Show()
	End Sub
End Class


Was This Post Helpful? 0
  • +
  • -

#10 salohcin   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 06-September 07

Re: mini project advice and suggestion needed on how to start it

Posted 18 September 2007 - 06:00 PM

any1 can help?
Was This Post Helpful? 0
  • +
  • -

#11 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: mini project advice and suggestion needed on how to start it

Posted 18 September 2007 - 06:26 PM

View Postsalohcin, on 16 Sep, 2007 - 05:45 PM, said:

sorry if i bump a old post but can i get some help regarding keyboard if each key press it will reset the timer?
i am am to do the mouse with timer but i have problems with the keyboard


If you're wanting to simulate a key press just use the SendKeys Method
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1