Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to call a cmd (let's call it x.cmd) on a remote server. The x.cmd will return a log file in a log folder. Problem is this log folder in x.cmd doesn't have an absolute path (just a relative path like log\ ) so if I do

wmic /node:server process call create "serverpath\x.cmd"

it will process x.cmd but save the log file into system32 or somewhere I assume. If I add cd /d %~dp0 into x.cmd then it works fine. Unfortunately I am not allowed to touch x.cmd. Just wondering is there any other way to call the x.cmd without modifying it and also the correct output. Thanks.

JS

share|improve this question
    
If you have the path to x.cmd, why can't you use the server path and the relative path to the log folder to get what you want ? –  leo21 May 24 '13 at 6:10
    
Yes I can,the problem I have now is nothing will be in that log folder as log folder path in x.cmd is not absolute. this is the previous question I asked. stackoverflow.com/questions/16708633/… –  user2381130 May 24 '13 at 6:22
    
If it is not absolute, then I am assuming it changes on every run. Is the path provided by the user when executing the x.cmd –  leo21 May 24 '13 at 6:28
    
so if I run it locally on that server it is fine, but cannot call it remotely. path is in x.cmd and given by the client so I am not allowed to touch it. –  user2381130 May 24 '13 at 6:33
    
are you allowed to create a .bat file on the remote machine (and then delete it) only to get the absolute path? –  npocmaka May 24 '13 at 6:56
add comment

migrated from stackoverflow.com May 24 '13 at 9:37

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 1 down vote accepted

http://msdn.microsoft.com/en-us/library/windows/desktop/aa389388(v=vs.85).aspx

the second parameter that wmic process accepts is the directory.You can try this:

wmic /node:server process call create "serverpath\x.cmd" , "c:\path\to\x.cmd"

or

wmic /node:server process call create CommandLine="serverpath\x.cmd" CurrentDirectory="c:\path\to\x.cmd"

You might need one additional call of net share on the remote machine to get exact location of the directory. something like this:

wmic /node:server process call create "cmd /c \"net share ^> \\\\myshare\\server.shares.txt \""
share|improve this answer
1  
process call create "cmd /c cd /d PATH_TO_X_CMD & PATH_TO_X_CMD\x.cmd" solved my problem! thanks everyone! –  user2381130 May 28 '13 at 1:22
    
Clever solution, user2381130, thanks! –  twasbrillig Mar 26 at 20:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.