by LeeC at 2012-10-18 12:21:35
I wrote a sizable number of code components to perform a number of tasks around the office for the sake of automation; originally, I had them all on my local hard drive, and things were peachy keen.by nohandle at 2012-10-19 03:36:05
Then I had folks ask if they could run my scripts themselves. "Certainly," I said.
Rather than copy the code to each person’s system, it makes sense to store it locally on a network drive. As background, a lot of what happens is REST calls using CURL to a cloud-hosted application. The problem began to appear:
First, to call curl.exe, I’m creating a string called $URL which looks like (for example) "‘-X PUT --data @SetReporter.json https://mycompany.jira.com/rest/api/lat … e/’+$Issue and then
cmd /c "curl.exe $URL"
I had to do this because several hours of trial and error convinced me that I couldn’t effectively use the ampersand with a string, and I had to have a string to pass to CURL. However, now that it’s on a shared drive, I’m getting
"CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory."
Second, and it’s related, I can’t call a java jar file using a batch file, for the same reason. I can’t find anything that suggests I can pass parameters to CMD to change the current directory (nor am I certain I could do so and invoke an executable on a shared drive.)
maybe i am oversimplifying the problem but:by figueroa2david at 2012-10-23 15:57:56
The cmd does not support \unc\paths only m:\apped\drives.
map the drive as a letter and retest
btw invoking the curl.exe directly from powershell is not possible? &curl "argument argument" ?
or in powershell 3 &curl --% argument argument
The easiest way to do this with a cmd.exe environment is to use a pushd entry.
Pushd will change directories, including drive letters, and if you supply a UNC path, it will automatically map a drive, starting with z: and working backwards.
In your case you might do something like create a batch file and use it…
cmd.exe /c ‘mybatch.cmd "$URL"’
mybatch.cmd would contain: