[SOLVED] VBScript: A under Reflect v6 perfect running script doesn't run under v7


[SOLVED] VBScript: A under Reflect v6 perfect running script doesn't...
Author
Message
jphughan
jphughan
Macrium Evangelist
Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)
Group: Forum Members
Posts: 8.8K, Visits: 59K
In addition to Nick’s idea, a manual run from the VBScript Files tab runs the script as the user currently logged into Windows. A manual run from the Scheduled Backups tab runs the script as whatever user is conducted for scheduled tasks, so those will not always behave the same way. But yes I too would be curious what happens if you run the script just from an elevated Command Prompt. If that works, are you using your own logon account as the scheduled task user in Reflect?
Joachim
Joachim
Junior Member
Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)
Group: Forum Members
Posts: 41, Visits: 60
Nick - 15 February 2018 6:23 PM
How have you run the script outside of Reflect?

I tested my own script to see, if the NAS would shutdown:
1. I run my uncompiled NAS-shutdown-script ("VBScript-Test-MRv7x.vbs") from VbsEdit to check, if it runs correct. -> Yes, it shutdown my NAS.
2. I run my compiled NAS-shutdown-script ("VBScript-Test-MRv7x.exe") - see below.
Nick - 15 February 2018 6:23 PM
Macrium Reflect runs with Elevated Privileges, this affects the process tokens though is no different between v6 and v7. 
What happens if you run the script from an Elevated (Run as Administrator) command prompt?


DOS-Box as Admin: > VBScript-Test-MRv7x.exe 1
Simple, it shutdown my NAS!

And I run "Reflect-Backup-VBScript-Test.txt" (as .vbs) from VbsEdit (outside Reflect): -> It shutdown my NAS.
But if I run "Reflect-Backup-VBScript-Test.txt" from inside Reflect (as Backup-VBScript) per "VBScript Files" -> "Run now" or per "Scheduled Task" -> "Run now" then, in both cases, my NAS was not shutdown.
Just again explicitly tested. 

Because of this, I mean there are differences between v6 and v7.


@jphughan: I have nothing done with PowerShell until today. Can you tell me, how can I run a Program (e.g. "VBScript-Test-MRv7x.exe ...") with a lot of parameter from PowerShell (like my example in "Reflect-Backup-VBScript-Test.txt":
objShell.Run """C:\Program Files (x86)\MagicPacket\NAS & Shares.exe"" /Read:""C:\Program Files (x86)\MagicPacket\NAS & Shares - Backups.txt"" /EventTextSelect:01 /RemoveDLs /NASoff", 1, True)?


jphughan
jphughan
Macrium Evangelist
Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)
Group: Forum Members
Posts: 8.8K, Visits: 59K
If you want to use PowerShell, the easiest way to run an EXE is to just place an "&" character at the beginning of the line, then just write the rest of the line the same way you would if you were running from Command Prompt, so do NOT use multiple sets of double quotes the way you are in your VBScript.  One possible catch with that design is that PowerShell will NOT wait for that external application to complete before proceeding with the script.  That's not typical PowerShell behavior, but it's true for that particular mechanism.  If you DO want PowerShell to wait for that application to complete before continuing, then the better way to call an external application is to use the Start-Process cmdlet with the Wait parameter, but then some extra care needs to be taken with parameters.  But if this application you're calling is also the end of the script, then the "&" invocation method is simpler.

Edited 15 February 2018 8:45 PM by jphughan
Nick
Nick
Macrium Representative
Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)
Group: Administrators
Posts: 2.3K, Visits: 14K
Joachim - 15 February 2018 8:29 PM
Nick - 15 February 2018 6:23 PM
How have you run the script outside of Reflect?

I tested my own script to see, if the NAS would shutdown:
1. I run my uncompiled NAS-shutdown-script ("VBScript-Test-MRv7x.vbs") from VbsEdit to check, if it runs correct. -> Yes, it shutdown my NAS.
2. I run my compiled NAS-shutdown-script ("VBScript-Test-MRv7x.exe") - see below.
Nick - 15 February 2018 6:23 PM
Macrium Reflect runs with Elevated Privileges, this affects the process tokens though is no different between v6 and v7. 
What happens if you run the script from an Elevated (Run as Administrator) command prompt?


DOS-Box as Admin: > VBScript-Test-MRv7x.exe 1
Simple, it shutdown my NAS!

And I run "Reflect-Backup-VBScript-Test.txt" (as .vbs) from VbsEdit (outside Reflect): -> It shutdown my NAS.
But if I run "Reflect-Backup-VBScript-Test.txt" from inside Reflect (as Backup-VBScript) per "VBScript Files" -> "Run now" or per "Scheduled Task" -> "Run now" then, in both cases, my NAS was not shutdown.
Just again explicitly tested. 

Because of this, I mean there are differences between v6 and v7.


@jphughan: I have nothing done with PowerShell until today. Can you tell me, how can I run a Program (e.g. "VBScript-Test-MRv7x.exe ...") with a lot of parameter from PowerShell (like my example in "Reflect-Backup-VBScript-Test.txt":
objShell.Run """C:\Program Files (x86)\MagicPacket\NAS & Shares.exe"" /Read:""C:\Program Files (x86)\MagicPacket\NAS & Shares - Backups.txt"" /EventTextSelect:01 /RemoveDLs /NASoff", 1, True)?


DOS-Box as Admin: > VBScript-Test-MRv7x.exe 1


Not quite sure why the script needs to be compiled. Can you repeat by running the .vbs file the same as in Reflect, from an elevated command prompt?

​​Can you download ​ ReflectBinv6.exe from here:
http://updates.macrium.com/Reflect/v6/v6.3.1852/reflectbinv6.exe​​

Copy to the Reflect installation folder and launch by double clicking in Explorer.  Can you let me know whether it behaves differently to v7 when launching your VBScript file?

Just launch from the VBScript tab​​, please don't try any other functionality. 

Thanks​​​ ​​

Kind Regards

Nick - Macrium Support

Next Webinar


Edited 15 February 2018 10:35 PM by Nick
Joachim
Joachim
Junior Member
Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)
Group: Forum Members
Posts: 41, Visits: 60

