English 中文(简体)
Opening a Web URL with a TCL App that is Sitting on a Network Drive
原标题:

I just finished a TCL Db App that includes a featrue to open web page URLs. My code is as follows ($adr is the url):

eval exec [auto_execok start] "" [list $adr]

This code works fine on my Windows workstation. However, after I placed the app on a network drive I receive the following error:

DriveShareFolderSubfolder CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory.

The web page still opens, but I still get the TCl error.

Does soemone know a better way to open URLs with TCL in a server or network environment?

Thank you,

DFM

问题回答

The message displayed is actually being generated by CMD.EXE, the Windows command interpreter, when Tcl tries to execute the URL that you specify. It generates that warning message to stderr when it is started with a current working directory that is set to a network path.

Two other things you could have tried:

  1. run exec with -ignorestderr. This will cause this particular warning message (and any other messages/errors written to stderr to not produce an error in Tcl). When you wrap your code with catch, you are basically ignoring this and any other errors, which may not be ideal.
     eval exec -ignorestderr [auto_execok start] "" [list $adr]
    
  2. set your working directory to another path prior to the exec, which is what CMD.EXE is doing after it prints out that warning:
     cd $::env(TEMP)
     eval exec [auto_execok start] "" [list $adr]
    

Of course, be careful about running arbitrary commands and arguments that come from untrusted inputs, or someone might use your application as a backdoor to run malicious commands.





相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签