Powershell Coding - Path and Variable Issues
Hello, I am working with a powershell program to copy a file off of my flash drive and into the startup file of what ever user is logged onto that computer.
My code is
powershell -command { }; $a=[Environment]::UserName ; $c='E:\Other\Programs\program2.bat' ; $b='C:/Users/$a/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup' ; copy $c $b ; start-sleep 30
It just uses the $a instead of the variable name... if I change it to " " it says that the path cannot be found a cmd or operable program. and it stops at Windows/Start
can anyone help me out with this?
For anyone wondering why I am using powershell -command instead of ISE is because I am running it from a .bat file because the execution policy is set to restricted AND CANNOT BE CHANGED.
Try
$b="\"C:/Users/$a/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup\"";
You must use double quotes for Powershell to use the value of $a - See:
https://technet.microsoft.com/en-us/library/hh847740.aspx
and you need an extra set of quotes escaped with a backslash to cope with the space in "Start Menu" - See:
http://www.tinyint.com/index.php/2011/04/20/escaping-quotes-in-powershell-exe-command-via-command-prompt/
In future (or if this is not working for you) please direct questions about Powershell to this forum
https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG
Similar Messages
-
Hi,
Problem Description:
After installing my new product version, when user does log-off and log in again into admin account
or switch from admin account to non-admin account, PATH environment variable shows incorrect path of my product (previous product version’s path) using command prompt.
It seems windows refresh issue during session changes (log off and log in / switch from Admin to
Non-admin account).
Why PATH environment variable is not refresh immediately after log off and log in again or Switch
from admin to non-admin mode?.
Please see my thread for more details http://social.msdn.microsoft.com/Forums/vstudio/en-US/445ab42c-bdff-405a-8d53-558e1b6c7d34/path-environment-variable-issue-when-user-logoff-and-login-or-switch-from-admin-to-nonadmin?forum=windowsgeneraldevelopmentissues
Also submitted bug for this in connect.microsoft.com portal.In that it has lots of information
like problem statement, Reproduction steps and Expected Results.
Bug ID: 871782
Could you please any body help me for this?. your support will be appreciated.
Thanks,
MarichamyWhy PATH environment variable is not refresh immediately after log off and log in again or Switch
from admin to non-admin mode?.
I wouldn't have any expectation of what you are doing to work the way you expect. E.g. why is the %ABC% being replaced at all? There is some help about this ambiguous scenario in the cmd help...
/V:ON Enable delayed environment variable expansion using ! as the
delimiter. For example, /V:ON would allow !var! to expand the
variable var at execution time. The var syntax expands variables
at input time, which is quite a different thing when inside of a FOR
loop.
/V:OFF Disable delayed environment expansion.
So, what's the setting for the /V: switch that your users would be using? Perhaps you should be using the ! instead of the % for your ABC variable?
Oh. There's more below where I found that...
Delayed environment variable expansion is NOT enabled by default. You
can enable or disable delayed environment variable expansion for a
particular invocation of CMD.EXE with the /V:ON or /V:OFF switch. You
can enable or disable delayed expansion for all invocations of CMD.EXE on a
machine and/or user logon session by setting either or both of the
following REG_DWORD values in the registry using REGEDIT.EXE:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\DelayedExpansion
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\DelayedExpansion
to either 0x1 or 0x0. The user specific setting takes precedence over
the machine setting. The command line switches take precedence over the
registry settings.
In a batch file the SETLOCAL ENABLEDELAYEDEXPANSION or DISABLEDELAYEDEXPANSION
arguments takes precedence over the /V:ON or /V:OFF switch. See SETLOCAL /?
for details.
If delayed environment variable expansion is enabled, then the exclamation
character can be used to substitute the value of an environment variable
at execution time.
So, I guess the essence of your "bug" will boil down to whether you
need the feature to get the result you want and the
truth of that first sentence but it certainly looks like a "can of worms" to me. ; )
HTH
Robert Aldwinckle -
Tips on avoiding hard coded paths and make a java app platform independent
HI all,
I would like to gather some tips on how to avoid hard coded file paths, which are plenty in the application I work on and which I inherited from previous programmers.
Also, when deploying to the production server, my app goes from a Windows platform to a Linux machine.
I am curious to know what tricks and tools other programmers find useful in similar contexts.
I am sure many of us would benefit from the discussion.
Thank you !Actually, Java does this for you; you can use unix-style paths and they will still work, even on Windoze. To wit:
public static void main(String[] args) {
File f = new File("/");
System.out.println(f.getAbsolutePath());
}Yields: C:\
public static void main(String[] args) {
File f = new File("/Program Files");
System.out.println(f.getAbsolutePath());
}Yields: C:\Program Files -
Photoshop CC 2014 Paths and Stroke Issues
Hi!
The first issue:
When i'm copying factor path and paste on a new layer it creates a vector mask instead of just placing vector shape, is there any solution on how to disable it? In 2013 version and older it just worked.
And the second issue:
I work with very tall documents and when I make any changes to any shape's stroke PS just moves me to the center of the document. It's really annoying. Any solutions?factor path
Auto correction can be a tricky thing, huh?
When i'm copying factor path and paste on a new layer it creates a vector mask instead of just placing vector shape,
Do you mean a plain Path?
I suppose you could select/create a Path in the Paths Panel or deselect the Layer in the Layers Panel. -
JTabbedPane and variable issue
ok so here's what I've got, it's a mess I know, everything is added and defined and such, but got cut out to make the code fit, but before I can clean it up I have to figure out what is wrong, my problem as far as I can tell is I don't know how to reference variables in gui, I think I had this problem before but I don't know how to fix it, the variable names are right, it's looking in the right class but nothing in the tab can be found from the action listener. I don't know where else to look. I'm really hoping that's the issue anyway, and not something that requires the demolition of all the code. thank you,
import java.awt.*;
import javax.swing.*;
import java.util.*;
import java.text.*;
import java.awt.event.*;
import java.io.*;
public class PoolEstimator extends JFrame
public PoolEstimator()
super( "Pool Estimator" );
DefaultListModel listModel = new DefaultListModel();
JTabbedPane tab = new JTabbedPane();
// constructing the second panel
JPanel CustInfo = new JPanel();
CustInfo.setLayout(new FlowLayout(FlowLayout.LEFT));
JLabel FirstName, LastName, Street, City, Zip, Phone, poolDepthup, poolDepthlow,
yardLength, poolLength, yardWidth, poolWidth, state;
JTextField FirstNamein, LastNamein, Streetin, Cityin, Zipin,
Phonein, poolDepthupin, poolDepthlowin, yardLengthin, poolLengthin, yardWidthin, poolWidthin;
String[] States = {"AL","AK","AS","AZ","AR","CA","CO","CT","DE","DC","FL","GA","HI","ID","IL","IN","IA",
"KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK",
"OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY"};
JComboBox State = new JComboBox(States);
FirstName = new JLabel("First Name");
LastName = new JLabel("Last Name");
Street = new JLabel("Street Address");
City = new JLabel("City");
state = new JLabel("State");
Zip = new JLabel("Zip Code");
Phone = new JLabel("Phone Number");
yardLength = new JLabel("Length of the yard.");
yardWidth = new JLabel("Width of the yard.");
poolDepthup = new JLabel("Deepest depth of the pool.");
poolDepthlow = new JLabel("Shalowest depth of the pool.");
poolLength = new JLabel("Length of the pool.");
poolWidth = new JLabel("Width of the pool.");
FirstNamein = new JTextField(20);
LastNamein = new JTextField(20);
Streetin = new JTextField(25);
Cityin = new JTextField(15);
Zipin = new JTextField(5);
Phonein = new JTextField(5);
poolDepthupin = new JTextField(2);
poolDepthlowin = new JTextField(2);
yardLengthin = new JTextField(3);
poolLengthin = new JTextField(3);
yardWidthin = new JTextField(3);
poolWidthin = new JTextField(3);
JButton Add = new JButton("Add");
CustInfo.add(Add);
tab.addTab( "New Customer Estimate", null, CustInfo, "Customer Information Page" );
getContentPane().add( tab );
setSize( 325,400 );
setVisible( true );
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);
AddButtonHandler AddNew = new AddButtonHandler();
Add.addActionListener(AddNew);
class AddButtonHandler implements ActionListener
public void actionPerformed(ActionEvent e)
try
//PoolEstimator run = new PoolEstimator();
String StateSelection = PoolEstimator.State.getSelectedItem().toString();
FileWriter AddEstimate = new FileWriter("Estimate.dat", true);
AddEstimate.write("First Name: ");
//AddEstimate.write(run.FirstNamein.getText());
AddEstimate.write("\nLast Name: ");
//AddEstimate.write(LastNamein.getText());
AddEstimate.write("\nTotal Cost: ");
//int width, length, depthupper, depthlower, SurfaceArea, Cement, Rebar, Labor, totalCost;
//width =Integer.parseInt(poolWidthin);
//length = Integer.parseInt(poolLengthin);
//depth = (Integer.parseInt(poolDepthupin) + Integer.parseInt(poolDepthlowin))/2;
//SurfaceArea = (width * depth)*2+(length*depth)*2;
//Cement = SurfaceArea * 3;
//Rebar = SurfaceArea *5;
//Labor = SurfaceArea%10*18;
//totalCost = Cement+Rebar+Labor;
//AddEstimate.write(totalCost);
AddEstimate.write("\n,");
AddEstimate.close();
//run.listmodel.add(run.FirstNamein + run.LastNamein);
catch(IOException r)
JOptionPane.showMessageDialog(null,r.getMessage(),"ERROR",2);
public static void main( String args[] )
PoolEstimator run = new PoolEstimator();
run.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}Im a newbie but Im finding it hard to understand what your talking about.
Could you explain what your program is suppose to do and what you want it to do that it isnt doing yet because you dont know how?
Plus I just thought I would mention this incase but its easier to use the following JFrame method instead of adding a window adaptor:
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); -
NavigateToUrl and variables issue
I'm having an issue passing variable to a local html file using an installed Air application. This works up to a point. I have a web page with a swf that passes a string Array to the Air app that is already installed on the desktop. I know the string arrray gets passed because I can parse it within the Air aplication. I run into a problem when I try to launch a local html file with the string array set as variables in the URLrequest. The launch.html sits in the same directory where the Application is installed. I have no problem launching the file, it just doesn't pass along the variables with it. Any clue as to why this isn't working would save me from disaster.
Here is the code:
import flash.events.Event;
import flash.external.ExternalInterface;
import flash.net.URLRequest;
import flash.desktop.NativeApplication;
import flash.events.InvokeEvent;
import flash.utils.*;
import flash.events.BrowserInvokeEvent;
import flash.filesystem.File;
import flash.errors.IOError;
import flash.net.URLLoader;
import flash.net.URLVariables;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequestMethod;
import flash.events.IOErrorEvent;
import flash.net.navigateToURL;
import flash.net.sendToURL;
var arguments:Array;
var dateString:String;
var indexString:String;
var videoTime:String;
var videoIndex:String;
var urlContent:String;
var urlRequester:URLRequest;
var variables:URLVariables;
NativeApplication.nativeApplication.addEventListener(BrowserInvokeEvent.BROWSER_INVOKE, onBrowserInvokeEvent);
//var currentDir:File;
function onBrowserInvokeEvent(invocation:BrowserInvokeEvent):void
arguments = invocation.arguments;
videoTime = invocation.arguments[0].toString();
videoIndex = invocation.arguments[1].toString();;
dateString = "dateString="+videoTime;
indexString="indexString="+videoIndex;
//urlContent = "launch.html"+"?"+dateString+"&"+indexString;
//currentDir = invocation.currentDirectory;
urlContent = "launch.html";
urlRequester = new URLRequest(urlContent);
variables = new URLVariables();
variables.dateString = videoTime;
variables.indexString = videoIndex;
urlRequester.data = variables;
Arguments.text=variables.toString();// outputs dateString=date&indexString=1
urlRequester.method = URLRequestMethod.GET;
var htmlLoader:URLLoader = new URLLoader(urlRequester);
//htmlLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
htmlLoader.dataFormat = URLLoaderDataFormat.TEXT;
htmlLoader.addEventListener(Event.COMPLETE, URLLoaded);
try {
htmlLoader.load(urlRequester);
// Arguments.text="Loaded";
//navigateToURL(urlRequester);
catch (error:Error) {
Arguments.text="Unable to load URL";
navigateToURL(urlRequester);
The Javascript reading the variable looks like this:
<script type="text/javascript">
var dateString;
window.onload=function()
var myQueryString=window.location.search;
// remove the '?' sign if exists
myQueryString=myQueryString.substr(1, myQueryString.length-1);
dateString=myQueryString;
function show_alert()
alert(dateString);//currently returns nothing
</script>
</head>
<body bgcolor="#ffffff" style="margin:0px">
<input type="button" onclick="show_alert()" value="Show alert box" />
Thanks in advance
DoctorNicOk, since my air application is pulling variables via BrowserInvocation the variables need to be converted to strings. So once I declare the urlVariables I need to decode them to strings.
function onBrowserInvokeEvent(invocation:BrowserInvokeEvent):void
arguments = invocation.arguments;
videoTime = invocation.arguments[0].toString();
videoIndex = invocation.arguments[1].toString();;
dateString = "dateString="+videoTime;
indexString="indexString="+videoIndex;
urlContent = File.applicationDirectory.url.substring(0, File.applicationDirectory.url.lastIndexOf("/") + 1) + "launch.html";
urlRequester = new URLRequest(urlContent);
variables = new URLVariables();
variables.dateString = videoTime;
variables.indexString = videoIndex;
variables.decode(variables.toString());
urlRequester.data = variables;
Arguments.text=variables.toString();
Thanks Again. -
Library paths and environment variables
Hello,
I am using 10g AS 9.0.4 on a Unix system.
I am trying to convert an old JSP web application to work with 10g. It is not an EAR/WAR file so I am manually trying to set it up under the "default-web-app" folder. It uses a number of java class files which currently reside in $J2EE_HOME/default-web-app/WEB-INF/classes/mystuff.
These class files require access to a number of libraries. I foolishly believed that they would be accessible if I were to place them in the $J2EE_HOME/default-web-app/WEB-INF/lib folder, but that did not work.
I read that OC4J uses a "catch all" lib directory at $J2EE_HOME/applib. I copied the library files there and they still did not work.
Frustrated, I tried to print out the environment variables for the server - only to find that this function is not supported.
I managed to print out the library path by creating a Java class files which returns the following as a string:
System.getProperty("java.library.path");
This (when called from a JSP) prints a number of different library paths, none of which match those found listed in the $J2EE_HOME/config/application.xml file. I placed the library files in one of the paths listed by the "java.library.path" and it worked!
3 questions:
1. How do you print the server's environment variables using a JSP? This strikes me as a very useful function for sorting out library and path issues. Do a search on Google for "print environment variables OC4J" or something similar and there are no useful pages suggesting how this can be done.
2. Why are the default library paths different on the server than to those specified in application.xml?
3. How do I change the LD_LIBRARY_PATH (or any environment variable for that matter)? I have tried adding the following line to $ORACLE_HOME/Apache/Jserv/etc/jserv.properties without success:
wrapper.env=LD_LIBRARY_PATH=/my/custom/library/path
Any help you can offer would be most appreciated.>
Thanks very much for a such a comprehensive response
- it has helped answer a lot of questions, especially
being able to print out the system properties. That
will be really useful!
No worries at all Rob.
The main hurdle is that the libraries are indeed
native (*.so) libraries. I hadn't considered that
until you pointed it out in your message. Can I
assume, then, that $J2EE_HOME/applib and
$J2EE_HOME/default-web-app/WEB-INF/lib are only
designed to handle Java's .JAR librares? That would
explain why placing the native libraries in there
didn't work, but is there a way of getting such
native libraries recognised and bundled up in a
WAR/EAR file?
Yep, that's it.
Our proprietary applib and the servlet specs web-inf/lib are only dealing with Java archives.
The J2EE specs don't cover how to deal with native libs like this.
Now I've NEVER EVER tried it, but it's worth a shot of at least trying -- for simplified packaging purposes, what you may be able to do is to distribute the .so's within the web-inf/lib -- and then just set that directory (where's its realized on the server after the app is deployed) to be referenced witihn the LD_LIBRARY_PATH. I'd expect our deployment manager will just ignore files it doesn't know about, so arguably you should be able to at least distribute them with the standard archive.
You'll need to specifically set the LD_LIBRARY_PATH as a separate task outside of the deployment operation though.
>
This is where things get a bit weird, and is partly
my fault during the installation of 10g AS.
We already had an existing installation of Oracle 10g
Database (10.1.0) at $ORACLE_HOME under the user
"oracle". I logged in as the user "oracle" to install
the Application Server into a different location (In
this case, "$ORACLE_HOME/../ias10g_9.0.4" - let's
call this $IAS_HOME). So there is no separate user
account for Oracle Database and Application Server
(and hence no separate $LD_LIBRARY_PATH).
If I log into UNIX as the user "oracle" and echo the
LD_LIBRARY_PATH, I get the following directories:
$ORACLE_HOME/lib
/usr/openv/netbackup/bin
/usr/dt/lib
/usr/lib
I use this user to do "opmnctl stopall" and "opmnctl
startall". If I then print out the library path from
a JSP using
"System.getProperty("java.library.path");", I get the
following paths:
$IAS_HOME/jdk/jre/lib/sparc/server
$IAS_HOME/jdk/jre/lib/sparc
$IAS_HOME/jdk/jre/../lib/sparc
$IAS_HOME/opmn/lib
$IAS_HOME/lib
$IAS_HOME/usr/lib
Which is totally different to those listed by
$LD_LIBRARY_PATH at the command line, which means
they must be coming from somewhere else.
It gets worse - my application is trying to call a
native library that is only present in the
$ORACLE_HOME/lib32 directory (libclntsh.so.10.1), so
unless I can include this path in the
"java.library.path" on the Applicaiton Server, then
my program will not work.
So, how do I change the "java.library.path" when the
values aren't coming from $LD_LIBRARY_PATH in the
first place?
The utility $IAS_HOME/opmn/bin/opmnctl is actually a shell script.
It has this section which sets the LD_LIBRARY_PATH:
if [ -z "$LD_LIBRARY_PATH" ]
then
LD_LIBRARY_PATH=$ORACLE_HOME/opmn/lib:$ORACLE_HOME/lib ; export LD_LIBRARY_PATH
else LD_LIBRARY_PATH=$ORACLE_HOME/opmn/lib:$ORACLE_HOME/lib:${LD_LIBRARY_PATH} ; export LD_LIBRARY_PATH
fi
So if you have an existing LD_LIBRARY_PATH env var set, it should just be putting its paths onto the front of it.
What you could try as a quick test is to edit the opmnctl script (after taking a backup of course) and either appending the path you need to it, or just add some debug statements to output the LD_LIBRARY_PATH value it ends up setting so you can try and work out what's causing it.
I expect these other entries:
$IAS_HOME/jdk/jre/lib/sparc/server
$IAS_HOME/jdk/jre/lib/sparc
$IAS_HOME/jdk/jre/../lib/sparc
are coming from the JRE when it is launched, in probably a similar manner to our opmn entries.
I really appreciate your help, and I bet if anyone
can answer these questions, you can! ;-)
You're very welcome.
cheers
-steve- -
Get (variable) file path and name in a text element
How do you get the (variable) file path and name in a text element (label) in LCD? If you save the PDF and afterwards relocate it, it should update the values. Is that actually possible?
Does anyone have any advice on this issue?
Thanks in advance,
Zack H. -
So my ultimate goal is to export emails after a specific length of time as a .msg and then upload them to sharepoint for archival purposes.
My issue is all the examples I find never seem to work for me. I use PowerGUI for my ISE, I have powershell 2.0 and Outlook 2007 SP3
So for example, when I try something very simple according to the scripting guy
Reference, I try this line of code:
[Reflection.Assembly]::LoadWithPartialname("Microsoft.Office.Interop.Outlook") | out-null
[enum]::GetNames("Microsoft.Office.Interop.Outlook.OlDefaultFolders")
This should list the enums used to point to the different folders in outlook....here are some of them:
olFolderDeletedItems
olFolderOutbox
olFolderSentMail
olFolderInbox
olFolderCalendar
olFolderContacts
olFolderJournal
When I run it, either PowerGUI or straight in the console I receive the following error:
Cannot convert argument "0", with value: "Microsoft.Office.Interop.Outlook.OlDefaultFolders", for "GetNames" to type "System.Type": "Cannot convert the "Microsoft.
Office.Interop.Outlook.OlDefaultFolders" value of type "System.String" to type "System.Type"."
At C:\Users\clayman\AppData\Local\Temp\ceb3eca9-5cf1-4dd2-92aa-c2c29d3ca438.ps1:2 char:17
+ [Enum]::GetNames <<<< ("Microsoft.Office.Interop.Outlook.OlDefaultFolders")
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
Truth be told, no matter what sample I try they all fail, for instance try and run this function (yet another scripting guy article)
Function Get-OutlookInBox
Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null
$olFolders = "Microsoft.Office.Interop.Outlook.olDefaultFolders" -as [type]
$outlook = new-object -comobject outlook.application
$namespace = $outlook.GetNameSpace("MAPI")
$folder = $namespace.getDefaultFolder($olFolders::olFolderInBox)
$folder.items |
Select-Object -Property Subject, ReceivedTime, Importance, SenderName
And this one fails with:
Add-Type : Could not load file or assembly 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dep
endencies. The system cannot find the file specified.
At C:\Users\clayman\AppData\Local\Temp\51f81593-6a0f-4261-9888-5499432508e7.ps1:3 char:10
+ Add-Type <<<< -AssemblyName "Microsoft.Office.Interop.Outlook" | Out-Null
+ CategoryInfo : NotSpecified: (:) [Add-Type], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.AddTypeCommand
Exception calling "GetDefaultFolder" with "1" argument(s): "Value does not fall within the expected range."
At C:\Users\clayman\AppData\Local\Temp\51f81593-6a0f-4261-9888-5499432508e7.ps1:8 char:39
+ $folder = $nameSpace.getDefaultFolder <<<< ($olFolders)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
If I change:
Add-Type -AssemblyName "Microsoft.Office.Interop.Outlook" | Out-Null
To:
[Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Interop.Outlook") | Out-Null
The first error goes away, but the second one remains. What the heck am I doing wrong?
If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.
Don't Retire TechnetHi,
How about change
$folder = $namespace.getDefaultFolder($olFolders::olFolderInBox)
to
$folder = $namespace.getDefaultFolder($olFolders.olFolderInBox)
Please test it.
Regards,
Yan Li
TechNet Subscriber Support
If you are
TechNet Subscription
user and have any feedback on our support quality, please send your feedback
here.
Cataleya Li
TechNet Community Support -
Very interesting and quizzical issue in JNI COding.
HI All,
i've been facing a really frustrating, interesting and mindwrenching issue in my native code. Here is a background.
1. I was given a thirdparty ACtiveX OCX file that needed to be called through JAva.
2. I wrote a C++ JNI wrapper to call the methods of the activex object.
3. I first initialize the object, set the relevant parameters (sent from java) and then call the method I need.
4. For every record, I need to perform step 3. NOw, I am ryuning batch loads. THE code works fine for 9500 records. BUt, once the record count reaches 9885, I get a pop-up error from the activeX OCX control. I've not coded that pop-up. It comes out of the blue.
I initially thought that it could be a memory issue, but even after doubling my VM Memory allocation, I get the error. Its not a data issue, because the reocrd that causes the issue, if I run the code just for that single record, it works fine.
Below is the implemetnation of the C++ code. LEt me know if I'm doign somethign wrong or if someone has seen something like this happen before. WHAt is baffling is that it works smoothly for less records. When the pop up appears, no exception is caught on the native side also.!!!
Does java set aside some memory specfic for native libs and that is exhausted after 9885?
I'm running on windows, so is it possible to trace the internal malloc and release within the dLL?
ANy thoughts and ideas will help. I've been struggling for about three days now. ALso, do you know of a good C++ forum that i could post this question?
#include "stdafx.h"
#include "jni.h"
#import "thirdparty.ocx" raw_native_types
JNIEXPORT jstring JNICALL Java_org_nik_integration_test_Exporter_saveAsImage
(JNIEnv * env, jobject obj, jint height, jint width , jstring fileName, jstring encryptionKey, jshort encryptionAlgorithm, jstring encryptedImage, jshort imageType)
const char* fName = NULL;
const char* encryptionKeyc = NULL;
const char* encImgc = NULL;
ThirdPartyLib::_DTPPtr tpptr = 0;
HRESULT hres = 0;
try
hres = ::CoCreateInstance(__uuidof(ThirdPartyLib::TP),NULL,CLSCTX_ALL, __uuidof(ThirdPartyLib::_DTP), (void**)&tpptr);
//Retrieve values sent from Java
fName = env->GetStringUTFChars(fileName,0);
encryptionKeyc = env->GetStringUTFChars(encryptionKey,0);
encImgc = env->GetStringUTFChars(encryptedImage,0);
tpptr->Key = _com_util::ConvertStringToBSTR(encryptionKeyc);
tpptr->Algorithm = encryptionAlgorithm;
tpptr->Img = _com_util::ConvertStringToBSTR(encImgc);
tpptr->SaveUnencrypted(width, height,_com_util::ConvertStringToBSTR(fName) , 1);
catch(_com_error &e)
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
printf( "Exception thrown for classes generated by #import" );
printf( "\tCode = %08lx\n", e.Error());
printf( "\tCode meaning = %s\n", e.ErrorMessage());
printf( "\tSource = %s\n", (LPCTSTR) bstrSource);
printf( "\tDescription = %s\n", (LPCTSTR) bstrDescription);
// Errors Collection may not always be populated.
if( FAILED( hres ) )
printf( "*** HRESULT ***" );
return NULL;
__finally
tpptr->Release();
tpptr = NULL;
//Release memory - java specific
env->ReleaseStringUTFChars(encryptionKey, encryptionKeyc);
env->ReleaseStringUTFChars(ink, inkc);
env->ReleaseStringUTFChars(fileName, fName);
}Well you have now demonstrated conclusively that it has nothing to do with JNI.
It is either a bug with that component and/or you are using it incorrectly. Solutions to either of those would come from the source of that component, which would be somewhere besides here.
If it was a bug then you might find a way around it by doing one of the following
1. Try variations of use (options, parameters, whatever.)
2. Determine if you can solve your problem by only processing 5000 entries at a time (where 5000 chosen just to be significantly lower than the limit you have already found.) If that works then you can solve the problem by using a restartable executable that wraps the component. -
Multiple oracle homes on Windows and the "Path" environment variable
Hi There,
We have a windows 2003 database server that has few databases running oracle 10.2.0.3. We are installing oracle 11.2.0.1 on the box as well, and we were wondering, which binaries should come 1st in the path environment variable? and how does this effect the working oracle environment?
Going to the oracle home selector and swapping the 2 oracle homes around will have the same effect on the windows path variable - which will treat the 1st oracle home to be the default home - are there any general rules reg. multiple oracle homes on a server and the default home?
Should the earlier version of oracle always proceed the newer one (i.e. c:\oracle\product\10.2.0.3\bin;c:\oracle\product\11.2.0.1\bin) or should the newer oracle version comes 1st as newer oracle versions are usually backward compatible?
Your thoughts are highly appreciated.
ThanksThat isn't going to happen.
If you install 11.2 last it will appear in the PATH variable first
If you don't want that you need to Oracle Home Selector utility in the Installer to change it.
Obviously, as usual, all of this is documented.
Sybrand Bakker
Senior Oracle DBA -
Environment variable PATH and Sql*Plus
Hi all,
i have a problem with sqlplus.
It might seem not to be able to read the path environment variable.
I need to launch some sqls without typing their path (to put the path i should modify morre than 300 shell scripts), e.g.: @script.sql.
My shell scripts are invoked by the database using java.
Inside the shell scripts we have commands like "sqlplus -silent <login> @script.sql [parameters]"
So if sqlplus is not able to read the PATH environment variable, the command hangs waiting for something to do without the chance to close it.(it is silent).
I run RDBMS v8.1.7 on compaq tru64 Unix.
Can someone help me??
Thanks in advance.
Marco - Milan, ItalyWhere do I set SQL*Plus SQLPATH variable??As every other unix environment variable - either in your profile or in your current shell whatever you like
Is this the PATH where SQL*Plus searches for .sql
files??SQL*Plus searches for your files in your current directory, and then the directories you specify with the SQLPATH environment variable.
SQL*Plus searches this colon-separated list of directories in the order they are listed. -
Powershell IE autostart and maximization crashes
Hello,
For starters i would like to say that i am really new in powershell and scripting itself, but i hope i have legit problem that someone could help me to solve.
I`m trying to create powershell script that starts Internet Explorer and maximizes than periodically checks if IE is till running starts it if it`s not, and if it is started then maximizes it if if its not. (everything that is seen in this script i have
scrapped from your forum and kind of tried to put it together.
Here is the script:
for (;;) {
$processToCheck = "iexplore"
$process = Get-Process $processToCheck -ErrorAction SilentlyContinue
If (!($process)) {
$ie = New-Object -ComObject InternetExplorer.Application
$ie.Visible = $true
$ie.Navigate("www.google.com")
$sw = @'
[DllImport("user32.dll")]
public static extern int ShowWindow(int hwnd, int nCmdShow);
$type = Add-Type -Name ShowWindow2 -MemberDefinition $sw -Language CSharpVersion3 -Namespace Utils -PassThru
$type::ShowWindow($ie.hwnd, 3) # 3 = maximize
start-sleep -s 5
else
{$sig = '[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
Add-Type -MemberDefinition $sig -name NativeMethods -namespace Win32
$hwnd = @(Get-Process iexplore)[0].MainWindowHandle
# Maximize window
[Win32.NativeMethods]::ShowWindowAsync($hwnd, 3)
start-sleep -s 5
Now about my issue. This script seems to do the trick but not every time. Sometimes if i just start it it starts IE normally and in 5 secs maximizes it and after that i can minimize or just change screen size and it will properly maximize. Issues start if
i close IE and it has to reopen. From time to time IE hangs. Everything lese in background works and i can stop my PS script from executing but IE stays Hanged till i kill it through Task manager Alt+F4 or any other way.
I tried to run the first part with plane start-process iexplore -wait and it does not hang.
As much as i understand (i might be terribly wrong though) IE is not fully started before rest of the code is executed and that leads to IE hang but -wait command does not help since it waits till IE is closed.
I hope i have made my point clear.
UPD1: Sometimes it hangs from the beggining
Best regards
BoRdoI did something like this a while back using a WMI event sink in a VBScript script...
' If IE isn't running, start it maximized.
' Restart IE automatically if it closes.
' Global constants
Const ERROR_FILE_NOT_FOUND = 2
Const SW_SHOWMAXIMIZED = 3
' Global objects
Dim FSO, WshShell, SWbemServices, EventSink
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
Set SWbemServices = GetObject("winmgmts:{impersonationlevel=impersonate}" _
& "!root/CIMV2")
Set EventSink = WScript.CreateObject("WbemScripting.SWbemSink", "EVENTSINK_")
' Global variables
Dim IEProcessID
' Returns full path and filename of Internet Explorer (32-bit on x64).
Function GetIEPath()
Dim WshEnvironment, ProgramFiles, IEPath
Set WshEnvironment = WshShell.Environment("PROCESS")
If WshEnvironment.Item("ProgramFiles(x86)") = "" Then
ProgramFiles = WshEnvironment.Item("ProgramFiles")
Else
ProgramFiles = WshEnvironment.Item("ProgramFiles(x86)")
End If
IEPath = FSO.BuildPath(ProgramFiles, "\Internet Explorer\iexplore.exe")
If Not FSO.FileExists(IEPath) Then
WScript.Echo "Internet Explorer not found"
WScript.Quit ERROR_FILE_NOT_FOUND
End If
GetIEPath = IEPath
End Function
' Returns process ID of iexplore.exe, or -1 if not found.
Function GetIEProcessID()
Dim Result, Collection, Item
Result = -1
Set Collection = SWbemServices.ExecQuery("select ProcessId from " _
& "Win32_Process where Name='iexplore.exe'")
For Each Item In Collection
Result = Item.ProcessId
Exit For
Next
GetIEProcessID = Result
End Function
' Starts IE maximized and returns its process ID.
Function StartIE()
Dim ProcStartup, Process, Result, ProcessID
Set ProcStartup = SWbemServices.Get("Win32_ProcessStartup").SpawnInstance_()
ProcStartup.ShowWindow = SW_SHOWMAXIMIZED
Set Process = SWbemServices.Get("Win32_Process")
Result = Process.Create(GetIEPath, Null, ProcStartup, ProcessID)
If Result <> 0 Then
WScript.Echo "Unable to start Internet Explorer; WMI error " & CStr(Result)
WScript.Quit Result
End If
StartIE = ProcessID
End Function
' WMI asyncronous event sink: If IE closes, start it again.
Sub EVENTSINK_OnObjectReady(ByVal ObjectEvent, ByVal Context)
If ObjectEvent.TargetInstance.ProcessId = IEProcessID Then
IEProcessID = StartIE()
End If
End Sub
' Execute query to receive events asyncronously.
SWbemServices.ExecNotificationQueryAsync _
EventSink, "select * from __InstanceDeletionEvent within 1 where " _
& "TargetInstance isa 'Win32_Process'"
' If IE isn't running, start it and get its process ID.
IEProcessID = GetIEProcessID()
If IEProcessID = -1 Then
IEProcessID = StartIE()
End If
' Loop forever. The event sink will restart IE if it closes.
Do While True
WScript.Sleep 100
Loop
-- Bill Stewart [Bill_Stewart] -
IBM QMF 9.1 - How to handle hard coded .ini and .xml files
Hi All,
I've been trying to sequence ibm QMF for workstation. The app has 2 gotchas in that there seems to be 2 config files that it uses to execute an eclipse environment.
C:\Program Files (x86)\IBM\DB2 Query Management Facility\QMF for Workstation\configuration\config.ini
has a path statement which cannot be resolved
[email protected]/Application Data/IBM/QMF for Workstation/settings
C:\Users\%USERID%\AppData\Roaming\IBM\QMF for Workstation\repositories.xml
has several path statements looking back at the program files directory (note I sequenced on an x86 machine, it doesn't work on x86 either)
<location id="1517929232917419009" url="C:\Program Files\IBM\DB2 Query Management Facility">
<property name="base-dir" value="C:\Program Files\IBM\DB2 Query Management Facility"/>
I can make the app work by copying in the directories to the PC and then editing the config files and changing the paths to something inside the app-v package.
What methods do folks use to get around this???With hard-coded paths like that, you need to sequence on the same 'bitness' as the client.
If the app is trying to read or write to that location under program files, then it should be redirected to the virtualised paths.
VFS issues can happen if:
The exe queries Windows to ask where it is running from, gets the virtual location, and finds an unexptected mismatch to the location expected in the config file.
The application uses WMI (or some other external service) to query if the folder exists, which then cannot find the folder.
You sequenced to the PVAD, as a result the folder is hidden in the virtual file system, and the app cannot see the install folder.
If you sequenced to the PVAD, I would try again setting a dummy PVAD location - or just sequence it with SP3.
If that does not help, does just creating those empty directories in the real file system do the trick?
If none of the above help, then creating a symbolic link under program files pointing to the virtual location may work.
Dan Gough - UK App-V MVP
Blog: packageology.com
Twitter: @packageologist
LinkedIn -
About Replacement Path, Text Variables & Cusomer Exit?
Hi
Please explain along with examples youwhen we use Replacement Path
Text Variables and
Customer Exit
Please search the forum before posting a thread
Edited by: Pravender on Apr 18, 2011 3:48 PMHi,
1. Customer EXIT :
Business Scenario:
The business department wants to check if the orders from the customers for a certain week (e.g. 6 weeks from now) are already transmitted into their system. Therefore they run a report with a variable, that is calculated automatically.
Note: Of course this is not the only suitable solution, but it will show you how the exit works.
Step by Step Solution:
A.You should create a variable on the info object 0CALWEEK like this:
1.Technical Name: WS_FWEEK
2.Description: Workshop Future Week
3 Interval
5.Mandatory variable entry
6.Processing: Customer Exit
7.NOT ready for input
B.Call transaction CMOD for the definition of the customer exit.
C.Create a new project, maintain the short text and assign a development class.
D.Go to Enhancement Assignments and assign RSR00001. Press the button components to continue.
E.Double-click on EXIT_SAPLRRS0_001.
F.For documentation place the cursor an RSR00001 and use the menu GoTo => Display documentation.
G.Then double-click on ZXRSRU01.
H. If the include does not exist, you have to create it; assign a development class and a transport request
Enter this code:
INCLUDE ZXRSRU01 *
data: l_idx like sy-tabix,
workdate(8) type d,
futureweek(6) type c.
DATA: L_S_RANGE TYPE RSR_S_RAGESID.
case I_vnam.
when u2018WS_FWEEKu2019.
if i_step = 2 u201C after pop-up
Calculate Current day plus 6 weeks:
workdate = sy-datum + 42 .
Calculate the week of this day
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = workdate
IMPORTING
WEEK = futureweek
EXCEPTIONS
DATE_INVALID = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
l_s_range-low = futureweek.
l_s_range-high =
l_s_range-sign = 'I'.
l_s_range-option = 'EQ'.
append l_s_range to l_t_range.
p_subrc = 0.
ENDIF.
ENDCASE.
I.Save and activate the codie
J.Activate the project. (Very important!)
K. Define a query using the above created variable.
L.For displaying the variable values in the executed query you also may define two text variables. These should, if necessary, be able to show the lower and the upper value calculated by the customer exit.
2 Replacement Path :
Example for filling variable values depending on an other variable /
Deriving one variable value from another variable
Business scenario.
A query should show in one column the value for one period. The period should be entered by the user. In the second column the accumulated vale from the beginning of the year to the period of the first column should be displayed. The InfoCube contains only the InfoObject 0CALMONTH (Month/Year) and not single InfoObjects for period and year.
Solution:
For this scenario we need four variables: two variables for the column text and two variables for the period values. One of these period variables is defined as a variable with a customer exit
Step by Step Solution:
Create an input variable u201CMONTHu201D (you need this specific information for the coding example below). The variable is based on the InfoObject 0CALMONTH. Set the following attributes:
Single Value
Ready for input
Mandatory variable entry
Create a variable u201CCUMMONTHu201D (you need this specific information for the coding example below) with a customer exit as a processing type. The variable is based on the InfoObject 0CALMONTH. Set the following attributes:
Interval
NOT ready for input!
Mandatory variable entry
Create two text variables. Both variables use the u201CReplacement Pathu201D as processing type. The first text variable is filled with the text from the u201Cfrom valueu201D. The second is filled with the text from the u201Cto valueu201D.
Enter this code
INCLUDE ZXRSRU01 *
DATA: L_S_RANGE TYPE RSR_S_RAGESID.
DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.
case I_vnam.
when u2018CUMMONTHu2019.
if i_step = 2 u201C after pop-up
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = u2018MONTHu2019.
CLEAR L_S_RANGE.
l_t_range-low = loc_var_range(4). u201Cgetting current year
l_t_range-low+4(2) = u201801u2019 u201Csetting 1st period in cur. year
l_t_range-high = loc_var_range-low u201Chigh value=input value
l_t_range-sign = 'I'.
l_t_range-option = 'BT'.
append l_s_range to e_t_range.
exit.
endloop.
endif.
endcase.
Save and activate the code.
Activate the project.
Define a query containing all the variables.
Regards
CSM Reddy
Maybe you are looking for
-
BO 3.1 SP3 - "Execution Time" query for reports has been changed?
Hi, We can see BO XI 3.1 SP3, the execution time for a report is faster. is it using BOXI Enterprise APIs to determine the start and end? How is calculated? thx aurora
-
Me22 Problem when change price for Conditions
Hi, I have a strange problem about ME22. I explain the problem step by step: 1) Enter ME22 with PO 2) Select one PO Item (ex. the first item) and click on Services 3) Select First Position. 4) Click on Conditions and Change the Price. 5) Back to Serv
-
Active document must to move one location
Hi When i open file in Original location that file need to be move in desktop. When file was moved Original location file must be delete. File must be move in one location to another loaction. Please help me.
-
Just updated to 10.8.1 and can no longer use Dragon Dictate 2.5.2 (It won't open) or Alarm Clock 2.4.5 (Won't open) or LineIn 2.0.3 (not opening) and I haven't even tried other applications besides my browser. Very frustrating as I have never had a p
-
Add new account assgnment category in IMG
Hi, I want to know the step by stop process to add the new Account assignment category in IMG settings. Please provide the complete step by step process. Thanks in Advance. Regards, Kumar.