locked
Running sequence of tasks in one script RRS feed

  • Question

  • Good afternoon

    I have the below scripts which I need to run in one script.

    I cant get the second script to execute so I think I'm missing command line to continue

    can anyone advise whats missing please, the script is below?

    I need to run script 1, then script 2 then end

    'script1 - input HKCU
    On Error Resume Next
    const HKCU = &H80000001
    Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
    Set wshShell = CreateObject( "WScript.Shell" )
    Sammie =  wshShell.ExpandEnvironmentStrings("%USERNAME%")

    Key = "Software\Microsoft\Office\16.0\Word\Options"
    oReg.CreateKey HKCU, Key
    oReg.SetStringValue HKCU, Key, "PersonalTemplates", "C:\Program Files (x86)\Office Templates"

    Set oReg = Nothing
    set wshShell = Nothing

    'script 2 - copy file

    Option Explicit
     Dim oFSO, strAppData, objShell
     Set objShell = CreateObject("WScript.Shell")
     Set oFSO = CreateObject("Scripting.FileSystemObject")
     objShell.CurrentDirectory = oFSO.GetParentFolderName(WScript.ScriptFullName)
     strAppData=objShell.ExpandEnvironmentStrings("%APPDATA%") & "\Microsoft\templates" & "\"
     oFSO.CopyFile "blank.potx", strAppData, True
     Set objShell = Nothing
     Set oFSO = Nothing

    Thursday, July 13, 2017 11:05 AM

Answers

  • Good afternoon

    I  will be using active setup to run the scripts on login for each user.

    the msi will merely put the scripts down to the machine, I was running the custom action for the logged on user, but not even sure that would work with the system account

    thanks for your help

    the personal templates folder works using this method, I have tested it, you change the key to one that works and it appears correctly on the machine.

    please close this request as answered, I have a method which now works.

    thanks

    • Marked as answer by Keane2017 Thursday, July 13, 2017 2:50 PM
    Thursday, July 13, 2017 2:50 PM
  • Good afternoon

    I  will be using active setup to run the scripts on login for each user.

    the msi will merely put the scripts down to the machine, I was running the custom action for the logged on user, but not even sure that would work with the system account

    thanks for your help

    the personal templates folder works using this method, I have tested it, you change the key to one that works and it appears correctly on the machine.

    please close this request as answered, I have a method which now works.

    thanks

    What you are trying to do will cause you issues in the future.,  Consider learning how to do this correctly.

    You say you are using ActiveSetup and not an MSI.  Changing the nature of your questions is not a good way to ask a technical question.

    Try to ask an accurate and complete question the next time you post.  You will find it easier to get answers that way.

    Active Setup executes scripts in the order defined in the config file. 


    \_(ツ)_/

    good afternoon,

    what I needed the script for was not relevant to this piece.

    I simply asked how I link the two together, the rest doesn't matter as I have all that in place and don't need guidance with this.

    I will look up the GPO way of deploying it, I don't need lectures, I asked a simple question about a script that was all, whats in the scripts or how I deploy wasn't relevant to the question.

    I know exactly how active setup works, I know why I'm using it.

    I am using active setup in an MSI, its standard practice for HKCU Keys or APPDATA files when deploying these.

    thanks for your help, I will consider this closed

    • Marked as answer by Keane2017 Thursday, July 13, 2017 3:15 PM
    Thursday, July 13, 2017 3:15 PM

