Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell to a program based on OS Version 1

Status
Not open for further replies.

SteveGregory

Structural
Jul 18, 2006
554
I am working on an Excel VBA macro that will keep a record of software usage.

After opening the spreadsheet, clicking a command button will stamp the current time and user name in the cell selected, move to the next cell down and launch a program. The path for the program being launched changes for a different Windows OS. I found an excel =INFO("osversion") function, but that returns "Windows (32-bit) NT 5.01" on my XP machine. I guess that works fine if it always works this way for Windows XP. What does this function return for Windows 7? Or perhaps you have a better way.

After the program is exited, the macro resumes and stamps the current time and user name in the new cell selected, moves to the next cell down and then saves the current spreadsheet and closes it.

Here is what I have so far:
Private Sub CommandButton1_Click()
Dim RetVal
ActiveCell = Now() & Environ("username")
ActiveWorkbook.Save
ActiveCell.Offset(1, 0).Select
'Win XP:RetVal = Shell("C:\Program Files\Bentley\Engineering\RAM Elements\RAMElements.exe", 1)
'Win 7:RetVal = Shell("C:\Program Files (x86)\Bentley\Engineering\RAM Elements\RAMElements.exe", 1)
RetVal = Shell("????... ????", 1)
ActiveCell = Now() & Environ("username")
ActiveCell.Offset(1, 0).Select
ActiveWorkbook.Close SaveChanges:=True
End Sub

Thanks for your help!!!
 
Replies continue below

Recommended for you

My Windows 7-32b returns

Windows (32-bit) NT 6.01

but my Windows 8.1-64b returns

Windows (32-bit) NT 6.02

But I think that's because it's a 32-b version of Excel.


TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529

Of course I can. I can do anything. I can do absolutely anything. I'm an expert!
 
Thanks, IR. I could parse function return so 5 represents XP and 6 represents Windows 7.

Next, I need to figure out how to get the macro to wait until I exit the program before executing the final steps of the macro (stamping the time, saving and closing).
 
Sure, but I'm not sure why my Windows 8.1 returned 6.02, since this is what Microsoft says it should be:


But that's assuming you can get the answer directly from the OS. This is what my command shell says for Windows 7, which is consistent with what Microsoft says:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

My Windows 8.1 command window shows Version 6.3.9600

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529

Of course I can. I can do anything. I can do absolutely anything. I'm an expert!
 
There's no option for some sort of Bentley Licence audit if you're running a network licence system?
 
Sure, but I'm not sure why my Windows 8.1 returned 6.02, since this is what Microsoft says it should be:


See from link:
* For applications that have been manifested for Windows 8.1. Applications not manifested for 8.1 will return the Windows 8 OS version value (6.2). To manifest your applications for Windows 8.1 please refer to Targeting your application for Windows 8.1.

Doug Jenkins
Interactive Design Services
 
Freddy,
I am not sure if the local network server option is still available. Using Bentley's internet "server" allows us to use the programs at home at night or weekends. Bentley's structural programs have transitioned from allowing users to use a program if a license is available to "trust" licensing.

"Trust" means you can use as many licenses as you want. Bentley logs your usage in 1-hour increments. So if you own 1 license of "X" and Sam exits the program at 9:45. Then Cathy runs the program at 9:50. This counts as 2 license uses or one more than you own. So at the end of every 3 months, Bentley will check the logs and bill you for a 3-month "lease" for the extra licenses you used. If Cathy could have waited 10 minutes, then no extra charge!

We are trying to manage our usage to prevent extra charges.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor