Tutorials & ManualsHow-tosLessonsMiscellaneousUsing shell() on Windows With UNC Paths

Using shell() on Windows With UNC Paths

When using the shell() function in Revolution on Windows to call a command line executable, cmd.exe will complain if the defaultFolder is a UNC path. This can occur in the following scenario:

1) Launch a Revolution application from a shared network folder.

2) Use shell() to call a command line executable.

This lesson will show you how to avoid said error message in the result.

The Error

When you launch a Revolution application the defaultFolder property is set to the folder containing the application. When you call shell() the defaultFolder is used as the starting directory. If the defaultFolder is a UNC path then cmd.exe on Windows XP (Vista doesn't seem to care) will complain.

This dialog shows 'the result' of calling a command line executable through shell() when the defaultFolder is set to a UNC path.

To avoid this error simply set the defaultFolder to a local path (i.e. C:\) before calling shell(). You probably want to restore the defaultFolder to the previous value after calling shell().

Example Script

This script demonstrates how to recreate the problem for testing purposes. Notice that in (1) the defaultFolder is set to a UNC path. This code created the dialog shown in the previous step.

If the code is changed so that the defaultFolder is "C:\" then no error appears in theCmdResult (2).

Example Of Code With the defaultFolder Set to C:\

1 Comments

Ken Ray

Just a quick note - you can turn off the additional error message info by adding a registry entry that disables the UNC checking:

get setRegistry("HKEY_CURRENT_USER\Software\Microsoft\Command Processor\DisableUNCCheck",binaryEncode("H*","01000000"),"dword")

This can be useful if you want to actually *need* to keep the current directory set to the UNC path.

If you don't want to code this yourself, you can use my 'stsSetShellUNCCheck' command (http://snipplr.com/view/9797/stssetshellunccheck/), or if you need to check if the registry has this flag turned on, you can use my 'stsIsShellCheckingForUNC' function (http://snipplr.com/view/9796/stsisshellcheckingforunc/).

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.