Compiler Thinks Backslashes Are Escape Sequences

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

40 Replies - 3057 Views - Last Post: 31 March 2017 - 08:28 AM

#31 hexagod  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 242
  • Joined: 29-October 16

Re: Compiler Thinks Backslashes Are Escape Sequences

Posted 28 March 2017 - 04:07 PM

Alrighty, so I'm pretty darn close now. I just need to run powershell.exe and then have this command execute:

./move

I tried...

system("start \"powershell.exe ./move\"");


but no dice... that brings up the command prompt and at the top says powershell.exe C:\move.ps1

but nothing has run, or will run

So yep.. just need to know how to use system("start powershell.exe") with a simple command and I'll leave you guys alone :basecase:
Was This Post Helpful? 0
  • +
  • -

#32 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5825
  • View blog
  • Posts: 19,843
  • Joined: 05-May 12

Re: Compiler Thinks Backslashes Are Escape Sequences

Posted 29 March 2017 - 05:29 AM

If you really want to go down the powershell path, I suggest hosting PowerShell instead of shelling out to it.

Windows PowerShell Host Quickstart

I still feel that you are going about this the hard way by setting up a Rube Goldberg configuration where you have a C++/CLI program starting PowerShell so that PowerShell can run your PowerShell script which simply copies files.