@Nick: Do you know how long my original script (working under v6) is (over 1600 lines)? (In the commented out lines in "Reflect-Backup-VBScript-Test.txt" (lines 'objShell.Run """C:\Program Files (x86)\MagicPacket\NAS & Shares.exe"" /Read:""C:\Program Files (x86)\MagicPacket\NAS & Shares - Backups.txt"" /EventTextSelect:01"... ' you can see that my original script is called several times possible with different parameters.)
Therefore, in "VBScript-Test-MRv7x.txt" I only had a short part, that did not work in the overall script, summarized and posted as a problem example.
It's also easier to test a script in a stand-alone environment - and if it works, compile it if necessary, and use it as a standalone application. This also simplifies troubleshooting, development, ... and it prevents side effects.

It's very late in the evening in Germany - hopefully google translates now reasonably - ... so I'll test the download tomorrow and then report it.
If it does not work out tomorrow - I'll be back after my one-week vacation.


@jphughan: It would be helpful for me to know, how to use PowerShell to call a program such as "XYZ.exe" in path y with Parameters; like '"C:\Program Files\XYZ.exe" /Read:"C:\Program Files (x86)\Parameter File.txt" /EventSelect:01 /NASoff'.
Thanks.


Joachim
Joachim
Junior Member
Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)
Group: Forum Members
Posts: 41, Visits: 60
@Nick: Download http://updates.macrium.com/Reflect/v6/v6.3.1852/reflectbinv6.exe not successful: "Server Error: 404 - File or directory not found."
Nick
Nick
Macrium Representative
Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)Macrium Representative (4.1K reputation)
Group: Administrators
Posts: 2.3K, Visits: 14K
Joachim - 15 February 2018 10:16 PM
@Nick: Download http://updates.macrium.com/Reflect/v6/v6.3.1852/reflectbinv6.exe not successful: "Server Error: 404 - File or directory not found."

No problem, it's late here as well. Just curious to know if you tried the same VBScript that you're running from an elevated command prompt as the one that isn't working when run from within Reflect. As I understand it is calling the compiled script, but I just wanted to ensure we're comparing like with like.

The download link is working so I'll paste it again to ensure there hasn't been a problem with the url in the previous post:
http://updates.macrium.com/Reflect/v6/v6.3.1852/reflectbinv6.exe





Kind Regards

Nick - Macrium Support

Next Webinar


Edited 15 February 2018 10:32 PM by Nick
jphughan
jphughan
Macrium Evangelist
Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)Macrium Evangelist (13K reputation)
Group: Forum Members
Posts: 8.8K, Visits: 59K
Joachim - 15 February 2018 10:11 PM

