Hello,
I want to make my CMD command's result be written to a txt file. No problem.
But creating the txt on a network share doesn't work.
Is this regularly impossible or do I have to chose a special syntax?
...>\\192.168.0.1\testshare\log.txt doesn't work. Creating the txt on a local drive works.
Access rights for the network share are given (share rights + ntfs rights: Everybody could do everything).
TD
CMD / Batch file: Creating an output/log file on a network share doesn't work
Moderator: DosItHelp
-
- Posts: 7
- Joined: 02 Feb 2017 01:19
Re: CMD / Batch file: Creating an output/log file on a network share doesn't work
I have no problems writing to a file using a unc path. Maybe you should show us the REAL code you are using.
Also posted on SO.
http://stackoverflow.com/questions/4202 ... oesnt-work
Also posted on SO.
http://stackoverflow.com/questions/4202 ... oesnt-work
-
- Posts: 7
- Joined: 02 Feb 2017 01:19
Re: CMD / Batch file: Creating an output/log file on a network share doesn't work
Hello Squashman,
sorry - yes, after some tests I can confirm that the problem is not the CMD command generally.
I start the command remote - via WMI.
I made some tests. Result is: Make the remote system starting the the CMD command works.
But: You can't make the remote system do something on a third system!
Starting the test app on the remote system - it works. The CMD command can create the txt file on a local drive on the remote system. But when you want the txt be created on a third system it fails.
Same result:
When you make the remote system create the txt on ofe of its local drives and then make it move the txt on a third system via CMD command, it fails.
It is not a CMD/DOS/Batch problem ... it is a problem concerning WMI. It seems to be a kind of security problem.
sorry - yes, after some tests I can confirm that the problem is not the CMD command generally.
I start the command remote - via WMI.
I made some tests. Result is: Make the remote system starting the the CMD command works.
But: You can't make the remote system do something on a third system!
Starting the test app on the remote system - it works. The CMD command can create the txt file on a local drive on the remote system. But when you want the txt be created on a third system it fails.
Same result:
When you make the remote system create the txt on ofe of its local drives and then make it move the txt on a third system via CMD command, it fails.
It is not a CMD/DOS/Batch problem ... it is a problem concerning WMI. It seems to be a kind of security problem.
Code: Select all
Function funct_test()
Dim objWMIService
Dim objProcess
Dim strCMDApp, strCMDLog, strCMDFull
Dim lngReturn
Dim intPID
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer("192.168.0.5", "root\cimv2", "TEST-PC\testuser", "123456789")
strCMDApp = """C:\Program Files\testapp\testapp.exe"""
strCMDLog = """\\192.168.0.7\log\log.txt"""
strCMDFull = "cmd /von /c ""call " & strCMDApp & " &>" & strCMDLog & " echo !errorlevel!"""
Set objProcess = objWMIService.Get("Win32_Process")
lngReturn = objProcess.create(strCMDFull, Null, Null, intPID)
Set objProcess = Nothing
Set objWMIService = Nothing
Set objLocator = Nothing
End Function
Re: CMD / Batch file: Creating an output/log file on a network share doesn't work
Sounds more like a permissions issue.
-
- Posts: 7
- Joined: 02 Feb 2017 01:19
Re: CMD / Batch file: Creating an output/log file on a network share doesn't work
That's it. No CMD problem. It is WMI. You can't open a WMI session and then make another connect from the remote system to a third system. It is forbidden.