Sign in to follow this  
Followers 0
Shibuya

FileGetShortName bug?

4 posts in this topic

I've got a DOS executable that needs to use short names when executed with RunWait or Run.

The code is as follows:

Dim $file_prn
Dim $pl_txt
Dim $data_extract

; Declare variables as constants
$pl_txt = @ScriptDir & "\CACHE\PL_TXT.TXT"
$data_extract = @ScriptDir & "\CACHE\DATA_EXTRACT.TXT"

#include ".\FUNCTIONS\FILEOPENDIALOGUE.AU3"

ProgressOn("Conversion in Progress...", "Converting...")

RunWait(FileGetShortName(@ScriptDir & "\COM\REVPMAC.EXE") & " " & FileGetShortName($file_prn) & " " & FileGetShortName($pl_txt), "", @SW_HIDE)

ProgressSet(100 , "Done", "Complete")
sleep(1000)
ProgressOff()

Apparently, FileGetShortName($pl_txt) does not give me the short name but the original windows long name!!

Can someone tell me what's wrong with my code or is it a bug??


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



No Bug, your RunWait() doesn't look setup right..

You can see that it does get the short name if you debug a bit:

$pl_txt = FileGetShortName(@ScriptDir & "\CACHE\PL_TXT.TXT")
MsgBox(0, "", $pl_txt)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

No Bug, your RunWait() doesn't look setup right..

You can see that it does get the short name if you debug a bit:

$pl_txt = FileGetShortName(@ScriptDir & "\CACHE\PL_TXT.TXT")
MsgBox(0, "", $pl_txt)
i did a test script as below

i've checked and it doesn't work

you all can try to verify?

save the script on your desktop and run it.

Dim $file_prn
Dim $pl_txt
Dim $data_extract

; Declare variables as constants
$pl_txt = @ScriptDir & "\CACHE\PL_TXT.TXT"
$data_extract = @ScriptDir & "\CACHE\DATA_EXTRACT.TXT"
$file_prn = @ScriptDir & "\TEST.PRN"

;ProgressOn("Conversion in Progress...", "Converting...")

MsgBox(0, "", FileGetShortName(@ScriptDir & "\COM\REVPMAC.EXE") & " " & FileGetShortName($file_prn) & " " & FileGetShortName($pl_txt))
;RunWait(FileGetShortName(@ScriptDir & "\COM\REVPMAC.EXE") & " " & FileGetShortName($file_prn) & " " & FileGetShortName($pl_txt), "", @SW_HIDE)

;ProgressSet(100 , "Done", "Complete")
;sleep(1000)
;ProgressOff()

I've figured out the problem

It seems that FileGetShortName requires an existing file and path indicated as in the script, else it will jus return the long name.

Once the indicated file and path name exists, my script works fine.

Is that how FileGetShortName is intended to work?

Or is it a undiscovered bug?

Edited by Shibuya

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

It seems that FileGetShortName requires an existing file and path indicated as in the script, else it will jus return the long name.

Once the indicated file and path name exists, my script works fine.

Is that how FileGetShortName is intended to work?

Or is it a undiscovered bug?

It's not possible to determine the short name of a nonexistent file, because it's not as simple as (for instance) truncating the name to 6 characters and appending ~1 to the end. I would suggest adjusting your RunWait() line to create files with names of 8.3 format and then rename them to your desired name.

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