Can anyone help me convert the following batch file to vbs? I have limited knowledge on vbs.
REM --- Check for an existing installation of Sophos AutoUpdate
if exist "C:\Program Files\Sophos\AutoUpdate\ALsvc.exe" goto _End
REM --- Deploy to Windows 2000/XP/2003
\\\InterChk\ESXP\Setup.exe -updp "\\\InterChk\ESXP" -user "USER" -pwd "PWD" -mng yes
REM --- End of the script
' Check for an existing installation of Sophos AutoUpdate
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists("C:\Program Files\Sophos\AutoUpdate\ALsvc.exe") Then
'Not found so install Sophos now.
WshShell.Run "\\\InterChk\ESXP\Setup.exe -updp ""\\\InterChk\ESXP"" -user ""USER"" -pwd ""PWD"" -mng yes"
Wscript.Echo "ExE already exists"
Not sure if that will work or if I've escaped the quotes in there properly but it should at least give you an idea..
Use this little function I have for logging to the event log:
function LogtoEvent (MSG,success)
select case success
case 1 objShell.LogEvent EVENT_SUCCESS, MSG ' 1 is a success
case 0 objShell.LogEvent EVENT_FAILURE, MSG ' 0 is a error
case 2 objShell.LogEvent EVENT_WARNING, MSG ' 2 is a warning
case 3 objShell.LogEvent EVENT_INFORMATION, MSG
This assumes you are declaring objShell as
Set objShell = wscript.createObject("wscript.shell")
you just call LogtoEvent in your script like so:
LogtoEvent "THE MESSAGE",1
You dont need to really clear variables as you only really do that if they are not needed again in the script but there is not much point if its the end anyway as it will be free automatically once the script is done.
BTW I think the difference between Set objFSO = CreateObject("Scripting.FileSystemObject") and wscript.shell is that the FSO has more functions for file system operations but I am not sure.
Also Scripting.FileSystemObject probably cant access the event log. I would probably use both to be safe.
As it will be running at logon for all machines I would need to only run it if the folder c:\itunefiles exists. This will copy the preferences I've set for ITunes into the student profiles and hopefully allow ITunes to run in a locked down environment.
I can't run any commandline script, as access to command is blocked for the student, as as the script has to run after they log on it needs to run under their permissions.
By executing a copy of ROBOCOPY, you are not running a command line script. ROBOCOPY is an executable program that does not rely on a command line to host it's output. This won't get around the fact that it has to run in the same security context as the user that is logging on of course any more that the VB script would.