@jphughan: It would be helpful for me to know, how to use PowerShell to call a program such as "XYZ.exe" in path y with Parameters; like '"C:\Program Files\XYZ.exe" /Read:"C:\Program Files (x86)\Parameter File.txt" /EventSelect:01 /NASoff'.
Thanks.


To run that in PowerShell, your script line would look like the below.  Note that you would NOT surround the entire expression with single quotes like you did in the line you posted above.

& "C:\Program Files\XYZ.exe" /Read:"C:\Program Files (x86)\Parameter File.txt" /EventSelect:01 /NASoff

PowerShell is often quite a bit cleaner than VBScript because it has the benefit of hindsight from several years of VBScript. Smile

Edited 15 February 2018 11:25 PM by jphughan
Joachim
Joachim
Junior Member
Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)
Group: Forum Members
Posts: 41, Visits: 60

@Nick:
1. In the meantime I have downloaded the "reflectbinv6.exe". Thank you.
2. You're right, of course, I can run the VBScript lines needed for the NAS shutdown directly in the backup SBScript (without compiling).

I will test both after my short holiday and then report with hopefully news.


@jphughan:
Thanks for the example in PowerShell. I will also test that on occasion.


Joachim
Joachim
Junior Member
Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)Junior Member (53 reputation)
Group: Forum Members
Posts: 41, Visits: 60

Hello Nick,

back again, but this week probably no possibilities to shut down my NAS. Therefore, further tests have to wait.

But in the meantime, I have summarized the logs of my script a bit, so that I can prove to you, that, since September 2016 under Reflect v6.x until exactly the day of the upgrade to version 7.1.x, my NAS was shutdown regularly by my script; over 500 times.

My script called "NAS & Shares.exe" (a compiled WScript) has two tasks and is called twice per Reflect backup task (see "Reflect-Backup-VBScript.vbs.txt") and writes his own log file.
The first call immediately before the real backup call in the Reflect backup task (VBScript, "Sub VBMain()") checks whether my NAS is switched on or not, remembers this state and possibly turns on the NAS.

After executing this real backup call in the Reflect backup task, depending on the backup type ("-full" or "-inc"), my NAS shuts down; with incremental backup then, if "NAS & Shares" had previously turned on the NAS or during full backups, my NAS will always shutdown due to the parameter "/NASoff".

This worked in total from September 2016 to February 04, 2018 under Reflect v6.x.

On February 05, 2018, I upgraded to Reflect v7.1.2885. And from that day on, shutting down the NAS does not work anymore; neither in the described dependency for "inc"-backups nor with the parameter "/NASoff". (The other tasks of "NAS & Shares.exe" are executed correctly.)

The problem, as far as I could identify with the help of my "NAS & Shares.log" (see "NAS & Shares.log.txt"), is the execution of the command "PLink.exe -load PuTTY-Session -l NAS_User -batch -pw "NAS-User_Password" sudo -S <<< "NAS-User_Password" /sbin/shutdown -P +1 ", because PLink now returns the return code 1 from inside the Reflect-VBScript environment. The 'PuTTY-Session' contains a valid SSH-access to NAS on a non-standard SSH-Port. PuTTY v0.67 and v0.70.
"NAS & Shares.exe" called about with a prompt with appropriate parameters, works!
Alternatively, after changing the NAS_User rights, I tested e.g. unsuccessfully: "PLink.exe -load PuTTY-Session -l NAS_User -batch -pw "NAS-User_Password" sudo "NAS-User_Password" /sbin/poweroff". Of course, this call also works from the command prompt.

I think there is hardly a stronger indication of a changed handling of VBScript files between Reflect v6 and Reflect v7.1.

Enclosed the used, original and complete, VBScript file "Reflect-Backup-VBScript.vbs.txt" (Reflect v6.x); the two "NAS & Schares.exe" calls are in "Sub VBMain ()".
Also I have attached the summarized log file of "NAS & Shares.exe" as "NAS & Shares.log.txt", too; I have marked manual explanations with "########".


I would like to see this as an indication of changes in handling between Reflect v6 and v7.1. I can not offer much more from my point of view, because I can not and do not want to get into the depths of Reflect.

Of course, I am happy to answer any questions.

If I can shut down my NAS again, I'll test "reflectbinv6.exe" as a precaution; but due to my logs and circumstances with little hope.

Best regards, Joachim.


Attachments
Reflect-Backup-VBScript.vbs.txt (2 views, 16.00 KB)
NAS & Shares.log.txt (1 view, 124.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Login

Explore
Messages
Mentions
Search