Blog du Tristank

So terrific that 3 of 4 readers rated it "soporific"

WshShell.Run and Long File Names

I hit this the other day – when using the Wsh Shell object’s Run method in VBScript, passing a long filename (LFN) tends to truncate, so:

set oShell = CreateObject(“Wscript.Shell”)
oShell.Run “C:\Documents and Settings\Tester\Desktop\TestFile.Doc”

will fail with a message similar to “Cannot find C:\Document”.

Simple solution: Double-escape the double quotes:

oShell.Run “””C:\Documents and Settings\Tester\Desktop\TestFile.Doc”””