Jump to content

subst - Issues with mounting in script doesn't display in command prompt call of subst.


Go to solution Solved by November,

Recommended Posts

Posted (edited)

I am failing to understand why mounting a folder using subst in a script fails to display in the command prompt. Not to mention when you change @WorkingDir to @SystemDir it fails too. Any help? I am using Windows 8.1 x64 with the latest version of AutoIt.

#include <Constants.au3>

Local $sDevice = 'X:' ; PLEASE CHANGE TO AN AVAILABLE DRIVE.
Run(@ComSpec & ' /c subst ' & $sDevice & ' "' & @ScriptDir & '"', @WorkingDir) ; Create a subst.

Local $iPID = Run(@ComSpec & ' /c subst', @SystemDir, @SW_HIDE, $STDOUT_CHILD)
ProcessWaitClose($iPID)
ConsoleWrite(StdoutRead($iPID) & @CRLF) ; Display the output of subst.
ConsoleWrite(_WinAPI_QueryDosDevice($sDevice & '\') & @CRLF) ; DOESN'T WORK but it should return \??\@ScriptDir.
MsgBox($MB_SYSTEMMODAL, '', 'Now open up a command prompt and type subst. Why doesn''t the same output display as it did above?')
Run(@ComSpec & ' /c subst ' & $sDevice & ' /D', @WorkingDir) ; Delete the subst.
Oh, and if I create a subst in the command prompt e.g. subst X: C:Example then it displays when I enter X:, but not when I call subst in the script. Am I going crazy?

Edit: The reason I stumbled on this is I was using DefineDosDevice and QueryDosDevice directly which is what subst wraps around.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • Moderators
Posted

I may be misunderstanding what you're seeing, but if I change this:

_WinAPI_QueryDosDevice($sDevice & '\') & @CRLF

to this:

_WinAPI_QueryDosDevice($sDevice) & @CRLF

I get the response from that call I would expect:

 

For the StdoutRead call:

post-54985-0-30715200-1401281616.png

For the _WinAPI_QueryDosDevice call:

post-54985-0-22271900-1401281806.png

And then what I see in the command line:

post-54985-0-81241600-1401281901_thumb.p

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

<excude>I woke up at 3am as I couldn't sleep and started to code this, so now I see where I went wrong.</excuse>

Thanks for that, the issue was the backslash and that I didn't run cmd prompt as Administrator. Commence ridiculing me!

Thanks for your help and sorry I missed the additional include.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Actually the subst drive doesn't display in Computer though.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • Solution
Posted

As far as I understood subst is displayed as a drive but it is really a junction point.

I tryed your script just changing the drive letter to W (X is already taken) and it worked like a charm. Windows 8.1 x64 and latest AutoIT

This subst command travels me to old 255 characters unc problem.

Hygienic reboot probably?

Cheers

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Posted
  On 5/28/2014 at 1:42 PM, November said:

Hygienic reboot probably?

Good point actually.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Seems a reboot sorted the issue. Thanks.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted
  On 6/4/2014 at 5:35 PM, guinness said:

Seems a reboot sorted the issue. Thanks.

And with so many years around Windows, I still feel mesmerized with the reboot option. Eliminates 60% of all troubles.

It is not an issue... it is a feature :)

Cheers Guinness!

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...