Executing Shell Commands/file Deletion With Wildcards?
Oct 10, 2011I need to execute the following commands from my application:
Echo Y | DEL C:Folder1cache*.*
DEL C:Folder1file.abc
DEL C:Folder1file.xyz
[code].....
I need to execute the following commands from my application:
Echo Y | DEL C:Folder1cache*.*
DEL C:Folder1file.abc
DEL C:Folder1file.xyz
[code].....
how can i execute a shell command from a string
shell("cd", StringName)
the string comes from a user entered textbox
StringName = Textbox.text
how can i get this to work?
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.
I am trying to execute the shell script in vb.net.[code]...
The script doesn't create the outfile mentioned in -out switch. The path mentioned is correct and also the command with switches is correct. It runs well in command prompt but not in the program. [code]...
how do i run my shell Shell("netsh interface ip set address" & Chr(34) & "Local Area Connection" & Chr(34) & "static 10." & IPAddy & ".4") as admin?
View 2 RepliesI have some code in Form Load event. It is doing fine. But when it reaches to pick data from database, no commands are executing after that. There is no error at all but it just goes silent.[code]...
View 3 RepliesI 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.
[Code]...
for exp. this the code that i use to open calculator but how can i use , appminimize, maximize, apphide, normal, show etc. command that i can use in visual basic ?
Sorry if i had make about tags.
Okay, heres the deal...I need to open up a cmd prompt, then run a file called adb.exe which opens a shell to communicate with my android cell phone...
My Form1
Code:
Label1.Text = "adb.exe shell"
[code].....
I need to open several pdf, word and excel files from process.start like command, but only open one file at time.
View 2 RepliesI'm trying to create a program that does the following:Executes the following command line string (wmic /node:computername bios get serialnumber)Prompts user for the "node" entry Displays the resulting serial number in a dialog box I'm a bit of a noob at this (I haven't coded anything in VB since early 2000s) so I'm at a bit of a loss where to start. I plan on including some functions to submit the node entry and the resulting serial number to a database in the future for archiving as well.
View 4 RepliesI'm using Visual Basic Professional 2010, I have two directories of XML files. The naming convention in directory one is a user's name, a six digit date and ending in ".xml_CREATE.xml". So, I perform some work on a file in directory two. During the course of that processing I discover that a file exists in directory one called "Mike" an unknown six digit date and ending with ".xml_CREATE.xml", so while I have no way to know the date, I know it exists and would look something like Mike030312.xml_CREATE.xml. So, now I want to load that file as an XElement that I will eventually incorporate into an XDocument, so I need to perform a Load similar to:
myXMLFile = XElement.Load(My.Settings.XMLDir & "" & Mike030312.xml_CREATE.xml),
However, since I don't know the date, I need to insert wildcards at that spot. How do I make that happen?
I would like to create an application that would shell command prompt, and then passcommands to it.
View 4 RepliesI am developing an application that Monitors a specific folder for file changes such as modify deletion, update, etc. The only problem I have is , the application doesn't fire up File events.
Here is the code:
Imports System.IO
Imports System.Diagnostics
Public Class Form1
[CODE].............................
I have this in my form closing event:
For Each FileFound As String In Directory.GetFiles(App_Path() & "tmp", "*.txt")
File.Delete(FileFound)
Application.DoEvents()
Next
For Each FileFound As String In Directory.GetFiles(App_Path() & "tmp", "*.txt")
File.Delete(FileFound)
Next
I used to run through an ultragrid with a for each loop and that took forever, I stumbled accross this way and it's much faster but I noticed today I still have some straggling .txt files after the form closes at times. Is there a way to actually verify all the files have been deleted before closing the form?
I ran the same for each loop twice to work it out but not sure if that works or worsens it. Also, I'm not entirely sure what that application.doevents does as I initially thought it would finish all above lines before continuing but that does not seem the case. Anyway, these .txt files files are about 500KB and up to 1000 of them at any one time so it's not instant but it's still pretty fast, faster then looping through a grid.
I want to make a very simple program that remove duplicate domain name from a txt file. First, it must have a Open file Button so that it can load list of url to Listbox.
So, the URLs will be loaded into listbox. Then It has 2 more button Start and Save button Lastly one counter to calculate how many URL in that listbox
So example.. let say I have a txt file which contains URLs
[URL]
I open this txt file and loaded it into listbox (can scroll)
Then when I press start button, it will delete the URL that has same domain name. so the output will look like this
[URL]
Then I can save the URL from listbox to my disc drive as text file
I am looking for maby something I am missing here in this code. My goal is to take the current user and delete there local settings/temp/ files. However some of these files are in use by the OS and that's what im running into a problem with. Here is what I have so far and it finds the dir easly and bam that's the brick wall access denied error because there is some files in there that are in use.
[Code]....
I was looking online for a application that can delete a file more secure then. Kill(C: est.txt")Then i had a thought.Maybe i can make my own.Is it possible to make a secure file deleter in vb.net or should i look into C++
View 5 RepliesIs there a way to detect if a file is being deleted,
1) Using the Del key
2) Using the Shift+Del keys
3) Using the above keys from a remote computer through a shared folder
And instead of deleting move it to another folder in the same computer. Basically when a user tries to delete a file or folder it should move it to a specified folder instead of deleting it.
I want to make a fairly simple program that would prevent file deletion of certain folders andor files that i would input into the program. Say if someone tried to delete the file it would display an error message.
View 3 RepliesThis is what I have for code:
Private Sub restoreDatabase(ByVal dbName As String)
Dim newDbName As String
newDbName = dbName.Substring(dbName.LastIndexOf("_") + 1)
My.Forms.portfolioGenerator.Close()
[Code] .....
It seems like it should be pretty simple, I take in a file name as a parameter, create a new name for it, delete it, then try to copy it back from an older version of the same file, and update the connection string. However, it continually tells me that "The file 'filenamehere' already exists." If I set overwrite to true then it goes through just fine, except it doesn't actually copy the file. Obviously I also check the folder, and the file does in fact Not exist...I've also checked all the file paths and what-not, they are all accurate.
I'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'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].....
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'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].....................
how would i got about executing another file from my application with hidden attributes so its not visible?
View 5 RepliesI'm trying to make a program that has command buttons, each running a different file. I have added some files so far, but I encountered a problem with a couple of them.
For example, I want to run Zuma's Revenge! right from the program, but it is not working. If I run the game from outside the program, it runs perfectly, but when I try running it from the program, it keeps saying "Zumas Revenge! - Adventure has stopped working."
What really confused me, is that the game is running normally if I run it from its folder or by using the shortcut, while from the program it isn't.I'm using Windows 7, with Visual Basic 2010 Express.
'Here's the code I'm using:
Private Sub Zumas_Revenge_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Zumas_Revenge.Click
Process.Start(My.Application.Info.DirectoryPath & "umas Revenge! - AdventureumasRevengeAdventure.exe")
End Sub
well i tried to make this vb code execute another app *hidden*(as in window not visible) and it didnt work because the window is still fully visible.. i dont know why, i think its just because of this particular kind of exe or something..
is there another way to really execute this file hidden? i dont know how to do it but i heard about mabye threading it or making it a windows service? will that solve this?
[Code]...