Use Shell Method On A File With Parameters?
Jul 27, 2010I'm trying to use the Shell method however I'm having trouble because I want to open the file a specific way.
For example,
Shell("C:x.exe" -window)
However this gives an error.
I'm trying to use the Shell method however I'm having trouble because I want to open the file a specific way.
For example,
Shell("C:x.exe" -window)
However this gives an error.
I want to open a notepad file using VisualBasic.Interaction.Shell method. At present I get a file not found exception using the following code.
int pid = Interaction.Shell(@"D:abc.txt", AppWinStyle.NormalNoFocus, false, -1);
But this works:
int pid = Interaction.Shell(@"notepad.exe", AppWinStyle.NormalNoFocus, false, -1);
[code].....
I cant understand why this works (Start a service "test" on a remote computer):
Dim rCommand As String
rCommand = "c:pstoolspsservice \computer -u admin -p blabla start test"
Shell("cmd.exe /c" & rCommand)
[Code]....
The above code that doesnt work starts a virtual machine on VmWare Server. I have the exact same line in a .bat file and if i call the batfile from VB it starts the batfile and execute the commmand. I cant understand why this doesnt work without the batfil when i have no problem executing the PsTools command from VB-code.
I am trying to setup a variable in VB, which will execute a shell command (autostatus.exe) with a parameter (-j JobName), and later display the output of the said variable. The code thus far is...
Dim JobName
Dim JobStatus
JobName = "asysr11_set_global_var_2day"
JobStatus = ShellExecute("autostatus.exe", -j, JobName)
What is the easiest way to achieve this? Currently, the above code returns error message "line:4, Type mismatch: 'ShellExecute', code: 800A000D"
I am trying to print (to a text file) the fragmentation information give by Win32_Volume class using the DefragAnalysis method and have come up with the following VB.NET code:
Dim objReader As StreamWriter
objReader = New StreamWriter(FolderBrowserDialog.SelectedPath + "FragInfo" + "_" + CreationDate + ".txt")
Dim colItemsFragInfo As New ManagementObjectSearcher("rootCIMV2", "Select * from Win32_Volume where DriveType = 3")
[code]....
You do not need to defragment this volume.However executing this in Visual Studio returns the below:
Volume size: MB
Cluster size: MB
You do not need to defragment this volume.The point here is though it does NOT work under Windows Server 2008 R2, but does work under Windows Server 2003 (when executed in Visual Studio), WMI Code will work regardless of platform.
NB: i have played with the "Console.WriteLine" and changed it to "Debug.WriteLine" to output value to immediate window.
I am trying to call a method which has two parameters using thread. How can I do this? If I pass parameter to my thread.start() method, it is giving error.
View 1 RepliesIs there a Visual Basic.NET method that can convert method parameters into an array?[code]...
View 2 RepliesI am writing a alternative to GDI, and rigth now i am working at a logging function. The idea is that while you use the class to draw, it will write a logg of what you have done, which can be used to draw it back later. In that way i would be able to store a drawing with weary little disk usage.
[Code]...
How would I go about passing parameters to a method? I would want to do the following:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ReceivingUdpClient = New System.Net.Sockets.UdpClient(6767)
Dim receiveBytes As [Byte]() = ReceivingUdpClient.Receive(RemoteIpEndPoint)
Dim ThreadReceive As New System.Threading.Thread(AddressOf receiveMessages(receiveBytes))
ThreadReceive.Start()
End Sub
Private Sub receiveMessages(ByVal receiveBytes As Byte())
'INSERT CODE
<br/>
End Sub
How to pass a object that is initialized from a derived class to a method that has Interface as the parameter?[code]...
View 1 RepliesI have an inline lambda expression that I would like to use throughout my application. I just can't seem to find a reference on how to do this with more parameters than the element being tested. Here is a quick example of what I currently have.
Private Sub Test()
Dim List As New List(Of String) From {"Joe", "Ken", "Bob", "John"}
Dim Search As String = "*Jo*"
[Code].....
Is there a way to create a method with unknown number of parameters? And if it this the case: How is it possible to get access to them within this method? Do they have to be from the same type?
View 1 RepliesI have the following test method (VB.NET)
<RowTest()> _
<Row(1, 2, 3)> _
Public Sub AddMultipleNumbers(ByVal number1 As Integer, ByVal number2 As Integer, ByVal result As Integer)
Dim dvbc As VbClass = New VbClass()
Dim actual As Integer = dvbc.Add(number1, number2)
Assert.That(actual, [Is].SameAs(result))
End Sub
My problem is that when the test runs, using TestDriven.Net, the three method parameters are 0 and not the values I am expecting. I have referenced the NUnit.Framework (v.2.5.3.9345) anf the NUnitExtension.RowTest (v.1.2.3.0).
I was familiar with the optional parameters in vb 6 and it made sense given the capabilities of the language but why the heck does VB.Net support optional parameters when there is method overloading? Which one should I use and is there a difference? If there is a difference when should I use each one?
View 4 RepliesI have vb.net method and i call it from JS code i can't send parameter to this method and here is sample:[code]
View 5 RepliesA friend in work suggested the use on classe to store the parameters BEFORE call a method. He's said this is called "Abstract Class". My "know how" of VB.NET is small... so, I want to know of you what mode is the best way: Call a function/sub like that:
[Code]...
Getting this error message and I am not able to figure out why. Here is my code:
<asp:TextBox ID="searchParam" Width="250px" runat="server"></asp:TextBox><asp:button ID="btnSearch" runat="server" Text="Search" />
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="getCOMDLs" TypeName="NewEmployee">
[Code]...
I have a COM component that I want to call using late-binding from VB.NET (using Primary Interop Assembly - PIA method). My IDL signature for the COM method looks like:
HRESULT Send([in]BSTR bstrRequestData,
[out]VARIANT *pvbstrResponseData,
[out]VARIANT *pvnExtCompCode,
[out,retval]int *pnCompletionCode);
So 2 'ByRef' parameters in VB.NET lingo, and a return value. I attempt to invoke this method like so:
Dim parameters(2) As Object
parameters(0) = "data"
parameters(1) = New Object()
parameters(2) = New Object()
Dim p As New ParameterModifier(3)
[Code] .....
This fails spectactularly with an exception: {"Invalid callee. (Exception from HRESULT: 0x80020010 (DISP_E_BADCALLEE))"}
I assume this means I'm doing something wrong in my parameterMods array. Because if I comment out setting any value of the ParameterMods array to 'True' - it works. It of course doesnt update the parameters that are [out] parameters and so it's not working as intended. Is there something else to consider since the method also has a return value? The MSDN example pretty much does exactly what I am doing, with the exception that example did not have a return value.
For example, assume that in my assembly, in Namespace A, Class B, there is an instance method with the following signature: void Test(string someString, int someOtherParm, string someOtherString ); This method is called multiple times, from multiple places in the assembly. I would like to be able build a list of all invocations of this method and the value of the someString/someOtherString (assuming they are hardcoded). In other words, I like to extract a list of calls like the example one below, if they happen in the assembly somewhere: Test("some text", 8, "some other text");
View 1 RepliesI'm going to attempt to make a shell replacement for the Windows default shell: explorer.exe. I'm not sure if its possible using Vb.Net, but I can't seem why not. My end goal is to use a custom made shell for a Windows Preinstallation Environment instead of the default command prompt. I plan to use a 3rd party program to compile the program with the .NET Framework. Otherwise, it wouldn't work because Windows PE does not support the .NET Framework.
View 1 Repliesi have this
Quote:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Process.Start("mybatchfile.bat")
End Sub
its working if they are on the same folder,i want to do is make the batch file as a resource file so that i can run it even not in the batchs folder?
I have nine pictures that I need to animate -I need to use the ToString method and a counter to concatenate a file name into a string variable from the Image.FromFile method. Once the counter reaches its maximum value, and the last picture is displayed, the counter should be reset to zero or one depending on how the first image file has been name. Also a static counter variable should be incremented in the time routine. what I have so far -- I know what I have to do; however, I just do not know how to code this properly.. Right now I have this going thru a button procedure but it needs to go through a timer.
[code]....
I'm just getting started in VB.net using vb.net 2010 . I thought what I had left to do today was simple but not to be.I am simply trying to open a zip file that the user has selected.No mater how I have tried to send the filename (with quotes added, chr(34) & selfilename, set permissions, confirm file is found) I get Error 53 File Not Found.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SelFileName As String
Dim ReturnValue As Boolean
SelFileName = ListBox1.SelectedItem 'Contains the full path and filename
[code].....
Here's an example code so you can understand my problem:
Dim test1 As String
Dim test2 As String
Dim test3 As String
[code]....
shell.Run("""testProgram""test1 test2 test3 test4") 'I know this is wrong.My problem is in the last line. I want the contents of the strings to be printed, not the names of the strings, and I don't know how to do that.
im trying to shell a file from a listbox by getting its name and then shelling
this is my code
Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
Shell("C:UsersNotandiDesktopSt�rikerfiFoldersGAMES" + ListBox1.SelectedItem.ToString)
End Sub
If I use the shell command: notepadID = Shell("C:\WINDOWS\system32\notepad.exe", AppWinStyle.MaximizedFocus)When note pad opens I want to control the fileopen box. I can use the SendKeys.SendWait("%(FO)") to get the box opened but then how can I control the initial directory and the file type filter? I would much rather open the fileopen box in code and control it that way. How can I use the code below to control the fileopen on a process that the shell command opened up? [code]
View 5 RepliesI will try to explain what I need.Let's say that I have a class like this:
Public Class Example1 Public Sub ToBeCalled()
[Code]...
I'm trying to use the Shell to have my application call an external application but its not working...I don't understand why. I get the following error: 'System.windows.shell' is a namespace and cannot be used as an expression!
Heres my code....any ideas what I'm doing wrong. Its got to be a simple...stupid error.
Private Sub mnuUpgrade_Click(ByVal Ctrl As Microsoft.Expression.Web.Interop.Legacy.CommandBarButton, ByRef CancelDefault As Boolean) Handles mnuUpgrade.Click
[CODE].....................
I have an application, that I have integrated into Windows Shell, for this example I will use Notepad. You can right-click a file on the desktop and select 'Edit with Notepad', this launches(if I am not mistaken 'NotePad %1') notepad, and opens the file right away for editing.For my application I need this to get the file name, so basically I would right click on my application, and it will run and have the filename for me to use inside the application.
View 1 RepliesI know the "Process.Start" function, but it creates a new object of the cmd shell which terminates itself when the Python script is at its end. How can i open the original Windows Command Shell so that the Python file can run to its end without the box getting closed?
View 6 Replies