You could simply perform the file copy yourself...
How to: Iterate Through a Directory Tree (C# Programming Guide)
How to: Copy, Delete, and Move Files and Folders (C# Programming Guide)
Was This Post Helpful? 1
  • +
  • -

#33 hexagod  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 242
  • Joined: 29-October 16

Re: Compiler Thinks Backslashes Are Escape Sequences

Posted 29 March 2017 - 09:16 AM

Nice, ty skydiver. I'll check out those resources. I agree though, I am doing this the hard way but keep in mind I was never taught to program... I started teaching myself TI-Basic back in highschool to have my Ti-83 do my tests/homework for me. I still use a pragmatic approach so I am aware I program inefficiently. I have to program in my spare time at work to make my job easier, so the approaches I take are often the only way I can make something work (without pulling my hair out).
Was This Post Helpful? 0
  • +
  • -

#34 hexagod  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 242
  • Joined: 29-October 16

Re: Compiler Thinks Backslashes Are Escape Sequences

Posted 29 March 2017 - 01:02 PM

HINSTANCE result;
result = ShellExecute(NULL, NULL, L"C:\\test.mp3", NULL, NULL, SW_SHOWDEFAULT);


Anyone ever seen this before? It threw a bunch of compiler errors when I tried to use it but I think that's what I'm looking for. Just will replace test.mp3 with my .ps1 scripts... if I can get this to work.

If you're familiar with this command ... Hollllaaaaa

Toodles
Was This Post Helpful? 0
  • +
  • -

#35 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13398
  • View blog
  • Posts: 53,472
  • Joined: 12-June 08

Re: Compiler Thinks Backslashes Are Escape Sequences

Posted 29 March 2017 - 01:15 PM

Have you looked up the command? Perhaps give some background information instead of just giving it a whirl?

https://msdn.microso...3(v=vs.85).aspx
https://msdn.microso...6(v=vs.85).aspx
Was This Post Helpful? 1
  • +
  • -

#36 hexagod  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 242
  • Joined: 29-October 16

Re: Compiler Thinks Backslashes Are Escape Sequences

Posted 29 March 2017 - 02:16 PM

Yeah I did, very confusing to me. The MSDN pages are usually a bit above my level but I'll check it out. Was just wondering if anyone had experience using shellexecute() at all and had some good resources. MSDN is a great resource but I usually just can't understand them.
Was This Post Helpful? 0
  • +
  • -

#37 hexagod  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 242
  • Joined: 29-October 16

Re: Compiler Thinks Backslashes Are Escape Sequences

Posted 29 March 2017 - 03:05 PM

anyone know what this means? 1>MyForm.obj : error LNK2020: unresolved token (0A00069F) "extern "C" struct HINSTANCE__ * __stdcall ShellExecuteW(struct HWND__ *,wchar_t const *,wchar_t const *,wchar_t const *,wchar_t const *,int)" ([email protected]@$$[email protected]@[email protected]@[email protected])
1>FileMove.obj : error LNK2028: unresolved token (0A00063A) "extern "C" struct HINSTANCE__ * __stdcall ShellExecuteW(struct HWND__ *,wchar_t const *,wchar_t const *,wchar_t const *,wchar_t const *,int)" ([email protected]@$$[email protected]@[email protected]@[email protected]) referenced in function "private: void __clrcall Utility::FileMove::button1_Click(class System::Object ^,class System::EventArgs ^)" ([email protected]@[email protected]@$$FA$AAMXP$[email protected]@@P$[email protected]@@Z)
1>FileMove.obj : error LNK2019: unresolved external symbol "extern "C" struct HINSTANCE__ * __stdcall ShellExecuteW(struct HWND__ *,wchar_t const *,wchar_t const *,wchar_t const *,wchar_t const *,int)" ([email protected]@$$[email protected]@[email protected]@[email protected]) referenced in function "private: void __clrcall Utility::FileMove::button1_Click(class System::Object ^,class System::EventArgs ^)" ([email protected][email protected]@@$$FA$AAMXP$[email protected]@@P$[email protected]@@Z)
1>MyForm.obj : error LNK2001: unresolved external symbol "extern "C" struct HINSTANCE__ * __stdcall ShellExecuteW(struct HWND__ *,wchar_t const *,wchar_t const *,wchar_t const *,wchar_t const *,int)" ([email protected]@$$[email protected]@[email protected]@[email protected])
1>C:\Users\xxxx\Desktop\Compiled Software\Versions\Utility (v2 Backup) - Copy (2)\Release\Utility.exe : fatal error LNK1120: 3 unresolved externals

Is it telling me I need to make a class? I've included
#include <string>
#include <fstream>
#include <iostream>
#include <istream>
#include <ostream>
#include <windows.h>
#include <stdlib.h>
#include <msclr\marshal_cppstd.h>
#include <shellapi.h>
#include <ShlObj.h>
#include <shlwapi.h>
#include <objbase.h>




Was This Post Helpful? 0
  • +
  • -

#38 hexagod  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 242
  • Joined: 29-October 16

Re: Compiler Thinks Backslashes Are Escape Sequences

Posted 29 March 2017 - 03:24 PM

BAM GOT IT BOOOOOOOOOOYAhhhhh BABY

Aight.. .so .. as promised.. here's how you do it.

First off, this only works in x86 for some reason

Second, you have to go project > linker > input >additional dependencies >select inherit from parent and make sure all of the sys32 .dlls populate

(kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) )

Hit OK

Include everything in the above post

Now..

Here's a quick example of what I got to work.. using shellexec which will allow you to run anything out of C++/.NET
		HINSTANCE result;
		result = ShellExecute(NULL, NULL, L"C:\\test.mp3", NULL, NULL, SW_SHOWDEFAULT);
		if ((int)result <= 32)
			std::cout << "Error!\nReturn value: " << (int)result << "\n";


code is from some online G

Good luck! w00p w00p :happybday: :bananaman:

Oh and BTW just change C:\\test.mp3 to whatever you want to run [filepath or .lnk]

You will have to set your default program in the shell though, or it won't open right

Oh so this only works because the dependencies are all 32bit?
Was This Post Helpful? 0
  • +
  • -

#39 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5825
  • View blog
  • Posts: 19,843
  • Joined: 05-May 12

Re: Compiler Thinks Backslashes Are Escape Sequences

Posted 29 March 2017 - 04:08 PM

Yes. You need to make sure the you link in the 64 bit versions of the libraries if you want 64 bit executables. You'll also have to ensure that you don't accidentally have any C defines that is forcing x86 instead of x64.
Was This Post Helpful? 1
  • +
  • -

#40 hexagod  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 242
  • Joined: 29-October 16

Re: Compiler Thinks Backslashes Are Escape Sequences

Posted 30 March 2017 - 09:08 AM

So hopefully I can get the whole package wrapped up into a beta today. If I can get it working: I'll try to post the full code so others could use this (if you don't mind shotty code) muahahha.
Was This Post Helpful? 0
  • +
  • -

#41 hexagod  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 242
  • Joined: 29-October 16

Re: Compiler Thinks Backslashes Are Escape Sequences

Posted 31 March 2017 - 08:28 AM

Hey now I've got another issue (sorry I'm needy): so when I run my .ps1 file by double clicking on it... it works fine but when I try and use shellexecute it's tripping the GP at my work and not allowing th script to run. I'm running PS all locally though so is there any way to bypass this? I tried adding Set-Executionpolicy Unrestricted to the script but it didn't seem to make any difference... do you guys know how to run a Powershell scriptwith special permissions using theshellexec?
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3