Environment variables and NiceForm

Label printing integration (NiceWatch middleware and ActiveX programming interface)

Moderators: Georges, milos, NiceLabel Support Team

Post Reply
User avatar
Frank
Addict
Addict
Posts: 282
Joined: Tue Oct 24, 2006 8:51 am
Location: Germany / Minden
Contact:

Environment variables and NiceForm

Post by Frank » Thu Feb 24, 2011 9:27 am

Hi,

with Batch programming I can use „Environment variable” e.g.:set path = %ALLUSERSPROFILE%
so that the path to my labels is always the same, “independent of the used Windows OS”

is that also possible within NiceForm VB scripting?
I didn’t found working examples for NiceForm yet…

It would be helpful to program a “Path to my labels”
that working in 2000/XP and Vista/Win7 and German/English
.... without making symlinks and study the necessary user rights...
Regards
Frank Breuckmann

Image
-AVERY Partner
-Intermec Fingerprint programming
no printer, no time? -> no problem, we can print for you! service@sde-web.de

alesp
NiceLabel Development
NiceLabel Development
Posts: 153
Joined: Tue Sep 26, 2006 1:26 pm
Location: Kranj, Slovenia
Contact:

Re: Environment variables and NiceForm

Post by alesp » Thu Feb 24, 2011 10:53 pm

If you would put them in the "My documents" folder (or subfolder in there) of your users computers you could get that path by using SpecialFolders property of the "WScript.Shell" object. Here is a sample that shows how that property can be used and what information you can get:

Code: Select all

Set wsh = CreateObject("WScript.Shell")
MsgBox wsh.SpecialFolders("MyDocuments")
MsgBox wsh.SpecialFolders("AllUsersDesktop")
MsgBox wsh.SpecialFolders("AllUsersStartMenu")
MsgBox wsh.SpecialFolders("AllUsersPrograms")
MsgBox wsh.SpecialFolders("AllUsersStartup")
MsgBox wsh.SpecialFolders("Desktop")
MsgBox wsh.SpecialFolders("Favorites")
MsgBox wsh.SpecialFolders("Fonts")
MsgBox wsh.SpecialFolders("NetHood")
MsgBox wsh.SpecialFolders("PrintHood")
MsgBox wsh.SpecialFolders("Programs")
MsgBox wsh.SpecialFolders("Recent")
MsgBox wsh.SpecialFolders("SendTo")
MsgBox wsh.SpecialFolders("StartMenu")
MsgBox wsh.SpecialFolders("Startup")
MsgBox wsh.SpecialFolders("Templates")
I believe this should work on all systems but it is better you test it first.

But if you would still like to define an environment variable and use that, here is a short script that returns a couple of environment variables and displays them:

Code: Select all

Set wsh = CreateObject("WScript.Shell")
user = wsh.ExpandEnvironmentStrings("%UserName%")
comp = wsh.ExpandEnvironmentStrings("%ComputerName%")
MsgBox user & " " & comp
MsgBox wsh.ExpandEnvironmentStrings("%Tmp%")
MsgBox wsh.ExpandEnvironmentStrings("%Path%")
Regards,

Ales

User avatar
Frank
Addict
Addict
Posts: 282
Joined: Tue Oct 24, 2006 8:51 am
Location: Germany / Minden
Contact:

Re: Environment variables and NiceForm

Post by Frank » Fri Feb 25, 2011 9:52 am

THX,
that's what I'm searching for...

unfortunately I used %ALLUSERSPROFILE%

Vista/WIN7 = C:\ProgramData\ <---German / English
2000/xp = C:\Dokumente und Einstellungen\All Users\ <-- German
2000/xp = C:\Documents and Settings\All Users\ <-- English

I know that... Nicelabel expect read/write rights in exactly this path...
so that I "never mind" about user rights...

anyway... I'm searching for a destination path for: NiceForm, logos, labels....
without become trouble with user rights, and it should working in German/English Win OS 2000/XP, Vista/Win7
therefore i need a path (inside Niceform) that work with "Environment Variables"


########################
edit:

->> wsh.ExpandEnvironmentStrings("%ALLUSERSPROFILE%")
is, what I need.....
THX for helping... =D>
Regards
Frank Breuckmann

Image
-AVERY Partner
-Intermec Fingerprint programming
no printer, no time? -> no problem, we can print for you! service@sde-web.de

Post Reply