|
I want (desperately) to do something very simple (i think or at least thought.)
I want to have a web page that simply has a link that you click, this runs a command line app and then returns the output to HTML.
{ie click here the and the system shows you the contents of C drive. Or shows you custom enviornmental settings.)
I just want command line interaction I do not want WMI workarounds (I figured how to do that on my own.)
I want to use VBscript... i know how I would do this if i could use Perl... the coding is not my actual issue, it is the nuances of VBscript and Command line interaction.. alas Perl does script to command line and back so much more smoothly than VBscript seems to but I am a newb with vb altogether...
Thanks very much for you time!
|
|
|
|
|
|
I have been trying to get this api to work in VB.NET, but have no clue how. I have the equivilent code in VB6, but can't get it converted to .NET. If anyone has an example, or know how to do this in VB.NET any help would be appreciated.
Enes M
|
|
|
|
|
Enes,
I am trying to do the exact same thing as yourself. I feel that I am close to a solution, it's just not 100% correct. I am trying to get NetSessionEnum working with level 2 or 502.
I get the data and correctly populate the structure with the first session's details, but when I go to populate subsequent sessions the data is being loaded into the wrong fields. My structure appears correct according to Microsoft's web-site.
If I get it working correctly I'll post the result, hopefully you can do the same if you beat me to the solution.
Regards,
Paul T.
|
|
|
|
|
Give this a try:
'Structures
'Requirements as of March 2005.
'Client : Windows XP, Windows 2000 Professional, or Windows NT Workstation.
'Server : Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Private Structure SHARE_SESSION_VALUES_502
Dim strComputerName As String 'The name of the computer that established the session.
Dim strUserName As String 'The name of the user who established the session.
Dim strNum_Opens As String 'The number of files, devices, and pipes opened during the session.
Dim strTime As String 'The number of seconds the session has been active.
Dim strIdle_Time As String 'The number of seconds the session has been idle.
Dim strUser_Flags As String 'Describes how the user established the session.
Dim strClientType As String 'The type of client that established the session.
Dim strTransport As String 'The name of the transport that the client is using to communicate with the server.
End Structure
Private Structure SHARE_SESSION_INFO_502
Dim strComputerName As IntPtr
Dim strUserName As IntPtr
Dim strNum_Opens As IntPtr
Dim strTime As IntPtr
Dim strIdle_Time As IntPtr
Dim strUser_Flags As IntPtr
Dim strClientType As IntPtr
Dim strTransport As IntPtr
End Structure
'Constants
Private Const NERR_SUCCESS As Long = 0
Private Const ERROR_MORE_DATA As Long = 234
'Variables
Private m_colSessionDetails As New Collection
Private m_strComputer As String
Private m_lngSessionLevel As Long
Public Sub Initialise(ByVal p_strComputerName As String)
Dim lngLoop As Long
m_strComputer = p_strComputerName
' Connect to the remote computer
test(p_strComputerName)
End Sub
Private Sub test(ByVal p_strComputer As String)
Dim p_lngRtn As Long
Dim p_intptrBuffer As IntPtr
Dim p_lngPreMaxLen As Long
Dim p_lngEntriesRead As Long
Dim p_lngTotalEntries As Long
Dim p_lngResumeHwnd As Long
Dim p_intPtrNextBuffer As IntPtr
Dim p_strClientName As String
Dim p_strUserName As String
Dim Share_Struct_Size As Integer
Dim SI502_Pointers As SHARE_SESSION_INFO_502
Dim SI502_Values As SHARE_SESSION_VALUES_502
Const cnstProcName As String = "Test"
Try
Do While m_colSessionDetails.Count > 0
m_colSessionDetails.Remove(1)
Loop
p_strComputer = "\\" & p_strComputer
p_strClientName = ""
p_strUserName = ""
p_lngPreMaxLen = 0
p_lngResumeHwnd = 0
'Try the Win XP, 2000 Server and 2003 Server option first, if that fails - then try
'the option for Win Me, 98, and 95.
m_lngSessionLevel = 502
p_lngRtn = NetSessionEnum(p_strComputer, _
p_strClientName, _
p_strUserName, _
m_lngSessionLevel, _
p_intptrBuffer, _
p_lngPreMaxLen, _
p_lngEntriesRead, _
p_lngTotalEntries, _
p_lngResumeHwnd)
If p_lngRtn = NERR_SUCCESS Then
If p_lngRtn <> ERROR_MORE_DATA Then
Share_Struct_Size = Marshal.SizeOf(SI502_Values)
For i As Integer = 0 To p_lngEntriesRead - 1
p_intPtrNextBuffer = New IntPtr(p_intptrBuffer.ToInt32 + (Share_Struct_Size * i))
SI502_Pointers = Marshal.PtrToStructure(p_intPtrNextBuffer, GetType(SHARE_SESSION_INFO_502))
SI502_Values = New SHARE_SESSION_VALUES_502
SI502_Values.strComputerName = Marshal.PtrToStringUni(SI502_Pointers.strComputerName)
SI502_Values.strUserName = Marshal.PtrToStringUni(SI502_Pointers.strUserName)
SI502_Values.strNum_Opens = SI502_Pointers.strNum_Opens.ToInt32
SI502_Values.strTime = SI502_Pointers.strTime.ToInt32
SI502_Values.strIdle_Time = SI502_Pointers.strIdle_Time.ToInt32
SI502_Values.strUser_Flags = SI502_Pointers.strUser_Flags.ToInt32
SI502_Values.strClientType = Marshal.PtrToStringUni(SI502_Pointers.strClientType)
SI502_Values.strTransport = Marshal.PtrToStringUni(SI502_Pointers.strTransport)
m_colSessionDetails.Add(SI502_Values)
Next
End If
Else
'TODO - Enumerate Sessions using level 50.
m_lngSessionLevel = 50
End If
'Clean up the buffer
Call NetAPIBufferFree(p_intptrBuffer)
Call NetAPIBufferFree(p_intPtrNextBuffer)
Exit Sub
Catch e As Exception
Err.Raise(p_lngRtn, _
cnstProcName, _
e.Message)
End Try
End Sub
Regards,
Paul T.
|
|
|
|
|
Does the above work for you? Api function always returns a long number 267964182123512921, or some other number depending on whether i use local or remote computer. Do you have a fully working module or a class? I'm not too good with APIs, so I don't think i will be able to figure this out. You can drop me an e-mail at enes@qwest.net if the code is too long to post here.
Here is my API function decleration.
Private Declare Function NetSessionEnum Lib "netapi32.dll" (_
ByVal lptstr As String,_
ByVal lptstr As String,_
ByVal lptstr As String,_
ByVal dword As Long,_
ByVal pbyte As IntPtr,_
ByVal dword As Long,_
ByRef pdword As Long,_
ByRef pdword As Long,_
ByRef pdword As Long) As Long
Thanks,
Enes M.
|
|
|
|
|
Enes,
The code I submitted does work for me. I have run it from a Win XP machine and received the correct details of a Win 2003 Server. Be careful of the level that you use because some older OS's won't run level 502, in this case you have to use level 50 which has a different structure. My apologies for not including the API declaration originally.
Private Declare Unicode Function NetSessionEnum Lib "netapi32.dll" (_
ByVal ServerName As String, _
ByVal ClientName As String, _
ByVal UserName As String, _
ByVal Level As Integer, _
ByRef Buffer As IntPtr, _
ByRef prefmaxlen As Integer, _
ByRef entriesread As Integer, _
ByRef totalentries As Integer, _
ByRef ResumeHandle As Integer) As Integer
Regards,
Paul T.
|
|
|
|
|
I`m trying to get picture from text. I need this to log on to my game, anyone knows how to pull it off ?
image text: http://www.void.rs.ba/gra.jpg
so i need to extract "LeechTower" or any other text from it
|
|
|
|
|
You'll need to implement some kind of OCR. There is an article here on CP, just search for OCR. I hope you're familiar with neural networks...
There is a problem with your image though. The lines going through the text will make it virtually impossible for ANY OCR implementation to see the text. You'll have to preprocess the image to make the text standout against the background before you try an OCR pass.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi,
Iam doing one small project in VB.NET.In that i want to give the command in TEXTBOX and the output should be displayed in RICH TEXTBOX.I need the code for this synario.pls help me in this regard.....
|
|
|
|
|
This is nowhere near enough information to help you with anything. What command? What are you doing to generate output? What is the output supposed to look like? What is it that your application is supposed to do?
So far, all you've said is "I want to type a command in a Textbox, do some processing, and write some output to a RichTextBox." Easy, RichTextBox1.Text = "some output..."
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for replying to me.normaly if we want to know the ip address of our system we will give "ipconfig" command in the command prompt.and the system will give ipaddress as the output these output is seen in the console itself.in the same way....i want to give this command "ipconfig" in textbox and the ipaddress that we get as output should display in richtextbox...its not compulsory that i want to use textbox and only richtextbox......u can use any usercontrol as u like....
|
|
|
|
|
Do you mean something like:
Dim proc As Process
proc = New Process
proc.StartInfo.FileName = "ipconfig"
proc.StartInfo.UseShellExecute = False
proc.StartInfo.RedirectStandardOutput = True
proc.StartInfo.CreateNoWindow = True
proc.Start()
Dim sr As IO.StreamReader = proc.StandardOutput
rtb.AppendText(sr.ReadToEnd)
sr.Close()
|
|
|
|
|
You should tell us more in details about ur project
handly will helps you so explain more clearly ur question
|
|
|
|
|
Thanks for replying to me.normaly if we want to know the ip address of our system we will give "ipconfig" command in the command prompt.and the system will give ipaddress as the output these output is seen in the console itself.in the same way....i want to give this command "ipconfig" in textbox and the ipaddress that we get as output should display in richtextbox...its not compulsory that i want to use textbox and only richtextbox......u can use any usercontrol as u like....
|
|
|
|
|
Hi all
While navigating in a form, how can I change the picture of an employee to another picture while pressing the button Next.
krish
|
|
|
|
|
How is the picture being drawn ? If in a picturebox, change the picture, if direct to screen, change the memory bitmap and call invalidate.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Sir,
Please sent me a sample code for setting flag in VB.Net.
In database (Stored procedure) flag = 0 is Insert and flag = 1 is Update command. I couldn't write correct code in VB.Net.
Regards
Lijo Mathew
|
|
|
|
|
Can you explain exactly what the problem is? I don't think someone will understand the question you're asking.
WM.
What about weapons of mass-construction?
|
|
|
|
|
hum, you don't really explain what you need that clear, but i think you can try this :
SqlUpdateCommand = <font color=gray>"UPDATE myTable"</font> & _
<font color=gray>"SET myFlagColumn 1"</font> & _
<font color=gray>"WHERE (condition)"</font>
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Im using visual basic webbrowser control and I would like to know of a way I can hard code a session cookie in every request the browser makes.
First off I would need to stop the browser from handling cookies or at least outbound cookies.
I think there is a flag with wininet that will stop browser sending cookies as it normaly would.
I guess I need to include cookie in header and I am not sure how to do this.
http://www.hashemian.com/tools/browser-simulator.htm this tool does what i need my app to do but it only works for typed urls and does not work with links clicked after.
also using the program proxomitron I am able to replace out going cookies to my session cookie and it works just fine. I would like to be able to do that in my visual basic app.
any help is greatly appretiated.
|
|
|
|
|
Could you tell me how to load/display a pre-created form? For example, I have two forms, MainForm and secondForm, If I want to load the secondForm in MainForm, how to write the code?
Thanks for your kind help.
|
|
|
|
|
Dim SecondForm1 as New SecondForm
SecondForm.Show
|
|
|
|
|
Try to read this article.[^]
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
in head of code-page declare SecondForm as new SecondForm
then in Form1_Load write this code...
SecondForm.ShowDialog()
the user should do something otherwise he/she cant see Form1.
I hope this gonna help you.
|
|
|
|