Just today, I made myself work a lot harder than was ever necessary. It started with a little bit of overconfidence, transitioned to about thirty minutes of frustration and swearing, and ended with success and a self deprecating laugh.
It started when I need to create a sample script to defragment an Autodesk Vault database.
How hard can it be, after all? It's a short script. It's only a few lines long anyway!
First, I grab the sample script from the Vault Help system. You can find that in the defragment section at this link.
So now I have my command!
Connectivity.ADMSConsole.exe -Odefragmentvault -NVault -VUAdministrator -VPadmin -S
This will fire up the command, but I still need to add my path information as well as my Vault name, I also need to add my administrator username and password.
REM - This Script Defrags the VAult Database
REM - Switch Legend
REM - Odefragmentvault ==> Command to defrag database
REM - -N Designates Vault name (this will vary machine to machine)
REM - -VU Vault user (must have administrator rights)
REM - -VP Vault password
REM - -S runs the script silently
D:\Program Files\Autodesk\ADMS Professional 2015\ADMS Console\Connectivity.ADMSConsole.exe -Odefragmentvault -NArduinna -VUadministrator -VP -S
IISRESET
Now, time for the test.
I run it once, it flashes on the screen and immediately disappears.
I check for syntax error, and I do find one. Which I quickly fix.
But the script doesn't run.
I check my vault name, my administrator name. My vault doesn't even have a password!
And for those of you with your mouse key on the comment button... I know it's bad practice not to have a password for the administrator! But this is a personal Vault, on my laptop, which only I access. So Thpppt!
Finally, I have an idea. One that I should have had a lot earlier than I did..
I add the word Pause at the end of my script. So the script won't disappear when it finishes.
Let's take a second and think about this. |
As soon as I run the script. I see two words immediately. "Not Recognized".
I say phrases commonly found in garages, aircraft hangars, and factories everywhere.
The double quotes at the each end of the path are missing!
Wait! What? This is the problem! |
It felt a little like this. (From the Ren & Stimpy Show) |
If you don't , the script reaches the first space it sees, and tries to execute that.
So my batch file got to D:\Programs, tried to run that, and didn't know what to do.
In order to fix the script, I had to change the command line to look like what is below:
"D:\Program Files\Autodesk\ADMS Professional 2015\ADMS Console\Connectivity.ADMSConsole.exe" -Odefragmentvault -NArduinna -VUadministrator -VP -S
The quotes (in red) placed before D:\Program and after ADMSConsole.exe make all the difference in the world.
One more shot, and it runs fine!
So the final script looks like this.
REM - This Script Defrags the Vault Database
REM - Switch Legend
REM - Odefragmentvault ==> Command to defrag database
REM - -N Designates Vault name (this will vary machine to machine)
REM - -VU Vault user (must have administrator rights)
REM - -VP Vault password
REM - -S runs the script silently
"D:\Program Files\Autodesk\ADMS Professional 2015\ADMS Console
\Connectivity.ADMSConsole.exe" -Odefragmentvault -NArduinna -VUadministrator -VP -S
IISRESET
And that's it! It's ready to go.
Ultimately, what did I take a way from this one?
- Use the PAUSE command to help analyze scripts. Because it was a short script, I figured if I studied it, I could find my error. But I didn't see the missing quotes. I missed the trees because of the forest, if you will. By adding the PAUSE command, I found my error in seconds. Literally seconds!
- Slow down, you'll go faster. Since this was an easy script, I thought I'd "bust it out quick". Had I taken a little more time, and thought about my approach when I hit a snag, I may have solved it easier.
- Pay it forward. I made a mistake. One I should have been able to avoid. Here it is for you to learn from. Hopefully, you can use this to avoid the pitfalls I found!
On a final note, there are several administrative commands that can be scripted using batch files in Autodesk Vault.
Learn more about them by following the link to the Autodesk site here!