Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SharePoint > SharePoint Development
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SharePoint Development Programming and development for SharePoint Portal Server and Windows SharePoint Services
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SharePoint Development section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 17th, 2007, 12:24 PM
Registered User
Join Date: Aug 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Running a shell command in sharepoint.

Im trying to invoke a java barcode generator on one of my pages. If
run within an asp.net page it runs perfectly, if I "echo" the command
line generated and run it within a command shell, it runs perfectly,
if I run this within sharepoint I get zilch in the directory and no
error message. Ive tracked it down to the process execution, which
returns True. Can someone please shed some light on my code or give
me some examples on how YOU did it? Thanks in advance.

Some of the code :

        protected void Genbarcode(string CEPNumber)
                string WorkingDirectory;
                WorkingDirectory = "C:\\";

                string strBarcodeDirectory;
                strBarcodeDirectory = "[barcodeDIR]";
                //strBarcodeDirectory = "C:\\Program Files\\Common Files\\Microsoft
Shared\\web server extensions\\12\\TEMPLATE\\IMAGES\\SS\\Barcodes\\";

                string strJavaLoc;
                strJavaLoc = "C:\\Program Files\\Java\\jre1.6.0_02\\bin\\java.exe";

                string strBarcodeLoc;
                strBarcodeLoc = "-cp " + WorkingDirectory + "barcode4j-1.0\\build\barcode4j.jar;" + WorkingDirectory + "barcode4j-1.0\\lib\\avalon-
framework-4.1.5.jar;" + WorkingDirectory + "barcode4j-1.0\\lib\commons-cli-1.0.jar org.krysalis.barcode4j.cli.Main -o \"" +
strBarcodeDirectory + CEPNumber + ".png\" -f png --bw -d 600 -s
code128 \"" + CEPNumber + "\"";

                if (!FileExists(strBarcodeDirectory, CEPNumber + ".png"))
                                Run_Shell_Command(strJavaLoc, strBarcodeLoc);
                        catch (Exception ex)

        protected void Run_Shell_Command(string FileName, string Arguments)
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.EnableRaisingEvents = false;
                proc.StartInfo.FileName = FileName;

                if (Arguments.Length > 0)
                        proc.StartInfo.Arguments = Arguments;

                catch (Exception ex)

        protected bool FileExists(string strDirectory, string strFilename)
                        string fileLoc = strDirectory + strFilename;
                        FileInfo fi = new FileInfo(fileLoc);
                        return (fi.Exists);
                catch (Exception ex)
                        return (true);

Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell command under Windows Vista mileski Access VBA 0 April 16th, 2007 10:17 AM
how to alter shell command to direct where window dgr7 Beginning VB 6 4 March 16th, 2007 02:00 PM
Shell Command doesn't respond in W2K machines kan_lenny Pro VB.NET 2002/2003 0 September 13th, 2006 07:36 PM
Shell command execution error toshesh VB Databases Basics 3 January 7th, 2006 03:17 AM
Shell command refusing to work underscore10304 Access VBA 4 October 20th, 2004 02:12 PM

All times are GMT -4. The time now is 10:31 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.