DosTips.com

A Forum all about DOS Batch
It is currently 27 Feb 2017 19:04

All times are UTC-06:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: 03 Feb 2017 04:32 
Offline

Joined: 02 Feb 2017 01:19
Posts: 7
Hello, :D

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


Top
   
PostPosted: 03 Feb 2017 07:51 
Offline
Expert

Joined: 23 Dec 2011 13:59
Posts: 3470
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


Top
   
PostPosted: 06 Feb 2017 03:20 
Offline

Joined: 02 Feb 2017 01:19
Posts: 7
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.

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



Top
   
PostPosted: 06 Feb 2017 07:28 
Offline
Expert

Joined: 23 Dec 2011 13:59
Posts: 3470
Sounds more like a permissions issue.


Top
   
PostPosted: 07 Feb 2017 02:16 
Offline

Joined: 02 Feb 2017 01:19
Posts: 7
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.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited