1.

Solve : Help with simple echo to file command for batch?

Answer»

I have a batch file I'm going to use to update a lab's Adobe flash. I would like for the script to add the computers name to a log file after installing just so I know which ones got the update. The below script works just fine when ran from our netlogon share manually (double clicking batch file) but will not run at startup when USED with Group Policy.

echo %COMPUTERNAME%>>\\dcboe.local\netlogon\apps\Flash1200044\log.txt

Here is the actual script I'm using

IF EXIST %WINDIR%\SysWOW64\Macromed\Flash\FlashUtil32_12_0_0_44_ActiveX.exe (
GOTO :EOF
) ELSE (
%WINDIR%\SysWOW64\Macromed\Flash\FlashUtil32_11_8_800_174_ActiveX.exe -uninstall -force
PING -n 11 127.0.0.1>nul
pushd %~dp0
"Flash1200044/InstallAX_12_0_0_44.exe" -install -au 2
echo %COMPUTERNAME%>>\\dcboe.local\netlogon\apps\Flash1200044\log.txt
)
exit

When the COMPUTER starts and Group Policy runs the script, everything works EXCEPT the log. It uninstalls the old flash, installs the new flash, but wont write to the log file. I don't understand why it will run correctly manually but not automatically from the same location.if it is not writing to the log file then there has to be some type of error. Can you put a pause after that command to see what the error is.If I do the batch with a pause manually (double clicking it) it there doesn't seem to be an error and it works. If group policy does it through start up, its always silent and you never see it, even with a pause. Your running into a UNC Path problem I believe. I had a similar problem years ago. My solution was to use an IP path with a share to drop the log file to.... such as:

\\172.16.4.120\c$\logs\log.txt

instead of:

\\system.name\c$\logs\log.txt

So if the system that the logs are going to has a static IP, I'd connect to a share on it via IP vs UNC path. At the share location, the user level would have to have the ability to write to this location otherwise it wont write as well. So you can verify that the lower user privileges are able to write to this drop location as well. I have seen some PEOPLE add runas into batch INSTRUCTIONS to elevate the privileges of the batch process to match that of the drop location etc, but that is not a good idea even if compiling the batch file from .bat into .exe form to prevent it from being viewed with a text editor by a nosy user and getting admin privileges. Its best to set the permissions on the drop location to match that of the user credentials or create an alt user privileged account to use the runas with so that the regular user cant see the log location contents unless they get the user level credentials to authenticate with this location with. This would keep someone from getting admin privileges by an oops with a runas, and instead the most they would get is a user level credential with restrictions.Yes! I went to a different share besides xxx.local and used the IP path and it works great now! Thanks a LOT!!Glad that fixed it!



Discussion

No Comment Found