|
Hi
I need to shutdown remote systems running on windows xp with Dotnet Framework 1.1 installed. The user is limited on these machines.
I have used the following methods to shutdown the systems.
1. wmi
Dim oOS, oOperatingSystem As Object
oOS = GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * from Win32_OperatingSystem")
For Each oOperatingSystem In oOS
oOperatingSystem.Win32Shutdown(nForcePowerDown)
Next
2. shutdown.exe of xp
The problem is using the wmi sometime fails for reasons I don't know. The other method needs Admin privileges. Which is also an overhead.
What should I do? Use the API or there is some other way?
Please help as search over internet has not helped me much.
Thanks
reman
|
|
|
|
|
Let's just assume that your reasons for wanting to do this are entirely legitimate.
Think about it, if it were possible to just shut down a remote system, without admin privileges, what would keep hackers from doing so?
My advice is free, and you may get what you paid for.
|
|
|
|
|
If you want to do remote shutdown, you need Admin privileges on the remote machine to do it. There is no way around it, for obvious reasons.
|
|
|
|
|
Imports System.Net
Imports System.Net.NetworkInformation
Imports System.Text
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
Public Shared Sub ShowTcpStatistics(ByVal version As NetworkInterfaceComponent)
Dim properties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
Dim tcpstat As TcpStatistics = Nothing
txtbox.Text("")
Select Case version
Case (NetworkInterfaceComponent.IPv4)
tcpstat = properties.GetTcpIPv4Statistics()
txtbox.Text("TCP/IPv4 Statistics:")
Exit Select
Case (NetworkInterfaceComponent.IPv6)
tcpstat = properties.GetTcpIPv6Statistics()
txtbox.Text("TCP/IPv6 Statistics:")
Exit Select
Case Else
Throw (New ArgumentException("version"))
' break;
End Select
txtbox.Text(" Minimum Transmission Timeout............. : {0}", tcpstat.MinimumTransmissionTimeout)
txtbox.Text(" Maximum Transmission Timeout............. : {0}", tcpstat.MaximumTransmissionTimeout)
txtbox.Text(" Connection Data:")
txtbox.Text(" Current ............................ : {0}", tcpstat.CurrentConnections)
txtbox.Text(" Cumulative .......................... : {0}", tcpstat.CumulativeConnections)
txtbox.Text(" Initiated ........................... : {0}", tcpstat.ConnectionsInitiated)
txtbox.Text(" Accepted ............................ : {0}", tcpstat.ConnectionsAccepted)
txtbox.Text(" Failed Attempts ..................... : {0}", tcpstat.FailedConnectionAttempts)
txtbox.Text(" Reset ............................... : {0}", tcpstat.ResetConnections)
txtbox.Text("")
txtbox.Text(" Segment Data:")
txtbox.Text(" Received ........................... : {0}", tcpstat.SegmentsReceived)
txtbox.Text(" Sent ................................ : {0}", tcpstat.SegmentsSent)
txtbox.Text(" Retransmitted ....................... : {0}", tcpstat.SegmentsResent)
txtbox.Text("")
End Sub
|
|
|
|
|
You should buy a very basic book and work through it berfore continuing this task.
You have a sub inside a sub. Remove the button4_click sub, or put an end sub at the bottom of it.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I think the cause of the error is really quite obvious. You didn't terminate your Protected Sub Button4_Click() method with an End Sub before you started with Public Shared Sub ShowTcpStatistics() .
|
|
|
|
|
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
ShowTcpStatistics(txtB.Text)
End Sub
Public Shared Sub ShowTcpStatistics(ByVal version As NetworkInterfaceComponent)
Dim properties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
Dim tcpstat As TcpStatistics = Nothing
txtbox.Text = ""
For Each tcp As TcpStatistics In tcpstat
txtbox = tcp.ToString()
Next
Select Case version
Case (NetworkInterfaceComponent.IPv4)
tcpstat = properties.GetTcpIPv4Statistics()
txtbox.Text("TCP/IPv4 Statistics:")
Exit Select
Case (NetworkInterfaceComponent.IPv6)
tcpstat = properties.GetTcpIPv6Statistics()
txtbox.Text("TCP/IPv6 Statistics:")
Exit Select
Case Else
Throw (New ArgumentException("version"))
' break;
End Select
txtbox.Text(" Minimum Transmission Timeout............. : {0}", tcpstat.MinimumTransmissionTimeout)
txtbox.Text(" Maximum Transmission Timeout............. : {0}", tcpstat.MaximumTransmissionTimeout)
txtbox.Text(" Connection Data:")
txtbox.Text(" Current ............................ : {0}", tcpstat.CurrentConnections)
txtbox.Text(" Cumulative .......................... : {0}", tcpstat.CumulativeConnections)
txtbox.Text(" Initiated ........................... : {0}", tcpstat.ConnectionsInitiated)
txtbox.Text(" Accepted ............................ : {0}", tcpstat.ConnectionsAccepted)
txtbox.Text(" Failed Attempts ..................... : {0}", tcpstat.FailedConnectionAttempts)
txtbox.Text(" Reset ............................... : {0}", tcpstat.ResetConnections)
txtbox.Text("")
txtbox.Text(" Segment Data:")
txtbox.Text(" Received ........................... : {0}", tcpstat.SegmentsReceived)
txtbox.Text(" Sent ................................ : {0}", tcpstat.SegmentsSent)
txtbox.Text(" Retransmitted ....................... : {0}", tcpstat.SegmentsResent)
txtbox.Text("")
End Sub
|
|
|
|
|
that_dude_tj wrote: txtbox.Text("TCP/IPv4 Statistics:")
Does this work ? What does it do ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
not sure why he wrote that. it does not work. text has an overload but it only extracts the character position at the given number textbox1.text(3)
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
OK, that's interesting. It's a property AND a method ? I didn't know that. Either way, his response looked to me like a further question, but no question was present, so I was trying to guess the problem
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I just tried it. It probably is 2 properties that are overloaded 'a' = text for the example
Public ReadOnly Property a(ByVal idx As Int16) As String
Get
'extracts character at position
End Get
End Property
Public Property a() As String
Get
End Get
Set(ByVal value As String)
End Set
End Property
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
I'm not certain, but I think it's just a property. It returns String, and the String object has a built in indexer. Just like you could have a List(Of List(Of Integer)), and use lst(0)(1) and get an Integer back
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
No not working yet it suppose to display Internet Protocol version 4 (TCP/IPv4) statistical data for the local computer to my textbox name txtbox. i used this in the ping and it worked fine
Dim ping As Ping = New Ping()
Dim pingreply As PingReply = ping.Send(txtHost.Text)
txtPing.Text &= "Address: " & pingreply.Address.ToString() & Constants.vbCr
txtPing.Text &= "Roundtrip Time: " & pingreply.RoundtripTime & Constants.vbCr
txtPing.Text &= "TTL (Time to Live): " & pingreply.Options.Ttl & Constants.vbCr
txtPing.Text &= "Buffer Size: " & pingreply.Buffer.Length.ToString() & Constants.vbCr
|
|
|
|
|
So what's this?? You didn't ask a question and I'm not inclined to just start throwing test apps together to guess what you want out of this...
|
|
|
|
|
lol my question is then i would be. that im unable to display the tcp statistics in my text box
|
|
|
|
|
I responded four hours ago to try to keep helping you, but you didn't even reply ?
You need to read a pretty basic VB.NET book. You seem to be making code up instead of knowing what you're doing. The best way to do what you want, is use a StringBuilder to build the message, as it's multiline from what I can tell, and then set that text to the Text property.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks ill get to reading
|
|
|
|
|
Your textbox lines are a bit funny. You seem to think there is a .Text method on it, but .Text is actually a property. Since you keep replacing the .Text property with a new line of text, the last line you supply is blank, so nothing will show up in the textbox.
Serisouly, pickup a beginners book on VB.NET. You're missing some really basic concepts that we really can't describe to you in forum posts.
|
|
|
|
|
Hi,
How to enum each charcter of string.
I am trying but getting error:
For i = 0 To Len(s) - 1
c = c Xor s[i] 'error here
Next i
|
|
|
|
|
What is the error.
If you want people to help you, you must help them!
A lot of CP members would be able to guess the error correctly, but most can't.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
You can use for each to more succinctly move through a string. VB does not use [] or <>, it's designed for non programmers and always uses ().
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
( )
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
you cannot use "for each" to go through the content of a string. if it was a string array then yes but not a single string.
"designed for non programmers"
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Really ? I didn't realise VB sucked like that. In C#, we can use foreach to iterate through the chars of a string.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
It doesn't actually suck that much, with VB you can iterate through the characters in a string no problem. I think Larson was just being nit picky. I.e. you would have to convert the string to an array of characters (SomeString.ToCharArray() ) before you can iterate through it.
My advice is free, and you may get what you paid for.
|
|
|
|