×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Shell to a program based on OS Version

Shell to a program based on OS Version

Shell to a program based on OS Version

(OP)
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!!!

RE: Shell to a program based on OS Version

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: Eng-Tips.com Forum Policies

Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers

Of course I can. I can do anything. I can do absolutely anything. I'm an expert!

RE: Shell to a program based on OS Version

(OP)
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).

RE: Shell to a program based on OS Version

Sure, but I'm not sure why my Windows 8.1 returned 6.02, since this is what Microsoft says it should be:

http://msdn.microsoft.com/en-us/library/windows/de...

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: Eng-Tips.com Forum Policies

Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers

Of course I can. I can do anything. I can do absolutely anything. I'm an expert!

RE: Shell to a program based on OS Version

There's no option for some sort of Bentley Licence audit if you're running a network licence system?

RE: Shell to a program based on OS Version


Quote:

Sure, but I'm not sure why my Windows 8.1 returned 6.02, since this is what Microsoft says it should be:

http://msdn.microsoft.com/en-us/library/windows/de...

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
http://newtonexcelbach.wordpress.com/

RE: Shell to a program based on OS Version

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources