KSum Posted June 13, 2013 Posted June 13, 2013 @ScriptDir is returning a network mapped drive instead of the UNC. How do I get this to give me the UNC instead? I though it returned this by default. Karl
water Posted June 13, 2013 Posted June 13, 2013 DriveMapGet? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
KSum Posted June 13, 2013 Author Posted June 13, 2013 Is there a way to have it return the UNC instead of the mapped path? I thought it was supposed to return the UNC based on other forum threads. I could also use the first array item from : $MyPath = _WinNet_GetUniversalName(@ScriptDir) but I believe I would first have to make sure @ScriptDir is not reporting a UNC
water Posted June 13, 2013 Posted June 13, 2013 Can you give an example what DriveMapget returns and what you expect? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
KSum Posted June 13, 2013 Author Posted June 13, 2013 Can you give an example what DriveMapget returns and what you expect? I have to deconstruct @ScriptDir if I use DriveMapGet. If I use: MsgBox(0,"test" ,DriveMapGet(@ScriptDir)) I get a message box with no message, suggesting that the function fails with a full path. I would have to split @scriptDir, then get the ServerShare of the drive and then reconstruct it to use RunAs to run something via a UNC So to display the UNC in a message box for a test, I end up with: _PathSplit( @ScriptDir, $MyDrive, $MyDir, $MyFile, $MyExtension) MsgBox(0,"test" ,DriveMapGet($MyDrive) & @CRLF & $MyDir & @CRLF & $MyFile & @CRLF & $MyExtension) ;display the Server\Share and other pieces MsgBox(0,"test" , DriveMapGet($MyDrive) & $MyDir) ;dispaly the full UNC path As you can see, to use the full UNC path, I need to put the strings together again, as shown. So why not use: $MyPath = _WinNet_GetUniversalName(@ScriptDir) _ArrayDisplay($MyPath, "Demo _PathSplit()") ;display all the values MsgBox(0,"test",$MyPath[0]) :display the full UNC path And then I can just reference $MyPath[0] when I need the full UNC path. Either way, I have to know that I am getting the mapped version of @ScriptDir and not the UNC version. or at least act according to which I am getting. I am still confused as to when @scriptDir returns a UNC and when it returns a UNC. I am hoping there is a way to force it to return a UNC and be done with it all without any conversions.
blckpythn Posted June 14, 2013 Posted June 14, 2013 Have you tried running it using the UNC path instead of a mapped drive path? Or is it required in your case to use the mapped drive?
KSum Posted June 14, 2013 Author Posted June 14, 2013 I need the UNC path. I am getting the mapped drive from @ScriptDir. So when I use @ScriptDir I get G:MyFolderPath and not ServerShareMyFolderPath.
water Posted June 14, 2013 Posted June 14, 2013 This should give you the UNC path: $sDir = @ScriptDir $aDir = StringSplit($sDir, ":") If @error = 0 Then $sInfo = DriveMapGet($aDir[1] & ":") $sInfo &= $aDir[2] MsgBox(0, "", $sInfo) EndIf My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
blckpythn Posted June 14, 2013 Posted June 14, 2013 (edited) $netscriptdir = DriveMapGet(StringLeft(@ScriptDir, 2)) & StringTrimLeft(@ScriptDir, 2) & "\" & @ScriptName ConsoleWrite($netscriptdir & @CRLF) This works for me, let me know if it works for you. Edit: Ah, water beat me to it. Edited June 14, 2013 by blckpythn
water Posted June 14, 2013 Posted June 14, 2013 Your solution works fine for me. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
KSum Posted June 14, 2013 Author Posted June 14, 2013 I came up with something similar, but was of the understanding @ScriptDir was supposed to return a UNC. Is this not the case? Is there a setting that can be made to force it to a UNC? I came up with this which tests for a mapped drive or UNC first as I am almost positive I have seen @ScriptDir give me a UNC before: #include <WinNet.au3> $ScriptPath = @ScriptDir ;Make sure it is a UNC and not a mapped drive if StringInStr($ScriptPath, ":") > 0 Then $MyPath = _WinNet_GetUniversalName(@ScriptDir) $ScriptPath = $MyPath[0] EndIf Is there a reason I should not use _WinNet_GetUniversalName()?
water Posted June 14, 2013 Posted June 14, 2013 There are many ways to skin a cat. Use whichever solution returns the correct result. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
blckpythn Posted June 14, 2013 Posted June 14, 2013 It may have shown up as a UNC path before, because you had opened up the .au3 file from network instead of a mapped drive.
water Posted June 14, 2013 Posted June 14, 2013 Correct. I just opened a script in SciTe and passed the UNC path to the open dialog. Then @ScriptDir gives you the UNC path. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
blckpythn Posted June 14, 2013 Posted June 14, 2013 (edited) I went through some trouble like this before while trying to make a login script that checks if it is running from the network and if so copy itself to the users' appdata and run again. But eventually I had an environment that had appdata stored on the server. This is how I learned to just do it with: If @ScriptDir <> @AppDataDir Then _CopyandRun Which of course was simpler, more reliable, and faster. Edited June 14, 2013 by blckpythn
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now