Acces share on a server or workgroup PC

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Acces share on a server or workgroup PC

Post by mrcoollion » Thu Mar 02, 2017 2:49 pm

I am trying to acces a file on a workgroup PC within my network (as a test)

On Windows I need to be able to:
1) Access a share on a server with a share related userID and password. (\\ServerName\SharedFolderName)
2) After 1 is possible I need to be able to acces this share and copy a SQLite DB to it.
3) If 1 & 2 are successful I need to use that DB in my Stack.

I cannot seem to find the the information on how to achieve this.

I tried

Code: Select all

put tFullDatabaseFileLocation & " /user "&tUserID &" "&tPassword into tFullDBFileLocationAndCredentials
    if there is a file tFullDBFileLocationAndCredentials
    then
        // Do something
    else
       // Do something else
    end if
But no luck..
Any idea's

regards,

MrCoolLion (Paul)

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Acces share on a server or workgroup PC

Post by AxWald » Thu Mar 02, 2017 6:46 pm

Hi,

Code: Select all

   put "I'm Joe" into myUser
   
   if (Me = paranoid) then
      put "*" into myPass
   else
      put "ThisCouldBeBetter" into myPass
   end if
      
   if (Me = Domainmember) then
      put "theDomainName" & "\" into myDomain
   else
      put empty into myDomain
   end if
   
   get shell("net use X: \\Server\ShareDir /user:" & myDomain & myUser && myPass && "/persistent:no")
   
   get revdb_connect("sqlite", "X:\DBFolder\mydb.sqlite")
This should give you an idea. Hint: If you are paranoid, the system should ask you for your password ;-)

Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Acces share on a server or workgroup PC

Post by mrcoollion » Fri Mar 03, 2017 12:09 am

Thx AxWald,

I have worked with the shell command before and seems to be a good solution for this situation.
---- UPDATE 03-03-2017 ---------
For others who need this. I placed the file-share in-between quotes and it worked. The astrix [*] means that it will get the highest possible free driveletter.
After this I could open the sqlite database and check on it with the file command.

Code: Select all

    put "net use * quote"& tDatabaseFileShare &"quote /user:"& tDomain & tUserID && tPassword && "/persistent:no" into tCommand
    replace "quote" with quote in tCommand
    get shell(tCommand)
    answer "Shell: "&it
----------------------

Regards,

Paul

Post Reply

Return to “Talking LiveCode”