• Simple task, can’t make it work, please Help!

    Home » Forums » Admin IT Lounge » Admin IT Lounge – Miscellaneous » Simple task, can’t make it work, please Help!

    Author
    Topic
    #173586

    Hey everyone,

    I hope someon can help me here, because this makes me mad.

    I’m more like a linux guy, but sometimes I have to admin some windows stuff. Like, now.

    I have a simple task but I just can’t get it to work. Surely I’m doing something wrong.

    So this would be the job: on a bunch of windows workstations, there’s a CAD software installed locally. All the data is on a linux fileserver (which requires authentication). No domains or anything.

    There’s a single file (a library) for the CAD, that has to be local on every workstation. This file is sometimes updated/expanded/changed, the master copy resides on the linux server, on the SMB share. It has to be distributed to all the workstations and must be copied to under C:\ProgramData, so it needs admin or higher privileges to be written. And again, the SMB needs authentication as well.

    How should I do this?

    My approach was a simple batch file, which checks if the file is available (i.e. the network is up) with a UNC path, and if it does. then it does an xcopy to ProgramData (only if the master file is newer than the local copy). And I execute this batch from a task scheduler job, every time any user logs in to the WS.

    But this just won’t work for some reason. If I run this as the admin user, it won’t even start the job, despite the tick box is on “run this even if the user is not logged in”. Credentials are saved as well (or supposed to). Tried running as the builtin Administrators group, no joy. It doesn’t even see the network resources.

    It only works If i run the job as a specified user (with highest privileges for the job) and only when that specified user logs in (any user logged it doesn’t work!), but that way I would have to do separate tasks for every single user.

    So, I don’t know… Isn’t this how it supposed to work? How else should I do this?

    Thanks for any help.

    Viewing 5 reply threads
    Author
    Replies
    • #173657

      What if the data resided on a Windows computer? Could the various Windows workstations access it there, or does the data absolutely have to be local on the computer that the person is using?

      What CAD software is it?

      Speaking of Linux, we have a Linux Forum here at Ask Woody. I’m sure your Linux expertise would be much appreciated in the Linux Forum.

      Group "L" (Linux Mint)
      with Windows 10 running in a remote session on my file server
    • #173737

      See if this article helps.

      HTH ?

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #173847

      Just wondering what your Windows version is, and what level of SMB you have active (or disabled). Might this be impacting your results?
      This gives some information on recent SMBv1 issues, for instance. Also these two topics tags to search:
      SMBv1
      SMB

    • #173890

      You don’t need to run the task when a user is logged on but you do need to provide credentials to connect to the share – this is because the user running the job doesn’t have rights to the share.
      The easiest way around this is to put the update files on a read-only share that everyone can access, then run the scheduled job as a user with permission to update the local files. Set the job to run regularly, probably at start up, but you may need to add a test to ensure the CAD program is not running during the update.

      cheers, Paul

    • #173915

      @MrJimPhelps: it doesn’t have to be local, it could be configured to be located centrally on the server where everyone can access it, but that causes a lot of problems (performance and multiple users trying to access it at the same time), so keeping it locally is much better (this is the default anyhow)

      @Kirsty: the WSs were all Win7 x64 pro until yesterday, when I had to replace some with newer Hardware and unfortunatelly we couldn’t get Win7 anymore (it wouldn’t support the new HW anyway, at least that’s waht MS says, lol), so there are now a few running that P.o.S Win10 x64 pro garbage. It doesn’t make a difference regarding this task scheduler. As for SMB, it’s v3, but v2 is also supported. There’s also a network scanner that only supports v1 (firmware update is going to happen some time soon), so I had to enable SMB v1 on the clients as well. (I’m not worried about it too much)

      @Paul T Adding a share for just one file? No. Nope. It wouldn’t help anyway. When running the task as administrator (who has credentials stored… supposedly), doesn’t work when another user logs is. According to my debugging attempts, that way when the script runs, it won’t even see the server itself, bare the shares on it. It couldn’t even resolve the server name as if there was no dns service, couldn’t understand the unc path to the server either. I guess it doesn’t have access to any network resources for some reason, despite that tickbox that controls this is unchecked.

      1 user thanked author for this post.
    • #174954

      So after lots and lots of debugging, but mostly trial and error, this seems to work:

      @echo off
      setlocal
      set logfile=”C:\ProgramData\initscriptlog.txt”
      if exist %logfile% (del %logfile% /Q)

      nslookup LOCAL-SERVER | find /I “12.34.56.78” >nul
      if %errorlevel%==0 (
      net use T: “\\LOCAL-SERVER\Samba”
      if exist “T:\path\to\batch\file\script.bat” (
      call “T:\path\to\batch\file\script.bat” >> %logfile%
      ) else (
      echo “SCRIPT.BAT not found!” >> %logfile%
      )
      net use T: /DELETE
      ) else (
      echo “LOCAL-SERVER not found!” >> %logfile%
      )

      The trick is in the “net use”. Without that, I just could not do anything with just using UNC paths. No matter how the credentials were stored, Windows just didn’t use them at all. It could not even do an “if exist “\\LOCAL-SERVER\Samba” which is browsable to anyone  (hence the nslookup instead)

      For some reason, “net use” uses the stored credentials and after that everything just works. I don’t know why. (As said I’m not a windows guy)

      This runs as the admin user, whether logged in or not, at any user login event, and seems to work.

    Viewing 5 reply threads
    Reply To: Simple task, can’t make it work, please Help!

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: