Sign in to follow this  
Followers 0
Gene

Having a problem with FileGetShortName()

18 posts in this topic

$sHelpFilePathName = FileGetShortName(@ScriptDir & "\StopLightTimerHelp.pdf" )
$sCmdLine = @ComSpec & " /c " & "start " & $sHelpFilePathName
MsgBox(0,"Information", "$sCmdLine = " & $sCmdLine)
ClipPut($sCmdLine)
Run($sCmdLine, "", @SW_MINIMIZE)

When this code is run in one location the content of $sCmdLine is:

C:\WINNT\system32\cmd.exe /c start K:\ETSDOC~1\TOASTM~1\Timer\BU60E3~1\STOPLI~1.PDF

This is exactly as expected and the .PDF is displayed

When run in another location the content of $sCmdLine is:

C:\WINNT\system32\cmd.exe /c start K:\Local\Prog\StopLight Timer\StopLightTimerHelp.pdf

Here I get an error to the effect that the file K:\Local\Prog\StopLight can't be found.

Suggestions please...

Gene


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites



$sHelpFilePathName = FileGetShortName(@ScriptDir & "\StopLightTimerHelp.pdf" )
$sCmdLine = @ComSpec & " /c " & "start " & $sHelpFilePathName
MsgBox(0,"Information", "$sCmdLine = " & $sCmdLine)
ClipPut($sCmdLine)
Run($sCmdLine, "", @SW_MINIMIZE)

When this code is run in one location the content of $sCmdLine is:

C:\WINNT\system32\cmd.exe /c start K:\ETSDOC~1\TOASTM~1\Timer\BU60E3~1\STOPLI~1.PDF

This is exactly as expected and the .PDF is displayed

When run in another location the content of $sCmdLine is:

C:\WINNT\system32\cmd.exe /c start K:\Local\Prog\StopLight Timer\StopLightTimerHelp.pdf

Here I get an error to the effect that the file K:\Local\Prog\StopLight can't be found.

Suggestions please...

Gene

Another work-around is to double qoute the File in stead of using the shortname:

$sCmdLine = @ComSpec & " /c " & 'start "' & $sHelpFilePathName & '"'


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Another work-around is to double qoute the File in stead of using the shortname:

$sCmdLine = @ComSpec & " /c " & 'start "' & $sHelpFilePathName & '"'

Why you want to use CMD? Avoiding to state the path to the Viewer exe? Perhaps this is what you want:

$oWSH = ObjCreate("Wscript.Shell")

$oWSH.run(@ScriptDir & "\StopLightTimerHelp.pdf")

HTH, Reinhard

Edited by ReFran

Share this post


Link to post
Share on other sites

would another location be a cdrom?

Lar.

Thanks for the reply.

No, they're both on the same hard drive. I forgot to mention that I'm usin beta .84.

Gene


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

Another work-around is to double qoute the File in stead of using the shortname:

$sCmdLine = @ComSpec & " /c " & 'start "' & $sHelpFilePathName & '"'

Thanks for the reply.

I tried to use the short name because I had no success with double quoting. Does that mean that the short file name function is not reliable? It appears not to be, in one HD location it works and in another location on the same drive it doesn't, or is there something I'm not seeing?

The environment is Win2K Pro sp4 256MB AutoIt beta .84.

Gene


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

Why you want to use CMD? Avoiding to state the path to the Viewer exe? Perhaps this is what you want:

$oWSH = ObjCreate("Wscript.Shell")

$oWSH.run(@ScriptDir & "\StopLightTimerHelp.pdf")

HTH, Reinhard

Thanks for the reply.

No, avoiding the 'Long" path to the PDF.

I'll try your suggestion.

That has pretty much the same problem in both locations, it opened an Explorer window on the following path K:\ETS. Since that path doesn't exist, the window was empty. I also tried enclosing the command line in quotes as below, but that didn't work either.

$oWSH = ObjCreate("Wscript.Shell")

$oWSH.run("'" & @ScriptDir & "\StopLightTimerHelp.pdf" & "'")


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

Another work-around is to double qoute the File in stead of using the shortname:

$sCmdLine = @ComSpec & " /c " & 'start "' & $sHelpFilePathName & '"'

