Hello guys
i am trying to write a program that executes a shell program like
oracle Export, as you know for that kind of programs parameters is
important, for example i have to do it with userid and Password
also i want to change a password for example when a user typed my
programs name in cmd and add userid and password and db_name, i want to
change that password and send it to oracle
i tried with shellexecute() but i couldnt use lpParameters
how can i use lpParamaeters
somebody can help me ! this is urgent.
my email address is info@fatihnayebi.com or
f.nayebi@gmail.com
this is my program
Module Module1
Dim extra As String
Sub Main()
ShellExec()
End Sub
Public Declare Function ShellExecute _
Lib "shell32.dll" _
Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) _
As Long
Sub ShellExec()
Dim strFile As String
Dim strAction As String
Dim lngErr As Long
Dim Usr_param As String
Dim Pass_param As String
Dim parametre As String
Dim lpparameteres As String
Dim parfile As String
extra = "x"
parfile = "jksdfkasj"
Console.WriteLine("Please enter your user name ")
Usr_param = Console.ReadLine
Console.WriteLine("Please enter your password")
Pass_param = Console.ReadLine()
Pass_param = Pass_param + extra
'parametre = "userid=" & Usr_param & "/" & Pass_param & "@symphony " & parfile
strFile = "R:\oracle\product\10.1.3\Db_1\BIN\exp"
strAction = "OPEN"
lngErr =ShellExecute(0, strAction, strFile, parametre, "", 0)
End Sub
End Module

How can i use lpParameters in Shellexecute()?
Sarge1
the problem is, i have to prepare a command line executable that will accept parameters
something like this:
R:\oracle\product\10.1.3\Db_1\BIN\expUserid=Uusername/(Ppassword & X)@Sservername parfile="Location"
but the important point is how can i change the password.
in oracle when user want to connect to program if he/she uses for example a for password,
as a dba u can change it to a & Const for example ax becuase maybe u dont want him to know the password for direct access to database for example in PL/SQL.
then the probelm is writing a program that user can type it in cmd with parameters but this program will execute a string like above,
it is also includes connection string as u see
by the way also i tried it with this:
-----------------------------------------------------------
Sub Main()
Dim startInfo As New ProcessStartInfo("R:\oracle\product\10.1.3\Db_1\BIN\exp")
startInfo.WindowStyle = ProcessWindowStyle.Minimized
startInfo.Arguments = "-Ppassword -Uusername -Sservername"
Process.Start(startInfo)
End Sub
-----------------------------------------------------------
but i didnt know how can i send that arguments to prepare that string.
Didymus
Are you looking for something like this
Dim userName As String = "user"
Dim password As String = GetThePasswordFromSomewhere()
...
startInfo.Arguments = "-P" & password & " -U" & userName & " -Sservername"
You can also look at the String.Format method.
NewbieDude
Sure, Your talking about command line arguments. Create a Console Application and place this code in there and then call it using the line
ConsoleApplication1 foo bar test
and you will say
3 arguments
foo
bar
test
Module Module1
Sub Main(ByVal CmdArgs() As String)
Dim i As Integer
Console.writeline ( UBound(CmdArgs) + 1 & " arguments")
For i = 0 To UBound(CmdArgs)
Console.WriteLine(CmdArgs(i))
Next i
End Sub
End Module
All you going to have to do is parse those arguments into what they are and how they are used. Are you going to use named arguments or positional arguments.
User=foo pwd=bar
or
foo bar
when the first item is always the user and the second is always to password.
Vitaly S.
is it possible to write a code like that but in cmd user will be able to enter his userid and password after the name of the program
for example this program's name will be Exp.exe
when user want to execute it he will type in cmd like this:
exp -uUsername -pPassword -sServername
but program will make another string like this:
"R:\oracle\product\10.1.3\Db_1\BIN\exp userid=Username/Password&Const@Servername parfile=R:\oracle\oradata\exp1013\parfile.txt"
Const is for example X
and will execute it
if i want to take username and password in another way it will be wrong,
because also i want to schedule this program in schedule tasks of windows.
--------------------------------------------------------------------------------------------
Sub Main()
Dim userName As String
Dim password As String
Dim serverName as string
'problem is i dont know how can i use tis parameters inputed from command line
Dim startInfo As New ProcessStartInfo("R:\oracle\product\10.1.3\Db_1\BIN\exp")
startInfo.WindowStyle = ProcessWindowStyle.Minimized
'startInfo.Arguments = "-Ppassword -Uusername -Sservername"
startInfo.Arguments = "userid=" & userName & "/" & password & "x"& "@" &
serverName & "" &"parfile=" & "R:\oracle\oradata\exp1013\parfile.txt"
Process.Start(startInfo)
End Sub
---------------------------------------------------------------------------------------------
PocketPC Coder
First of all, why are you using ShellExecute at all and not System.Diagnostics.Process.Start
I'm not sure I understand the problem. What exactly was it you couldn't do with the lpParameters parameter