+ Post New Thread
Page 1 of 3 123 LastLast
Results 1 to 15 of 43
O/S Deployment Thread, Anyone write me a VB Script please? in Technical; Hi all, See my batch file below, could someone possibly kindly rewrite this in a vbs for me? net use ...
  1. #1

    Join Date
    Jul 2008
    Location
    Merseyside
    Posts
    295
    Thank Post
    16
    Thanked 10 Times in 10 Posts
    Rep Power
    14

    Anyone write me a VB Script please?

    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!!

  2. #2

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,705
    Thank Post
    3,239
    Thanked 1,045 Times in 967 Posts
    Rep Power
    363
    @Steve21 - may be able to help with the vbs side, might be others who may be able to suggest something else ?

  3. #3

    Join Date
    Jul 2008
    Location
    Merseyside
    Posts
    295
    Thank Post
    16
    Thanked 10 Times in 10 Posts
    Rep Power
    14
    any help would be appreciated thanks, vbscript it not my strong point! lol. i will return the favour, somehow

  4. #4
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,998
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106
    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.

  5. #5

    Join Date
    Jul 2008
    Location
    Merseyside
    Posts
    295
    Thank Post
    16
    Thanked 10 Times in 10 Posts
    Rep Power
    14
    because i have no idea of how to map and delete network drives, or how to get the script to delete itself,...

  6. #6

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by mac_shinobi View Post
    @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

    Code:
    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

  7. Thanks to Steve21 from:

    mac_shinobi (14th July 2012)

  8. #7

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,705
    Thank Post
    3,239
    Thanked 1,045 Times in 967 Posts
    Rep Power
    363
    Quote Originally Posted by Steve21 View Post
    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

    Code:
    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


  9. #8

    Join Date
    Jul 2008
    Location
    Merseyside
    Posts
    295
    Thank Post
    16
    Thanked 10 Times in 10 Posts
    Rep Power
    14
    Thanks for the script However, line 6 character 35, expected end of statement :s ? Thanks

  10. #9

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,705
    Thank Post
    3,239
    Thanked 1,045 Times in 967 Posts
    Rep Power
    363
    Quote Originally Posted by mbrunt View Post
    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

    Code:
    objNetwork.RemoveNetworkDrive "t:"

  11. #10

    Join Date
    Jul 2008
    Location
    Merseyside
    Posts
    295
    Thank Post
    16
    Thanked 10 Times in 10 Posts
    Rep Power
    14
    Nah tried that, same error.

  12. #11

    Join Date
    Jul 2008
    Location
    Merseyside
    Posts
    295
    Thank Post
    16
    Thanked 10 Times in 10 Posts
    Rep Power
    14
    Untitled.png see...

  13. #12
    Jamo's Avatar
    Join Date
    Jan 2009
    Posts
    1,349
    Thank Post
    66
    Thanked 175 Times in 147 Posts
    Rep Power
    60
    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:
    Code:
    pushd \\ccmgmt01\its
    msiexec /qn /i ".\abtclient6.msi"
    popd
    The same goes for the Sophos install. I have all mine separated though into their different MDT applications, makes management a little easier.



  14. #13

    Join Date
    Jul 2008
    Location
    Merseyside
    Posts
    295
    Thank Post
    16
    Thanked 10 Times in 10 Posts
    Rep Power
    14
    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

  15. #14
    Jamo's Avatar
    Join Date
    Jan 2009
    Posts
    1,349
    Thank Post
    66
    Thanked 175 Times in 147 Posts
    Rep Power
    60
    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""""

  16. #15

    Join Date
    Jul 2008
    Location
    Merseyside
    Posts
    295
    Thank Post
    16
    Thanked 10 Times in 10 Posts
    Rep Power
    14
    hmm thanks but same error.

SHARE:
+ Post New Thread
Page 1 of 3 123 LastLast

Similar Threads

  1. vb script help please
    By mac_shinobi in forum Scripts
    Replies: 13
    Last Post: 31st March 2011, 12:39 PM
  2. Replies: 0
    Last Post: 22nd November 2009, 11:07 AM
  3. Replies: 5
    Last Post: 14th November 2009, 04:37 PM
  4. Writing to Excel from .vbs script
    By Samson in forum Windows
    Replies: 6
    Last Post: 15th October 2008, 07:34 AM
  5. VBS script for prestaging computers anyone?
    By ChrisH in forum Scripts
    Replies: 7
    Last Post: 23rd June 2006, 09:59 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •