VBdotnet2005
asked on
Shell
This code run perfectly file on VS2003, but when I put in on VS2008, it does not execute the c:\pgp\myEncryptPGP.bat file. Help.
Public Sub EnCrtFiles()
Dim myDir, strfile
Dim filename, savefilename, xPGPfilename, tmpfilename
Dim cmdString
myDir = "m:\server\pgp\cust\"
cmdString = ""
For Each strfile In System.IO.Directory.GetFil es(myDir, "*.mcr")
filename = GetName(strfile) ' GetName is a sub to get the name of a file
xPGPfilename = myDir & Replace(filename, ".mcr", ".gpg")
If File.Exists(xPGPfilename) = False Then
cmdString = "c:\pgp\myEncryptPGP.bat " & strfile
Shell(cmdString)
txtFilesList.Text = "Encrypting myfile " & filename & vbCrLf & txtFilesList.Text
End If
Next
End Sub
Public Sub EnCrtFiles()
Dim myDir, strfile
Dim filename, savefilename, xPGPfilename, tmpfilename
Dim cmdString
myDir = "m:\server\pgp\cust\"
cmdString = ""
For Each strfile In System.IO.Directory.GetFil
filename = GetName(strfile) ' GetName is a sub to get the name of a file
xPGPfilename = myDir & Replace(filename, ".mcr", ".gpg")
If File.Exists(xPGPfilename) = False Then
cmdString = "c:\pgp\myEncryptPGP.bat " & strfile
Shell(cmdString)
txtFilesList.Text = "Encrypting myfile " & filename & vbCrLf & txtFilesList.Text
End If
Next
End Sub
ASKER
strfile is the path and filename to that file which needs to be encyrpted.
cmdString = "c:\pgp\myEncryptPGP.bat " & strfile > "m:\server\pgp\cust\strfil .mcr"
cmdString = "c:\pgp\myEncryptPGP.bat " & strfile > "m:\server\pgp\cust\strfil
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
error
Exception has been thrown by the target of an invocation.
Exception has been thrown by the target of an invocation.
And if you do that in DOS prompt it works ?
ASKER
In VS2003, yes . It put a myfile.gpg in "m:\server\pgp\cust\" myfile.gpg
For Each strfile In System.IO.Directory.GetFil es(myDir, "*.mcr")
filename = GetName(strfile) ' GetName is a sub to get the name of a file
xPGPfilename = myDir & Replace(filename, ".mcr", ".gpg")
If File.Exists(xPGPfilename) = False Then
cmdString = "c:\pgp\myEncryptPGP.bat " & strfile
Shell(cmdString)
txtFilesList.Text = "Encrypting myfile " & filename & vbCrLf & txtFilesList.Text
End If
Next
For Each strfile In System.IO.Directory.GetFil
filename = GetName(strfile) ' GetName is a sub to get the name of a file
xPGPfilename = myDir & Replace(filename, ".mcr", ".gpg")
If File.Exists(xPGPfilename) = False Then
cmdString = "c:\pgp\myEncryptPGP.bat " & strfile
Shell(cmdString)
txtFilesList.Text = "Encrypting myfile " & filename & vbCrLf & txtFilesList.Text
End If
Next
And using only ?
Process.Start(cmdString)
If it works in VS2003 it should also work in VS2008, even with the Shell() command. Have you checked if anything is different ?
Process.Start(cmdString)
If it works in VS2003 it should also work in VS2008, even with the Shell() command. Have you checked if anything is different ?
ASKER
I checked c:\pgp\myEncryptPGP.bat that is where it is supposed to be.
And what's the result of ?
filename = GetName(strfile)
add a msgbox after this line
msgbox(filename)
filename = GetName(strfile)
add a msgbox after this line
msgbox(filename)
ASKER
filename is the name of the file like "A45678-080808142601.mcr"
You can try Process.Start(cmdString, strfile)
But what it strfile ?