Situation:
I currently search for a method, to execute logon scripts, that are saved on a NAS. When I try it like normal with GPO -> User -> Windows settings -> Logon and give the path \\NAS-UNC\Folder\script.bat
it won't start and execute the script.
The script is for testing, to use it at one of our customers, whom don't have AD.
@echo off
mkdir test
echo The test was successfull!
PAUSE
I do mount the NAS as a network drive with one user, all clients should connect. So there shouldn't be any missing permissions to connect to the NAS.
If i execute the script via explorer, it works just fine.
If anybody knows a solution, or a tipp, I would be very grateful.
Best Regards Haga
CodePudding user response:
So after a little bit longer, i found a solution. But its kinda ugly... BUT it works!
How I got it to work was kinda dumb and easy... In my mount-script, I made a ping for 6 iterations, just so there is enough time to mount the drive. After the ping i copied the script from the NAS into the Logon folder in Windows.
My mount-script looks something like this:
@echo off
net use Z: \\NAS-UNC\_sharedfolders USERNAME:NAS-UNC\User your-password /PRESISTENT:NO
ping 127.0.0.1 -n 6 > nul
copy Z:\script.bat C:\Windows\System32\GroupPolicy\User\Scripts\Logon\NAS-Script\test.bat /y
If you may notice, the /y
in the copy command. This is for the case, the file allready exists in the folder, you won't get a window prompting you to either overwrite, or rename it.
Further I then added the copied script as a logon script.