All replies

  • Not enough information to guess at what you are asking.

    I recommend asking the author of the scripts for help.

    The easiest solutions is to combine both scripts into one file.

    Since you do  not understand scripting I recommend that you should start by learning PowerShell as VBScript is obsolete.

    Note also that we do not fix or modify scripts on request.


    \_(ツ)_/

    Thursday, July 13, 2017 1:05 PM
  • Good afternoon,

    I am simply asking what I need to add for script 1 to run and then script 2 once script 1 is completed

    there is an next command or something missing but I aren't sure what

    it cannot be powershell as its for a custom action in an MSI.

    I don't want the script modifying I just wanted peoples advise on whats missing

    but since you cant offer that no worries

    thanks

    Thursday, July 13, 2017 1:15 PM
  • For how to use MSI script steps please post in the Developers forum.  This forum is only for administrative scripting.

    Again - the simplest way is to combine both scripts into one.


    \_(ツ)_/

    Thursday, July 13, 2017 1:35 PM
  • this is a scripting question.........

    the question was simple,

    I merely asked what I add between script 1 and 2 to get it to continue so that when script 1 runs it then moves onto script 2, this is as much info as was needed, I haven't being able to figure it out hence been on here.

    I didn't come on here for a lecture, I came on here for some help.........


    • Edited by Keane2017 Thursday, July 13, 2017 1:42 PM
    Thursday, July 13, 2017 1:41 PM
  • You concepts and question are technically wrong.

    Just add the two script together and they will run sequentially. 

    Please post you issue to the developers forum as that is where MSI is supported.  You are in the wrong forum.


    \_(ツ)_/

    Thursday, July 13, 2017 1:44 PM
  • You concepts and question are technically wrong.

    Just add the two script together and they will run sequentially. 

    Please post you issue to the developers forum as that is where MSI is supported.  You are in the wrong forum.


    \_(ツ)_/

    Hi again,

    I have added both together and they do not run...

    that's why I'm on here

    its not an MSI supported question, its a vb script query.... so I aren't in the wrong forum

    the issue is when having both scripts displayed as above it errors

    Line: 15

    char: 1

    error: expected statement

    code: 800a0400

    source: Microsoft vbscript compilation error

    so it runs script 1, then on the option explicit section of script 2 I get that error.

    Regards

    Thursday, July 13, 2017 1:49 PM
  • To run one script after the other, create a batch file that contains two lines in it:


    @cscript "d:\path\script1.vbs"
    @cscript "d:\path\script2.vbs"
    

    If you want to combine the scripts into a single file, you need to know how to incorporate the code together. (You can't just paste one file into the other.) Since you don't know VBScript, the above will be simpler.


    -- Bill Stewart [Bill_Stewart]

    Thursday, July 13, 2017 1:54 PM
  • You concepts and question are technically wrong.

    Just add the two script together and they will run sequentially. 

    Please post you issue to the developers forum as that is where MSI is supported.  You are in the wrong forum.


    \_(ツ)_/

    Hi again,

    I have added both together and they do not run...

    that's why I'm on here

    its not an MSI supported question, its a vb script query.... so I aren't in the wrong forum

    the issue is when having both scripts displayed as above it errors

    Line: 15

    char: 1

    error: expected statement

    code: 800a0400

    source: Microsoft vbscript compilation error

    so it runs script 1, then on the option explicit section of script 2 I get that error.

    Regards

    Yes you VBScript have errors.  You only asked about how to run them sequentially.  VBScript run from an MSI cannot use CScript or batch files.   To learn how to call a sequence of scripts in an MSI you will need to post in the VS developers forum.

    An MSI is a database of instructions to the installer service.  YOU will have to store the scripts in the MSI then add them to the installer task sequence as needed.  This is not something that can be done by external means.

    The following line cannot be used in an MSI script:

      objShell.CurrentDirectory = oFSO.GetParentFolderName(WScript.ScriptFullName)

    There are other issues with the scripts when run in an MSI which you will have to learn MSI technology to fix.  All of that is beyond the scope of this forum.


    \_(ツ)_/

    Thursday, July 13, 2017 2:18 PM
  • Another issue is that the script, when run from an MSI, will not work as the MSI is run under the TRusted Installer account and not the user account referenced in the script.

    If you are trying to configure a users templates then we would use Group Policy to do this as it cannot be done this way.  Another way to do it is to have the installer define a global "first run" script for MSWord that will update each users hive the next time the user runs Word.

    To learn how to correctly configure Word and Office post int eh Office deployment forum.

    If you just want to have the user run a script to do this then this script should work:

    Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
    Key = "Software\Microsoft\Office\16.0\Word\Options"
    oReg.CreateKey HKCU, Key
    oReg.SetStringValue &H80000001, Key, "PersonalTemplates", "C:\Program Files (x86)\Office Templates"
    
    Set wshShell = CreateObject( "WScript.Shell" )
    username =  wshShell.ExpandEnvironmentStrings("%USERNAME%")
    Set oFSO = CreateObject("Scripting.FileSystemObject") 
     
    strAppData = wshShell.ExpandEnvironmentStrings("%APPDATA%") & "\Microsoft\templates"
    oFSO.CopyFile "blank.potx", strAppData, True
    

    Of course the settings you are using don't really make any sense.  The Personal templates folder is not set in the registry for Word 16 (2016).  The templates folder is set via policy and is also defined in the profile and should not be moved except via a GPO.

    If you research a bit you will fin an environment variable that defines the current templates folder.

    Here is the default folder:

    "C:\Users\%username%\Documents\Custom Office Templates\"

    To correctly get the current document folder:

    [environment]::GetFolderPath([System.Environment+SpecialFolder]::MyDocuments)

    The public folder is here:

    [environment]::GetFolderPath([System.Environment+SpecialFolder]::CommonDocuments)

    This is the default and it should not be moved.  TO share templates we would place them in the "public" profile or relocate the public office template folder to a network share using a GPO.

    Post in "Office Deployment" forum for instructions on how to mage Office and why you would do it in a specific way.

    A moderator should move this thread to that forum so that you can get re-oriented about deploying Office.

    Using an "admin" install you can customize the installer and the per-user deployment with a PRF file.


    \_(ツ)_/

    Thursday, July 13, 2017 2:45 PM
  • Good afternoon

    I  will be using active setup to run the scripts on login for each user.

    the msi will merely put the scripts down to the machine, I was running the custom action for the logged on user, but not even sure that would work with the system account

    thanks for your help

    the personal templates folder works using this method, I have tested it, you change the key to one that works and it appears correctly on the machine.

    please close this request as answered, I have a method which now works.

    thanks

    • Marked as answer by Keane2017 Thursday, July 13, 2017 2:50 PM
    Thursday, July 13, 2017 2:50 PM
  • Good afternoon

    I  will be using active setup to run the scripts on login for each user.

    the msi will merely put the scripts down to the machine, I was running the custom action for the logged on user, but not even sure that would work with the system account

    thanks for your help

    the personal templates folder works using this method, I have tested it, you change the key to one that works and it appears correctly on the machine.

    please close this request as answered, I have a method which now works.

    thanks

    What you are trying to do will cause you issues in the future.,  Consider learning how to do this correctly.

    You say you are using ActiveSetup and not an MSI.  Changing the nature of your questions is not a good way to ask a technical question.

    Try to ask an accurate and complete question the next time you post.  You will find it easier to get answers that way.

    Active Setup executes scripts in the order defined in the config file. 


    \_(ツ)_/

    Thursday, July 13, 2017 3:02 PM
  • Good afternoon

    I  will be using active setup to run the scripts on login for each user.

    the msi will merely put the scripts down to the machine, I was running the custom action for the logged on user, but not even sure that would work with the system account

    thanks for your help

    the personal templates folder works using this method, I have tested it, you change the key to one that works and it appears correctly on the machine.

    please close this request as answered, I have a method which now works.

    thanks

    What you are trying to do will cause you issues in the future.,  Consider learning how to do this correctly.

    You say you are using ActiveSetup and not an MSI.  Changing the nature of your questions is not a good way to ask a technical question.

    Try to ask an accurate and complete question the next time you post.  You will find it easier to get answers that way.

    Active Setup executes scripts in the order defined in the config file. 


    \_(ツ)_/

    good afternoon,

    what I needed the script for was not relevant to this piece.

    I simply asked how I link the two together, the rest doesn't matter as I have all that in place and don't need guidance with this.

    I will look up the GPO way of deploying it, I don't need lectures, I asked a simple question about a script that was all, whats in the scripts or how I deploy wasn't relevant to the question.

    I know exactly how active setup works, I know why I'm using it.

    I am using active setup in an MSI, its standard practice for HKCU Keys or APPDATA files when deploying these.

    thanks for your help, I will consider this closed

    • Marked as answer by Keane2017 Thursday, July 13, 2017 3:15 PM
    Thursday, July 13, 2017 3:15 PM
  • I will look up the GPO way of deploying it, I don't need lectures, I asked a simple question about a script that was all, whats in the scripts or how I deploy wasn't relevant to the question.

    I know exactly how active setup works, I know why I'm using it.

    I am using active setup in an MSI, its standard practice for HKCU Keys or APPDATA files when deploying these.

    thanks for your help, I will consider this closed

    First it is not standard but is an older and deprecated method.

    Second you didn't ask a question about Active Setup.  If you had the answer would have been simple.

    Using older Office hacks to do installs will eventually get you into trouble in a distributed environment and it is also much harder to maintain.

    Since you are such an expert with AS how come you didn't know how to add the two scripts to the setup? With AS you can use bills method but you will also have to add a batch file to the AS package.


    \_(ツ)_/

    Thursday, July 13, 2017 3:33 PM
  • I will look up the GPO way of deploying it, I don't need lectures, I asked a simple question about a script that was all, whats in the scripts or how I deploy wasn't relevant to the question.

    I know exactly how active setup works, I know why I'm using it.

    I am using active setup in an MSI, its standard practice for HKCU Keys or APPDATA files when deploying these.

    thanks for your help, I will consider this closed

    First it is not standard but is an older and deprecated method.

    Second you didn't ask a question about Active Setup.  If you had the answer would have been simple.

    Using older Office hacks to do installs will eventually get you into trouble in a distributed environment and it is also much harder to maintain.

    Since you are such an expert with AS how come you didn't know how to add the two scripts to the setup? With AS you can use bills method but you will also have to add a batch file to the AS package.


    \_(ツ)_/

    Again, because active setup wasn't relevant, I wanted help with the script, nothing else....

    the thread was about how I binded the two scripts into one, nothing else

    Thursday, July 13, 2017 3:40 PM
  • Again, because active setup wasn't relevant, I wanted help with the script, nothing else....

    the thread was about how I binded the two scripts into one, nothing else

    Yes and I posted that you should just add the two scripts into one file. As you questions referenced an MSI script this was the only solution. If you had said you were deploying the scrips with AS then it would have been a different issue.

    Without understanding what is different between saying you are "using" the scripts in an  MSI deployment and saying you are "deploying" the scripts with AS the only answer I could give had to assume that you were giving us the correct information n which you were not.

    Technical issues requires accurate, unambiguous questions.


    \_(ツ)_/

    Thursday, July 13, 2017 3:46 PM