WMIC get Executable path in batch file
Hi,
I would like to get a execution path of a process using batch file. I wrote,
FOR /F "usebackq skip=1 tokens=* delims==" %%f IN (`wmic process where "ProcessID=8000" get ExecutablePath`) DO echo %%f
This command gives the execution path. But i cant set the value in a variable. Set command also fails here.
Please anyone help me.
Hi,
I would like to get a execution path of a process using batch file. I wrote,
FOR /F "usebackq skip=1 tokens=* delims==" %%f IN (`wmic process where "ProcessID=8000" get ExecutablePath`) DO echo %%f
This command gives the execution path. But i cant set the value in a variable. Set command also fails here.
Please anyone help me.
Here you go:
@echo off
FOR /F "delims==" %%f IN ('wmic process where "ProcessID=3940" get ExecutablePath ^| find "\"') do set Exe=%%f
echo %Exe%
Similar Messages
-
F4 Help to get the path for a File source directory
There are numerous function modules for browsing a particular file in desktop and getting the file path (including the fine name) , like F4_FILENAME , KD_GET_FILENAME_ON_F4 , WS_FILENAME_GET etc. But can anyone tell me how to fetch only the directory path to the field were the F4 help is given. Actually the filename has to come in some other field in the selection screen. Is there separate funtion modules for these OR will changing parameters in the above function modules work?
Pls Help....
Also are there function modules for providing F4 help for getting the path to a file in application directory?Try this method CL_GUI_FRONTEND_SERVICES.
It is a Global CLASS which is having different methods for different purposes
see the documentation of it and use the methods of it
see
CL CL_GUI_FRONTEND_SERVICES
Short Text
Frontend Services
Functionality
The class CL_GUI_FRONTEND_SERVICES contains static methods for the following areas:
File functions
Directory functions
Registry
Environment
Write to / read from clipboard
Upload / download files
Execute programs / open documents
Query functions, such as Windows directory, Windows version, and so on
Standard dialogs (open, save, directory selection)
Example
Determine the temp directory on your PC:
DATA: TEMP_DIR TYPE STRING.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_TEMP_DIRECTORY
CHANGING
TEMP_DIR = TEMP_DIR
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2.
IF SY-SUBRC 0.
Error handling
ENDIF.
flush to send previous call to frontend
CALL METHOD CL_GUI_CFW=>FLUSH
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2
OTHERS = 3.
IF SY-SUBRC 0.
Error handling
ENDIF.
WRITE: / 'Temporary directory is:', TEMP_DIR.
Notes
The class CL_GUI_FRONTEND_SERVICES is based on the Control Framework. See the documentation for more information, in particular on CL_GUI_CFW=>FLUSH which must be called after many CL_GUI_FRONTEND_SERVICES methods.
Migration Information
The old file transfer model was based on function modules of the function group GRAP. The old features have been replaced by the class CL_GUI_FRONTEND_SERVICES. The following list contains the old function modules (italic) and the new methods (bold) that replace them:
CLPB_EXPORT
CLIPBOARD_EXPORT
CLPB_IMPORT
CLIPBOARD_IMPORT
DOWNLOAD
GUI_DOWNLOAD, dialog replaced by FILE_SAVE_DIALOG
PROFILE_GET
No replacement, use REGISTRY_* methods instead
PROFILE_SET
No replacement, use REGISTRY_* methods instead
REGISTRY_GET
REGISTRY_GET_VALUE, REGISTRY_GET_DWORD_VALUE
REGISTRY_SET
REGISTRY_SET_VALUE, REGISTRY_SET_DWORD_VALUE
UPLOAD
GUI_UPLOAD, dialog replaced by FILE_OPEN_DIALOG
WS_DDE
Obsolete: This function is no longer supported.
SET_DOWNLOAD_AUTHORITY
Obsolete: This function is no longer supported.
WS_DOWNLOAD
GUI_DOWNLOAD
WS_DOWNLOAD_WAN
Obsolete: This function is no longer supported.
WS_EXCEL
Obsolete: This function is no longer supported.
WS_EXECUTE
EXECUTE
WS_FILENAME_GET
FILE_SAVE_DIALOG, FILE_OPEN_DIALOG
WS_FILE_ATTRIB
FILE_SET_ATTRIBUTES, FILE_GET_ATTRIBUTES
WS_FILE_COPY
FILE_COPY
WS_FILE_DELETE
FILE_DELETE
WS_MSG
Obsolete: This function is no longer supported.
WS_QUERY
CD (current directory)
DIRECTORY_GET_CURRENT
EN (read/write environment)
ENVIRONMENT_GET_VARIABLE
ENVIRONMENT_SET_VARIABLE
FL (determine file length)
FILE_GET_SIZE
FE (check if file exists)
FILE_EXIST
DE (check if directory exists)
DIRECTORY_EXIST
WS (determine Windows system)
GET_PLATFORM
OS (operating system)
GET_PLATFORM
WS_UPLDL_PATH
Obsolete: This function is no longer supported.
WS_UPLOAD
GUI_UPLOAD
WS_VOLUME_GET
Obsolete: This function is no longer supported.
Reward points if useful. -
hi
i wanted to get the path of the file.i just need to get the path not the file.i wanted to do using swing.may be filechooser or tree. but i need to know how could i get tht if i know the exampl for this it would be useful for me ..i need it in a way that like in windows explore.. so tht if i get the path of it i can use that in another class file.
anyway i am looking out in File class also. -
how 2 get the path of a file Using jsp
i have tried getPath...but i'm geting the error
The method getPath(String) is undefined for the type HttpServletRequest
any idea how 2 get the path of a fileYou need ServletContext#getRealPath().
API documentation: http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String) -
How 2 get the path of a file Using jsp
how 2 get the path of a file Using jsp
i have tried getPath...but i'm geting the error
The method getPath(String) is undefined for the type HttpServletRequest
any idea how 2 get the path of a fileYou need ServletContext#getRealPath().
API documentation: http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String) -
How do i get the path of the file selected for opening in JFileChooser
hi
I need to get the path of the file selected for opening or saving in the JFileChooser dialog box.Is there any method available.if not how do i get that?
Thanks and Regards
Saminathan.don't know if its the best/only way, but you could use the getSelectedFile() method in JFileChooser which returns a file and then use the getAbsolutePath() file method
-
How to call/Execute a dos batch file via LAN
Hello,
Can i execute remotely dos batch files?
I have to execute bat file via LAN ex
IP\dir\batfile.bat from abap code, is that possible?
thanks in advance,
MichalHi,
Use CL_GUI_FRONTEND_SERVICES=>EXECUTE method to run any application in your case batch file..
The batch file you are trying to run should be accessible on presentation system i.e. user's machine.
Regards,
Vishal -
Getting absolute path of a file running in remote machine
Hi,
I want to get the absolute path of a file that will be created in the remote server. Inside a directory XYZ in remote machine, the file will be created and the remote machine's address is xxx.xx.x.x. I have used the following snippet
File f=new File(Filename);
f.getAbsolutePath();
Now, in the output am getting the absolute path of the file as d:/XYZ/Filename. Is there any way to get the output as xxx.xx.x.x/XYZ/FileName ? Can someone please suggest why the server details are not fetched and instead the directory name is fetched.
I am running the program to get absolute path of a file in my remote machine. and for accessing that remote file from my machine, I use xxx.xx.x.x/XYZ/FileName.
Thanks in advance.I'm going to take it a step further and guess at what the OP is going to say next.
On host w.x.y.z there's a file /a/b/share/some_dir/file.txt.
Host w.x.y.z is sharing the /a/b/share/ directory as SHARE.
Client mounts \\w.x.y.z\SHARE as D:, so that he sees D:/some_dir/file.txt.
OP now wants to know not just that D:/some_dir/file.txt is \\w.x.y.z\SHARE/some_dir/file.txt, but also wants to know that on w.x.y.z, SHARE corresponds to /a/b/share.
@OP: If that's what you want, forget it. Part of the premise of file common drive/directory sharing protocols is that the client does not know or care and does not need to know or care what the absolute path is on the serving host. It's none of his business. -
Error Executing Interface using batch file
Hi All,
I am currently using a batch file to execute particular interface from remote location.
The steps I used before executing are
1. I have created the scenario for the interface.
2. I have used this in the batch file to run the interface.
3. I have mapped the network drive to get the startscen.bat file.
The error which was generated was (Z - mapped server name)
Z:\ODI\oracledi\agent\bin>startscen.bat Sample_interface 001 Sample_context -NAME=Sample_AGENT
OracleDI: Starting scenario SAMPLE_INTERFACE 001 in context SAMPLE_CONTEXT .
2011-10-11 10:06:45.404 ERROR ODI-1132 Agent SAMPLE_AGENT encountered an warning: O
DI-1419: Warning connecting to Agent SAMPLE_AGENT: JDBC connection error occurs whi
le connecting to the work repository WORKREP.
ODI-1419: Warning connecting to Agent SAMPLE_AGENT: JDBC connection error occurs wh
ile connecting to the work repository WORKREP.
Caused By: oracle.odi.core.config.WorkRepositoryResourceFailureException: org.sp
ringframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connecti
on; nested exception is java.sql.SQLException: Exception occurred while getting
connection: oracle.ucp.UniversalConnectionPoolException: Cannot get Connection f
rom Datasource
at oracle.odi.core.repository.Repository.getWorkRepository(Repository.ja
va:150)
at oracle.odi.core.OdiInstance.createWorkRepository(OdiInstance.java:512
at oracle.odi.core.OdiInstance.<init>(OdiInstance.java:565)
at oracle.odi.core.OdiInstance.createInstance(OdiInstance.java:529)
at oracle.odi.StartScen.main(StartScen.java:163)
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not
get JDBC Connection; nested exception is java.sql.SQLException: Exception occurr
ed while getting connection: oracle.ucp.UniversalConnectionPoolException: Cannot
get Connection from Datasource
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(Dat
aSourceUtils.java:82)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:
524)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:58
8)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:61
3)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:64
5)
at org.springframework.jdbc.object.SqlQuery.execute(SqlQuery.java:111)
at org.springframework.jdbc.object.SqlQuery.execute(SqlQuery.java:121)
at org.springframework.jdbc.object.SqlQuery.execute(SqlQuery.java:136)
at oracle.odi.core.repository.support.RepositoryUtils$RepositoryInfoSour
ce.loadRepositoryInfo(RepositoryUtils.java:179)
at oracle.odi.core.repository.support.RepositoryUtils.loadWorkRepository
Info(RepositoryUtils.java:379)
at oracle.odi.core.repository.Repository.getWorkRepository(Repository.ja
va:148)
... 4 more
Caused by: java.sql.SQLException: Exception occurred while getting connection: o
racle.ucp.UniversalConnectionPoolException: Cannot get Connection from Datasourc
e
at oracle.odi.jdbc.datasource.LoginTimeoutDatasourceAdapter.doGetConnect
ion(LoginTimeoutDatasourceAdapter.java:133)
at oracle.odi.jdbc.datasource.LoginTimeoutDatasourceAdapter.getConnectio
n(LoginTimeoutDatasourceAdapter.java:62)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(D
ataSourceUtils.java:113)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(Dat
aSourceUtils.java:79)
... 14 more
Caused by: java.sql.SQLException: Exception occurred while getting connection: o
racle.ucp.UniversalConnectionPoolException: Cannot get Connection from Datasourc
e
at oracle.ucp.util.UCPErrorHandler.newSQLException(UCPErrorHandler.java:
541)
at oracle.ucp.jdbc.PoolDataSourceImpl.throwSQLException(PoolDataSourceIm
pl.java:587)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.j
ava:668)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.j
ava:613)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.j
ava:607)
at oracle.odi.jdbc.datasource.LoginTimeoutDatasourceAdapter$ConnectionPr
ocessor.run(LoginTimeoutDatasourceAdapter.java:217)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:44
1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: oracle.ucp.UniversalConnectionPoolException: Cannot get Connection fr
om Datasource
at oracle.ucp.util.UCPErrorHandler.newUniversalConnectionPoolException(U
CPErrorHandler.java:421)
at oracle.ucp.util.UCPErrorHandler.newUniversalConnectionPoolException(U
CPErrorHandler.java:389)
at oracle.ucp.jdbc.DriverConnectionFactoryAdapter.createConnection(Drive
rConnectionFactoryAdapter.java:133)
at oracle.ucp.common.UniversalConnectionPoolImpl$UniversalConnectionPool
Internal.createOnePooledConnectionInternal(UniversalConnectionPoolImpl.java:1570
at oracle.ucp.common.UniversalConnectionPoolImpl$UniversalConnectionPool
Internal.access$600(UniversalConnectionPoolImpl.java:1378)
at oracle.ucp.common.UniversalConnectionPoolImpl.createOnePooledConnecti
on(UniversalConnectionPoolImpl.java:445)
at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionWithout
CountingRequests(UniversalConnectionPoolImpl.java:302)
at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnection(Univer
salConnectionPoolImpl.java:129)
at oracle.ucp.jdbc.JDBCConnectionPool.borrowConnection(JDBCConnectionPoo
l.java:119)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.j
ava:655)
... 9 more
Caused by: java.sql.SQLException: ORA-01017: invalid username/password; logon de
nied
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.ja
va:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:1
33)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:206)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:406)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
at oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthentica
te.java:799)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:368)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:
508)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtensio
n.java:33)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510)
at oracle.ucp.jdbc.DriverConnectionFactoryAdapter.createConnection(Drive
rConnectionFactoryAdapter.java:129)
... 16 more
Thank you,
Regards
RavHi All,
Please update if any encountered a similar error.
Thank you,
Regards
Rav -
Help needed in executing a remote batch file
I need to execute a batch file which is located on a remote machine through my machine. I have no idea to go about with. Please can someone help me out with can be used to execute the remote bat file. I am at present using Runtime.exec() to execute it on my machine.. But i cant use it to execute teh bat file on teh remote machine.Please help
Below is an example server that would run on the remote host. You can connect to it using telnet from DOS prompt, it takes a Y/N to run your command in the cmd variable. I haven't included code for a client as it's really not needed for the example below.
Change the cmd and port variables to what you need. You may need to setup firewall rules to allow your chosen port.
Once it's running, you can test it by using "telnet localhost 1234" on your machine, localhost would obviously become the remote computer's hostname or IP.
I am incredibly new to Java (using the forums to learn bits), so excuse any bad coding practises, I'm sure people will point them out.
Keep in mind that this is totally insecure, so if you're using it on an untrusted network, you may want to look into encryption and providing some kind of password authentication, that, for the moment is out of my league.
Screenshot here.
import java.io.*;
import java.net.*;
class RemoteServer {
public static int port = 1234; // Port to listen on
public static String cmd = "C:\\Test.bat"; // Command to run
public static void main(String[] args)
System.out.println("Waiting for connection...");
try {
/* If you want the server to run forever, uncomment the while
loop */
// while (true)
startServer();
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
/* Starts the server */
private static void startServer() throws IOException
ServerSocket server = null;
Socket client = null;
String input;
try {
server = new ServerSocket(port);
} catch (IOException e) {
System.err.println("Unable to list on port " + port);
System.exit(1); // Can't listen, nothing else to do
try {
client = server.accept();
System.out.println("Client connected... awaiting Y/N");
} catch (IOException e) {
System.err.println("Unable to accept connection.");
System.exit(1);
PrintWriter out = new PrintWriter(client.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(
client.getInputStream()));
out.println("You are connected, ready to launch command: <y/n>");
while ((input = in.readLine()) != null)
if (input.equalsIgnoreCase("y"))
Runtime rt = Runtime.getRuntime();
rt.exec(cmd);
out.println("Command executed... disconnecting.");
System.out.println("Command executed... disconnecting client.");
break;
} else if (input.equalsIgnoreCase("n")) {
break;
} else {
out.println("Please enter Y/N.");
out.close();
in.close();
client.close();
server.close();
} -
How to run a project which gets parameters from a batch file
Hello all,
I use to run a program, which gets parameters only by interactive mode, using a batch file as you can see below:
# myprogram < batchfile.txt
Now, I'm updating its code by SunStudioExpress IDE and I'd like to run it from the batchfile. I have noticed that the project properties window has the option run -> arguments, however this program doesn't accept arguments this way and for changing it, I'd have a hard job.
Does someone know how to run this project and to get its parameters from batchfile?
Regards,
GlauberAh, it appears that when you run the project, "<" is passed as one of the arguments and is not treated as input redirection.
Sorry, it looks like it is not possible to do the redirection; and it looks like a bug to me. Could you please file it through bugs.sun.com? It shouldn't take long as the problem is evident now. -
when I write to a file in the actuel directory,
e.g fw = new FileWriter("file.txt");
how I can get the absolute path of this file? (e.g. C:\dir\file.txt)
thanks stnCaptain Obvious says ..... File.getAbsolutePath();
Thank you, Captain Obvious. -
How could I have a VI execute a DOS batch file?
I need to update the PC's hardware timeclock and the Windows clock via a VI front panel. If I can update hardware and windows timeclocks from a DOS prompt (TIME/NEW TIME), is there a way to provide a LV interface for the same operation? If a VI could run a DOS batch file, having the operator enter a new time in a DOS prompt window is the next best thing.
Thanks,
Jeff Bledsoe
Jeffrey Bledsoe
Electrical Engineertst wrote:
The syntax is that of the operating system.
Have you tried right clicking the VI and selecting Help?
I found the online example by selecting help. I'm using LV 5.1 and I've noticed that offline help is not as detailed as it is with LV 7 Student Edition (I have student edition at home).
In my latest attempts, I have the string "command.com /c time" wired to the command line input of system exec.vi. I get the dos prompt and a request for a new time.
To avoid the operator having to enter the time in the DOS window, I tried passing carriage returns and a time update value in the command line input. It didn't work. Do I have to add a system exec.vi for each command line entry and concatenate the vi's somehow?
Thanks,
Jeff
Jeffrey Bledsoe
Electrical Engineer -
Getting absolute path of a file in a webapp without using servlet/JSP
Hi all,
I need a small clarification. Is it possible to reterive the absolute path of a file present in a tomcat web application without using Servlet/JSP. I have a normal java class which uses this file to read the configuration parameters. I like to know whether I need to create a seperate servlet which will read the parameters from web.xml.Hi all,
I need a small clarification. Is it possible to
reterive the absolute path of a file present in a
tomcat web application without using Servlet/JSP. What if the file is in a WAR? What do you do then?
I
have a normal java class which uses this file to
read the configuration parameters. There are other, better ways to do this.
I like to know
whether I need to create a seperate servlet which
will read the parameters from web.xml.What do you really want it for? You shouldn't need an absolute path. Use the class loader to get an InputStream.
% -
How to get full path of a file uploaded using file control on a jsp ?
Hi all...
I have a jsp on which i am using a file element (input type="file") to upload files present on the physical file system.. Thats working fine.. But i want to retrieve the full path of the file uploaded for further computation.
What are the possible ways which can give me the full path ?? (e.g. "D:\data\text\Output.txt" )
Thanks all for attending the question..
Regards
PrasadSome browsers send the full path. Some do not.
You can not affect this in any way shape or form.
All you can count on receiving is a filename - no path information.
So you will have to have some other way for the user to pass along this information.
If they are uploading to a "remote web site" they could specify a folder to put the uploaded file in.
You could classify it and put all image files in "images" and all script files in "scripts" etc etc by default, and let the user deal with it in their own HTML.
Hope this helps,
evnafets
Maybe you are looking for
-
Is it possible to run sub vi and main vi at same time from startup?
Is it possible to run both my main vi and my two sub vi`s from startup, all of them continuously? I have to sub vi`s that are supposed to take in measurements from two different instruments continuously. I manage to make a program where I can open up
-
AP Credit Memo Without Outgoing Excise Invoice
Hi , When we create an A/P Invoice for an excise item ,and then when we raise an A/P credit memo for the same .. Automatically an Outgoing Excise Invoice is created ...Now because of this the series of the outgoing excise invoice , which is creat
-
Why do app downloads time out? iTunes 10.6.3.25
I have VZW FiOS, running iTunes 10.6.3.25 on Windows 7 and everytime I download app updates to iTunes they time out - it does not matter if there is 1 app, 3, 30, or more - I find I'm constantly clicking on dialog boxes and the "resume all" button in
-
Nokia 6124 classic wont work with the USB Data Cab...
Hi all, I'm trying to connett Nokia 6124 classic but its not working with the USB Data Cable. Is there a way to fixing it yourself? Thanks Jonathan 'Jonnie'
-
Gents currently using SCM4.1, we have a situation whereby more than 1 R/3 system is connected to the APO system. However in the near future the product numbers will be aligned for each R/3 system. therefore product 1 will exist in each R/3 system,