I tried double quoting again using your syntax above, In fact I just pasted it into my script. It still didn't work.

Gene

Thanks for the reply.


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

I tried double quoting again using your syntax above, In fact I just pasted it into my script. It still didn't work.

Gene

Thanks for the reply.

It sounds like a local problem on your PC. Also if you wanted to avoid it please state your full path.

Keep in mind that there is also a limitation in the length of a path. You may try to shorten the long pathname with an CMD substitute command (something like subst V: D:\blabla\.....

HTH, Reinhard

Share this post


Link to post
Share on other sites

It sounds like a local problem on your PC. Also if you wanted to avoid it please state your full path.

Keep in mind that there is also a limitation in the length of a path. You may try to shorten the long pathname with an CMD substitute command (something like subst V: D:\blabla\.....

HTH, Reinhard

This will be installed on other people's PCs, I won't have control of the path. I would never setup substitutions on someone elses's PC. Besides which, the FileGetShortName() function succeeds on a long path and appears to fail on a shorter path. Look again at the first post in this thread.

I wonder what sort of local problem would cause the FileGetShortName() function to fail in that manner.

Thanks for the reply.

Gene


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

your file StopLightTimerHelp.pdf must exist during the execution of the command in order for FileGetShortName to work


The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!"

Share this post


Link to post
Share on other sites

your file StopLightTimerHelp.pdf must exist during the execution of the command in order for FileGetShortName to work

That is a good point. It does.


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Well, it is possible to disable short file names on NTFS volumes B)

A lot of good info can be found here (scroll down a bit for the pertinent info, but the full page is an interesting read)

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Well, it is possible to disable short file names on NTFS volumes B)

A lot of good info can be found here (scroll down a bit for the pertinent info, but the full page is an interesting read)

The thing that is hard to understand is that both the success and apparent failure occurr in different directory trees on the same had drive. The success is with the path with more levels and longer folder names than the failure location. Thanks for the link to more information. I'll look at it later today when I'm functional.


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

The behavior of FileGetShortName is to return the path that it was given if the underlying function call to GetShortPathName fails.

It would be interesting to see what GetLastError returns immediately after the failure.

$ourError = DLLCall("kernel32.dll","int","GetLastError")

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

Hi,

I am not surprised how much trouble there is "getting the quotes right"

I have settled my problem by always using this type of structure to keep the quotes honest;

If StringInStr($File, " ") Then $File = '"' & $File & '"'

If StringInStr($AnswerFile, " ") Then $AnswerFile = '"' & $AnswerFile & '"'

$Command = @ComSpec & " /c " & 'FINDSTR '& $Switches &' '& $File &'>'&$AnswerFile

$DosFINDSTRReturn=RunWait($Command, @SystemDir, @SW_HIDE)

If you really look at "double quotes", they sometimes need to be triple etc.

i would be interested to hear if this solves the problems people have with the quotes, or if you really believe there is some other problem?

Best, randall

Share this post


Link to post
Share on other sites

The behavior of FileGetShortName is to return the path that it was given if the underlying function call to GetShortPathName fails.

It would be interesting to see what GetLastError returns immediately after the failure.

$ourError = DLLCall("kernel32.dll","int","GetLastError")
As you suspected it is failing part of the time. Below are the path that it fails with then the path it succeeds with.

Path Failed - K:\Local\Prog\StopLight Timer\_StopLightTimerHelp.pdf :o

Path Succeeded - K:\ETS Documents\ToastMasters\Timer\Build 2005-10-26a\StopLightTimerHelp.pdf :graduated:

H'mmmn, my face is red. B) As you can see (and me too now that they are next to each other) there is a difference in the file name. I don't know when I got the wrong named file in the zipped auxilary files.

Thank you all for your responses and suggestions.


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites
B)

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

Hi,

I am not surprised how much trouble there is "getting the quotes right"

I have settled my problem by always using this type of structure to keep the quotes honest;

If you really look at "double quotes", they sometimes need to be triple etc.

i would be interested to hear if this solves the problems people have with the quotes, or if you really believe there is some other problem?

Best, randall

The reason I went to the FileGetShortName() function was that I expected I was getting the quotes wrong. However, the problem here was my error, but a different one. If you check my previous post you'll see what I mean.


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0