mbrunt Posted July 11, 2012 Posted July 11, 2012 Hi all, See my batch file below, could someone possibly kindly rewrite this in a vbs for me? net use t: \\ccmgmt01\its /User:domain.local\administrator P&ssword msiexec /qn /i "t:\APPS\AB\v6\silent\abtclient6.msi" net use t: /delete /y @echo Checking to see if Aero capable... winsat.exe dwmformal @echo Switching off Hibernate... powercfg -h off @echo Installing Sophos Antivirus, please wait... net use s: \\ccsophos01.domain.local\sophosupdate /User:domain.local\sophos P&ssword s: cd CIDs\S000\SAVSCFXP setup.exe -updp "\\ccsophos01\SophosUpdate\CIDs\S000\SAVSCFXP" -user "domain.local\sophos" -pwd "P&ssword" -mng yes net use s: /delete /y del /f "c:\windows\system32\sysprep\x64unattend.xml" del %0 The reason I need it rewriting is that although the script works perfectly mdt seems to find something wrong with it and causes the task sequence to report errors at the very end. What I've done for now is write a very basic vbs that simply calls the batch file above. Although this works its not 100% ideal. Thanks for anyone that can help!!
mac_shinobi Posted July 11, 2012 Posted July 11, 2012 @Steve21 - may be able to help with the vbs side, might be others who may be able to suggest something else ?
mbrunt Posted July 11, 2012 Author Posted July 11, 2012 any help would be appreciated thanks, vbscript it not my strong point! lol. i will return the favour, somehow
ChrisH Posted July 11, 2012 Posted July 11, 2012 If you have written a VBS script to call that batch script then that command is probably going to be the same one to call all those separate commands in your batch file. Just keep repeating it for all the commands.
mbrunt Posted July 12, 2012 Author Posted July 12, 2012 because i have no idea of how to map and delete network drives, or how to get the script to delete itself,...
Steve21 Posted July 14, 2012 Posted July 14, 2012 @Steve21 - may be able to help with the vbs side, might be others who may be able to suggest something else ? Oops Been busy week didn't notice this! @mbrunt Can't really test this due to your paths etc, but this should work unless I missed some syntax changes from your exes etc, but try this when you have a minute dim objNetwork Set objNetwork = CreateObject("Wscript.Network") objNetwork.MapNetworkDrive "T:", "\\ccmgmt01\its", False, "domain.local\administrator", "P&ssword" Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "msiexec.exe /qn /i "t:\APPS\AB\v6\silent\abtclient6.msi"" objNetwork.RemoveNetworkDrive "T:" WshShell.Run "winsat.exe dwmformal" WshShell.Run "powercfg -h off" objNetwork.MapNetworkDrive "S:", "\\ccsophos01.domain.local\sophosupdate", False, "domain.local\sophos", "P&ssword" WshShell.Run "S:\CIDs\S000\SAVSCFXP\setup.exe -updp "\\ccsophos01\SophosUpdate\CIDs\S000\SAVSCFXP" -user "domain.local\sophos" -pwd "P&ssword" -mng yes" objNetwork.RemoveNetworkDrive "S:" Dim fso Set fso = CreateObject("Scripting.FileSystemObject") fso.DeleteFile "c:\windows\system32\sysprep\x64unattend.xml", True fso.DeleteFile WScript.ScriptFullName Steve 1
mac_shinobi Posted July 14, 2012 Posted July 14, 2012 Oops Been busy week didn't notice this! @mbrunt Can't really test this due to your paths etc, but this should work unless I missed some syntax changes from your exes etc, but try this when you have a minute dim objNetwork Set objNetwork = CreateObject("Wscript.Network") objNetwork.MapNetworkDrive "T:", "\\ccmgmt01\its", False, "domain.local\administrator", "P&ssword" Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "msiexec.exe /qn /i "t:\APPS\AB\v6\silent\abtclient6.msi"" objNetwork.RemoveNetworkDrive "T:" WshShell.Run "winsat.exe dwmformal" WshShell.Run "powercfg -h off" objNetwork.MapNetworkDrive "S:", "\\ccsophos01.domain.local\sophosupdate", False, "domain.local\sophos", "P&ssword" WshShell.Run "S:\CIDs\S000\SAVSCFXP\setup.exe -updp "\\ccsophos01\SophosUpdate\CIDs\S000\SAVSCFXP" -user "domain.local\sophos" -pwd "P&ssword" -mng yes" objNetwork.RemoveNetworkDrive "S:" Dim fso Set fso = CreateObject("Scripting.FileSystemObject") fso.DeleteFile "c:\windows\system32\sysprep\x64unattend.xml", True fso.DeleteFile WScript.ScriptFullName Steve Thanks Steve, I didn't even have a chance to look at it properly as was at work at the time of posting a mention
mbrunt Posted July 16, 2012 Author Posted July 16, 2012 Thanks for the script However, line 6 character 35, expected end of statement :s ? Thanks
mac_shinobi Posted July 16, 2012 Posted July 16, 2012 Thanks for the script However, line 6 character 35, expected end of statement :s ? Thanks Not sure if it makes any difference but you are assigning a mapped network drive with a lower case t and then trying to remove a network drive letter with an uppercase T, would making it a lowercase t make any difference objNetwork.RemoveNetworkDrive "t:"
Jamo Posted July 16, 2012 Posted July 16, 2012 Just out of curiosity, why aren't you using MDT to map the drives etc for installing the apps? You should be able to get a decent error code out of it then. Something else to note is that the error codes from MDT are decimal whereas most sites will list them as hex ie 0x8007002 etc. Also if you want to map drives in batch files its more friendly these days to use pushd and popd which will auto add/remove drives from network locations without causing errors which are usually just, "someone is using this dir and you have force disconnected it" etc etc. IE: [color=#333333]pushd \\ccmgmt01\its[/color] [color=#333333]msiexec /qn /i ".\abtclient6.msi" [/color][color=#333333]popd[/color] The same goes for the Sophos install. I have all mine separated though into their different MDT applications, makes management a little easier.
mbrunt Posted July 16, 2012 Author Posted July 16, 2012 Hi James, I've never heard of pushd or popd but I shall give it a go. Also, I'm running the script at the end of the task just because its easy to be honest. I haven't yet looked into MDT deploying apps, but I shall probably also give that a go sometime soon. For now though I just want this vb to work properly, im currently calling a batch file from a vb, which works but its a bit dirty. THanks
Jamo Posted July 16, 2012 Posted July 16, 2012 That error btw on line 6 is due to the double " chars WshShell.Run "msiexec.exe /qn /i "t:\APPS\AB\v6\silent\abtclient6.msi"" The bold lettering is where the .Run command will go to due to the " effectively escaping the command early. Try altering the line to: WshShell.Run "msiexec.exe /qn /i """t:\APPS\AB\v6\silent\abtclient6.msi""""
Jamo Posted July 16, 2012 Posted July 16, 2012 hmm thanks but same error. Is it on the same line and character? You will have to do the same to the sophos lines
Jamo Posted July 16, 2012 Posted July 16, 2012 Actually scratch that try [color=#333333]WshShell.Run "msiexec.exe /qn /i ""t:\APPS\AB\v6\silent\abtclient6.msi""" Too many ""s lol[/color]
mbrunt Posted July 16, 2012 Author Posted July 16, 2012 (edited) ive stripped the script down to this for now... dim objNetwork Set objNetwork = CreateObject("Wscript.Network") objNetwork.MapNetworkDrive "T:", "\\ccmgmt01\its", False, "carmel.local\administrator", "password" Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "msiexec.exe /qn /i """t:\APPS\AB\v6\silent\abtclient6.msi"""" objNetwork.RemoveNetworkDrive "T:" now error is line 6, char 37, expected end of statement... Edited July 16, 2012 by mbrunt
mbrunt Posted July 16, 2012 Author Posted July 16, 2012 when i run this... dim objNetwork Set objNetwork = CreateObject("Wscript.Network") objNetwork.MapNetworkDrive "T:", "\\ccmgmt01\its", False, "carmel.local\administrator", "password" Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "msiexec.exe /qn /i ""t:\APPS\AB\v6\silent\abtclient6.msi""" objNetwork.RemoveNetworkDrive "T:" i get no error but nothin happens at all :S
Jamo Posted July 16, 2012 Posted July 16, 2012 Are you sure it hasn't run the installer? It is running in silent mode so you wouldn't see anything. Check in event vwr for Windows Installer entries
mbrunt Posted July 16, 2012 Author Posted July 16, 2012 yeah i dont even see it map the network drive :S
mbrunt Posted July 16, 2012 Author Posted July 16, 2012 ok, it looks as if the drive is being mapped n then deleted before sophos can even have time to install
mac_shinobi Posted July 16, 2012 Posted July 16, 2012 (edited) I think I know what it is You map network drive T you execute an installer from the T Drive You are trying to remove or un map the T drive whilst it is still in use , no pause or anything for said installer to finish before trying to remove the T Drive @mbrunt beat me to it lol Can you move the line of code to nearer the bottom of the script so it un maps the T drive once it has completed the other tasks ? Haven't got time to look into this so @Steve21 or someone else can post a bit of vbscript that will make it wait until the installer has completed before executing the code to remove the network drives? Edited July 16, 2012 by mac_shinobi
mbrunt Posted July 16, 2012 Author Posted July 16, 2012 mac yea ur right, if i tell it not to unmap it works ok...
Jamo Posted July 16, 2012 Posted July 16, 2012 lol you should be able to run the installers without mapping the network drive? Just put the full UNC path as the arguments to msiexec
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now