nstd-sts
asked on
VB script to extract contents to a created network folder
I am creating a visual basic script and need some help.
I have a form with a open file button. I can get the button to Open and browse to the file you want to open. The file is going to be symantec antivirus updates. What I want to happen is once the file is selected, I want it to extract the contents to a network share with a folder created with the name of the file.
I know the command for a batch script to extract the contents is
symantecfilename.exe /extract \\servername\share
Thanks
We are running this on Windows XP Boxes
I have a form with a open file button. I can get the button to Open and browse to the file you want to open. The file is going to be symantec antivirus updates. What I want to happen is once the file is selected, I want it to extract the contents to a network share with a folder created with the name of the file.
I know the command for a batch script to extract the contents is
symantecfilename.exe /extract \\servername\share
Thanks
We are running this on Windows XP Boxes
ASKER
Here is the code, I havent used vb in years and I am just coping from Visual Studio. Also, the file name is going to change every time I import a file.
<Global.Microsoft.VisualBa sic.Compil erServices .DesignerG enerated() > _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.Debugg erNonUserC ode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.ICon tainer
'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.
<System.Diagnostics.Debugg erStepThro ugh()> _
Private Sub InitializeComponent()
Me.OpenFileDialog1 = New System.Windows.Forms.OpenF ileDialog
Me.TextBox1 = New System.Windows.Forms.TextB ox
Me.Open = New System.Windows.Forms.Butto n
Me.Button1 = New System.Windows.Forms.Butto n
Me.SuspendLayout()
'
'OpenFileDialog1
'
Me.OpenFileDialog1.FileNam e = "OpenFileDialog1"
Me.OpenFileDialog1.Support MultiDotte dExtension s = True
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(12, 21)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(156, 20)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "Symantec 64 Bit Auto Update"
'
'Open
'
Me.Open.Location = New System.Drawing.Point(12, 59)
Me.Open.Name = "Open"
Me.Open.Size = New System.Drawing.Size(75, 23)
Me.Open.TabIndex = 1
Me.Open.Text = "Open"
Me.Open.UseVisualStyleBack Color = True
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(12, 88)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 23)
Me.Button1.TabIndex = 2
Me.Button1.Text = "Start"
Me.Button1.UseVisualStyleB ackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoS caleMode.F ont
Me.ClientSize = New System.Drawing.Size(582, 320)
Me.Controls.Add(Me.Button1 )
Me.Controls.Add(Me.Open)
Me.Controls.Add(Me.TextBox 1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenF ileDialog
Friend WithEvents TextBox1 As System.Windows.Forms.TextB ox
Friend WithEvents Open As System.Windows.Forms.Butto n
Friend WithEvents Button1 As System.Windows.Forms.Butto n
End Class
<Global.Microsoft.VisualBa
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.Debugg
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.ICon
'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.
<System.Diagnostics.Debugg
Private Sub InitializeComponent()
Me.OpenFileDialog1 = New System.Windows.Forms.OpenF
Me.TextBox1 = New System.Windows.Forms.TextB
Me.Open = New System.Windows.Forms.Butto
Me.Button1 = New System.Windows.Forms.Butto
Me.SuspendLayout()
'
'OpenFileDialog1
'
Me.OpenFileDialog1.FileNam
Me.OpenFileDialog1.Support
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(12, 21)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(156, 20)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "Symantec 64 Bit Auto Update"
'
'Open
'
Me.Open.Location = New System.Drawing.Point(12, 59)
Me.Open.Name = "Open"
Me.Open.Size = New System.Drawing.Size(75, 23)
Me.Open.TabIndex = 1
Me.Open.Text = "Open"
Me.Open.UseVisualStyleBack
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(12, 88)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 23)
Me.Button1.TabIndex = 2
Me.Button1.Text = "Start"
Me.Button1.UseVisualStyleB
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!,
Me.AutoScaleMode = System.Windows.Forms.AutoS
Me.ClientSize = New System.Drawing.Size(582, 320)
Me.Controls.Add(Me.Button1
Me.Controls.Add(Me.Open)
Me.Controls.Add(Me.TextBox
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenF
Friend WithEvents TextBox1 As System.Windows.Forms.TextB
Friend WithEvents Open As System.Windows.Forms.Butto
Friend WithEvents Button1 As System.Windows.Forms.Butto
End Class
ASKER
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub OpenFileDialog1_FileOk(ByV al sender As System.Object, ByVal e As System.ComponentModel.Canc elEventArg s) Handles OpenFileDialog1.FileOk
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub FolderBrowserDialog1_HelpR equest(ByV al sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Open.Click
' Reset the file names for the Open File dialog box and for the Media Player.
OpenFileDialog1.FileName = ""
' Display the Open File dialog box.
OpenFileDialog1.ShowDialog ()
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Shell("cmd /c start /w /y C:\test.bat", vbHide)
End Sub
End Class
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub OpenFileDialog1_FileOk(ByV
End Sub
Private Sub TextBox1_TextChanged(ByVal
End Sub
Private Sub FolderBrowserDialog1_HelpR
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Open.Click
' Reset the file names for the Open File dialog box and for the Media Player.
OpenFileDialog1.FileName = ""
' Display the Open File dialog box.
OpenFileDialog1.ShowDialog
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Shell("cmd /c start /w /y C:\test.bat", vbHide)
End Sub
End Class
So you are using Shell to run the test.bat file......you can use the same method to run the extraction:
strDestDir = "C:\ExtractedFiles"
Shell("Symantecfilename.ex e /extract " & strDestdir, vbHide)
Will that do what you need?
Rob.
strDestDir = "C:\ExtractedFiles"
Shell("Symantecfilename.ex
Will that do what you need?
Rob.
My appologies, I thought you were refering to a vb script, dot net's not on my desktop yet.
zf
zf
ASKER
If I do use the shell comands. When I Use the Open file button, how do I pass the name of the file that I opened to the shell command or the batch file?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Rob
Thanks, I added my info into that and everything works.
Thanks for all the help everyone
Thanks, I added my info into that and everything works.
Thanks for all the help everyone
That's great. If that helped you solve it, please don't forget to accept an answer and close the question.
Regards,
Rob.
Regards,
Rob.
ASKER
cleaning up, my apologies Rob, forgot about this one
No problem at all, thanks for the grade.
Rob.
Rob.
Set objFso = CreateObject("Scripting.Fi
Set objWshshell = WScript.CreateObject("WScr
NewFolder = Left(YourNameFromButtun,(L
strDestdir = InputBox("Enter the shared folder name.") & "\" & NewFolder & "\" & YournameFromButton
If Not objFSO.FolderExists(strDes
objFSO.CreateFolder(strDes
End If
strCommand = "Symantecfilename.exe /extract" & strDestdir
return = objWshShell.Run(strCommand
If return <> 0 Then
MsgBox "There was an error extracting the update"
Else
MsgBox "Extraction complete"
End If
if you have problems let me know.
Posting what you already have could help smooth incorperating this into it as well.
zf